idnits 2.17.1 draft-ietf-cellar-ebml-13.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 (22 October 2019) is 1647 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 989, but not defined == Missing Reference: 'EBMLMinOccurrence' is mentioned on line 1000, but not defined == Missing Reference: 'EBMLMaxOccurrence' is mentioned on line 1000, but not defined == Missing Reference: 'PathMinOccurrence' is mentioned on line 1003, but not defined == Missing Reference: 'PathMaxOccurrence' is mentioned on line 1003, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'IEEE.754.1985' -- Possible downref: Non-RFC (?) normative reference: ref. 'ITU.V42.1994' Summary: 0 errors (**), 0 flaws (~~), 6 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 cellar S. Lhomme 3 Internet-Draft D. Rice 4 Intended status: Standards Track M. Bunkus 5 Expires: 24 April 2020 22 October 2019 7 Extensible Binary Meta Language 8 draft-ietf-cellar-ebml-13 10 Abstract 12 This document defines the Extensible Binary Meta Language (EBML) 13 format as a generalized file format for any type of data in a 14 hierarchical form. EBML is designed as a binary equivalent to XML 15 and uses a storage-efficient approach to build nested Elements with 16 identifiers, lengths, and values. Similar to how an XML Schema 17 defines the structure and semantics of an XML Document, this document 18 defines how EBML Schemas are created to convey the semantics of an 19 EBML Document. 21 Status of This Memo 23 This Internet-Draft is submitted in full conformance with the 24 provisions of BCP 78 and BCP 79. 26 Internet-Drafts are working documents of the Internet Engineering 27 Task Force (IETF). Note that other groups may also distribute 28 working documents as Internet-Drafts. The list of current Internet- 29 Drafts is at https://datatracker.ietf.org/drafts/current/. 31 Internet-Drafts are draft documents valid for a maximum of six months 32 and may be updated, replaced, or obsoleted by other documents at any 33 time. It is inappropriate to use Internet-Drafts as reference 34 material or to cite them other than as "work in progress." 36 This Internet-Draft will expire on 24 April 2020. 38 Copyright Notice 40 Copyright (c) 2019 IETF Trust and the persons identified as the 41 document authors. All rights reserved. 43 This document is subject to BCP 78 and the IETF Trust's Legal 44 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 45 license-info) in effect on the date of publication of this document. 46 Please review these documents carefully, as they describe your rights 47 and restrictions with respect to this document. Code Components 48 extracted from this document must include Simplified BSD License text 49 as described in Section 4.e of the Trust Legal Provisions and are 50 provided without warranty as described in the Simplified BSD License. 52 Table of Contents 54 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 55 2. Notation and Conventions . . . . . . . . . . . . . . . . . . 4 56 3. Structure . . . . . . . . . . . . . . . . . . . . . . . . . . 7 57 4. Variable Size Integer . . . . . . . . . . . . . . . . . . . . 7 58 4.1. VINT_WIDTH . . . . . . . . . . . . . . . . . . . . . . . 7 59 4.2. VINT_MARKER . . . . . . . . . . . . . . . . . . . . . . . 7 60 4.3. VINT_DATA . . . . . . . . . . . . . . . . . . . . . . . . 8 61 4.4. VINT Examples . . . . . . . . . . . . . . . . . . . . . . 8 62 5. Element ID . . . . . . . . . . . . . . . . . . . . . . . . . 9 63 6. Element Data Size . . . . . . . . . . . . . . . . . . . . . . 11 64 6.1. Data Size Format . . . . . . . . . . . . . . . . . . . . 11 65 6.2. Unknown Data Size . . . . . . . . . . . . . . . . . . . . 11 66 6.3. Data Size Values . . . . . . . . . . . . . . . . . . . . 14 67 7. EBML Element Types . . . . . . . . . . . . . . . . . . . . . 15 68 7.1. Signed Integer Element . . . . . . . . . . . . . . . . . 15 69 7.2. Unsigned Integer Element . . . . . . . . . . . . . . . . 16 70 7.3. Float Element . . . . . . . . . . . . . . . . . . . . . . 16 71 7.4. String Element . . . . . . . . . . . . . . . . . . . . . 16 72 7.5. UTF-8 Element . . . . . . . . . . . . . . . . . . . . . . 16 73 7.6. Date Element . . . . . . . . . . . . . . . . . . . . . . 17 74 7.7. Master Element . . . . . . . . . . . . . . . . . . . . . 17 75 7.8. Binary Element . . . . . . . . . . . . . . . . . . . . . 17 76 8. EBML Document . . . . . . . . . . . . . . . . . . . . . . . . 17 77 8.1. EBML Header . . . . . . . . . . . . . . . . . . . . . . . 18 78 8.2. EBML Body . . . . . . . . . . . . . . . . . . . . . . . . 18 79 9. EBML Stream . . . . . . . . . . . . . . . . . . . . . . . . . 18 80 10. EBML Versioning . . . . . . . . . . . . . . . . . . . . . . . 18 81 10.1. EBML Header Version . . . . . . . . . . . . . . . . . . 19 82 10.2. EBML Document Version . . . . . . . . . . . . . . . . . 19 83 11. Elements semantic . . . . . . . . . . . . . . . . . . . . . . 19 84 11.1. EBML Schema . . . . . . . . . . . . . . . . . . . . . . 19 85 11.1.1. EBML Schema Example . . . . . . . . . . . . . . . . 20 86 11.1.2. Element . . . . . . . . . . . . . . . . 21 87 11.1.3. Attributes . . . . . . . . . . . . . . 21 88 11.1.4. Element . . . . . . . . . . . . . . . . . 21 89 11.1.5. Attributes . . . . . . . . . . . . . . . . 22 90 11.1.6. Element . . . . . . . . . . . . . . 29 91 11.1.7. Attributes . . . . . . . . . . . . . 29 92 11.1.8. Element . . . . . . . . . . . 29 93 11.1.9. Attributes . . . . . . . . . . 29 94 11.1.10. Element . . . . . . . . . . . . . . . 30 95 11.1.11. Element . . . . . . . . . . . . . . . . . . . 30 96 11.1.12. Attributes . . . . . . . . . . . . . . . . . 30 97 11.1.13. Element . . . . . . . . . . . . . . . . 30 98 11.1.14. Attributes . . . . . . . . . . . . . . . 31 99 11.1.15. XML Schema for EBML Schema . . . . . . . . . . . . . 31 100 11.1.16. Identically Recurring Elements . . . . . . . . . . . 33 101 11.1.17. Textual expression of floats . . . . . . . . . . . . 34 102 11.1.18. Note on the use of default attributes to define 103 Mandatory EBML Elements . . . . . . . . . . . . . . . 35 104 11.2. EBML Header Elements . . . . . . . . . . . . . . . . . . 35 105 11.2.1. EBML Element . . . . . . . . . . . . . . . . . . . . 36 106 11.2.2. EBMLVersion Element . . . . . . . . . . . . . . . . 36 107 11.2.3. EBMLReadVersion Element . . . . . . . . . . . . . . 36 108 11.2.4. EBMLMaxIDLength Element . . . . . . . . . . . . . . 37 109 11.2.5. EBMLMaxSizeLength Element . . . . . . . . . . . . . 37 110 11.2.6. DocType Element . . . . . . . . . . . . . . . . . . 38 111 11.2.7. DocTypeVersion Element . . . . . . . . . . . . . . . 38 112 11.2.8. DocTypeReadVersion Element . . . . . . . . . . . . . 39 113 11.2.9. DocTypeExtension Element . . . . . . . . . . . . . . 39 114 11.2.10. DocTypeExtensionName Element . . . . . . . . . . . . 40 115 11.2.11. DocTypeExtensionVersion Element . . . . . . . . . . 40 116 11.3. Global Elements . . . . . . . . . . . . . . . . . . . . 41 117 11.3.1. CRC-32 Element . . . . . . . . . . . . . . . . . . . 41 118 11.3.2. Void Element . . . . . . . . . . . . . . . . . . . . 42 119 12. Considerations for Reading EBML Data . . . . . . . . . . . . 42 120 13. Terminating Elements . . . . . . . . . . . . . . . . . . . . 42 121 14. Guidelines for Updating Elements . . . . . . . . . . . . . . 43 122 14.1. Reducing a Element Data in Size . . . . . . . . . . . . 43 123 14.1.1. Adding a Void Element . . . . . . . . . . . . . . . 43 124 14.1.2. Extending the Element Data Size . . . . . . . . . . 43 125 14.1.3. Terminating Element Data . . . . . . . . . . . . . . 45 126 14.2. Considerations when Updating Elements with Cyclic 127 Redundancy Check (CRC) . . . . . . . . . . . . . . . . . 45 128 15. Backward and Forward Compatibility . . . . . . . . . . . . . 45 129 15.1. Backward Compatibility . . . . . . . . . . . . . . . . . 45 130 15.2. Forward Compatibility . . . . . . . . . . . . . . . . . 46 131 16. Security Considerations . . . . . . . . . . . . . . . . . . . 46 132 17. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 47 133 17.1. CELLAR EBML Element ID Registry . . . . . . . . . . . . 48 134 17.2. CELLAR EBML DocType Registry . . . . . . . . . . . . . . 51 135 18. Normative References . . . . . . . . . . . . . . . . . . . . 51 136 19. Informative References . . . . . . . . . . . . . . . . . . . 52 137 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 53 139 1. Introduction 141 EBML, short for Extensible Binary Meta Language, specifies a binary 142 and octet (byte) aligned format inspired by the principle of XML (a 143 framework for structuring data). 145 The goal of this document is to define a generic, binary, space- 146 efficient format that can be used to define more complex formats 147 using an EBML Schema. EBML is used by the multimedia container 148 Matroska (https://github.com/Matroska-Org/matroska-specification/). 149 The applicability of EBML for other use cases is beyond the scope of 150 this document. 152 The definition of the EBML format recognizes the idea behind HTML and 153 XML as a good one: separate structure and semantics allowing the same 154 structural layer to be used with multiple, possibly widely differing 155 semantic layers. Except for the EBML Header and a few Global 156 Elements this specification does not define particular EBML format 157 semantics; however this specification is intended to define how other 158 EBML-based formats can be defined, such as the audio-video container 159 formats Matroska and WebM. 161 EBML uses a simple approach of building Elements upon three pieces of 162 data (tag, length, and value) as this approach is well known, easy to 163 parse, and allows selective data parsing. The EBML structure 164 additionally allows for hierarchical arrangement to support complex 165 structural formats in an efficient manner. 167 A typical EBML file has the following structure: 169 EBML Header (master) 170 + DocType (string) 171 + DocTypeVersion (unsigned integer) 172 EBML Body Root (master) 173 + ElementA (utf-8) 174 + Parent (master) 175 + ElementB (integer) 176 + Parent (master) 177 + ElementB (integer) 179 2. Notation and Conventions 181 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 182 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 183 "OPTIONAL" in this document are to be interpreted as described in BCP 184 14 [RFC2119] [RFC8174] when, and only when, they appear in all 185 capitals, as shown here. 187 This document defines specific terms in order to define the format 188 and application of "EBML". Specific terms are defined below: 190 "EBML": Extensible Binary Meta Language 191 "EBML Document Type": A name provided by an "EBML Schema" to 192 designate a particular implementation of "EBML" for a data format 193 (e.g.: matroska and webm). 195 "EBML Schema": A standardized definition for the structure of an 196 "EBML Document Type". 198 "EBML Document": A datastream comprised of only two components, an 199 "EBML Header" and an "EBML Body". 201 "EBML Reader": A data parser that interprets the semantics of an 202 "EBML Document" and creates a way for programs to use "EBML". 204 "EBML Stream": A file that consists of one or more "EBML Documents" 205 that are concatenated together. 207 "EBML Header": A declaration that provides processing instructions 208 and identification of the "EBML Body". The "EBML Header" is 209 analogous to an XML Declaration [W3C.REC-xml-20081126] (see section 210 2.8 on Prolog and Document Type Declaration). 212 "EBML Body": All data of an "EBML Document" following the "EBML 213 Header". 215 "Variable Size Integer": A compact variable-length binary value which 216 defines its own length. 218 "VINT": Also known as "Variable Size Integer". 220 "EBML Element": A foundation block of data that contains three parts: 221 an "Element ID", an "Element Data Size", and "Element Data". 223 "Element ID": The "Element ID" is a binary value, encoded as a 224 "Variable Size Integer", used to uniquely identify a defined "EBML 225 Element" within a specific "EBML Schema". 227 "EBML Class": A representation of the octet length of an "Element 228 ID". 230 "Element Data Size": An expression, encoded as a "Variable Size 231 Integer", of the length in octets of "Element Data". 233 "VINTMAX": The maximum possible value that can be stored as "Element 234 Data Size". 236 "Unknown-Sized Element": An "Element" with an unknown "Element Data 237 Size". 239 "Element Data": The value(s) of the "EBML Element" which is 240 identified by its "Element ID" and "Element Data Size". The form of 241 the "Element Data" is defined by this document and the corresponding 242 "EBML Schema" of the Element's "EBML Document Type". 244 "Root Level": The starting level in the hierarchy of an "EBML 245 Document". 247 "Root Element": A mandatory, non-repeating "EBML Element" which 248 occurs at the top level of the path hierarchy within an "EBML Body" 249 and contains all other "EBML Elements" of the "EBML Body", excepting 250 optional "Void Elements". 252 "Top-Level Element": An "EBML Element" defined to only occur as a 253 "Child Element" of the "Root Element". 255 "Master Element": The "Master Element" contains zero, one, or many 256 other "EBML Elements". 258 "Child Element": A "Child Element" is a relative term to describe the 259 "EBML Elements" immediately contained within a "Master Element". 261 "Parent Element": A relative term to describe the "Master Element" 262 which contains a specified element. For any specified "EBML Element" 263 that is not at "Root Level", the "Parent Element" refers to the 264 "Master Element" in which that "EBML Element" is contained. 266 "Descendant Element": A relative term to describe any "EBML Elements" 267 contained within a "Master Element", including any of the "Child 268 Elements" of its "Child Elements", and so on. 270 "Void Element": A "Void Element" is an "Element" used to overwrite 271 data or reserve space within a "Master Element" for later use. 273 "Element Name": The human-readable name of the "EBML Element". 275 "Element Path": The hierarchy of "Parent Element" where the "EBML 276 Element" is expected to be found in the "EBML Body". 278 "Empty Element": An "EBML Element" that has an "Element Data Size" 279 with all "VINT_DATA" bits set to zero, which indicates that the 280 "Element Data" of the "Element" is zero octets in length. 282 3. Structure 284 EBML uses a system of Elements to compose an EBML Document. EBML 285 Elements incorporate three parts: an Element ID, an Element Data 286 Size, and Element Data. The Element Data, which is described by the 287 Element ID, includes either binary data, one or more other EBML 288 Elements, or both. 290 4. Variable Size Integer 292 The Element ID and Element Data Size are both encoded as a Variable 293 Size Integer. The Variable Size Integer is composed of a VINT_WIDTH, 294 VINT_MARKER, and VINT_DATA, in that order. Variable Size Integers 295 MUST left-pad the VINT_DATA value with zero bits so that the whole 296 Variable Size Integer is octet-aligned. Variable Size Integer will 297 be referred to as VINT for shorthand. 299 4.1. VINT_WIDTH 301 Each Variable Size Integer begins with a VINT_WIDTH which consists of 302 zero or many zero-value bits. The count of consecutive zero-values 303 of the VINT_WIDTH plus one equals the length in octets of the 304 Variable Size Integer. For example, a Variable Size Integer that 305 starts with a VINT_WIDTH which contains zero consecutive zero-value 306 bits is one octet in length and a Variable Size Integer that starts 307 with one consecutive zero-value bit is two octets in length. The 308 VINT_WIDTH MUST only contain zero-value bits or be empty. 310 Within the EBML Header the VINT_WIDTH of a VINT MUST NOT exceed three 311 bits in length (meaning that the Variable Size Integer MUST NOT 312 exceed four octets in length) except if said VINT is used to express 313 the Element Data Size of an EBML Element with Element Name EBML and 314 Element ID "0x1A45DFA3" (see Section 11.2.1) in which case the 315 VINT_WIDTH MUST NOT exceed seven bits in length. Within the EBML 316 Body, when a VINT is used to express an Element ID, the maximum 317 length allowed for the VINT_WIDTH is one less than the value set in 318 the EBMLMaxIDLength Element. Within the EBML Body, when a VINT is 319 used to express an Element Data Size, the maximum length allowed for 320 the VINT_WIDTH is one less than the value set in the 321 EBMLMaxSizeLength Element. 323 4.2. VINT_MARKER 325 The VINT_MARKER serves as a separator between the VINT_WIDTH and 326 VINT_DATA. Each Variable Size Integer MUST contain exactly one 327 VINT_MARKER. The VINT_MARKER is one bit in length and contain a bit 328 with a value of one. The first bit with a value of one within the 329 Variable Size Integer is the VINT_MARKER. 331 4.3. VINT_DATA 333 The VINT_DATA portion of the Variable Size Integer includes all data 334 that follows (but not including) the VINT_MARKER until end of the 335 Variable Size Integer whose length is derived from the VINT_WIDTH. 336 The bits required for the VINT_WIDTH and the VINT_MARKER use one out 337 of every eight bits of the total length of the Variable Size Integer. 338 Thus a Variable Size Integer of 1 octet length supplies 7 bits for 339 VINT_DATA, a 2 octet length supplies 14 bits for VINT_DATA, and a 3 340 octet length supplies 21 bits for VINT_DATA. If the number of bits 341 required for VINT_DATA are less than the bit size of VINT_DATA, then 342 VINT_DATA MUST be zero-padded to the left to a size that fits. The 343 VINT_DATA value MUST be expressed as a big-endian unsigned integer. 345 4.4. VINT Examples 347 This table shows examples of Variable Size Integers with lengths from 348 1 to 5 octets. The Usable Bits column refers to the number of bits 349 that can be used in the VINT_DATA. The Representation column depicts 350 a binary expression of Variable Size Integers where VINT_WIDTH is 351 depicted by "0", the VINT_MARKER as "1", and the VINT_DATA as "x". 353 +--------------+-------------+-------------------------------+ 354 | Octet Length | Usable Bits | Representation | 355 +==============+=============+===============================+ 356 | 1 | 7 | 1xxx xxxx | 357 +--------------+-------------+-------------------------------+ 358 | 2 | 14 | 01xx xxxx xxxx xxxx | 359 +--------------+-------------+-------------------------------+ 360 | 3 | 21 | 001x xxxx xxxx xxxx xxxx xxxx | 361 +--------------+-------------+-------------------------------+ 362 | 4 | 28 | 0001 xxxx xxxx xxxx xxxx xxxx | 363 | | | xxxx xxxx | 364 +--------------+-------------+-------------------------------+ 365 | 5 | 35 | 0000 1xxx xxxx xxxx xxxx xxxx | 366 | | | xxxx xxxx xxxx xxxx | 367 +--------------+-------------+-------------------------------+ 369 Table 1 371 Data encoded as a Variable Size Integer may be rendered at octet 372 lengths larger than needed to store the data in order to facilitate 373 overwriting it at a later date, e.g. when its final size isn't known 374 in advance. In this table a binary value of 0b10 is shown encoded as 375 different Variable Size Integers with lengths from one octet to four 376 octets. All four encoded examples have identical semantic meaning 377 though the VINT_WIDTH and the padding of the VINT_DATA vary. 379 +--------------+--------------+-----------------------+ 380 | Binary Value | Octet Length | As Represented in | 381 | | | Variable Size Integer | 382 +==============+==============+=======================+ 383 | 10 | 1 | 1000 0010 | 384 +--------------+--------------+-----------------------+ 385 | 10 | 2 | 0100 0000 0000 0010 | 386 +--------------+--------------+-----------------------+ 387 | 10 | 3 | 0010 0000 0000 0000 | 388 | | | 0000 0010 | 389 +--------------+--------------+-----------------------+ 390 | 10 | 4 | 0001 0000 0000 0000 | 391 | | | 0000 0000 0000 0010 | 392 +--------------+--------------+-----------------------+ 394 Table 2 396 5. Element ID 398 The Element ID is encoded as a Variable Size Integer. By default, 399 Element IDs are encoded in lengths from one octet to four octets, 400 although Element IDs of greater lengths MAY be used if the 401 EBMLMaxIDLength Element of the EBML Header is set to a value greater 402 than four (see Section 11.2.4). The VINT_DATA component of the 403 Element ID MUST NOT be either defined or written as either all zero 404 values or all one values. Any Element ID with the VINT_DATA 405 component set as all zero values or all one values MUST be ignored. 406 The VINT_DATA component of the Element ID MUST be encoded at the 407 shortest valid length. For example, an Element ID with binary 408 encoding of "1011 1111" is valid, whereas an Element ID with binary 409 encoding of "0100 0000 0011 1111" stores a semantically equal 410 VINT_DATA but is invalid because a shorter VINT encoding is possible. 411 Additionally, an Element ID with binary encoding of "1111 1111" is 412 invalid since the VINT_DATA section is set to all one values, whereas 413 an Element ID with binary encoding of "0100 0000 0111 1111" stores a 414 semantically equal VINT_DATA and is the shortest possible VINT 415 encoding. 417 The following table details these specific examples further: 419 +------------+-------------+----------------+--------------------+ 420 | VINT_WIDTH | VINT_MARKER | VINT_DATA | Element ID Status | 421 +============+=============+================+====================+ 422 | | 1 | 0000000 | Invalid: VINT_DATA | 423 | | | | MUST NOT be set to | 424 | | | | all 0 | 425 +------------+-------------+----------------+--------------------+ 426 | 0 | 1 | 00000000000000 | Invalid: VINT_DATA | 427 | | | | MUST NOT be set to | 428 | | | | all 0 | 429 +------------+-------------+----------------+--------------------+ 430 | | 1 | 0000001 | Valid | 431 +------------+-------------+----------------+--------------------+ 432 | 0 | 1 | 00000000000001 | Invalid: A shorter | 433 | | | | VINT_DATA encoding | 434 | | | | is available. | 435 +------------+-------------+----------------+--------------------+ 436 | | 1 | 0111111 | Valid | 437 +------------+-------------+----------------+--------------------+ 438 | 0 | 1 | 00000000111111 | Invalid: A shorter | 439 | | | | VINT_DATA encoding | 440 | | | | is available. | 441 +------------+-------------+----------------+--------------------+ 442 | | 1 | 1111111 | Invalid: VINT_DATA | 443 | | | | MUST NOT be set to | 444 | | | | all 1 | 445 +------------+-------------+----------------+--------------------+ 446 | 0 | 1 | 00000001111111 | Valid | 447 +------------+-------------+----------------+--------------------+ 449 Table 3 451 The octet length of an Element ID determines its EBML Class. 453 +------------+--------+-------------------------+---------------+ 454 | EBML Class | Length | Possible IDs | Number of IDs | 455 +============+========+=========================+===============+ 456 | Class A | 1 | 0x81 - 0xFE | 126 | 457 +------------+--------+-------------------------+---------------+ 458 | Class B | 2 | 0x407F - 0x7FFE | 16,256 | 459 +------------+--------+-------------------------+---------------+ 460 | Class C | 3 | 0x203FFF - 0x3FFFFE | 2,080,768 | 461 +------------+--------+-------------------------+---------------+ 462 | Class D | 4 | 0x101FFFFF - 0x1FFFFFFE | 268,338,304 | 463 +------------+--------+-------------------------+---------------+ 465 Table 4 467 6. Element Data Size 469 6.1. Data Size Format 471 The Element Data Size expresses the length in octets of Element Data. 472 The Element Data Size itself is encoded as a Variable Size Integer. 473 By default, Element Data Sizes can be encoded in lengths from one 474 octet to eight octets, although Element Data Sizes of greater lengths 475 MAY be used if the octet length of the longest Element Data Size of 476 the EBML Document is declared in the EBMLMaxSizeLength Element of the 477 EBML Header (see Section 11.2.5). Unlike the VINT_DATA of the 478 Element ID, the VINT_DATA component of the Element Data Size is not 479 mandated to be encoded at the shortest valid length. For example, an 480 Element Data Size with binary encoding of 1011 1111 or a binary 481 encoding of 0100 0000 0011 1111 are both valid Element Data Sizes and 482 both store a semantically equal value (both 0b00000000111111 and 483 0b0111111, the VINT_DATA sections of the examples, represent the 484 integer 63). 486 Although an Element ID with all VINT_DATA bits set to zero is 487 invalid, an Element Data Size with all VINT_DATA bits set to zero is 488 allowed for EBML Element Types which do not mandate a non-zero length 489 (see Section 7). An Element Data Size with all VINT_DATA bits set to 490 zero indicates that the Element Data is zero octets in length. Such 491 an EBML Element is referred to as an Empty Element. If an Empty 492 Element has a default value declared then the EBML Reader MUST 493 interpret the value of the Empty Element as the default value. If an 494 Empty Element has no default value declared then the EBML Reader MUST 495 use the value of the Empty Element for the corresponding EBML Element 496 Type of the Element ID, 0 for numbers and an empty string for 497 strings. 499 6.2. Unknown Data Size 501 An Element Data Size with all VINT_DATA bits set to one is reserved 502 as an indicator that the size of the EBML Element is unknown. The 503 only reserved value for the VINT_DATA of Element Data Size is all 504 bits set to one. An EBML Element with an unknown Element Data Size 505 is referred to as an Unknown-Sized Element. A Master Element MAY be 506 an Unknown-Sized Element; however an EBML Element that is not a 507 Master Element MUST NOT be an Unknown-Sized Element. Master Elements 508 MUST NOT use an unknown size unless the unknownsizeallowed attribute 509 of their EBML Schema is set to true (see Section 11.1.5.10). 511 The use of Unknown-Sized Elements allows for an EBML Element to be 512 written and read before the size of the EBML Element is known. 513 Unknown-Sized Element MUST NOT be used or defined unnecessarily; 514 however if the Element Data Size is not known before the Element Data 515 is written, such as in some cases of data streaming, then Unknown- 516 Sized Elements MAY be used. The end of an Unknown-Sized Element is 517 determined by whichever comes first: 519 * Any EBML Element that is a valid Parent Element of the Unknown- 520 Sized Element according to the EBML Schema, Global Elements 521 excluded. 523 * Any valid EBML Element according to the EBML Schema, Global 524 Elements excluded, that is not a Descendant Element of the 525 Unknown-Sized Element but share a common direct parent, such as a 526 Top-Level Element. 528 * Any EBML Element that is a valid Root Element according to the 529 EBML Schema, Global Elements excluded. 531 * The end of the Parent Element with a known size has been reached. 533 * The end of the EBML Document, either when reaching the end of the 534 file or because a new EBML Header started. 536 Consider an Unknown-Sized Element which EBML path is 537 "\root\level1\level2\elt". When reading a new Element ID, assuming 538 the EBML Path of that new Element is valid, here are some possible 539 and impossible ways that this new Element is ending "elt": 541 +------------------------------------+----------------------------+ 542 | EBML Path of new element | Status | 543 +====================================+============================+ 544 | "\root\level1\level2" | Ends the Unknown-Sized | 545 | | Element, as it is a new | 546 | | Parent Element | 547 +------------------------------------+----------------------------+ 548 | "\root\level1" | Ends the Unknown-Sized | 549 | | Element, as it is a new | 550 | | Parent Element | 551 +------------------------------------+----------------------------+ 552 | "\root" | Ends the Unknown-Sized | 553 | | Element, as it is a new | 554 | | Root Element | 555 +------------------------------------+----------------------------+ 556 | "\root2" | Ends the Unknown-Sized | 557 | | Element, as it is a new | 558 | | Root Element | 559 +------------------------------------+----------------------------+ 560 | "\root\level1\level2\other" | Ends the Unknown-Sized | 561 | | Element, as they share the | 562 | | same parent | 563 +------------------------------------+----------------------------+ 564 | "\root\level1\level2\elt" | Ends the Unknown-Sized | 565 | | Element, as they share the | 566 | | same parent | 567 +------------------------------------+----------------------------+ 568 | "\root\level1\level2\elt\inside" | Doesn't end the Unknown- | 569 | | Sized Element, it's a | 570 | | child of "elt" | 571 +------------------------------------+----------------------------+ 572 | "\root\level1\level2\elt\" | Global Element is valid, | 573 | | it's a child of "elt" | 574 +------------------------------------+----------------------------+ 575 | "\root\level1\level2\" | Global Element cannot be | 576 | | assumed to have this path, | 577 | | while parsing "elt" it can | 578 | | only be a child of "elt" | 579 +------------------------------------+----------------------------+ 581 Table 5 583 6.3. Data Size Values 585 For Element Data Sizes encoded at octet lengths from one to eight, 586 this table depicts the range of possible values that can be encoded 587 as an Element Data Size. An Element Data Size with an octet length 588 of 8 is able to express a size of 2^56-2 or 72,057,594,037,927,934 589 octets (or about 72 petabytes). The maximum possible value that can 590 be stored as Element Data Size is referred to as VINTMAX. 592 +--------------+----------------------+ 593 | Octet Length | Possible Value Range | 594 +==============+======================+ 595 | 1 | 0 to 2^(7-2) | 596 +--------------+----------------------+ 597 | 2 | 0 to 2^(14-2) | 598 +--------------+----------------------+ 599 | 3 | 0 to 2^(21-2) | 600 +--------------+----------------------+ 601 | 4 | 0 to 2^(28-2) | 602 +--------------+----------------------+ 603 | 5 | 0 to 2^(35-2) | 604 +--------------+----------------------+ 605 | 6 | 0 to 2^(42-2) | 606 +--------------+----------------------+ 607 | 7 | 0 to 2^(49-2) | 608 +--------------+----------------------+ 609 | 8 | 0 to 2^(56-2) | 610 +--------------+----------------------+ 612 Table 6 614 If the length of Element Data equals 2^(n*7)-1 then the octet length 615 of the Element Data Size MUST be at least n+1. This rule prevents an 616 Element Data Size from being expressed as the unknown size value. 617 The following table clarifies this rule by showing a valid and 618 invalid expression of an Element Data Size with a VINT_DATA of 127 619 (which is equal to 2^(1*7)-1) and 16,383 (which is equal to 2^((2*7)- 620 1).) 621 +------------+-------------+-----------------------+--------------+ 622 | VINT_WIDTH | VINT_MARKER | VINT_DATA | Element Data | 623 | | | | Size Status | 624 +============+=============+=======================+==============+ 625 | | 1 | 1111111 | Reserved | 626 | | | | (meaning | 627 | | | | Unknown) | 628 +------------+-------------+-----------------------+--------------+ 629 | 0 | 1 | 00000001111111 | Valid | 630 | | | | (meaning 127 | 631 | | | | octets) | 632 +------------+-------------+-----------------------+--------------+ 633 | 00 | 1 | 000000000000001111111 | Valid | 634 | | | | (meaning 127 | 635 | | | | octets) | 636 +------------+-------------+-----------------------+--------------+ 637 | 0 | 1 | 11111111111111 | Reserved | 638 | | | | (meaning | 639 | | | | Unknown) | 640 +------------+-------------+-----------------------+--------------+ 641 | 00 | 1 | 000000011111111111111 | Valid | 642 | | | | (16,383 | 643 | | | | octets) | 644 +------------+-------------+-----------------------+--------------+ 646 Table 7 648 7. EBML Element Types 650 EBML Elements are defined by an EBML Schema (see Section 11.1) which 651 MUST declare one of the following EBML Element Types for each EBML 652 Element. An EBML Element Type defines a concept of storing data 653 within an EBML Element that describes such characteristics as length, 654 endianness, and definition. 656 EBML Elements which are defined as a Signed Integer Element, Unsigned 657 Integer Element, Float Element, or Date Element use big endian 658 storage. 660 7.1. Signed Integer Element 662 A Signed Integer Element MUST declare a length from zero to eight 663 octets. If the EBML Element is not defined to have a default value, 664 then a Signed Integer Element with a zero-octet length represents an 665 integer value of zero. 667 A Signed Integer Element stores an integer (meaning that it can be 668 written without a fractional component) which could be negative, 669 positive, or zero. Signed Integers are stored with two's complement 670 notation with the leftmost bit being the sign bit. Because EBML 671 limits Signed Integers to 8 octets in length a Signed Integer Element 672 stores a number from -9,223,372,036,854,775,808 to 673 +9,223,372,036,854,775,807. 675 7.2. Unsigned Integer Element 677 An Unsigned Integer Element MUST declare a length from zero to eight 678 octets. If the EBML Element is not defined to have a default value, 679 then an Unsigned Integer Element with a zero-octet length represents 680 an integer value of zero. 682 An Unsigned Integer Element stores an integer (meaning that it can be 683 written without a fractional component) which could be positive or 684 zero. Because EBML limits Unsigned Integers to 8 octets in length an 685 Unsigned Integer Element stores a number from 0 to 686 18,446,744,073,709,551,615. 688 7.3. Float Element 690 A Float Element MUST declare a length of either zero octet (0 bit), 691 four octets (32 bit) or eight octets (64 bit). If the EBML Element 692 is not defined to have a default value, then a Float Element with a 693 zero-octet length represents a numerical value of zero. 695 A Float Element stores a floating-point number as defined in 696 [IEEE.754.1985]. 698 7.4. String Element 700 A String Element MUST declare a length in octets from zero to 701 VINTMAX. If the EBML Element is not defined to have a default value, 702 then a String Element with a zero-octet length represents an empty 703 string. 705 A String Element MUST either be empty (zero-length) or contain 706 printable ASCII characters [RFC0020] in the range of 0x20 to 0x7E, 707 with an exception made for termination (see Section 13). 709 7.5. UTF-8 Element 711 A UTF-8 Element MUST declare a length in octets from zero to VINTMAX. 712 If the EBML Element is not defined to have a default value, then a 713 UTF-8 Element with a zero-octet length represents an empty string. 715 A UTF-8 Element contains only a valid Unicode string as defined in 716 [RFC3629], with an exception made for termination (see Section 13). 718 7.6. Date Element 720 A Date Element MUST declare a length of either zero octets or eight 721 octets. If the EBML Element is not defined to have a default value, 722 then a Date Element with a zero-octet length represents a timestamp 723 of 2001-01-01T00:00:00.000000000 UTC [RFC3339]. 725 The Date Element stores an integer in the same format as the Signed 726 Integer Element that expresses a point in time referenced in 727 nanoseconds from the precise beginning of the third millennium of the 728 Gregorian Calendar in Coordinated Universal Time (also known as 729 2001-01-01T00:00:00.000000000 UTC). This provides a possible 730 expression of time from 1708-09-11T00:12:44.854775808 UTC to 731 2293-04-11T11:47:16.854775807 UTC. 733 7.7. Master Element 735 A Master Element MUST declare a length in octets from zero to 736 VINTMAX. The Master Element MAY also use an unknown length. See 737 Section 6 for rules that apply to elements of unknown length. 739 The Master Element contains zero, one, or many other elements. EBML 740 Elements contained within a Master Element MUST have the 741 EBMLParentPath of their Element Path equal to the EBMLMasterPath of 742 the Master Element Element Path (see Section 11.1.5.2). Element Data 743 stored within Master Elements SHOULD only consist of EBML Elements 744 and SHOULD NOT contain any data that is not part of an EBML Element. 745 The EBML Schema identifies what Element IDs are valid within the 746 Master Elements for that version of the EBML Document Type. Any data 747 contained within a Master Element that is not part of a Child Element 748 MUST be ignored. 750 7.8. Binary Element 752 A Binary Element MUST declare a length in octets from zero to 753 VINTMAX. 755 The contents of a Binary Element should not be interpreted by the 756 EBML Reader. 758 8. EBML Document 760 An EBML Document is comprised of only two components, an EBML Header 761 and an EBML Body. An EBML Document MUST start with an EBML Header 762 that declares significant characteristics of the entire EBML Body. 763 An EBML Document consists of EBML Elements and MUST NOT contain any 764 data that is not part of an EBML Element. 766 8.1. EBML Header 768 The EBML Header is a declaration that provides processing 769 instructions and identification of the EBML Body. The EBML Header of 770 an EBML Document is analogous to the XML Declaration of an XML 771 Document. 773 The EBML Header documents the EBML Schema (also known as the EBML 774 DocType) that is used to semantically interpret the structure and 775 meaning of the EBML Document. Additionally the EBML Header documents 776 the versions of both EBML and the EBML Schema that were used to write 777 the EBML Document and the versions required to read the EBML 778 Document. 780 The EBML Header MUST contain a single Master Element with an Element 781 Name of EBML and Element ID of 0x1A45DFA3 (see Section 11.2.1) and 782 any number of additional EBML Elements within it. The EBML Header of 783 an EBML Document that uses an EBMLVersion of 1 MUST only contain EBML 784 Elements that are defined as part of this document. 786 8.2. EBML Body 788 All data of an EBML Document following the EBML Header is the EBML 789 Body. The end of the EBML Body, as well as the end of the EBML 790 Document that contains the EBML Body, is reached at whichever comes 791 first: the beginning of a new EBML Header at the Root Level or the 792 end of the file. The EBML Body MUST NOT contain any data that is not 793 part of an EBML Element. This document defines precisely which EBML 794 Elements are to be used within the EBML Header, but does not name or 795 define which EBML Elements are to be used within the EBML Body. The 796 definition of which EBML Elements are to be used within the EBML Body 797 is defined by an EBML Schema. 799 9. EBML Stream 801 An EBML Stream is a file that consists of one or more EBML Documents 802 that are concatenated together. An occurrence of a EBML Header at 803 the Root Level marks the beginning of an EBML Document. 805 10. EBML Versioning 807 An EBML Document handles 2 different versions: the version of the 808 EBML Header and the version of the EBML Body. Both versions are 809 meant to be backward compatible. 811 10.1. EBML Header Version 813 The version of the EBML Header is found in EBMLVersion. An EBML 814 parser can read an EBML Header if it can read either the EBMLVersion 815 version or a version equal or higher than the one found in 816 EBMLReadVersion. 818 10.2. EBML Document Version 820 The version of the EBML Body is found in EBMLDocTypeVersion. A 821 parser for the particular DocType format can read the EBML Document 822 if it can read either the EBMLDocTypeVersion version of that format 823 or a version equal or higher than the one found in 824 EBMLDocTypeReadVersion. 826 11. Elements semantic 828 11.1. EBML Schema 830 An EBML Schema is a well-formed XML Document [W3C.REC-xml-20081126] 831 that defines the properties, arrangement, and usage of EBML Elements 832 that compose a specific EBML Document Type. The relationship of an 833 EBML Schema to an EBML Document is analogous to the relationship of 834 an XML Schema [W3C.REC-xmlschema-0-20041028] to an XML Document 835 [W3C.REC-xml-20081126]. An EBML Schema MUST be clearly associated 836 with one or more EBML Document Types. An EBML Document Type is 837 identified by a string stored within the EBML Header in the DocType 838 Element; for example matroska or webm (see Section 11.2.6). The 839 DocType value for an EBML Document Type MUST be unique and 840 persistent. 842 An EBML Schema MUST declare exactly one EBML Element at Root Level 843 (referred to as the Root Element) that occurs exactly once within an 844 EBML Document. The Void Element MAY also occur at Root Level but is 845 not a Root Element (see Section 11.3.2). 847 The EBML Schema MUST document all Elements of the EBML Body. The 848 EBML Schema does not document Global Elements that are defined by 849 this document (namely the Void Element and the CRC-32 Element). 851 The EBML Schema MUST NOT use the Element ID "0x1A45DFA3" which is 852 reserved for the EBML Header for resynchronization purpose. 854 An EBML Schema MAY constrain the use of EBML Header Elements (see 855 Section 11.2) by adding or constraining that Element's "range" 856 attribute. For example, an EBML Schema MAY constrain the 857 EBMLMaxSizeLength to a maximum value of "8" or MAY constrain the 858 EBMLVersion to only support a value of "1". If an EBML Schema adopts 859 the EBML Header Element as-is, then it is not required to document 860 that Element within the EBML Schema. If an EBML Schema constrains 861 the range of an EBML Header Element, then that Element MUST be 862 documented within an "" node of the EBML Schema. This 863 document provides an example of an EBML Schema, see Section 11.1.1. 865 11.1.1. EBML Schema Example 867 868 870 871 874 877 878 880 Container of data and 881 attributes representing one or many files. 882 883 885 886 An attached file. 887 888 889 892 893 Filename of the attached file. 894 895 896 899 900 MIME type of the file. 901 902 903 906 907 Modification timestamp of the file. 908 909 910 912 913 The data of the file. 914 915 916 918 11.1.2. Element 920 As an XML Document, the EBML Schema MUST use "" as the 921 top level element. The "" element can contain 922 "" sub-elements. 924 11.1.3. Attributes 926 Within an EBML Schema the "" element uses the following 927 attributes: 929 11.1.3.1. docType 931 The docType lists the official name of the EBML Document Type that is 932 defined by the EBML Schema; for example, "". 935 The docType attribute is REQUIRED within the "" Element. 937 11.1.3.2. version 939 The version lists a non-negative integer that specifies the version 940 of the docType documented by the EBML Schema. Unlike XML Schemas, an 941 EBML Schema documents all versions of a docType's definition rather 942 than using separate EBML Schemas for each version of a docType. EBML 943 Elements may be introduced and deprecated by using the minver and 944 maxver attributes of "". 946 The version attribute is REQUIRED within the "" Element. 948 11.1.4. Element 950 Each "" defines one EBML Element through the use of several 951 attributes that are defined in Section 11.1.3. EBML Schemas MAY 952 contain additional attributes to extend the semantics but MUST NOT 953 conflict with the definitions of the "" attributes defined 954 within this document. 956 The "" nodes contain a description of the meaning and use of 957 the EBML Element stored within one or more "" sub- 958 elements, followed by optional "" sub-elements, 959 followed by zero or one "" sub-element, followed by 960 optional "" sub-elements. All "" nodes MUST be 961 sub-elements of the "". 963 11.1.5. Attributes 965 Within an EBML Schema the "" uses the following attributes 966 to define an EBML Element: 968 11.1.5.1. name 970 The name provides the human-readable name of the EBML Element. The 971 value of the name MUST be in the form of characters "A" to "Z", "a" 972 to "z", "0" to "9", "-" and ".". 974 The name attribute is REQUIRED. 976 11.1.5.2. path 978 The path defines the allowed storage locations of the EBML Element 979 within an EBML Document. This path MUST be defined with the full 980 hierarchy of EBML Elements separated with a "\". The top EBML 981 Element in the path hierarchy being the first in the value. The 982 syntax of the path attribute is defined using this Augmented Backus- 983 Naur Form (ABNF) [RFC5234] with the case sensitive update [RFC7405] 984 notation: 986 The path attribute is REQUIRED. 988 EBMLFullPath = EBMLEltOccurrence "(" EBMLMasterPath ")" 989 EBMLMasterPath = [EBMLParentPath] EBMLElementPath 990 EBMLParentPath = EBMLFixedParent EBMLLastParent 991 EBMLFixedParent = *(EBMLPathAtom) 992 EBMLElementPath = EBMLPathAtom / EBMLPathAtomRecursive 993 EBMLPathAtom = PathDelimiter EBMLAtomName 994 EBMLPathAtomRecursive = "(1*(" EBMLPathAtom "))" 995 EBMLLastParent = EBMLPathAtom / EBMLGlobalParent 996 EBMLGlobalParent = "(" GlobalParentOccurence "\)" 997 EBMLAtomName = 1*(EBMLNameChar) 998 EBMLNameChar = ALPHA / DIGIT / "-" / "." 999 PathDelimiter = "\" 1000 EBMLEltOccurrence = [EBMLMinOccurrence] "*" [EBMLMaxOccurrence] 1001 EBMLMinOccurrence = 1*DIGIT ; no upper limit 1002 EBMLMaxOccurrence = 1*DIGIT ; no upper limit 1003 GlobalParentOccurence = [PathMinOccurrence] "*" [PathMaxOccurrence] 1004 PathMinOccurrence = 1*DIGIT ; no upper limit 1005 PathMaxOccurrence = 1*DIGIT ; no upper limit 1007 The "*", "(" and ")" symbols are interpreted as defined in [RFC5234]. 1009 The EBMLPathAtom part of the EBMLElementPath MUST be equal to the 1010 name attribute of the EBML Schema. 1012 The starting PathDelimiter of the path corresponds to the root of the 1013 EBML Document. 1015 The EBMLEltOccurrence part is interpreted as an ABNF Variable 1016 Repetition. The repetition amounts correspond to how many times the 1017 EBML Element can be found in its Parent Element. 1019 The EBMLMinOccurrence represents the minimum permitted number of 1020 occurrences of this EBML Element within its Parent Element. Each 1021 instance of the Parent Element MUST contain at least this many 1022 instances of this EBML Element. If the EBML Element has an empty 1023 EBMLParentPath then EBMLMinOccurrence refers to constraints on the 1024 occurrence of the EBML Element within the EBML Document. If 1025 EBMLMinOccurrence is not present then that EBML Element has an 1026 EBMLMinOccurrence value of 0. The semantic meaning of 1027 EBMLMinOccurrence within an EBML Schema is analogous to the meaning 1028 of minOccurs within an XML Schema. EBML Elements with 1029 EBMLMinOccurrence set to "1" that also have a default value (see 1030 Section 11.1.5.8) declared are not REQUIRED to be stored but are 1031 REQUIRED to be interpreted, see Section 11.1.18. An EBML Element 1032 defined with a EBMLMinOccurrence value greater than zero is called a 1033 Mandatory EBML Element. 1035 The EBMLMaxOccurrence represents the maximum permitted number of 1036 occurrences of this EBML Element within its Parent Element. Each 1037 instance of the Parent Element MUST contain at most this many 1038 instances of this EBML Element. If the EBML Element has an empty 1039 EBMLParentPath then EBMLMaxOccurrence refers to constraints on the 1040 occurrence of the EBML Element within the EBML Document. If 1041 EBMLMaxOccurrence is not present then there is no upper bound for the 1042 permitted number of occurrences of this EBML Element within its 1043 Parent Element resp. within the EBML Document depending on whether 1044 the EBMLParentPath of the EBML Element is empty or not. The semantic 1045 meaning of EBMLMaxOccurrence within an EBML Schema path is analogous 1046 to the meaning of maxOccurs within an XML Schema. 1048 In some cases the EBMLLastParent part of the path is an 1049 EBMLGlobalParent. A path with a EBMLGlobalParent defines a 1050 Section 11.3. Any path that starts with the EBMLFixedParent of the 1051 Global Element and matches the occurrences found in the 1052 GlobalParentOccurence is a valid path for the Global Element. 1054 The GlobalParentOccurence part is interpreted as an ABNF Variable 1055 Repetition. The repetition amounts correspond to the amount of 1056 unspecified Parent Element levels there can be between the 1057 EBMLFixedParent and the actual EBMLElementPath. 1059 PathMinOccurrence represents the minimum number of element path 1060 required between the EBMLFixedParent and the Global Element 1061 EBMLElementPath. For example 0 means the EBMLElementPath can be 1062 right after the EBMLFixedParent, 1 means there has to be at least an 1063 element between the EBMLFixedParent and the EBMLElementPath. If 1064 PathMinOccurrence is not present then that EBML Element has an 1065 PathMinOccurrence value of 0. 1067 PathMaxOccurrence represents the maximum number of element path 1068 possible between the EBMLFixedParent and the Global Element 1069 EBMLElementPath. It cannot have the value 0 as it would be the 1070 Global Element can only be found right after the EBMLFixedParent, in 1071 which case it's not a Global Element anymore. If PathMaxOccurrence 1072 is not present then there is no upper bound for the permitted number 1073 of occurrences of element path possible between the EBMLFixedParent 1074 and the Global Element EBMLElementPath. 1076 If the path contains an EBMLPathAtomRecursive part, the EBML Element 1077 can occur within itself recursively (see Section 11.1.5.11). 1079 As an example, a "path" of "1*(\Segment\Info)" means the element Info 1080 is found inside the Segment elements at least once and with no 1081 maximum iteration. An element SeekHead with path 1082 "0*2(\Segment\SeekHead)" may not be found at all in its Segment 1083 parent, once or twice but no more than that. 1085 11.1.5.3. id 1087 The Element ID encoded as a Variable Size Integer expressed in 1088 hexadecimal notation prefixed by a 0x that is read and stored in big- 1089 endian order. To reduce the risk of false positives while parsing 1090 EBML Streams, the Element IDs of the Root Element and Top-Level 1091 Elements SHOULD be at least 4 octets in length. Element IDs defined 1092 for use at Root Level or directly under the Root Level MAY use 1093 shorter octet lengths to facilitate padding and optimize edits to 1094 EBML Documents; for instance, the Void Element uses an Element ID 1095 with a one octet length to allow its usage in more writing and 1096 editing scenarios. 1098 The id attribute is REQUIRED. 1100 11.1.5.4. minOccurs 1102 An integer expressing the minimum permitted number of occurrences of 1103 this EBML Element within its Parent Element. The minOccurs value 1104 MUST be equal to the EBMLMinOccurrence value of the path. 1106 The minOccurs attribute is OPTIONAL. If the minOccurs attribute is 1107 not present then that EBML Element has a minOccurs value of 0. 1109 11.1.5.5. maxOccurs 1111 An integer expressing the maximum permitted number of occurrences of 1112 this EBML Element within its Parent Element. The maxOccurs value 1113 MUST be equal to the EBMLMaxOccurrence value of the path. 1115 The maxOccurs attribute is OPTIONAL. If the maxOccurs attribute is 1116 not present then that EBML Element has no maximum occurrence, similar 1117 to unbounded in the XML world. 1119 11.1.5.6. range 1121 A numerical range for EBML Elements which are of numerical types 1122 (Unsigned Integer, Signed Integer, Float, and Date). If specified 1123 the value of the EBML Element MUST be within the defined range. See 1124 Section 11.1.5.6.1 for rules applied to expression of range values. 1126 The range attribute is OPTIONAL. If the range attribute is not 1127 present then any value legal for the type attribute is valid. 1129 11.1.5.6.1. Expression of range 1131 The range attribute MUST only be used with EBML Elements that are 1132 either signed integer, unsigned integer, float, or date. The 1133 expression defines the upper, lower, exact or excluded value of the 1134 EBML Element and optionally an upper boundary value combined with a 1135 lower boundary. The range expression may contain whitespace (using 1136 the ASCII 0x20 character) for readability but whitespace within a 1137 range expression MUST NOT convey meaning. 1139 To set a fixed value for the range, the value is used as the 1140 attribute value. For example "1234" means the EBML element always 1141 has the value 1234. The value can be prefixed with "not" to indicate 1142 that the fixed value MUST NOT be used for that Element. For example 1143 "not 1234" means the Element can use all values of its type except 1144 1234. 1146 For an exclusive lower boundary the ">" sign is used and the ">=" 1147 sign is used for an inclusive lower boundary. For example ">3" 1148 meaning the Element value MUST be greater than 3 or ">=0x1p+0" 1149 meaning the Element value MUST be greater than or equal to the 1150 floating value 1.0, see Section 11.1.17. 1152 For an exclusive upper boundary the "<" sign is used and the "<=" 1153 sign is used for an inclusive upper boundary. For example "<-2" 1154 meaning the Element value MUST be less than -2 or "<=10" meaning the 1155 Element value MUST be less than or equal to the 10. 1157 The lower and upper bounds can be combined into an expression to form 1158 a closed boundary. The lower boundary coming first followed by the 1159 upper boundary, separated by a comma. For example ">3,<= 20" means 1160 the Element value MUST be greater than 3 and less than or equal to 1161 20. 1163 A special form of lower and upper bounds using the "-" separator is 1164 possible, meaning the Element value MUST be greater than or to the 1165 first value and MUST be less than or equal to the second value. For 1166 example "1-10" is equivalent to ">=1,<=10". If the upper boundary is 1167 negative, only the latter form MUST be used. 1169 11.1.5.7. length 1171 A value to express the valid length of the Element Data as written 1172 measured in octets. The length provides a constraint in addition to 1173 the Length value of the definition of the corresponding EBML Element 1174 Type. This length MUST be expressed as either a non-negative integer 1175 or a range (see Section 11.1.5.6.1) that consists of only non- 1176 negative integers and valid operators. 1178 The length attribute is OPTIONAL. If the length attribute is not 1179 present for that EBML Element then that EBML Element is only limited 1180 in length by the definition of the associated EBML Element Type. 1182 11.1.5.8. default 1184 If an Element is mandatory (has a EBMLMinOccurrence value greater 1185 than zero) but not written within its Parent Element or stored as an 1186 Empty Element, then the EBML Reader of the EBML Document MUST 1187 semantically interpret the EBML Element as present with this 1188 specified default value for the EBML Element. An unwritten mandatory 1189 Element with a declared default value is semantically to that Element 1190 if written with the default value stored as the Element Data. EBML 1191 Elements that are Master Elements MUST NOT declare a default value. 1192 EBML Elements with a minOccurs value greater than 1 MUST NOT declare 1193 a default value. 1195 The default attribute is OPTIONAL. 1197 11.1.5.9. type 1199 The type MUST be set to one of the following values: "integer" 1200 (signed integer), "uinteger" (unsigned integer), "float", "string", 1201 "date", "utf-8", "master", or "binary". The content of each type is 1202 defined within Section 7. 1204 The type attribute is REQUIRED. 1206 11.1.5.10. unknownsizeallowed 1208 A boolean to express if an EBML Element is permitted to be Unknown- 1209 Sized Element (having all VINT_DATA bits of Element Data Size set to 1210 1). EBML Elements that are not Master Elements MUST NOT set 1211 unknownsizeallowed to true. An EBML Element that is defined with an 1212 unknownsizeallowed attribute set to 1 MUST also have the 1213 unknownsizeallowed attribute of its Parent Element set to 1. 1215 An EBML Element with the unknownsizeallowed attribute set to 1 MUST 1216 NOT have its recursive attribute set to 1. 1218 The unknownsizeallowed attribute is OPTIONAL. If the 1219 unknownsizeallowed attribute is not used then that EBML Element is 1220 not allowed to use an unknown Element Data Size. 1222 11.1.5.11. recursive 1224 A boolean to express if an EBML Element is permitted to be stored 1225 recursively. In this case the EBML Element MAY be stored within 1226 another EBML Element that has the same Element ID. Which itself can 1227 be stored in an EBML Element that has the same Element ID, and so on. 1228 EBML Elements that are not Master Elements MUST NOT set recursive to 1229 true. 1231 If the path contains an EBMLPathAtomRecursive part then the recursive 1232 value MUST be true and false otherwise. 1234 An EBML Element with the recursive attribute set to 1 MUST NOT have 1235 its unknownsizeallowed attribute set to 1. 1237 The recursive attribute is OPTIONAL. If the recursive attribute is 1238 not present then the EBML Element MUST NOT be used recursively. 1240 11.1.5.12. recurring 1242 A boolean to express if an EBML Element is defined as an Identically 1243 Recurring Element or not. 1245 The recurring attribute is OPTIONAL. If the recurring attribute is 1246 not present then the EBML Element is not an Identically Recurring 1247 Element. 1249 11.1.5.13. minver 1251 The minver (minimum version) attribute stores a non-negative integer 1252 that represents the first version of the docType to support the EBML 1253 Element. 1255 The minver attribute is OPTIONAL. If the minver attribute is not 1256 present, then the EBML Element has a minimum version of "1". 1258 11.1.5.14. maxver 1260 The maxver (maximum version) attribute stores a non-negative integer 1261 that represents the last or most recent version of the docType to 1262 support the element. maxver MUST be greater than or equal to minver. 1264 The maxver attribute is OPTIONAL. If the maxver attribute is not 1265 present then the EBML Element has a maximum version equal to the 1266 value stored in the version attribute of "". 1268 11.1.6. Element 1270 The "" element provides additional information about 1271 the EBML Element. Within the "" element the following 1272 XHTML [W3C.SPSD-xhtml-basic-20180327] elements MAY be used: "", 1273 "
", "". 1275 11.1.7. Attributes 1277 11.1.7.1. lang 1279 A lang attribute which is set to the [RFC5646] value of the language 1280 of the element's documentation. 1282 The lang attribute is OPTIONAL. 1284 11.1.7.2. purpose 1286 A purpose attribute distinguishes the meaning of the documentation. 1287 Values for the "" sub-element's purpose attribute MUST 1288 include one of the following: "definition", "rationale", "usage 1289 notes", and "references". 1291 The purpose attribute is REQUIRED. 1293 11.1.8. Element 1295 In some cases within an EBML Document Type, the attributes of the 1296 "" element are not sufficient to clearly communicate how the 1297 defined EBML Element is intended to be implemented. For instance, 1298 one EBML Element might only be mandatory if another EBML Element is 1299 present, or as another example, the default value of an EBML Element 1300 might derive from a related Element's content. In these cases where 1301 the Element's definition is conditional or advanced implementation 1302 notes are needed, one or many "" elements can be 1303 used to store that information. The "" refer to 1304 a specific attribute of the parent "" as expressed by the 1305 "note_attribute" attribute Section 11.1.9.1. 1307 11.1.9. Attributes 1309 11.1.9.1. note_attribute 1311 The note_attribute attribute references which of the ""'s 1312 attributes that the implementation_note is in regards to. The 1313 note_attribute attribute MUST be set to one of the following values 1314 (corresponding to that attribute of the parent ""): 1315 "minOccurs", "maxOccurs", "range", "length", "default", "minver", or 1316 "maxver". The "" SHALL supersede the parent 1317 ""'s attribute that is named in the "note_attribute" 1318 attribute. An "" SHALL NOT have more than one 1319 "" of the same "note_attribute". 1321 The note_attribute attribute is REQUIRED. 1323 11.1.10. Element 1325 The "" element provides information about restrictions 1326 to the allowable values for the EBML Element which are listed in 1327 "" elements. 1329 11.1.11. Element 1331 The "" element stores a list of values allowed for storage in 1332 the EBML Element. The values MUST match the type of the EBML Element 1333 (for example "" cannot be a valid value for a EBML 1334 Element that is defined as an unsigned integer). An "" element 1335 MAY also store "" elements to further describe the 1336 "". 1338 11.1.12. Attributes 1340 11.1.12.1. label 1342 The label provides a concise expression for human consumption that 1343 describes what the value of the "" represents. 1345 The label attribute is OPTIONAL. 1347 11.1.12.2. value 1349 The value represents data that MAY be stored within the EBML Element. 1351 The value attribute is REQUIRED. 1353 11.1.13. Element 1355 The "" element provides an unconstrained element to 1356 contain information about the associated EBML "" which is 1357 undefined by this document but MAY be defined by the associated EBML 1358 Document Type. The "" element MUST contain a "type" 1359 attribute and also MAY contain any other attribute or sub-element as 1360 long as the EBML Schema remains as a well-formed XML Document. All 1361 "" elements MUST be sub-elements of the "". 1363 11.1.14. Attributes 1365 11.1.14.1. type 1367 The type attribute should reference a name or identifier of the 1368 project or authority associated with the contents of the 1369 "" element. 1371 The type attribute is REQUIRED. 1373 11.1.15. XML Schema for EBML Schema 1375 This following provides an XML Schema [W3C.REC-xmlschema-0-20041028] 1376 for facilitating verification of an EBML Schema to the definition 1377 described in Section 8.1. 1379 1380 1386 1387 1390 1392 1393 1394 1396 1397 1398 1399 1401 1402 1403 1405 1407 1409 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1428 1429 1430 1432 1433 1435 1436 1437 1439 1440 1441 1442 1444 1445 1446 1448 1449 1450 1451 1453 1454 1455 1457 1459 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1496 11.1.16. Identically Recurring Elements 1498 An Identically Recurring Element is an EBML Element that MAY occur 1499 within its Parent Element more than once but that each recurrence 1500 within that Parent Element MUST be identical both in storage and 1501 semantics. Identically Recurring Elements are permitted to be stored 1502 multiple times within the same Parent Element in order to increase 1503 data resilience and optimize the use of EBML in transmission. For 1504 instance a pertinent Top-Level Element could be periodically resent 1505 within a data stream so that an EBML Reader which starts reading the 1506 stream from the middle could better interpret the contents. 1507 Identically Recurring Elements SHOULD include a CRC-32 Element as a 1508 Child Element; this is especially recommended when EBML is used for 1509 long-term storage or transmission. If a Parent Element contains more 1510 than one copy of an Identically Recurring Element which includes a 1511 CRC-32 Element as a Child Element then the first instance of the 1512 Identically Recurring Element with a valid CRC-32 value should be 1513 used for interpretation. If a Parent Element contains more than one 1514 copy of an Identically Recurring Element which does not contain a 1515 CRC-32 Element or if CRC-32 Elements are present but none are valid 1516 then the first instance of the Identically Recurring Element should 1517 be used for interpretation. 1519 11.1.17. Textual expression of floats 1521 When a float value is represented textually in an EBML Schema, such 1522 as within a default or range value, the float values MUST be 1523 expressed as Hexadecimal Floating-Point Constants as defined in the 1524 C11 standard [ISO.9899.2011] (see section 6.4.4.2 on Floating 1525 Constants). The following table provides examples of expressions of 1526 float ranges. 1528 +-------------------+-----------------------------------------+ 1529 | as decimal | as Hexadecimal Floating-Point Constants | 1530 +===================+=========================================+ 1531 | 0.0 | "0x0p+1" | 1532 +-------------------+-----------------------------------------+ 1533 | 0.0-1.0 | "0x0p+1-0x1p+0" | 1534 +-------------------+-----------------------------------------+ 1535 | 1.0-256.0 | "0x1p+0-0x1p+8" | 1536 +-------------------+-----------------------------------------+ 1537 | 0.857421875 | "0x1.b7p-1" | 1538 +-------------------+-----------------------------------------+ 1539 | -1.0--0.857421875 | "-0x1p+0--0x1.b7p-1" | 1540 +-------------------+-----------------------------------------+ 1542 Table 8 1544 Within an expression of a float range, as in an integer range, the - 1545 (hyphen) character is the separator between the minimal and maximum 1546 value permitted by the range. Hexadecimal Floating-Point Constants 1547 also use a - (hyphen) when indicating a negative binary power. 1548 Within a float range, when a - (hyphen) is immediately preceded by a 1549 letter p, then the - (hyphen) is a part of the Hexadecimal Floating- 1550 Point Constant which notes negative binary power. Within a float 1551 range, when a - (hyphen) is not immediately preceded by a letter p, 1552 then the - (hyphen) represents the separator between the minimal and 1553 maximum value permitted by the range. 1555 11.1.18. Note on the use of default attributes to define Mandatory EBML 1556 Elements 1558 If a Mandatory EBML Element has a default value declared by an EBML 1559 Schema and the value of the EBML Element is equal to the declared 1560 default value then that EBML Element is not required to be present 1561 within the EBML Document if its Parent Element is present. In this 1562 case, the default value of the Mandatory EBML Element MUST be read by 1563 the EBML Reader although the EBML Element is not present within its 1564 Parent Element. 1566 If a Mandatory EBML Element has no default value declared by an EBML 1567 Schema and its Parent Element is present then the EBML Element MUST 1568 be present as well. If a Mandatory EBML Element has a default value 1569 declared by an EBML Schema and its Parent Element is present and the 1570 value of the EBML Element is NOT equal to the declared default value 1571 then the EBML Element MUST be present. 1573 This table clarifies if a Mandatory EBML Element MUST be written, 1574 according to if the default value is declared, if the value of the 1575 EBML Element is equal to the declared default value, and if the 1576 Parent Element is used. 1578 +-----------------+-------------+---------------+------------------+ 1579 | Is the default | Is the | Is the Parent | Then is storing | 1580 | value declared? | value equal | Element | the EBML Element | 1581 | | to default? | present? | REQUIRED? | 1582 +=================+=============+===============+==================+ 1583 | Yes | Yes | Yes | No | 1584 +-----------------+-------------+---------------+------------------+ 1585 | Yes | Yes | No | No | 1586 +-----------------+-------------+---------------+------------------+ 1587 | Yes | No | Yes | Yes | 1588 +-----------------+-------------+---------------+------------------+ 1589 | Yes | No | No | No | 1590 +-----------------+-------------+---------------+------------------+ 1591 | No | n/a | Yes | Yes | 1592 +-----------------+-------------+---------------+------------------+ 1593 | No | n/a | No | No | 1594 +-----------------+-------------+---------------+------------------+ 1596 Table 9 1598 11.2. EBML Header Elements 1600 This document contains definitions of all EBML Elements of the EBML 1601 Header. 1603 11.2.1. EBML Element 1605 name: EBML 1607 path: "1*1(\EBML)" 1609 id: 0x1A45DFA3 1611 minOccurs: 1 1613 maxOccurs: 1 1615 type: Master Element 1617 description: Set the EBML characteristics of the data to follow. 1618 Each EBML Document has to start with this. 1620 11.2.2. EBMLVersion Element 1622 name: EBMLVersion 1624 path: "1*1(\EBML\EBMLVersion)" 1626 id 0x4286 1628 minOccurs: 1 1630 maxOccurs: 1 1632 range: not 0 1634 default: 1 1636 type: Unsigned Integer 1638 description: The version of EBML specifications used to create the 1639 EBML Document. The version of EBML defined in this document is 1, so 1640 EBMLVersion SHOULD be 1. 1642 11.2.3. EBMLReadVersion Element 1644 name: EBMLReadVersion 1646 path: "1*1(\EBML\EBMLReadVersion)" 1648 id: 0x42F7 1650 minOccurs: 1 1651 maxOccurs: 1 1653 range: 1 1655 default: 1 1657 type: Unsigned Integer 1659 description: The minimum EBML version an EBML Reader has to support 1660 to read this EBML Document. The EBMLReadVersion Element MUST be less 1661 than or equal to EBMLVersion. 1663 11.2.4. EBMLMaxIDLength Element 1665 name: EBMLMaxIDLength 1667 path: "1*1(\EBML\EBMLMaxIDLength)" 1669 id 0x42F2 1671 minOccurs: 1 1673 maxOccurs: 1 1675 range: >=4 1677 default: 4 1679 type: Unsigned Integer 1681 description: The EBMLMaxIDLength Element stores the maximum permitted 1682 length in octets of the Element IDs to be found within the EBML Body. 1683 An EBMLMaxIDLength Element value of four is RECOMMENDED, though 1684 larger values are allowed. 1686 11.2.5. EBMLMaxSizeLength Element 1688 name: EBMLMaxSizeLength 1690 path: "1*1(\EBML\EBMLMaxSizeLength)" 1692 id 0x42F3 1694 minOccurs: 1 1696 maxOccurs: 1 1698 range: not 0 1699 default: 8 1701 type: Unsigned Integer 1703 description: The EBMLMaxSizeLength Element stores the maximum 1704 permitted length in octets of the expressions of all Element Data 1705 Sizes to be found within the EBML Body. The EBMLMaxSizeLength 1706 Element documents an upper bound for the "length" of all Element Data 1707 Size expressions within the EBML Body and not an upper bound for the 1708 "value" of all Element Data Size expressions within the EBML Body. 1709 EBML Elements that have an Element Data Size expression which is 1710 larger in octets than what is expressed by EBMLMaxSizeLength Element 1711 are invalid. 1713 11.2.6. DocType Element 1715 name: DocType 1717 path: "1*1(\EBML\DocType)" 1719 id 0x4282 1721 minOccurs: 1 1723 maxOccurs: 1 1725 length: >0 1727 type: String 1729 description: A string that describes and identifies the content of 1730 the EBML Body that follows this EBML Header. 1732 11.2.7. DocTypeVersion Element 1734 name: DocTypeVersion 1736 path: "1*1(\EBML\DocTypeVersion)" 1738 id 0x4287 1740 minOccurs: 1 1742 maxOccurs: 1 1744 range: not 0 1746 default: 1 1747 type: Unsigned Integer 1749 description: The version of DocType interpreter used to create the 1750 EBML Document. 1752 11.2.8. DocTypeReadVersion Element 1754 name: DocTypeReadVersion 1756 path: "1*1(\EBML\DocTypeReadVersion)" 1758 id 0x4285 1760 minOccurs: 1 1762 maxOccurs: 1 1764 range: not 0 1766 default: 1 1768 type: Unsigned Integer 1770 description: The minimum DocType version an EBML Reader has to 1771 support to read this EBML Document. The value of the 1772 DocTypeReadVersion Element MUST be less than or equal to the value of 1773 the DocTypeVersion Element. 1775 11.2.9. DocTypeExtension Element 1777 name: DocTypeExtension 1779 path: "0*(\EBML\DocTypeExtension)" 1781 id 0x4281 1783 minOccurs: 0 1785 type: Master Element 1787 description: A DocTypeExtension adds extra Elements to the main 1788 DocType+DocTypeVersion tuple it's attached to. An EBML Reader MAY 1789 know these extra Elements and how to use them. A DocTypeExtension 1790 MAY be used to iterate between experimental Elements before they are 1791 integrated in a regular DocTypeVersion. Reading one DocTypeExtension 1792 version of a DocType+DocTypeVersion tuple doesn't imply one should be 1793 able to read upper versions of this DocTypeExtension. 1795 11.2.10. DocTypeExtensionName Element 1797 name: DocTypeExtensionName 1799 path: "1*1(\EBML\DocTypeExtension\Name)" 1801 id 0x4283 1803 minOccurs: 1 1805 maxOccurs: 1 1807 length: >0 1809 type: String 1811 description: The name of the DocTypeExtension to differentiate it 1812 from other DocTypeExtension of the same DocType+DocTypeVersion tuple. 1813 A DocTypeExtensionName value MUST be unique within the EBML Header. 1815 11.2.11. DocTypeExtensionVersion Element 1817 name: DocTypeExtensionVersion 1819 path: "1*1(\EBML\DocTypeExtension\Version)" 1821 id 0x4284 1823 minOccurs: 1 1825 maxOccurs: 1 1827 range: not 0 1829 type: Unsigned Integer 1831 description: The version of the DocTypeExtension. Different 1832 DocTypeExtensionVersion values of the same 1833 DocType+DocTypeVersion+DocTypeExtensionName tuple MAY contain 1834 completely different sets of extra Elements. An EBML Reader MAY 1835 support multiple versions of the same DocTypeExtension, only one or 1836 none. 1838 11.3. Global Elements 1840 EBML allows some special Elements to be found within more than one 1841 parent in an EBML Document or optionally at the Root Level of an EBML 1842 Body. These Elements are called Global Elements. There are 2 Global 1843 Elements that can be found in any EBML Document: the CRC-32 Element 1844 and the Void Element. An EBML Schema MAY add other Global Elements 1845 to the format it defines. These extra elements apply only to the 1846 EBML Body, not the EBML Header. 1848 Global Elements are EBML Elements whose path have a EBMLGlobalParent 1849 as their EBMLLastParent. Because it is the last Parent part of the 1850 path, a Global Element might also have non-EBMLGlobalParent parts in 1851 its path. In this case the Global Element can only be found within 1852 this non-EBMLGlobalParent path, i.e. it's not fully "global". 1854 The EBMLEltOccurrence of a Global Element is the number of 1855 occurrences the Element can be found in a Parent Element. But the 1856 Global Element can be found in many Parent Elements, allowing the 1857 same number of occurrences in each Parent where this Element is 1858 found. 1860 11.3.1. CRC-32 Element 1862 name: CRC-32 1864 path: "*1((1*\)\CRC-32)" 1866 id: 0xBF 1868 minOccurs: 0 1870 maxOccurs: 1 1872 length: 4 1874 type: Binary 1876 description: The CRC-32 Element contains a 32-bit Cyclic Redundancy 1877 Check value of all the Element Data of the Parent Element as stored 1878 except for the CRC-32 Element itself. When the CRC-32 Element is 1879 present, the CRC-32 Element MUST be the first ordered EBML Element 1880 within its Parent Element for easier reading. All Top-Level Elements 1881 of an EBML Document that are Master Elements SHOULD include a CRC-32 1882 Element as a Child Element. The CRC in use is the IEEE-CRC-32 1883 algorithm as used in the [ISO.3309.1979] standard and in section 1884 8.1.1.6.2 of [ITU.V42.1994], with initial value of 0xFFFFFFFF. The 1885 CRC value MUST be computed on a little endian bitstream and MUST use 1886 little endian storage. 1888 11.3.2. Void Element 1890 name: Void 1892 path: "*((*\)\Void)" 1894 id: 0xEC 1896 minOccurs: 0 1898 type: Binary 1900 description: Used to void data or to avoid unexpected behaviors when 1901 using damaged data. The content is discarded. Also used to reserve 1902 space in a sub-element for later use. 1904 12. Considerations for Reading EBML Data 1906 The following scenarios describe events to consider when reading EBML 1907 Documents and the recommended design of an EBML Reader. 1909 If a Master Element contains a CRC-32 Element that doesn't validate, 1910 then the EBML Reader MAY ignore all contained data except for 1911 Descendant Elements that contain their own valid CRC-32 Element. 1913 If a Master Element contains more occurrences of a Child Master 1914 Element than permitted according to the maxOccurs and recurring 1915 attributes of the definition of that Element then the occurrences in 1916 addition to maxOccurs MAY be ignored. 1918 If a Master Element contains more occurrences of a Child Element than 1919 permitted according to the maxOccurs attribute of the definition of 1920 that Element then all instances of that Element after the first 1921 maxOccur occurrences from the beginning of its Parent Element SHOULD 1922 be ignored. 1924 13. Terminating Elements 1926 Null Octets, which are octets with all bits set to zero, MAY follow 1927 the value of a String Element or UTF-8 Element to serve as a 1928 terminator. An EBML Writer MAY terminate a String Element or UTF-8 1929 Element with Null Octets in order to overwrite a stored value with a 1930 new value of lesser length while maintaining the same Element Data 1931 Size (this can prevent the need to rewrite large portions of an EBML 1932 Document); otherwise the use of Null Octets within a String Element 1933 or UTF-8 Element is NOT RECOMMENDED. An EBML Reader MUST consider 1934 the value of the String Element or UTF-8 Element to be terminated 1935 upon the first read Null Octet and MUST ignore any data following the 1936 first Null Octet within that Element. A string value and a copy of 1937 that string value terminated by one or more Null Octets are 1938 semantically equal. 1940 The following table shows examples of semantics and validation for 1941 the use of Null Octets. Values to represent Stored Values and the 1942 Semantic Meaning as represented as hexadecimal values. 1944 +---------------------+---------------------+ 1945 | Stored Value | Semantic Meaning | 1946 +=====================+=====================+ 1947 | 0x65 0x62 0x6D 0x6C | 0x65 0x62 0x6D 0x6C | 1948 +---------------------+---------------------+ 1949 | 0x65 0x62 0x00 0x6C | 0x65 0x62 | 1950 +---------------------+---------------------+ 1951 | 0x65 0x62 0x00 0x00 | 0x65 0x62 | 1952 +---------------------+---------------------+ 1953 | 0x65 0x62 | 0x65 0x62 | 1954 +---------------------+---------------------+ 1956 Table 10 1958 14. Guidelines for Updating Elements 1960 An EBML Document can be updated without requiring that the entire 1961 EBML Document be rewritten. These recommendations describe 1962 strategies to change the Element Data of a written EBML Element with 1963 minimal disruption to the rest of the EBML Document. 1965 14.1. Reducing a Element Data in Size 1967 There are three methods to reduce the size of Element Data of a 1968 written EBML Element. 1970 14.1.1. Adding a Void Element 1972 When an EBML Element is changed to reduce its total length by more 1973 than one octet, an EBML Writer SHOULD fill the freed space with a 1974 Void Element. 1976 14.1.2. Extending the Element Data Size 1978 The same value for Element Data Size MAY be written in variable 1979 lengths, so for minor reductions in octet length the Element Data 1980 Size MAY be written to a longer octet length to fill the freed space. 1982 For example, the first row of the following table depicts a String 1983 Element that stores an Element ID (3 octets), Element Data Size (1 1984 octet), and Element Data (4 octets). If the Element Data is changed 1985 to reduce the length by one octet and if the current length of the 1986 Element Data Size is less than its maximum permitted length, then the 1987 Element Data Size of that Element MAY be rewritten to increase its 1988 length by one octet. Thus before and after the change the EBML 1989 Element maintains the same length of 8 octets and data around the 1990 Element does not need to be moved. 1992 +-------------+------------+-------------------+--------------+ 1993 | Status | Element ID | Element Data Size | Element Data | 1994 +=============+============+===================+==============+ 1995 | Before edit | 0x3B4040 | 0x84 | 0x65626D6C | 1996 +-------------+------------+-------------------+--------------+ 1997 | After edit | 0x3B4040 | 0x4003 | 0x6D6B76 | 1998 +-------------+------------+-------------------+--------------+ 2000 Table 11 2002 This method is RECOMMENDED when the Element Data is reduced by a 2003 single octet; for reductions by two or more octets it is RECOMMENDED 2004 to fill the freed space with a Void Element. 2006 Note that if the Element Data length needs to be rewritten as 2007 shortened by one octet and the Element Data Size could be rewritten 2008 as a shorter VINT then it is RECOMMENDED to rewrite the Element Data 2009 Size as one octet shorter, shorten the Element Data by one octet, and 2010 follow that Element with a Void Element. For example, the following 2011 table depicts a String Element that stores an Element ID (3 octets), 2012 Element Data Size (2 octets, but could be rewritten in one octet), 2013 and Element Data (3 octets). If the Element Data is to be rewritten 2014 to a two octet length, then another octet can be taken from Element 2015 Data Size so that there is enough space to add a two octet Void 2016 Element. 2018 +--------+------------+-------------------+--------------+---------+ 2019 | Status | Element ID | Element Data Size | Element Data | Void | 2020 | | | | | Element | 2021 +========+============+===================+==============+=========+ 2022 | Before | 0x3B4040 | 0x4003 | 0x6D6B76 | | 2023 +--------+------------+-------------------+--------------+---------+ 2024 | After | 0x3B4040 | 0x82 | 0x6869 | 0xEC80 | 2025 +--------+------------+-------------------+--------------+---------+ 2027 Table 12 2029 14.1.3. Terminating Element Data 2031 For String Elements and UTF-8 Elements the length of Element Data MAY 2032 be reduced by adding Null Octets to terminate the Element Data (see 2033 Section 13). 2035 In the following table, a four octets long Element Data is changed to 2036 a three octet long value followed by a Null Octet; the Element Data 2037 Size includes any Null Octets used to terminate Element Data so 2038 remains unchanged. 2040 +-------------+------------+-------------------+--------------+ 2041 | Status | Element ID | Element Data Size | Element Data | 2042 +=============+============+===================+==============+ 2043 | Before edit | 0x3B4040 | 0x84 | 0x65626D6C | 2044 +-------------+------------+-------------------+--------------+ 2045 | After edit | 0x3B4040 | 0x84 | 0x6D6B7600 | 2046 +-------------+------------+-------------------+--------------+ 2048 Table 13 2050 Note that this method is NOT RECOMMENDED. For reductions of one 2051 octet, the method for Extending the Element Data Size SHOULD be used. 2052 For reduction by more than one octet, the method for Adding a Void 2053 Element SHOULD be used. 2055 14.2. Considerations when Updating Elements with Cyclic Redundancy 2056 Check (CRC) 2058 If the Element to be changed is a Descendant Element of any Master 2059 Element that contains a CRC-32 Element (see Section 11.3.1) then the 2060 CRC-32 Element MUST be verified before permitting the change. 2061 Additionally the CRC-32 Element value MUST be subsequently updated to 2062 reflect the changed data. 2064 15. Backward and Forward Compatibility 2066 Elements of an EBML format SHOULD be designed with backward and 2067 forward compatibility in mind. 2069 15.1. Backward Compatibility 2071 Backward compatibility of new EBML Elements can be achieved by using 2072 default values for mandatory elements. The default value MUST 2073 represent the state that was assumed for previous versions of the 2074 EBML Schema, without this new EBML Element. If such a state doesn't 2075 make sense for previous versions, then the new EBML Element SHOULD 2076 NOT be mandatory. 2078 Non mandatory EBML Elements can be added in a new EBMLDocTypeVersion. 2079 Since they are not mandatory they won't be found in older versions of 2080 the EBMLDocTypeVersion, just as they might not be found in newer 2081 versions. This causes no compatibility issue. 2083 15.2. Forward Compatibility 2085 EBML Elements MAY be marked as deprecated in a new EBMLDocTypeVersion 2086 using the maxver attribute of the EBML Schema. If such an Element is 2087 found in an EBML Document with newer version of the 2088 EBMLDocTypeVersion it SHOULD be discarded. 2090 16. Security Considerations 2092 EBML itself does not offer any kind of security and does not provide 2093 confidentiality. EBML does not provide any kind of authorization. 2094 EBML only offers marginally useful and effective data integrity 2095 options, such as CRC elements. 2097 Even if the semantic layer offers any kind of encryption, EBML itself 2098 could leak information at both the semantic layer (as declared via 2099 the DocType Element) and within the EBML structure (the presence of 2100 EBML Elements can be derived even with an unknown semantic layer 2101 using a heuristic approach; not without errors, of course, but with a 2102 certain degree of confidence). 2104 An EBML Document that has the following issues may still be handled 2105 by the EBML Reader and the data accepted as such, depending on how 2106 strict the EBML Reader wants to be: 2108 * Invalid Element IDs that are longer than the limit stated in the 2109 EBMLMaxIDLength Element of the EBML Header. 2111 * Invalid Element IDs that are not encoded in the shortest-possible 2112 way. 2114 * Invalid Element Data Size values that are longer than the limit 2115 stated in the EBMLMaxSizeLength Element of the EBML Header. 2117 Element IDs that are unknown to the EBML Reader MAY be accepted as 2118 valid EBML IDs in order to skip such elements. 2120 EBML Elements with a string type may contain extra data after the 2121 first 0x00. These data MUST be discarded according to the Section 13 2122 rules. 2124 An EBML Reader may discard some or all data if the following errors 2125 are found in the EBML Document: 2127 * Invalid Element Data Size values (e.g. extending the length of the 2128 EBML Element beyond the scope of the Parent Element; possibly 2129 triggering access-out-of-bounds issues). 2131 * Very high lengths in order to force out-of-memory situations 2132 resulting in a denial of service, access-out-of-bounds issues etc. 2134 * Missing EBML Elements that are mandatory in a Master Element and 2135 have no declared default value, making the semantic invalid at 2136 that Master Element level. 2138 * Usage of invalid UTF-8 encoding in EBML Elements of UTF-8 type 2139 (e.g. in order to trigger access-out-of-bounds or buffer overflow 2140 issues). 2142 * Usage of invalid data in EBML Elements with a date type, 2143 triggering bogus date accesses. 2145 Side channel attacks could exploit: 2147 * The semantic equivalence of the same string stored in a String 2148 Element or UTF-8 Element with and without zero-bit padding, making 2149 comparison at the semantic level invalid. 2151 * The semantic equivalence of VINT_DATA within Element Data Size 2152 with two different lengths due to left-padding zero bits, making 2153 comparison at the semantic level invalid. 2155 * Data contained within a Master Element which is not itself part of 2156 a Child Element can trigger incorrect parsing behavior in EBML 2157 Readers. 2159 * Extraneous copies of Identically Recurring Element, making parsing 2160 unnecessarily slow to the point of not being usable. 2162 * Copies of Identically Recurring Element within a Parent Element 2163 that contain invalid CRC-32 Elements. EBML Readers not checking 2164 the CRC-32 might use the version of the element with mismatching 2165 CRC-32. 2167 * Use of Void Elements which could be used to hide content or create 2168 bogus resynchronization points seen by some EBML Reader and not 2169 others. 2171 17. IANA Considerations 2172 17.1. CELLAR EBML Element ID Registry 2174 This document creates a new IANA Registry called "CELLAR EBML Element 2175 ID Registry". 2177 Element IDs are described in section Element ID. Element IDs are 2178 encoded using the VINT mechanism described in section Section 4 can 2179 be between one and five octets long. Five octet long Element IDs are 2180 possible only if declared in the header. 2182 This IANA Registry only applies to Elements that can be contained in 2183 the EBML Header, thus including Global Elements. Elements only found 2184 in the EBML Body have their own set of independent Element IDs and 2185 are not part of this IANA Registry. 2187 The VINT Data value of one-octet Element IDs MUST be between 0x01 and 2188 0x7E. These items are valuable because they are short, and need to 2189 be used for commonly repeated elements. Values from 1 to 126 are to 2190 be allocated according to the "RFC Required" policy [RFC8126]. 2192 The VINT Data value of two-octet Element IDs MUST be between 0x007F 2193 and 0x3FFE. Numbers are to be allocated within this range according 2194 to the "Specification Required" policy [RFC8126]. 2196 The numbers 0x3FFF and 0x4000 are RESERVED. 2198 The VINT Data value of three-octet Element IDs MUST be between 0x4001 2199 and 0x1FFFFE. Numbers may be allocated within this range according 2200 to the "First Come First Served" policy [RFC8126]. 2202 The numbers 0x1FFFFF and 0x200000 are RESERVED. 2204 Four-octet Element IDs are numbers between 0x101FFFFF and 0x1FFFFFFE. 2205 Four-octet Element IDs are somewhat special in that they are useful 2206 for resynchronizing to major structures in the event of data 2207 corruption or loss. As such four-octet Element IDs are split into 2208 two categories. Four-octet Element IDs whose lower three octets (as 2209 encoded) would make printable 7-bit ASCII values (0x20 to 0x7E, 2210 inclusive) MUST be allocated by the "Specification Required" policy. 2211 Sequential allocation of values is not required: specifications 2212 SHOULD include a specific request, and are encouraged to do early 2213 allocations. 2215 To be clear about the above category: four-octet Element IDs always 2216 start with hex 0x10 to 0x1F, and that octet may be chosen so that the 2217 entire number has some desirable property, such as a specific CRC. 2218 The other three octets, when ALL having values between 0x21 (33, 2219 ASCII !) and 0x7E (126, ASCII ~), fall into this category. 2221 Other four-octet Element IDs may be allocated by the "First Come 2222 First Served" policy. 2224 The numbers 0xFFFFFFF and 0x1000000 are RESERVED. 2226 Five octet Element IDs (values from 0x10000001 upwards) are RESERVED 2227 according to the "Experimental Use" policy [RFC8126]: they may be 2228 used by anyone at any time, but there is no coordination. 2230 ID Values found in this document are assigned as initial values as 2231 follows: 2233 +------------+-------------------------+-----------------+ 2234 | ID | Element Name | Reference | 2235 +============+=========================+=================+ 2236 | 0x1A45DFA3 | EBML | Described in | 2237 | | | Section 11.2.1 | 2238 +------------+-------------------------+-----------------+ 2239 | 0x4286 | EBMLVersion | Described in | 2240 | | | Section 11.2.2 | 2241 +------------+-------------------------+-----------------+ 2242 | 0x42F7 | EBMLReadVersion | Described in | 2243 | | | Section 11.2.3 | 2244 +------------+-------------------------+-----------------+ 2245 | 0x42F2 | EBMLMaxIDLength | Described in | 2246 | | | Section 11.2.4 | 2247 +------------+-------------------------+-----------------+ 2248 | 0x42F3 | EBMLMaxSizeLength | Described in | 2249 | | | Section 11.2.5 | 2250 +------------+-------------------------+-----------------+ 2251 | 0x4282 | DocType | Described in | 2252 | | | Section 11.2.6 | 2253 +------------+-------------------------+-----------------+ 2254 | 0x4287 | DocTypeVersion | Described in | 2255 | | | Section 11.2.7 | 2256 +------------+-------------------------+-----------------+ 2257 | 0x4285 | DocTypeReadVersion | Described in | 2258 | | | Section 11.2.8 | 2259 +------------+-------------------------+-----------------+ 2260 | 0x4281 | DocTypeExtension | Described in | 2261 | | | Section 11.2.9 | 2262 +------------+-------------------------+-----------------+ 2263 | 0x4283 | DocTypeExtensionName | Described in | 2264 | | | Section 11.2.10 | 2265 +------------+-------------------------+-----------------+ 2266 | 0x4284 | DocTypeExtensionVersion | Described in | 2267 | | | Section 11.2.11 | 2268 +------------+-------------------------+-----------------+ 2269 | 0xBF | CRC-32 | Described in | 2270 | | | Section 11.3.1 | 2271 +------------+-------------------------+-----------------+ 2272 | 0xEC | Void | Described in | 2273 | | | Section 11.3.2 | 2274 +------------+-------------------------+-----------------+ 2276 Table 14 2278 17.2. CELLAR EBML DocType Registry 2280 This document creates a new IANA Registry called "CELLAR EBML DocType 2281 Registry". 2283 To register a new DocType in this registry one needs a DocType name, 2284 a Description of the DocType, a Change Controller (IESG or email of 2285 registrant) and an optional Reference to a document describing the 2286 DocType. 2288 DocType values are described in Section 11.1.3.1. DocTypes are ASCII 2289 strings, defined in Section 7.4, which label the official name of the 2290 EBML Document Type. The strings may be allocated according to the 2291 "First Come First Served" policy. 2293 The use of ASCII corresponds to the types and code already in use, 2294 the value is not meant to be visible to the user. 2296 DocType string values of "matroska" and "webm" are RESERVED to the 2297 IETF for future use. These can be assigned via the "IESG Approval" 2298 or "RFC Required" policies [RFC8126]. 2300 18. Normative References 2302 [IEEE.754.1985] 2303 Institute of Electrical and Electronics Engineers, 2304 "Standard for Binary Floating-Point Arithmetic", August 2305 1985. 2307 [ISO.3309.1979] 2308 International Organization for Standardization, "Data 2309 communication - High-level data link control procedures - 2310 Frame structure", 1979. 2312 [ISO.9899.2011] 2313 International Organization for Standardization, 2314 "Programming languages - C", 2011. 2316 [ITU.V42.1994] 2317 International Telecommunications Union, "Error-correcting 2318 Procedures for DCEs Using Asynchronous-to-Synchronous 2319 Conversion", 1994. 2321 [RFC0020] Cerf, V., "ASCII format for network interchange", STD 80, 2322 RFC 20, DOI 10.17487/RFC0020, October 1969, 2323 . 2325 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2326 Requirement Levels", BCP 14, RFC 2119, 2327 DOI 10.17487/RFC2119, March 1997, 2328 . 2330 [RFC3339] Klyne, G. and C. Newman, "Date and Time on the Internet: 2331 Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002, 2332 . 2334 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 2335 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 2336 2003, . 2338 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 2339 Specifications: ABNF", STD 68, RFC 5234, 2340 DOI 10.17487/RFC5234, January 2008, 2341 . 2343 [RFC5646] Phillips, A., Ed. and M. Davis, Ed., "Tags for Identifying 2344 Languages", BCP 47, RFC 5646, DOI 10.17487/RFC5646, 2345 September 2009, . 2347 [RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", 2348 RFC 7405, DOI 10.17487/RFC7405, December 2014, 2349 . 2351 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 2352 Writing an IANA Considerations Section in RFCs", BCP 26, 2353 RFC 8126, DOI 10.17487/RFC8126, June 2017, 2354 . 2356 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2357 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2358 May 2017, . 2360 [W3C.REC-xml-20081126] 2361 Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and 2362 F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth 2363 Edition)", World Wide Web Consortium Recommendation REC- 2364 xml-20081126, 26 November 2008, 2365 . 2367 [W3C.SPSD-xhtml-basic-20180327] 2368 McCarron, S., "XHTML(tm) Basic 1.1 - Second Edition", 27 2369 March 2018. 2371 19. Informative References 2373 [W3C.REC-xmlschema-0-20041028] 2374 Fallside, D. and P. Walmsley, "XML Schema Part 0: Primer 2375 Second Edition", World Wide Web Consortium Recommendation 2376 REC-xmlschema-0-20041028, 28 October 2004, 2377 . 2379 Authors' Addresses 2381 Steve Lhomme 2383 Email: slhomme@matroska.org 2385 Dave Rice 2387 Email: dave@dericed.com 2389 Moritz Bunkus 2391 Email: moritz@bunkus.org