168349Sobrien 268349Sobrien#------------------------------------------------------------------------------ 3284237Sdelphij# $File: riff,v 1.31 2015/02/14 17:30:03 christos Exp $ 468349Sobrien# riff: file(1) magic for RIFF format 568349Sobrien# See 668349Sobrien# 768349Sobrien# http://www.seanet.com/users/matts/riffmci/riffmci.htm 868349Sobrien# 9267843Sdelphij 10267843Sdelphij# audio format tag. Assume limits: max 1024 bit, 128 channels, 1 MHz 11267843Sdelphij0 name riff-wave 12267843Sdelphij>0 leshort 1 \b, Microsoft PCM 13267843Sdelphij>>14 leshort >0 14267843Sdelphij>>>14 leshort <1024 \b, %d bit 15267843Sdelphij>0 leshort 2 \b, Microsoft ADPCM 16267843Sdelphij>0 leshort 6 \b, ITU G.711 A-law 17267843Sdelphij>0 leshort 7 \b, ITU G.711 mu-law 18267843Sdelphij>0 leshort 8 \b, Microsoft DTS 19267843Sdelphij>0 leshort 17 \b, IMA ADPCM 20267843Sdelphij>0 leshort 20 \b, ITU G.723 ADPCM (Yamaha) 21267843Sdelphij>0 leshort 49 \b, GSM 6.10 22267843Sdelphij>0 leshort 64 \b, ITU G.721 ADPCM 23267843Sdelphij>0 leshort 80 \b, MPEG 24267843Sdelphij>0 leshort 85 \b, MPEG Layer 3 25267843Sdelphij>0 leshort 0x2001 \b, DTS 26267843Sdelphij>2 leshort =1 \b, mono 27267843Sdelphij>2 leshort =2 \b, stereo 28267843Sdelphij>2 leshort >2 29267843Sdelphij>>2 leshort <128 \b, %d channels 30267843Sdelphij>4 lelong >0 31267843Sdelphij>>4 lelong <1000000 %d Hz 32267843Sdelphij 33267843Sdelphij# try to find "fmt " 34267843Sdelphij0 name riff-walk 35267843Sdelphij>0 string fmt\x20 36267843Sdelphij>>4 lelong <0x80 37267843Sdelphij>>>8 use riff-wave 38267843Sdelphij>0 string LIST 39267843Sdelphij>>&(4.l+4) use riff-walk 40267843Sdelphij>0 string DISP 41267843Sdelphij>>&(4.l+4) use riff-walk 42267843Sdelphij>0 string bext 43267843Sdelphij>>&(4.l+4) use riff-walk 44267843Sdelphij>0 string Fake 45267843Sdelphij>>&(4.l+4) use riff-walk 46267843Sdelphij>0 string fact 47267843Sdelphij>>&(4.l+4) use riff-walk 48275698Sdelphij>0 string VP8 49275698Sdelphij>>11 byte 0x9d 50275698Sdelphij>>>12 byte 0x01 51275698Sdelphij>>>>13 byte 0x2a \b, VP8 encoding 52275698Sdelphij>>>>>14 leshort&0x3fff x \b, %d 53275698Sdelphij>>>>>16 leshort&0x3fff x \bx%d, Scaling: 54275698Sdelphij>>>>>14 leshort&0xc000 0x0000 \b [none] 55275698Sdelphij>>>>>14 leshort&0xc000 0x1000 \b [5/4] 56275698Sdelphij>>>>>14 leshort&0xc000 0x2000 \b [5/3] 57275698Sdelphij>>>>>14 leshort&0xc000 0x3000 \b [2] 58275698Sdelphij>>>>>14 leshort&0xc000 0x0000 \bx[none] 59275698Sdelphij>>>>>14 leshort&0xc000 0x1000 \bx[5/4] 60275698Sdelphij>>>>>14 leshort&0xc000 0x2000 \bx[5/3] 61275698Sdelphij>>>>>14 leshort&0xc000 0x3000 \bx[2] 62275698Sdelphij>>>>>15 byte&0x80 =0x00 \b, YUV color 63275698Sdelphij>>>>>15 byte&0x80 =0x80 \b, bad color specification 64275698Sdelphij>>>>>15 byte&0x40 =0x40 \b, no clamping required 65275698Sdelphij>>>>>15 byte&0x40 =0x00 \b, decoders should clamp 66275698Sdelphij#>0 string x we got %s 67275698Sdelphij#>>&(4.l+4) use riff-walk 68267843Sdelphij 69267843Sdelphij# AVI section extended by Patrik Radman <patrik+file-magic@iki.fi> 7068349Sobrien# 7168349Sobrien0 string RIFF RIFF (little-endian) data 7268349Sobrien# RIFF Palette format 7368349Sobrien>8 string PAL \b, palette 7468349Sobrien>>16 leshort x \b, version %d 7568349Sobrien>>18 leshort x \b, %d entries 7668349Sobrien# RIFF Device Independent Bitmap format 7768349Sobrien>8 string RDIB \b, device-independent bitmap 7868349Sobrien>>16 string BM 7968349Sobrien>>>30 leshort 12 \b, OS/2 1.x format 8068349Sobrien>>>>34 leshort x \b, %d x 8168349Sobrien>>>>36 leshort x %d 8268349Sobrien>>>30 leshort 64 \b, OS/2 2.x format 8368349Sobrien>>>>34 leshort x \b, %d x 8468349Sobrien>>>>36 leshort x %d 8568349Sobrien>>>30 leshort 40 \b, Windows 3.x format 8668349Sobrien>>>>34 lelong x \b, %d x 8768349Sobrien>>>>38 lelong x %d x 8868349Sobrien>>>>44 leshort x %d 8968349Sobrien# RIFF MIDI format 9068349Sobrien>8 string RMID \b, MIDI 9168349Sobrien# RIFF Multimedia Movie File format 9268349Sobrien>8 string RMMP \b, multimedia movie 93169942Sobrien# RIFF wrapper for MP3 94169942Sobrien>8 string RMP3 \b, MPEG Layer 3 audio 9568349Sobrien# Microsoft WAVE format (*.wav) 9668349Sobrien>8 string WAVE \b, WAVE audio 97186690Sobrien!:mime audio/x-wav 98267843Sdelphij>>12 string >\0 99267843Sdelphij>>>12 use riff-walk 100133359Sobrien# Corel Draw Picture 101133359Sobrien>8 string CDRA \b, Corel Draw Picture 102186690Sobrien!:mime image/x-coreldraw 103267843Sdelphij>8 string CDR6 \b, Corel Draw Picture, version 6 104267843Sdelphij!:mime image/x-coreldraw 105267843Sdelphij>8 string NUNDROOT \b, Steinberg CuBase 10668349Sobrien# AVI == Audio Video Interleave 107133359Sobrien>8 string AVI\040 \b, AVI 108186690Sobrien!:mime video/x-msvideo 109133359Sobrien>>12 string LIST 110133359Sobrien>>>20 string hdrlavih 111267843Sdelphij>>>>&36 lelong x \b, %u x 112267843Sdelphij>>>>&40 lelong x %u, 113133359Sobrien>>>>&4 lelong >1000000 <1 fps, 114133359Sobrien>>>>&4 lelong 1000000 1.00 fps, 115133359Sobrien>>>>&4 lelong 500000 2.00 fps, 116133359Sobrien>>>>&4 lelong 333333 3.00 fps, 117133359Sobrien>>>>&4 lelong 250000 4.00 fps, 118133359Sobrien>>>>&4 lelong 200000 5.00 fps, 119133359Sobrien>>>>&4 lelong 166667 6.00 fps, 120133359Sobrien>>>>&4 lelong 142857 7.00 fps, 121133359Sobrien>>>>&4 lelong 125000 8.00 fps, 122133359Sobrien>>>>&4 lelong 111111 9.00 fps, 123133359Sobrien>>>>&4 lelong 100000 10.00 fps, 124133359Sobrien# ]9.9,10.1[ 125133359Sobrien>>>>&4 lelong <101010 126133359Sobrien>>>>>&-4 lelong >99010 127133359Sobrien>>>>>>&-4 lelong !100000 ~10 fps, 128133359Sobrien>>>>&4 lelong 83333 12.00 fps, 129133359Sobrien# ]11.9,12.1[ 130133359Sobrien>>>>&4 lelong <84034 131133359Sobrien>>>>>&-4 lelong >82645 132133359Sobrien>>>>>>&-4 lelong !83333 ~12 fps, 133133359Sobrien>>>>&4 lelong 66667 15.00 fps, 134133359Sobrien# ]14.9,15.1[ 135133359Sobrien>>>>&4 lelong <67114 136133359Sobrien>>>>>&-4 lelong >66225 137133359Sobrien>>>>>>&-4 lelong !66667 ~15 fps, 138133359Sobrien>>>>&4 lelong 50000 20.00 fps, 139133359Sobrien>>>>&4 lelong 41708 23.98 fps, 140133359Sobrien>>>>&4 lelong 41667 24.00 fps, 141133359Sobrien# ]23.9,24.1[ 142133359Sobrien>>>>&4 lelong <41841 143133359Sobrien>>>>>&-4 lelong >41494 144133359Sobrien>>>>>>&-4 lelong !41708 145133359Sobrien>>>>>>>&-4 lelong !41667 ~24 fps, 146133359Sobrien>>>>&4 lelong 40000 25.00 fps, 147133359Sobrien# ]24.9,25.1[ 148133359Sobrien>>>>&4 lelong <40161 149133359Sobrien>>>>>&-4 lelong >39841 150133359Sobrien>>>>>>&-4 lelong !40000 ~25 fps, 151133359Sobrien>>>>&4 lelong 33367 29.97 fps, 152133359Sobrien>>>>&4 lelong 33333 30.00 fps, 153133359Sobrien# ]29.9,30.1[ 154133359Sobrien>>>>&4 lelong <33445 155133359Sobrien>>>>>&-4 lelong >33223 156133359Sobrien>>>>>>&-4 lelong !33367 157133359Sobrien>>>>>>>&-4 lelong !33333 ~30 fps, 158133359Sobrien>>>>&4 lelong <32224 >30 fps, 159133359Sobrien##>>>>&4 lelong x (%lu) 160133359Sobrien##>>>>&20 lelong x %lu frames, 161133359Sobrien# Note: The tests below assume that the AVI has 1 or 2 streams, 162133359Sobrien# "vids" optionally followed by "auds". 163133359Sobrien# (Should cover 99.9% of all AVIs.) 164133359Sobrien# assuming avih length = 56 165133359Sobrien>>>88 string LIST 166133359Sobrien>>>>96 string strlstrh 167133359Sobrien>>>>>108 string vids video: 168133359Sobrien>>>>>>&0 lelong 0 uncompressed 169133359Sobrien# skip past vids strh 170133359Sobrien>>>>>>(104.l+108) string strf 171133359Sobrien>>>>>>>(104.l+132) lelong 1 RLE 8bpp 172133359Sobrien>>>>>>>(104.l+132) string/c cvid Cinepak 173133359Sobrien>>>>>>>(104.l+132) string/c i263 Intel I.263 174133359Sobrien>>>>>>>(104.l+132) string/c iv32 Indeo 3.2 175133359Sobrien>>>>>>>(104.l+132) string/c iv41 Indeo 4.1 176133359Sobrien>>>>>>>(104.l+132) string/c iv50 Indeo 5.0 177133359Sobrien>>>>>>>(104.l+132) string/c mp42 Microsoft MPEG-4 v2 178133359Sobrien>>>>>>>(104.l+132) string/c mp43 Microsoft MPEG-4 v3 179169942Sobrien>>>>>>>(104.l+132) string/c fmp4 FFMpeg MPEG-4 180133359Sobrien>>>>>>>(104.l+132) string/c mjpg Motion JPEG 181133359Sobrien>>>>>>>(104.l+132) string/c div3 DivX 3 182133359Sobrien>>>>>>>>112 string/c div3 Low-Motion 183133359Sobrien>>>>>>>>112 string/c div4 Fast-Motion 184133359Sobrien>>>>>>>(104.l+132) string/c divx DivX 4 185133359Sobrien>>>>>>>(104.l+132) string/c dx50 DivX 5 186133359Sobrien>>>>>>>(104.l+132) string/c xvid XviD 187186690Sobrien>>>>>>>(104.l+132) string/c h264 H.264 188169942Sobrien>>>>>>>(104.l+132) string/c wmv3 Windows Media Video 9 189186690Sobrien>>>>>>>(104.l+132) string/c h264 X.264 or H.264 190133359Sobrien>>>>>>>(104.l+132) lelong 0 191133359Sobrien##>>>>>>>(104.l+132) string x (%.4s) 192133359Sobrien# skip past first (video) LIST 193133359Sobrien>>>>(92.l+96) string LIST 194133359Sobrien>>>>>(92.l+104) string strlstrh 195133359Sobrien>>>>>>(92.l+116) string auds \b, audio: 196133359Sobrien# auds strh length = 56: 197133359Sobrien>>>>>>>(92.l+172) string strf 198133359Sobrien>>>>>>>>(92.l+180) leshort 0x0001 uncompressed PCM 199133359Sobrien>>>>>>>>(92.l+180) leshort 0x0002 ADPCM 200169942Sobrien>>>>>>>>(92.l+180) leshort 0x0006 aLaw 201169942Sobrien>>>>>>>>(92.l+180) leshort 0x0007 uLaw 202169942Sobrien>>>>>>>>(92.l+180) leshort 0x0050 MPEG-1 Layer 1 or 2 203133359Sobrien>>>>>>>>(92.l+180) leshort 0x0055 MPEG-1 Layer 3 204133359Sobrien>>>>>>>>(92.l+180) leshort 0x2000 Dolby AC3 205133359Sobrien>>>>>>>>(92.l+180) leshort 0x0161 DivX 206133359Sobrien##>>>>>>>>(92.l+180) leshort x (0x%.4x) 207133359Sobrien>>>>>>>>(92.l+182) leshort 1 (mono, 208133359Sobrien>>>>>>>>(92.l+182) leshort 2 (stereo, 209133359Sobrien>>>>>>>>(92.l+182) leshort >2 (%d channels, 210133359Sobrien>>>>>>>>(92.l+184) lelong x %d Hz) 211133359Sobrien# auds strh length = 64: 212133359Sobrien>>>>>>>(92.l+180) string strf 213133359Sobrien>>>>>>>>(92.l+188) leshort 0x0001 uncompressed PCM 214133359Sobrien>>>>>>>>(92.l+188) leshort 0x0002 ADPCM 215133359Sobrien>>>>>>>>(92.l+188) leshort 0x0055 MPEG-1 Layer 3 216133359Sobrien>>>>>>>>(92.l+188) leshort 0x2000 Dolby AC3 217133359Sobrien>>>>>>>>(92.l+188) leshort 0x0161 DivX 218133359Sobrien##>>>>>>>>(92.l+188) leshort x (0x%.4x) 219133359Sobrien>>>>>>>>(92.l+190) leshort 1 (mono, 220133359Sobrien>>>>>>>>(92.l+190) leshort 2 (stereo, 221133359Sobrien>>>>>>>>(92.l+190) leshort >2 (%d channels, 222133359Sobrien>>>>>>>>(92.l+192) lelong x %d Hz) 22368349Sobrien# Animated Cursor format 22468349Sobrien>8 string ACON \b, animated cursor 225133359Sobrien# SoundFont 2 <mpruett@sgi.com> 226133359Sobrien>8 string sfbk SoundFont/Bank 227133359Sobrien# MPEG-1 wrapped in a RIFF, apparently 228133359Sobrien>8 string CDXA \b, wrapped MPEG-1 (CDXA) 229133359Sobrien>8 string 4XMV \b, 4X Movie file 230226048Sobrien# AMV-type AVI file: http://wiki.multimedia.cx/index.php?title=AMV 231226048Sobrien>8 string AMV\040 \b, AMV 232275698Sdelphij>8 string WEBP \b, Web/P image 233284237Sdelphij!:mime image/webp 234275698Sdelphij>>12 use riff-walk 23568349Sobrien 23668349Sobrien# 23768349Sobrien# XXX - some of the below may only appear in little-endian form. 23868349Sobrien# 23968349Sobrien# Also "MV93" appears to be for one form of Macromedia Director 24068349Sobrien# files, and "GDMF" appears to be another multimedia format. 24168349Sobrien# 24268349Sobrien0 string RIFX RIFF (big-endian) data 24368349Sobrien# RIFF Palette format 24468349Sobrien>8 string PAL \b, palette 24568349Sobrien>>16 beshort x \b, version %d 24668349Sobrien>>18 beshort x \b, %d entries 24768349Sobrien# RIFF Device Independent Bitmap format 24868349Sobrien>8 string RDIB \b, device-independent bitmap 24968349Sobrien>>16 string BM 25068349Sobrien>>>30 beshort 12 \b, OS/2 1.x format 25168349Sobrien>>>>34 beshort x \b, %d x 25268349Sobrien>>>>36 beshort x %d 25368349Sobrien>>>30 beshort 64 \b, OS/2 2.x format 25468349Sobrien>>>>34 beshort x \b, %d x 25568349Sobrien>>>>36 beshort x %d 25668349Sobrien>>>30 beshort 40 \b, Windows 3.x format 25768349Sobrien>>>>34 belong x \b, %d x 25868349Sobrien>>>>38 belong x %d x 25968349Sobrien>>>>44 beshort x %d 26068349Sobrien# RIFF MIDI format 26168349Sobrien>8 string RMID \b, MIDI 26268349Sobrien# RIFF Multimedia Movie File format 26368349Sobrien>8 string RMMP \b, multimedia movie 26468349Sobrien# Microsoft WAVE format (*.wav) 26568349Sobrien>8 string WAVE \b, WAVE audio 26668349Sobrien>>20 leshort 1 \b, Microsoft PCM 26768349Sobrien>>>34 leshort >0 \b, %d bit 26868349Sobrien>>22 beshort =1 \b, mono 26968349Sobrien>>22 beshort =2 \b, stereo 27068349Sobrien>>22 beshort >2 \b, %d channels 27168349Sobrien>>24 belong >0 %d Hz 272133359Sobrien# Corel Draw Picture 273133359Sobrien>8 string CDRA \b, Corel Draw Picture 274267843Sdelphij>8 string CDR6 \b, Corel Draw Picture, version 6 27568349Sobrien# AVI == Audio Video Interleave 276133359Sobrien>8 string AVI\040 \b, AVI 27768349Sobrien# Animated Cursor format 27868349Sobrien>8 string ACON \b, animated cursor 27968349Sobrien# Notation Interchange File Format (big-endian only) 28068349Sobrien>8 string NIFF \b, Notation Interchange File Format 28169216Sobrien# SoundFont 2 <mpruett@sgi.com> 282133359Sobrien>8 string sfbk SoundFont/Bank 283226048Sobrien 284226048Sobrien#------------------------------------------------------------------------------ 285226048Sobrien# Sony Wave64 286226048Sobrien# see http://www.vcs.de/fileadmin/user_upload/MBS/PDF/Whitepaper/Informations_about_Sony_Wave64.pdf 287226048Sobrien# 128 bit RIFF-GUID { 66666972-912E-11CF-A5D6-28DB04C10000 } in little-endian 288226048Sobrien0 string riff\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00 Sony Wave64 RIFF data 289226048Sobrien# 128 bit + total file size (64 bits) so 24 bytes 290226048Sobrien# then WAVE-GUID { 65766177-ACF3-11D3-8CD1-00C04F8EDB8A } 291226048Sobrien>24 string wave\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A \b, WAVE 64 audio 292226048Sobrien!:mime audio/x-w64 293226048Sobrien# FMT-GUID { 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A } 294226048Sobrien>>40 search/256 fmt\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A \b 295226048Sobrien>>>&10 leshort =1 \b, mono 296226048Sobrien>>>&10 leshort =2 \b, stereo 297226048Sobrien>>>&10 leshort >2 \b, %d channels 298226048Sobrien>>>&12 lelong >0 %d Hz 299226048Sobrien 300226048Sobrien#------------------------------------------------------------------------------ 301226048Sobrien# MBWF/RF64 302267843Sdelphij# see EBU TECH 3306 http://tech.ebu.ch/docs/tech/tech3306-2009.pdf 303226048Sobrien0 string RF64\xff\xff\xff\xffWAVEds64 MBWF/RF64 audio 304226048Sobrien!:mime audio/x-wav 305226048Sobrien>40 search/256 fmt\x20 \b 306226048Sobrien>>&6 leshort =1 \b, mono 307226048Sobrien>>&6 leshort =2 \b, stereo 308226048Sobrien>>&6 leshort >2 \b, %d channels 309226048Sobrien>>&8 lelong >0 %d Hz 310