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