xref: /freebsd/contrib/file/magic/Magdir/riff (revision 3416500aef140042c64bc149cb1ec6620483bc44)
1
2#------------------------------------------------------------------------------
3# $File: riff,v 1.31 2015/02/14 17:30:03 christos Exp $
4# riff:  file(1) magic for RIFF format
5# See
6#
7#	http://www.seanet.com/users/matts/riffmci/riffmci.htm
8#
9
10# audio format tag. Assume limits: max 1024 bit, 128 channels, 1 MHz
110   name    riff-wave
12>0	leshort		1		\b, Microsoft PCM
13>>14	leshort		>0
14>>>14	leshort		<1024	\b, %d bit
15>0	leshort		2		\b, Microsoft ADPCM
16>0	leshort		6		\b, ITU G.711 A-law
17>0	leshort		7		\b, ITU G.711 mu-law
18>0	leshort		8		\b, Microsoft DTS
19>0	leshort		17		\b, IMA ADPCM
20>0	leshort		20		\b, ITU G.723 ADPCM (Yamaha)
21>0	leshort		49		\b, GSM 6.10
22>0	leshort		64		\b, ITU G.721 ADPCM
23>0	leshort		80		\b, MPEG
24>0	leshort		85		\b, MPEG Layer 3
25>0	leshort		0x2001		\b, DTS
26>2	leshort		=1		\b, mono
27>2	leshort		=2		\b, stereo
28>2	leshort		>2
29>>2	leshort		<128	\b, %d channels
30>4	lelong		>0
31>>4	lelong		<1000000	%d Hz
32
33# try to find "fmt "
340   name    riff-walk
35>0  string  fmt\x20
36>>4 lelong  <0x80
37>>>8 use    riff-wave
38>0  string  LIST
39>>&(4.l+4)  use riff-walk
40>0  string  DISP
41>>&(4.l+4)  use riff-walk
42>0  string  bext
43>>&(4.l+4)  use riff-walk
44>0  string  Fake
45>>&(4.l+4)  use riff-walk
46>0  string  fact
47>>&(4.l+4)  use riff-walk
48>0  string  VP8
49>>11		byte		0x9d
50>>>12		byte		0x01
51>>>>13		byte		0x2a	\b, VP8 encoding
52>>>>>14		leshort&0x3fff	x	\b, %d
53>>>>>16		leshort&0x3fff	x	\bx%d, Scaling:
54>>>>>14		leshort&0xc000	0x0000	\b [none]
55>>>>>14		leshort&0xc000	0x1000	\b [5/4]
56>>>>>14		leshort&0xc000	0x2000	\b [5/3]
57>>>>>14		leshort&0xc000	0x3000	\b [2]
58>>>>>14		leshort&0xc000	0x0000	\bx[none]
59>>>>>14		leshort&0xc000	0x1000	\bx[5/4]
60>>>>>14		leshort&0xc000	0x2000	\bx[5/3]
61>>>>>14		leshort&0xc000	0x3000	\bx[2]
62>>>>>15		byte&0x80	=0x00	\b, YUV color
63>>>>>15		byte&0x80	=0x80	\b, bad color specification
64>>>>>15		byte&0x40	=0x40	\b, no clamping required
65>>>>>15		byte&0x40	=0x00	\b, decoders should clamp
66#>0  string  x		we got %s
67#>>&(4.l+4)  use riff-walk
68
69# AVI section extended by Patrik Radman <patrik+file-magic@iki.fi>
70#
710	string		RIFF		RIFF (little-endian) data
72# RIFF Palette format
73>8	string		PAL		\b, palette
74>>16	leshort		x		\b, version %d
75>>18	leshort		x		\b, %d entries
76# RIFF Device Independent Bitmap format
77>8	string		RDIB		\b, device-independent bitmap
78>>16	string		BM
79>>>30	leshort		12		\b, OS/2 1.x format
80>>>>34	leshort		x		\b, %d x
81>>>>36	leshort		x		%d
82>>>30	leshort		64		\b, OS/2 2.x format
83>>>>34	leshort		x		\b, %d x
84>>>>36	leshort		x		%d
85>>>30	leshort		40		\b, Windows 3.x format
86>>>>34	lelong		x		\b, %d x
87>>>>38	lelong		x		%d x
88>>>>44	leshort		x		%d
89# RIFF MIDI format
90>8	string		RMID		\b, MIDI
91# RIFF Multimedia Movie File format
92>8	string		RMMP		\b, multimedia movie
93# RIFF wrapper for MP3
94>8	string		RMP3		\b, MPEG Layer 3 audio
95# Microsoft WAVE format (*.wav)
96>8	string		WAVE		\b, WAVE audio
97!:mime	audio/x-wav
98>>12    string  >\0
99>>>12   use     riff-walk
100# Corel Draw Picture
101>8	string		CDRA		\b, Corel Draw Picture
102!:mime	image/x-coreldraw
103>8	string		CDR6		\b, Corel Draw Picture, version 6
104!:mime	image/x-coreldraw
105>8	string		NUNDROOT	\b, Steinberg CuBase
106# AVI == Audio Video Interleave
107>8	string		AVI\040		\b, AVI
108!:mime	video/x-msvideo
109>>12    string          LIST
110>>>20   string          hdrlavih
111>>>>&36 lelong          x               \b, %u x
112>>>>&40 lelong          x               %u,
113>>>>&4  lelong          >1000000        <1 fps,
114>>>>&4  lelong          1000000         1.00 fps,
115>>>>&4  lelong          500000          2.00 fps,
116>>>>&4  lelong          333333          3.00 fps,
117>>>>&4  lelong          250000          4.00 fps,
118>>>>&4  lelong          200000          5.00 fps,
119>>>>&4  lelong          166667          6.00 fps,
120>>>>&4  lelong          142857          7.00 fps,
121>>>>&4  lelong          125000          8.00 fps,
122>>>>&4  lelong          111111          9.00 fps,
123>>>>&4  lelong          100000          10.00 fps,
124# ]9.9,10.1[
125>>>>&4  lelong          <101010
126>>>>>&-4        lelong  >99010
127>>>>>>&-4       lelong  !100000         ~10 fps,
128>>>>&4  lelong          83333           12.00 fps,
129# ]11.9,12.1[
130>>>>&4  lelong          <84034
131>>>>>&-4        lelong  >82645
132>>>>>>&-4       lelong  !83333          ~12 fps,
133>>>>&4  lelong          66667           15.00 fps,
134# ]14.9,15.1[
135>>>>&4  lelong          <67114
136>>>>>&-4        lelong  >66225
137>>>>>>&-4       lelong  !66667          ~15 fps,
138>>>>&4  lelong          50000           20.00 fps,
139>>>>&4  lelong          41708           23.98 fps,
140>>>>&4  lelong          41667           24.00 fps,
141# ]23.9,24.1[
142>>>>&4  lelong          <41841
143>>>>>&-4        lelong  >41494
144>>>>>>&-4       lelong  !41708
145>>>>>>>&-4      lelong  !41667          ~24 fps,
146>>>>&4  lelong          40000           25.00 fps,
147# ]24.9,25.1[
148>>>>&4  lelong          <40161
149>>>>>&-4        lelong  >39841
150>>>>>>&-4       lelong  !40000          ~25 fps,
151>>>>&4  lelong          33367           29.97 fps,
152>>>>&4  lelong          33333           30.00 fps,
153# ]29.9,30.1[
154>>>>&4  lelong          <33445
155>>>>>&-4        lelong  >33223
156>>>>>>&-4       lelong  !33367
157>>>>>>>&-4      lelong  !33333          ~30 fps,
158>>>>&4  lelong          <32224          >30 fps,
159##>>>>&4  lelong          x               (%lu)
160##>>>>&20 lelong          x               %lu frames,
161# Note: The tests below assume that the AVI has 1 or 2 streams,
162#       "vids" optionally followed by "auds".
163#       (Should cover 99.9% of all AVIs.)
164# assuming avih length = 56
165>>>88   string  LIST
166>>>>96  string  strlstrh
167>>>>>108        string  vids    video:
168>>>>>>&0        lelong  0               uncompressed
169# skip past vids strh
170>>>>>>(104.l+108)       string  strf
171>>>>>>>(104.l+132)      lelong          1       RLE 8bpp
172>>>>>>>(104.l+132)      string/c        cvid    Cinepak
173>>>>>>>(104.l+132)      string/c        i263    Intel I.263
174>>>>>>>(104.l+132)      string/c        iv32    Indeo 3.2
175>>>>>>>(104.l+132)      string/c        iv41    Indeo 4.1
176>>>>>>>(104.l+132)      string/c        iv50    Indeo 5.0
177>>>>>>>(104.l+132)      string/c        mp42    Microsoft MPEG-4 v2
178>>>>>>>(104.l+132)      string/c        mp43    Microsoft MPEG-4 v3
179>>>>>>>(104.l+132)      string/c        fmp4    FFMpeg MPEG-4
180>>>>>>>(104.l+132)      string/c        mjpg    Motion JPEG
181>>>>>>>(104.l+132)      string/c        div3    DivX 3
182>>>>>>>>112             string/c        div3    Low-Motion
183>>>>>>>>112             string/c        div4    Fast-Motion
184>>>>>>>(104.l+132)      string/c        divx    DivX 4
185>>>>>>>(104.l+132)      string/c        dx50    DivX 5
186>>>>>>>(104.l+132)      string/c        xvid    XviD
187>>>>>>>(104.l+132)	string/c	h264	H.264
188>>>>>>>(104.l+132)      string/c        wmv3    Windows Media Video 9
189>>>>>>>(104.l+132)      string/c        h264    X.264 or H.264
190>>>>>>>(104.l+132)      lelong  0
191##>>>>>>>(104.l+132)      string  x       (%.4s)
192# skip past first (video) LIST
193>>>>(92.l+96)   string  LIST
194>>>>>(92.l+104) string  strlstrh
195>>>>>>(92.l+116)        string          auds    \b, audio:
196# auds strh length = 56:
197>>>>>>>(92.l+172)       string          strf
198>>>>>>>>(92.l+180)      leshort 0x0001  uncompressed PCM
199>>>>>>>>(92.l+180)      leshort 0x0002  ADPCM
200>>>>>>>>(92.l+180)      leshort 0x0006  aLaw
201>>>>>>>>(92.l+180)      leshort 0x0007  uLaw
202>>>>>>>>(92.l+180)      leshort 0x0050  MPEG-1 Layer 1 or 2
203>>>>>>>>(92.l+180)      leshort 0x0055  MPEG-1 Layer 3
204>>>>>>>>(92.l+180)      leshort 0x2000  Dolby AC3
205>>>>>>>>(92.l+180)      leshort 0x0161  DivX
206##>>>>>>>>(92.l+180)      leshort x       (0x%.4x)
207>>>>>>>>(92.l+182)      leshort 1       (mono,
208>>>>>>>>(92.l+182)      leshort 2       (stereo,
209>>>>>>>>(92.l+182)      leshort >2      (%d channels,
210>>>>>>>>(92.l+184)      lelong  x       %d Hz)
211# auds strh length = 64:
212>>>>>>>(92.l+180)       string          strf
213>>>>>>>>(92.l+188)      leshort 0x0001  uncompressed PCM
214>>>>>>>>(92.l+188)      leshort 0x0002  ADPCM
215>>>>>>>>(92.l+188)      leshort 0x0055  MPEG-1 Layer 3
216>>>>>>>>(92.l+188)      leshort 0x2000  Dolby AC3
217>>>>>>>>(92.l+188)      leshort 0x0161  DivX
218##>>>>>>>>(92.l+188)      leshort x       (0x%.4x)
219>>>>>>>>(92.l+190)      leshort 1       (mono,
220>>>>>>>>(92.l+190)      leshort 2       (stereo,
221>>>>>>>>(92.l+190)      leshort >2      (%d channels,
222>>>>>>>>(92.l+192)      lelong  x       %d Hz)
223# Animated Cursor format
224>8	string		ACON		\b, animated cursor
225# SoundFont 2 <mpruett@sgi.com>
226>8	string		sfbk		SoundFont/Bank
227# MPEG-1 wrapped in a RIFF, apparently
228>8      string          CDXA            \b, wrapped MPEG-1 (CDXA)
229>8	string		4XMV		\b, 4X Movie file
230# AMV-type AVI file: http://wiki.multimedia.cx/index.php?title=AMV
231>8	string		AMV\040		\b, AMV
232>8      string          WEBP            \b, Web/P image
233!:mime	image/webp
234>>12	use		riff-walk
235
236#
237# XXX - some of the below may only appear in little-endian form.
238#
239# Also "MV93" appears to be for one form of Macromedia Director
240# files, and "GDMF" appears to be another multimedia format.
241#
2420	string		RIFX		RIFF (big-endian) data
243# RIFF Palette format
244>8	string		PAL		\b, palette
245>>16	beshort		x		\b, version %d
246>>18	beshort		x		\b, %d entries
247# RIFF Device Independent Bitmap format
248>8	string		RDIB		\b, device-independent bitmap
249>>16	string		BM
250>>>30	beshort		12		\b, OS/2 1.x format
251>>>>34	beshort		x		\b, %d x
252>>>>36	beshort		x		%d
253>>>30	beshort		64		\b, OS/2 2.x format
254>>>>34	beshort		x		\b, %d x
255>>>>36	beshort		x		%d
256>>>30	beshort		40		\b, Windows 3.x format
257>>>>34	belong		x		\b, %d x
258>>>>38	belong		x		%d x
259>>>>44	beshort		x		%d
260# RIFF MIDI format
261>8	string		RMID		\b, MIDI
262# RIFF Multimedia Movie File format
263>8	string		RMMP		\b, multimedia movie
264# Microsoft WAVE format (*.wav)
265>8	string		WAVE		\b, WAVE audio
266>>20	leshort		1		\b, Microsoft PCM
267>>>34	leshort		>0		\b, %d bit
268>>22	beshort		=1		\b, mono
269>>22	beshort		=2		\b, stereo
270>>22	beshort		>2		\b, %d channels
271>>24	belong		>0		%d Hz
272# Corel Draw Picture
273>8	string		CDRA		\b, Corel Draw Picture
274>8	string		CDR6		\b, Corel Draw Picture, version 6
275# AVI == Audio Video Interleave
276>8	string		AVI\040		\b, AVI
277# Animated Cursor format
278>8	string		ACON		\b, animated cursor
279# Notation Interchange File Format (big-endian only)
280>8	string		NIFF		\b, Notation Interchange File Format
281# SoundFont 2 <mpruett@sgi.com>
282>8	string		sfbk		SoundFont/Bank
283
284#------------------------------------------------------------------------------
285# Sony Wave64
286# see http://www.vcs.de/fileadmin/user_upload/MBS/PDF/Whitepaper/Informations_about_Sony_Wave64.pdf
287# 128 bit RIFF-GUID { 66666972-912E-11CF-A5D6-28DB04C10000 } in little-endian
2880	string	riff\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00		Sony Wave64 RIFF data
289# 128 bit + total file size (64 bits) so 24 bytes
290# then WAVE-GUID { 65766177-ACF3-11D3-8CD1-00C04F8EDB8A }
291>24	string		wave\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A		\b, WAVE 64 audio
292!:mime	audio/x-w64
293# FMT-GUID { 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A }
294>>40	search/256	fmt\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A		\b
295>>>&10	leshort		=1		\b, mono
296>>>&10	leshort		=2		\b, stereo
297>>>&10	leshort		>2		\b, %d channels
298>>>&12	lelong		>0		%d Hz
299
300#------------------------------------------------------------------------------
301# MBWF/RF64
302# see EBU TECH 3306 http://tech.ebu.ch/docs/tech/tech3306-2009.pdf
3030	string	RF64\xff\xff\xff\xffWAVEds64		MBWF/RF64 audio
304!:mime	audio/x-wav
305>40	search/256	fmt\x20		\b
306>>&6	leshort		=1		\b, mono
307>>&6	leshort		=2		\b, stereo
308>>&6	leshort		>2		\b, %d channels
309>>&8	lelong		>0		%d Hz
310