-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathqtvr.hexpat
More file actions
845 lines (698 loc) · 21.3 KB
/
Copy pathqtvr.hexpat
File metadata and controls
845 lines (698 loc) · 21.3 KB
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
// inspired by: https://gist.github.com/Zaggy1024/a030cf23069ed62d452161f579ed272f
#pragma endian big
#include <std/core.pat>
#include <std/fxpt.pat>
#include <std/io.pat>
#include <std/math.pat>
#include <std/mem.pat>
#include <std/string.pat>
#include <std/time.pat>
#include <type/byte.pat>
#include <type/guid.pat>
#include <type/size.pat>
#define MIN_BOX_SIZE 8
fn contents_size(u128 base_offset, u64 size) {
s128 end = size == 0 ? std::mem::size() : base_offset + size;
end = std::math::min(end, std::mem::size());
s128 offset_signed = $;
return end - offset_signed;
};
struct Atom {
type::Size32 box_size;
char box_type[4];
if (box_size == 1) {
type::Size64 box_size;
}
};
struct FullAtom : Atom {
u8 version;
u24 flags;
};
fn to_float(auto value) {
return std::string::parse_float(std::string::to_string(value));
};
fn format_fixed(u32 value, u32 precision) {
// double cast is broken it seems
return to_float(value) + to_float(1 << precision);
};
fn format_fixed_signed(s32 value, u32 precision) {
float val = value >> precision;
s32 second_val = value & ( 1 << precision - 1);
float comma = second_val / ( 1 << precision + 1);
return val + comma;
};
using fixed_s32 = s32 [[format("format_fixed_signed_32")]];
using fixed_u32 = u32 [[format("format_fixed_32")]];
fn format_fixed_signed_32(s32 value) {
return format_fixed_signed(value, 16);
};
fn format_fixed_32(s32 value) {
return format_fixed(value, 16);
};
using fixed_s16 = s16 [[format("format_fixed_16")]];
fn format_fixed_16(u16 value) {
return format_fixed(value, 8);
};
using normal_s32 = s32 [[format("format_normal_32")]];
fn format_normal_32(auto value) {
return format_fixed(value, 30);
};
struct Matrix {
fixed_s32 matrix_00;
fixed_s32 matrix_01;
fixed_s32 matrix_02;
fixed_s32 matrix_10;
fixed_s32 matrix_11;
fixed_s32 matrix_12;
normal_s32 matrix_20;
normal_s32 matrix_21;
normal_s32 matrix_22;
} [[format("format_matrix")]];
fn format_matrix(auto matrix) {
return std::format("[ [ {}, {}, {} ], [ {}, {}, {} ], [ {}, {}, {} ] ]",
format_fixed_32(matrix.matrix_00), format_fixed_32(matrix.matrix_01), format_fixed_32(matrix.matrix_02),
format_fixed_32(matrix.matrix_10), format_fixed_32(matrix.matrix_11), format_fixed_32(matrix.matrix_12),
format_normal_32(matrix.matrix_20), format_normal_32(matrix.matrix_21), format_normal_32(matrix.matrix_22));
};
using UnknownAtom;
struct CTYPAtom : Atom {
char id[4];
};
struct NAVGAtom: Atom {
u16 version;
u16 columns;
u16 rows;
padding[2];
u16 loop_size;
u16 frame_duration;
u16 movie_type;
u16 ticks;
fixed_s32 field_of_view;
fixed_s32 startHPan;
fixed_s32 endHPan;
fixed_s32 endVPan;
fixed_s32 startVPan;
fixed_s32 initialHPan;
fixed_s32 initialVPan;
padding[4];
};
// moov -> udta
struct UserDataChildAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("ctyp"): CTYPAtom ctyp;
("NAVG"): NAVGAtom navg;
(_): UnknownAtom unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct UserDataAtom : Atom {
UserDataChildAtomSelector children[while (contents_size(addressof(this), box_size) > MIN_BOX_SIZE)];
// handle optional padding
// ToDo? improve it?
u128 current_pos = $;
u32 trailingZero @ $;
$ = current_pos;
$ += contents_size(addressof(this), box_size);
};
fn appears_to_contain_boxes(ref u128 contents_offset, u128 contents_size) {
u128 current_offset = contents_offset;
while (true) {
u32 current_size_raw @ current_offset;
u32 current_size = be u32(current_size_raw);
current_offset += current_size;
if (current_offset == contents_offset || current_offset >= (contents_offset + contents_size)) {
break;
}
}
return current_offset == (contents_offset + contents_size);
};
struct UnknownAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
UnknownAtom unknown [[name(atom_header.box_type)]];
std::print("unknown: " + atom_header.box_type);
} [[inline]];
struct UnknownAtom : Atom {
if (appears_to_contain_boxes($, contents_size(addressof(this), box_size))) {
UnknownAtomSelector children[while (contents_size(addressof(this), box_size) > MIN_BOX_SIZE && std::mem::size() - $ > MIN_BOX_SIZE)];
} else {
$ += sizeof(u32);
if (appears_to_contain_boxes($, contents_size(addressof(this), box_size))) {
$ -= sizeof(u32);
u8 version;
u24 flags;
UnknownAtomSelector children[while (contents_size(addressof(this), box_size) > MIN_BOX_SIZE && std::mem::size() - $ > MIN_BOX_SIZE)];
} else {
$ -= sizeof(u32);
}
}
u128 next_offset = std::math::min($ + contents_size(addressof(this), box_size), std::mem::size());
if (next_offset > $) {
u8 unknown_data[next_offset - $] [[sealed]];
} else {
$ = next_offset;
}
std::print("unknown atom: {}: {}", box_type, $);
} [[format("format_box_type")]];
fn format_box_type(auto box) {
return box.box_type;
};
// original has formatting
// original parses times as datetimes
struct MovieHeaderAtom : FullAtom {
u32 creation_time;
u32 modification_time;
u32 timescale;
u32 duration;
fixed_s32 rate;
fixed_s16 volume;
padding[10];
Matrix matrix;
u32 preview_time;
u32 preview_duration;
u32 poster_time;
u32 selection_time;
u32 selection_duration;
u32 current_time;
u32 next_track_id;
}[[format("format_mvhd")]];
bitfield TrackHeaderFlags {
padding : 4;
bool track_in_poster: 1;
bool track_in_preview: 1;
bool track_in_movie: 1;
bool track_enabled : 1;
};
struct TrackHeaderAtom : Atom {
u8 version;
padding[2];
TrackHeaderFlags;
u32 creation_time;
u32 modification_time;
u32 track_id;
padding[sizeof(u32)];
u32 duration;
padding[sizeof(u32) * 2];
s16 layer;
u16 alternate_group;
fixed_s16 volume;
padding[sizeof(u16)];
Matrix matrix;
fixed_s32 track_width;
fixed_s32 track_height;
};
using EditListAtom;
struct EditAtom : Atom {
EditListAtom edits[while (contents_size(addressof(this), box_size) > MIN_BOX_SIZE)];
$ += contents_size(addressof(this), box_size);
};
// moov -> trak -> edts -> elst
struct EditListEntry<DurationT, TimeT> {
DurationT segment_duration;
TimeT media_time;
s16 media_rate_integer;
s16 media_rate_fraction;
};
struct EditListAtom : FullAtom {
u32 entry_count;
EditListEntry<u32, s32> entries[entry_count];
$ += contents_size(addressof(this), box_size);
};
using MediaHeaderAtom;
using HandlerAtom;
using SampleTableChildAtomSelector;
struct SampleTableAtom : Atom {
SampleTableChildAtomSelector children[while(contents_size(addressof(this), box_size) > 0)];
};
struct DataPointer32 {
u8* pointer : u32;
} [[inline]];
struct ChunkOffsetAtom : FullAtom {
u32 entry_count;
DataPointer32 chunk_offset[entry_count];
$ += contents_size(addressof(this), box_size);
};
struct UnknownSampleEntryChildSelector {
Atom box_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
(_): UnknownAtom unknown [[name(box_header.box_type)]];
}
} [[inline]];
struct SampleEntry : Atom {
padding[sizeof(u8) * 6];
u16 data_reference_index;
};
struct UnknownSampleEntry : SampleEntry {
if (appears_to_contain_boxes($, contents_size(addressof(this), box_size))) {
UnknownSampleEntryChildSelector children[while (contents_size(addressof(this), box_size) > MIN_BOX_SIZE)];
}
$ += contents_size(addressof(this), box_size);
};
enum VisualSampleDepth : u16 {
ColourNoAlpha = 0x0018,
};
struct VisualSampleEntry : SampleEntry {
u16 version;
u16 revision;
char vendor[4];
u32 temporal_quality;
u32 spatial_quality;
u16 width;
u16 height;
fixed_s32 horizresolution; // in pixels per inch
fixed_s32 vertresolution; // in pixels per inch
padding[sizeof(u32)];
u16 frame_count_per_sample;
u8 compressorname_size [[hidden]];
char compressorname[compressorname_size];
$ = addressof(compressorname_size) + 32;
u16 depth;
s16 colorTableID;
if (colorTableID != -1 ) {
std::print("Special color table");
}
$ += contents_size(addressof(this), box_size);
};
struct PanoSampleDescription: Atom {
// https://developer.apple.com/library/archive/technotes/tn/tn1035.html
std::print("pano located at: 0x{:X}", addressof(this));
padding[sizeof(u32)];
padding[sizeof(u32)]; // must be zero, sometimes it contains a 1
s16 majorVersion; // must be zero, sometimes it contains a 1
s16 minorVersion;
s32 sceneTrackID;
s32 loResSceneTrackID;
padding[sizeof(u32) * 6];
s32 hotspotTrackID;
padding[sizeof(u32) * 9];
fixed_s32 hPanStart;
fixed_s32 hPanEnd;
fixed_s32 vPanTop;
fixed_s32 vPanBottom; // TODO: number is off...
fixed_s32 minimumZoom;
fixed_s32 maximumZoom;
// Info for highest res version of scene track
s32 sceneSizeX;
s32 sceneSizeY;
s32 numFrames;
padding[sizeof(u16)];
s16 sceneNumFramesX;
s16 sceneNumFramesY;
s16 sceneColorDepth;
// Info for highest res version of hotSpot track
s32 hotSpotSizeX;
s32 hotSpotSizeY;
padding[sizeof(u16)];
s16 hotSpotNumFramesX;
s16 hotSpotNumFrameY;
s16 hotspotColorDepth;
$ += contents_size(addressof(this), box_size);
};
struct SampleEntrySelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("cvid"): VisualSampleEntry cvid;
("smc "): VisualSampleEntry smc;
("rle "): VisualSampleEntry rle;
("pano"): PanoSampleDescription pano;
("SVQ1"): VisualSampleEntry svq;
//("qtvr"): QTVRSampleDescription qtvr;
(_): UnknownSampleEntry unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct SampleDescriptionAtom : FullAtom {
u32 entry_count;
SampleEntrySelector children[entry_count];
$ += contents_size(addressof(this), box_size);
};
// moov -> trak -> mdia -> minf -> stbl -> stts
struct TimeToSampleEntry {
u32 sample_count;
u32 sample_duration;
} [[format("format_stts_entry")]];
fn format_stts_entry(auto stts_entry) {
return std::format("count = {}, duration = {}", stts_entry.sample_count, stts_entry.sample_duration);
};
struct TimeToSampleAtom : FullAtom {
u32 entry_count;
TimeToSampleEntry entries[entry_count] [[format("count_samples")]];
$ += contents_size(addressof(this), box_size);
};
fn count_samples(auto entries) {
u128 count = 0;
for (u32 i = 0, i < std::core::member_count(entries), i += 1) {
count += entries[i].sample_count;
}
return std::format("{} samples total", count);
};
// moov -> trak -> mdia -> minf -> stbl -> stsc
struct SampleToChunkAtomEntry {
u32 first_chunk;
u32 samples_per_chunk;
u32 sample_description_index;
} [[format("format_stsc_entry")]];
fn format_stsc_entry(auto stsc_entry) {
return std::format("first_chunk = {}, samples_per_chunk = {}, sample_description_index = {}",
stsc_entry.first_chunk, stsc_entry.samples_per_chunk, stsc_entry.sample_description_index);
};
struct SampleToChunkAtom : FullAtom {
u32 entry_count;
SampleToChunkAtomEntry entries[entry_count];
$ += contents_size(addressof(this), box_size);
};
using SampleSizeAtom;
struct SampleTableChildAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("stsd"): SampleDescriptionAtom stsd;
("stsz"): SampleSizeAtom stsz;
("stco"): ChunkOffsetAtom stco;
("stts"): TimeToSampleAtom stts;
("stsc"): SampleToChunkAtom stsc;
(_): UnknownAtom unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct SampleSizeAtom : FullAtom {
u32 sample_size;
u32 sample_count;
if (sample_size == 0) {
u32 entry_size[sample_count];
}
$ += contents_size(addressof(this), box_size);
};
struct VideoMediaHeaderAtom : FullAtom {
u16 graphicsmode;
u16 opcolor[3];
$ += contents_size(addressof(this), box_size);
};
// moov -> trak -> mdia -> minf -> dinf
using DataReferenceAtom;
struct DataEntryAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("alis"): FullAtom alis;
(_): UnknownAtom unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct DataReferenceAtom : FullAtom {
u32 entry_count;
DataEntryAtomSelector children[entry_count];
$ += contents_size(addressof(this), box_size);
};
struct DataInformationChildAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("dref"): DataReferenceAtom dref;
(_): UnknownAtom unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct DataInformationAtom : Atom {
DataInformationChildAtomSelector children[while (contents_size(addressof(this), box_size) > MIN_BOX_SIZE)];
};
struct BaseMediaInfoAtom: FullAtom {
u16 graphics_mode;
u16 opcolor_1;
u16 opcolor_2;
u16 opcolor_3;
u16 balance;
padding[sizeof(u16)];
};
struct PanoMediaEntry {
u32 nodeID;
u32 time;
};
struct PanoMediaInfoAtom: Atom {
std::print("pINF: 0x{:X}", $);
std::string::SizedString<u8> name;
// string is padded till the 32nd byte.
// this is the beginning of the atom, including the 8 byte.
padding[40-($ - addressof(this))];
u32 defNodeId;
fixed_s32 defZoom;
s32 reserved;
s16 pad;
s16 numEntries;
PanoMediaEntry entries[numEntries];
$ += contents_size(addressof(this), box_size);
}[[hex::visualize("hex_viewer", this)]];
struct STPanoMediaInfoChildAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("pInf"): PanoMediaInfoAtom pInf;
(_): UnknownAtom unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct STPanoMediaInfoAtom: Atom {
STPanoMediaInfoChildAtomSelector children[while (contents_size(addressof(this), box_size) > MIN_BOX_SIZE)];
};
struct GMHDChildAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("gmin"): BaseMediaInfoAtom gmin;
("STpn"): STPanoMediaInfoAtom STpn;
(_): UnknownAtom unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct GMHDAtom: Atom {
GMHDChildAtomSelector children[while (contents_size(addressof(this), box_size) > MIN_BOX_SIZE)];
$ += contents_size(addressof(this), box_size);
};
struct MediaInformationChildAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("stbl"): SampleTableAtom stbl;
("hdlr"): HandlerAtom hdlr;
("vmhd"): VideoMediaHeaderAtom vmhd;
("dinf"): DataInformationAtom dinf;
("gmhd"): GMHDAtom gmhd;
(_): UnknownAtom unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct MediaInformationAtom : Atom {
MediaInformationChildAtomSelector children[while(contents_size(addressof(this), box_size) > 0)];
};
struct MediaChildAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("mdhd"): MediaHeaderAtom mdhd;
("hdlr"): HandlerAtom hdlr;
("minf"): MediaInformationAtom minf;
(_): UnknownAtom unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct MediaAtom : Atom {
MediaChildAtomSelector children[while (contents_size(addressof(this), box_size) > 0)];
};
struct TrackChildAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("tkhd"): TrackHeaderAtom tkhd;
("mdia"): MediaAtom mdia;
("edts"): EditAtom edts;
(_): UnknownAtom unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct TrackAtom : Atom {
TrackChildAtomSelector children[while(contents_size(addressof(this), box_size) > 0)];
};
str current_handler;
// (mdia|meta) -> hdlr
struct HandlerAtom : FullAtom {
char component_type[4];
char component_subtype[4];
char component_manufacturer[4];
u32 component_flags;
u32 component_flags_mask;
if (box_size > 32) {
std::string::SizedString<u8> name;
}
};
fn format_hdlr(auto hdlr) {
if (std::core::has_member(hdlr, "name")) {
return std::format("hdlr (type={}, name={})", hdlr.handler_type, hdlr.name.name);
}
return std::format("hdlr (type={})", hdlr.handler_type);
};
struct MediaHeaderAtom : FullAtom {
u32 creation_time;
u32 modification_time;
u32 timescale;
u32 duration;
u16 language;
u16 quality;
} [[format("format_mdhd")]];
fn format_mdhd(auto mdhd) {
return std::format("mdhd {{ duration = {} }}",
format_duration(mdhd.duration, mdhd.timescale));
};
fn format_duration(auto duration, auto timescale) {
float duration_f = duration;
float timescale_f = timescale;
float total_seconds = duration_f / timescale_f;
u128 minutes = std::math::floor(total_seconds / 60);
float seconds = total_seconds - (minutes * 60);
if (minutes > 0) {
return std::format("{:02d}:{:06.3f}", minutes, seconds);
} else {
return std::format("{:.3f}s", seconds);
}
};
fn format_mvhd(auto mvhd) {
return "mvhd { duration = " + format_duration(mvhd.duration, mvhd.timescale) + " }";
};
struct MovieChildAtomSelector {
Atom atom_header [[hidden]];
$ = addressof(this);
match(atom_header.box_type) {
("mvhd"): MovieHeaderAtom mvhd;
("trak"): TrackAtom trak;
("udta"): UserDataAtom udta;
(_): UnknownAtomSelector unknown [[name(atom_header.box_type)]];
}
} [[inline]];
struct MovieAtom: Atom {
MovieChildAtomSelector children[while(contents_size(addressof(this), box_size) > MIN_BOX_SIZE)];
};
// mdat
struct MediaDataAtom : Atom {
u8 data[contents_size(addressof(this), box_size)] [[sealed]];
};
fn string_trim_end(ref str string, u128 amount) {
u128 length = std::string::length(string);
return std::string::substr(string, 0, length - amount);
};
fn format_box_array(auto atom_array) {
str result = "[ ";
u64 i;
for (i = 0, i < std::core::member_count(atom_array), i += 1) {
result = result + atom_array[i].atom_header.box_type + ", ";
}
return string_trim_end(result, 2) + " ]";
};
struct RootAtom {
Atom atom_header [[hidden]];
$ = addressof(this);
if ($ + contents_size(addressof(this), atom_header.box_size) <= std::mem::size()) {
match(atom_header.box_type) {
("moov"): MovieAtom moov;
("mdat"): MediaDataAtom mdat;
(_): UnknownAtomSelector unknown [[name(atom_header.box_type)]];
}
} else {
$ = std::mem::size();
}
} [[inline]];
RootAtom atoms[while(std::mem::size() - $ > MIN_BOX_SIZE)] @ 0x00 [[format("format_box_array")]];
struct HotSpotEntry {
u16 hotSpotId;
padding[2];
char type[4];
u32 typeData;
fixed_s32 viewHPan;
fixed_s32 viewVPan;
fixed_s32 viewZoom;
u16 rect1;
u16 rect2;
u16 rect3;
u16 rect4;
s32 mouseOVerCursorID;
s32 mouseDownCursorID;
s32 mouseUpCursorID;
padding[sizeof(s32)];
s32 nameStrOffset;
s32 commentStrOffset;
};
struct pHot: Atom {
padding[2];
u16 numHotSpots;
HotSpotEntry entries[numHotSpots];
};
struct pHdr: Atom {
u32 nodeID;
fixed_s32 defHPan;
fixed_s32 defVPan;
fixed_s32 defZoom;
fixed_s32 minHPan;
fixed_s32 minVPan;
fixed_s32 minZoom;
fixed_s32 maxHPan;
fixed_s32 maxVPan;
fixed_s32 maxZoom;
padding[sizeof(u32)];
padding[sizeof(u32)];
u32 nameStrOffset;
u32 commentStrOffset;
};
struct PanoLink {
u16 linkID;
padding[sizeof(u16)];
padding[sizeof(u32)];
padding[sizeof(u32)];
u32 toNodeID;
padding[sizeof(u32) * 3];
fixed_s32 toHPan;
fixed_s32 toVPan;
fixed_s32 toZoom;
padding[sizeof(u32)];
padding[sizeof(u32)];
u32 nameStrOffset;
u32 commentStrOffset;
};
struct LinkTableAtom : Atom {
padding[sizeof(u16)];
u16 numLinks;
PanoLink entries[numLinks];
};
struct NavgObject {
u16 objID;
padding[sizeof(u16)]; // reserved1
padding[sizeof(u32)]; // reserved2
fixed_s32 navgHPan;
fixed_s32 navgVPan;
fixed_s32 navgZoom;
u16 rect1;
u16 rect2;
u16 rect3;
u16 rect4;
padding[sizeof(u32)]; // reserved3
u32 nameStrOffset;
u32 commentStrOffset;
};
struct NavgTableAtom : Atom {
padding[sizeof(u16)];
u16 numObjects;
NavgObject entries[numObjects];
};
struct PascalString {
std::string::SizedString<u8> name;
};
struct StringTableAtom : Atom {
PascalString children[while (contents_size(addressof(this), box_size) > MIN_BOX_SIZE)];
};
struct PanoramaMDAT {
Atom atom_header [[hidden]];
$ = addressof(this);
if ($ + contents_size(addressof(this), atom_header.box_size) <= std::mem::size()) {
match(atom_header.box_type) {
("pHot"): pHot phot;
("pHdr"): pHdr phdr;
("pLnk"): LinkTableAtom plnk;
("strT"): StringTableAtom strt;
("pNav"): NavgTableAtom pnav;
(_): UnknownAtomSelector unknown [[name(atom_header.box_type)]];
}
} else {
$ = std::mem::size();
}
} [[inline]];