riff revision 226048
168349Sobrien 268349Sobrien#------------------------------------------------------------------------------ 3226048Sobrien# $File: riff,v 1.22 2011/09/06 11:00:06 christos Exp $ 468349Sobrien# riff: file(1) magic for RIFF format 568349Sobrien# See 668349Sobrien# 768349Sobrien# http://www.seanet.com/users/matts/riffmci/riffmci.htm 868349Sobrien# 9133359Sobrien# AVI section extended by Patrik R�dman <patrik+file-magic@iki.fi> 1068349Sobrien# 1168349Sobrien0 string RIFF RIFF (little-endian) data 1268349Sobrien# RIFF Palette format 1368349Sobrien>8 string PAL \b, palette 1468349Sobrien>>16 leshort x \b, version %d 1568349Sobrien>>18 leshort x \b, %d entries 1668349Sobrien# RIFF Device Independent Bitmap format 1768349Sobrien>8 string RDIB \b, device-independent bitmap 1868349Sobrien>>16 string BM 1968349Sobrien>>>30 leshort 12 \b, OS/2 1.x format 2068349Sobrien>>>>34 leshort x \b, %d x 2168349Sobrien>>>>36 leshort x %d 2268349Sobrien>>>30 leshort 64 \b, OS/2 2.x format 2368349Sobrien>>>>34 leshort x \b, %d x 2468349Sobrien>>>>36 leshort x %d 2568349Sobrien>>>30 leshort 40 \b, Windows 3.x format 2668349Sobrien>>>>34 lelong x \b, %d x 2768349Sobrien>>>>38 lelong x %d x 2868349Sobrien>>>>44 leshort x %d 2968349Sobrien# RIFF MIDI format 3068349Sobrien>8 string RMID \b, MIDI 3168349Sobrien# RIFF Multimedia Movie File format 3268349Sobrien>8 string RMMP \b, multimedia movie 33169942Sobrien# RIFF wrapper for MP3 34169942Sobrien>8 string RMP3 \b, MPEG Layer 3 audio 3568349Sobrien# Microsoft WAVE format (*.wav) 3668349Sobrien>8 string WAVE \b, WAVE audio 37186690Sobrien!:mime audio/x-wav 3868349Sobrien>>20 leshort 1 \b, Microsoft PCM 3968349Sobrien>>>34 leshort >0 \b, %d bit 4080588Sobrien>>20 leshort 2 \b, Microsoft ADPCM 41133359Sobrien>>20 leshort 6 \b, ITU G.711 A-law 42133359Sobrien>>20 leshort 7 \b, ITU G.711 mu-law 43226048Sobrien>>20 leshort 8 \b, Microsoft DTS 4480588Sobrien>>20 leshort 17 \b, IMA ADPCM 4580588Sobrien>>20 leshort 20 \b, ITU G.723 ADPCM (Yamaha) 4680588Sobrien>>20 leshort 49 \b, GSM 6.10 4780588Sobrien>>20 leshort 64 \b, ITU G.721 ADPCM 4880588Sobrien>>20 leshort 80 \b, MPEG 4980588Sobrien>>20 leshort 85 \b, MPEG Layer 3 50226048Sobrien>>20 leshort 0x2001 \b, DTS 5168349Sobrien>>22 leshort =1 \b, mono 5268349Sobrien>>22 leshort =2 \b, stereo 5368349Sobrien>>22 leshort >2 \b, %d channels 5468349Sobrien>>24 lelong >0 %d Hz 55133359Sobrien# Corel Draw Picture 56133359Sobrien>8 string CDRA \b, Corel Draw Picture 57186690Sobrien!:mime image/x-coreldraw 5868349Sobrien# AVI == Audio Video Interleave 59133359Sobrien>8 string AVI\040 \b, AVI 60186690Sobrien!:mime video/x-msvideo 61133359Sobrien>>12 string LIST 62133359Sobrien>>>20 string hdrlavih 63133359Sobrien>>>>&36 lelong x \b, %lu x 64133359Sobrien>>>>&40 lelong x %lu, 65133359Sobrien>>>>&4 lelong >1000000 <1 fps, 66133359Sobrien>>>>&4 lelong 1000000 1.00 fps, 67133359Sobrien>>>>&4 lelong 500000 2.00 fps, 68133359Sobrien>>>>&4 lelong 333333 3.00 fps, 69133359Sobrien>>>>&4 lelong 250000 4.00 fps, 70133359Sobrien>>>>&4 lelong 200000 5.00 fps, 71133359Sobrien>>>>&4 lelong 166667 6.00 fps, 72133359Sobrien>>>>&4 lelong 142857 7.00 fps, 73133359Sobrien>>>>&4 lelong 125000 8.00 fps, 74133359Sobrien>>>>&4 lelong 111111 9.00 fps, 75133359Sobrien>>>>&4 lelong 100000 10.00 fps, 76133359Sobrien# ]9.9,10.1[ 77133359Sobrien>>>>&4 lelong <101010 78133359Sobrien>>>>>&-4 lelong >99010 79133359Sobrien>>>>>>&-4 lelong !100000 ~10 fps, 80133359Sobrien>>>>&4 lelong 83333 12.00 fps, 81133359Sobrien# ]11.9,12.1[ 82133359Sobrien>>>>&4 lelong <84034 83133359Sobrien>>>>>&-4 lelong >82645 84133359Sobrien>>>>>>&-4 lelong !83333 ~12 fps, 85133359Sobrien>>>>&4 lelong 66667 15.00 fps, 86133359Sobrien# ]14.9,15.1[ 87133359Sobrien>>>>&4 lelong <67114 88133359Sobrien>>>>>&-4 lelong >66225 89133359Sobrien>>>>>>&-4 lelong !66667 ~15 fps, 90133359Sobrien>>>>&4 lelong 50000 20.00 fps, 91133359Sobrien>>>>&4 lelong 41708 23.98 fps, 92133359Sobrien>>>>&4 lelong 41667 24.00 fps, 93133359Sobrien# ]23.9,24.1[ 94133359Sobrien>>>>&4 lelong <41841 95133359Sobrien>>>>>&-4 lelong >41494 96133359Sobrien>>>>>>&-4 lelong !41708 97133359Sobrien>>>>>>>&-4 lelong !41667 ~24 fps, 98133359Sobrien>>>>&4 lelong 40000 25.00 fps, 99133359Sobrien# ]24.9,25.1[ 100133359Sobrien>>>>&4 lelong <40161 101133359Sobrien>>>>>&-4 lelong >39841 102133359Sobrien>>>>>>&-4 lelong !40000 ~25 fps, 103133359Sobrien>>>>&4 lelong 33367 29.97 fps, 104133359Sobrien>>>>&4 lelong 33333 30.00 fps, 105133359Sobrien# ]29.9,30.1[ 106133359Sobrien>>>>&4 lelong <33445 107133359Sobrien>>>>>&-4 lelong >33223 108133359Sobrien>>>>>>&-4 lelong !33367 109133359Sobrien>>>>>>>&-4 lelong !33333 ~30 fps, 110133359Sobrien>>>>&4 lelong <32224 >30 fps, 111133359Sobrien##>>>>&4 lelong x (%lu) 112133359Sobrien##>>>>&20 lelong x %lu frames, 113133359Sobrien# Note: The tests below assume that the AVI has 1 or 2 streams, 114133359Sobrien# "vids" optionally followed by "auds". 115133359Sobrien# (Should cover 99.9% of all AVIs.) 116133359Sobrien# assuming avih length = 56 117133359Sobrien>>>88 string LIST 118133359Sobrien>>>>96 string strlstrh 119133359Sobrien>>>>>108 string vids video: 120133359Sobrien>>>>>>&0 lelong 0 uncompressed 121133359Sobrien# skip past vids strh 122133359Sobrien>>>>>>(104.l+108) string strf 123133359Sobrien>>>>>>>(104.l+132) lelong 1 RLE 8bpp 124133359Sobrien>>>>>>>(104.l+132) string/c cvid Cinepak 125133359Sobrien>>>>>>>(104.l+132) string/c i263 Intel I.263 126133359Sobrien>>>>>>>(104.l+132) string/c iv32 Indeo 3.2 127133359Sobrien>>>>>>>(104.l+132) string/c iv41 Indeo 4.1 128133359Sobrien>>>>>>>(104.l+132) string/c iv50 Indeo 5.0 129133359Sobrien>>>>>>>(104.l+132) string/c mp42 Microsoft MPEG-4 v2 130133359Sobrien>>>>>>>(104.l+132) string/c mp43 Microsoft MPEG-4 v3 131169942Sobrien>>>>>>>(104.l+132) string/c fmp4 FFMpeg MPEG-4 132133359Sobrien>>>>>>>(104.l+132) string/c mjpg Motion JPEG 133133359Sobrien>>>>>>>(104.l+132) string/c div3 DivX 3 134133359Sobrien>>>>>>>>112 string/c div3 Low-Motion 135133359Sobrien>>>>>>>>112 string/c div4 Fast-Motion 136133359Sobrien>>>>>>>(104.l+132) string/c divx DivX 4 137133359Sobrien>>>>>>>(104.l+132) string/c dx50 DivX 5 138133359Sobrien>>>>>>>(104.l+132) string/c xvid XviD 139186690Sobrien>>>>>>>(104.l+132) string/c h264 H.264 140169942Sobrien>>>>>>>(104.l+132) string/c wmv3 Windows Media Video 9 141186690Sobrien>>>>>>>(104.l+132) string/c h264 X.264 or H.264 142133359Sobrien>>>>>>>(104.l+132) lelong 0 143133359Sobrien##>>>>>>>(104.l+132) string x (%.4s) 144133359Sobrien# skip past first (video) LIST 145133359Sobrien>>>>(92.l+96) string LIST 146133359Sobrien>>>>>(92.l+104) string strlstrh 147133359Sobrien>>>>>>(92.l+116) string auds \b, audio: 148133359Sobrien# auds strh length = 56: 149133359Sobrien>>>>>>>(92.l+172) string strf 150133359Sobrien>>>>>>>>(92.l+180) leshort 0x0001 uncompressed PCM 151133359Sobrien>>>>>>>>(92.l+180) leshort 0x0002 ADPCM 152169942Sobrien>>>>>>>>(92.l+180) leshort 0x0006 aLaw 153169942Sobrien>>>>>>>>(92.l+180) leshort 0x0007 uLaw 154169942Sobrien>>>>>>>>(92.l+180) leshort 0x0050 MPEG-1 Layer 1 or 2 155133359Sobrien>>>>>>>>(92.l+180) leshort 0x0055 MPEG-1 Layer 3 156133359Sobrien>>>>>>>>(92.l+180) leshort 0x2000 Dolby AC3 157133359Sobrien>>>>>>>>(92.l+180) leshort 0x0161 DivX 158133359Sobrien##>>>>>>>>(92.l+180) leshort x (0x%.4x) 159133359Sobrien>>>>>>>>(92.l+182) leshort 1 (mono, 160133359Sobrien>>>>>>>>(92.l+182) leshort 2 (stereo, 161133359Sobrien>>>>>>>>(92.l+182) leshort >2 (%d channels, 162133359Sobrien>>>>>>>>(92.l+184) lelong x %d Hz) 163133359Sobrien# auds strh length = 64: 164133359Sobrien>>>>>>>(92.l+180) string strf 165133359Sobrien>>>>>>>>(92.l+188) leshort 0x0001 uncompressed PCM 166133359Sobrien>>>>>>>>(92.l+188) leshort 0x0002 ADPCM 167133359Sobrien>>>>>>>>(92.l+188) leshort 0x0055 MPEG-1 Layer 3 168133359Sobrien>>>>>>>>(92.l+188) leshort 0x2000 Dolby AC3 169133359Sobrien>>>>>>>>(92.l+188) leshort 0x0161 DivX 170133359Sobrien##>>>>>>>>(92.l+188) leshort x (0x%.4x) 171133359Sobrien>>>>>>>>(92.l+190) leshort 1 (mono, 172133359Sobrien>>>>>>>>(92.l+190) leshort 2 (stereo, 173133359Sobrien>>>>>>>>(92.l+190) leshort >2 (%d channels, 174133359Sobrien>>>>>>>>(92.l+192) lelong x %d Hz) 17568349Sobrien# Animated Cursor format 17668349Sobrien>8 string ACON \b, animated cursor 177133359Sobrien# SoundFont 2 <mpruett@sgi.com> 178133359Sobrien>8 string sfbk SoundFont/Bank 179133359Sobrien# MPEG-1 wrapped in a RIFF, apparently 180133359Sobrien>8 string CDXA \b, wrapped MPEG-1 (CDXA) 181133359Sobrien>8 string 4XMV \b, 4X Movie file 182226048Sobrien# AMV-type AVI file: http://wiki.multimedia.cx/index.php?title=AMV 183226048Sobrien>8 string AMV\040 \b, AMV 18468349Sobrien 18568349Sobrien# 18668349Sobrien# XXX - some of the below may only appear in little-endian form. 18768349Sobrien# 18868349Sobrien# Also "MV93" appears to be for one form of Macromedia Director 18968349Sobrien# files, and "GDMF" appears to be another multimedia format. 19068349Sobrien# 19168349Sobrien0 string RIFX RIFF (big-endian) data 19268349Sobrien# RIFF Palette format 19368349Sobrien>8 string PAL \b, palette 19468349Sobrien>>16 beshort x \b, version %d 19568349Sobrien>>18 beshort x \b, %d entries 19668349Sobrien# RIFF Device Independent Bitmap format 19768349Sobrien>8 string RDIB \b, device-independent bitmap 19868349Sobrien>>16 string BM 19968349Sobrien>>>30 beshort 12 \b, OS/2 1.x format 20068349Sobrien>>>>34 beshort x \b, %d x 20168349Sobrien>>>>36 beshort x %d 20268349Sobrien>>>30 beshort 64 \b, OS/2 2.x format 20368349Sobrien>>>>34 beshort x \b, %d x 20468349Sobrien>>>>36 beshort x %d 20568349Sobrien>>>30 beshort 40 \b, Windows 3.x format 20668349Sobrien>>>>34 belong x \b, %d x 20768349Sobrien>>>>38 belong x %d x 20868349Sobrien>>>>44 beshort x %d 20968349Sobrien# RIFF MIDI format 21068349Sobrien>8 string RMID \b, MIDI 21168349Sobrien# RIFF Multimedia Movie File format 21268349Sobrien>8 string RMMP \b, multimedia movie 21368349Sobrien# Microsoft WAVE format (*.wav) 21468349Sobrien>8 string WAVE \b, WAVE audio 21568349Sobrien>>20 leshort 1 \b, Microsoft PCM 21668349Sobrien>>>34 leshort >0 \b, %d bit 21768349Sobrien>>22 beshort =1 \b, mono 21868349Sobrien>>22 beshort =2 \b, stereo 21968349Sobrien>>22 beshort >2 \b, %d channels 22068349Sobrien>>24 belong >0 %d Hz 221133359Sobrien# Corel Draw Picture 222133359Sobrien>8 string CDRA \b, Corel Draw Picture 22368349Sobrien# AVI == Audio Video Interleave 224133359Sobrien>8 string AVI\040 \b, AVI 22568349Sobrien# Animated Cursor format 22668349Sobrien>8 string ACON \b, animated cursor 22768349Sobrien# Notation Interchange File Format (big-endian only) 22868349Sobrien>8 string NIFF \b, Notation Interchange File Format 22969216Sobrien# SoundFont 2 <mpruett@sgi.com> 230133359Sobrien>8 string sfbk SoundFont/Bank 231226048Sobrien 232226048Sobrien#------------------------------------------------------------------------------ 233226048Sobrien# Sony Wave64 234226048Sobrien# see http://www.vcs.de/fileadmin/user_upload/MBS/PDF/Whitepaper/Informations_about_Sony_Wave64.pdf 235226048Sobrien# 128 bit RIFF-GUID { 66666972-912E-11CF-A5D6-28DB04C10000 } in little-endian 236226048Sobrien0 string riff\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00 Sony Wave64 RIFF data 237226048Sobrien# 128 bit + total file size (64 bits) so 24 bytes 238226048Sobrien# then WAVE-GUID { 65766177-ACF3-11D3-8CD1-00C04F8EDB8A } 239226048Sobrien>24 string wave\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A \b, WAVE 64 audio 240226048Sobrien!:mime audio/x-w64 241226048Sobrien# FMT-GUID { 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A } 242226048Sobrien>>40 search/256 fmt\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A \b 243226048Sobrien>>>&10 leshort =1 \b, mono 244226048Sobrien>>>&10 leshort =2 \b, stereo 245226048Sobrien>>>&10 leshort >2 \b, %d channels 246226048Sobrien>>>&12 lelong >0 %d Hz 247226048Sobrien 248226048Sobrien#------------------------------------------------------------------------------ 249226048Sobrien# MBWF/RF64 250226048Sobrien# see EBU � TECH 3306 http://tech.ebu.ch/docs/tech/tech3306-2009.pdf 251226048Sobrien0 string RF64\xff\xff\xff\xffWAVEds64 MBWF/RF64 audio 252226048Sobrien!:mime audio/x-wav 253226048Sobrien>40 search/256 fmt\x20 \b 254226048Sobrien>>&6 leshort =1 \b, mono 255226048Sobrien>>&6 leshort =2 \b, stereo 256226048Sobrien>>&6 leshort >2 \b, %d channels 257226048Sobrien>>&8 lelong >0 %d Hz 258226048Sobrien 259