riff 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. #------------------------------------------------------------------------------
  2. # riff: file(1) magic for RIFF format
  3. # See
  4. #
  5. # http://www.seanet.com/users/matts/riffmci/riffmci.htm
  6. #
  7. # AVI section extended by Patrik Rådman <patrik+file-magic@iki.fi>
  8. #
  9. 0 string RIFF RIFF (little-endian) data
  10. # RIFF Palette format
  11. >8 string PAL \b, palette
  12. >>16 leshort x \b, version %d
  13. >>18 leshort x \b, %d entries
  14. # RIFF Device Independent Bitmap format
  15. >8 string RDIB \b, device-independent bitmap
  16. >>16 string BM
  17. >>>30 leshort 12 \b, OS/2 1.x format
  18. >>>>34 leshort x \b, %d x
  19. >>>>36 leshort x %d
  20. >>>30 leshort 64 \b, OS/2 2.x format
  21. >>>>34 leshort x \b, %d x
  22. >>>>36 leshort x %d
  23. >>>30 leshort 40 \b, Windows 3.x format
  24. >>>>34 lelong x \b, %d x
  25. >>>>38 lelong x %d x
  26. >>>>44 leshort x %d
  27. # RIFF MIDI format
  28. >8 string RMID \b, MIDI
  29. # RIFF Multimedia Movie File format
  30. >8 string RMMP \b, multimedia movie
  31. # RIFF wrapper for MP3
  32. >8 string RMP3 \b, MPEG Layer 3 audio
  33. # Microsoft WAVE format (*.wav)
  34. >8 string WAVE \b, WAVE audio
  35. >>20 leshort 1 \b, Microsoft PCM
  36. >>>34 leshort >0 \b, %d bit
  37. >>20 leshort 2 \b, Microsoft ADPCM
  38. >>20 leshort 6 \b, ITU G.711 A-law
  39. >>20 leshort 7 \b, ITU G.711 mu-law
  40. >>20 leshort 17 \b, IMA ADPCM
  41. >>20 leshort 20 \b, ITU G.723 ADPCM (Yamaha)
  42. >>20 leshort 49 \b, GSM 6.10
  43. >>20 leshort 64 \b, ITU G.721 ADPCM
  44. >>20 leshort 80 \b, MPEG
  45. >>20 leshort 85 \b, MPEG Layer 3
  46. >>22 leshort =1 \b, mono
  47. >>22 leshort =2 \b, stereo
  48. >>22 leshort >2 \b, %d channels
  49. >>24 lelong >0 %d Hz
  50. # Corel Draw Picture
  51. >8 string CDRA \b, Corel Draw Picture
  52. # AVI == Audio Video Interleave
  53. >8 string AVI\040 \b, AVI
  54. >>12 string LIST
  55. >>>20 string hdrlavih
  56. >>>>&36 lelong x \b, %lu x
  57. >>>>&40 lelong x %lu,
  58. >>>>&4 lelong >1000000 <1 fps,
  59. >>>>&4 lelong 1000000 1.00 fps,
  60. >>>>&4 lelong 500000 2.00 fps,
  61. >>>>&4 lelong 333333 3.00 fps,
  62. >>>>&4 lelong 250000 4.00 fps,
  63. >>>>&4 lelong 200000 5.00 fps,
  64. >>>>&4 lelong 166667 6.00 fps,
  65. >>>>&4 lelong 142857 7.00 fps,
  66. >>>>&4 lelong 125000 8.00 fps,
  67. >>>>&4 lelong 111111 9.00 fps,
  68. >>>>&4 lelong 100000 10.00 fps,
  69. # ]9.9,10.1[
  70. >>>>&4 lelong <101010
  71. >>>>>&-4 lelong >99010
  72. >>>>>>&-4 lelong !100000 ~10 fps,
  73. >>>>&4 lelong 83333 12.00 fps,
  74. # ]11.9,12.1[
  75. >>>>&4 lelong <84034
  76. >>>>>&-4 lelong >82645
  77. >>>>>>&-4 lelong !83333 ~12 fps,
  78. >>>>&4 lelong 66667 15.00 fps,
  79. # ]14.9,15.1[
  80. >>>>&4 lelong <67114
  81. >>>>>&-4 lelong >66225
  82. >>>>>>&-4 lelong !66667 ~15 fps,
  83. >>>>&4 lelong 50000 20.00 fps,
  84. >>>>&4 lelong 41708 23.98 fps,
  85. >>>>&4 lelong 41667 24.00 fps,
  86. # ]23.9,24.1[
  87. >>>>&4 lelong <41841
  88. >>>>>&-4 lelong >41494
  89. >>>>>>&-4 lelong !41708
  90. >>>>>>>&-4 lelong !41667 ~24 fps,
  91. >>>>&4 lelong 40000 25.00 fps,
  92. # ]24.9,25.1[
  93. >>>>&4 lelong <40161
  94. >>>>>&-4 lelong >39841
  95. >>>>>>&-4 lelong !40000 ~25 fps,
  96. >>>>&4 lelong 33367 29.97 fps,
  97. >>>>&4 lelong 33333 30.00 fps,
  98. # ]29.9,30.1[
  99. >>>>&4 lelong <33445
  100. >>>>>&-4 lelong >33223
  101. >>>>>>&-4 lelong !33367
  102. >>>>>>>&-4 lelong !33333 ~30 fps,
  103. >>>>&4 lelong <32224 >30 fps,
  104. ##>>>>&4 lelong x (%lu)
  105. ##>>>>&20 lelong x %lu frames,
  106. # Note: The tests below assume that the AVI has 1 or 2 streams,
  107. # "vids" optionally followed by "auds".
  108. # (Should cover 99.9% of all AVIs.)
  109. # assuming avih length = 56
  110. >>>88 string LIST
  111. >>>>96 string strlstrh
  112. >>>>>108 string vids video:
  113. >>>>>>&0 lelong 0 uncompressed
  114. # skip past vids strh
  115. >>>>>>(104.l+108) string strf
  116. >>>>>>>(104.l+132) lelong 1 RLE 8bpp
  117. >>>>>>>(104.l+132) string/c cvid Cinepak
  118. >>>>>>>(104.l+132) string/c i263 Intel I.263
  119. >>>>>>>(104.l+132) string/c iv32 Indeo 3.2
  120. >>>>>>>(104.l+132) string/c iv41 Indeo 4.1
  121. >>>>>>>(104.l+132) string/c iv50 Indeo 5.0
  122. >>>>>>>(104.l+132) string/c mp42 Microsoft MPEG-4 v2
  123. >>>>>>>(104.l+132) string/c mp43 Microsoft MPEG-4 v3
  124. >>>>>>>(104.l+132) string/c fmp4 FFMpeg MPEG-4
  125. >>>>>>>(104.l+132) string/c mjpg Motion JPEG
  126. >>>>>>>(104.l+132) string/c div3 DivX 3
  127. >>>>>>>>112 string/c div3 Low-Motion
  128. >>>>>>>>112 string/c div4 Fast-Motion
  129. >>>>>>>(104.l+132) string/c divx DivX 4
  130. >>>>>>>(104.l+132) string/c dx50 DivX 5
  131. >>>>>>>(104.l+132) string/c xvid XviD
  132. >>>>>>>(104.l+132) string/c wmv3 Windows Media Video 9
  133. >>>>>>>(104.l+132) string/c h264 X.264
  134. >>>>>>>(104.l+132) lelong 0
  135. ##>>>>>>>(104.l+132) string x (%.4s)
  136. # skip past first (video) LIST
  137. >>>>(92.l+96) string LIST
  138. >>>>>(92.l+104) string strlstrh
  139. >>>>>>(92.l+116) string auds \b, audio:
  140. # auds strh length = 56:
  141. >>>>>>>(92.l+172) string strf
  142. >>>>>>>>(92.l+180) leshort 0x0001 uncompressed PCM
  143. >>>>>>>>(92.l+180) leshort 0x0002 ADPCM
  144. >>>>>>>>(92.l+180) leshort 0x0006 aLaw
  145. >>>>>>>>(92.l+180) leshort 0x0007 uLaw
  146. >>>>>>>>(92.l+180) leshort 0x0050 MPEG-1 Layer 1 or 2
  147. >>>>>>>>(92.l+180) leshort 0x0055 MPEG-1 Layer 3
  148. >>>>>>>>(92.l+180) leshort 0x2000 Dolby AC3
  149. >>>>>>>>(92.l+180) leshort 0x0161 DivX
  150. ##>>>>>>>>(92.l+180) leshort x (0x%.4x)
  151. >>>>>>>>(92.l+182) leshort 1 (mono,
  152. >>>>>>>>(92.l+182) leshort 2 (stereo,
  153. >>>>>>>>(92.l+182) leshort >2 (%d channels,
  154. >>>>>>>>(92.l+184) lelong x %d Hz)
  155. # auds strh length = 64:
  156. >>>>>>>(92.l+180) string strf
  157. >>>>>>>>(92.l+188) leshort 0x0001 uncompressed PCM
  158. >>>>>>>>(92.l+188) leshort 0x0002 ADPCM
  159. >>>>>>>>(92.l+188) leshort 0x0055 MPEG-1 Layer 3
  160. >>>>>>>>(92.l+188) leshort 0x2000 Dolby AC3
  161. >>>>>>>>(92.l+188) leshort 0x0161 DivX
  162. ##>>>>>>>>(92.l+188) leshort x (0x%.4x)
  163. >>>>>>>>(92.l+190) leshort 1 (mono,
  164. >>>>>>>>(92.l+190) leshort 2 (stereo,
  165. >>>>>>>>(92.l+190) leshort >2 (%d channels,
  166. >>>>>>>>(92.l+192) lelong x %d Hz)
  167. # Animated Cursor format
  168. >8 string ACON \b, animated cursor
  169. # SoundFont 2 <mpruett@sgi.com>
  170. >8 string sfbk SoundFont/Bank
  171. # MPEG-1 wrapped in a RIFF, apparently
  172. >8 string CDXA \b, wrapped MPEG-1 (CDXA)
  173. >8 string 4XMV \b, 4X Movie file
  174. #
  175. # XXX - some of the below may only appear in little-endian form.
  176. #
  177. # Also "MV93" appears to be for one form of Macromedia Director
  178. # files, and "GDMF" appears to be another multimedia format.
  179. #
  180. 0 string RIFX RIFF (big-endian) data
  181. # RIFF Palette format
  182. >8 string PAL \b, palette
  183. >>16 beshort x \b, version %d
  184. >>18 beshort x \b, %d entries
  185. # RIFF Device Independent Bitmap format
  186. >8 string RDIB \b, device-independent bitmap
  187. >>16 string BM
  188. >>>30 beshort 12 \b, OS/2 1.x format
  189. >>>>34 beshort x \b, %d x
  190. >>>>36 beshort x %d
  191. >>>30 beshort 64 \b, OS/2 2.x format
  192. >>>>34 beshort x \b, %d x
  193. >>>>36 beshort x %d
  194. >>>30 beshort 40 \b, Windows 3.x format
  195. >>>>34 belong x \b, %d x
  196. >>>>38 belong x %d x
  197. >>>>44 beshort x %d
  198. # RIFF MIDI format
  199. >8 string RMID \b, MIDI
  200. # RIFF Multimedia Movie File format
  201. >8 string RMMP \b, multimedia movie
  202. # Microsoft WAVE format (*.wav)
  203. >8 string WAVE \b, WAVE audio
  204. >>20 leshort 1 \b, Microsoft PCM
  205. >>>34 leshort >0 \b, %d bit
  206. >>22 beshort =1 \b, mono
  207. >>22 beshort =2 \b, stereo
  208. >>22 beshort >2 \b, %d channels
  209. >>24 belong >0 %d Hz
  210. # Corel Draw Picture
  211. >8 string CDRA \b, Corel Draw Picture
  212. # AVI == Audio Video Interleave
  213. >8 string AVI\040 \b, AVI
  214. # Animated Cursor format
  215. >8 string ACON \b, animated cursor
  216. # Notation Interchange File Format (big-endian only)
  217. >8 string NIFF \b, Notation Interchange File Format
  218. # SoundFont 2 <mpruett@sgi.com>
  219. >8 string sfbk SoundFont/Bank