-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontype
1922 lines (1707 loc) · 32.1 KB
/
contype
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
struct contype {
MIBenum encoding : 12
uint supertype : 2
uint subtype : 18
// optional
}
struct WebContype {
uint encoding : 3; // text encodings assume UTF-8 and perform encoding checks for other unicode variants
uint class : 5; // root = composite
uint type : 8;
}
lil ... big
0 binary
1 text
00 misc 0
0... unknown 0
10 primitive 4
10 int 20
01 real 36
11 string 52
01 composite 8
11 technical 12
10 media 1
100 audio 5
010 image 9
110 video 13
001 model 17
101 doc 21
011 style 25
111 multi 29
01 exec 2
10 object 6
01 source 10
11 script 14
11 meta 3
0... metatype
100 protocol 72
010 fs 11
10 file 45
01 directory 75
11 link 59
110 archive 15
001 app 19
10 vendor 45
01 vanity 77
11 example 109
101 config 23
011
111
unknown
int
real
string
composite
technical
audio
image
video
model
doc
style
multi
object
source
script
protocol
fs
archive
app
config
u1 text/binary
u5 class
What we want to encode in order of importance:
* actual file type
* encoding (binary/various text encodings)
* class
* embedder syntax (xml, json, yaml, etc)
What is the point of having a prefix code? I cited future-proofing, but you'd have about as much proofing by incrementing the largest id. Prefix codes allow for determination of the general category of an unrecognized type? But the class isn't expected to change all that much, most of the novelty comes in the form of specific ids.
Goal: Provide a unique 32-bit identifier for all common data formats, allowing for variations in encoding, with a human-readable textual representation
Goal: Perfect interoperability with MIME
* Any valid MIME type can be interpreted as a contype
* ;charset=* -> contype prefix
* Alias classes
- application/*
- chemical/*
- text/*
- model/* -> image/3d/*
- example/*
- message/* -> meta/*
- multipart/* -> meta/*
- font/* -> style/font/*
- vnd.* -> app/*
- example/* -> meta/example
- prs.* -> meta/vanity
- x.* or x-* -> search for *
Formats:
* var-contype
- Contype using LEB128 encoding, variable size
* micro-contype
- single byte encoding of the top 256 most common formats
- expected to be volatile, not for long-term use
* web-contype
- two byte encoding of "websafe" formats - removes alternate text encodings, deprecated, obsolete, legacy, and rare formats
- much more stable but doesn't support obscure contypes
* contype
- four bytes encoding many formats and encodings
- canonical format, integer value guaranteed to be stable
* ex-contype
- eight bytes, contype + another four bytes describing extra metadata which may be found in the file itself (eg ogg mp3 and ogg vorbis would have different contype extensions)
To enable future-proofing, classes "grow" MSB to LSB, whereas types "grow" LSB to MSB, essentially creating a "wall" of zero bits between the two. Thus old standards are preserved, and new standards can make use of the unused bits, which older implementations will recognize as an unknown class/type
Text to binary representation conversion:
* Everything is case insensitive
* Classes and subclasses are collated into a flat set of the maximally expanded subclasses such that there are no duplicates
* Get subset of classes with the provided class in their hierarchy
* Search for the subtype in a collated alias table
*
* For example, media/png and image/png result in the same binary contype
Type entry fields:
parent: strict superset (eg xml)
tags:
magic:
extensions: (in order of preference), may be empty
standards: (converting to other enumerations eg mime, iso, rfc)
names: (in order of preference)
related: (other formats which can be losslessly converted to)
format: description of how to decompose the format into subtypes
Standard tags:
#fourcc
#deprecated - don't generate such files, but they can be kept in their current format
#obsolete - attempts should be made to convert to equivalent formats (lest they lose all compatibility) and generating the format is forbidden. Anything #obsolete is guaranteed to have at least one injective alternative
#legacy - modern formats made to interface with obsolete technology, eg emulator files
#proprietary - created/owned by a private organization
#protected - legally protected, implementing decoding may be illegal
#unknown - format is known to exist, but its encoding is unknown (needs to be reverse-engineered)
#lossy - converting to this format will lose information
#lossless - no information will be lost while converting
#nonstandard - not accepted by a recognized standardization authority
#unbroken-crypto - some or all of the file's structure is behind some kind of cryptography, often for DRM purposes
#cat:<category> - used for alias classes
Encoding names:
* case-insensitive, has normal form
* a-z, 0-9, -
Encodings can differentiate format encodings if:
* Formats are binary and textual
* An encoding is "binary" if it has the type "binary" or is binary encoding
[encoding:]class.../type[+subtype][;attr=value...]
* Each type has an assumed encoding which allows it to be excluded
* Class may have multiple components separated by slashes
Textual binary encodings:
* All are assumed to be subsets of ASCII
* Intended for arbitrary data encoding
* 00 binary
* 01 text
* 02 percent (hex escaped)
* 03 base32 - human readable
* 04 base64
- Different formats can be disambiguated with content scanning:
- base64 +/ =
- base64url -_ =
- base64yui ._ -
- base64fs +_ =
* 05 dul58 - bitcoin addresses and IPFS hashes
* 06 multibase
* 07 unknown - for unknown/unsupported encodings, overloaded in webcontype with "anything that doesn't fit in 3 bits"
* Encodings after this are excluded from webcontype
* 08 hex
* 09 qp "quoted parsable"
* 10 base32hex - contiguous
* 11 zbase32
* 12 base36
* 13 dlu58
* 14 uuenc
* 15 xxenc
* 16 binhex
* 17 6pack
* 18 btoa85
* 19 adobe85
* 20 yEnc
Type names:
* Case-insensitive, have normal form (which may be cased)
* a-z, 0-9, -, +, .
* Classes are alpha-only
0 primitive
00 int
--- split middle
0 static size
0 unsigned
0 le
blob bit nibble byte
16 24 32 48 64 128 256
1 be
1 signed
0 le
1 be
00 blob
01 u16-le
02 u24-le
03 u32-le
04 u48-le
05 u64-le
06 u128-le
07 u256-le
08 bit
09 u16-be
10 u24-be
11 u32-be
12 u48-be
13 u64-be
14 u128-be
15 u256-be
16 nibble
17 s16-le
18 s24-le
19 s32-le
20 s48-le
21 s64-le
22 s128-le
23 s256-le
24 byte
25 s16-be
26 s24-be
27 s32-be
28 s48-be
29 s64-be
30 s128-be
31 s256-be
1 varint
00 uleb128
01 sleb128
02 vlq
03 vlq+git
04 zigzag
05 clzprefix // # bytes = clz(first), rest is data
06 lesqlite
07 lesqlite2
08 vbr / llvm-varint
09 dlugosz
01 real
ms-float32 (microsoft binary format)
ms-float40
ms-float64
ibm-hexfloat
ieee-float8
ieee-float16
ieee-float32
ieee-float64
ieee-float128
ieee-float256
bfloat16
nvidia-tensorfloat
amd-fp24
fixed
10 string
cstring
pstring8
pstring16
pstring24
pstring32
hollerith
gcc-mangle
11 struct
bitfield
bits4 8 16 32
color
rgb24
rgba8888
argb8888
abgr8888
grey8
cymk
hsv
hsl
time
1 composite
00 data
config
crypto
digest
hash
crc
encrypt
technical
bibliography
apa
mla
chicago
abstract
ref
bool
char
number
string
enum
list
map
app
proprietary
app/progname+extra
01 media
000 multi
001 audio
010 style
011 image
3d
100 video
101 doc
110
111
10 exec
00 code - machine code / bytecode
01
10 source
11 script
11 meta
stream
proto
http
ftp
ssh
mqtt
archive - data that contains data
fs
file
directory
stat
device
loop
tty
mount
special
symlink
(hardlink) - no way to distinguish?
sparse
tmp
empty
shadow
pipe
socket
---
data = 00
blob
config
xml
json
yaml
ini
htaccess
crypto
codec
lz
lzw
lz77
ppm
huffman
deflate
shannon-fano
fast-fourier
hadamard
discrete-cosine dct
vorbis
mp3
flac
shorten
tta
alac
mpeg-4-als
wma-9
monkey
wavpack
mdct
lpc
dpcm
adpcm
apc
celp
aac
motion compensation
discrete wavelet transform
cabac
cavlc
avc
hapzipper
mafe
dnazip
genomezip
elias-gamma
elias-delta
elias-omega
exp-golomb
fibonacci
levenshtein
unary
rice
golomb
lpcm
pcm
pdm
dsd
pam
optimfrog
tak
tta
wmal
dts-hd
dolby truehd
meridian lossless packing packed pcm
mpeg-4 als
mpeg-4 sls
realaudio
bfd lossless audio Compression
atrac advanced lossless
direct stream transfer
original sound quality
lossless audio - discontinued
shorten - discontinued
lpac
ltac
mp3 - discontinued
usac
opus
ietf ipmr speech codec
atrac
dolby digital ac3 atsc a/52 etsi ts 102 366
dolby digital+
dts coherent acoustics
dolby ac-4
impala
itu
g.711
g.711.0
g.711.1
g.718
g.718b
g.722b
g.719
g.722
g.722.1
g.722.2
g.723
g.723.1
g.726
g.728
g.729
g.729a
g.729d
g.729.1
g.729.1e
hiln
twinvq
bsac
mpeg-h
musepack
at&t perceptual audio coder
pasc
qdesign
picturetel
siren 7
siren 14
sire 22
ntt twinvq
voxware
aes3
smpte
dolbe e
sbc
cvsd 8khz
msbc
lc3
etsi
aptx
aptx-hd
aptx-low-latency
aptx-Adaptive
faststream
ldac
lhdc
llac
uat
hd/uhq-bt
scalable codec
nrsc-5
speex
isac
asao
picture tel pt716
pt724
rtaudio
svopc
openlpc
ansi/scte
ilbc
evs
mplp
inmarsat-m imbe
voxware metavoice
truespeech
ms-gsm
ms-adpcm
dss-sp
dss-qp
micronas intermetall sc4 mi-sc4
lpec
truespeech triple rate coder
int
#min
#max
#string
sleb128
uleb128
msbc-sint // msb set = continue
msbc-uint
msbcc-sint // msb unset = continue
msbcc-uint
bit
nibble
bitfield
real
ms-float32 (microsoft binary format)
ms-float40
ms-float64
ibm-hexfloat
ieee-float8
ieee-float16
ieee-float32
ieee-float64
ieee-float128
ieee-float256
bfloat16
nvidia-tensorfloat
amd-fp24
ieee-754 / iec-60559
ieee float
fixed
enum
#values
enum+int
MIBenum
UCS
contype
enum+string
enum+bool
string
cstring
pstring8
pstring16
pstring24
pstring32
hollerith
gcc-mangle
color
hexcolor
xorg-color
css-color
websafe
rgba
rgba8888
argb8888
abgr8888
grey8
bgr
gbr
rgba
cmyk
hsl
hsv
ycc
time
unix
unix+ms
unix+us
unix+ns
iso-balbla
reference
cookie
media = 01
audio
fullname: Audible (Amazon.com)
names: audio/aa
tags: unbroken-drm
related: aax, mp4
fullname: Advanced Audio Coding
names: audio/aac
tags: lossy codec
extensions:
standards:
iso: 13818-7, 14496-3
mime: audio/aac, audio/aacp
rfc: 3016, 3640, 4281, 4337
fullname: Audio Data Interchange Format
names: audio/adif
tags: container
parent: iso-68960
fullname: Audio Data Transport Stream
names: stream/adts
tags: audio
extensions: adts
fullname: Audible Enhanced Audiobook
names: audio/aax
extensions: aax
names: audio/act
related: mp4
fullname: Audio Interchange File Format
names: audio/aiff
extensions: aiff, aif, aifc
tags: uncompressed
parent: archive/iff
related: aiff-c, aifc
standards:
mime: audio/x-aiff, audio/aiff
type code: aiff, aifc
uti: public.aiff-audio, public.aifc-audio
fullname: Apple Lossless Audio Codec
names: audio/alac, audio/ale
extensions: alac
tags: lossless codec
fullname: Core Audio Format
names: audio/caf
extensions: caf
standards:
mime: audio/x-caf
fullname: Adaptive Multi-Rate
names: audio/amr
extensions: amr
tags: codec
related: audio/3gpp, audio/3gpp2
standards:
mime: audio/amr
fullame: Monkey's Audio
names: audio/monkey
extensions: ape, apl
tags: lossless
names: audio/au
magic: .snd
extensions: au, snd
standards:
mime: audio/basic
fullname: Adaptive Multi-Rate Wideband
names: audio/amr-wb
extensions: awb
tags: codec
standards:
mime: audio/amr-wb
itu-t: G.722.2
names: audio/dct
extensions: dct
tags: container
fullname: Digital Speech Standard
names: audio/dss
extensions: dss
tags: proprietary lossy
names: audio/dvf
extensions: dvf
tags: proprietary
related: audio/wav
fullname: Free Lossless Audio Codec
magic: fLaC
extensions: flac
tags: open-source lossless codec
standards:
mime: audio/flac
uti: org.xiph.flac
names: audio/gsm
extensions: gsm, fr
tags: lossy codec
standards:
etsi: 300 961
fullname: iKlax
names: audio/iklax
tags: open-source
standards:
mime: audio/iklax
arXiv: 0901.3902
fullname: Internet Video Streaming
names: audio/ivs
tags: proprietary container
fullname: Synthetic music Mobile Application Format
names: audio/mmf
extensions: mmf, smaf
fullname: MPEG-2 Audio Layer III
names: audio/mp3
extensions: mp3, bit
tags: lossy codec
standards:
mime: audio/mpeg, audio/mpa, audio/mpa-robust
fullname: Musepack
names: audio/musepack
magic: MPCK, MP+
extensions: mpc, mp+, mpp
tags: lossy codec
standards:
mime: audio/x-musepack, audio/musepack
fullname: Memory Stick compressed Voice files
names: audio/msv
tags: proprietary lossy
fullname: NICE Media player audio File
names: audio/nice
extensions: nmf
tags: proprietary
fullname: NES Sound Format
names: audio/nes
tags: legacy proprietary
fullname: Ogg
names: audio/ogg, video/ogg
magic: OggS
extensions: ogg, ogv, oga, mogg, ogx, ogm, spx, opus
tags: open-source container
standards:
mime: video/ogg, audio/ogg, application/ogg
fullname: Opus
names: audio/opus
extensions: opus
tags: lossy codec
standards:
mime: audio/opus
rfc: 6716
fullname: RealAudio
names: audio/realaudio, stream/realaudio
extensions: ra, ram
tags: proprietary container
standards:
mime: audio/vnd.rn-realaudio, audio/x-pn-realaudio
fullname: Pulse-Code Modulation 8-bit
names: audio/pcm8
extensions: l8, pcm, raw
tags: uncompressed codec
standards:
mime: audio/L8
fullname: Pulse-Code Modulation 16-bit
names: audio/pcm16
extensions: l16, pcm, raw
tags: uncompressed codec
standards:
mime: audio/L16
fullname: Pulse-Code Modulation 20-bit
names: audio/pcm20
extensions: l20, pcm
tags: uncompressed codec
standards:
mime: audio/L20
fullname: Pulse-Code Modulation 24-bit
names: audio/pcm24
extensions: l24, pcm
tags: uncompressed codec
standards:
mime: audio/L24
fullname: Signed Linear Pulse-Code Modulation
names: audio/spcm16
extensions: l16, pcm
tags: uncompressed codec
fullname: Wave
name: audio/wave
parent: media/exif
extensions: wav, rf64, bwf
tags: uncompressed container
fullname: The True Audio
names: audio/trueaudio
extensions: tta
tags: lossless codec
standards:
mime: audio/x-tta
fullname: Creative Voice
names: audio/creative
magic: Creative Voice File\x1a\x1a\0
extensions: voc
tags: container
fullname: Dialogic ADPCM
names: audio/dialogic
extensions: vox
tags: lossy
fullname: Windows Media Audio
names: audio/wma
extensions: wma
tags: proprietary codec
fullname: WavPack
names: audio/wavpack
tags: open-source lossless container
extensions: wv
related: audio/wave
fullname: WebM
names: audio/webm, video/webm (media/webm?)
tags: open-source container
extensions: webm
standards:
mime: video/webm, audio/webm
fullname: 8-Bit Sampled Voice
names: audio/8svx
parent: iff
tags: container
standards:
mime: audio/x-8svx
fullname: Compact Disc Digital Audio
names: audio/cdda
extensions: cda
fullname: Game Boy Advance Song File
names: audio/gba
extensions: minigsf
image
#raster
#lossy
#lossless
#vector
#obsolete (objectively better formats exist)
#deprecated
fullname: Windows Animated Cursor
names: anim/ms-cursor
extensions: ani
fullname: Windows Icon
names: image/ms-icon
exensions: ico, cur
fullname: Amiga Animation File
names: anim/amiga
parent: iff
fullname: AOL Compressed Image File
names: anim/aol
extensions: art
fullname: CALS Raster
names: image/cals
extensions: cal
fullname: CPC Compressed Image
names: image/cpc
extensions: cpc
tags: monochrome
fullname: DirectDraw Surface
names: image/directdraw
extensions: dds
fullname: OpenEXR Image
names: image/openexr
extensions: exr
names: anim/autodesk
extensions: flic
fullname: FlashPix Bitmap Image
names: image/flashpix
extensions: fpx
fullname: High Efficiency Video Coding
names: video/h.265
extensions: hevc
fullname: MacOS Icon Resource
names: image/mac-icon
extensions: icns
fullname: Joint Bi-level Image
names: image/jbig
extensions: jbg, jbig
standards:
iso: 11544
itu-t: T.82, T.85
fullname: Joint Bi-level Image 2
names: image/jbig2
extensions: jbg, jbig2
standards:
itu: T.88
iso: 14492
fullname: JPEG Network Graphics
names: image/jng
extensions: jng
fullname: Magick Image File Format
names: image/magick
extensions: miff
fullname: Ulead PhotoImpact
names: image/photoimpact, app/photoimpact (?)
extensions: ufo, ufp
fullname: Wireless Application Protocol Bitmap
names: image/wbmp
extensions: wbmp
standards:
mime: image/vnd.wap.wbmp
fullname: WebP
names: image/webp
magic:
offset: 8
value: "WEBPVP8 "
extensions: webp
parent: riff
fullname: X Bitmap
names: image/x-bitmap
extensions: xbm
standards:
mime: image/x-xbitmap, image/x-xbm
fullname: X Pixmap 1
names: image/x-pixmap1
extensions: xpm
fullname: X Pixmap 2
names: image/x-pixmap2
extensions: xpm
fullame: X Pixmap 3
names: image/x-pixmap3