aboutsummaryrefslogtreecommitdiff
path: root/matroska/src/matroska.rs
blob: 50e12b91c4bcb94010e066f3888b695e443b3ac1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2025 metamuffin <metamuffin.org>
*/
use ebml_derive::define_ebml;

define_ebml! {
    global Crc32[0xbf]: Binary,
    global Void[0xec]: Binary,

    Ebml[0x1a45dfa3]: {
        EbmlVersion[0x4286]: Uint,
        EbmlReadVersion[0x42f7]: Uint,
        EbmlMaxIdLength[0x42f2]: Uint,
        EbmlMaxSizeLength[0x42f3]: Uint,
        DocType[0x4282]: Utf8,
        DocTypeVersion[0x4287]: Uint,
        DocTypeReadVersion[0x4285]: Uint,
        DocTypeExtension[0x4281]: {
            DocTypeExtensionName[0x4283]: Utf8,
            DocTypeExtensionVersion[0x4284]: Uint,
        },
    },

    Segment[0x18538067]: {
        Attachments[0x1941A469]: {
            AttachedFile[0x61A7]: {
                FileData[0x465C]: Binary,
                FileDescription[0x467E]: Utf8,
                FileMimeType[0x4660]: Utf8,
                FileName[0x466E]: Utf8,
                FileReferral[0x4675]: Binary,
                FileUID[0x46AE]: Uint,
                FileUsedEndTime[0x4662]: Uint,
                FileUsedStartTime[0x4661]: Uint,
            },
        },

        Chapters[0x1043A770]: {
            EditionEntry[0x45B9]: {
                ChapterAtom[0xB6]: {
                    ChapProcess[0x6944]: {
                        ChapProcessCodecID[0x6955]: Uint,
                        ChapProcessCommand[0x6911]: {
                            ChapProcessData[0x6933]: Binary,
                            ChapProcessTime[0x6922]: Uint,
                        },
                        ChapProcessPrivate[0x450D]: Binary,
                    },
                    ChapterDisplay[0x80]: {
                        ChapCountry[0x437E]: Utf8,
                        ChapLanguage[0x437C]: Utf8,
                        ChapLanguageIETF[0x437D]: Utf8,
                        ChapString[0x85]: Utf8,
                    },
                    ChapterFlagEnabled[0x4598]: Uint,
                    ChapterFlagHidden[0x98]: Uint,
                    ChapterPhysicalEquiv[0x63C3]: Uint,
                    ChapterSegmentEditionUID[0x6EBC]: Uint,
                    ChapterSegmentUID[0x6E67]: Binary,
                    ChapterStringUID[0x5654]: Utf8,
                    ChapterTimeEnd[0x92]: Uint,
                    ChapterTimeStart[0x91]: Uint,
                    ChapterUID[0x73C4]: Uint,
                    ChapterTrack[0x8F]: {
                        ChapterTrackUID[0x89]: Uint,
                    },
                },
                EditionFlagDefault[0x45DB]: Uint,
                EditionFlagHidden[0x45BD]: Uint,
                EditionFlagOrdered[0x45DD]: Uint,
                EditionUID[0x45BC]: Uint,
            },
        },

        Cluster[0x1F43B675]: {
            BlockGroup[0xA0]: {
                Block[0xA1]: Block,
                BlockAdditions[0x75A1]: {
                    BlockMore[0xA6]: {
                        BlockAddID[0xEE]: Uint,
                        BlockAdditional[0xA5]: Binary,
                    },
                },
                BlockDuration[0x9B]: Uint,
                BlockVirtual[0xA2]: Binary,
                CodecState[0xA4]: Binary,
                DiscardPadding[0x75A2]: Int,
                ReferenceBlock[0xFB]: Int,
                ReferenceFrame[0xC8]: {
                    ReferenceOffset[0xC9]: Uint,
                    ReferenceTimestamp[0xCA]: Uint,
                },
                ReferencePriority[0xFA]: Uint,
                ReferenceVirtual[0xFD]: Int,
                Slices[0x8E]: {
                    TimeSlice[0xE8]: {
                        BlockAdditionID[0xCB]: Uint,
                        Delay[0xCE]: Uint,
                        FrameNumber[0xCD]: Uint,
                        LaceNumber[0xCC]: Uint,
                        SliceDuration[0xCF]: Uint,
                    },
                },
            },
            EncryptedBlock[0xAF]: Binary,
            Position[0xA7]: Uint,
            PrevSize[0xAB]: Uint,
            SilentTracks[0x5854]: {
                SilentTrackNumber[0x58D7]: Uint,
            },
            SimpleBlock[0xA3]: Block,
            Timestamp[0xE7]: Uint,
        },

        Cues[0x1C53BB6B]: {
            CuePoint[0xBB]: {
                CueTime[0xB3]: Uint,
                CueTrackPositions[0xB7]: {
                    CueBlockNumber[0x5378]: Uint,
                    CueClusterPosition[0xF1]: Uint,
                    CueCodecState[0xEA]: Uint,
                    CueDuration[0xB2]: Uint,
                    CueReference[0xDB]: {
                        CueRefCluster[0x97]: Uint,
                        CueRefCodecState[0xEB]: Uint,
                        CueRefNumber[0x535F]: Uint,
                        CueRefTime[0x96]: Uint,
                    },
                    CueRelativePosition[0xF0]: Uint,
                    CueTrack[0xF7]: Uint,
                },
            },
        },

        Info[0x1549A966]: {
            ChapterTranslate[0x6924]: {
                ChapterTranslateCodec[0x69BF]: Uint,
                ChapterTranslateEditionUID[0x69FC]: Uint,
                ChapterTranslateID[0x69A5]: Binary,
            },
            DateUTC[0x4461]: Int,
            Duration[0x4489]: Float,
            MuxingApp[0x4D80]: Utf8,
            NextFilename[0x3E83BB]: Utf8,
            NextUID[0x3EB923]: Binary,
            PrevFilename[0x3C83AB]: Utf8,
            PrevUID[0x3CB923]: Binary,
            SegmentFamily[0x4444]: Binary,
            SegmentFilename[0x7384]: Utf8,
            SegmentUID[0x73A4]: Binary,
            TimestampScale[0x2AD7B1]: Uint,
            Title[0x7BA9]: Utf8,
            WritingApp[0x5741]: Utf8,
        },

        SeekHead[0x114D9B74]: {
            Seek[0x4DBB]: {
                SeekID[0x53AB]: Binary,
                SeekPosition[0x53AC]: Uint,
            },
        },

        Tags[0x1254C367]: {
            Tag[0x7373]: {
                SimpleTag[0x67C8]: {
                    TagBinary[0x4485]: Binary,
                    TagDefault[0x4484]: Uint,
                    TagDefaultBogus[0x44B4]: Uint,
                    TagLanguage[0x447A]: Utf8,
                    TagLanguageIETF[0x447B]: Utf8,
                    TagName[0x45A3]: Utf8,
                    TagString[0x4487]: Utf8,
                },
                Targets[0x63C0]: {
                    TagAttachmentUID[0x63C6]: Uint,
                    TagChapterUID[0x63C4]: Uint,
                    TagEditionUID[0x63C9]: Uint,
                    TagTrackUID[0x63C5]: Uint,
                    TargetType[0x63CA]: Utf8,
                    TargetTypeValue[0x68CA]: Uint,
                },
            },
        },

        Tracks[0x1654AE6B]: {
            TrackEntry[0xAE]: {
                AttachmentLink[0x7446]: Uint,
                Audio[0xE1]: {
                    BitDepth[0x6264]: Uint,
                    ChannelPositions[0x7D7B]: Binary,
                    Channels[0x9F]: Uint,
                    OutputSamplingFrequency[0x78B5]: Float,
                    SamplingFrequency[0xB5]: Float,
                },
                BlockAdditionMapping[0x41E4]: {
                    BlockAddIDExtraData[0x41ED]: Binary,
                    BlockAddIDName[0x41A4]: Utf8,
                    BlockAddIDType[0x41E7]: Uint,
                    BlockAddIDValue[0x41F0]: Uint,
                },
                CodecDecodeAll[0xAA]: Uint,
                CodecDelay[0x56AA]: Uint,
                CodecDownloadURL[0x26B240]: Utf8,
                CodecID[0x86]: Utf8,
                CodecInfoURL[0x3B4040]: Utf8,
                CodecName[0x258688]: Utf8,
                CodecPrivate[0x63A2]: Binary,
                CodecSettings[0x3A9697]: Utf8,
                ContentEncodings[0x6D80]: {
                    ContentEncoding[0x6240]: {
                        ContentCompression[0x5034]: {
                            ContentCompAlgo[0x4254]: Uint,
                            ContentCompSettings[0x4255]: Binary,
                        },
                        ContentEncodingOrder[0x5031]: Uint,
                        ContentEncodingScope[0x5032]: Uint,
                        ContentEncodingType[0x5033]: Uint,
                        ContentEncryption[0x5035]: {
                            ContentEncAESSettings[0x47E7]: {
                                AESSettingsCipherMode[0x47E8]: Uint,
                            },
                            ContentEncAlgo[0x47E1]: Uint,
                            ContentEncKeyID[0x47E2]: Binary,
                            ContentSigAlgo[0x47E5]: Uint,
                            ContentSigHashAlgo[0x47E6]: Uint,
                            ContentSigKeyID[0x47E4]: Binary,
                            ContentSignature[0x47E3]: Binary,
                        },
                    },
                },
                DefaultDecodedFieldDuration[0x234E7A]: Uint,
                DefaultDuration[0x23E383]: Uint,
                FlagCommentary[0x55AF]: Uint,
                FlagDefault[0x88]: Uint,
                FlagEnabled[0xB9]: Uint,
                FlagForced[0x55AA]: Uint,
                FlagHearingImpaired[0x55AB]: Uint,
                FlagLacing[0x9C]: Uint,
                FlagOriginal[0x55AE]: Uint,
                FlagTextDescriptions[0x55AD]: Uint,
                FlagVisualImpaired[0x55AC]: Uint,
                Language[0x22B59C]: Utf8,
                LanguageIETF[0x22B59D]: Utf8,
                MaxBlockAdditionID[0x55EE]: Uint,
                MaxCache[0x6DF8]: Uint,
                MinCache[0x6DE7]: Uint,
                Name[0x536E]: Utf8,
                SeekPreRoll[0x56BB]: Uint,
                TrackNumber[0xD7]: Uint,
                TrackOffset[0x537F]: Int,
                TrackOperation[0xE2]: {
                    TrackCombinePlanes[0xE3]: {
                        TrackPlane[0xE4]: {
                            TrackPlaneType[0xE6]: Uint,
                            TrackPlaneUID[0xE5]: Uint,
                        },
                    },
                    TrackJoinBlocks[0xE9]: {
                        TrackJoinUID[0xED]: Uint,
                    },
                },
                TrackOverlay[0x6FAB]: Uint,
                TrackTimestampScale[0x23314F]: Float,
                TrackTranslate[0x6624]: {
                    TrackTranslateCodec[0x66BF]: Uint,
                    TrackTranslateEditionUID[0x66FC]: Uint,
                    TrackTranslateTrackID[0x66A5]: Binary,
                },
                TrackType[0x83]: Uint,
                TrackUID[0x73C5]: Uint,
                TrickMasterTrackSegmentUID[0xC4]: Binary,
                TrickMasterTrackUID[0xC7]: Uint,
                TrickTrackFlag[0xC6]: Uint,
                TrickTrackSegmentUID[0xC1]: Binary,
                TrickTrackUID[0xC0]: Uint,
                Video[0xE0]: {
                    AlphaMode[0x53C0]: Uint,
                    AspectRatioType[0x54B3]: Uint,
                    Colour[0x55B0]: {
                        BitsPerChannel[0x55B2]: Uint,
                        CbSubsamplingHorz[0x55B5]: Uint,
                        CbSubsamplingVert[0x55B6]: Uint,
                        ChromaSitingHorz[0x55B7]: Uint,
                        ChromaSitingVert[0x55B8]: Uint,
                        ChromaSubsamplingHorz[0x55B3]: Uint,
                        ChromaSubsamplingVert[0x55B4]: Uint,
                        MasteringMetadata[0x55D0]: {
                            LuminanceMax[0x55D9]: Float,
                            LuminanceMin[0x55DA]: Float,
                            PrimaryBChromaticityX[0x55D5]: Float,
                            PrimaryBChromaticityY[0x55D6]: Float,
                            PrimaryGChromaticityX[0x55D3]: Float,
                            PrimaryGChromaticityY[0x55D4]: Float,
                            PrimaryRChromaticityX[0x55D1]: Float,
                            PrimaryRChromaticityY[0x55D2]: Float,
                            WhitePointChromaticityX[0x55D7]: Float,
                            WhitePointChromaticityY[0x55D8]: Float,
                        },
                        MatrixCoefficients[0x55B1]: Uint,
                        MaxCLL[0x55BC]: Uint,
                        MaxFALL[0x55BD]: Uint,
                        Primaries[0x55BB]: Uint,
                        Range[0x55B9]: Uint,
                        TransferCharacteristics[0x55BA]: Uint,
                    },
                    DisplayHeight[0x54BA]: Uint,
                    DisplayUnit[0x54B2]: Uint,
                    DisplayWidth[0x54B0]: Uint,
                    FieldOrder[0x9D]: Uint,
                    FlagInterlaced[0x9A]: Uint,
                    FrameRate[0x2383E3]: Float,
                    GammaValue[0x2FB523]: Float,
                    OldStereoMode[0x53B9]: Uint,
                    PixelCropBottom[0x54AA]: Uint,
                    PixelCropLeft[0x54CC]: Uint,
                    PixelCropRight[0x54DD]: Uint,
                    PixelCropTop[0x54BB]: Uint,
                    PixelHeight[0xBA]: Uint,
                    PixelWidth[0xB0]: Uint,
                    Projection[0x7670]: {
                        ProjectionPosePitch[0x7674]: Float,
                        ProjectionPoseRoll[0x7675]: Float,
                        ProjectionPoseYaw[0x7673]: Float,
                        ProjectionPrivate[0x7672]: Binary,
                        ProjectionType[0x7671]: Uint,
                    },
                    StereoMode[0x53B8]: Uint,
                    UncompressedFourCC[0x2EB524]: Binary,
                },
            },
        },
    },
}