idnits 2.17.1 draft-ietf-cellar-ebml-14.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 (1 December 2019) is 1607 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) == Missing Reference: 'EBMLParentPath' is mentioned on line 1009, but not defined == Missing Reference: 'PathMinOccurrence' is mentioned on line 1020, but not defined == Missing Reference: 'PathMaxOccurrence' is mentioned on line 1020, 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 (~~), 4 warnings (==), 3 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: 3 June 2020 6 M. Bunkus 7 1 December 2019 9 Extensible Binary Meta Language 10 draft-ietf-cellar-ebml-14 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 3 June 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 (https://trustee.ietf.org/ 47 license-info) in effect on the date of publication of this document. 48 Please review these documents carefully, as they describe your rights 49 and restrictions with respect to this document. Code Components 50 extracted from this document must include Simplified BSD License text 51 as described in Section 4.e of the Trust Legal Provisions and are 52 provided without warranty as described in the Simplified BSD License. 54 Table of Contents 56 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 57 2. Notation and Conventions . . . . . . . . . . . . . . . . . . 4 58 3. Structure . . . . . . . . . . . . . . . . . . . . . . . . . . 7 59 4. Variable Size Integer . . . . . . . . . . . . . . . . . . . . 7 60 4.1. VINT_WIDTH . . . . . . . . . . . . . . . . . . . . . . . 7 61 4.2. VINT_MARKER . . . . . . . . . . . . . . . . . . . . . . . 7 62 4.3. VINT_DATA . . . . . . . . . . . . . . . . . . . . . . . . 8 63 4.4. VINT Examples . . . . . . . . . . . . . . . . . . . . . . 8 64 5. Element ID . . . . . . . . . . . . . . . . . . . . . . . . . 9 65 6. Element Data Size . . . . . . . . . . . . . . . . . . . . . . 11 66 6.1. Data Size Format . . . . . . . . . . . . . . . . . . . . 11 67 6.2. Unknown Data Size . . . . . . . . . . . . . . . . . . . . 11 68 6.3. Data Size Values . . . . . . . . . . . . . . . . . . . . 14 69 7. EBML Element Types . . . . . . . . . . . . . . . . . . . . . 15 70 7.1. Signed Integer Element . . . . . . . . . . . . . . . . . 15 71 7.2. Unsigned Integer Element . . . . . . . . . . . . . . . . 16 72 7.3. Float Element . . . . . . . . . . . . . . . . . . . . . . 16 73 7.4. String Element . . . . . . . . . . . . . . . . . . . . . 16 74 7.5. UTF-8 Element . . . . . . . . . . . . . . . . . . . . . . 16 75 7.6. Date Element . . . . . . . . . . . . . . . . . . . . . . 17 76 7.7. Master Element . . . . . . . . . . . . . . . . . . . . . 17 77 7.8. Binary Element . . . . . . . . . . . . . . . . . . . . . 17 78 8. EBML Document . . . . . . . . . . . . . . . . . . . . . . . . 17 79 8.1. EBML Header . . . . . . . . . . . . . . . . . . . . . . . 18 80 8.2. EBML Body . . . . . . . . . . . . . . . . . . . . . . . . 18 81 9. EBML Stream . . . . . . . . . . . . . . . . . . . . . . . . . 18 82 10. EBML Versioning . . . . . . . . . . . . . . . . . . . . . . . 18 83 10.1. EBML Header Version . . . . . . . . . . . . . . . . . . 19 84 10.2. EBML Document Version . . . . . . . . . . . . . . . . . 19 85 11. Elements semantic . . . . . . . . . . . . . . . . . . . . . . 19 86 11.1. EBML Schema . . . . . . . . . . . . . . . . . . . . . . 19 87 11.1.1. EBML Schema Example . . . . . . . . . . . . . . . . 20 88 11.1.2. Element . . . . . . . . . . . . . . . . 21 89 11.1.3. Attributes . . . . . . . . . . . . . . 21 90 11.1.4. Element . . . . . . . . . . . . . . . . . 22 91 11.1.5. Attributes . . . . . . . . . . . . . . . . 22 92 11.1.6. Element . . . . . . . . . . . . . . 29 93 11.1.7. Attributes . . . . . . . . . . . . . 29 94 11.1.8. Element . . . . . . . . . . . 30 95 11.1.9. Attributes . . . . . . . . . . 30 96 11.1.10. Element . . . . . . . . . . . . . . . 31 97 11.1.11. Element . . . . . . . . . . . . . . . . . . . 32 98 11.1.12. Attributes . . . . . . . . . . . . . . . . . 32 99 11.1.13. Element . . . . . . . . . . . . . . . . 32 100 11.1.14. Attributes . . . . . . . . . . . . . . . 32 101 11.1.15. XML Schema for EBML Schema . . . . . . . . . . . . . 33 102 11.1.16. Identically Recurring Elements . . . . . . . . . . . 37 103 11.1.17. Textual expression of floats . . . . . . . . . . . . 37 104 11.1.18. Note on the use of default attributes to define 105 Mandatory EBML Elements . . . . . . . . . . . . . . . 38 106 11.2. EBML Header Elements . . . . . . . . . . . . . . . . . . 39 107 11.2.1. EBML Element . . . . . . . . . . . . . . . . . . . . 39 108 11.2.2. EBMLVersion Element . . . . . . . . . . . . . . . . 39 109 11.2.3. EBMLReadVersion Element . . . . . . . . . . . . . . 40 110 11.2.4. EBMLMaxIDLength Element . . . . . . . . . . . . . . 40 111 11.2.5. EBMLMaxSizeLength Element . . . . . . . . . . . . . 41 112 11.2.6. DocType Element . . . . . . . . . . . . . . . . . . 41 113 11.2.7. DocTypeVersion Element . . . . . . . . . . . . . . . 42 114 11.2.8. DocTypeReadVersion Element . . . . . . . . . . . . . 42 115 11.2.9. DocTypeExtension Element . . . . . . . . . . . . . . 43 116 11.2.10. DocTypeExtensionName Element . . . . . . . . . . . . 43 117 11.2.11. DocTypeExtensionVersion Element . . . . . . . . . . 44 118 11.3. Global Elements . . . . . . . . . . . . . . . . . . . . 44 119 11.3.1. CRC-32 Element . . . . . . . . . . . . . . . . . . . 44 120 11.3.2. Void Element . . . . . . . . . . . . . . . . . . . . 45 121 12. Considerations for Reading EBML Data . . . . . . . . . . . . 45 122 13. Terminating Elements . . . . . . . . . . . . . . . . . . . . 46 123 14. Guidelines for Updating Elements . . . . . . . . . . . . . . 47 124 14.1. Reducing a Element Data in Size . . . . . . . . . . . . 47 125 14.1.1. Adding a Void Element . . . . . . . . . . . . . . . 47 126 14.1.2. Extending the Element Data Size . . . . . . . . . . 47 127 14.1.3. Terminating Element Data . . . . . . . . . . . . . . 49 128 14.2. Considerations when Updating Elements with Cyclic 129 Redundancy Check (CRC) . . . . . . . . . . . . . . . . . 49 130 15. Backward and Forward Compatibility . . . . . . . . . . . . . 49 131 15.1. Backward Compatibility . . . . . . . . . . . . . . . . . 49 132 15.2. Forward Compatibility . . . . . . . . . . . . . . . . . 50 133 16. Security Considerations . . . . . . . . . . . . . . . . . . . 50 134 17. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 51 135 17.1. CELLAR EBML Element ID Registry . . . . . . . . . . . . 52 136 17.2. CELLAR EBML DocType Registry . . . . . . . . . . . . . . 55 137 18. Normative References . . . . . . . . . . . . . . . . . . . . 55 138 19. Informative References . . . . . . . . . . . . . . . . . . . 57 139 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 57 141 1. Introduction 143 EBML, short for Extensible Binary Meta Language, specifies a binary 144 and octet (byte) aligned format inspired by the principle of XML (a 145 framework for structuring data). 147 The goal of this document is to define a generic, binary, space- 148 efficient format that can be used to define more complex formats 149 using an EBML Schema. EBML is used by the multimedia container 150 Matroska (https://github.com/Matroska-Org/matroska-specification/). 151 The applicability of EBML for other use cases is beyond the scope of 152 this document. 154 The definition of the EBML format recognizes the idea behind HTML and 155 XML as a good one: separate structure and semantics allowing the same 156 structural layer to be used with multiple, possibly widely differing 157 semantic layers. Except for the EBML Header and a few Global 158 Elements this specification does not define particular EBML format 159 semantics; however this specification is intended to define how other 160 EBML-based formats can be defined, such as the audio-video container 161 formats Matroska and WebM. 163 EBML uses a simple approach of building Elements upon three pieces of 164 data (tag, length, and value) as this approach is well known, easy to 165 parse, and allows selective data parsing. The EBML structure 166 additionally allows for hierarchical arrangement to support complex 167 structural formats in an efficient manner. 169 A typical EBML file has the following structure: 171 EBML Header (master) 172 + DocType (string) 173 + DocTypeVersion (unsigned integer) 174 EBML Body Root (master) 175 + ElementA (utf-8) 176 + Parent (master) 177 + ElementB (integer) 178 + Parent (master) 179 + ElementB (integer) 181 2. Notation and Conventions 183 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 184 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 185 "OPTIONAL" in this document are to be interpreted as described in BCP 186 14 [RFC2119] [RFC8174] when, and only when, they appear in all 187 capitals, as shown here. 189 This document defines specific terms in order to define the format 190 and application of "EBML". Specific terms are defined below: 192 "EBML": Extensible Binary Meta Language 194 "EBML Document Type": A name provided by an "EBML Schema" to 195 designate a particular implementation of "EBML" for a data format 196 (e.g.: matroska and webm). 198 "EBML Schema": A standardized definition for the structure of an 199 "EBML Document Type". 201 "EBML Document": A datastream comprised of only two components, an 202 "EBML Header" and an "EBML Body". 204 "EBML Reader": A data parser that interprets the semantics of an 205 "EBML Document" and creates a way for programs to use "EBML". 207 "EBML Stream": A file that consists of one or more "EBML Documents" 208 that are concatenated together. 210 "EBML Header": A declaration that provides processing instructions 211 and identification of the "EBML Body". The "EBML Header" is 212 analogous to an XML Declaration [W3C.REC-xml-20081126] (see section 213 2.8 on Prolog and Document Type Declaration). 215 "EBML Body": All data of an "EBML Document" following the "EBML 216 Header". 218 "Variable Size Integer": A compact variable-length binary value which 219 defines its own length. 221 "VINT": Also known as "Variable Size Integer". 223 "EBML Element": A foundation block of data that contains three parts: 224 an "Element ID", an "Element Data Size", and "Element Data". 226 "Element ID": The "Element ID" is a binary value, encoded as a 227 "Variable Size Integer", used to uniquely identify a defined "EBML 228 Element" within a specific "EBML Schema". 230 "EBML Class": A representation of the octet length of an "Element 231 ID". 233 "Element Data Size": An expression, encoded as a "Variable Size 234 Integer", of the length in octets of "Element Data". 236 "VINTMAX": The maximum possible value that can be stored as "Element 237 Data Size". 239 "Unknown-Sized Element": An "Element" with an unknown "Element Data 240 Size". 242 "Element Data": The value(s) of the "EBML Element" which is 243 identified by its "Element ID" and "Element Data Size". The form of 244 the "Element Data" is defined by this document and the corresponding 245 "EBML Schema" of the Element's "EBML Document Type". 247 "Root Level": The starting level in the hierarchy of an "EBML 248 Document". 250 "Root Element": A mandatory, non-repeating "EBML Element" which 251 occurs at the top level of the path hierarchy within an "EBML Body" 252 and contains all other "EBML Elements" of the "EBML Body", excepting 253 optional "Void Elements". 255 "Top-Level Element": An "EBML Element" defined to only occur as a 256 "Child Element" of the "Root Element". 258 "Master Element": The "Master Element" contains zero, one, or many 259 other "EBML Elements". 261 "Child Element": A "Child Element" is a relative term to describe the 262 "EBML Elements" immediately contained within a "Master Element". 264 "Parent Element": A relative term to describe the "Master Element" 265 which contains a specified element. For any specified "EBML Element" 266 that is not at "Root Level", the "Parent Element" refers to the 267 "Master Element" in which that "EBML Element" is contained. 269 "Descendant Element": A relative term to describe any "EBML Elements" 270 contained within a "Master Element", including any of the "Child 271 Elements" of its "Child Elements", and so on. 273 "Void Element": A "Void Element" is an "Element" used to overwrite 274 data or reserve space within a "Master Element" for later use. 276 "Element Name": The human-readable name of the "EBML Element". 278 "Element Path": The hierarchy of "Parent Element" where the "EBML 279 Element" is expected to be found in the "EBML Body". 281 "Empty Element": An "EBML Element" that has an "Element Data Size" 282 with all "VINT_DATA" bits set to zero, which indicates that the 283 "Element Data" of the "Element" is zero octets in length. 285 3. Structure 287 EBML uses a system of Elements to compose an EBML Document. EBML 288 Elements incorporate three parts: an Element ID, an Element Data 289 Size, and Element Data. The Element Data, which is described by the 290 Element ID, includes either binary data, one or more other EBML 291 Elements, or both. 293 4. Variable Size Integer 295 The Element ID and Element Data Size are both encoded as a Variable 296 Size Integer. The Variable Size Integer is composed of a VINT_WIDTH, 297 VINT_MARKER, and VINT_DATA, in that order. Variable Size Integers 298 MUST left-pad the VINT_DATA value with zero bits so that the whole 299 Variable Size Integer is octet-aligned. Variable Size Integer will 300 be referred to as VINT for shorthand. 302 4.1. VINT_WIDTH 304 Each Variable Size Integer begins with a VINT_WIDTH which consists of 305 zero or many zero-value bits. The count of consecutive zero-values 306 of the VINT_WIDTH plus one equals the length in octets of the 307 Variable Size Integer. For example, a Variable Size Integer that 308 starts with a VINT_WIDTH which contains zero consecutive zero-value 309 bits is one octet in length and a Variable Size Integer that starts 310 with one consecutive zero-value bit is two octets in length. The 311 VINT_WIDTH MUST only contain zero-value bits or be empty. 313 Within the EBML Header the VINT_WIDTH of a VINT MUST NOT exceed three 314 bits in length (meaning that the Variable Size Integer MUST NOT 315 exceed four octets in length) except if said VINT is used to express 316 the Element Data Size of an EBML Element with Element Name EBML and 317 Element ID "0x1A45DFA3" (see Section 11.2.1) in which case the 318 VINT_WIDTH MUST NOT exceed seven bits in length. Within the EBML 319 Body, when a VINT is used to express an Element ID, the maximum 320 length allowed for the VINT_WIDTH is one less than the value set in 321 the EBMLMaxIDLength Element. Within the EBML Body, when a VINT is 322 used to express an Element Data Size, the maximum length allowed for 323 the VINT_WIDTH is one less than the value set in the 324 EBMLMaxSizeLength Element. 326 4.2. VINT_MARKER 328 The VINT_MARKER serves as a separator between the VINT_WIDTH and 329 VINT_DATA. Each Variable Size Integer MUST contain exactly one 330 VINT_MARKER. The VINT_MARKER is one bit in length and contain a bit 331 with a value of one. The first bit with a value of one within the 332 Variable Size Integer is the VINT_MARKER. 334 4.3. VINT_DATA 336 The VINT_DATA portion of the Variable Size Integer includes all data 337 that follows (but not including) the VINT_MARKER until end of the 338 Variable Size Integer whose length is derived from the VINT_WIDTH. 339 The bits required for the VINT_WIDTH and the VINT_MARKER use one out 340 of every eight bits of the total length of the Variable Size Integer. 341 Thus a Variable Size Integer of 1 octet length supplies 7 bits for 342 VINT_DATA, a 2 octet length supplies 14 bits for VINT_DATA, and a 3 343 octet length supplies 21 bits for VINT_DATA. If the number of bits 344 required for VINT_DATA are less than the bit size of VINT_DATA, then 345 VINT_DATA MUST be zero-padded to the left to a size that fits. The 346 VINT_DATA value MUST be expressed as a big-endian unsigned integer. 348 4.4. VINT Examples 350 This table shows examples of Variable Size Integers with lengths from 351 1 to 5 octets. The Usable Bits column refers to the number of bits 352 that can be used in the VINT_DATA. The Representation column depicts 353 a binary expression of Variable Size Integers where VINT_WIDTH is 354 depicted by "0", the VINT_MARKER as "1", and the VINT_DATA as "x". 356 +--------------+-------------+-------------------------------+ 357 | Octet Length | Usable Bits | Representation | 358 +==============+=============+===============================+ 359 | 1 | 7 | 1xxx xxxx | 360 +--------------+-------------+-------------------------------+ 361 | 2 | 14 | 01xx xxxx xxxx xxxx | 362 +--------------+-------------+-------------------------------+ 363 | 3 | 21 | 001x xxxx xxxx xxxx xxxx xxxx | 364 +--------------+-------------+-------------------------------+ 365 | 4 | 28 | 0001 xxxx xxxx xxxx xxxx xxxx | 366 | | | xxxx xxxx | 367 +--------------+-------------+-------------------------------+ 368 | 5 | 35 | 0000 1xxx xxxx xxxx xxxx xxxx | 369 | | | xxxx xxxx xxxx xxxx | 370 +--------------+-------------+-------------------------------+ 372 Table 1 374 Data encoded as a Variable Size Integer may be rendered at octet 375 lengths larger than needed to store the data in order to facilitate 376 overwriting it at a later date, e.g. when its final size isn't known 377 in advance. In this table a binary value of 0b10 is shown encoded as 378 different Variable Size Integers with lengths from one octet to four 379 octets. All four encoded examples have identical semantic meaning 380 though the VINT_WIDTH and the padding of the VINT_DATA vary. 382 +--------------+--------------+-----------------------+ 383 | Binary Value | Octet Length | As Represented in | 384 | | | Variable Size Integer | 385 +==============+==============+=======================+ 386 | 10 | 1 | 1000 0010 | 387 +--------------+--------------+-----------------------+ 388 | 10 | 2 | 0100 0000 0000 0010 | 389 +--------------+--------------+-----------------------+ 390 | 10 | 3 | 0010 0000 0000 0000 | 391 | | | 0000 0010 | 392 +--------------+--------------+-----------------------+ 393 | 10 | 4 | 0001 0000 0000 0000 | 394 | | | 0000 0000 0000 0010 | 395 +--------------+--------------+-----------------------+ 397 Table 2 399 5. Element ID 401 The Element ID is encoded as a Variable Size Integer. By default, 402 Element IDs are encoded in lengths from one octet to four octets, 403 although Element IDs of greater lengths MAY be used if the 404 EBMLMaxIDLength Element of the EBML Header is set to a value greater 405 than four (see Section 11.2.4). The VINT_DATA component of the 406 Element ID MUST NOT be either defined or written as either all zero 407 values or all one values. Any Element ID with the VINT_DATA 408 component set as all zero values or all one values MUST be ignored. 409 The VINT_DATA component of the Element ID MUST be encoded at the 410 shortest valid length. For example, an Element ID with binary 411 encoding of "1011 1111" is valid, whereas an Element ID with binary 412 encoding of "0100 0000 0011 1111" stores a semantically equal 413 VINT_DATA but is invalid because a shorter VINT encoding is possible. 414 Additionally, an Element ID with binary encoding of "1111 1111" is 415 invalid since the VINT_DATA section is set to all one values, whereas 416 an Element ID with binary encoding of "0100 0000 0111 1111" stores a 417 semantically equal VINT_DATA and is the shortest possible VINT 418 encoding. 420 The following table details these specific examples further: 422 +------------+-------------+----------------+--------------------+ 423 | VINT_WIDTH | VINT_MARKER | VINT_DATA | Element ID Status | 424 +============+=============+================+====================+ 425 | | 1 | 0000000 | Invalid: VINT_DATA | 426 | | | | MUST NOT be set to | 427 | | | | all 0 | 428 +------------+-------------+----------------+--------------------+ 429 | 0 | 1 | 00000000000000 | Invalid: VINT_DATA | 430 | | | | MUST NOT be set to | 431 | | | | all 0 | 432 +------------+-------------+----------------+--------------------+ 433 | | 1 | 0000001 | Valid | 434 +------------+-------------+----------------+--------------------+ 435 | 0 | 1 | 00000000000001 | Invalid: A shorter | 436 | | | | VINT_DATA encoding | 437 | | | | is available. | 438 +------------+-------------+----------------+--------------------+ 439 | | 1 | 0111111 | Valid | 440 +------------+-------------+----------------+--------------------+ 441 | 0 | 1 | 00000000111111 | Invalid: A shorter | 442 | | | | VINT_DATA encoding | 443 | | | | is available. | 444 +------------+-------------+----------------+--------------------+ 445 | | 1 | 1111111 | Invalid: VINT_DATA | 446 | | | | MUST NOT be set to | 447 | | | | all 1 | 448 +------------+-------------+----------------+--------------------+ 449 | 0 | 1 | 00000001111111 | Valid | 450 +------------+-------------+----------------+--------------------+ 452 Table 3 454 The octet length of an Element ID determines its EBML Class. 456 +------------+--------+-------------------------+---------------+ 457 | EBML Class | Length | Possible IDs | Number of IDs | 458 +============+========+=========================+===============+ 459 | Class A | 1 | 0x81 - 0xFE | 126 | 460 +------------+--------+-------------------------+---------------+ 461 | Class B | 2 | 0x407F - 0x7FFE | 16,256 | 462 +------------+--------+-------------------------+---------------+ 463 | Class C | 3 | 0x203FFF - 0x3FFFFE | 2,080,768 | 464 +------------+--------+-------------------------+---------------+ 465 | Class D | 4 | 0x101FFFFF - 0x1FFFFFFE | 268,338,304 | 466 +------------+--------+-------------------------+---------------+ 468 Table 4 470 6. Element Data Size 472 6.1. Data Size Format 474 The Element Data Size expresses the length in octets of Element Data. 475 The Element Data Size itself is encoded as a Variable Size Integer. 476 By default, Element Data Sizes can be encoded in lengths from one 477 octet to eight octets, although Element Data Sizes of greater lengths 478 MAY be used if the octet length of the longest Element Data Size of 479 the EBML Document is declared in the EBMLMaxSizeLength Element of the 480 EBML Header (see Section 11.2.5). Unlike the VINT_DATA of the 481 Element ID, the VINT_DATA component of the Element Data Size is not 482 mandated to be encoded at the shortest valid length. For example, an 483 Element Data Size with binary encoding of 1011 1111 or a binary 484 encoding of 0100 0000 0011 1111 are both valid Element Data Sizes and 485 both store a semantically equal value (both 0b00000000111111 and 486 0b0111111, the VINT_DATA sections of the examples, represent the 487 integer 63). 489 Although an Element ID with all VINT_DATA bits set to zero is 490 invalid, an Element Data Size with all VINT_DATA bits set to zero is 491 allowed for EBML Element Types which do not mandate a non-zero length 492 (see Section 7). An Element Data Size with all VINT_DATA bits set to 493 zero indicates that the Element Data is zero octets in length. Such 494 an EBML Element is referred to as an Empty Element. If an Empty 495 Element has a default value declared then the EBML Reader MUST 496 interpret the value of the Empty Element as the default value. If an 497 Empty Element has no default value declared then the EBML Reader MUST 498 use the value of the Empty Element for the corresponding EBML Element 499 Type of the Element ID, 0 for numbers and an empty string for 500 strings. 502 6.2. Unknown Data Size 504 An Element Data Size with all VINT_DATA bits set to one is reserved 505 as an indicator that the size of the EBML Element is unknown. The 506 only reserved value for the VINT_DATA of Element Data Size is all 507 bits set to one. An EBML Element with an unknown Element Data Size 508 is referred to as an Unknown-Sized Element. A Master Element MAY be 509 an Unknown-Sized Element; however an EBML Element that is not a 510 Master Element MUST NOT be an Unknown-Sized Element. Master Elements 511 MUST NOT use an unknown size unless the unknownsizeallowed attribute 512 of their EBML Schema is set to true (see Section 11.1.5.10). 514 The use of Unknown-Sized Elements allows for an EBML Element to be 515 written and read before the size of the EBML Element is known. 516 Unknown-Sized Element MUST NOT be used or defined unnecessarily; 517 however if the Element Data Size is not known before the Element Data 518 is written, such as in some cases of data streaming, then Unknown- 519 Sized Elements MAY be used. The end of an Unknown-Sized Element is 520 determined by whichever comes first: 522 * Any EBML Element that is a valid Parent Element of the Unknown- 523 Sized Element according to the EBML Schema, Global Elements 524 excluded. 526 * Any valid EBML Element according to the EBML Schema, Global 527 Elements excluded, that is not a Descendant Element of the 528 Unknown-Sized Element but share a common direct parent, such as a 529 Top-Level Element. 531 * Any EBML Element that is a valid Root Element according to the 532 EBML Schema, Global Elements excluded. 534 * The end of the Parent Element with a known size has been reached. 536 * The end of the EBML Document, either when reaching the end of the 537 file or because a new EBML Header started. 539 Consider an Unknown-Sized Element which EBML path is 540 "\root\level1\level2\elt". When reading a new Element ID, assuming 541 the EBML Path of that new Element is valid, here are some possible 542 and impossible ways that this new Element is ending "elt": 544 +------------------------------------+----------------------------+ 545 | EBML Path of new element | Status | 546 +====================================+============================+ 547 | "\root\level1\level2" | Ends the Unknown-Sized | 548 | | Element, as it is a new | 549 | | Parent Element | 550 +------------------------------------+----------------------------+ 551 | "\root\level1" | Ends the Unknown-Sized | 552 | | Element, as it is a new | 553 | | Parent Element | 554 +------------------------------------+----------------------------+ 555 | "\root" | Ends the Unknown-Sized | 556 | | Element, as it is a new | 557 | | Root Element | 558 +------------------------------------+----------------------------+ 559 | "\root2" | Ends the Unknown-Sized | 560 | | Element, as it is a new | 561 | | Root Element | 562 +------------------------------------+----------------------------+ 563 | "\root\level1\level2\other" | Ends the Unknown-Sized | 564 | | Element, as they share the | 565 | | same parent | 566 +------------------------------------+----------------------------+ 567 | "\root\level1\level2\elt" | Ends the Unknown-Sized | 568 | | Element, as they share the | 569 | | same parent | 570 +------------------------------------+----------------------------+ 571 | "\root\level1\level2\elt\inside" | Doesn't end the Unknown- | 572 | | Sized Element, it's a | 573 | | child of "elt" | 574 +------------------------------------+----------------------------+ 575 | "\root\level1\level2\elt\" | Global Element is valid, | 576 | | it's a child of "elt" | 577 +------------------------------------+----------------------------+ 578 | "\root\level1\level2\" | Global Element cannot be | 579 | | assumed to have this path, | 580 | | while parsing "elt" it can | 581 | | only be a child of "elt" | 582 +------------------------------------+----------------------------+ 584 Table 5 586 6.3. Data Size Values 588 For Element Data Sizes encoded at octet lengths from one to eight, 589 this table depicts the range of possible values that can be encoded 590 as an Element Data Size. An Element Data Size with an octet length 591 of 8 is able to express a size of 2^56-2 or 72,057,594,037,927,934 592 octets (or about 72 petabytes). The maximum possible value that can 593 be stored as Element Data Size is referred to as VINTMAX. 595 +--------------+----------------------+ 596 | Octet Length | Possible Value Range | 597 +==============+======================+ 598 | 1 | 0 to 2^(7-2) | 599 +--------------+----------------------+ 600 | 2 | 0 to 2^(14-2) | 601 +--------------+----------------------+ 602 | 3 | 0 to 2^(21-2) | 603 +--------------+----------------------+ 604 | 4 | 0 to 2^(28-2) | 605 +--------------+----------------------+ 606 | 5 | 0 to 2^(35-2) | 607 +--------------+----------------------+ 608 | 6 | 0 to 2^(42-2) | 609 +--------------+----------------------+ 610 | 7 | 0 to 2^(49-2) | 611 +--------------+----------------------+ 612 | 8 | 0 to 2^(56-2) | 613 +--------------+----------------------+ 615 Table 6 617 If the length of Element Data equals 2^(n*7)-1 then the octet length 618 of the Element Data Size MUST be at least n+1. This rule prevents an 619 Element Data Size from being expressed as the unknown size value. 620 The following table clarifies this rule by showing a valid and 621 invalid expression of an Element Data Size with a VINT_DATA of 127 622 (which is equal to 2^(1*7)-1) and 16,383 (which is equal to 2^((2*7)- 623 1).) 624 +------------+-------------+-----------------------+--------------+ 625 | VINT_WIDTH | VINT_MARKER | VINT_DATA | Element Data | 626 | | | | Size Status | 627 +============+=============+=======================+==============+ 628 | | 1 | 1111111 | Reserved | 629 | | | | (meaning | 630 | | | | Unknown) | 631 +------------+-------------+-----------------------+--------------+ 632 | 0 | 1 | 00000001111111 | Valid | 633 | | | | (meaning 127 | 634 | | | | octets) | 635 +------------+-------------+-----------------------+--------------+ 636 | 00 | 1 | 000000000000001111111 | Valid | 637 | | | | (meaning 127 | 638 | | | | octets) | 639 +------------+-------------+-----------------------+--------------+ 640 | 0 | 1 | 11111111111111 | Reserved | 641 | | | | (meaning | 642 | | | | Unknown) | 643 +------------+-------------+-----------------------+--------------+ 644 | 00 | 1 | 000000011111111111111 | Valid | 645 | | | | (16,383 | 646 | | | | octets) | 647 +------------+-------------+-----------------------+--------------+ 649 Table 7 651 7. EBML Element Types 653 EBML Elements are defined by an EBML Schema (see Section 11.1) which 654 MUST declare one of the following EBML Element Types for each EBML 655 Element. An EBML Element Type defines a concept of storing data 656 within an EBML Element that describes such characteristics as length, 657 endianness, and definition. 659 EBML Elements which are defined as a Signed Integer Element, Unsigned 660 Integer Element, Float Element, or Date Element use big endian 661 storage. 663 7.1. Signed Integer Element 665 A Signed Integer Element MUST declare a length from zero to eight 666 octets. If the EBML Element is not defined to have a default value, 667 then a Signed Integer Element with a zero-octet length represents an 668 integer value of zero. 670 A Signed Integer Element stores an integer (meaning that it can be 671 written without a fractional component) which could be negative, 672 positive, or zero. Signed Integers are stored with two's complement 673 notation with the leftmost bit being the sign bit. Because EBML 674 limits Signed Integers to 8 octets in length a Signed Integer Element 675 stores a number from -9,223,372,036,854,775,808 to 676 +9,223,372,036,854,775,807. 678 7.2. Unsigned Integer Element 680 An Unsigned Integer Element MUST declare a length from zero to eight 681 octets. If the EBML Element is not defined to have a default value, 682 then an Unsigned Integer Element with a zero-octet length represents 683 an integer value of zero. 685 An Unsigned Integer Element stores an integer (meaning that it can be 686 written without a fractional component) which could be positive or 687 zero. Because EBML limits Unsigned Integers to 8 octets in length an 688 Unsigned Integer Element stores a number from 0 to 689 18,446,744,073,709,551,615. 691 7.3. Float Element 693 A Float Element MUST declare a length of either zero octet (0 bit), 694 four octets (32 bit) or eight octets (64 bit). If the EBML Element 695 is not defined to have a default value, then a Float Element with a 696 zero-octet length represents a numerical value of zero. 698 A Float Element stores a floating-point number as defined in 699 [IEEE.754.1985]. 701 7.4. String Element 703 A String Element MUST declare a length in octets from zero to 704 VINTMAX. If the EBML Element is not defined to have a default value, 705 then a String Element with a zero-octet length represents an empty 706 string. 708 A String Element MUST either be empty (zero-length) or contain 709 printable ASCII characters [RFC0020] in the range of 0x20 to 0x7E, 710 with an exception made for termination (see Section 13). 712 7.5. UTF-8 Element 714 A UTF-8 Element MUST declare a length in octets from zero to VINTMAX. 715 If the EBML Element is not defined to have a default value, then a 716 UTF-8 Element with a zero-octet length represents an empty string. 718 A UTF-8 Element contains only a valid Unicode string as defined in 719 [RFC3629], with an exception made for termination (see Section 13). 721 7.6. Date Element 723 A Date Element MUST declare a length of either zero octets or eight 724 octets. If the EBML Element is not defined to have a default value, 725 then a Date Element with a zero-octet length represents a timestamp 726 of 2001-01-01T00:00:00.000000000 UTC [RFC3339]. 728 The Date Element stores an integer in the same format as the Signed 729 Integer Element that expresses a point in time referenced in 730 nanoseconds from the precise beginning of the third millennium of the 731 Gregorian Calendar in Coordinated Universal Time (also known as 732 2001-01-01T00:00:00.000000000 UTC). This provides a possible 733 expression of time from 1708-09-11T00:12:44.854775808 UTC to 734 2293-04-11T11:47:16.854775807 UTC. 736 7.7. Master Element 738 A Master Element MUST declare a length in octets from zero to 739 VINTMAX. The Master Element MAY also use an unknown length. See 740 Section 6 for rules that apply to elements of unknown length. 742 The Master Element contains zero, one, or many other elements. EBML 743 Elements contained within a Master Element MUST have the 744 EBMLParentPath of their Element Path equal to the EBMLFullPath of the 745 Master Element Element Path (see Section 11.1.5.2). Element Data 746 stored within Master Elements SHOULD only consist of EBML Elements 747 and SHOULD NOT contain any data that is not part of an EBML Element. 748 The EBML Schema identifies what Element IDs are valid within the 749 Master Elements for that version of the EBML Document Type. Any data 750 contained within a Master Element that is not part of a Child Element 751 MUST be ignored. 753 7.8. Binary Element 755 A Binary Element MUST declare a length in octets from zero to 756 VINTMAX. 758 The contents of a Binary Element should not be interpreted by the 759 EBML Reader. 761 8. EBML Document 763 An EBML Document is comprised of only two components, an EBML Header 764 and an EBML Body. An EBML Document MUST start with an EBML Header 765 that declares significant characteristics of the entire EBML Body. 766 An EBML Document consists of EBML Elements and MUST NOT contain any 767 data that is not part of an EBML Element. 769 8.1. EBML Header 771 The EBML Header is a declaration that provides processing 772 instructions and identification of the EBML Body. The EBML Header of 773 an EBML Document is analogous to the XML Declaration of an XML 774 Document. 776 The EBML Header documents the EBML Schema (also known as the EBML 777 DocType) that is used to semantically interpret the structure and 778 meaning of the EBML Document. Additionally the EBML Header documents 779 the versions of both EBML and the EBML Schema that were used to write 780 the EBML Document and the versions required to read the EBML 781 Document. 783 The EBML Header MUST contain a single Master Element with an Element 784 Name of EBML and Element ID of 0x1A45DFA3 (see Section 11.2.1) and 785 any number of additional EBML Elements within it. The EBML Header of 786 an EBML Document that uses an EBMLVersion of 1 MUST only contain EBML 787 Elements that are defined as part of this document. 789 8.2. EBML Body 791 All data of an EBML Document following the EBML Header is the EBML 792 Body. The end of the EBML Body, as well as the end of the EBML 793 Document that contains the EBML Body, is reached at whichever comes 794 first: the beginning of a new EBML Header at the Root Level or the 795 end of the file. The EBML Body MUST NOT contain any data that is not 796 part of an EBML Element. This document defines precisely which EBML 797 Elements are to be used within the EBML Header, but does not name or 798 define which EBML Elements are to be used within the EBML Body. The 799 definition of which EBML Elements are to be used within the EBML Body 800 is defined by an EBML Schema. 802 9. EBML Stream 804 An EBML Stream is a file that consists of one or more EBML Documents 805 that are concatenated together. An occurrence of a EBML Header at 806 the Root Level marks the beginning of an EBML Document. 808 10. EBML Versioning 810 An EBML Document handles 2 different versions: the version of the 811 EBML Header and the version of the EBML Body. Both versions are 812 meant to be backward compatible. 814 10.1. EBML Header Version 816 The version of the EBML Header is found in EBMLVersion. An EBML 817 parser can read an EBML Header if it can read either the EBMLVersion 818 version or a version equal or higher than the one found in 819 EBMLReadVersion. 821 10.2. EBML Document Version 823 The version of the EBML Body is found in EBMLDocTypeVersion. A 824 parser for the particular DocType format can read the EBML Document 825 if it can read either the EBMLDocTypeVersion version of that format 826 or a version equal or higher than the one found in 827 EBMLDocTypeReadVersion. 829 11. Elements semantic 831 11.1. EBML Schema 833 An EBML Schema is a well-formed XML Document [W3C.REC-xml-20081126] 834 that defines the properties, arrangement, and usage of EBML Elements 835 that compose a specific EBML Document Type. The relationship of an 836 EBML Schema to an EBML Document is analogous to the relationship of 837 an XML Schema [W3C.REC-xmlschema-0-20041028] to an XML Document 838 [W3C.REC-xml-20081126]. An EBML Schema MUST be clearly associated 839 with one or more EBML Document Types. An EBML Document Type is 840 identified by a string stored within the EBML Header in the DocType 841 Element; for example matroska or webm (see Section 11.2.6). The 842 DocType value for an EBML Document Type MUST be unique and 843 persistent. 845 An EBML Schema MUST declare exactly one EBML Element at Root Level 846 (referred to as the Root Element) that occurs exactly once within an 847 EBML Document. The Void Element MAY also occur at Root Level but is 848 not a Root Element (see Section 11.3.2). 850 The EBML Schema MUST document all Elements of the EBML Body. The 851 EBML Schema does not document Global Elements that are defined by 852 this document (namely the Void Element and the CRC-32 Element). 854 The EBML Schema MUST NOT use the Element ID "0x1A45DFA3" which is 855 reserved for the EBML Header for resynchronization purpose. 857 An EBML Schema MAY constrain the use of EBML Header Elements (see 858 Section 11.2) by adding or constraining that Element's "range" 859 attribute. For example, an EBML Schema MAY constrain the 860 EBMLMaxSizeLength to a maximum value of "8" or MAY constrain the 861 EBMLVersion to only support a value of "1". If an EBML Schema adopts 862 the EBML Header Element as-is, then it is not required to document 863 that Element within the EBML Schema. If an EBML Schema constrains 864 the range of an EBML Header Element, then that Element MUST be 865 documented within an "" node of the EBML Schema. This 866 document provides an example of an EBML Schema, see Section 11.1.1. 868 11.1.1. EBML Schema Example 870 871 873 874 877 880 881 883 Container of data and 884 attributes representing one or many files. 885 886 888 889 An attached file. 890 891 892 895 896 Filename of the attached file. 897 898 899 902 903 MIME type of the file. 904 905 906 909 910 Modification timestamp of the file. 911 912 913 915 916 The data of the file. 917 918 919 921 11.1.2. Element 923 Within an EBML Schema, the XPath [W3C.REC-xpath-19991116] of 924 "" element is "/EBMLSchema". 926 As an XML Document, the EBML Schema MUST use "" as the 927 top level element. The "" element can contain 928 "" sub-elements. 930 11.1.3. Attributes 932 Within an EBML Schema the "" element uses the following 933 attributes: 935 11.1.3.1. docType 937 Within an EBML Schema, the XPath of "@docType" attribute is 938 "/EBMLSchema/@docType". 940 The docType lists the official name of the EBML Document Type that is 941 defined by the EBML Schema; for example, "". 944 The docType attribute is REQUIRED within the "" Element. 946 11.1.3.2. version 948 Within an EBML Schema, the XPath of "@version" attribute is 949 "/EBMLSchema/@version". 951 The version lists a non-negative integer that specifies the version 952 of the docType documented by the EBML Schema. Unlike XML Schemas, an 953 EBML Schema documents all versions of a docType's definition rather 954 than using separate EBML Schemas for each version of a docType. EBML 955 Elements may be introduced and deprecated by using the minver and 956 maxver attributes of "". 958 The version attribute is REQUIRED within the "" Element. 960 11.1.4. Element 962 Within an EBML Schema, the XPath of "" element is 963 "/EBMLSchema/element". 965 Each "" defines one EBML Element through the use of several 966 attributes that are defined in Section 11.1.3. EBML Schemas MAY 967 contain additional attributes to extend the semantics but MUST NOT 968 conflict with the definitions of the "" attributes defined 969 within this document. 971 The "" nodes contain a description of the meaning and use of 972 the EBML Element stored within one or more "" sub- 973 elements, followed by optional "" sub-elements, 974 followed by zero or one "" sub-element, followed by 975 optional "" sub-elements. All "" nodes MUST be 976 sub-elements of the "". 978 11.1.5. Attributes 980 Within an EBML Schema the "" uses the following attributes 981 to define an EBML Element: 983 11.1.5.1. name 985 Within an EBML Schema, the XPath of "@name" attribute is 986 "/EBMLSchema/element/@name". 988 The name provides the human-readable name of the EBML Element. The 989 value of the name MUST be in the form of characters "A" to "Z", "a" 990 to "z", "0" to "9", "-" and ".". 992 The name attribute is REQUIRED. 994 11.1.5.2. path 996 Within an EBML Schema, the XPath of "@path" attribute is 997 "/EBMLSchema/element/@path". 999 The path defines the allowed storage locations of the EBML Element 1000 within an EBML Document. This path MUST be defined with the full 1001 hierarchy of EBML Elements separated with a "\". The top EBML 1002 Element in the path hierarchy being the first in the value. The 1003 syntax of the path attribute is defined using this Augmented Backus- 1004 Naur Form (ABNF) [RFC5234] with the case sensitive update [RFC7405] 1005 notation: 1007 The path attribute is REQUIRED. 1009 EBMLFullPath = [EBMLParentPath] EBMLElementPath 1010 EBMLParentPath = EBMLFixedParent EBMLLastParent 1011 EBMLFixedParent = *(EBMLPathAtom) 1012 EBMLElementPath = EBMLPathAtom / EBMLPathAtomRecursive 1013 EBMLPathAtom = PathDelimiter EBMLAtomName 1014 EBMLPathAtomRecursive = "(1*(" EBMLPathAtom "))" 1015 EBMLLastParent = EBMLPathAtom / EBMLGlobalParent 1016 EBMLGlobalParent = "(" GlobalParentOccurence "\)" 1017 EBMLAtomName = 1*(EBMLNameChar) 1018 EBMLNameChar = ALPHA / DIGIT / "-" / "." 1019 PathDelimiter = "\" 1020 GlobalParentOccurence = [PathMinOccurrence] "*" [PathMaxOccurrence] 1021 PathMinOccurrence = 1*DIGIT ; no upper limit 1022 PathMaxOccurrence = 1*DIGIT ; no upper limit 1024 The "*", "(" and ")" symbols are interpreted as defined in [RFC5234]. 1026 The EBMLPathAtom part of the EBMLElementPath MUST be equal to the 1027 name attribute of the EBML Schema. 1029 The starting PathDelimiter of the path corresponds to the root of the 1030 EBML Document. 1032 In some cases the EBMLLastParent part of the path is an 1033 EBMLGlobalParent. A path with a EBMLGlobalParent defines a 1034 Section 11.3. Any path that starts with the EBMLFixedParent of the 1035 Global Element and matches the occurrences found in the 1036 GlobalParentOccurence is a valid path for the Global Element. 1038 The GlobalParentOccurence part is interpreted as an ABNF Variable 1039 Repetition. The repetition amounts correspond to the amount of 1040 unspecified Parent Element levels there can be between the 1041 EBMLFixedParent and the actual EBMLElementPath. 1043 PathMinOccurrence represents the minimum number of element path 1044 required between the EBMLFixedParent and the Global Element 1045 EBMLElementPath. For example 0 means the EBMLElementPath can be 1046 right after the EBMLFixedParent, 1 means there has to be at least an 1047 element between the EBMLFixedParent and the EBMLElementPath. If 1048 PathMinOccurrence is not present then that EBML Element has an 1049 PathMinOccurrence value of 0. 1051 PathMaxOccurrence represents the maximum number of element path 1052 possible between the EBMLFixedParent and the Global Element 1053 EBMLElementPath. It cannot have the value 0 as it would be the 1054 Global Element can only be found right after the EBMLFixedParent, in 1055 which case it's not a Global Element anymore. If PathMaxOccurrence 1056 is not present then there is no upper bound for the permitted number 1057 of occurrences of element path possible between the EBMLFixedParent 1058 and the Global Element EBMLElementPath. 1060 If the path contains an EBMLPathAtomRecursive part, the EBML Element 1061 can occur within itself recursively (see Section 11.1.5.11). 1063 As an example, a "path" of "1*(\Segment\Info)" means the element Info 1064 is found inside the Segment elements at least once and with no 1065 maximum iteration. An element SeekHead with path 1066 "0*2(\Segment\SeekHead)" may not be found at all in its Segment 1067 parent, once or twice but no more than that. 1069 11.1.5.3. id 1071 Within an EBML Schema, the XPath of "@id" attribute is "/EBMLSchema/ 1072 element/@id". 1074 The Element ID encoded as a Variable Size Integer expressed in 1075 hexadecimal notation prefixed by a 0x that is read and stored in big- 1076 endian order. To reduce the risk of false positives while parsing 1077 EBML Streams, the Element IDs of the Root Element and Top-Level 1078 Elements SHOULD be at least 4 octets in length. Element IDs defined 1079 for use at Root Level or directly under the Root Level MAY use 1080 shorter octet lengths to facilitate padding and optimize edits to 1081 EBML Documents; for instance, the Void Element uses an Element ID 1082 with a one octet length to allow its usage in more writing and 1083 editing scenarios. 1085 The id attribute is REQUIRED. 1087 11.1.5.4. minOccurs 1089 Within an EBML Schema, the XPath of "@minOccurs" attribute is 1090 "/EBMLSchema/element/@minOccurs". 1092 The minOccurs is a non-negative integer expressing the minimum 1093 permitted number of occurrences of this EBML Element within its 1094 Parent Element. 1096 Each instance of the Parent Element MUST contain at least this many 1097 instances of this EBML Element. If the EBML Element has an empty 1098 EBMLParentPath then minOccurs refers to constraints on the occurrence 1099 of the EBML Element within the EBML Document. EBML Elements with 1100 minOccurs set to "1" that also have a default value (see 1101 Section 11.1.5.8) declared are not REQUIRED to be stored but are 1102 REQUIRED to be interpreted, see Section 11.1.18. 1104 An EBML Element defined with a minOccurs value greater than zero is 1105 called a Mandatory EBML Element. 1107 The minOccurs attribute is OPTIONAL. If the minOccurs attribute is 1108 not present then that EBML Element has a minOccurs value of 0. 1110 The semantic meaning of minOccurs within an EBML Schema is analogous 1111 to the meaning of minOccurs within an XML Schema. 1113 11.1.5.5. maxOccurs 1115 Within an EBML Schema, the XPath of "@maxOccurs" attribute is 1116 "/EBMLSchema/element/@maxOccurs". 1118 The maxOccurs is a non-negative integer expressing the maximum 1119 permitted number of occurrences of this EBML Element within its 1120 Parent Element. 1122 Each instance of the Parent Element MUST contain at most this many 1123 instances of this EBML Element, including the unwritten mandatory 1124 element with a default value, see Section 11.1.18. If the EBML 1125 Element has an empty EBMLParentPath then maxOccurs refers to 1126 constraints on the occurrence of the EBML Element within the EBML 1127 Document. 1129 The maxOccurs attribute is OPTIONAL. If the maxOccurs attribute is 1130 not present then there is no upper bound for the permitted number of 1131 occurrences of this EBML Element within its Parent Element or within 1132 the EBML Document depending on whether the EBMLParentPath of the EBML 1133 Element is empty or not. 1135 The semantic meaning of maxOccurs within an EBML Schema is analogous 1136 to the meaning of maxOccurs within an XML Schema, when it is not 1137 present it's similar to xml:maxOccurs="unbounded" in an XML Schema. 1139 11.1.5.6. range 1141 Within an EBML Schema, the XPath of "@range" attribute is 1142 "/EBMLSchema/element/@range". 1144 A numerical range for EBML Elements which are of numerical types 1145 (Unsigned Integer, Signed Integer, Float, and Date). If specified 1146 the value of the EBML Element MUST be within the defined range. See 1147 Section 11.1.5.6.1 for rules applied to expression of range values. 1149 The range attribute is OPTIONAL. If the range attribute is not 1150 present then any value legal for the type attribute is valid. 1152 11.1.5.6.1. Expression of range 1154 The range attribute MUST only be used with EBML Elements that are 1155 either signed integer, unsigned integer, float, or date. The 1156 expression defines the upper, lower, exact or excluded value of the 1157 EBML Element and optionally an upper boundary value combined with a 1158 lower boundary. The range expression may contain whitespace (using 1159 the ASCII 0x20 character) for readability but whitespace within a 1160 range expression MUST NOT convey meaning. 1162 To set a fixed value for the range, the value is used as the 1163 attribute value. For example "1234" means the EBML element always 1164 has the value 1234. The value can be prefixed with "not" to indicate 1165 that the fixed value MUST NOT be used for that Element. For example 1166 "not 1234" means the Element can use all values of its type except 1167 1234. 1169 For an exclusive lower boundary the ">" sign is used and the ">=" 1170 sign is used for an inclusive lower boundary. For example ">3" 1171 meaning the Element value MUST be greater than 3 or ">=0x1p+0" 1172 meaning the Element value MUST be greater than or equal to the 1173 floating value 1.0, see Section 11.1.17. 1175 For an exclusive upper boundary the "<" sign is used and the "<=" 1176 sign is used for an inclusive upper boundary. For example "<-2" 1177 meaning the Element value MUST be less than -2 or "<=10" meaning the 1178 Element value MUST be less than or equal to the 10. 1180 The lower and upper bounds can be combined into an expression to form 1181 a closed boundary. The lower boundary coming first followed by the 1182 upper boundary, separated by a comma. For example ">3,<= 20" means 1183 the Element value MUST be greater than 3 and less than or equal to 1184 20. 1186 A special form of lower and upper bounds using the "-" separator is 1187 possible, meaning the Element value MUST be greater than or to the 1188 first value and MUST be less than or equal to the second value. For 1189 example "1-10" is equivalent to ">=1,<=10". If the upper boundary is 1190 negative, only the latter form MUST be used. 1192 11.1.5.7. length 1194 Within an EBML Schema, the XPath of "@length" attribute is 1195 "/EBMLSchema/element/@length". 1197 A value to express the valid length of the Element Data as written 1198 measured in octets. The length provides a constraint in addition to 1199 the Length value of the definition of the corresponding EBML Element 1200 Type. This length MUST be expressed as either a non-negative integer 1201 or a range (see Section 11.1.5.6.1) that consists of only non- 1202 negative integers and valid operators. 1204 The length attribute is OPTIONAL. If the length attribute is not 1205 present for that EBML Element then that EBML Element is only limited 1206 in length by the definition of the associated EBML Element Type. 1208 11.1.5.8. default 1210 Within an EBML Schema, the XPath of "@default" attribute is 1211 "/EBMLSchema/element/@default". 1213 If an Element is mandatory (has a minOccurs value greater than zero) 1214 but not written within its Parent Element or stored as an Empty 1215 Element, then the EBML Reader of the EBML Document MUST semantically 1216 interpret the EBML Element as present with this specified default 1217 value for the EBML Element. An unwritten mandatory Element with a 1218 declared default value is semantically equivalent to that Element if 1219 written with the default value stored as the Element Data. EBML 1220 Elements that are Master Elements MUST NOT declare a default value. 1221 EBML Elements with a minOccurs value greater than 1 MUST NOT declare 1222 a default value. 1224 The default attribute is OPTIONAL. 1226 11.1.5.9. type 1228 Within an EBML Schema, the XPath of "@type" attribute is 1229 "/EBMLSchema/element/@type". 1231 The type MUST be set to one of the following values: "integer" 1232 (signed integer), "uinteger" (unsigned integer), "float", "string", 1233 "date", "utf-8", "master", or "binary". The content of each type is 1234 defined within Section 7. 1236 The type attribute is REQUIRED. 1238 11.1.5.10. unknownsizeallowed 1240 Within an EBML Schema, the XPath of "@unknownsizeallowed" attribute 1241 is "/EBMLSchema/element/@unknownsizeallowed". 1243 A boolean to express if an EBML Element is permitted to be Unknown- 1244 Sized Element (having all VINT_DATA bits of Element Data Size set to 1245 1). EBML Elements that are not Master Elements MUST NOT set 1246 unknownsizeallowed to true. An EBML Element that is defined with an 1247 unknownsizeallowed attribute set to 1 MUST also have the 1248 unknownsizeallowed attribute of its Parent Element set to 1. 1250 An EBML Element with the unknownsizeallowed attribute set to 1 MUST 1251 NOT have its recursive attribute set to 1. 1253 The unknownsizeallowed attribute is OPTIONAL. If the 1254 unknownsizeallowed attribute is not used then that EBML Element is 1255 not allowed to use an unknown Element Data Size. 1257 11.1.5.11. recursive 1259 Within an EBML Schema, the XPath of "@recursive" attribute is 1260 "/EBMLSchema/element/@recursive". 1262 A boolean to express if an EBML Element is permitted to be stored 1263 recursively. In this case the EBML Element MAY be stored within 1264 another EBML Element that has the same Element ID. Which itself can 1265 be stored in an EBML Element that has the same Element ID, and so on. 1266 EBML Elements that are not Master Elements MUST NOT set recursive to 1267 true. 1269 If the path contains an EBMLPathAtomRecursive part then the recursive 1270 value MUST be true and false otherwise. 1272 An EBML Element with the recursive attribute set to 1 MUST NOT have 1273 its unknownsizeallowed attribute set to 1. 1275 The recursive attribute is OPTIONAL. If the recursive attribute is 1276 not present then the EBML Element MUST NOT be used recursively. 1278 11.1.5.12. recurring 1280 Within an EBML Schema, the XPath of "@recurring" attribute is 1281 "/EBMLSchema/element/@recurring". 1283 A boolean to express if an EBML Element is defined as an Identically 1284 Recurring Element or not. 1286 The recurring attribute is OPTIONAL. If the recurring attribute is 1287 not present then the EBML Element is not an Identically Recurring 1288 Element. 1290 11.1.5.13. minver 1292 Within an EBML Schema, the XPath of "@minver" attribute is 1293 "/EBMLSchema/element/@minver". 1295 The minver (minimum version) attribute stores a non-negative integer 1296 that represents the first version of the docType to support the EBML 1297 Element. 1299 The minver attribute is OPTIONAL. If the minver attribute is not 1300 present, then the EBML Element has a minimum version of "1". 1302 11.1.5.14. maxver 1304 Within an EBML Schema, the XPath of "@maxver" attribute is 1305 "/EBMLSchema/element/@maxver". 1307 The maxver (maximum version) attribute stores a non-negative integer 1308 that represents the last or most recent version of the docType to 1309 support the element. maxver MUST be greater than or equal to minver. 1311 The maxver attribute is OPTIONAL. If the maxver attribute is not 1312 present then the EBML Element has a maximum version equal to the 1313 value stored in the version attribute of "". 1315 11.1.6. Element 1317 Within an EBML Schema, the XPath of "" attribute is 1318 "/EBMLSchema/element/documentation". 1320 The "" element provides additional information about 1321 the EBML Element. Within the "" element the following 1322 XHTML [W3C.SPSD-xhtml-basic-20180327] elements MAY be used: "", 1323 "
", "". 1325 11.1.7. Attributes 1327 11.1.7.1. lang 1329 Within an EBML Schema, the XPath of "@lang" attribute is 1330 "/EBMLSchema/element/documentation/@lang". 1332 A lang attribute which is set to the [RFC5646] value of the language 1333 of the element's documentation. 1335 The lang attribute is OPTIONAL. 1337 11.1.7.2. purpose 1339 Within an EBML Schema, the XPath of "@purpose" attribute is 1340 "/EBMLSchema/element/documentation/@purpose". 1342 A purpose attribute distinguishes the meaning of the documentation. 1343 Values for the "" sub-element's purpose attribute MUST 1344 include one of the following: "definition", "rationale", "usage 1345 notes", and "references". 1347 The purpose attribute is REQUIRED. 1349 11.1.8. Element 1351 Within an EBML Schema, the XPath of "" attribute 1352 is "/EBMLSchema/element/implementation_note". 1354 In some cases within an EBML Document Type, the attributes of the 1355 "" element are not sufficient to clearly communicate how the 1356 defined EBML Element is intended to be implemented. For instance, 1357 one EBML Element might only be mandatory if another EBML Element is 1358 present, or as another example, the default value of an EBML Element 1359 might derive from a related Element's content. In these cases where 1360 the Element's definition is conditional or advanced implementation 1361 notes are needed, one or many "" elements can be 1362 used to store that information. The "" refer to 1363 a specific attribute of the parent "" as expressed by the 1364 "note_attribute" attribute Section 11.1.9.1. 1366 11.1.9. Attributes 1368 11.1.9.1. note_attribute 1370 Within an EBML Schema, the XPath of "@note_attribute" attribute is 1371 "/EBMLSchema/element/implementation_note/@note_attribute". 1373 The note_attribute attribute references which of the ""'s 1374 attributes that the implementation_note is in regards to. The 1375 note_attribute attribute MUST be set to one of the following values 1376 (corresponding to that attribute of the parent ""): 1377 "minOccurs", "maxOccurs", "range", "length", "default", "minver", or 1378 "maxver". The "" SHALL supersede the parent 1379 ""'s attribute that is named in the "note_attribute" 1380 attribute. An "" SHALL NOT have more than one 1381 "" of the same "note_attribute". 1383 The note_attribute attribute is REQUIRED. 1385 11.1.9.2. Example 1387 The following fragment of an EBML Schema demonstrates how an 1388 "" is used. In this case an EBML Schema 1389 documents a list of items that are described with an optional cost. 1390 The Currency Element uses an "" to say that the 1391 Currency Element is REQUIRED if the Cost Element is set, otherwise 1392 not. 1394 1396 1397 A set of items. 1398 1399 1400 1402 1403 An item. 1404 1405 1406 1408 1409 The cost of the item, if any. 1410 1411 1412 1414 1415 The currency of the item's cost. 1416 1417 1418 Currency MUST be set (minOccurs=1) if the associated Item stores 1419 a Cost, else Currency MAY be unset (minOccurs=0). 1420 1421 1423 11.1.10. Element 1425 Within an EBML Schema, the XPath of "" attribute is 1426 "/EBMLSchema/element/restriction". 1428 The "" element provides information about restrictions 1429 to the allowable values for the EBML Element which are listed in 1430 "" elements. 1432 11.1.11. Element 1434 Within an EBML Schema, the XPath of "" attribute is 1435 "/EBMLSchema/element/restriction/enum". 1437 The "" element stores a list of values allowed for storage in 1438 the EBML Element. The values MUST match the type of the EBML Element 1439 (for example "" cannot be a valid value for a EBML 1440 Element that is defined as an unsigned integer). An "" element 1441 MAY also store "" elements to further describe the 1442 "". 1444 11.1.12. Attributes 1446 11.1.12.1. label 1448 Within an EBML Schema, the XPath of "@label" attribute is 1449 "/EBMLSchema/element/restriction/enum/@label". 1451 The label provides a concise expression for human consumption that 1452 describes what the value of the "" represents. 1454 The label attribute is OPTIONAL. 1456 11.1.12.2. value 1458 Within an EBML Schema, the XPath of "@value" attribute is 1459 "/EBMLSchema/element/restriction/enum/@value". 1461 The value represents data that MAY be stored within the EBML Element. 1463 The value attribute is REQUIRED. 1465 11.1.13. Element 1467 Within an EBML Schema, the XPath of "" attribute is 1468 "/EBMLSchema/element/extension". 1470 The "" element provides an unconstrained element to 1471 contain information about the associated EBML "" which is 1472 undefined by this document but MAY be defined by the associated EBML 1473 Document Type. The "" element MUST contain a "type" 1474 attribute and also MAY contain any other attribute or sub-element as 1475 long as the EBML Schema remains as a well-formed XML Document. All 1476 "" elements MUST be sub-elements of the "". 1478 11.1.14. Attributes 1479 11.1.14.1. type 1481 Within an EBML Schema, the XPath of "@type" attribute is 1482 "/EBMLSchema/element/extension/@type". 1484 The type attribute should reference a name or identifier of the 1485 project or authority associated with the contents of the 1486 "" element. 1488 The type attribute is REQUIRED. 1490 11.1.15. XML Schema for EBML Schema 1492 This following provides an XML Schema [W3C.REC-xmlschema-0-20041028] 1493 for facilitating verification of an EBML Schema to the definition 1494 described in Section 8.1. 1496 1497 1503 1504 1507 1509 1510 1511 1513 1514 1515 1516 1518 1519 1520 1522 1524 1526 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1599 1600 1601 1603 1604 1606 1607 1608 1610 1611 1612 1613 1615 1616 1617 1619 1620 1621 1622 1623 1624 1625 1627 1629 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1666 11.1.16. Identically Recurring Elements 1668 An Identically Recurring Element is an EBML Element that MAY occur 1669 within its Parent Element more than once but that each recurrence 1670 within that Parent Element MUST be identical both in storage and 1671 semantics. Identically Recurring Elements are permitted to be stored 1672 multiple times within the same Parent Element in order to increase 1673 data resilience and optimize the use of EBML in transmission. For 1674 instance a pertinent Top-Level Element could be periodically resent 1675 within a data stream so that an EBML Reader which starts reading the 1676 stream from the middle could better interpret the contents. 1677 Identically Recurring Elements SHOULD include a CRC-32 Element as a 1678 Child Element; this is especially recommended when EBML is used for 1679 long-term storage or transmission. If a Parent Element contains more 1680 than one copy of an Identically Recurring Element which includes a 1681 CRC-32 Element as a Child Element then the first instance of the 1682 Identically Recurring Element with a valid CRC-32 value should be 1683 used for interpretation. If a Parent Element contains more than one 1684 copy of an Identically Recurring Element which does not contain a 1685 CRC-32 Element or if CRC-32 Elements are present but none are valid 1686 then the first instance of the Identically Recurring Element should 1687 be used for interpretation. 1689 11.1.17. Textual expression of floats 1691 When a float value is represented textually in an EBML Schema, such 1692 as within a default or range value, the float values MUST be 1693 expressed as Hexadecimal Floating-Point Constants as defined in the 1694 C11 standard [ISO.9899.2011] (see section 6.4.4.2 on Floating 1695 Constants). The following table provides examples of expressions of 1696 float ranges. 1698 +-------------------+-----------------------------------------+ 1699 | as decimal | as Hexadecimal Floating-Point Constants | 1700 +===================+=========================================+ 1701 | 0.0 | "0x0p+1" | 1702 +-------------------+-----------------------------------------+ 1703 | 0.0-1.0 | "0x0p+1-0x1p+0" | 1704 +-------------------+-----------------------------------------+ 1705 | 1.0-256.0 | "0x1p+0-0x1p+8" | 1706 +-------------------+-----------------------------------------+ 1707 | 0.857421875 | "0x1.b7p-1" | 1708 +-------------------+-----------------------------------------+ 1709 | -1.0--0.857421875 | "-0x1p+0--0x1.b7p-1" | 1710 +-------------------+-----------------------------------------+ 1712 Table 8 1714 Within an expression of a float range, as in an integer range, the - 1715 (hyphen) character is the separator between the minimal and maximum 1716 value permitted by the range. Hexadecimal Floating-Point Constants 1717 also use a - (hyphen) when indicating a negative binary power. 1718 Within a float range, when a - (hyphen) is immediately preceded by a 1719 letter p, then the - (hyphen) is a part of the Hexadecimal Floating- 1720 Point Constant which notes negative binary power. Within a float 1721 range, when a - (hyphen) is not immediately preceded by a letter p, 1722 then the - (hyphen) represents the separator between the minimal and 1723 maximum value permitted by the range. 1725 11.1.18. Note on the use of default attributes to define Mandatory EBML 1726 Elements 1728 If a Mandatory EBML Element has a default value declared by an EBML 1729 Schema and the value of the EBML Element is equal to the declared 1730 default value then that EBML Element is not required to be present 1731 within the EBML Document if its Parent Element is present. In this 1732 case, the default value of the Mandatory EBML Element MUST be read by 1733 the EBML Reader although the EBML Element is not present within its 1734 Parent Element. 1736 If a Mandatory EBML Element has no default value declared by an EBML 1737 Schema and its Parent Element is present then the EBML Element MUST 1738 be present as well. If a Mandatory EBML Element has a default value 1739 declared by an EBML Schema and its Parent Element is present and the 1740 value of the EBML Element is NOT equal to the declared default value 1741 then the EBML Element MUST be present. 1743 This table clarifies if a Mandatory EBML Element MUST be written, 1744 according to if the default value is declared, if the value of the 1745 EBML Element is equal to the declared default value, and if the 1746 Parent Element is used. 1748 +-----------------+-------------+---------------+------------------+ 1749 | Is the default | Is the | Is the Parent | Then is storing | 1750 | value declared? | value equal | Element | the EBML Element | 1751 | | to default? | present? | REQUIRED? | 1752 +=================+=============+===============+==================+ 1753 | Yes | Yes | Yes | No | 1754 +-----------------+-------------+---------------+------------------+ 1755 | Yes | Yes | No | No | 1756 +-----------------+-------------+---------------+------------------+ 1757 | Yes | No | Yes | Yes | 1758 +-----------------+-------------+---------------+------------------+ 1759 | Yes | No | No | No | 1760 +-----------------+-------------+---------------+------------------+ 1761 | No | n/a | Yes | Yes | 1762 +-----------------+-------------+---------------+------------------+ 1763 | No | n/a | No | No | 1764 +-----------------+-------------+---------------+------------------+ 1766 Table 9 1768 11.2. EBML Header Elements 1770 This document contains definitions of all EBML Elements of the EBML 1771 Header. 1773 11.2.1. EBML Element 1775 name: EBML 1777 path: "1*1(\EBML)" 1779 id: 0x1A45DFA3 1781 minOccurs: 1 1783 maxOccurs: 1 1785 type: Master Element 1787 description: Set the EBML characteristics of the data to follow. 1788 Each EBML Document has to start with this. 1790 11.2.2. EBMLVersion Element 1792 name: EBMLVersion 1794 path: "1*1(\EBML\EBMLVersion)" 1795 id 0x4286 1797 minOccurs: 1 1799 maxOccurs: 1 1801 range: not 0 1803 default: 1 1805 type: Unsigned Integer 1807 description: The version of EBML specifications used to create the 1808 EBML Document. The version of EBML defined in this document is 1, so 1809 EBMLVersion SHOULD be 1. 1811 11.2.3. EBMLReadVersion Element 1813 name: EBMLReadVersion 1815 path: "1*1(\EBML\EBMLReadVersion)" 1817 id: 0x42F7 1819 minOccurs: 1 1821 maxOccurs: 1 1823 range: 1 1825 default: 1 1827 type: Unsigned Integer 1829 description: The minimum EBML version an EBML Reader has to support 1830 to read this EBML Document. The EBMLReadVersion Element MUST be less 1831 than or equal to EBMLVersion. 1833 11.2.4. EBMLMaxIDLength Element 1835 name: EBMLMaxIDLength 1837 path: "1*1(\EBML\EBMLMaxIDLength)" 1839 id 0x42F2 1841 minOccurs: 1 1842 maxOccurs: 1 1844 range: >=4 1846 default: 4 1848 type: Unsigned Integer 1850 description: The EBMLMaxIDLength Element stores the maximum permitted 1851 length in octets of the Element IDs to be found within the EBML Body. 1852 An EBMLMaxIDLength Element value of four is RECOMMENDED, though 1853 larger values are allowed. 1855 11.2.5. EBMLMaxSizeLength Element 1857 name: EBMLMaxSizeLength 1859 path: "1*1(\EBML\EBMLMaxSizeLength)" 1861 id 0x42F3 1863 minOccurs: 1 1865 maxOccurs: 1 1867 range: not 0 1869 default: 8 1871 type: Unsigned Integer 1873 description: The EBMLMaxSizeLength Element stores the maximum 1874 permitted length in octets of the expressions of all Element Data 1875 Sizes to be found within the EBML Body. The EBMLMaxSizeLength 1876 Element documents an upper bound for the "length" of all Element Data 1877 Size expressions within the EBML Body and not an upper bound for the 1878 "value" of all Element Data Size expressions within the EBML Body. 1879 EBML Elements that have an Element Data Size expression which is 1880 larger in octets than what is expressed by EBMLMaxSizeLength Element 1881 are invalid. 1883 11.2.6. DocType Element 1885 name: DocType 1887 path: "1*1(\EBML\DocType)" 1889 id 0x4282 1890 minOccurs: 1 1892 maxOccurs: 1 1894 length: >0 1896 type: String 1898 description: A string that describes and identifies the content of 1899 the EBML Body that follows this EBML Header. 1901 11.2.7. DocTypeVersion Element 1903 name: DocTypeVersion 1905 path: "1*1(\EBML\DocTypeVersion)" 1907 id 0x4287 1909 minOccurs: 1 1911 maxOccurs: 1 1913 range: not 0 1915 default: 1 1917 type: Unsigned Integer 1919 description: The version of DocType interpreter used to create the 1920 EBML Document. 1922 11.2.8. DocTypeReadVersion Element 1924 name: DocTypeReadVersion 1926 path: "1*1(\EBML\DocTypeReadVersion)" 1928 id 0x4285 1930 minOccurs: 1 1932 maxOccurs: 1 1934 range: not 0 1936 default: 1 1937 type: Unsigned Integer 1939 description: The minimum DocType version an EBML Reader has to 1940 support to read this EBML Document. The value of the 1941 DocTypeReadVersion Element MUST be less than or equal to the value of 1942 the DocTypeVersion Element. 1944 11.2.9. DocTypeExtension Element 1946 name: DocTypeExtension 1948 path: "0*(\EBML\DocTypeExtension)" 1950 id 0x4281 1952 minOccurs: 0 1954 type: Master Element 1956 description: A DocTypeExtension adds extra Elements to the main 1957 DocType+DocTypeVersion tuple it's attached to. An EBML Reader MAY 1958 know these extra Elements and how to use them. A DocTypeExtension 1959 MAY be used to iterate between experimental Elements before they are 1960 integrated in a regular DocTypeVersion. Reading one DocTypeExtension 1961 version of a DocType+DocTypeVersion tuple doesn't imply one should be 1962 able to read upper versions of this DocTypeExtension. 1964 11.2.10. DocTypeExtensionName Element 1966 name: DocTypeExtensionName 1968 path: "1*1(\EBML\DocTypeExtension\Name)" 1970 id 0x4283 1972 minOccurs: 1 1974 maxOccurs: 1 1976 length: >0 1978 type: String 1980 description: The name of the DocTypeExtension to differentiate it 1981 from other DocTypeExtension of the same DocType+DocTypeVersion tuple. 1982 A DocTypeExtensionName value MUST be unique within the EBML Header. 1984 11.2.11. DocTypeExtensionVersion Element 1986 name: DocTypeExtensionVersion 1988 path: "1*1(\EBML\DocTypeExtension\Version)" 1990 id 0x4284 1992 minOccurs: 1 1994 maxOccurs: 1 1996 range: not 0 1998 type: Unsigned Integer 2000 description: The version of the DocTypeExtension. Different 2001 DocTypeExtensionVersion values of the same 2002 DocType+DocTypeVersion+DocTypeExtensionName tuple MAY contain 2003 completely different sets of extra Elements. An EBML Reader MAY 2004 support multiple versions of the same DocTypeExtension, only one or 2005 none. 2007 11.3. Global Elements 2009 EBML allows some special Elements to be found within more than one 2010 parent in an EBML Document or optionally at the Root Level of an EBML 2011 Body. These Elements are called Global Elements. There are 2 Global 2012 Elements that can be found in any EBML Document: the CRC-32 Element 2013 and the Void Element. An EBML Schema MAY add other Global Elements 2014 to the format it defines. These extra elements apply only to the 2015 EBML Body, not the EBML Header. 2017 Global Elements are EBML Elements whose path have a EBMLGlobalParent 2018 as their EBMLLastParent. Because it is the last Parent part of the 2019 path, a Global Element might also have non-EBMLGlobalParent parts in 2020 its path. In this case the Global Element can only be found within 2021 this non-EBMLGlobalParent path, i.e. it's not fully "global". 2023 A Global Element can be found in many Parent Elements, allowing the 2024 same number of occurrences in each Parent where this Element is 2025 found. 2027 11.3.1. CRC-32 Element 2029 name: CRC-32 2031 path: "*1((1*\)\CRC-32)" 2032 id: 0xBF 2034 minOccurs: 0 2036 maxOccurs: 1 2038 length: 4 2040 type: Binary 2042 description: The CRC-32 Element contains a 32-bit Cyclic Redundancy 2043 Check value of all the Element Data of the Parent Element as stored 2044 except for the CRC-32 Element itself. When the CRC-32 Element is 2045 present, the CRC-32 Element MUST be the first ordered EBML Element 2046 within its Parent Element for easier reading. All Top-Level Elements 2047 of an EBML Document that are Master Elements SHOULD include a CRC-32 2048 Element as a Child Element. The CRC in use is the IEEE-CRC-32 2049 algorithm as used in the [ISO.3309.1979] standard and in section 2050 8.1.1.6.2 of [ITU.V42.1994], with initial value of 0xFFFFFFFF. The 2051 CRC value MUST be computed on a little endian bitstream and MUST use 2052 little endian storage. 2054 11.3.2. Void Element 2056 name: Void 2058 path: "*((*\)\Void)" 2060 id: 0xEC 2062 minOccurs: 0 2064 type: Binary 2066 description: Used to void data or to avoid unexpected behaviors when 2067 using damaged data. The content is discarded. Also used to reserve 2068 space in a sub-element for later use. 2070 12. Considerations for Reading EBML Data 2072 The following scenarios describe events to consider when reading EBML 2073 Documents and the recommended design of an EBML Reader. 2075 If a Master Element contains a CRC-32 Element that doesn't validate, 2076 then the EBML Reader MAY ignore all contained data except for 2077 Descendant Elements that contain their own valid CRC-32 Element. 2079 In the following XML representation of a simple, hypothetical EBML 2080 fragment, a Master Element called CONTACT contains two Child 2081 Elements, NAME and ADDRESS. In this example, some data within the 2082 NAME Element had been altered, so that the CRC-32 of the NAME Element 2083 does not validate and thus any Ancestor Element with a CRC-32 would 2084 therefore also no longer validate. However, even though the CONTACT 2085 Element has a CRC-32 that does not validate (because of the changed 2086 data within the NAME Element), the CRC-32 of the ADDRESS Element does 2087 validate and thus the contents and semantics of the ADDRESS Element 2088 MAY be used. 2090 2091 c119a69b 2092 2093 1f59ee2b 2094 invalid data 2095 invalid data 2096 2097
2098 df941cc9 2099 valid data 2100 valid data 2101
2102
2104 If a Master Element contains more occurrences of a Child Master 2105 Element than permitted according to the maxOccurs and recurring 2106 attributes of the definition of that Element then the occurrences in 2107 addition to maxOccurs MAY be ignored. 2109 If a Master Element contains more occurrences of a Child Element than 2110 permitted according to the maxOccurs attribute of the definition of 2111 that Element then all instances of that Element after the first 2112 maxOccur occurrences from the beginning of its Parent Element SHOULD 2113 be ignored. 2115 13. Terminating Elements 2117 Null Octets, which are octets with all bits set to zero, MAY follow 2118 the value of a String Element or UTF-8 Element to serve as a 2119 terminator. An EBML Writer MAY terminate a String Element or UTF-8 2120 Element with Null Octets in order to overwrite a stored value with a 2121 new value of lesser length while maintaining the same Element Data 2122 Size (this can prevent the need to rewrite large portions of an EBML 2123 Document); otherwise the use of Null Octets within a String Element 2124 or UTF-8 Element is NOT RECOMMENDED. An EBML Reader MUST consider 2125 the value of the String Element or UTF-8 Element to be terminated 2126 upon the first read Null Octet and MUST ignore any data following the 2127 first Null Octet within that Element. A string value and a copy of 2128 that string value terminated by one or more Null Octets are 2129 semantically equal. 2131 The following table shows examples of semantics and validation for 2132 the use of Null Octets. Values to represent Stored Values and the 2133 Semantic Meaning as represented as hexadecimal values. 2135 +---------------------+---------------------+ 2136 | Stored Value | Semantic Meaning | 2137 +=====================+=====================+ 2138 | 0x65 0x62 0x6D 0x6C | 0x65 0x62 0x6D 0x6C | 2139 +---------------------+---------------------+ 2140 | 0x65 0x62 0x00 0x6C | 0x65 0x62 | 2141 +---------------------+---------------------+ 2142 | 0x65 0x62 0x00 0x00 | 0x65 0x62 | 2143 +---------------------+---------------------+ 2144 | 0x65 0x62 | 0x65 0x62 | 2145 +---------------------+---------------------+ 2147 Table 10 2149 14. Guidelines for Updating Elements 2151 An EBML Document can be updated without requiring that the entire 2152 EBML Document be rewritten. These recommendations describe 2153 strategies to change the Element Data of a written EBML Element with 2154 minimal disruption to the rest of the EBML Document. 2156 14.1. Reducing a Element Data in Size 2158 There are three methods to reduce the size of Element Data of a 2159 written EBML Element. 2161 14.1.1. Adding a Void Element 2163 When an EBML Element is changed to reduce its total length by more 2164 than one octet, an EBML Writer SHOULD fill the freed space with a 2165 Void Element. 2167 14.1.2. Extending the Element Data Size 2169 The same value for Element Data Size MAY be written in variable 2170 lengths, so for minor reductions in octet length the Element Data 2171 Size MAY be written to a longer octet length to fill the freed space. 2173 For example, the first row of the following table depicts a String 2174 Element that stores an Element ID (3 octets), Element Data Size (1 2175 octet), and Element Data (4 octets). If the Element Data is changed 2176 to reduce the length by one octet and if the current length of the 2177 Element Data Size is less than its maximum permitted length, then the 2178 Element Data Size of that Element MAY be rewritten to increase its 2179 length by one octet. Thus before and after the change the EBML 2180 Element maintains the same length of 8 octets and data around the 2181 Element does not need to be moved. 2183 +-------------+------------+-------------------+--------------+ 2184 | Status | Element ID | Element Data Size | Element Data | 2185 +=============+============+===================+==============+ 2186 | Before edit | 0x3B4040 | 0x84 | 0x65626D6C | 2187 +-------------+------------+-------------------+--------------+ 2188 | After edit | 0x3B4040 | 0x4003 | 0x6D6B76 | 2189 +-------------+------------+-------------------+--------------+ 2191 Table 11 2193 This method is RECOMMENDED when the Element Data is reduced by a 2194 single octet; for reductions by two or more octets it is RECOMMENDED 2195 to fill the freed space with a Void Element. 2197 Note that if the Element Data length needs to be rewritten as 2198 shortened by one octet and the Element Data Size could be rewritten 2199 as a shorter VINT then it is RECOMMENDED to rewrite the Element Data 2200 Size as one octet shorter, shorten the Element Data by one octet, and 2201 follow that Element with a Void Element. For example, the following 2202 table depicts a String Element that stores an Element ID (3 octets), 2203 Element Data Size (2 octets, but could be rewritten in one octet), 2204 and Element Data (3 octets). If the Element Data is to be rewritten 2205 to a two octet length, then another octet can be taken from Element 2206 Data Size so that there is enough space to add a two octet Void 2207 Element. 2209 +--------+------------+-------------------+--------------+---------+ 2210 | Status | Element ID | Element Data Size | Element Data | Void | 2211 | | | | | Element | 2212 +========+============+===================+==============+=========+ 2213 | Before | 0x3B4040 | 0x4003 | 0x6D6B76 | | 2214 +--------+------------+-------------------+--------------+---------+ 2215 | After | 0x3B4040 | 0x82 | 0x6869 | 0xEC80 | 2216 +--------+------------+-------------------+--------------+---------+ 2218 Table 12 2220 14.1.3. Terminating Element Data 2222 For String Elements and UTF-8 Elements the length of Element Data MAY 2223 be reduced by adding Null Octets to terminate the Element Data (see 2224 Section 13). 2226 In the following table, a four octets long Element Data is changed to 2227 a three octet long value followed by a Null Octet; the Element Data 2228 Size includes any Null Octets used to terminate Element Data so 2229 remains unchanged. 2231 +-------------+------------+-------------------+--------------+ 2232 | Status | Element ID | Element Data Size | Element Data | 2233 +=============+============+===================+==============+ 2234 | Before edit | 0x3B4040 | 0x84 | 0x65626D6C | 2235 +-------------+------------+-------------------+--------------+ 2236 | After edit | 0x3B4040 | 0x84 | 0x6D6B7600 | 2237 +-------------+------------+-------------------+--------------+ 2239 Table 13 2241 Note that this method is NOT RECOMMENDED. For reductions of one 2242 octet, the method for Extending the Element Data Size SHOULD be used. 2243 For reduction by more than one octet, the method for Adding a Void 2244 Element SHOULD be used. 2246 14.2. Considerations when Updating Elements with Cyclic Redundancy 2247 Check (CRC) 2249 If the Element to be changed is a Descendant Element of any Master 2250 Element that contains a CRC-32 Element (see Section 11.3.1) then the 2251 CRC-32 Element MUST be verified before permitting the change. 2252 Additionally the CRC-32 Element value MUST be subsequently updated to 2253 reflect the changed data. 2255 15. Backward and Forward Compatibility 2257 Elements of an EBML format SHOULD be designed with backward and 2258 forward compatibility in mind. 2260 15.1. Backward Compatibility 2262 Backward compatibility of new EBML Elements can be achieved by using 2263 default values for mandatory elements. The default value MUST 2264 represent the state that was assumed for previous versions of the 2265 EBML Schema, without this new EBML Element. If such a state doesn't 2266 make sense for previous versions, then the new EBML Element SHOULD 2267 NOT be mandatory. 2269 Non mandatory EBML Elements can be added in a new EBMLDocTypeVersion. 2270 Since they are not mandatory they won't be found in older versions of 2271 the EBMLDocTypeVersion, just as they might not be found in newer 2272 versions. This causes no compatibility issue. 2274 15.2. Forward Compatibility 2276 EBML Elements MAY be marked as deprecated in a new EBMLDocTypeVersion 2277 using the maxver attribute of the EBML Schema. If such an Element is 2278 found in an EBML Document with newer version of the 2279 EBMLDocTypeVersion it SHOULD be discarded. 2281 16. Security Considerations 2283 EBML itself does not offer any kind of security and does not provide 2284 confidentiality. EBML does not provide any kind of authorization. 2285 EBML only offers marginally useful and effective data integrity 2286 options, such as CRC elements. 2288 Even if the semantic layer offers any kind of encryption, EBML itself 2289 could leak information at both the semantic layer (as declared via 2290 the DocType Element) and within the EBML structure (the presence of 2291 EBML Elements can be derived even with an unknown semantic layer 2292 using a heuristic approach; not without errors, of course, but with a 2293 certain degree of confidence). 2295 An EBML Document that has the following issues may still be handled 2296 by the EBML Reader and the data accepted as such, depending on how 2297 strict the EBML Reader wants to be: 2299 * Invalid Element IDs that are longer than the limit stated in the 2300 EBMLMaxIDLength Element of the EBML Header. 2302 * Invalid Element IDs that are not encoded in the shortest-possible 2303 way. 2305 * Invalid Element Data Size values that are longer than the limit 2306 stated in the EBMLMaxSizeLength Element of the EBML Header. 2308 Element IDs that are unknown to the EBML Reader MAY be accepted as 2309 valid EBML IDs in order to skip such elements. 2311 EBML Elements with a string type may contain extra data after the 2312 first 0x00. These data MUST be discarded according to the Section 13 2313 rules. 2315 An EBML Reader may discard some or all data if the following errors 2316 are found in the EBML Document: 2318 * Invalid Element Data Size values (e.g. extending the length of the 2319 EBML Element beyond the scope of the Parent Element; possibly 2320 triggering access-out-of-bounds issues). 2322 * Very high lengths in order to force out-of-memory situations 2323 resulting in a denial of service, access-out-of-bounds issues etc. 2325 * Missing EBML Elements that are mandatory in a Master Element and 2326 have no declared default value, making the semantic invalid at 2327 that Master Element level. 2329 * Usage of invalid UTF-8 encoding in EBML Elements of UTF-8 type 2330 (e.g. in order to trigger access-out-of-bounds or buffer overflow 2331 issues). 2333 * Usage of invalid data in EBML Elements with a date type, 2334 triggering bogus date accesses. 2336 Side channel attacks could exploit: 2338 * The semantic equivalence of the same string stored in a String 2339 Element or UTF-8 Element with and without zero-bit padding, making 2340 comparison at the semantic level invalid. 2342 * The semantic equivalence of VINT_DATA within Element Data Size 2343 with two different lengths due to left-padding zero bits, making 2344 comparison at the semantic level invalid. 2346 * Data contained within a Master Element which is not itself part of 2347 a Child Element can trigger incorrect parsing behavior in EBML 2348 Readers. 2350 * Extraneous copies of Identically Recurring Element, making parsing 2351 unnecessarily slow to the point of not being usable. 2353 * Copies of Identically Recurring Element within a Parent Element 2354 that contain invalid CRC-32 Elements. EBML Readers not checking 2355 the CRC-32 might use the version of the element with mismatching 2356 CRC-32. 2358 * Use of Void Elements which could be used to hide content or create 2359 bogus resynchronization points seen by some EBML Reader and not 2360 others. 2362 17. IANA Considerations 2363 17.1. CELLAR EBML Element ID Registry 2365 This document creates a new IANA Registry called "CELLAR EBML Element 2366 ID Registry". 2368 Element IDs are described in section Element ID. Element IDs are 2369 encoded using the VINT mechanism described in section Section 4 can 2370 be between one and five octets long. Five octet long Element IDs are 2371 possible only if declared in the header. 2373 This IANA Registry only applies to Elements that can be contained in 2374 the EBML Header, thus including Global Elements. Elements only found 2375 in the EBML Body have their own set of independent Element IDs and 2376 are not part of this IANA Registry. 2378 The VINT Data value of one-octet Element IDs MUST be between 0x01 and 2379 0x7E. These items are valuable because they are short, and need to 2380 be used for commonly repeated elements. Values from 1 to 126 are to 2381 be allocated according to the "RFC Required" policy [RFC8126]. 2383 The VINT Data value of two-octet Element IDs MUST be between 0x007F 2384 and 0x3FFE. Numbers are to be allocated within this range according 2385 to the "Specification Required" policy [RFC8126]. 2387 The numbers 0x3FFF and 0x4000 are RESERVED. 2389 The VINT Data value of three-octet Element IDs MUST be between 0x4001 2390 and 0x1FFFFE. Numbers may be allocated within this range according 2391 to the "First Come First Served" policy [RFC8126]. 2393 The numbers 0x1FFFFF and 0x200000 are RESERVED. 2395 Four-octet Element IDs are numbers between 0x101FFFFF and 0x1FFFFFFE. 2396 Four-octet Element IDs are somewhat special in that they are useful 2397 for resynchronizing to major structures in the event of data 2398 corruption or loss. As such four-octet Element IDs are split into 2399 two categories. Four-octet Element IDs whose lower three octets (as 2400 encoded) would make printable 7-bit ASCII values (0x20 to 0x7E, 2401 inclusive) MUST be allocated by the "Specification Required" policy. 2402 Sequential allocation of values is not required: specifications 2403 SHOULD include a specific request, and are encouraged to do early 2404 allocations. 2406 To be clear about the above category: four-octet Element IDs always 2407 start with hex 0x10 to 0x1F, and that octet may be chosen so that the 2408 entire number has some desirable property, such as a specific CRC. 2409 The other three octets, when ALL having values between 0x21 (33, 2410 ASCII !) and 0x7E (126, ASCII ~), fall into this category. 2412 Other four-octet Element IDs may be allocated by the "First Come 2413 First Served" policy. 2415 The numbers 0xFFFFFFF and 0x1000000 are RESERVED. 2417 Five octet Element IDs (values from 0x10000001 upwards) are RESERVED 2418 according to the "Experimental Use" policy [RFC8126]: they may be 2419 used by anyone at any time, but there is no coordination. 2421 ID Values found in this document are assigned as initial values as 2422 follows: 2424 +------------+-------------------------+-----------------+ 2425 | ID | Element Name | Reference | 2426 +============+=========================+=================+ 2427 | 0x1A45DFA3 | EBML | Described in | 2428 | | | Section 11.2.1 | 2429 +------------+-------------------------+-----------------+ 2430 | 0x4286 | EBMLVersion | Described in | 2431 | | | Section 11.2.2 | 2432 +------------+-------------------------+-----------------+ 2433 | 0x42F7 | EBMLReadVersion | Described in | 2434 | | | Section 11.2.3 | 2435 +------------+-------------------------+-----------------+ 2436 | 0x42F2 | EBMLMaxIDLength | Described in | 2437 | | | Section 11.2.4 | 2438 +------------+-------------------------+-----------------+ 2439 | 0x42F3 | EBMLMaxSizeLength | Described in | 2440 | | | Section 11.2.5 | 2441 +------------+-------------------------+-----------------+ 2442 | 0x4282 | DocType | Described in | 2443 | | | Section 11.2.6 | 2444 +------------+-------------------------+-----------------+ 2445 | 0x4287 | DocTypeVersion | Described in | 2446 | | | Section 11.2.7 | 2447 +------------+-------------------------+-----------------+ 2448 | 0x4285 | DocTypeReadVersion | Described in | 2449 | | | Section 11.2.8 | 2450 +------------+-------------------------+-----------------+ 2451 | 0x4281 | DocTypeExtension | Described in | 2452 | | | Section 11.2.9 | 2453 +------------+-------------------------+-----------------+ 2454 | 0x4283 | DocTypeExtensionName | Described in | 2455 | | | Section 11.2.10 | 2456 +------------+-------------------------+-----------------+ 2457 | 0x4284 | DocTypeExtensionVersion | Described in | 2458 | | | Section 11.2.11 | 2459 +------------+-------------------------+-----------------+ 2460 | 0xBF | CRC-32 | Described in | 2461 | | | Section 11.3.1 | 2462 +------------+-------------------------+-----------------+ 2463 | 0xEC | Void | Described in | 2464 | | | Section 11.3.2 | 2465 +------------+-------------------------+-----------------+ 2467 Table 14 2469 17.2. CELLAR EBML DocType Registry 2471 This document creates a new IANA Registry called "CELLAR EBML DocType 2472 Registry". 2474 To register a new DocType in this registry one needs a DocType name, 2475 a Description of the DocType, a Change Controller (IESG or email of 2476 registrant) and an optional Reference to a document describing the 2477 DocType. 2479 DocType values are described in Section 11.1.3.1. DocTypes are ASCII 2480 strings, defined in Section 7.4, which label the official name of the 2481 EBML Document Type. The strings may be allocated according to the 2482 "First Come First Served" policy. 2484 The use of ASCII corresponds to the types and code already in use, 2485 the value is not meant to be visible to the user. 2487 DocType string values of "matroska" and "webm" are RESERVED to the 2488 IETF for future use. These can be assigned via the "IESG Approval" 2489 or "RFC Required" policies [RFC8126]. 2491 18. Normative References 2493 [RFC3339] Klyne, G. and C. Newman, "Date and Time on the Internet: 2494 Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002, 2495 . 2497 [W3C.REC-xmlschema-0-20041028] 2498 Fallside, D. and P. Walmsley, "XML Schema Part 0: Primer 2499 Second Edition", World Wide Web Consortium Recommendation 2500 REC-xmlschema-0-20041028, 28 October 2004, 2501 . 2503 [W3C.SPSD-xhtml-basic-20180327] 2504 McCarron, S., "XHTML(tm) Basic 1.1 - Second Edition", 27 2505 March 2018. 2507 [ISO.9899.2011] 2508 International Organization for Standardization, 2509 "Programming languages - C", 2011. 2511 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 2512 Writing an IANA Considerations Section in RFCs", BCP 26, 2513 RFC 8126, DOI 10.17487/RFC8126, June 2017, 2514 . 2516 [W3C.REC-xml-20081126] 2517 Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and 2518 F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth 2519 Edition)", World Wide Web Consortium Recommendation REC- 2520 xml-20081126, 26 November 2008, 2521 . 2523 [IEEE.754.1985] 2524 Institute of Electrical and Electronics Engineers, 2525 "Standard for Binary Floating-Point Arithmetic", August 2526 1985. 2528 [RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", 2529 RFC 7405, DOI 10.17487/RFC7405, December 2014, 2530 . 2532 [RFC5646] Phillips, A., Ed. and M. Davis, Ed., "Tags for Identifying 2533 Languages", BCP 47, RFC 5646, DOI 10.17487/RFC5646, 2534 September 2009, . 2536 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2537 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2538 May 2017, . 2540 [RFC0020] Cerf, V., "ASCII format for network interchange", STD 80, 2541 RFC 20, DOI 10.17487/RFC0020, October 1969, 2542 . 2544 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 2545 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 2546 2003, . 2548 [ISO.3309.1979] 2549 International Organization for Standardization, "Data 2550 communication - High-level data link control procedures - 2551 Frame structure", 1979. 2553 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2554 Requirement Levels", BCP 14, RFC 2119, 2555 DOI 10.17487/RFC2119, March 1997, 2556 . 2558 [ITU.V42.1994] 2559 International Telecommunications Union, "Error-correcting 2560 Procedures for DCEs Using Asynchronous-to-Synchronous 2561 Conversion", 1994. 2563 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 2564 Specifications: ABNF", STD 68, RFC 5234, 2565 DOI 10.17487/RFC5234, January 2008, 2566 . 2568 19. Informative References 2570 [W3C.REC-xpath-19991116] 2571 Clark, J. and S. DeRose, "XML Path Language (XPath) 2572 Version 1.0", World Wide Web Consortium Recommendation 2573 REC-xpath-19991116, 16 November 1999, 2574 . 2576 Authors' Addresses 2578 Steve Lhomme 2580 Email: slhomme@matroska.org 2582 Dave Rice 2584 Email: dave@dericed.com 2586 Moritz Bunkus 2588 Email: moritz@bunkus.org