riff revision 186690
168349Sobrien
268349Sobrien#------------------------------------------------------------------------------
368349Sobrien# riff:  file(1) magic for RIFF format
468349Sobrien# See
568349Sobrien#
668349Sobrien#	http://www.seanet.com/users/matts/riffmci/riffmci.htm
768349Sobrien#
8133359Sobrien# AVI section extended by Patrik R�dman <patrik+file-magic@iki.fi>
968349Sobrien#
1068349Sobrien0	string		RIFF		RIFF (little-endian) data
1168349Sobrien# RIFF Palette format
1268349Sobrien>8	string		PAL		\b, palette
1368349Sobrien>>16	leshort		x		\b, version %d
1468349Sobrien>>18	leshort		x		\b, %d entries
1568349Sobrien# RIFF Device Independent Bitmap format
1668349Sobrien>8	string		RDIB		\b, device-independent bitmap
1768349Sobrien>>16	string		BM		
1868349Sobrien>>>30	leshort		12		\b, OS/2 1.x format
1968349Sobrien>>>>34	leshort		x		\b, %d x
2068349Sobrien>>>>36	leshort		x		%d
2168349Sobrien>>>30	leshort		64		\b, OS/2 2.x format
2268349Sobrien>>>>34	leshort		x		\b, %d x
2368349Sobrien>>>>36	leshort		x		%d
2468349Sobrien>>>30	leshort		40		\b, Windows 3.x format
2568349Sobrien>>>>34	lelong		x		\b, %d x
2668349Sobrien>>>>38	lelong		x		%d x
2768349Sobrien>>>>44	leshort		x		%d
2868349Sobrien# RIFF MIDI format
2968349Sobrien>8	string		RMID		\b, MIDI
3068349Sobrien# RIFF Multimedia Movie File format
3168349Sobrien>8	string		RMMP		\b, multimedia movie
32169942Sobrien# RIFF wrapper for MP3
33169942Sobrien>8	string		RMP3		\b, MPEG Layer 3 audio
3468349Sobrien# Microsoft WAVE format (*.wav)
3568349Sobrien>8	string		WAVE		\b, WAVE audio
36186690Sobrien!:mime	audio/x-wav
3768349Sobrien>>20	leshort		1		\b, Microsoft PCM
3868349Sobrien>>>34	leshort		>0		\b, %d bit
3980588Sobrien>>20	leshort		2		\b, Microsoft ADPCM
40133359Sobrien>>20	leshort		6		\b, ITU G.711 A-law
41133359Sobrien>>20	leshort		7		\b, ITU G.711 mu-law
4280588Sobrien>>20	leshort		17		\b, IMA ADPCM
4380588Sobrien>>20	leshort		20		\b, ITU G.723 ADPCM (Yamaha)
4480588Sobrien>>20	leshort		49		\b, GSM 6.10
4580588Sobrien>>20	leshort		64		\b, ITU G.721 ADPCM
4680588Sobrien>>20	leshort		80		\b, MPEG
4780588Sobrien>>20	leshort		85		\b, MPEG Layer 3
4868349Sobrien>>22	leshort		=1		\b, mono
4968349Sobrien>>22	leshort		=2		\b, stereo
5068349Sobrien>>22	leshort		>2		\b, %d channels
5168349Sobrien>>24	lelong		>0		%d Hz
52133359Sobrien# Corel Draw Picture
53133359Sobrien>8	string		CDRA		\b, Corel Draw Picture
54186690Sobrien!:mime	image/x-coreldraw
5568349Sobrien# AVI == Audio Video Interleave
56133359Sobrien>8	string		AVI\040		\b, AVI
57186690Sobrien!:mime	video/x-msvideo
58133359Sobrien>>12    string          LIST
59133359Sobrien>>>20   string          hdrlavih
60133359Sobrien>>>>&36 lelong          x               \b, %lu x
61133359Sobrien>>>>&40 lelong          x               %lu,
62133359Sobrien>>>>&4  lelong          >1000000        <1 fps,
63133359Sobrien>>>>&4  lelong          1000000         1.00 fps,
64133359Sobrien>>>>&4  lelong          500000          2.00 fps,
65133359Sobrien>>>>&4  lelong          333333          3.00 fps,
66133359Sobrien>>>>&4  lelong          250000          4.00 fps,
67133359Sobrien>>>>&4  lelong          200000          5.00 fps,
68133359Sobrien>>>>&4  lelong          166667          6.00 fps,
69133359Sobrien>>>>&4  lelong          142857          7.00 fps,
70133359Sobrien>>>>&4  lelong          125000          8.00 fps,
71133359Sobrien>>>>&4  lelong          111111          9.00 fps,
72133359Sobrien>>>>&4  lelong          100000          10.00 fps,
73133359Sobrien# ]9.9,10.1[
74133359Sobrien>>>>&4  lelong          <101010
75133359Sobrien>>>>>&-4        lelong  >99010
76133359Sobrien>>>>>>&-4       lelong  !100000         ~10 fps,
77133359Sobrien>>>>&4  lelong          83333           12.00 fps,
78133359Sobrien# ]11.9,12.1[
79133359Sobrien>>>>&4  lelong          <84034
80133359Sobrien>>>>>&-4        lelong  >82645
81133359Sobrien>>>>>>&-4       lelong  !83333          ~12 fps,
82133359Sobrien>>>>&4  lelong          66667           15.00 fps,
83133359Sobrien# ]14.9,15.1[
84133359Sobrien>>>>&4  lelong          <67114
85133359Sobrien>>>>>&-4        lelong  >66225
86133359Sobrien>>>>>>&-4       lelong  !66667          ~15 fps,
87133359Sobrien>>>>&4  lelong          50000           20.00 fps,
88133359Sobrien>>>>&4  lelong          41708           23.98 fps,
89133359Sobrien>>>>&4  lelong          41667           24.00 fps,
90133359Sobrien# ]23.9,24.1[
91133359Sobrien>>>>&4  lelong          <41841
92133359Sobrien>>>>>&-4        lelong  >41494
93133359Sobrien>>>>>>&-4       lelong  !41708
94133359Sobrien>>>>>>>&-4      lelong  !41667          ~24 fps,
95133359Sobrien>>>>&4  lelong          40000           25.00 fps,
96133359Sobrien# ]24.9,25.1[
97133359Sobrien>>>>&4  lelong          <40161
98133359Sobrien>>>>>&-4        lelong  >39841
99133359Sobrien>>>>>>&-4       lelong  !40000          ~25 fps,
100133359Sobrien>>>>&4  lelong          33367           29.97 fps,
101133359Sobrien>>>>&4  lelong          33333           30.00 fps,
102133359Sobrien# ]29.9,30.1[
103133359Sobrien>>>>&4  lelong          <33445
104133359Sobrien>>>>>&-4        lelong  >33223
105133359Sobrien>>>>>>&-4       lelong  !33367
106133359Sobrien>>>>>>>&-4      lelong  !33333          ~30 fps,
107133359Sobrien>>>>&4  lelong          <32224          >30 fps,
108133359Sobrien##>>>>&4  lelong          x               (%lu)
109133359Sobrien##>>>>&20 lelong          x               %lu frames,
110133359Sobrien# Note: The tests below assume that the AVI has 1 or 2 streams,
111133359Sobrien#       "vids" optionally followed by "auds".
112133359Sobrien#       (Should cover 99.9% of all AVIs.)
113133359Sobrien# assuming avih length = 56
114133359Sobrien>>>88   string  LIST
115133359Sobrien>>>>96  string  strlstrh
116133359Sobrien>>>>>108        string  vids    video:
117133359Sobrien>>>>>>&0        lelong  0               uncompressed
118133359Sobrien# skip past vids strh
119133359Sobrien>>>>>>(104.l+108)       string  strf
120133359Sobrien>>>>>>>(104.l+132)      lelong          1       RLE 8bpp
121133359Sobrien>>>>>>>(104.l+132)      string/c        cvid    Cinepak
122133359Sobrien>>>>>>>(104.l+132)      string/c        i263    Intel I.263
123133359Sobrien>>>>>>>(104.l+132)      string/c        iv32    Indeo 3.2
124133359Sobrien>>>>>>>(104.l+132)      string/c        iv41    Indeo 4.1
125133359Sobrien>>>>>>>(104.l+132)      string/c        iv50    Indeo 5.0
126133359Sobrien>>>>>>>(104.l+132)      string/c        mp42    Microsoft MPEG-4 v2
127133359Sobrien>>>>>>>(104.l+132)      string/c        mp43    Microsoft MPEG-4 v3
128169942Sobrien>>>>>>>(104.l+132)      string/c        fmp4    FFMpeg MPEG-4
129133359Sobrien>>>>>>>(104.l+132)      string/c        mjpg    Motion JPEG
130133359Sobrien>>>>>>>(104.l+132)      string/c        div3    DivX 3
131133359Sobrien>>>>>>>>112             string/c        div3    Low-Motion
132133359Sobrien>>>>>>>>112             string/c        div4    Fast-Motion
133133359Sobrien>>>>>>>(104.l+132)      string/c        divx    DivX 4
134133359Sobrien>>>>>>>(104.l+132)      string/c        dx50    DivX 5
135133359Sobrien>>>>>>>(104.l+132)      string/c        xvid    XviD
136186690Sobrien>>>>>>>(104.l+132)	string/c	h264	H.264
137169942Sobrien>>>>>>>(104.l+132)      string/c        wmv3    Windows Media Video 9
138186690Sobrien>>>>>>>(104.l+132)      string/c        h264    X.264 or H.264
139133359Sobrien>>>>>>>(104.l+132)      lelong  0
140133359Sobrien##>>>>>>>(104.l+132)      string  x       (%.4s)
141133359Sobrien# skip past first (video) LIST
142133359Sobrien>>>>(92.l+96)   string  LIST
143133359Sobrien>>>>>(92.l+104) string  strlstrh
144133359Sobrien>>>>>>(92.l+116)        string          auds    \b, audio:
145133359Sobrien# auds strh length = 56:
146133359Sobrien>>>>>>>(92.l+172)       string          strf
147133359Sobrien>>>>>>>>(92.l+180)      leshort 0x0001  uncompressed PCM
148133359Sobrien>>>>>>>>(92.l+180)      leshort 0x0002  ADPCM
149169942Sobrien>>>>>>>>(92.l+180)      leshort 0x0006  aLaw
150169942Sobrien>>>>>>>>(92.l+180)      leshort 0x0007  uLaw
151169942Sobrien>>>>>>>>(92.l+180)      leshort 0x0050  MPEG-1 Layer 1 or 2
152133359Sobrien>>>>>>>>(92.l+180)      leshort 0x0055  MPEG-1 Layer 3
153133359Sobrien>>>>>>>>(92.l+180)      leshort 0x2000  Dolby AC3
154133359Sobrien>>>>>>>>(92.l+180)      leshort 0x0161  DivX
155133359Sobrien##>>>>>>>>(92.l+180)      leshort x       (0x%.4x)
156133359Sobrien>>>>>>>>(92.l+182)      leshort 1       (mono,
157133359Sobrien>>>>>>>>(92.l+182)      leshort 2       (stereo,
158133359Sobrien>>>>>>>>(92.l+182)      leshort >2      (%d channels,
159133359Sobrien>>>>>>>>(92.l+184)      lelong  x       %d Hz)
160133359Sobrien# auds strh length = 64:
161133359Sobrien>>>>>>>(92.l+180)       string          strf
162133359Sobrien>>>>>>>>(92.l+188)      leshort 0x0001  uncompressed PCM
163133359Sobrien>>>>>>>>(92.l+188)      leshort 0x0002  ADPCM
164133359Sobrien>>>>>>>>(92.l+188)      leshort 0x0055  MPEG-1 Layer 3
165133359Sobrien>>>>>>>>(92.l+188)      leshort 0x2000  Dolby AC3
166133359Sobrien>>>>>>>>(92.l+188)      leshort 0x0161  DivX
167133359Sobrien##>>>>>>>>(92.l+188)      leshort x       (0x%.4x)
168133359Sobrien>>>>>>>>(92.l+190)      leshort 1       (mono,
169133359Sobrien>>>>>>>>(92.l+190)      leshort 2       (stereo,
170133359Sobrien>>>>>>>>(92.l+190)      leshort >2      (%d channels,
171133359Sobrien>>>>>>>>(92.l+192)      lelong  x       %d Hz)
17268349Sobrien# Animated Cursor format
17368349Sobrien>8	string		ACON		\b, animated cursor
174133359Sobrien# SoundFont 2 <mpruett@sgi.com>
175133359Sobrien>8	string		sfbk		SoundFont/Bank
176133359Sobrien# MPEG-1 wrapped in a RIFF, apparently
177133359Sobrien>8      string          CDXA            \b, wrapped MPEG-1 (CDXA)
178133359Sobrien>8	string		4XMV		\b, 4X Movie file 
17968349Sobrien
18068349Sobrien#
18168349Sobrien# XXX - some of the below may only appear in little-endian form.
18268349Sobrien#
18368349Sobrien# Also "MV93" appears to be for one form of Macromedia Director
18468349Sobrien# files, and "GDMF" appears to be another multimedia format.
18568349Sobrien#
18668349Sobrien0	string		RIFX		RIFF (big-endian) data
18768349Sobrien# RIFF Palette format
18868349Sobrien>8	string		PAL		\b, palette
18968349Sobrien>>16	beshort		x		\b, version %d
19068349Sobrien>>18	beshort		x		\b, %d entries
19168349Sobrien# RIFF Device Independent Bitmap format
19268349Sobrien>8	string		RDIB		\b, device-independent bitmap
19368349Sobrien>>16	string		BM		
19468349Sobrien>>>30	beshort		12		\b, OS/2 1.x format
19568349Sobrien>>>>34	beshort		x		\b, %d x
19668349Sobrien>>>>36	beshort		x		%d
19768349Sobrien>>>30	beshort		64		\b, OS/2 2.x format
19868349Sobrien>>>>34	beshort		x		\b, %d x
19968349Sobrien>>>>36	beshort		x		%d
20068349Sobrien>>>30	beshort		40		\b, Windows 3.x format
20168349Sobrien>>>>34	belong		x		\b, %d x
20268349Sobrien>>>>38	belong		x		%d x
20368349Sobrien>>>>44	beshort		x		%d
20468349Sobrien# RIFF MIDI format
20568349Sobrien>8	string		RMID		\b, MIDI
20668349Sobrien# RIFF Multimedia Movie File format
20768349Sobrien>8	string		RMMP		\b, multimedia movie
20868349Sobrien# Microsoft WAVE format (*.wav)
20968349Sobrien>8	string		WAVE		\b, WAVE audio
21068349Sobrien>>20	leshort		1		\b, Microsoft PCM
21168349Sobrien>>>34	leshort		>0		\b, %d bit
21268349Sobrien>>22	beshort		=1		\b, mono
21368349Sobrien>>22	beshort		=2		\b, stereo
21468349Sobrien>>22	beshort		>2		\b, %d channels
21568349Sobrien>>24	belong		>0		%d Hz
216133359Sobrien# Corel Draw Picture
217133359Sobrien>8	string		CDRA		\b, Corel Draw Picture
21868349Sobrien# AVI == Audio Video Interleave
219133359Sobrien>8	string		AVI\040		\b, AVI
22068349Sobrien# Animated Cursor format
22168349Sobrien>8	string		ACON		\b, animated cursor
22268349Sobrien# Notation Interchange File Format (big-endian only)
22368349Sobrien>8	string		NIFF		\b, Notation Interchange File Format
22469216Sobrien# SoundFont 2 <mpruett@sgi.com>
225133359Sobrien>8	string		sfbk		SoundFont/Bank
226