-
Notifications
You must be signed in to change notification settings - Fork 29
/
ValidateAtoms.cpp
5220 lines (4133 loc) · 169 KB
/
ValidateAtoms.cpp
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
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
This file contains Original Code and/or Modifications of Original Code
as defined in and that are subject to the Apple Public Source License
Version 2.0 (the 'License'). You may not use this file except in
compliance with the License. Please obtain a copy of the License at
http://www.opensource.apple.com/apsl/ and read it before using this
file.
The Original Code and all software distributed under the License are
distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
Please see the License for the specific language governing rights and
limitations under the License.
*/
#include "ValidateMP4.h"
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
extern ValidateGlobals vg;
//===============================================
OSErr CheckMatrixForUnity( MatrixRecord mr )
{
OSErr err = noErr;
if ( (mr[0][0] != 0x00010000)
|| (mr[0][1] != 0)
|| (mr[0][2] != 0)
|| (mr[1][0] != 0)
|| (mr[1][1] != 0x00010000)
|| (mr[1][2] != 0)
|| (mr[2][0] != 0)
|| (mr[2][1] != 0)
|| (mr[2][2] != 0x40000000)
) {
err = badAtomErr;
errprint("has non-identity matrix" "\n");
}
return err;
}
//===============================================
OSErr GetFullAtomVersionFlags( atomOffsetEntry *aoe, UInt32 *version, UInt32 *flags, UInt64 *offsetOut)
{
OSErr err = noErr;
UInt32 versFlags;
UInt64 offset;
// Get version/flags
offset = aoe->offset + aoe->atomStartSize;
BAILIFERR( GetFileDataN32( aoe, &versFlags, offset, &offset ) );
*version = (versFlags >> 24) & 0xFF;
*flags = versFlags & 0x00ffffff;
*offsetOut = offset;
bail:
return err;
}
//==========================================================================================
OSErr Validate_iods_Atom( atomOffsetEntry *aoe, void *refcon )
{
#pragma unused(refcon)
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
Ptr odDataP = nil;
UInt32 odSize;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
FieldMustBe( flags, 0, "'iods' version must be %d not %d" );
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint(">\n");
// Get the ObjectDescriptor
BAILIFERR( GetFileBitStreamDataToEndOfAtom( aoe, &odDataP, &odSize, offset, &offset ) );
BAILIFERR( Validate_iods_OD_Bits( odDataP, odSize, true ) );
// All done
aoe->aoeflags |= kAtomValidated;
bail:
if (odDataP)
free(odDataP);
return err;
}
//==========================================================================================
typedef struct MovieHeaderCommonRecord {
Fixed preferredRate; // must be 1.0 for mp4
SInt16 preferredVolume; // must be 1.0 for mp4
short reserved1; // must be 0
SInt32 preferredLong1; // must be 0 for mp4
SInt32 preferredLong2; // must be 0 for mp4
MatrixRecord matrix; // must be identity for mp4
TimeValue previewTime; // must be 0 for mp4
TimeValue previewDuration; // must be 0 for mp4
TimeValue posterTime; // must be 0 for mp4
TimeValue selectionTime; // must be 0 for mp4
TimeValue selectionDuration; // must be 0 for mp4
TimeValue currentTime; // must be 0 for mp4
SInt32 nextTrackID;
} MovieHeaderCommonRecord;
typedef struct MovieHeaderVers0Record {
UInt32 creationTime;
UInt32 modificationTime;
UInt32 timeScale;
UInt32 duration;
} MovieHeaderVers0Record;
typedef struct MovieHeaderVers1Record {
UInt64 creationTime;
UInt64 modificationTime;
UInt32 timeScale;
UInt64 duration;
} MovieHeaderVers1Record;
OSErr Validate_mvhd_Atom( atomOffsetEntry *aoe, void *refcon )
{
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
MovieHeaderVers1Record mvhdHead;
MovieHeaderCommonRecord mvhdHeadCommon;
MovieInfoRec *mir = (MovieInfoRec *)refcon;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// Get data based on version
if (version == 0) {
MovieHeaderVers0Record mvhdHead0;
BAILIFERR( GetFileData( aoe, &mvhdHead0, offset, sizeof(mvhdHead0), &offset ) );
mvhdHead.creationTime = EndianU32_BtoN(mvhdHead0.creationTime);
mvhdHead.modificationTime = EndianU32_BtoN(mvhdHead0.modificationTime);
mvhdHead.timeScale = EndianU32_BtoN(mvhdHead0.timeScale);
mvhdHead.duration = EndianU32_BtoN(mvhdHead0.duration);
} else if (version == 1) {
BAILIFERR( GetFileData( aoe, &mvhdHead.creationTime, offset, sizeof(mvhdHead.creationTime), &offset ) );
mvhdHead.creationTime = EndianU64_BtoN(mvhdHead.creationTime);
BAILIFERR( GetFileData( aoe, &mvhdHead.modificationTime, offset, sizeof(mvhdHead.modificationTime), &offset ) );
mvhdHead.modificationTime = EndianU64_BtoN(mvhdHead.modificationTime);
BAILIFERR( GetFileData( aoe, &mvhdHead.timeScale, offset, sizeof(mvhdHead.timeScale), &offset ) );
mvhdHead.timeScale = EndianU32_BtoN(mvhdHead.timeScale);
BAILIFERR( GetFileData( aoe, &mvhdHead.duration, offset, sizeof(mvhdHead.duration), &offset ) );
mvhdHead.duration = EndianU64_BtoN(mvhdHead.duration);
} else {
errprint("Movie header is version other than 0 or 1\n");
err = badAtomErr;
goto bail;
}
BAILIFERR( GetFileData( aoe, &mvhdHeadCommon, offset, sizeof(mvhdHeadCommon), &offset ) );
mvhdHeadCommon.preferredRate = EndianU32_BtoN(mvhdHeadCommon.preferredRate);
mvhdHeadCommon.preferredVolume = EndianS16_BtoN(mvhdHeadCommon.preferredVolume);
mvhdHeadCommon.reserved1 = EndianS16_BtoN(mvhdHeadCommon.reserved1);
mvhdHeadCommon.preferredLong1 = EndianS32_BtoN(mvhdHeadCommon.preferredLong1);
mvhdHeadCommon.preferredLong2 = EndianS32_BtoN(mvhdHeadCommon.preferredLong2);
EndianMatrix_BtoN(&mvhdHeadCommon.matrix);
mvhdHeadCommon.previewTime = EndianS32_BtoN(mvhdHeadCommon.previewTime);
mvhdHeadCommon.previewDuration = EndianS32_BtoN(mvhdHeadCommon.previewDuration);
mvhdHeadCommon.posterTime = EndianS32_BtoN(mvhdHeadCommon.posterTime);
mvhdHeadCommon.selectionTime = EndianS32_BtoN(mvhdHeadCommon.selectionTime);
mvhdHeadCommon.selectionDuration = EndianS32_BtoN(mvhdHeadCommon.selectionDuration);
mvhdHeadCommon.currentTime = EndianS32_BtoN(mvhdHeadCommon.currentTime);
mvhdHeadCommon.nextTrackID = EndianS32_BtoN(mvhdHeadCommon.nextTrackID);
if(vg.cmaf){
if(mvhdHeadCommon.preferredRate != 0x00010000){
errprint("CMAF check violated: Section 7.5.1. \"The field rate SHALL be set to its default value\", found 0x%lx\n", mvhdHeadCommon.preferredRate);
}
if(mvhdHeadCommon.preferredVolume != 0x0100){
errprint("CMAF check violated: Section 7.5.1. \"The field volume SHALL be set to its default value\", found 0x%lx\n", mvhdHeadCommon.preferredVolume);
}
if(mvhdHeadCommon.matrix[0][0] != 0 && mvhdHeadCommon.matrix[1][1] != 0 && mvhdHeadCommon.matrix[2][2] != 0x40000000){
errprint("CMAF check violated: Section 7.5.1. \"The field matrix SHALL be set to its default value\", found (0x%lx, 0x%lx, 0x%lx)\n", mvhdHeadCommon.matrix[0][0], mvhdHeadCommon.matrix[1][1], mvhdHeadCommon.matrix[2][2]);
}
}
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint("creationTime=\"%s\"\n", int64toxstr(mvhdHead.creationTime));
atomprint("modificationTime=\"%s\"\n", int64toxstr(mvhdHead.modificationTime));
atomprint("timeScale=\"%s\"\n", int64todstr(mvhdHead.timeScale));
atomprint("duration=\"%s\"\n", int64todstr(mvhdHead.duration));
atomprint("nextTrackID=\"%ld\"\n", mvhdHeadCommon.nextTrackID);
atomprint(">\n");
mir->mvhd_timescale = mvhdHead.timeScale; //Used for edit lists
// Check required field values
FieldMustBe( mvhdHeadCommon.preferredRate, 0x00010000, "'mvhd' preferredRate must be 0x%lx not 0x%lx" );
FieldMustBe( mvhdHeadCommon.preferredVolume, 0x0100, "'mvhd' preferredVolume must be 0x%lx not 0x%lx" );
FieldMustBe( mvhdHeadCommon.reserved1, 0, "'mvhd' has a non-zero reserved field, should be %d is %d" );
FieldMustBe( mvhdHeadCommon.reserved1, 0, "'mvhd' has a non-zero reserved field, should be %d is %d" );
FieldMustBe( mvhdHeadCommon.preferredLong1, 0, "'mvhd' has a non-zero reserved field, should be %d is %d" );
FieldMustBe( mvhdHeadCommon.preferredLong2, 0, "'mvhd' has a non-zero reserved field, should be %d is %d" );
FieldMustBe( mvhdHeadCommon.previewTime, 0, "'mvhd' has a non-zero reserved field, should be %d is %d" );
FieldMustBe( mvhdHeadCommon.previewDuration, 0, "'mvhd' has a non-zero reserved field, should be %d is %d" );
FieldMustBe( mvhdHeadCommon.posterTime, 0, "'mvhd' has a non-zero reserved field, should be %d is %d" );
FieldMustBe( mvhdHeadCommon.selectionTime, 0, "'mvhd' has a non-zero reserved field, should be %d is %d" );
FieldMustBe( mvhdHeadCommon.selectionDuration, 0, "'mvhd' has a non-zero reserved field, should be %d is %d" );
FieldMustBe( mvhdHeadCommon.currentTime, 0, "'mvhd' has a non-zero reserved field, should be %d is %d" );
BAILIFERR( CheckMatrixForUnity( mvhdHeadCommon.matrix ) );
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//===============================================
typedef struct TrackHeaderCommonRecord {
TimeValue movieTimeOffset; // reserved in mp4
PriorityType priority; // reserved in mp4
SInt16 layer; // reserved in mp4
SInt16 alternateGroup; // reserved in mp4
SInt16 volume; // 256 for audio, 0 otherwise
SInt16 reserved;
MatrixRecord matrix; // must be identity matrix
Fixed trackWidth; // 320 for video, 0 otherwise
Fixed trackHeight; // 240 for video, 0 otherwise
} TrackHeaderCommonRecord;
typedef struct TrackHeaderVers0Record {
UInt32 creationTime;
UInt32 modificationTime;
UInt32 trackID;
UInt32 reserved;
TimeValue duration;
} TrackHeaderVers0Record;
typedef struct TrackHeaderVers1Record {
UInt64 creationTime;
UInt64 modificationTime;
UInt32 trackID;
UInt32 reserved;
UInt64 duration;
} TrackHeaderVers1Record;
OSErr Validate_tkhd_Atom( atomOffsetEntry *aoe, void *refcon )
{
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
TrackHeaderVers1Record tkhdHead;
TrackHeaderCommonRecord tkhdHeadCommon;
TrackInfoRec *tir = (TrackInfoRec*)refcon;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// Get data based on version
if (version == 0) {
TrackHeaderVers0Record tkhdHead0;
BAILIFERR( GetFileData( aoe, &tkhdHead0, offset, sizeof(tkhdHead0), &offset ) );
tkhdHead.creationTime = EndianU32_BtoN(tkhdHead0.creationTime);
tkhdHead.modificationTime = EndianU32_BtoN(tkhdHead0.modificationTime);
tkhdHead.trackID = EndianU32_BtoN(tkhdHead0.trackID);
tkhdHead.reserved = EndianU32_BtoN(tkhdHead0.reserved);
tkhdHead.duration = EndianU32_BtoN(tkhdHead0.duration);
FieldMustBe( EndianU32_BtoN(tkhdHead0.reserved), 0, "'tkhd' reserved must be %d not %d" );
} else if (version == 1) {
BAILIFERR( GetFileData( aoe, &tkhdHead.creationTime, offset, sizeof(tkhdHead.creationTime), &offset ) );
tkhdHead.creationTime = EndianU64_BtoN(tkhdHead.creationTime);
BAILIFERR( GetFileData( aoe, &tkhdHead.modificationTime, offset, sizeof(tkhdHead.modificationTime), &offset ) );
tkhdHead.modificationTime = EndianU64_BtoN(tkhdHead.modificationTime);
BAILIFERR( GetFileData( aoe, &tkhdHead.trackID , offset, sizeof(tkhdHead.trackID ), &offset ) );
tkhdHead.trackID = EndianU32_BtoN(tkhdHead.trackID);
BAILIFERR( GetFileData( aoe, &tkhdHead.reserved , offset, sizeof(tkhdHead.reserved ), &offset ) );
tkhdHead.reserved = EndianU32_BtoN(tkhdHead.reserved);
BAILIFERR( GetFileData( aoe, &tkhdHead.duration, offset, sizeof(tkhdHead.duration), &offset ) );
tkhdHead.duration = EndianU64_BtoN(tkhdHead.duration);
} else {
errprint("Track header is version other than 0 or 1\n");
err = badAtomErr;
goto bail;
}
BAILIFERR( GetFileData( aoe, &tkhdHeadCommon, offset, sizeof(tkhdHeadCommon), &offset ) );
tkhdHeadCommon.movieTimeOffset = EndianU32_BtoN(tkhdHeadCommon.movieTimeOffset);
tkhdHeadCommon.priority = EndianU32_BtoN(tkhdHeadCommon.priority);
tkhdHeadCommon.layer = EndianS16_BtoN(tkhdHeadCommon.layer);
tkhdHeadCommon.alternateGroup = EndianS16_BtoN(tkhdHeadCommon.alternateGroup);
tkhdHeadCommon.volume = EndianS16_BtoN(tkhdHeadCommon.volume);
tkhdHeadCommon.reserved = EndianS16_BtoN(tkhdHeadCommon.reserved);
EndianMatrix_BtoN(&tkhdHeadCommon.matrix);
tkhdHeadCommon.trackWidth = EndianS32_BtoN(tkhdHeadCommon.trackWidth);
tkhdHeadCommon.trackHeight = EndianS32_BtoN(tkhdHeadCommon.trackHeight);
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint("creationTime=\"%s\"\n", int64toxstr(tkhdHead.creationTime));
atomprint("modificationTime=\"%s\"\n", int64toxstr(tkhdHead.modificationTime));
atomprint("trackID=\"%ld\"\n", tkhdHead.trackID);
atomprint("duration=\"%s\"\n", int64todstr(tkhdHead.duration));
atomprint("volume=\"%s\"\n", fixed16str(tkhdHeadCommon.volume));
atomprint("width=\"%s\"\n", fixedU32str(tkhdHeadCommon.trackWidth));
atomprint("height=\"%s\"\n", fixedU32str(tkhdHeadCommon.trackHeight));
atomprint(">\n");
// Check required field values
// else FieldMustBe( flags, 1, "'tkhd' flags must be 1" );
if ((flags & 7) != flags) errprint("Tkhd flags 0x%X other than 1,2 or 4 set\n", flags);
if (flags == 0) warnprint( "WARNING: 'tkhd' flags == 0 (OK in a hint track)\n", flags );
if (tkhdHead.duration == 0 && !vg.dashSegment) warnprint( "WARNING: 'tkhd' duration == 0, track may be considered empty\n", flags );
FieldMustBe( tkhdHeadCommon.movieTimeOffset, 0, "'tkhd' movieTimeOffset must be %d not %d" );
FieldMustBe( tkhdHeadCommon.priority, 0, "'tkhd' priority must be %d not %d" );
FieldMustBe( tkhdHeadCommon.layer, 0, "'tkhd' layer must be %d not %d" );
FieldMustBe( tkhdHeadCommon.alternateGroup, 0, "'tkhd' alternateGroup must be %d not %d" );
FieldMustBe( tkhdHeadCommon.reserved, 0, "'tkhd' reserved must be %d not %d" );
// ���� CHECK for audio/video
{
FieldMustBeOneOf2( tkhdHeadCommon.volume, SInt16, "'tkhd' volume must be set to one of ", (0, 0x0100) );
if( vg.majorBrand == brandtype_mp41 ){
FieldMustBeOneOf2( tkhdHeadCommon.trackWidth, Fixed, "'tkhd' trackWidth must be set to one of ", (0, (320L << 16)) );
FieldMustBeOneOf2( tkhdHeadCommon.trackHeight, Fixed, "'tkhd' trackHeight must be set to one of ", (0, (240L << 16)) );
}
}
if(vg.cmaf){
if(tkhdHead.duration != 0){
errprint("CMAF check violated: Section 7.5.4. \"The value of the duration field SHALL be set to a value of zero\", found %lu\n",tkhdHead.duration);
}
if((tkhdHeadCommon.matrix[0][0] != 0 && tkhdHeadCommon.matrix[1][1] != 0 && tkhdHeadCommon.matrix[2][2] != 0x40000000) || (tkhdHeadCommon.matrix[0][0] != 0x00010000 && tkhdHeadCommon.matrix[1][1] != 0x00010000 && tkhdHeadCommon.matrix[2][2] != 0x40000000)){
errprint("CMAF check violated: Section 7.5.4. \"The field matrix SHALL be set their default values\", found (0x%lx, 0x%lx, 0x%lx)\n", tkhdHeadCommon.matrix[0][0], tkhdHeadCommon.matrix[1][1], tkhdHeadCommon.matrix[2][2]);
}
if(tir->mediaType == 'soun'){
if(tkhdHeadCommon.trackWidth != 0 && tkhdHeadCommon.trackHeight != 0)
errprint("CMAF check violated: Section 7.5.4. \"The width and height fields for a non-visual track SHALL be 0\", found width=\"%s\", height=\"%s\"\n", fixedU32str(tkhdHeadCommon.trackWidth), fixedU32str(tkhdHeadCommon.trackHeight));
}
}
// save off some of the fields in the rec
if (tir != NULL) {
tir->trackID = tkhdHead.trackID;
tir->trackWidth = tkhdHeadCommon.trackWidth;
tir->trackHeight = tkhdHeadCommon.trackHeight;
}
else errprint("Internal error -- Track ID %d not recorded\n",tkhdHead.trackID);
BAILIFERR( CheckMatrixForUnity( tkhdHeadCommon.matrix ) );
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
typedef struct MediaHeaderCommonRecord {
UInt16 language; // high-bit = 0, packed ISO-639-2/T language code (int(5)[3])
UInt16 quality; // must be 0 for mp4
} MediaHeaderCommonRecord;
typedef struct MediaHeaderVers0Record {
UInt32 creationTime;
UInt32 modificationTime;
UInt32 timescale;
UInt32 duration;
} MediaHeaderVers0Record;
typedef struct MediaHeaderVers1Record {
UInt64 creationTime;
UInt64 modificationTime;
UInt32 timescale;
UInt64 duration;
} MediaHeaderVers1Record;
OSErr Validate_mdhd_Atom( atomOffsetEntry *aoe, void *refcon )
{
TrackInfoRec *tir = (TrackInfoRec *)refcon;
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
MediaHeaderVers1Record mdhdHead;
MediaHeaderCommonRecord mdhdHeadCommon;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// Get data based on version
if (version == 0) {
MediaHeaderVers0Record mdhdHead0;
BAILIFERR( GetFileData( aoe, &mdhdHead0, offset, sizeof(mdhdHead0), &offset ) );
mdhdHead.creationTime = EndianU32_BtoN(mdhdHead0.creationTime);
mdhdHead.modificationTime = EndianU32_BtoN(mdhdHead0.modificationTime);
mdhdHead.timescale = EndianU32_BtoN(mdhdHead0.timescale);
mdhdHead.duration = EndianU32_BtoN(mdhdHead0.duration);
} else if (version == 1) {
BAILIFERR( GetFileData( aoe, &mdhdHead.creationTime, offset, sizeof(mdhdHead.creationTime), &offset ) );
mdhdHead.creationTime = EndianU64_BtoN(mdhdHead.creationTime);
BAILIFERR( GetFileData( aoe, &mdhdHead.modificationTime, offset, sizeof(mdhdHead.modificationTime), &offset ) );
mdhdHead.modificationTime = EndianU64_BtoN(mdhdHead.modificationTime);
BAILIFERR( GetFileData( aoe, &mdhdHead.timescale, offset, sizeof(mdhdHead.timescale), &offset ) );
mdhdHead.timescale = EndianU32_BtoN(mdhdHead.timescale);
BAILIFERR( GetFileData( aoe, &mdhdHead.duration, offset, sizeof(mdhdHead.duration), &offset ) );
mdhdHead.duration = EndianU64_BtoN(mdhdHead.duration);
} else {
errprint("Media header is version other than 0 or 1\n");
err = badAtomErr;
goto bail;
}
tir->mediaTimeScale = mdhdHead.timescale;
tir->mediaDuration = mdhdHead.duration;
vg.mediaHeaderTimescale=mdhdHead.timescale;
BAILIFERR( GetFileData( aoe, &mdhdHeadCommon, offset, sizeof(mdhdHeadCommon), &offset ) );
mdhdHeadCommon.language = EndianU16_BtoN(mdhdHeadCommon.language);
mdhdHeadCommon.quality = EndianU16_BtoN(mdhdHeadCommon.quality);
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint("creationTime=\"%s\"\n", int64toxstr(mdhdHead.creationTime));
atomprint("modificationTime=\"%s\"\n", int64toxstr(mdhdHead.modificationTime));
atomprint("timescale=\"%s\"\n", int64todstr(mdhdHead.timescale));
atomprint("duration=\"%s\"\n", int64todstr(mdhdHead.duration));
atomprint("language=\"%s\"\n", langtodstr(mdhdHeadCommon.language));
if (mdhdHeadCommon.language==0) warnprint("Warning: Media Header language code of 0 not strictly legit -- 'und' preferred\n");
atomprint(">\n");
// Check required field values
FieldMustBe( flags, 0, "'mdvd' flags must be %d not %d" );
FieldMustBe( mdhdHeadCommon.quality, 0, "'mdhd' quality (reserved in mp4) must be %d not %d" );
FieldCheck( (mdhdHead.duration > 0 || vg.dashSegment), "'mdhd' duration must be > 0" );
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
OSErr Get_mdia_hdlr_mediaType( atomOffsetEntry *aoe, TrackInfoRec *tir )
{
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
HandlerInfoRecord hdlrInfo;
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
BAILIFERR( GetFileData( aoe, &hdlrInfo, offset, (UInt64)fieldOffset(HandlerInfoRecord, Name), &offset ) );
tir->mediaType = EndianU32_BtoN(hdlrInfo.componentSubType);
bail:
return err;
}
OSErr Validate_mdia_hdlr_Atom( atomOffsetEntry *aoe, void *refcon )
{
TrackInfoRec *tir = (TrackInfoRec *)refcon;
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
HandlerInfoRecord *hdlrInfo = (HandlerInfoRecord *)malloc(sizeof(HandlerInfoRecord));
char *nameP;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
FieldMustBe( version, 0, "version must be %d not %d" );
FieldMustBe( flags, 0, "flags must be %d not %d" );
// Get Handler Info (minus name)
BAILIFERR( GetFileData( aoe, hdlrInfo, offset, (UInt64)fieldOffset(HandlerInfoRecord, Name), &offset ) );
hdlrInfo->componentType = EndianU32_BtoN(hdlrInfo->componentType);
hdlrInfo->componentSubType = EndianU32_BtoN(hdlrInfo->componentSubType);
hdlrInfo->componentFlags = EndianU32_BtoN(hdlrInfo->componentFlags);
hdlrInfo->componentFlagsMask = EndianU32_BtoN(hdlrInfo->componentFlagsMask);
hdlrInfo->componentFlags = EndianU32_BtoN(hdlrInfo->componentFlags);
hdlrInfo->componentFlags = EndianU32_BtoN(hdlrInfo->componentFlags);
// Remember info in the refcon
if (vg.print_atompath) {
fprintf(stdout,"\t\tHandler subtype = '%s'\n", ostypetostr(hdlrInfo->componentSubType));
}
tir->mediaType = hdlrInfo->componentSubType;
atomprint("handler_type=\"%s\"\n", ostypetostr(hdlrInfo->componentSubType));
// Get Handler Info Name
BAILIFERR( GetFileCString( aoe, &nameP, offset, aoe->maxOffset - offset, &offset ) );
//atomprint("name=\"%s\"\n", nameP);
// Check required field values
FieldMustBe( hdlrInfo->componentType, 0, "'hdlr' componentType (reserved in mp4) must be %d not 0x%lx" );
FieldMustBe( hdlrInfo->componentManufacturer, 0, "'hdlr' componentManufacturer (reserved in mp4) must be %d not 0x%lx" );
FieldMustBe( hdlrInfo->componentFlags, 0, "'hdlr' componentFlags (reserved in mp4) must be %d not 0x%lx" );
FieldMustBe( hdlrInfo->componentFlagsMask, 0, "'hdlr' componentFlagsMask (reserved in mp4) must be %d not 0x%lx" );
FieldMustBeOneOf12( hdlrInfo->componentSubType, OSType,
"'hdlr' handler type must be be one of ",
('odsm', 'crsm', 'sdsm', 'vide', 'soun', 'm7sm', 'ocsm', 'ipsm', 'mjsm', 'hint', 'subt', 'text') );
//Explicit check for ac-4
if(!strcmp(vg.codecs, "ac-4") && strcmp(ostypetostr(hdlrInfo->componentSubType),"soun"))
errprint("handler_type is not 'soun', 'soun' is expected for 'ac-4'\n" );
//Explicit check for ec-3
if(!strcmp(vg.codecs, "ec-3") && strcmp(ostypetostr(hdlrInfo->componentSubType),"soun"))
errprint("handler_type is not 'soun', 'soun' is expected for 'ec-3'\n" );
//Explicit check for ac-3
if(!strcmp(vg.codecs, "ac-3") && strcmp(ostypetostr(hdlrInfo->componentSubType),"soun"))
errprint("handler_type is not 'soun', 'soun' is expected for 'ac-3'\n" );
tir->hdlrInfo = hdlrInfo;
// All done
atomprint(">\n");
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
OSErr Validate_hdlr_Atom( atomOffsetEntry *aoe, void *refcon )
{
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
HandlerInfoRecord *hdlrInfo = (HandlerInfoRecord *)malloc(sizeof(HandlerInfoRecord));
char *nameP;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
FieldMustBe( version, 0, "version must be %d not %d" );
FieldMustBe( flags, 0, "flags must be %d not %d" );
// Get Handler Info (minus name)
BAILIFERR( GetFileData( aoe, hdlrInfo, offset, (UInt64)fieldOffset(HandlerInfoRecord, Name), &offset ) );
hdlrInfo->componentType = EndianU32_BtoN(hdlrInfo->componentType);
hdlrInfo->componentSubType = EndianU32_BtoN(hdlrInfo->componentSubType);
hdlrInfo->componentFlags = EndianU32_BtoN(hdlrInfo->componentFlags);
hdlrInfo->componentFlagsMask = EndianU32_BtoN(hdlrInfo->componentFlagsMask);
hdlrInfo->componentFlags = EndianU32_BtoN(hdlrInfo->componentFlags);
hdlrInfo->componentFlags = EndianU32_BtoN(hdlrInfo->componentFlags);
// Remember info in the refcon
if (vg.print_atompath) {
fprintf(stdout,"\t\tHandler subtype = '%s'\n", ostypetostr(hdlrInfo->componentSubType));
}
atomprint("handler_type=\"%s\"\n", ostypetostr(hdlrInfo->componentSubType));
// Get Handler Info Name
BAILIFERR( GetFileCString( aoe, &nameP, offset, aoe->maxOffset - offset, &offset ) );
atomprint("name=\"%s\"\n", nameP);
// Check required field values
FieldMustBe( hdlrInfo->componentType, 0, "'hdlr' componentType (reserved in mp4) must be %d not 0x%lx" );
FieldMustBe( hdlrInfo->componentManufacturer, 0, "'hdlr' componentManufacturer (reserved in mp4) must be %d not 0x%lx" );
FieldMustBe( hdlrInfo->componentFlags, 0, "'hdlr' componentFlags (reserved in mp4) must be %d not 0x%lx" );
FieldMustBe( hdlrInfo->componentFlagsMask, 0, "'hdlr' componentFlagsMask (reserved in mp4) must be %d not 0x%lx" );
// All done
atomprint(">\n");
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
OSErr Validate_elng_Atom( atomOffsetEntry *aoe, void *refcon )
{
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
char* extended_languages;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
// Get related attributes
BAILIFERR( GetFileCString( aoe, &extended_languages, offset, aoe->maxOffset - offset, &offset ) );
atomprint("extended_languages=\"%s\"\n", extended_languages);
atomprint(">\n");
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
typedef struct VideoMediaInfoHeader {
UInt16 graphicsMode; /* for QD - transfer mode */
UInt16 opColorRed; /* opcolor for transfer mode */
UInt16 opColorGreen;
UInt16 opColorBlue;
} VideoMediaInfoHeader;
OSErr Validate_vmhd_Atom( atomOffsetEntry *aoe, void *refcon )
{
#pragma unused(refcon)
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
VideoMediaInfoHeader vmhdInfo;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// Get data
BAILIFERR( GetFileData( aoe, &vmhdInfo, offset, sizeof(vmhdInfo), &offset ) );
vmhdInfo.graphicsMode = EndianU16_BtoN(vmhdInfo.graphicsMode);
vmhdInfo.opColorRed = EndianU16_BtoN(vmhdInfo.opColorRed);
vmhdInfo.opColorGreen = EndianU16_BtoN(vmhdInfo.opColorGreen);
vmhdInfo.opColorBlue = EndianU16_BtoN(vmhdInfo.opColorBlue);
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint(">\n");
if(vg.cmaf){
if(version != 0){
errprint("CMAF check violated: Section 7.5.6. \"The following field SHALL be set to its default value: version=0\", found %d\n",version);
}
if(vmhdInfo.graphicsMode != 0){
errprint("CMAF check violated: Section 7.5.6. \"The following field SHALL be set to its default value: graphicsmode=0\", found %d\n",vmhdInfo.graphicsMode);
}
if(vmhdInfo.opColorRed != 0 && vmhdInfo.opColorGreen != 0 && vmhdInfo.opColorBlue != 0){
errprint("CMAF check violated: Section 7.5.6. \"The following field SHALL be set to its default value: opcolor={0, 0, 0}\", found {0x%lx, 0x%lx, 0x%lx}\n",vmhdInfo.opColorRed, vmhdInfo.opColorGreen, vmhdInfo.opColorBlue);
}
}
// Check required field values
FieldMustBe( version, 0, "'vmhd' version must be %d not %d" );
FieldMustBe( flags, 1, "'vmhd' flags must be %d not 0x%lx" );
FieldMustBe( vmhdInfo.graphicsMode, 0, "'vmhd' graphicsMode (reserved in mp4) must be %d not 0x%lx" );
FieldMustBe( vmhdInfo.opColorRed, 0, "'vmhd' opColorRed (reserved in mp4) must be %d not 0x%lx" );
FieldMustBe( vmhdInfo.opColorGreen, 0, "'vmhd' opColorGreen (reserved in mp4) must be %d not 0x%lx" );
FieldMustBe( vmhdInfo.opColorBlue, 0, "'vmhd' opColorBlue (reserved in mp4) must be %d not 0x%lx" );
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
typedef struct SoundMediaInfoHeader {
UInt16 balance;
UInt16 rsrvd;
} SoundMediaInfoHeader;
OSErr Validate_smhd_Atom( atomOffsetEntry *aoe, void *refcon )
{
#pragma unused(refcon)
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
SoundMediaInfoHeader smhdInfo;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// Get data
BAILIFERR( GetFileData( aoe, &smhdInfo, offset, sizeof(smhdInfo), &offset ) );
smhdInfo.balance = EndianU16_BtoN(smhdInfo.balance);
smhdInfo.rsrvd = EndianU16_BtoN(smhdInfo.rsrvd);
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint(">\n");
// Check required field values
FieldMustBe( flags, 0, "'smhd' flags must be %d not 0x%lx" );
FieldMustBe( smhdInfo.balance, 0, "'smhd' balance (reserved in mp4) must be %d not %d" );
FieldMustBe( smhdInfo.rsrvd, 0, "'smhd' rsrvd must be %d not 0x%lx" );
if(vg.cmaf && smhdInfo.balance !=0)
errprint("CMAF check violated: Section 7.5.7. \"The balance field in SoundMediaHeaderBox SHALL be set to its default value 0\", found %d\n",smhdInfo.balance);
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
typedef struct HintMediaInfoHeader {
UInt16 maxPDUsize;
UInt16 avgPDUsize;
UInt32 maxbitrate;
UInt32 avgbitrate;
UInt32 slidingavgbitrate;
} HintMediaInfoHeader;
OSErr Validate_hmhd_Atom( atomOffsetEntry *aoe, void *refcon )
{
#pragma unused(refcon)
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
HintMediaInfoHeader hmhdInfo;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// Get data
BAILIFERR( GetFileData( aoe, &hmhdInfo, offset, sizeof(hmhdInfo), &offset ) );
hmhdInfo.maxPDUsize = EndianU16_BtoN(hmhdInfo.maxPDUsize);
hmhdInfo.avgPDUsize = EndianU16_BtoN(hmhdInfo.avgPDUsize);
hmhdInfo.maxbitrate = EndianU32_BtoN(hmhdInfo.maxbitrate);
hmhdInfo.avgbitrate = EndianU32_BtoN(hmhdInfo.avgbitrate);
hmhdInfo.slidingavgbitrate = EndianU32_BtoN(hmhdInfo.slidingavgbitrate);
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint("maxPDUsize=\"%ld\"\n", hmhdInfo.maxPDUsize);
atomprint("avgPDUsize=\"%ld\"\n", hmhdInfo.avgPDUsize);
atomprint("maxbitrate=\"%ld\"\n", hmhdInfo.maxbitrate);
atomprint("avgbitrate=\"%ld\"\n", hmhdInfo.avgbitrate);
atomprint("slidingavgbitrate=\"%ld\"\n", hmhdInfo.slidingavgbitrate);
atomprint(">\n");
// Check required field values
FieldMustBe( flags, 0, "'hmdh' flags must be %d not 0x%lx" );
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
OSErr Validate_sthd_Atom( atomOffsetEntry *aoe, void *refcon )
{
#pragma unused(refcon)
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint(">\n");
// Check required field values
FieldMustBe( flags, 0, "'sthd' flags must be %d not 0x%lx" );
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
OSErr Validate_nmhd_Atom( atomOffsetEntry *aoe, void *refcon )
{
#pragma unused(refcon)
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// There is no data
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint(">\n");
//����� need to check for underrun
// Check required field values
FieldMustBe( flags, 0, "'nmhd' flags must be %d not 0x%lx" );
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
OSErr Validate_mp4s_Atom( atomOffsetEntry *aoe, void *refcon )
{
#pragma unused(refcon)
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// There is no data
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint("/>\n");
// Check required field values
FieldMustBe( flags, 0, "'mp4s' flags must be %d not 0x%lx" );
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
OSErr Validate_url_Entry( atomOffsetEntry *aoe, void *refcon )
{
#pragma unused(refcon)
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
char *locationP = nil;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// Get data
if (flags & 1) {
// no more data
} else {
if(vg.dashSegment)
errprint("url pointing to external data found in 'dref', violating ISO/IEC 23009-1:2012(E), 6.3.4.2: The 'moof' boxes shall use movie-fragment relative addressing for media data that does not use external data references.\n");
BAILIFERR( GetFileCString( aoe, &locationP, offset, aoe->maxOffset - offset, &offset ) );
}
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
if (locationP) {
atomprint("location=\"%s\"\n", locationP);
}
atomprint("/>\n");
// Check required field values
//��� FieldMustBe( flags, 0, "'mp4s' flags must be 0" );
//��� need to check that the atom has ended.
if(vg.cmaf && flags != 0x000001){
errprint("CMAF check violated: Section 7.5.9. \"The Data Reference Box ('dref') SHALL contain a single entry with the entry_flags set to 0x000001 \", found 0x%lx\n", flags); //Single entry has been checked in 'dref' validation.
}
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
OSErr Validate_urn_Entry( atomOffsetEntry *aoe, void *refcon )
{
#pragma unused(refcon)
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
char *nameP = nil;
char *locationP = nil;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
if ((flags & 1) == 0 && vg.dashSegment)
errprint("urn entry with pointing to external data found in 'dref', violating ISO/IEC 23009-1:2012(E), 6.3.4.2: The 'moof' boxes shall use movie-fragment relative addressing for media data that does not use external data references.\n");
// Get data
// name is required
BAILIFERR( GetFileCString( aoe, &nameP, offset, aoe->maxOffset - offset, &offset ) );
if (offset >= (aoe->offset + aoe->size)) {
BAILIFERR( GetFileCString( aoe, &locationP, offset, aoe->maxOffset - offset, &offset ) );
}
// Print atom contents non-required fields
atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags);
atomprint("name=\"%s\"\n", nameP);
if (locationP) {
atomprint("location=\"%s\"\n", locationP);
}
atomprint("/>\n");
// Check required field values
//��� FieldMustBe( flags, 0, "'mp4s' flags must be 0" );
//��� need to check that the atom has ended.
if(vg.cmaf && flags != 0x000001){
errprint("CMAF check violated: Section 7.5.9. \"The Data Reference Box ('dref') SHALL contain a single entry with the entry_flags set to 0x000001 \", found 0x%lx\n", flags); //Single entry has been checked in 'dref' validation.
}
// All done
aoe->aoeflags |= kAtomValidated;
bail:
return err;
}
//==========================================================================================
OSErr Validate_dref_Atom( atomOffsetEntry *aoe, void *refcon )
{
#pragma unused(refcon)
OSErr err = noErr;
UInt32 version;
UInt32 flags;
UInt64 offset;
UInt32 entryCount;
// Get version/flags
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
// Get data
BAILIFERR( GetFileDataN32( aoe, &entryCount, offset, &offset ) );
if(vg.cmaf && entryCount != 1){
errprint("CMAF check violated: Section 7.5.9. \"The Data Reference Box ('dref') SHALL contain a single entry \", found %ld\n", entryCount);
}
// Print atom contents non-required fields