idnits 2.17.1 draft-ietf-cellar-ebml-12.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 : ---------------------------------------------------------------------------- ** There are 4 instances of too long lines in the document, the longest one being 3492 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (21 October 2019) is 1648 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 949, but not defined == Missing Reference: 'EBMLMinOccurrence' is mentioned on line 960, but not defined == Missing Reference: 'EBMLMaxOccurrence' is mentioned on line 960, but not defined == Missing Reference: 'PathMinOccurrence' is mentioned on line 963, but not defined == Missing Reference: 'PathMaxOccurrence' is mentioned on line 963, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'IEEE.754.1985' -- Possible downref: Non-RFC (?) normative reference: ref. 'ITU.V42.1994' Summary: 1 error (**), 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: 23 April 2020 21 October 2019 7 Extensible Binary Meta Language 8 draft-ietf-cellar-ebml-12 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 23 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 . . . . . . . . . . . . . . . . . . . . . . . . 18 77 8.1. EBML Header . . . . . . . . . . . . . . . . . . . . . . . 18 78 8.2. EBML Body . . . . . . . . . . . . . . . . . . . . . . . . 18 79 9. EBML Stream . . . . . . . . . . . . . . . . . . . . . . . . . 18 80 10. EBML Versioning . . . . . . . . . . . . . . . . . . . . . . . 19 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 . . . . . . . . . . . . . . . . 20 87 11.1.3. Attributes . . . . . . . . . . . . . . 20 88 11.1.4. Element . . . . . . . . . . . . . . . . . 21 89 11.1.5. Attributes . . . . . . . . . . . . . . . . 21 90 11.1.6. Element . . . . . . . . . . . . . . 28 91 11.1.7. Attributes . . . . . . . . . . . . . 28 92 11.1.8. Element . . . . . . . . . . . 28 93 11.1.9. Attributes . . . . . . . . . . 28 94 11.1.10. Element . . . . . . . . . . . . . . . 29 95 11.1.11. Element . . . . . . . . . . . . . . . . . . . 29 96 11.1.12. Attributes . . . . . . . . . . . . . . . . . 29 97 11.1.13. Element . . . . . . . . . . . . . . . . 29 98 11.1.14. Attributes . . . . . . . . . . . . . . . 30 99 11.1.15. XML Schema for EBML Schema . . . . . . . . . . . . . 30 100 11.1.16. Identically Recurring Elements . . . . . . . . . . . 30 101 11.1.17. Textual expression of floats . . . . . . . . . . . . 31 102 11.1.18. Note on the use of default attributes to define 103 Mandatory EBML Elements . . . . . . . . . . . . . . . 31 104 11.2. EBML Header Elements . . . . . . . . . . . . . . . . . . 32 105 11.2.1. EBML Element . . . . . . . . . . . . . . . . . . . . 32 106 11.2.2. EBMLVersion Element . . . . . . . . . . . . . . . . 33 107 11.2.3. EBMLReadVersion Element . . . . . . . . . . . . . . 33 108 11.2.4. EBMLMaxIDLength Element . . . . . . . . . . . . . . 34 109 11.2.5. EBMLMaxSizeLength Element . . . . . . . . . . . . . 34 110 11.2.6. DocType Element . . . . . . . . . . . . . . . . . . 35 111 11.2.7. DocTypeVersion Element . . . . . . . . . . . . . . . 35 112 11.2.8. DocTypeReadVersion Element . . . . . . . . . . . . . 35 113 11.2.9. DocTypeExtension Element . . . . . . . . . . . . . . 36 114 11.2.10. DocTypeExtensionName Element . . . . . . . . . . . . 36 115 11.2.11. DocTypeExtensionVersion Element . . . . . . . . . . 37 116 11.3. Global Elements . . . . . . . . . . . . . . . . . . . . 37 117 11.3.1. CRC-32 Element . . . . . . . . . . . . . . . . . . . 38 118 11.3.2. Void Element . . . . . . . . . . . . . . . . . . . . 38 119 12. Considerations for Reading EBML Data . . . . . . . . . . . . 39 120 13. Terminating Elements . . . . . . . . . . . . . . . . . . . . 39 121 14. Guidelines for Updating Elements . . . . . . . . . . . . . . 40 122 14.1. Reducing a Element Data in Size . . . . . . . . . . . . 40 123 14.1.1. Adding a Void Element . . . . . . . . . . . . . . . 40 124 14.1.2. Extending the Element Data Size . . . . . . . . . . 40 125 14.1.3. Terminating Element Data . . . . . . . . . . . . . . 41 126 14.2. Considerations when Updating Elements with Cyclic 127 Redundancy Check (CRC) . . . . . . . . . . . . . . . . . 42 128 15. Backward and Forward Compatibility . . . . . . . . . . . . . 42 129 15.1. Backward Compatibility . . . . . . . . . . . . . . . . . 42 130 15.2. Forward Compatibility . . . . . . . . . . . . . . . . . 43 131 16. Security Considerations . . . . . . . . . . . . . . . . . . . 43 132 17. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 44 133 17.1. CELLAR EBML Element ID Registry . . . . . . . . . . . . 44 134 17.2. CELLAR EBML DocType Registry . . . . . . . . . . . . . . 48 135 18. Normative References . . . . . . . . . . . . . . . . . . . . 48 136 19. Informative References . . . . . . . . . . . . . . . . . . . 49 137 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 50 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 the definition of the EBML Element 315 (#ebml-element)) in which case the VINT_WIDTH MUST NOT exceed seven 316 bits in length. Within the EBML Body, when a VINT is used to express 317 an Element ID, the maximum length allowed for the VINT_WIDTH is one 318 less than the value set in the EBMLMaxIDLength Element. Within the 319 EBML Body, when a VINT is used to express an Element Data Size, the 320 maximum length allowed for the VINT_WIDTH is one less than the value 321 set in the 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 the section on the EBMLMaxIDLength Element 403 (#ebmlmaxidlength-element)). The VINT_DATA component of the Element 404 ID MUST NOT be either defined or written as either all zero values or 405 all one values. Any Element ID with the VINT_DATA component set as 406 all zero values or all one values MUST be ignored. The VINT_DATA 407 component of the Element ID MUST be encoded at the shortest valid 408 length. For example, an Element ID with binary encoding of "1011 409 1111" is valid, whereas an Element ID with binary encoding of "0100 410 0000 0011 1111" stores a semantically equal VINT_DATA but is invalid 411 because a shorter VINT encoding is possible. Additionally, an 412 Element ID with binary encoding of "1111 1111" is invalid since the 413 VINT_DATA section is set to all one values, whereas an Element ID 414 with binary encoding of "0100 0000 0111 1111" stores a semantically 415 equal VINT_DATA and is the shortest possible VINT 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 the section on the EBMLMaxSizeLength Element 478 (#ebmlmaxsizelength-element)). Unlike the VINT_DATA of the Element 479 ID, the VINT_DATA component of the Element Data Size is not mandated 480 to be encoded at the shortest valid length. For example, an Element 481 Data Size with binary encoding of 1011 1111 or a binary encoding of 482 0100 0000 0011 1111 are both valid Element Data Sizes and both store 483 a semantically equal value (both 0b00000000111111 and 0b0111111, the 484 VINT_DATA sections of the examples, represent the 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 the section on EBML Element Types (#ebml-element-types)). An 490 Element Data Size with all VINT_DATA bits set to zero indicates that 491 the Element Data is zero octets in length. Such an EBML Element is 492 referred to as an Empty Element. If an Empty Element has a default 493 value declared then the EBML Reader MUST interpret the value of the 494 Empty Element as the default value. If an Empty Element has no 495 default value declared then the EBML Reader MUST use the value of the 496 Empty Element for the corresponding EBML Element Type of the Element 497 ID, 0 for numbers and an empty string for 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 the section on the 510 unknownsizeallowed attribute (#unknownsizeallowed)). 512 The use of Unknown-Sized Elements allows for an EBML Element to be 513 written and read before the size of the EBML Element is known. 514 Unknown-Sized Element MUST NOT be used or defined unnecessarily; 515 however if the Element Data Size is not known before the Element Data 516 is written, such as in some cases of data streaming, then Unknown- 517 Sized Elements MAY be used. The end of an Unknown-Sized Element is 518 determined by whichever comes first: 520 * Any EBML Element that is a valid Parent Element of the Unknown- 521 Sized Element according to the EBML Schema, Global Elements 522 (#global-elements) excluded. 524 * Any valid EBML Element according to the EBML Schema, Global 525 Elements (#global-elements) excluded, that is not a Descendant 526 Element of the Unknown-Sized Element but share a common direct 527 parent, such as a Top-Level Element. 529 * Any EBML Element that is a valid Root Element according to the 530 EBML Schema, Global Elements (#global-elements) excluded. 532 * The end of the Parent Element with a known size has been reached. 534 * The end of the EBML Document, either when reaching the end of the 535 file or because a new EBML Header started. 537 Consider an Unknown-Sized Element which EBML path is 538 "\root\level1\level2\elt". When reading a new Element ID, assuming 539 the EBML Path of that new Element is valid, here are some possible 540 and impossible ways that this new Element is ending "elt": 542 +------------------------------------+----------------------------+ 543 | EBML Path of new element | Status | 544 +====================================+============================+ 545 | "\root\level1\level2" | Ends the Unknown-Sized | 546 | | Element, as it is a new | 547 | | Parent Element | 548 +------------------------------------+----------------------------+ 549 | "\root\level1" | Ends the Unknown-Sized | 550 | | Element, as it is a new | 551 | | Parent Element | 552 +------------------------------------+----------------------------+ 553 | "\root" | Ends the Unknown-Sized | 554 | | Element, as it is a new | 555 | | Root Element | 556 +------------------------------------+----------------------------+ 557 | "\root2" | Ends the Unknown-Sized | 558 | | Element, as it is a new | 559 | | Root Element | 560 +------------------------------------+----------------------------+ 561 | "\root\level1\level2\other" | Ends the Unknown-Sized | 562 | | Element, as they share the | 563 | | same parent | 564 +------------------------------------+----------------------------+ 565 | "\root\level1\level2\elt" | Ends the Unknown-Sized | 566 | | Element, as they share the | 567 | | same parent | 568 +------------------------------------+----------------------------+ 569 | "\root\level1\level2\elt\inside" | Doesn't end the Unknown- | 570 | | Sized Element, it's a | 571 | | child of "elt" | 572 +------------------------------------+----------------------------+ 573 | "\root\level1\level2\elt\" | Global Element is valid, | 574 | | it's a child of "elt" | 575 +------------------------------------+----------------------------+ 576 | "\root\level1\level2\" | Global Element cannot be | 577 | | assumed to have this path, | 578 | | while parsing "elt" it can | 579 | | only be a child of "elt" | 580 +------------------------------------+----------------------------+ 582 Table 5 584 6.3. Data Size Values 586 For Element Data Sizes encoded at octet lengths from one to eight, 587 this table depicts the range of possible values that can be encoded 588 as an Element Data Size. An Element Data Size with an octet length 589 of 8 is able to express a size of 2^56-2 or 72,057,594,037,927,934 590 octets (or about 72 petabytes). The maximum possible value that can 591 be stored as Element Data Size is referred to as VINTMAX. 593 +--------------+----------------------+ 594 | Octet Length | Possible Value Range | 595 +==============+======================+ 596 | 1 | 0 to 2^(7-2) | 597 +--------------+----------------------+ 598 | 2 | 0 to 2^(14-2) | 599 +--------------+----------------------+ 600 | 3 | 0 to 2^(21-2) | 601 +--------------+----------------------+ 602 | 4 | 0 to 2^(28-2) | 603 +--------------+----------------------+ 604 | 5 | 0 to 2^(35-2) | 605 +--------------+----------------------+ 606 | 6 | 0 to 2^(42-2) | 607 +--------------+----------------------+ 608 | 7 | 0 to 2^(49-2) | 609 +--------------+----------------------+ 610 | 8 | 0 to 2^(56-2) | 611 +--------------+----------------------+ 613 Table 6 615 If the length of Element Data equals 2^(n*7)-1 then the octet length 616 of the Element Data Size MUST be at least n+1. This rule prevents an 617 Element Data Size from being expressed as the unknown size value. 618 The following table clarifies this rule by showing a valid and 619 invalid expression of an Element Data Size with a VINT_DATA of 127 620 (which is equal to 2^(1*7)-1) and 16,383 (which is equal to 2^((2*7)- 621 1).) 622 +------------+-------------+-----------------------+--------------+ 623 | VINT_WIDTH | VINT_MARKER | VINT_DATA | Element Data | 624 | | | | Size Status | 625 +============+=============+=======================+==============+ 626 | | 1 | 1111111 | Reserved | 627 | | | | (meaning | 628 | | | | Unknown) | 629 +------------+-------------+-----------------------+--------------+ 630 | 0 | 1 | 00000001111111 | Valid | 631 | | | | (meaning 127 | 632 | | | | octets) | 633 +------------+-------------+-----------------------+--------------+ 634 | 00 | 1 | 000000000000001111111 | Valid | 635 | | | | (meaning 127 | 636 | | | | octets) | 637 +------------+-------------+-----------------------+--------------+ 638 | 0 | 1 | 11111111111111 | Reserved | 639 | | | | (meaning | 640 | | | | Unknown) | 641 +------------+-------------+-----------------------+--------------+ 642 | 00 | 1 | 000000011111111111111 | Valid | 643 | | | | (16,383 | 644 | | | | octets) | 645 +------------+-------------+-----------------------+--------------+ 647 Table 7 649 7. EBML Element Types 651 EBML Elements are defined by an EBML Schema (see Section 11.1) which 652 MUST declare one of the following EBML Element Types for each EBML 653 Element. An EBML Element Type defines a concept of storing data 654 within an EBML Element that describes such characteristics as length, 655 endianness, and definition. 657 EBML Elements which are defined as a Signed Integer Element, Unsigned 658 Integer Element, Float Element, or Date Element use big endian 659 storage. 661 7.1. Signed Integer Element 663 A Signed Integer Element MUST declare a length from zero to eight 664 octets. If the EBML Element is not defined to have a default value, 665 then a Signed Integer Element with a zero-octet length represents an 666 integer value of zero. 668 A Signed Integer Element stores an integer (meaning that it can be 669 written without a fractional component) which could be negative, 670 positive, or zero. Signed Integers are stored with two's complement 671 notation with the leftmost bit being the sign bit. Because EBML 672 limits Signed Integers to 8 octets in length a Signed Integer Element 673 stores a number from -9,223,372,036,854,775,808 to 674 +9,223,372,036,854,775,807. 676 7.2. Unsigned Integer Element 678 An Unsigned Integer Element MUST declare a length from zero to eight 679 octets. If the EBML Element is not defined to have a default value, 680 then an Unsigned Integer Element with a zero-octet length represents 681 an integer value of zero. 683 An Unsigned Integer Element stores an integer (meaning that it can be 684 written without a fractional component) which could be positive or 685 zero. Because EBML limits Unsigned Integers to 8 octets in length an 686 Unsigned Integer Element stores a number from 0 to 687 18,446,744,073,709,551,615. 689 7.3. Float Element 691 A Float Element MUST declare a length of either zero octet (0 bit), 692 four octets (32 bit) or eight octets (64 bit). If the EBML Element 693 is not defined to have a default value, then a Float Element with a 694 zero-octet length represents a numerical value of zero. 696 A Float Element stores a floating-point number as defined in 697 [IEEE.754.1985]. 699 7.4. String Element 701 A String Element MUST declare a length in octets from zero to 702 VINTMAX. If the EBML Element is not defined to have a default value, 703 then a String Element with a zero-octet length represents an empty 704 string. 706 A String Element MUST either be empty (zero-length) or contain 707 printable ASCII characters [RFC0020] in the range of 0x20 to 0x7E, 708 with an exception made for termination (see the section on the 709 Terminating Elements (#terminating-elements)). 711 7.5. UTF-8 Element 713 A UTF-8 Element MUST declare a length in octets from zero to VINTMAX. 714 If the EBML Element is not defined to have a default value, then a 715 UTF-8 Element with a zero-octet length represents an empty string. 717 A UTF-8 Element contains only a valid Unicode string as defined in 718 [RFC3629], with an exception made for termination (see the section on 719 the Terminating Elements (#terminating-elements)). 721 7.6. Date Element 723 A Date Element MUST declare a length of either zero octets or eight 724 octets. If the EBML Element is not defined to have a default value, 725 then a Date Element with a zero-octet length represents a timestamp 726 of 2001-01-01T00:00:00.000000000 UTC [RFC3339]. 728 The Date Element stores an integer in the same format as the Signed 729 Integer Element that expresses a point in time referenced in 730 nanoseconds from the precise beginning of the third millennium of the 731 Gregorian Calendar in Coordinated Universal Time (also known as 732 2001-01-01T00:00:00.000000000 UTC). This provides a possible 733 expression of time from 1708-09-11T00:12:44.854775808 UTC to 734 2293-04-11T11:47:16.854775807 UTC. 736 7.7. Master Element 738 A Master Element MUST declare a length in octets from zero to 739 VINTMAX. The Master Element MAY also use an unknown length. See the 740 section on Element Data Size (#element-data-size) for rules that 741 apply to elements of unknown length. 743 The Master Element contains zero, one, or many other elements. EBML 744 Elements contained within a Master Element MUST have the 745 EBMLParentPath of their Element Path equal to the EBMLMasterPath of 746 the Master Element Element Path (see the section on the EBML Path 747 (#path)). Element Data stored within Master Elements SHOULD only 748 consist of EBML Elements and SHOULD NOT contain any data that is not 749 part of an EBML Element. The EBML Schema identifies what Element IDs 750 are valid within the Master Elements for that version of the EBML 751 Document Type. Any data contained within a Master Element that is 752 not part of a Child Element MUST be ignored. 754 7.8. Binary Element 756 A Binary Element MUST declare a length in octets from zero to 757 VINTMAX. 759 The contents of a Binary Element should not be interpreted by the 760 EBML Reader. 762 8. EBML Document 764 An EBML Document is comprised of only two components, an EBML Header 765 and an EBML Body. An EBML Document MUST start with an EBML Header 766 that declares significant characteristics of the entire EBML Body. 767 An EBML Document consists of EBML Elements and MUST NOT contain any 768 data that is not part of an EBML Element. 770 8.1. EBML Header 772 The EBML Header is a declaration that provides processing 773 instructions and identification of the EBML Body. The EBML Header of 774 an EBML Document is analogous to the XML Declaration of an XML 775 Document. 777 The EBML Header documents the EBML Schema (also known as the EBML 778 DocType) that is used to semantically interpret the structure and 779 meaning of the EBML Document. Additionally the EBML Header documents 780 the versions of both EBML and the EBML Schema that were used to write 781 the EBML Document and the versions required to read the EBML 782 Document. 784 The EBML Header MUST contain a single Master Element with an Element 785 Name of EBML and Element ID of 0x1A45DFA3 (see the definition of the 786 EBML Element (#ebml-element)) and any number of additional EBML 787 Elements within it. The EBML Header of an EBML Document that uses an 788 EBMLVersion of 1 MUST only contain EBML Elements that are defined as 789 part of this document. 791 8.2. EBML Body 793 All data of an EBML Document following the EBML Header is the EBML 794 Body. The end of the EBML Body, as well as the end of the EBML 795 Document that contains the EBML Body, is reached at whichever comes 796 first: the beginning of a new EBML Header at the Root Level or the 797 end of the file. The EBML Body MUST NOT contain any data that is not 798 part of an EBML Element. This document defines precisely which EBML 799 Elements are to be used within the EBML Header, but does not name or 800 define which EBML Elements are to be used within the EBML Body. The 801 definition of which EBML Elements are to be used within the EBML Body 802 is defined by an EBML Schema. 804 9. EBML Stream 806 An EBML Stream is a file that consists of one or more EBML Documents 807 that are concatenated together. An occurrence of a EBML Header at 808 the Root Level marks the beginning of an EBML Document. 810 10. EBML Versioning 812 An EBML Document handles 2 different versions: the version of the 813 EBML Header and the version of the EBML Body. Both versions are 814 meant to be backward compatible. 816 10.1. EBML Header Version 818 The version of the EBML Header is found in EBMLVersion. An EBML 819 parser can read an EBML Header if it can read either the EBMLVersion 820 version or a version equal or higher than the one found in 821 EBMLReadVersion. 823 10.2. EBML Document Version 825 The version of the EBML Body is found in EBMLDocTypeVersion. A 826 parser for the particular DocType format can read the EBML Document 827 if it can read either the EBMLDocTypeVersion version of that format 828 or a version equal or higher than the one found in 829 EBMLDocTypeReadVersion. 831 11. Elements semantic 833 11.1. EBML Schema 835 An EBML Schema is a well-formed XML Document [W3C.REC-xml-20081126] 836 that defines the properties, arrangement, and usage of EBML Elements 837 that compose a specific EBML Document Type. The relationship of an 838 EBML Schema to an EBML Document is analogous to the relationship of 839 an XML Schema [W3C.REC-xmlschema-0-20041028] to an XML Document 840 [W3C.REC-xml-20081126]. An EBML Schema MUST be clearly associated 841 with one or more EBML Document Types. An EBML Document Type is 842 identified by a string stored within the EBML Header in the DocType 843 Element; for example matroska or webm (see the definition of the 844 DocType Element (#doctype-element)). The DocType value for an EBML 845 Document Type MUST be unique and persistent. 847 An EBML Schema MUST declare exactly one EBML Element at Root Level 848 (referred to as the Root Element) that occurs exactly once within an 849 EBML Document. The Void Element MAY also occur at Root Level but is 850 not a Root Element (see the definition of the Void Element (#void- 851 element)). 853 The EBML Schema MUST document all Elements of the EBML Body. The 854 EBML Schema does not document Global Elements (#global-elements) that 855 are defined by this document (namely the Void Element and the CRC-32 856 Element). 858 The EBML Schema MUST NOT use the Element ID "0x1A45DFA3" which is 859 reserved for the EBML Header for resynchronization purpose. 861 An EBML Schema MAY constrain the use of EBML Header Elements (see 862 EBML Header Elements (#ebml-header-elements)) by adding or 863 constraining that Element's "range" attribute. For example, an EBML 864 Schema MAY constrain the EBMLMaxSizeLength to a maximum value of "8" 865 or MAY constrain the EBMLVersion to only support a value of "1". If 866 an EBML Schema adopts the EBML Header Element as-is, then it is not 867 required to document that Element within the EBML Schema. If an EBML 868 Schema constrains the range of an EBML Header Element, then that 869 Element MUST be documented within an "" node of the EBML 870 Schema. This document provides an example of an EBML Schema, see 871 EBML Schema Example (#ebml-schema-example). 873 11.1.1. EBML Schema Example 875 Container of data and attributes representing one or many files. An attached file. Filename of the attached file. MIME type of the file. Modification timestamp of the file. The data of the file. 877 11.1.2. Element 879 As an XML Document, the EBML Schema MUST use "" as the 880 top level element. The "" element can contain 881 "" sub-elements. 883 11.1.3. Attributes 885 Within an EBML Schema the "" element uses the following 886 attributes: 888 11.1.3.1. docType 890 The docType lists the official name of the EBML Document Type that is 891 defined by the EBML Schema; for example, "". 894 The docType attribute is REQUIRED within the "" Element. 896 11.1.3.2. version 898 The version lists a non-negative integer that specifies the version 899 of the docType documented by the EBML Schema. Unlike XML Schemas, an 900 EBML Schema documents all versions of a docType's definition rather 901 than using separate EBML Schemas for each version of a docType. EBML 902 Elements may be introduced and deprecated by using the minver and 903 maxver attributes of "". 905 The version attribute is REQUIRED within the "" Element. 907 11.1.4. Element 909 Each "" defines one EBML Element through the use of several 910 attributes that are defined in EBML Schema Element Attributes 911 (#ebmlschema-attributes). EBML Schemas MAY contain additional 912 attributes to extend the semantics but MUST NOT conflict with the 913 definitions of the "" attributes defined within this 914 document. 916 The "" nodes contain a description of the meaning and use of 917 the EBML Element stored within one or more "" sub- 918 elements, followed by optional "" sub-elements, 919 followed by zero or one "" sub-element, followed by 920 optional "" sub-elements. All "" nodes MUST be 921 sub-elements of the "". 923 11.1.5. Attributes 925 Within an EBML Schema the "" uses the following attributes 926 to define an EBML Element: 928 11.1.5.1. name 930 The name provides the human-readable name of the EBML Element. The 931 value of the name MUST be in the form of characters "A" to "Z", "a" 932 to "z", "0" to "9", "-" and ".". 934 The name attribute is REQUIRED. 936 11.1.5.2. path 938 The path defines the allowed storage locations of the EBML Element 939 within an EBML Document. This path MUST be defined with the full 940 hierarchy of EBML Elements separated with a "\". The top EBML 941 Element in the path hierarchy being the first in the value. The 942 syntax of the path attribute is defined using this Augmented Backus- 943 Naur Form (ABNF) [RFC5234] with the case sensitive update [RFC7405] 944 notation: 946 The path attribute is REQUIRED. 948 EBMLFullPath = EBMLEltOccurrence "(" EBMLMasterPath ")" 949 EBMLMasterPath = [EBMLParentPath] EBMLElementPath 950 EBMLParentPath = EBMLFixedParent EBMLLastParent 951 EBMLFixedParent = *(EBMLPathAtom) 952 EBMLElementPath = EBMLPathAtom / EBMLPathAtomRecursive 953 EBMLPathAtom = PathDelimiter EBMLAtomName 954 EBMLPathAtomRecursive = "(1*(" EBMLPathAtom "))" 955 EBMLLastParent = EBMLPathAtom / EBMLGlobalParent 956 EBMLGlobalParent = "(" GlobalParentOccurence "\)" 957 EBMLAtomName = 1*(EBMLNameChar) 958 EBMLNameChar = ALPHA / DIGIT / "-" / "." 959 PathDelimiter = "\" 960 EBMLEltOccurrence = [EBMLMinOccurrence] "*" [EBMLMaxOccurrence] 961 EBMLMinOccurrence = 1*DIGIT ; no upper limit 962 EBMLMaxOccurrence = 1*DIGIT ; no upper limit 963 GlobalParentOccurence = [PathMinOccurrence] "*" [PathMaxOccurrence] 964 PathMinOccurrence = 1*DIGIT ; no upper limit 965 PathMaxOccurrence = 1*DIGIT ; no upper limit 967 The "*", "(" and ")" symbols are interpreted as defined in [RFC5234]. 969 The EBMLPathAtom part of the EBMLElementPath MUST be equal to the 970 name attribute of the EBML Schema. 972 The starting PathDelimiter of the path corresponds to the root of the 973 EBML Document. 975 The EBMLEltOccurrence part is interpreted as an ABNF Variable 976 Repetition. The repetition amounts correspond to how many times the 977 EBML Element can be found in its Parent Element. 979 The EBMLMinOccurrence represents the minimum permitted number of 980 occurrences of this EBML Element within its Parent Element. Each 981 instance of the Parent Element MUST contain at least this many 982 instances of this EBML Element. If the EBML Element has an empty 983 EBMLParentPath then EBMLMinOccurrence refers to constraints on the 984 occurrence of the EBML Element within the EBML Document. If 985 EBMLMinOccurrence is not present then that EBML Element has an 986 EBMLMinOccurrence value of 0. The semantic meaning of 987 EBMLMinOccurrence within an EBML Schema is analogous to the meaning 988 of minOccurs within an XML Schema. EBML Elements with 989 EBMLMinOccurrence set to "1" that also have a default value (see 990 default (#default)) declared are not REQUIRED to be stored but are 991 REQUIRED to be interpreted, see Note on the Use of default attributes 992 to define Mandatory EBML Elements (#note-on-the-use-of-default- 993 attributes-to-define-mandatory-ebml-elements). An EBML Element 994 defined with a EBMLMinOccurrence value greater than zero is called a 995 Mandatory EBML Element. 997 The EBMLMaxOccurrence represents the maximum permitted number of 998 occurrences of this EBML Element within its Parent Element. Each 999 instance of the Parent Element MUST contain at most this many 1000 instances of this EBML Element. If the EBML Element has an empty 1001 EBMLParentPath then EBMLMaxOccurrence refers to constraints on the 1002 occurrence of the EBML Element within the EBML Document. If 1003 EBMLMaxOccurrence is not present then there is no upper bound for the 1004 permitted number of occurrences of this EBML Element within its 1005 Parent Element resp. within the EBML Document depending on whether 1006 the EBMLParentPath of the EBML Element is empty or not. The semantic 1007 meaning of EBMLMaxOccurrence within an EBML Schema path is analogous 1008 to the meaning of maxOccurs within an XML Schema. 1010 In some cases the EBMLLastParent part of the path is an 1011 EBMLGlobalParent. A path with a EBMLGlobalParent defines a Global 1012 Element (#global-elements). Any path that starts with the 1013 EBMLFixedParent of the Global Element and matches the occurrences 1014 found in the GlobalParentOccurence is a valid path for the Global 1015 Element. 1017 The GlobalParentOccurence part is interpreted as an ABNF Variable 1018 Repetition. The repetition amounts correspond to the amount of 1019 unspecified Parent Element levels there can be between the 1020 EBMLFixedParent and the actual EBMLElementPath. 1022 PathMinOccurrence represents the minimum number of element path 1023 required between the EBMLFixedParent and the Global Element 1024 EBMLElementPath. For example 0 means the EBMLElementPath can be 1025 right after the EBMLFixedParent, 1 means there has to be at least an 1026 element between the EBMLFixedParent and the EBMLElementPath. If 1027 PathMinOccurrence is not present then that EBML Element has an 1028 PathMinOccurrence value of 0. 1030 PathMaxOccurrence represents the maximum number of element path 1031 possible between the EBMLFixedParent and the Global Element 1032 EBMLElementPath. It cannot have the value 0 as it would be the 1033 Global Element can only be found right after the EBMLFixedParent, in 1034 which case it's not a Global Element anymore. If PathMaxOccurrence 1035 is not present then there is no upper bound for the permitted number 1036 of occurrences of element path possible between the EBMLFixedParent 1037 and the Global Element EBMLElementPath. 1039 If the path contains an EBMLPathAtomRecursive part, the EBML Element 1040 can occur within itself recursively (see the recursive attribute 1041 (#recursive)). 1043 As an example, a "path" of "1*(\Segment\Info)" means the element Info 1044 is found inside the Segment elements at least once and with no 1045 maximum iteration. An element SeekHead with path 1046 "0*2(\Segment\SeekHead)" may not be found at all in its Segment 1047 parent, once or twice but no more than that. 1049 11.1.5.3. id 1051 The Element ID encoded as a Variable Size Integer expressed in 1052 hexadecimal notation prefixed by a 0x that is read and stored in big- 1053 endian order. To reduce the risk of false positives while parsing 1054 EBML Streams, the Element IDs of the Root Element and Top-Level 1055 Elements SHOULD be at least 4 octets in length. Element IDs defined 1056 for use at Root Level or directly under the Root Level MAY use 1057 shorter octet lengths to facilitate padding and optimize edits to 1058 EBML Documents; for instance, the Void Element uses an Element ID 1059 with a one octet length to allow its usage in more writing and 1060 editing scenarios. 1062 The id attribute is REQUIRED. 1064 11.1.5.4. minOccurs 1066 An integer expressing the minimum permitted number of occurrences of 1067 this EBML Element within its Parent Element. The minOccurs value 1068 MUST be equal to the EBMLMinOccurrence value of the path. 1070 The minOccurs attribute is OPTIONAL. If the minOccurs attribute is 1071 not present then that EBML Element has a minOccurs value of 0. 1073 11.1.5.5. maxOccurs 1075 An integer expressing the maximum permitted number of occurrences of 1076 this EBML Element within its Parent Element. The maxOccurs value 1077 MUST be equal to the EBMLMaxOccurrence value of the path. 1079 The maxOccurs attribute is OPTIONAL. If the maxOccurs attribute is 1080 not present then that EBML Element has no maximum occurrence, similar 1081 to unbounded in the XML world. 1083 11.1.5.6. range 1085 A numerical range for EBML Elements which are of numerical types 1086 (Unsigned Integer, Signed Integer, Float, and Date). If specified 1087 the value of the EBML Element MUST be within the defined range. See 1088 section of Expressions of range (#expression-of-range) for rules 1089 applied to expression of range values. 1091 The range attribute is OPTIONAL. If the range attribute is not 1092 present then any value legal for the type attribute is valid. 1094 11.1.5.6.1. Expression of range 1096 The range attribute MUST only be used with EBML Elements that are 1097 either signed integer, unsigned integer, float, or date. The 1098 expression defines the upper, lower, exact or excluded value of the 1099 EBML Element and optionally an upper boundary value combined with a 1100 lower boundary. The range expression may contain whitespace (using 1101 the ASCII 0x20 character) for readability but whitespace within a 1102 range expression MUST NOT convey meaning. 1104 To set a fixed value for the range, the value is used as the 1105 attribute value. For example "1234" means the EBML element always 1106 has the value 1234. The value can be prefixed with "not" to indicate 1107 that the fixed value MUST NOT be used for that Element. For example 1108 "not 1234" means the Element can use all values of its type except 1109 1234. 1111 For an exclusive lower boundary the ">" sign is used and the ">=" 1112 sign is used for an inclusive lower boundary. For example ">3" 1113 meaning the Element value MUST be greater than 3 or ">=0x1p+0" 1114 meaning the Element value MUST be greater than or equal to the 1115 floating value 1.0, see textual expression of floats (#textual- 1116 expression-of-floats). 1118 For an exclusive upper boundary the "<" sign is used and the "<=" 1119 sign is used for an inclusive upper boundary. For example "<-2" 1120 meaning the Element value MUST be less than -2 or "<=10" meaning the 1121 Element value MUST be less than or equal to the 10. 1123 The lower and upper bounds can be combined into an expression to form 1124 a closed boundary. The lower boundary coming first followed by the 1125 upper boundary, separated by a comma. For example ">3,<= 20" means 1126 the Element value MUST be greater than 3 and less than or equal to 1127 20. 1129 A special form of lower and upper bounds using the "-" separator is 1130 possible, meaning the Element value MUST be greater than or to the 1131 first value and MUST be less than or equal to the second value. For 1132 example "1-10" is equivalent to ">=1,<=10". If the upper boundary is 1133 negative, only the latter form MUST be used. 1135 11.1.5.7. length 1137 A value to express the valid length of the Element Data as written 1138 measured in octets. The length provides a constraint in addition to 1139 the Length value of the definition of the corresponding EBML Element 1140 Type. This length MUST be expressed as either a non-negative integer 1141 or a range (see expression of range (#expression-of-range)) that 1142 consists of only non-negative integers and valid operators. 1144 The length attribute is OPTIONAL. If the length attribute is not 1145 present for that EBML Element then that EBML Element is only limited 1146 in length by the definition of the associated EBML Element Type. 1148 11.1.5.8. default 1150 If an Element is mandatory (has a EBMLMinOccurrence value greater 1151 than zero) but not written within its Parent Element or stored as an 1152 Empty Element, then the EBML Reader of the EBML Document MUST 1153 semantically interpret the EBML Element as present with this 1154 specified default value for the EBML Element. EBML Elements that are 1155 Master Elements MUST NOT declare a default value. EBML Elements with 1156 a minOccurs value greater than 1 MUST NOT declare a default value. 1158 The default attribute is OPTIONAL. 1160 11.1.5.9. type 1162 The type MUST be set to one of the following values: "integer" 1163 (signed integer), "uinteger" (unsigned integer), "float", "string", 1164 "date", "utf-8", "master", or "binary". The content of each type is 1165 defined within section on EBML Element Types (#ebml-element-types). 1167 The type attribute is REQUIRED. 1169 11.1.5.10. unknownsizeallowed 1171 A boolean to express if an EBML Element is permitted to be Unknown- 1172 Sized Element (having all VINT_DATA bits of Element Data Size set to 1173 1). EBML Elements that are not Master Elements MUST NOT set 1174 unknownsizeallowed to true. An EBML Element that is defined with an 1175 unknownsizeallowed attribute set to 1 MUST also have the 1176 unknownsizeallowed attribute of its Parent Element set to 1. 1178 An EBML Element with the unknownsizeallowed attribute set to 1 MUST 1179 NOT have its recursive attribute set to 1. 1181 The unknownsizeallowed attribute is OPTIONAL. If the 1182 unknownsizeallowed attribute is not used then that EBML Element is 1183 not allowed to use an unknown Element Data Size. 1185 11.1.5.11. recursive 1187 A boolean to express if an EBML Element is permitted to be stored 1188 recursively. In this case the EBML Element MAY be stored within 1189 another EBML Element that has the same Element ID. Which itself can 1190 be stored in an EBML Element that has the same Element ID, and so on. 1191 EBML Elements that are not Master Elements MUST NOT set recursive to 1192 true. 1194 If the path contains an EBMLPathAtomRecursive part then the recursive 1195 value MUST be true and false otherwise. 1197 An EBML Element with the recursive attribute set to 1 MUST NOT have 1198 its unknownsizeallowed attribute set to 1. 1200 The recursive attribute is OPTIONAL. If the recursive attribute is 1201 not present then the EBML Element MUST NOT be used recursively. 1203 11.1.5.12. recurring 1205 A boolean to express if an EBML Element is defined as an Identically 1206 Recurring Element or not. 1208 The recurring attribute is OPTIONAL. If the recurring attribute is 1209 not present then the EBML Element is not an Identically Recurring 1210 Element. 1212 11.1.5.13. minver 1214 The minver (minimum version) attribute stores a non-negative integer 1215 that represents the first version of the docType to support the EBML 1216 Element. 1218 The minver attribute is OPTIONAL. If the minver attribute is not 1219 present, then the EBML Element has a minimum version of "1". 1221 11.1.5.14. maxver 1223 The maxver (maximum version) attribute stores a non-negative integer 1224 that represents the last or most recent version of the docType to 1225 support the element. maxver MUST be greater than or equal to minver. 1227 The maxver attribute is OPTIONAL. If the maxver attribute is not 1228 present then the EBML Element has a maximum version equal to the 1229 value stored in the version attribute of "". 1231 11.1.6. Element 1233 The "" element provides additional information about 1234 the EBML Element. Within the "" element the following 1235 XHTML [W3C.SPSD-xhtml-basic-20180327] elements MAY be used: "", 1236 "
", "". 1238 11.1.7. Attributes 1240 11.1.7.1. lang 1242 A lang attribute which is set to the [RFC5646] value of the language 1243 of the element's documentation. 1245 The lang attribute is OPTIONAL. 1247 11.1.7.2. purpose 1249 A purpose attribute distinguishes the meaning of the documentation. 1250 Values for the "" sub-element's purpose attribute MUST 1251 include one of the following: "definition", "rationale", "usage 1252 notes", and "references". 1254 The purpose attribute is REQUIRED. 1256 11.1.8. Element 1258 In some cases within an EBML Document Type, the attributes of the 1259 "" element are not sufficient to clearly communicate how the 1260 defined EBML Element is intended to be implemented. For instance, 1261 one EBML Element might only be mandatory if another EBML Element is 1262 present, or as another example, the default value of an EBML Element 1263 might derive from a related Element's content. In these cases where 1264 the Element's definition is conditional or advanced implementation 1265 notes are needed, one or many "" elements can be 1266 used to store that information. The "" refer to 1267 a specific attribute of the parent "" as expressed by the 1268 "note_attribute" attribute Section 11.1.9.1. 1270 11.1.9. Attributes 1272 11.1.9.1. note_attribute 1274 The note_attribute attribute references which of the ""'s 1275 attributes that the implementation_note is in regards to. The 1276 note_attribute attribute MUST be set to one of the following values 1277 (corresponding to that attribute of the parent ""): 1278 "minOccurs", "maxOccurs", "range", "length", "default", "minver", or 1279 "maxver". The "" SHALL supersede the parent 1280 ""'s attribute that is named in the "note_attribute" 1281 attribute. An "" SHALL NOT have more than one 1282 "" of the same "note_attribute". 1284 The note_attribute attribute is REQUIRED. 1286 11.1.10. Element 1288 The "" element provides information about restrictions 1289 to the allowable values for the EBML Element which are listed in 1290 "" elements. 1292 11.1.11. Element 1294 The "" element stores a list of values allowed for storage in 1295 the EBML Element. The values MUST match the type of the EBML Element 1296 (for example "" cannot be a valid value for a EBML 1297 Element that is defined as an unsigned integer). An "" element 1298 MAY also store "" elements to further describe the 1299 "". 1301 11.1.12. Attributes 1303 11.1.12.1. label 1305 The label provides a concise expression for human consumption that 1306 describes what the value of the "" represents. 1308 The label attribute is OPTIONAL. 1310 11.1.12.2. value 1312 The value represents data that MAY be stored within the EBML Element. 1314 The value attribute is REQUIRED. 1316 11.1.13. Element 1318 The "" element provides an unconstrained element to 1319 contain information about the associated EBML "" which is 1320 undefined by this document but MAY be defined by the associated EBML 1321 Document Type. The "" element MUST contain a "type" 1322 attribute and also MAY contain any other attribute or sub-element as 1323 long as the EBML Schema remains as a well-formed XML Document. All 1324 "" elements MUST be sub-elements of the "". 1326 11.1.14. Attributes 1328 11.1.14.1. type 1330 The type attribute should reference a name or identifier of the 1331 project or authority associated with the contents of the 1332 "" element. 1334 The type attribute is REQUIRED. 1336 11.1.15. XML Schema for EBML Schema 1338 This following provides an XML Schema [W3C.REC-xmlschema-0-20041028] 1339 for facilitating verification of an EBML Schema to the definition 1340 described in Section 8.1. 1342 1344 11.1.16. Identically Recurring Elements 1346 An Identically Recurring Element is an EBML Element that MAY occur 1347 within its Parent Element more than once but that each recurrence 1348 within that Parent Element MUST be identical both in storage and 1349 semantics. Identically Recurring Elements are permitted to be stored 1350 multiple times within the same Parent Element in order to increase 1351 data resilience and optimize the use of EBML in transmission. For 1352 instance a pertinent Top-Level Element could be periodically resent 1353 within a data stream so that an EBML Reader which starts reading the 1354 stream from the middle could better interpret the contents. 1355 Identically Recurring Elements SHOULD include a CRC-32 Element as a 1356 Child Element; this is especially recommended when EBML is used for 1357 long-term storage or transmission. If a Parent Element contains more 1358 than one copy of an Identically Recurring Element which includes a 1359 CRC-32 Element as a Child Element then the first instance of the 1360 Identically Recurring Element with a valid CRC-32 value should be 1361 used for interpretation. If a Parent Element contains more than one 1362 copy of an Identically Recurring Element which does not contain a 1363 CRC-32 Element or if CRC-32 Elements are present but none are valid 1364 then the first instance of the Identically Recurring Element should 1365 be used for interpretation. 1367 11.1.17. Textual expression of floats 1369 When a float value is represented textually in an EBML Schema, such 1370 as within a default or range value, the float values MUST be 1371 expressed as Hexadecimal Floating-Point Constants as defined in the 1372 C11 standard [ISO.9899.2011] (see section 6.4.4.2 on Floating 1373 Constants). The following table provides examples of expressions of 1374 float ranges. 1376 +-------------------+-----------------------------------------+ 1377 | as decimal | as Hexadecimal Floating-Point Constants | 1378 +===================+=========================================+ 1379 | 0.0 | "0x0p+1" | 1380 +-------------------+-----------------------------------------+ 1381 | 0.0-1.0 | "0x0p+1-0x1p+0" | 1382 +-------------------+-----------------------------------------+ 1383 | 1.0-256.0 | "0x1p+0-0x1p+8" | 1384 +-------------------+-----------------------------------------+ 1385 | 0.857421875 | "0x1.b7p-1" | 1386 +-------------------+-----------------------------------------+ 1387 | -1.0--0.857421875 | "-0x1p+0--0x1.b7p-1" | 1388 +-------------------+-----------------------------------------+ 1390 Table 8 1392 Within an expression of a float range, as in an integer range, the - 1393 (hyphen) character is the separator between the minimal and maximum 1394 value permitted by the range. Hexadecimal Floating-Point Constants 1395 also use a - (hyphen) when indicating a negative binary power. 1396 Within a float range, when a - (hyphen) is immediately preceded by a 1397 letter p, then the - (hyphen) is a part of the Hexadecimal Floating- 1398 Point Constant which notes negative binary power. Within a float 1399 range, when a - (hyphen) is not immediately preceded by a letter p, 1400 then the - (hyphen) represents the separator between the minimal and 1401 maximum value permitted by the range. 1403 11.1.18. Note on the use of default attributes to define Mandatory EBML 1404 Elements 1406 If a Mandatory EBML Element has a default value declared by an EBML 1407 Schema and the value of the EBML Element is equal to the declared 1408 default value then that EBML Element is not required to be present 1409 within the EBML Document if its Parent Element is present. In this 1410 case, the default value of the Mandatory EBML Element MUST be read by 1411 the EBML Reader although the EBML Element is not present within its 1412 Parent Element. 1414 If a Mandatory EBML Element has no default value declared by an EBML 1415 Schema and its Parent Element is present then the EBML Element MUST 1416 be present as well. If a Mandatory EBML Element has a default value 1417 declared by an EBML Schema and its Parent Element is present and the 1418 value of the EBML Element is NOT equal to the declared default value 1419 then the EBML Element MUST be present. 1421 This table clarifies if a Mandatory EBML Element MUST be written, 1422 according to if the default value is declared, if the value of the 1423 EBML Element is equal to the declared default value, and if the 1424 Parent Element is used. 1426 +-----------------+-------------+---------------+------------------+ 1427 | Is the default | Is the | Is the Parent | Then is storing | 1428 | value declared? | value equal | Element | the EBML Element | 1429 | | to default? | present? | REQUIRED? | 1430 +=================+=============+===============+==================+ 1431 | Yes | Yes | Yes | No | 1432 +-----------------+-------------+---------------+------------------+ 1433 | Yes | Yes | No | No | 1434 +-----------------+-------------+---------------+------------------+ 1435 | Yes | No | Yes | Yes | 1436 +-----------------+-------------+---------------+------------------+ 1437 | Yes | No | No | No | 1438 +-----------------+-------------+---------------+------------------+ 1439 | No | n/a | Yes | Yes | 1440 +-----------------+-------------+---------------+------------------+ 1441 | No | n/a | No | No | 1442 +-----------------+-------------+---------------+------------------+ 1444 Table 9 1446 11.2. EBML Header Elements 1448 This document contains definitions of all EBML Elements of the EBML 1449 Header. 1451 11.2.1. EBML Element 1453 name: EBML 1455 path: "1*1(\EBML)" 1457 id: 0x1A45DFA3 1459 minOccurs: 1 1461 maxOccurs: 1 1462 type: Master Element 1464 description: Set the EBML characteristics of the data to follow. 1465 Each EBML Document has to start with this. 1467 11.2.2. EBMLVersion Element 1469 name: EBMLVersion 1471 path: "1*1(\EBML\EBMLVersion)" 1473 id 0x4286 1475 minOccurs: 1 1477 maxOccurs: 1 1479 range: not 0 1481 default: 1 1483 type: Unsigned Integer 1485 description: The version of EBML specifications used to create the 1486 EBML Document. The version of EBML defined in this document is 1, so 1487 EBMLVersion SHOULD be 1. 1489 11.2.3. EBMLReadVersion Element 1491 name: EBMLReadVersion 1493 path: "1*1(\EBML\EBMLReadVersion)" 1495 id: 0x42F7 1497 minOccurs: 1 1499 maxOccurs: 1 1501 range: 1 1503 default: 1 1505 type: Unsigned Integer 1507 description: The minimum EBML version an EBML Reader has to support 1508 to read this EBML Document. The EBMLReadVersion Element MUST be less 1509 than or equal to EBMLVersion. 1511 11.2.4. EBMLMaxIDLength Element 1513 name: EBMLMaxIDLength 1515 path: "1*1(\EBML\EBMLMaxIDLength)" 1517 id 0x42F2 1519 minOccurs: 1 1521 maxOccurs: 1 1523 range: >=4 1525 default: 4 1527 type: Unsigned Integer 1529 description: The EBMLMaxIDLength Element stores the maximum permitted 1530 length in octets of the Element IDs to be found within the EBML Body. 1531 An EBMLMaxIDLength Element value of four is RECOMMENDED, though 1532 larger values are allowed. 1534 11.2.5. EBMLMaxSizeLength Element 1536 name: EBMLMaxSizeLength 1538 path: "1*1(\EBML\EBMLMaxSizeLength)" 1540 id 0x42F3 1542 minOccurs: 1 1544 maxOccurs: 1 1546 range: not 0 1548 default: 8 1550 type: Unsigned Integer 1552 description: The EBMLMaxSizeLength Element stores the maximum 1553 permitted length in octets of the expressions of all Element Data 1554 Sizes to be found within the EBML Body. The EBMLMaxSizeLength 1555 Element documents an upper bound for the "length" of all Element Data 1556 Size expressions within the EBML Body and not an upper bound for the 1557 "value" of all Element Data Size expressions within the EBML Body. 1558 EBML Elements that have an Element Data Size expression which is 1559 larger in octets than what is expressed by EBMLMaxSizeLength Element 1560 are invalid. 1562 11.2.6. DocType Element 1564 name: DocType 1566 path: "1*1(\EBML\DocType)" 1568 id 0x4282 1570 minOccurs: 1 1572 maxOccurs: 1 1574 length: >0 1576 type: String 1578 description: A string that describes and identifies the content of 1579 the EBML Body that follows this EBML Header. 1581 11.2.7. DocTypeVersion Element 1583 name: DocTypeVersion 1585 path: "1*1(\EBML\DocTypeVersion)" 1587 id 0x4287 1589 minOccurs: 1 1591 maxOccurs: 1 1593 range: not 0 1595 default: 1 1597 type: Unsigned Integer 1599 description: The version of DocType interpreter used to create the 1600 EBML Document. 1602 11.2.8. DocTypeReadVersion Element 1604 name: DocTypeReadVersion 1606 path: "1*1(\EBML\DocTypeReadVersion)" 1607 id 0x4285 1609 minOccurs: 1 1611 maxOccurs: 1 1613 range: not 0 1615 default: 1 1617 type: Unsigned Integer 1619 description: The minimum DocType version an EBML Reader has to 1620 support to read this EBML Document. The value of the 1621 DocTypeReadVersion Element MUST be less than or equal to the value of 1622 the DocTypeVersion Element. 1624 11.2.9. DocTypeExtension Element 1626 name: DocTypeExtension 1628 path: "0*(\EBML\DocTypeExtension)" 1630 id 0x4281 1632 minOccurs: 0 1634 type: Master Element 1636 description: A DocTypeExtension adds extra Elements to the main 1637 DocType+DocTypeVersion tuple it's attached to. An EBML Reader MAY 1638 know these extra Elements and how to use them. A DocTypeExtension 1639 MAY be used to iterate between experimental Elements before they are 1640 integrated in a regular DocTypeVersion. Reading one DocTypeExtension 1641 version of a DocType+DocTypeVersion tuple doesn't imply one should be 1642 able to read upper versions of this DocTypeExtension. 1644 11.2.10. DocTypeExtensionName Element 1646 name: DocTypeExtensionName 1648 path: "1*1(\EBML\DocTypeExtension\Name)" 1650 id 0x4283 1652 minOccurs: 1 1654 maxOccurs: 1 1655 length: >0 1657 type: String 1659 description: The name of the DocTypeExtension to differentiate it 1660 from other DocTypeExtension of the same DocType+DocTypeVersion tuple. 1661 A DocTypeExtensionName value MUST be unique within the EBML Header. 1663 11.2.11. DocTypeExtensionVersion Element 1665 name: DocTypeExtensionVersion 1667 path: "1*1(\EBML\DocTypeExtension\Version)" 1669 id 0x4284 1671 minOccurs: 1 1673 maxOccurs: 1 1675 range: not 0 1677 type: Unsigned Integer 1679 description: The version of the DocTypeExtension. Different 1680 DocTypeExtensionVersion values of the same 1681 DocType+DocTypeVersion+DocTypeExtensionName tuple MAY contain 1682 completely different sets of extra Elements. An EBML Reader MAY 1683 support multiple versions of the same DocTypeExtension, only one or 1684 none. 1686 11.3. Global Elements 1688 EBML allows some special Elements to be found within more than one 1689 parent in an EBML Document or optionally at the Root Level of an EBML 1690 Body. These Elements are called Global Elements. There are 2 Global 1691 Elements that can be found in any EBML Document: the CRC-32 Element 1692 and the Void Element. An EBML Schema MAY add other Global Elements 1693 to the format it defines. These extra elements apply only to the 1694 EBML Body, not the EBML Header. 1696 Global Elements are EBML Elements whose path have a EBMLGlobalParent 1697 as their EBMLLastParent. Because it is the last Parent part of the 1698 path, a Global Element might also have non-EBMLGlobalParent parts in 1699 its path. In this case the Global Element can only be found within 1700 this non-EBMLGlobalParent path, i.e. it's not fully "global". 1702 The EBMLEltOccurrence of a Global Element is the number of 1703 occurrences the Element can be found in a Parent Element. But the 1704 Global Element can be found in many Parent Elements, allowing the 1705 same number of occurrences in each Parent where this Element is 1706 found. 1708 11.3.1. CRC-32 Element 1710 name: CRC-32 1712 path: "*1((1*\)\CRC-32)" 1714 id: 0xBF 1716 minOccurs: 0 1718 maxOccurs: 1 1720 length: 4 1722 type: Binary 1724 description: The CRC-32 Element contains a 32-bit Cyclic Redundancy 1725 Check value of all the Element Data of the Parent Element as stored 1726 except for the CRC-32 Element itself. When the CRC-32 Element is 1727 present, the CRC-32 Element MUST be the first ordered EBML Element 1728 within its Parent Element for easier reading. All Top-Level Elements 1729 of an EBML Document that are Master Elements SHOULD include a CRC-32 1730 Element as a Child Element. The CRC in use is the IEEE-CRC-32 1731 algorithm as used in the [ISO.3309.1979] standard and in section 1732 8.1.1.6.2 of [ITU.V42.1994], with initial value of 0xFFFFFFFF. The 1733 CRC value MUST be computed on a little endian bitstream and MUST use 1734 little endian storage. 1736 11.3.2. Void Element 1738 name: Void 1740 path: "*((*\)\Void)" 1742 id: 0xEC 1744 minOccurs: 0 1746 type: Binary 1748 description: Used to void data or to avoid unexpected behaviors when 1749 using damaged data. The content is discarded. Also used to reserve 1750 space in a sub-element for later use. 1752 12. Considerations for Reading EBML Data 1754 The following scenarios describe events to consider when reading EBML 1755 Documents and the recommended design of an EBML Reader. 1757 If a Master Element contains a CRC-32 Element that doesn't validate, 1758 then the EBML Reader MAY ignore all contained data except for 1759 Descendant Elements that contain their own valid CRC-32 Element. 1761 If a Master Element contains more occurrences of a Child Master 1762 Element than permitted according to the maxOccurs and recurring 1763 attributes of the definition of that Element then the occurrences in 1764 addition to maxOccurs MAY be ignored. 1766 If a Master Element contains more occurrences of a Child Element than 1767 permitted according to the maxOccurs attribute of the definition of 1768 that Element then all instances of that Element after the first 1769 maxOccur occurrences from the beginning of its Parent Element SHOULD 1770 be ignored. 1772 13. Terminating Elements 1774 Null Octets, which are octets with all bits set to zero, MAY follow 1775 the value of a String Element or UTF-8 Element to serve as a 1776 terminator. An EBML Writer MAY terminate a String Element or UTF-8 1777 Element with Null Octets in order to overwrite a stored value with a 1778 new value of lesser length while maintaining the same Element Data 1779 Size (this can prevent the need to rewrite large portions of an EBML 1780 Document); otherwise the use of Null Octets within a String Element 1781 or UTF-8 Element is NOT RECOMMENDED. An EBML Reader MUST consider 1782 the value of the String Element or UTF-8 Element to be terminated 1783 upon the first read Null Octet and MUST ignore any data following the 1784 first Null Octet within that Element. A string value and a copy of 1785 that string value terminated by one or more Null Octets are 1786 semantically equal. 1788 The following table shows examples of semantics and validation for 1789 the use of Null Octets. Values to represent Stored Values and the 1790 Semantic Meaning as represented as hexadecimal values. 1792 +---------------------+---------------------+ 1793 | Stored Value | Semantic Meaning | 1794 +=====================+=====================+ 1795 | 0x65 0x62 0x6D 0x6C | 0x65 0x62 0x6D 0x6C | 1796 +---------------------+---------------------+ 1797 | 0x65 0x62 0x00 0x6C | 0x65 0x62 | 1798 +---------------------+---------------------+ 1799 | 0x65 0x62 0x00 0x00 | 0x65 0x62 | 1800 +---------------------+---------------------+ 1801 | 0x65 0x62 | 0x65 0x62 | 1802 +---------------------+---------------------+ 1804 Table 10 1806 14. Guidelines for Updating Elements 1808 An EBML Document can be updated without requiring that the entire 1809 EBML Document be rewritten. These recommendations describe 1810 strategies to change the Element Data of a written EBML Element with 1811 minimal disruption to the rest of the EBML Document. 1813 14.1. Reducing a Element Data in Size 1815 There are three methods to reduce the size of Element Data of a 1816 written EBML Element. 1818 14.1.1. Adding a Void Element 1820 When an EBML Element is changed to reduce its total length by more 1821 than one octet, an EBML Writer SHOULD fill the freed space with a 1822 Void Element. 1824 14.1.2. Extending the Element Data Size 1826 The same value for Element Data Size MAY be written in variable 1827 lengths, so for minor reductions in octet length the Element Data 1828 Size MAY be written to a longer octet length to fill the freed space. 1830 For example, the first row of the following table depicts a String 1831 Element that stores an Element ID (3 octets), Element Data Size (1 1832 octet), and Element Data (4 octets). If the Element Data is changed 1833 to reduce the length by one octet and if the current length of the 1834 Element Data Size is less than its maximum permitted length, then the 1835 Element Data Size of that Element MAY be rewritten to increase its 1836 length by one octet. Thus before and after the change the EBML 1837 Element maintains the same length of 8 octets and data around the 1838 Element does not need to be moved. 1840 +-------------+------------+-------------------+--------------+ 1841 | Status | Element ID | Element Data Size | Element Data | 1842 +=============+============+===================+==============+ 1843 | Before edit | 0x3B4040 | 0x84 | 0x65626D6C | 1844 +-------------+------------+-------------------+--------------+ 1845 | After edit | 0x3B4040 | 0x4003 | 0x6D6B76 | 1846 +-------------+------------+-------------------+--------------+ 1848 Table 11 1850 This method is RECOMMENDED when the Element Data is reduced by a 1851 single octet; for reductions by two or more octets it is RECOMMENDED 1852 to fill the freed space with a Void Element. 1854 Note that if the Element Data length needs to be rewritten as 1855 shortened by one octet and the Element Data Size could be rewritten 1856 as a shorter VINT then it is RECOMMENDED to rewrite the Element Data 1857 Size as one octet shorter, shorten the Element Data by one octet, and 1858 follow that Element with a Void Element. For example, the following 1859 table depicts a String Element that stores an Element ID (3 octets), 1860 Element Data Size (2 octets, but could be rewritten in one octet), 1861 and Element Data (3 octets). If the Element Data is to be rewritten 1862 to a two octet length, then another octet can be taken from Element 1863 Data Size so that there is enough space to add a two octet Void 1864 Element. 1866 +--------+------------+-------------------+--------------+---------+ 1867 | Status | Element ID | Element Data Size | Element Data | Void | 1868 | | | | | Element | 1869 +========+============+===================+==============+=========+ 1870 | Before | 0x3B4040 | 0x4003 | 0x6D6B76 | | 1871 +--------+------------+-------------------+--------------+---------+ 1872 | After | 0x3B4040 | 0x82 | 0x6869 | 0xEC80 | 1873 +--------+------------+-------------------+--------------+---------+ 1875 Table 12 1877 14.1.3. Terminating Element Data 1879 For String Elements and UTF-8 Elements the length of Element Data MAY 1880 be reduced by adding Null Octets to terminate the Element Data (see 1881 the section on Terminating Elements (#terminating-elements)). 1883 In the following table, a four octets long Element Data is changed to 1884 a three octet long value followed by a Null Octet; the Element Data 1885 Size includes any Null Octets used to terminate Element Data so 1886 remains unchanged. 1888 +-------------+------------+-------------------+--------------+ 1889 | Status | Element ID | Element Data Size | Element Data | 1890 +=============+============+===================+==============+ 1891 | Before edit | 0x3B4040 | 0x84 | 0x65626D6C | 1892 +-------------+------------+-------------------+--------------+ 1893 | After edit | 0x3B4040 | 0x84 | 0x6D6B7600 | 1894 +-------------+------------+-------------------+--------------+ 1896 Table 13 1898 Note that this method is NOT RECOMMENDED. For reductions of one 1899 octet, the method for Extending the Element Data Size SHOULD be used. 1900 For reduction by more than one octet, the method for Adding a Void 1901 Element SHOULD be used. 1903 14.2. Considerations when Updating Elements with Cyclic Redundancy 1904 Check (CRC) 1906 If the Element to be changed is a Descendant Element of any Master 1907 Element that contains a CRC-32 Element (see Section 11.3.1) then the 1908 CRC-32 Element MUST be verified before permitting the change. 1909 Additionally the CRC-32 Element value MUST be subsequently updated to 1910 reflect the changed data. 1912 15. Backward and Forward Compatibility 1914 Elements of an EBML format SHOULD be designed with backward and 1915 forward compatibility in mind. 1917 15.1. Backward Compatibility 1919 Backward compatibility of new EBML Elements can be achieved by using 1920 default values for mandatory elements. The default value MUST 1921 represent the state that was assumed for previous versions of the 1922 EBML Schema, without this new EBML Element. If such a state doesn't 1923 make sense for previous versions, then the new EBML Element SHOULD 1924 NOT be mandatory. 1926 Non mandatory EBML Elements can be added in a new EBMLDocTypeVersion. 1927 Since they are not mandatory they won't be found in older versions of 1928 the EBMLDocTypeVersion, just as they might not be found in newer 1929 versions. This causes no compatibility issue. 1931 15.2. Forward Compatibility 1933 EBML Elements MAY be marked as deprecated in a new EBMLDocTypeVersion 1934 using the maxver attribute of the EBML Schema. If such an Element is 1935 found in an EBML Document with newer version of the 1936 EBMLDocTypeVersion it SHOULD be discarded. 1938 16. Security Considerations 1940 EBML itself does not offer any kind of security and does not provide 1941 confidentiality. EBML does not provide any kind of authorization. 1942 EBML only offers marginally useful and effective data integrity 1943 options, such as CRC elements. 1945 Even if the semantic layer offers any kind of encryption, EBML itself 1946 could leak information at both the semantic layer (as declared via 1947 the DocType Element) and within the EBML structure (the presence of 1948 EBML Elements can be derived even with an unknown semantic layer 1949 using a heuristic approach; not without errors, of course, but with a 1950 certain degree of confidence). 1952 An EBML Document that has the following issues may still be handled 1953 by the EBML Reader and the data accepted as such, depending on how 1954 strict the EBML Reader wants to be: 1956 * Invalid Element IDs that are longer than the limit stated in the 1957 EBMLMaxIDLength Element of the EBML Header. 1959 * Invalid Element IDs that are not encoded in the shortest-possible 1960 way. 1962 * Invalid Element Data Size values that are longer than the limit 1963 stated in the EBMLMaxSizeLength Element of the EBML Header. 1965 Element IDs that are unknown to the EBML Reader MAY be accepted as 1966 valid EBML IDs in order to skip such elements. 1968 EBML Elements with a string type may contain extra data after the 1969 first 0x00. These data MUST be discarded according to the Section 13 1970 rules. 1972 An EBML Reader may discard some or all data if the following errors 1973 are found in the EBML Document: 1975 * Invalid Element Data Size values (e.g. extending the length of the 1976 EBML Element beyond the scope of the Parent Element; possibly 1977 triggering access-out-of-bounds issues). 1979 * Very high lengths in order to force out-of-memory situations 1980 resulting in a denial of service, access-out-of-bounds issues etc. 1982 * Missing EBML Elements that are mandatory in a Master Element and 1983 have no declared default value, making the semantic invalid at 1984 that Master Element level. 1986 * Usage of invalid UTF-8 encoding in EBML Elements of UTF-8 type 1987 (e.g. in order to trigger access-out-of-bounds or buffer overflow 1988 issues). 1990 * Usage of invalid data in EBML Elements with a date type, 1991 triggering bogus date accesses. 1993 Side channel attacks could exploit: 1995 * The semantic equivalence of the same string stored in a String 1996 Element or UTF-8 Element with and without zero-bit padding, making 1997 comparison at the semantic level invalid. 1999 * The semantic equivalence of VINT_DATA within Element Data Size 2000 with two different lengths due to left-padding zero bits, making 2001 comparison at the semantic level invalid. 2003 * Data contained within a Master Element which is not itself part of 2004 a Child Element can trigger incorrect parsing behavior in EBML 2005 Readers. 2007 * Extraneous copies of Identically Recurring Element, making parsing 2008 unnecessarily slow to the point of not being usable. 2010 * Copies of Identically Recurring Element within a Parent Element 2011 that contain invalid CRC-32 Elements. EBML Readers not checking 2012 the CRC-32 might use the version of the element with mismatching 2013 CRC-32. 2015 * Use of Void Elements which could be used to hide content or create 2016 bogus resynchronization points seen by some EBML Reader and not 2017 others. 2019 17. IANA Considerations 2021 17.1. CELLAR EBML Element ID Registry 2023 This document creates a new IANA Registry called "CELLAR EBML Element 2024 ID Registry". 2026 Element IDs are described in section Element ID. Element IDs are 2027 encoded using the VINT mechanism described in section Section 4 can 2028 be between one and five octets long. Five octet long Element IDs are 2029 possible only if declared in the header. 2031 This IANA Registry only applies to Elements that can be contained in 2032 the EBML Header, thus including Global Elements (#global-elements). 2033 Elements only found in the EBML Body have their own set of 2034 independent Element IDs and are not part of this IANA Registry. 2036 The VINT Data value of one-octet Element IDs MUST be between 0x01 and 2037 0x7E. These items are valuable because they are short, and need to 2038 be used for commonly repeated elements. Values from 1 to 126 are to 2039 be allocated according to the "RFC Required" policy [RFC8126]. 2041 The VINT Data value of two-octet Element IDs MUST be between 0x007F 2042 and 0x3FFE. Numbers are to be allocated within this range according 2043 to the "Specification Required" policy [RFC8126]. 2045 The numbers 0x3FFF and 0x4000 are RESERVED. 2047 The VINT Data value of three-octet Element IDs MUST be between 0x4001 2048 and 0x1FFFFE. Numbers may be allocated within this range according 2049 to the "First Come First Served" policy [RFC8126]. 2051 The numbers 0x1FFFFF and 0x200000 are RESERVED. 2053 Four-octet Element IDs are numbers between 0x101FFFFF and 0x1FFFFFFE. 2054 Four-octet Element IDs are somewhat special in that they are useful 2055 for resynchronizing to major structures in the event of data 2056 corruption or loss. As such four-octet Element IDs are split into 2057 two categories. Four-octet Element IDs whose lower three octets (as 2058 encoded) would make printable 7-bit ASCII values (0x20 to 0x7E, 2059 inclusive) MUST be allocated by the "Specification Required" policy. 2060 Sequential allocation of values is not required: specifications 2061 SHOULD include a specific request, and are encouraged to do early 2062 allocations. 2064 To be clear about the above category: four-octet Element IDs always 2065 start with hex 0x10 to 0x1F, and that octet may be chosen so that the 2066 entire number has some desirable property, such as a specific CRC. 2067 The other three octets, when ALL having values between 0x21 (33, 2068 ASCII !) and 0x7E (126, ASCII ~), fall into this category. 2070 Other four-octet Element IDs may be allocated by the "First Come 2071 First Served" policy. 2073 The numbers 0xFFFFFFF and 0x1000000 are RESERVED. 2075 Five octet Element IDs (values from 0x10000001 upwards) are RESERVED 2076 according to the "Experimental Use" policy [RFC8126]: they may be 2077 used by anyone at any time, but there is no coordination. 2079 ID Values found in this document are assigned as initial values as 2080 follows: 2082 +------------+-------------------------+-----------------+ 2083 | ID | Element Name | Reference | 2084 +============+=========================+=================+ 2085 | 0x1A45DFA3 | EBML | Described in | 2086 | | | Section 11.2.1 | 2087 +------------+-------------------------+-----------------+ 2088 | 0x4286 | EBMLVersion | Described in | 2089 | | | Section 11.2.2 | 2090 +------------+-------------------------+-----------------+ 2091 | 0x42F7 | EBMLReadVersion | Described in | 2092 | | | Section 11.2.3 | 2093 +------------+-------------------------+-----------------+ 2094 | 0x42F2 | EBMLMaxIDLength | Described in | 2095 | | | Section 11.2.4 | 2096 +------------+-------------------------+-----------------+ 2097 | 0x42F3 | EBMLMaxSizeLength | Described in | 2098 | | | Section 11.2.5 | 2099 +------------+-------------------------+-----------------+ 2100 | 0x4282 | DocType | Described in | 2101 | | | Section 11.2.6 | 2102 +------------+-------------------------+-----------------+ 2103 | 0x4287 | DocTypeVersion | Described in | 2104 | | | Section 11.2.7 | 2105 +------------+-------------------------+-----------------+ 2106 | 0x4285 | DocTypeReadVersion | Described in | 2107 | | | Section 11.2.8 | 2108 +------------+-------------------------+-----------------+ 2109 | 0x4281 | DocTypeExtension | Described in | 2110 | | | Section 11.2.9 | 2111 +------------+-------------------------+-----------------+ 2112 | 0x4283 | DocTypeExtensionName | Described in | 2113 | | | Section 11.2.10 | 2114 +------------+-------------------------+-----------------+ 2115 | 0x4284 | DocTypeExtensionVersion | Described in | 2116 | | | Section 11.2.11 | 2117 +------------+-------------------------+-----------------+ 2118 | 0xBF | CRC-32 | Described in | 2119 | | | Section 11.3.1 | 2120 +------------+-------------------------+-----------------+ 2121 | 0xEC | Void | Described in | 2122 | | | Section 11.3.2 | 2123 +------------+-------------------------+-----------------+ 2125 Table 14 2127 17.2. CELLAR EBML DocType Registry 2129 This document creates a new IANA Registry called "CELLAR EBML DocType 2130 Registry". 2132 To register a new DocType in this registry one needs a DocType name, 2133 a Description of the DocType, a Change Controller (IESG or email of 2134 registrant) and an optional Reference to a document describing the 2135 DocType. 2137 DocType values are described in this section (#doctype). DocTypes 2138 are ASCII strings, defined in the String Element section (#string- 2139 element), which label the official name of the EBML Document Type. 2140 The strings may be allocated according to the "First Come First 2141 Served" policy. 2143 The use of ASCII corresponds to the types and code already in use, 2144 the value is not meant to be visible to the user. 2146 DocType string values of "matroska" and "webm" are RESERVED to the 2147 IETF for future use. These can be assigned via the "IESG Approval" 2148 or "RFC Required" policies [RFC8126]. 2150 18. Normative References 2152 [IEEE.754.1985] 2153 Institute of Electrical and Electronics Engineers, 2154 "Standard for Binary Floating-Point Arithmetic", August 2155 1985. 2157 [ISO.3309.1979] 2158 International Organization for Standardization, "Data 2159 communication - High-level data link control procedures - 2160 Frame structure", 1979. 2162 [ISO.9899.2011] 2163 International Organization for Standardization, 2164 "Programming languages - C", 2011. 2166 [ITU.V42.1994] 2167 International Telecommunications Union, "Error-correcting 2168 Procedures for DCEs Using Asynchronous-to-Synchronous 2169 Conversion", 1994. 2171 [RFC0020] Cerf, V., "ASCII format for network interchange", STD 80, 2172 RFC 20, DOI 10.17487/RFC0020, October 1969, 2173 . 2175 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2176 Requirement Levels", BCP 14, RFC 2119, 2177 DOI 10.17487/RFC2119, March 1997, 2178 . 2180 [RFC3339] Klyne, G. and C. Newman, "Date and Time on the Internet: 2181 Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002, 2182 . 2184 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 2185 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 2186 2003, . 2188 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 2189 Specifications: ABNF", STD 68, RFC 5234, 2190 DOI 10.17487/RFC5234, January 2008, 2191 . 2193 [RFC5646] Phillips, A., Ed. and M. Davis, Ed., "Tags for Identifying 2194 Languages", BCP 47, RFC 5646, DOI 10.17487/RFC5646, 2195 September 2009, . 2197 [RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", 2198 RFC 7405, DOI 10.17487/RFC7405, December 2014, 2199 . 2201 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 2202 Writing an IANA Considerations Section in RFCs", BCP 26, 2203 RFC 8126, DOI 10.17487/RFC8126, June 2017, 2204 . 2206 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2207 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2208 May 2017, . 2210 [W3C.REC-xml-20081126] 2211 Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and 2212 F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth 2213 Edition)", World Wide Web Consortium Recommendation REC- 2214 xml-20081126, 26 November 2008, 2215 . 2217 [W3C.SPSD-xhtml-basic-20180327] 2218 McCarron, S., "XHTML(tm) Basic 1.1 - Second Edition", 27 2219 March 2018. 2221 19. Informative References 2223 [W3C.REC-xmlschema-0-20041028] 2224 Fallside, D. and P. Walmsley, "XML Schema Part 0: Primer 2225 Second Edition", World Wide Web Consortium Recommendation 2226 REC-xmlschema-0-20041028, 28 October 2004, 2227 . 2229 Authors' Addresses 2231 Steve Lhomme 2233 Email: slhomme@matroska.org 2235 Dave Rice 2237 Email: dave@dericed.com 2239 Moritz Bunkus 2241 Email: moritz@bunkus.org