PageRenderTime 35ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/application/libraries/getid3/module.audio-video.riff.php

https://github.com/libis/Flandrica
PHP | 2391 lines | 1858 code | 404 blank | 129 comment | 248 complexity | fb6c7610710749b4a70742c09517cf5d MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, Apache-2.0
  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP version 5 |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 2002-2009 James Heinrich, Allan Hansen |
  6. // +----------------------------------------------------------------------+
  7. // | This source file is subject to version 2 of the GPL license, |
  8. // | that is bundled with this package in the file license.txt and is |
  9. // | available through the world-wide-web at the following url: |
  10. // | http://www.gnu.org/copyleft/gpl.html |
  11. // +----------------------------------------------------------------------+
  12. // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org |
  13. // +----------------------------------------------------------------------+
  14. // | Authors: James Heinrich <infoŘgetid3*org> |
  15. // | Allan Hansen <ahŘartemis*dk> |
  16. // +----------------------------------------------------------------------+
  17. // | module.audio-video.riff.php |
  18. // | module for analyzing RIFF files: |
  19. // | Wave, AVI, AIFF/AIFC, (MP3,AC3)/RIFF, Wavpack3, 8SVX |
  20. // | dependencies: module.audio.mp3.php (optional) |
  21. // | module.audio.ac3.php (optional) |
  22. // | module.audio.dts.php (optional) |
  23. // | module.audio-video.mpeg.php (optional) |
  24. // +----------------------------------------------------------------------+
  25. //
  26. // $Id: module.audio-video.riff.php,v 1.10 2006/12/03 20:13:17 ah Exp $
  27. class getid3_riff extends getid3_handler
  28. {
  29. private $endian_function = 'LittleEndian2Int';
  30. public function Analyze() {
  31. $getid3 = $this->getid3;
  32. $getid3->info['riff']['raw'] = array ();
  33. $info_riff = &$getid3->info['riff'];
  34. $info_riff_raw = &$info_riff['raw'];
  35. $info_audio = &$getid3->info['audio'];
  36. $info_video = &$getid3->info['video'];
  37. $info_avdataoffset = &$getid3->info['avdataoffset'];
  38. $info_avdataend = &$getid3->info['avdataend'];
  39. $info_audio_dataformat = &$info_audio['dataformat'];
  40. $info_riff_audio = &$info_riff['audio'];
  41. $info_riff_video = &$info_riff['video'];
  42. $original['avdataend'] = $info_avdataend;
  43. $this->fseek($info_avdataoffset, SEEK_SET);
  44. $riff_header = $this->fread(12);
  45. $riff_sub_type = substr($riff_header, 8, 4);
  46. switch (substr($riff_header, 0, 4)) {
  47. case 'FORM':
  48. $getid3->info['fileformat'] = 'aiff';
  49. $this->endian_function = 'BigEndian2Int';
  50. $riff_header_size = getid3_lib::BigEndian2Int(substr($riff_header, 4, 4));
  51. $info_riff[$riff_sub_type] = $this->ParseRIFF($info_avdataoffset + 12, $info_avdataoffset + $riff_header_size);
  52. $info_riff['header_size'] = $riff_header_size;
  53. break;
  54. case 'RIFF':
  55. case 'SDSS': // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
  56. case 'RMP3': // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s
  57. if ($riff_sub_type == 'RMP3') {
  58. $riff_sub_type = 'WAVE';
  59. }
  60. $getid3->info['fileformat'] = 'riff';
  61. $this->endian_function = 'LittleEndian2Int';
  62. $riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_header, 4, 4));
  63. $info_riff[$riff_sub_type] = $this->ParseRIFF($info_avdataoffset + 12, $info_avdataoffset + $riff_header_size);
  64. $info_riff['header_size'] = $riff_header_size;
  65. if ($riff_sub_type == 'WAVE') {
  66. $info_riff_wave = &$info_riff['WAVE'];
  67. }
  68. break;
  69. default:
  70. throw new getid3_exception('Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "'.$riff_sub_type.'" instead');
  71. }
  72. $endian_function = $this->endian_function;
  73. $stream_index = 0;
  74. switch ($riff_sub_type) {
  75. case 'WAVE':
  76. if (empty($info_audio['bitrate_mode'])) {
  77. $info_audio['bitrate_mode'] = 'cbr';
  78. }
  79. if (empty($info_audio_dataformat)) {
  80. $info_audio_dataformat = 'wav';
  81. }
  82. if (isset($info_riff_wave['data'][0]['offset'])) {
  83. $info_avdataoffset = $info_riff_wave['data'][0]['offset'] + 8;
  84. $info_avdataend = $info_avdataoffset + $info_riff_wave['data'][0]['size'];
  85. }
  86. if (isset($info_riff_wave['fmt '][0]['data'])) {
  87. $info_riff_audio[$stream_index] = getid3_riff::RIFFparseWAVEFORMATex($info_riff_wave['fmt '][0]['data']);
  88. $info_audio['wformattag'] = $info_riff_audio[$stream_index]['raw']['wFormatTag'];
  89. $info_riff_raw['fmt '] = $info_riff_audio[$stream_index]['raw'];
  90. unset($info_riff_audio[$stream_index]['raw']);
  91. $info_audio['streams'][$stream_index] = $info_riff_audio[$stream_index];
  92. $info_audio = getid3_riff::array_merge_noclobber($info_audio, $info_riff_audio[$stream_index]);
  93. if (substr($info_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
  94. $getid3->warning('Audio codec = '.$info_audio['codec']);
  95. }
  96. $info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate'];
  97. $getid3->info['playtime_seconds'] = (float)((($info_avdataend - $info_avdataoffset) * 8) / $info_audio['bitrate']);
  98. $info_audio['lossless'] = false;
  99. if (isset($info_riff_wave['data'][0]['offset']) && isset($info_riff_raw['fmt ']['wFormatTag'])) {
  100. switch ($info_riff_raw['fmt ']['wFormatTag']) {
  101. case 0x0001: // PCM
  102. $info_audio['lossless'] = true;
  103. break;
  104. case 0x2000: // AC-3
  105. $info_audio_dataformat = 'ac3';
  106. break;
  107. default:
  108. // do nothing
  109. break;
  110. }
  111. }
  112. $info_audio['streams'][$stream_index]['wformattag'] = $info_audio['wformattag'];
  113. $info_audio['streams'][$stream_index]['bitrate_mode'] = $info_audio['bitrate_mode'];
  114. $info_audio['streams'][$stream_index]['lossless'] = $info_audio['lossless'];
  115. $info_audio['streams'][$stream_index]['dataformat'] = $info_audio_dataformat;
  116. }
  117. if (isset($info_riff_wave['rgad'][0]['data'])) {
  118. // shortcuts
  119. $rgadData = &$info_riff_wave['rgad'][0]['data'];
  120. $info_riff_raw['rgad'] = array ('track'=>array(), 'album'=>array());
  121. $info_riff_raw_rgad = &$info_riff_raw['rgad'];
  122. $info_riff_raw_rgad_track = &$info_riff_raw_rgad['track'];
  123. $info_riff_raw_rgad_album = &$info_riff_raw_rgad['album'];
  124. $info_riff_raw_rgad['fPeakAmplitude'] = getid3_riff::BigEndian2Float(strrev(substr($rgadData, 0, 4))); // LittleEndian2Float()
  125. $info_riff_raw_rgad['nRadioRgAdjust'] = getid3_lib::$endian_function(substr($rgadData, 4, 2));
  126. $info_riff_raw_rgad['nAudiophileRgAdjust'] = getid3_lib::$endian_function(substr($rgadData, 6, 2));
  127. $n_track_rg_adjust_bit_string = str_pad(decbin($info_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
  128. $n_album_rg_adjust_bit_string = str_pad(decbin($info_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
  129. $info_riff_raw_rgad_track['name'] = bindec(substr($n_track_rg_adjust_bit_string, 0, 3));
  130. $info_riff_raw_rgad_track['originator'] = bindec(substr($n_track_rg_adjust_bit_string, 3, 3));
  131. $info_riff_raw_rgad_track['signbit'] = bindec($n_track_rg_adjust_bit_string[6]);
  132. $info_riff_raw_rgad_track['adjustment'] = bindec(substr($n_track_rg_adjust_bit_string, 7, 9));
  133. $info_riff_raw_rgad_album['name'] = bindec(substr($n_album_rg_adjust_bit_string, 0, 3));
  134. $info_riff_raw_rgad_album['originator'] = bindec(substr($n_album_rg_adjust_bit_string, 3, 3));
  135. $info_riff_raw_rgad_album['signbit'] = bindec($n_album_rg_adjust_bit_string[6]);
  136. $info_riff_raw_rgad_album['adjustment'] = bindec(substr($n_album_rg_adjust_bit_string, 7, 9));
  137. $info_riff['rgad']['peakamplitude'] = $info_riff_raw_rgad['fPeakAmplitude'];
  138. if (($info_riff_raw_rgad_track['name'] != 0) && ($info_riff_raw_rgad_track['originator'] != 0)) {
  139. $info_riff['rgad']['track']['name'] = getid3_lib_replaygain::NameLookup($info_riff_raw_rgad_track['name']);
  140. $info_riff['rgad']['track']['originator'] = getid3_lib_replaygain::OriginatorLookup($info_riff_raw_rgad_track['originator']);
  141. $info_riff['rgad']['track']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($info_riff_raw_rgad_track['adjustment'], $info_riff_raw_rgad_track['signbit']);
  142. }
  143. if (($info_riff_raw_rgad_album['name'] != 0) && ($info_riff_raw_rgad_album['originator'] != 0)) {
  144. $info_riff['rgad']['album']['name'] = getid3_lib_replaygain::NameLookup($info_riff_raw_rgad_album['name']);
  145. $info_riff['rgad']['album']['originator'] = getid3_lib_replaygain::OriginatorLookup($info_riff_raw_rgad_album['originator']);
  146. $info_riff['rgad']['album']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($info_riff_raw_rgad_album['adjustment'], $info_riff_raw_rgad_album['signbit']);
  147. }
  148. }
  149. if (isset($info_riff_wave['fact'][0]['data'])) {
  150. $info_riff_raw['fact']['NumberOfSamples'] = getid3_lib::$endian_function(substr($info_riff_wave['fact'][0]['data'], 0, 4));
  151. // This should be a good way of calculating exact playtime, but some sample files have had incorrect number of samples, so cannot use this method
  152. // if (!empty($info_riff_raw['fmt ']['nSamplesPerSec'])) {
  153. // $getid3->info['playtime_seconds'] = (float)$info_riff_raw['fact']['NumberOfSamples'] / $info_riff_raw['fmt ']['nSamplesPerSec'];
  154. // }
  155. }
  156. if (!empty($info_riff_raw['fmt ']['nAvgBytesPerSec'])) {
  157. $info_audio['bitrate'] = (int)$info_riff_raw['fmt ']['nAvgBytesPerSec'] * 8;
  158. }
  159. if (isset($info_riff_wave['bext'][0]['data'])) {
  160. $info_riff_wave_bext_0 = &$info_riff_wave['bext'][0];
  161. getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_wave_bext_0, $info_riff_wave_bext_0['data'], 0,
  162. array (
  163. 'title' => -256,
  164. 'author' => -32,
  165. 'reference' => -32,
  166. 'origin_date' => -10,
  167. 'origin_time' => -8,
  168. 'time_reference' => 8,
  169. 'bwf_version' => 1,
  170. 'reserved' => 254
  171. )
  172. );
  173. foreach (array ('title', 'author', 'reference') as $key) {
  174. $info_riff_wave_bext_0[$key] = trim($info_riff_wave_bext_0[$key]);
  175. }
  176. $info_riff_wave_bext_0['coding_history'] = explode("\r\n", trim(substr($info_riff_wave_bext_0['data'], 601)));
  177. $info_riff_wave_bext_0['origin_date_unix'] = gmmktime(substr($info_riff_wave_bext_0['origin_time'], 0, 2),
  178. substr($info_riff_wave_bext_0['origin_time'], 3, 2),
  179. substr($info_riff_wave_bext_0['origin_time'], 6, 2),
  180. substr($info_riff_wave_bext_0['origin_date'], 5, 2),
  181. substr($info_riff_wave_bext_0['origin_date'], 8, 2),
  182. substr($info_riff_wave_bext_0['origin_date'], 0, 4));
  183. $info_riff['comments']['author'][] = $info_riff_wave_bext_0['author'];
  184. $info_riff['comments']['title'][] = $info_riff_wave_bext_0['title'];
  185. }
  186. if (isset($info_riff_wave['MEXT'][0]['data'])) {
  187. $info_riff_wave_mext_0 = &$info_riff_wave['MEXT'][0];
  188. $info_riff_wave_mext_0['raw']['sound_information'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 0, 2));
  189. $info_riff_wave_mext_0['flags']['homogenous'] = (bool)($info_riff_wave_mext_0['raw']['sound_information'] & 0x0001);
  190. if ($info_riff_wave_mext_0['flags']['homogenous']) {
  191. $info_riff_wave_mext_0['flags']['padding'] = ($info_riff_wave_mext_0['raw']['sound_information'] & 0x0002) ? false : true;
  192. $info_riff_wave_mext_0['flags']['22_or_44'] = (bool)($info_riff_wave_mext_0['raw']['sound_information'] & 0x0004);
  193. $info_riff_wave_mext_0['flags']['free_format'] = (bool)($info_riff_wave_mext_0['raw']['sound_information'] & 0x0008);
  194. $info_riff_wave_mext_0['nominal_frame_size'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 2, 2));
  195. }
  196. $info_riff_wave_mext_0['anciliary_data_length'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 6, 2));
  197. $info_riff_wave_mext_0['raw']['anciliary_data_def'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 8, 2));
  198. $info_riff_wave_mext_0['flags']['anciliary_data_left'] = (bool)($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x0001);
  199. $info_riff_wave_mext_0['flags']['anciliary_data_free'] = (bool)($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x0002);
  200. $info_riff_wave_mext_0['flags']['anciliary_data_right'] = (bool)($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x0004);
  201. }
  202. if (isset($info_riff_wave['cart'][0]['data'])) {
  203. $info_riff_wave_cart_0 = &$info_riff_wave['cart'][0];
  204. getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_wave_cart_0, $info_riff_wave_cart_0['data'], 0,
  205. array (
  206. 'version' => -4,
  207. 'title' => -64,
  208. 'artist' => -64,
  209. 'cut_id' => -64,
  210. 'client_id' => -64,
  211. 'category' => -64,
  212. 'classification' => -64,
  213. 'out_cue' => -64,
  214. 'start_date' => -10,
  215. 'start_time' => -8,
  216. 'end_date' => -10,
  217. 'end_time' => -8,
  218. 'producer_app_id' => -64,
  219. 'producer_app_version' => -64,
  220. 'user_defined_text' => -64,
  221. )
  222. );
  223. foreach (array ('artist', 'cut_id', 'client_id', 'category', 'classification', 'out_cue', 'start_date', 'start_time', 'end_date', 'end_time', 'producer_app_id', 'producer_app_version', 'user_defined_text') as $key) {
  224. $info_riff_wave_cart_0[$key] = trim($info_riff_wave_cart_0[$key]);
  225. }
  226. $info_riff_wave_cart_0['zero_db_reference'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_cart_0['data'], 680, 4), true);
  227. for ($i = 0; $i < 8; $i++) {
  228. $info_riff_wave_cart_0['post_time'][$i]['usage_fourcc'] = substr($info_riff_wave_cart_0['data'], 684 + ($i * 8), 4);
  229. $info_riff_wave_cart_0['post_time'][$i]['timer_value'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_cart_0['data'], 684 + ($i * 8) + 4, 4));
  230. }
  231. $info_riff_wave_cart_0['url'] = trim(substr($info_riff_wave_cart_0['data'], 748, 1024));
  232. $info_riff_wave_cart_0['tag_text'] = explode("\r\n", trim(substr($info_riff_wave_cart_0['data'], 1772)));
  233. $info_riff['comments']['artist'][] = $info_riff_wave_cart_0['artist'];
  234. $info_riff['comments']['title'][] = $info_riff_wave_cart_0['title'];
  235. }
  236. if (isset($info_riff_wave['SNDM'][0]['data'])) {
  237. // SoundMiner metadata
  238. // shortcuts
  239. $info_riff_wave_SNDM_0 = &$info_riff_wave['SNDM'][0];
  240. $info_riff_wave_SNDM_0_data = &$info_riff_wave_SNDM_0['data'];
  241. $SNDM_startoffset = 0;
  242. $SNDM_endoffset = $info_riff_wave_SNDM_0['size'];
  243. while ($SNDM_startoffset < $SNDM_endoffset) {
  244. $SNDM_thisTagOffset = 0;
  245. $SNDM_thisTagSize = getid3_lib::BigEndian2Int(substr($info_riff_wave_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 4));
  246. $SNDM_thisTagOffset += 4;
  247. $SNDM_thisTagKey = substr($info_riff_wave_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 4);
  248. $SNDM_thisTagOffset += 4;
  249. $SNDM_thisTagDataSize = getid3_lib::BigEndian2Int(substr($info_riff_wave_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 2));
  250. $SNDM_thisTagOffset += 2;
  251. $SNDM_thisTagDataFlags = getid3_lib::BigEndian2Int(substr($info_riff_wave_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 2));
  252. $SNDM_thisTagOffset += 2;
  253. $SNDM_thisTagDataText = substr($info_riff_wave_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, $SNDM_thisTagDataSize);
  254. $SNDM_thisTagOffset += $SNDM_thisTagDataSize;
  255. if ($SNDM_thisTagSize != (4 + 4 + 2 + 2 + $SNDM_thisTagDataSize)) {
  256. $getid3->warning('RIFF.WAVE.SNDM.data contains tag not expected length (expected: '.$SNDM_thisTagSize.', found: '.(4 + 4 + 2 + 2 + $SNDM_thisTagDataSize).') at offset '.$SNDM_startoffset.' (file offset '.($info_riff_wave_SNDM_0['offset'] + $SNDM_startoffset).')');
  257. break;
  258. } elseif ($SNDM_thisTagSize <= 0) {
  259. $getid3->warning('RIFF.WAVE.SNDM.data contains zero-size tag at offset '.$SNDM_startoffset.' (file offset '.($info_riff_wave_SNDM_0['offset'] + $SNDM_startoffset).')');
  260. break;
  261. }
  262. $SNDM_startoffset += $SNDM_thisTagSize;
  263. $info_riff_wave_SNDM_0['parsed_raw'][$SNDM_thisTagKey] = $SNDM_thisTagDataText;
  264. $parsedkey = $this->RIFFwaveSNDMtagLookup($SNDM_thisTagKey);
  265. if ($parsedkey) {
  266. $info_riff_wave_SNDM_0['parsed'][$parsedkey] = $SNDM_thisTagDataText;
  267. } else {
  268. $getid3->warning('RIFF.WAVE.SNDM contains unknown tag "'.$SNDM_thisTagKey.'" at offset '.$SNDM_startoffset.' (file offset '.($info_riff_wave_SNDM_0['offset'] + $SNDM_startoffset).')');
  269. }
  270. }
  271. $tagmapping = array(
  272. 'tracktitle'=>'title',
  273. 'category' =>'genre',
  274. 'cdtitle' =>'album',
  275. 'tracktitle'=>'title',
  276. );
  277. foreach ($tagmapping as $fromkey => $tokey) {
  278. if (isset($info_riff_wave_SNDM_0['parsed'][$fromkey])) {
  279. $info_riff['comments'][$tokey][] = $info_riff_wave_SNDM_0['parsed'][$fromkey];
  280. }
  281. }
  282. }
  283. if (!isset($info_audio['bitrate']) && isset($info_riff_audio[$stream_index]['bitrate'])) {
  284. $info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate'];
  285. $getid3->info['playtime_seconds'] = (float)((($info_avdataend - $info_avdataoffset) * 8) / $info_audio['bitrate']);
  286. }
  287. if (@$getid3->info['wavpack']) {
  288. if (!$this->data_string_flag) {
  289. $info_audio_dataformat = 'wavpack';
  290. $info_audio['bitrate_mode'] = 'vbr';
  291. $info_audio['encoder'] = 'WavPack v'.$getid3->info['wavpack']['version'];
  292. // Reset to the way it was - RIFF parsing will have messed this up
  293. $info_avdataend = $original['avdataend'];
  294. $info_audio['bitrate'] = (($info_avdataend - $info_avdataoffset) * 8) / $getid3->info['playtime_seconds'];
  295. $this->fseek($info_avdataoffset - 44, SEEK_SET);
  296. $riff_data = $this->fread(44);
  297. $orignal_riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_data, 4, 4)) + 8;
  298. $orignal_riff_data_size = getid3_lib::LittleEndian2Int(substr($riff_data, 40, 4)) + 44;
  299. if ($orignal_riff_header_size > $orignal_riff_data_size) {
  300. $info_avdataend -= ($orignal_riff_header_size - $orignal_riff_data_size);
  301. $this->fseek($info_avdataend, SEEK_SET);
  302. $riff_data .= $this->fread($orignal_riff_header_size - $orignal_riff_data_size);
  303. }
  304. // move the data chunk after all other chunks (if any)
  305. // so that the RIFF parser doesn't see EOF when trying
  306. // to skip over the data chunk
  307. $riff_data = substr($riff_data, 0, 36).substr($riff_data, 44).substr($riff_data, 36, 8);
  308. // Save audio info key
  309. $saved_info_audio = $info_audio;
  310. // Analyze riff_data
  311. $this->AnalyzeString($riff_data);
  312. // Restore info key
  313. $info_audio = $saved_info_audio;
  314. }
  315. }
  316. if (isset($info_riff_raw['fmt ']['wFormatTag'])) {
  317. switch ($info_riff_raw['fmt ']['wFormatTag']) {
  318. case 0x08AE: // ClearJump LiteWave
  319. $info_audio['bitrate_mode'] = 'vbr';
  320. $info_audio_dataformat = 'litewave';
  321. //typedef struct tagSLwFormat {
  322. // WORD m_wCompFormat; // low byte defines compression method, high byte is compression flags
  323. // DWORD m_dwScale; // scale factor for lossy compression
  324. // DWORD m_dwBlockSize; // number of samples in encoded blocks
  325. // WORD m_wQuality; // alias for the scale factor
  326. // WORD m_wMarkDistance; // distance between marks in bytes
  327. // WORD m_wReserved;
  328. //
  329. // //following paramters are ignored if CF_FILESRC is not set
  330. // DWORD m_dwOrgSize; // original file size in bytes
  331. // WORD m_bFactExists; // indicates if 'fact' chunk exists in the original file
  332. // DWORD m_dwRiffChunkSize; // riff chunk size in the original file
  333. //
  334. // PCMWAVEFORMAT m_OrgWf; // original wave format
  335. // }SLwFormat, *PSLwFormat;
  336. $info_riff['litewave']['raw'] = array ();
  337. $info_riff_litewave = &$info_riff['litewave'];
  338. $info_riff_litewave_raw = &$info_riff_litewave['raw'];
  339. getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_litewave_raw, $info_riff_wave['fmt '][0]['data'], 18,
  340. array (
  341. 'compression_method' => 1,
  342. 'compression_flags' => 1,
  343. 'm_dwScale' => 4,
  344. 'm_dwBlockSize' => 4,
  345. 'm_wQuality' => 2,
  346. 'm_wMarkDistance' => 2,
  347. 'm_wReserved' => 2,
  348. 'm_dwOrgSize' => 4,
  349. 'm_bFactExists' => 2,
  350. 'm_dwRiffChunkSize' => 4
  351. )
  352. );
  353. //$info_riff_litewave['quality_factor'] = intval(round((2000 - $info_riff_litewave_raw['m_dwScale']) / 20));
  354. $info_riff_litewave['quality_factor'] = $info_riff_litewave_raw['m_wQuality'];
  355. $info_riff_litewave['flags']['raw_source'] = ($info_riff_litewave_raw['compression_flags'] & 0x01) ? false : true;
  356. $info_riff_litewave['flags']['vbr_blocksize'] = ($info_riff_litewave_raw['compression_flags'] & 0x02) ? false : true;
  357. $info_riff_litewave['flags']['seekpoints'] = (bool)($info_riff_litewave_raw['compression_flags'] & 0x04);
  358. $info_audio['lossless'] = (($info_riff_litewave_raw['m_wQuality'] == 100) ? true : false);
  359. $info_audio['encoder_options'] = '-q'.$info_riff_litewave['quality_factor'];
  360. break;
  361. }
  362. }
  363. if ($info_avdataend > $getid3->info['filesize']) {
  364. switch (@$info_audio_dataformat) {
  365. case 'wavpack': // WavPack
  366. case 'lpac': // LPAC
  367. case 'ofr': // OptimFROG
  368. case 'ofs': // OptimFROG DualStream
  369. // lossless compressed audio formats that keep original RIFF headers - skip warning
  370. break;
  371. case 'litewave':
  372. if (($info_avdataend - $getid3->info['filesize']) == 1) {
  373. // LiteWave appears to incorrectly *not* pad actual output file
  374. // to nearest WORD boundary so may appear to be short by one
  375. // byte, in which case - skip warning
  376. } else {
  377. // Short by more than one byte, throw warning
  378. $getid3->warning('Probably truncated file - expecting '.$info_riff[$riff_sub_type]['data'][0]['size'].' bytes of data, only found '.($getid3->info['filesize'] - $info_avdataoffset).' (short by '.($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] - $info_avdataoffset)).' bytes)');
  379. }
  380. break;
  381. default:
  382. if ((($info_avdataend - $getid3->info['filesize']) == 1) && (($info_riff[$riff_sub_type]['data'][0]['size'] % 2) == 0) && ((($getid3->info['filesize'] - $info_avdataoffset) % 2) == 1)) {
  383. // output file appears to be incorrectly *not* padded to nearest WORD boundary
  384. // Output less severe warning
  385. $getid3->warning('File should probably be padded to nearest WORD boundary, but it is not (expecting '.$info_riff[$riff_sub_type]['data'][0]['size'].' bytes of data, only found '.($getid3->info['filesize'] - $info_avdataoffset).' therefore short by '.($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] - $info_avdataoffset)).' bytes)');
  386. $info_avdataend = $getid3->info['filesize'];
  387. break;
  388. }
  389. // Short by more than one byte, throw warning
  390. $getid3->warning('Probably truncated file - expecting '.$info_riff[$riff_sub_type]['data'][0]['size'].' bytes of data, only found '.($getid3->info['filesize'] - $info_avdataoffset).' (short by '.($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] - $info_avdataoffset)).' bytes)');
  391. $info_avdataend = $getid3->info['filesize'];
  392. break;
  393. }
  394. }
  395. if (!empty($getid3->info['mpeg']['audio']['LAME']['audio_bytes'])) {
  396. if ((($info_avdataend - $info_avdataoffset) - $getid3->info['mpeg']['audio']['LAME']['audio_bytes']) == 1) {
  397. $info_avdataend--;
  398. $getid3->warning('Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored');
  399. }
  400. }
  401. if (@$info_audio_dataformat == 'ac3') {
  402. unset($info_audio['bits_per_sample']);
  403. if (!empty($getid3->info['ac3']['bitrate']) && ($getid3->info['ac3']['bitrate'] != $info_audio['bitrate'])) {
  404. $info_audio['bitrate'] = $getid3->info['ac3']['bitrate'];
  405. }
  406. }
  407. break;
  408. case 'AVI ':
  409. $info_video['bitrate_mode'] = 'vbr'; // maybe not, but probably
  410. $info_video['dataformat'] = 'avi';
  411. $getid3->info['mime_type'] = 'video/avi';
  412. if (isset($info_riff[$riff_sub_type]['movi']['offset'])) {
  413. $info_avdataoffset = $info_riff[$riff_sub_type]['movi']['offset'] + 8;
  414. $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['movi']['size'];
  415. if ($info_avdataend > $getid3->info['filesize']) {
  416. $getid3->warning('Probably truncated file - expecting '.$info_riff[$riff_sub_type]['movi']['size'].' bytes of data, only found '.($getid3->info['filesize'] - $info_avdataoffset).' (short by '.($info_riff[$riff_sub_type]['movi']['size'] - ($getid3->info['filesize'] - $info_avdataoffset)).' bytes)');
  417. $info_avdataend = $getid3->info['filesize'];
  418. }
  419. }
  420. if (isset($info_riff['AVI ']['hdrl']['avih'][$stream_index]['data'])) {
  421. $avihData = $info_riff['AVI ']['hdrl']['avih'][$stream_index]['data'];
  422. $info_riff_raw['avih'] = array ();
  423. $info_riff_raw_avih = &$info_riff_raw['avih'];
  424. getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_avih, $avihData, 0,
  425. array (
  426. 'dwMicroSecPerFrame' => 4, // frame display rate (or 0L)
  427. 'dwMaxBytesPerSec' => 4, // max. transfer rate
  428. 'dwPaddingGranularity' => 4, // pad to multiples of this size; normally 2K.
  429. 'dwFlags' => 4, // the ever-present flags
  430. 'dwTotalFrames' => 4, // # frames in file
  431. 'dwInitialFrames' => 4,
  432. 'dwStreams' => 4,
  433. 'dwSuggestedBufferSize' => 4,
  434. 'dwWidth' => 4,
  435. 'dwHeight' => 4,
  436. 'dwScale' => 4,
  437. 'dwRate' => 4,
  438. 'dwStart' => 4,
  439. 'dwLength' => 4
  440. )
  441. );
  442. $info_riff_raw_avih['flags']['hasindex'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000010);
  443. $info_riff_raw_avih['flags']['mustuseindex'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000020);
  444. $info_riff_raw_avih['flags']['interleaved'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000100);
  445. $info_riff_raw_avih['flags']['trustcktype'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000800);
  446. $info_riff_raw_avih['flags']['capturedfile'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00010000);
  447. $info_riff_raw_avih['flags']['copyrighted'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00020010);
  448. $info_riff_video[$stream_index] = array ();
  449. $info_riff_video_current = &$info_riff_video[$stream_index];
  450. if ($info_riff_raw_avih['dwWidth'] > 0) {
  451. $info_riff_video_current['frame_width'] = $info_riff_raw_avih['dwWidth'];
  452. $info_video['resolution_x'] = $info_riff_video_current['frame_width'];
  453. }
  454. if ($info_riff_raw_avih['dwHeight'] > 0) {
  455. $info_riff_video_current['frame_height'] = $info_riff_raw_avih['dwHeight'];
  456. $info_video['resolution_y'] = $info_riff_video_current['frame_height'];
  457. }
  458. if ($info_riff_raw_avih['dwTotalFrames'] > 0) {
  459. $info_riff_video_current['total_frames'] = $info_riff_raw_avih['dwTotalFrames'];
  460. $info_video['total_frames'] = $info_riff_video_current['total_frames'];
  461. }
  462. $info_riff_video_current['frame_rate'] = round(1000000 / $info_riff_raw_avih['dwMicroSecPerFrame'], 3);
  463. $info_video['frame_rate'] = $info_riff_video_current['frame_rate'];
  464. }
  465. if (isset($info_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) {
  466. if (is_array($info_riff['AVI ']['hdrl']['strl']['strh'])) {
  467. for ($i = 0; $i < count($info_riff['AVI ']['hdrl']['strl']['strh']); $i++) {
  468. if (isset($info_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'])) {
  469. $strh_data = $info_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'];
  470. $strh_fcc_type = substr($strh_data, 0, 4);
  471. if (isset($info_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) {
  472. $strf_data = $info_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'];
  473. // shortcut
  474. $info_riff_raw_strf_strh_fcc_type_stream_index = &$info_riff_raw['strf'][$strh_fcc_type][$stream_index];
  475. switch ($strh_fcc_type) {
  476. case 'auds':
  477. $info_audio['bitrate_mode'] = 'cbr';
  478. $info_audio_dataformat = 'wav';
  479. if (isset($info_riff_audio) && is_array($info_riff_audio)) {
  480. $stream_index = count($info_riff_audio);
  481. }
  482. $info_riff_audio[$stream_index] = getid3_riff::RIFFparseWAVEFORMATex($strf_data);
  483. $info_audio['wformattag'] = $info_riff_audio[$stream_index]['raw']['wFormatTag'];
  484. // shortcut
  485. $info_audio['streams'][$stream_index] = $info_riff_audio[$stream_index];
  486. $info_audio_streams_currentstream = &$info_audio['streams'][$stream_index];
  487. if (@$info_audio_streams_currentstream['bits_per_sample'] === 0) {
  488. unset($info_audio_streams_currentstream['bits_per_sample']);
  489. }
  490. $info_audio_streams_currentstream['wformattag'] = $info_audio_streams_currentstream['raw']['wFormatTag'];
  491. unset($info_audio_streams_currentstream['raw']);
  492. // shortcut
  493. $info_riff_raw['strf'][$strh_fcc_type][$stream_index] = $info_riff_audio[$stream_index]['raw'];
  494. unset($info_riff_audio[$stream_index]['raw']);
  495. $info_audio = getid3_riff::array_merge_noclobber($info_audio, $info_riff_audio[$stream_index]);
  496. $info_audio['lossless'] = false;
  497. switch ($info_riff_raw_strf_strh_fcc_type_stream_index['wFormatTag']) {
  498. case 0x0001: // PCM
  499. $info_audio_dataformat = 'wav';
  500. $info_audio['lossless'] = true;
  501. break;
  502. case 0x0050: // MPEG Layer 2 or Layer 1
  503. $info_audio_dataformat = 'mp2'; // Assume Layer-2
  504. break;
  505. case 0x0055: // MPEG Layer 3
  506. $info_audio_dataformat = 'mp3';
  507. break;
  508. case 0x00FF: // AAC
  509. $info_audio_dataformat = 'aac';
  510. break;
  511. case 0x0161: // Windows Media v7 / v8 / v9
  512. case 0x0162: // Windows Media Professional v9
  513. case 0x0163: // Windows Media Lossess v9
  514. $info_audio_dataformat = 'wma';
  515. break;
  516. case 0x2000: // AC-3
  517. $info_audio_dataformat = 'ac3';
  518. break;
  519. case 0x2001: // DTS
  520. $info_audio_dataformat = 'dts';
  521. break;
  522. default:
  523. $info_audio_dataformat = 'wav';
  524. break;
  525. }
  526. $info_audio_streams_currentstream['dataformat'] = $info_audio_dataformat;
  527. $info_audio_streams_currentstream['lossless'] = $info_audio['lossless'];
  528. $info_audio_streams_currentstream['bitrate_mode'] = $info_audio['bitrate_mode'];
  529. break;
  530. case 'iavs':
  531. case 'vids':
  532. // shortcut
  533. $info_riff_raw['strh'][$i] = array ();
  534. $info_riff_raw_strh_current = &$info_riff_raw['strh'][$i];
  535. getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_strh_current, $strh_data, 0,
  536. array (
  537. 'fccType' => -4, // same as $strh_fcc_type;
  538. 'fccHandler' => -4,
  539. 'dwFlags' => 4, // Contains AVITF_* flags
  540. 'wPriority' => 2,
  541. 'wLanguage' => 2,
  542. 'dwInitialFrames' => 4,
  543. 'dwScale' => 4,
  544. 'dwRate' => 4,
  545. 'dwStart' => 4,
  546. 'dwLength' => 4,
  547. 'dwSuggestedBufferSize' => 4,
  548. 'dwQuality' => 4,
  549. 'dwSampleSize' => 4,
  550. 'rcFrame' => 4
  551. )
  552. );
  553. $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strh_current['fccHandler']);
  554. $info_video['fourcc'] = $info_riff_raw_strh_current['fccHandler'];
  555. if (!$info_riff_video_current['codec'] && isset($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']) && getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'])) {
  556. $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']);
  557. $info_video['fourcc'] = $info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'];
  558. }
  559. $info_video['codec'] = $info_riff_video_current['codec'];
  560. $info_video['pixel_aspect_ratio'] = (float)1;
  561. switch ($info_riff_raw_strh_current['fccHandler']) {
  562. case 'HFYU': // Huffman Lossless Codec
  563. case 'IRAW': // Intel YUV Uncompressed
  564. case 'YUY2': // Uncompressed YUV 4:2:2
  565. $info_video['lossless'] = true;
  566. break;
  567. default:
  568. $info_video['lossless'] = false;
  569. break;
  570. }
  571. switch ($strh_fcc_type) {
  572. case 'vids':
  573. getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_strf_strh_fcc_type_stream_index, $strf_data, 0,
  574. array (
  575. 'biSize' => 4, // number of bytes required by the BITMAPINFOHEADER structure
  576. 'biWidth' => 4, // width of the bitmap in pixels
  577. 'biHeight' => 4, // height of the bitmap in pixels. If biHeight is positive, the bitmap is a 'bottom-up' DIB and its origin is the lower left corner. If biHeight is negative, the bitmap is a 'top-down' DIB and its origin is the upper left corner
  578. 'biPlanes' => 2, // number of color planes on the target device. In most cases this value must be set to 1
  579. 'biBitCount' => 2, // Specifies the number of bits per pixels
  580. 'fourcc' => -4, //
  581. 'biSizeImage' => 4, // size of the bitmap data section of the image (the actual pixel data, excluding BITMAPINFOHEADER and RGBQUAD structures)
  582. 'biXPelsPerMeter' => 4, // horizontal resolution, in pixels per metre, of the target device
  583. 'biYPelsPerMeter' => 4, // vertical resolution, in pixels per metre, of the target device
  584. 'biClrUsed' => 4, // actual number of color indices in the color table used by the bitmap. If this value is zero, the bitmap uses the maximum number of colors corresponding to the value of the biBitCount member for the compression mode specified by biCompression
  585. 'biClrImportant' => 4 // number of color indices that are considered important for displaying the bitmap. If this value is zero, all colors are important
  586. )
  587. );
  588. $info_video['bits_per_sample'] = $info_riff_raw_strf_strh_fcc_type_stream_index['biBitCount'];
  589. if ($info_riff_video_current['codec'] == 'DV') {
  590. $info_riff_video_current['dv_type'] = 2;
  591. }
  592. break;
  593. case 'iavs':
  594. $info_riff_video_current['dv_type'] = 1;
  595. break;
  596. }
  597. break;
  598. default:
  599. $getid3->warning('Unhandled fccType for stream ('.$i.'): "'.$strh_fcc_type.'"');
  600. break;
  601. }
  602. }
  603. }
  604. if (isset($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']) && getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'])) {
  605. $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']);
  606. $info_video['codec'] = $info_riff_video_current['codec'];
  607. $info_video['fourcc'] = $info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'];
  608. switch ($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']) {
  609. case 'HFYU': // Huffman Lossless Codec
  610. case 'IRAW': // Intel YUV Uncompressed
  611. case 'YUY2': // Uncompressed YUV 4:2:2
  612. $info_video['lossless'] = true;
  613. $info_video['bits_per_sample'] = 24;
  614. break;
  615. default:
  616. $info_video['lossless'] = false;
  617. $info_video['bits_per_sample'] = 24;
  618. break;
  619. }
  620. }
  621. }
  622. }
  623. }
  624. break;
  625. case 'CDDA':
  626. $info_audio['bitrate_mode'] = 'cbr';
  627. $info_audio_dataformat = 'cda';
  628. $info_audio['lossless'] = true;
  629. unset($getid3->info['mime_type']);
  630. $info_avdataoffset = 44;
  631. if (isset($info_riff['CDDA']['fmt '][0]['data'])) {
  632. $info_riff_cdda_fmt_0 = &$info_riff['CDDA']['fmt '][0];
  633. getid3_lib::ReadSequence($this->endian_function, $info_riff_cdda_fmt_0, $info_riff_cdda_fmt_0['data'], 0,
  634. array (
  635. 'unknown1' => 2,
  636. 'track_num' => 2,
  637. 'disc_id' => 4,
  638. 'start_offset_frame' => 4,
  639. 'playtime_frames' => 4,
  640. 'unknown6' => 4,
  641. 'unknown7' => 4
  642. )
  643. );
  644. $info_riff_cdda_fmt_0['start_offset_seconds'] = (float)$info_riff_cdda_fmt_0['start_offset_frame'] / 75;
  645. $info_riff_cdda_fmt_0['playtime_seconds'] = (float)$info_riff_cdda_fmt_0['playtime_frames'] / 75;
  646. $getid3->info['comments']['track'] = $info_riff_cdda_fmt_0['track_num'];
  647. $getid3->info['playtime_seconds'] = $info_riff_cdda_fmt_0['playtime_seconds'];
  648. // hardcoded data for CD-audio
  649. $info_audio['sample_rate'] = 44100;
  650. $info_audio['channels'] = 2;
  651. $info_audio['bits_per_sample'] = 16;
  652. $info_audio['bitrate'] = $info_audio['sample_rate'] * $info_audio['channels'] * $info_audio['bits_per_sample'];
  653. $info_audio['bitrate_mode'] = 'cbr';
  654. }
  655. break;
  656. case 'AIFF':
  657. case 'AIFC':
  658. $info_audio['bitrate_mode'] = 'cbr';
  659. $info_audio_dataformat = 'aiff';
  660. $info_audio['lossless'] = true;
  661. $getid3->info['mime_type'] = 'audio/x-aiff';
  662. if (isset($info_riff[$riff_sub_type]['SSND'][0]['offset'])) {
  663. $info_avdataoffset = $info_riff[$riff_sub_type]['SSND'][0]['offset'] + 8;
  664. $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['SSND'][0]['size'];
  665. if ($info_avdataend > $getid3->info['filesize']) {
  666. if (($info_avdataend == ($getid3->info['filesize'] + 1)) && (($getid3->info['filesize'] % 2) == 1)) {
  667. // structures rounded to 2-byte boundary, but dumb encoders
  668. // forget to pad end of file to make this actually work
  669. } else {
  670. $getid3->warning('Probable truncated AIFF file: expecting '.$info_riff[$riff_sub_type]['SSND'][0]['size'].' bytes of audio data, only '.($getid3->info['filesize'] - $info_avdataoffset).' bytes found');
  671. }
  672. $info_avdataend = $getid3->info['filesize'];
  673. }
  674. }
  675. if (isset($info_riff[$riff_sub_type]['COMM'][0]['data'])) {
  676. // shortcut
  677. $info_riff_RIFFsubtype_COMM_0_data = &$info_riff[$riff_sub_type]['COMM'][0]['data'];
  678. $info_riff_audio['channels'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 0, 2));
  679. $info_riff_audio['total_samples'] = getid3_lib::BigEndian2Int( substr($info_riff_RIFFsubtype_COMM_0_data, 2, 4));
  680. $info_riff_audio['bits_per_sample'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 6, 2));
  681. $info_riff_audio['sample_rate'] = (int)getid3_riff::BigEndian2Float(substr($info_riff_RIFFsubtype_COMM_0_data, 8, 10));
  682. if ($info_riff[$riff_sub_type]['COMM'][0]['size'] > 18) {
  683. $info_riff_audio['codec_fourcc'] = substr($info_riff_RIFFsubtype_COMM_0_data, 18, 4);
  684. $codec_name_size = getid3_lib::BigEndian2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 22, 1));
  685. $info_riff_audio['codec_name'] = substr($info_riff_RIFFsubtype_COMM_0_data, 23, $codec_name_size);
  686. switch ($info_riff_audio['codec_name']) {
  687. case 'NONE':
  688. $info_audio['codec'] = 'Pulse Code Modulation (PCM)';
  689. $info_audio['lossless'] = true;
  690. break;
  691. case '':
  692. switch ($info_riff_audio['codec_fourcc']) {
  693. // http://developer.apple.com/qa/snd/snd07.html
  694. case 'sowt':
  695. $info_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM';
  696. $info_audio['lossless'] = true;
  697. break;
  698. case 'twos':
  699. $info_riff_audio['codec_name'] = 'Two\'s Compliment Big-Endian PCM';
  700. $info_audio['lossless'] = true;
  701. break;
  702. default:
  703. break;
  704. }
  705. break;
  706. default:
  707. $info_audio['codec'] = $info_riff_audio['codec_name'];
  708. $info_audio['lossless'] = false;
  709. break;
  710. }
  711. }
  712. $info_audio['channels'] = $info_riff_audio['channels'];
  713. if ($info_riff_audio['bits_per_sample'] > 0) {
  714. $info_audio['bits_per_sample'] = $info_riff_audio['bits_per_sample'];
  715. }
  716. $info_audio['sample_rate'] = $info_riff_audio['sample_rate'];
  717. $getid3->info['playtime_seconds'] = $info_riff_audio['total_samples'] / $info_audio['sample_rate'];
  718. }
  719. if (isset($info_riff[$riff_sub_type]['COMT'])) {
  720. $comment_count = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], 0, 2));
  721. $offset = 2;
  722. for ($i = 0; $i < $comment_count; $i++) {
  723. $getid3->info['comments_raw'][$i]['timestamp'] = getid3_lib::BigEndian2Int( substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 4));
  724. $offset += 4;
  725. $getid3->info['comments_raw'][$i]['marker_id'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 2));
  726. $offset += 2;
  727. $comment_length = getid3_lib::BigEndian2Int( substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 2));
  728. $offset += 2;
  729. $getid3->info['comments_raw'][$i]['comment'] = substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, $comment_length);
  730. $offset += $comment_length;
  731. $getid3->info['comments_raw'][$i]['timestamp_unix'] = getid3_riff::DateMac2Unix($getid3->info['comments_raw'][$i]['timestamp']);
  732. $info_riff['comments']['comment'][] = $getid3->info['comments_raw'][$i]['comment'];
  733. }
  734. }
  735. foreach (array ('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment') as $key => $value) {
  736. if (isset($info_riff[$riff_sub_type][$key][0]['data'])) {
  737. $info_riff['comments'][$value][] = $info_riff[$riff_sub_type][$key][0]['data'];
  738. }
  739. }
  740. break;
  741. case '8SVX':
  742. $info_audio['bitrate_mode'] = 'cbr';
  743. $info_audio_dataformat = '8svx';
  744. $info_audio['bits_per_sample'] = 8;
  745. $info_audio['channels'] = 1; // overridden below, if need be
  746. $getid3->info['mime_type'] = 'audio/x-aiff';
  747. if (isset($info_riff[$riff_sub_type]['BODY'][0]['offset'])) {
  748. $info_avdataoffset = $info_riff[$riff_sub_type]['BODY'][0]['offset'] + 8;
  749. $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['BODY'][0]['size'];
  750. if ($info_avdataend > $getid3->info['filesize']) {
  751. $getid3->warning('Probable truncated AIFF file: expecting '.$info_riff[$riff_sub_type]['BODY'][0]['size'].' bytes of audio data, only '.($getid3->info['filesize'] - $info_avdataoffset).' bytes found');
  752. }
  753. }
  754. if (isset($info_riff[$riff_sub_type]['VHDR'][0]['offset'])) {
  755. // shortcut
  756. $info_riff_riff_sub_type_vhdr_0 = &$info_riff[$riff_sub_type]['VHDR'][0];
  757. getid3_lib::ReadSequence('BigEndian2Int', $info_riff_riff_sub_type_vhdr_0, $info_riff_riff_sub_type_vhdr_0['data'], 0,
  758. array (
  759. 'oneShotHiSamples' => 4,
  760. 'repeatHiSamples' => 4,
  761. 'samplesPerHiCycle' => 4,
  762. 'samplesPerSec' => 2,
  763. 'ctOctave' => 1,
  764. 'sCompression' => 1,
  765. 'Volume' => -4
  766. )
  767. );
  768. $info_riff_riff_sub_type_vhdr_0['Volume'] = getid3_riff::FixedPoint16_16($info_riff_riff_sub_type_vhdr_0['Volume']);
  769. $info_audio['sample_rate'] = $info_riff_riff_sub_type_vhdr_0['samplesPerSec'];
  770. switch ($info_riff_riff_sub_type_vhdr_0['sCompression']) {
  771. case 0:
  772. $info_audio['codec'] = 'Pulse Code Modulation (PCM)';
  773. $info_audio['lossless'] = true;
  774. $actual_bits_per_sample = 8;
  775. break;
  776. case 1:
  777. $info_audio['codec'] = 'Fibonacci-delta encoding';
  778. $info_audio['lossless'] = false;
  779. $actual_bits_per_sample = 4;
  780. break;
  781. default:
  782. $getid3->warning('Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "'.sCompression.'"');
  783. break;
  784. }
  785. }
  786. if (isset($info_riff[$riff_sub_type]['CHAN'][0]['data'])) {
  787. $ChannelsIndex = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['CHAN'][0]['data'], 0, 4));
  788. switch ($ChannelsIndex) {
  789. case 6: // Stereo
  790. $info_audio['channels'] = 2;
  791. break;
  792. case 2: // Left channel only
  793. case 4: // Right channel only
  794. $info_audio['channels'] = 1;
  795. break;
  796. default:
  797. $getid3->warning('Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "'.$ChannelsIndex.'"');
  798. break;
  799. }
  800. }
  801. foreach (array ('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment') as $key => $value) {
  802. if (isset($info_riff[$riff_sub_type][$key][0]['data'])) {
  803. $info_riff['comments'][$value][] = $info_riff[$riff_sub_type][$key][0]['data'];
  804. }
  805. }
  806. $info_audio['bitrate'] = $info_audio['sample_rate'] * $actual_bits_per_sample * $info_audio['channels'];
  807. if (!empty($info_audio['bitrate'])) {
  808. $getid3->info['playtime_seconds'] = ($info_avdataend - $info_avdataoffset) / ($info_audio['bitrate'] / 8);
  809. }
  810. break;
  811. case 'CDXA':
  812. $getid3->info['mime_type'] = 'video/mpeg';
  813. if (!empty($info_riff['CDXA']['data'][0]['size'])) {
  814. $GETID3_ERRORARRAY = &$getid3->info['warning'];
  815. if (!$getid3->include_module_optional('audio-video.mpeg')) {
  816. $getid3->warning('MPEG skipped because mpeg module is missing.');
  817. }
  818. else {
  819. // Clone getid3 - messing with offsets - better safe than sorry
  820. $clone = clone $getid3;
  821. // Analyse
  822. $mpeg = new getid3_mpeg($clone);
  823. $mpeg->Analyze();
  824. // Import from clone and destroy
  825. $getid3->info['audio'] = $clone->info['audio'];
  826. $getid3->info['video'] = $clone->info['video'];
  827. $getid3->info['mpeg'] = $clone->info['mpeg'];
  828. $getid3->info['warning'] = $clone->info['warning'];
  829. unset($clone);
  830. }
  831. }
  832. break;
  833. default:
  834. throw new getid3_exception('Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "'.$riff_sub_type.'" instead');
  835. }
  836. if (@$info_riff_raw['fmt ']['wFormatTag'] == 1) {
  837. // http://www.mega-nerd.com/erikd/Blog/Windiots/dts.html
  838. $this->fseek($getid3->info['avdataoffset'], SEEK_SET);
  839. $bytes4 = $this->fread(4);
  840. // DTSWAV
  841. if (preg_match('/^\xFF\x1F\x00\xE8/s', $bytes4)) {
  842. $info_audio_dataformat = 'dts';
  843. }
  844. // DTS, but this probably shouldn't happen
  845. elseif (preg_match('/^\x7F\xFF\x80\x01/s', $bytes4)) {
  846. $info_audio_dataformat = 'dts';
  847. }
  848. }
  849. if (@is_array($info_riff_wave['DISP'])) {
  850. $info_riff['comments']['title'][] = trim(substr($info_riff_wave['DISP'][count($info_riff_wave['DISP']) - 1]['data'], 4));
  851. }
  852. if (@is_array($info_riff_wave['INFO'])) {
  853. getid3_riff::RIFFCommentsParse($info_riff_wave['INFO'], $info_riff['comments']);
  854. }
  855. if (isset($info_riff_wave['INFO']) && is_array($info_riff_wave['INFO'])) {
  856. foreach (array ('IARL' => 'archivallocation', 'IART' => 'artist', 'ICDS' => 'costumedesigner', 'ICMS' => 'commissionedby', 'ICMT' => 'comment', 'ICNT' => 'country', 'ICOP' => 'copyright', 'ICRD' => 'creationdate', 'IDIM' => 'dimensions', 'IDIT' => 'digitizationdate', 'IDPI' => 'resolution', 'IDST' => 'distributor', 'IEDT' => 'editor', 'IENG' => 'engineers', 'IFRM' => 'accountofparts', 'IGNR' => 'genre', 'IKEY' => 'keywords', 'ILGT' => 'lightness', 'ILNG' => 'language', 'IMED' => 'orignalmedium', 'IMUS' => 'composer', 'INAM' => 'title', 'IPDS' => 'productiondesigner', 'IPLT' => 'palette', 'IPRD' => 'product', 'IPRO' => 'producer', 'IPRT' => 'part', 'IRTD' => 'rating', 'ISBJ' => 'subject', 'ISFT' => 'software', 'ISGN' => 'secondarygenre', 'ISHP' => 'sharpness', 'ISRC' => 'sourcesupplier', 'ISRF' => 'digitizationsource', 'ISTD' => 'productionstudio', 'ISTR' => 'starring', 'ITCH' => 'encoded_by', 'IWEB' => 'url', 'IWRI' => 'writer') as $key => $value) {
  857. if (isset($info_riff_wave['INFO'][$key])) {
  858. foreach ($info_riff_wave['INFO'][$key] as $comment_id => $comment_data) {
  859. if (trim($comment_data['data']) != '') {
  860. $info_riff['comments'][$value][] = trim($comment_data['data']);
  861. }
  862. }
  863. }
  864. }
  865. }
  866. if (empty($info_audio['encoder']) && !empty($getid3->info['mpeg']['audio']['LAME']['short_version'])) {
  867. $info_audio['encoder'] = $getid3->info['mpeg']['audio']['LAME']['short_version'];
  868. }
  869. if (!isset($getid3->info['playtime_seconds'])) {
  870. $getid3->info['playtime_seconds'] = 0;
  871. }
  872. if (isset($info_riff_raw['avih']['dwTotalFrames']) && isset($info_riff_raw['avih']['dwMicroSecPerFrame'])) {
  873. $getid3->info['playtime_seconds'] = $info_riff_raw['avih']['dwTotalFrames'] * ($info_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
  874. }
  875. if ($getid3->info['playtime_seconds'] > 0) {
  876. if (isset($info_riff_audio) && isset($info_riff_video)) {
  877. if (!isset($getid3->info['bitrate'])) {
  878. $getid3->info['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8);
  879. }
  880. } elseif (isset($info_riff_audio) && !isset($info_riff_video)) {
  881. if (!isset($info_audio['bitrate'])) {
  882. $info_audio['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8);
  883. }
  884. } elseif (!isset($info_riff_audio) && isset($info_riff_video)) {
  885. if (!isset($info_video['bitrate'])) {
  886. $info_video['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8);
  887. }
  888. }
  889. }
  890. if (isset($info_riff_video) && isset($info_audio['bitrate']) && ($info_audio['bitrate'] > 0) && ($getid3->info['playtime_seconds'] > 0)) {
  891. $getid3->info['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8);
  892. $info_audio['bitrate'] = 0;
  893. $info_video['bitrate'] = $getid3->info['bitrate'];
  894. foreach ($info_riff_audio as $channelnumber => $audioinfoarray) {
  895. $info_video['bitrate'] -= $audioinfoarray['bitrate'];
  896. $info_audio['bitrate'] += $audioinfoarray['bitrate'];
  897. }
  898. if ($info_video['bitrate'] <= 0) {
  899. unset($info_video['bitrate']);
  900. }
  901. if ($info_audio['bitrate'] <= 0) {
  902. unset($info_audio['bitrate']);
  903. }
  904. }
  905. if (isset($getid3->info['mpeg']['audio'])) {
  906. $info_audio_dataformat = 'mp'.$getid3->info['mpeg']['audio']['layer'];
  907. $info_audio['sample_rate'] = $getid3->info['mpeg']['audio']['sample_rate'];
  908. $info_audio['channels'] = $getid3->info['mpeg']['audio']['channels'];
  909. $info_audio['bitrate'] = $getid3->info['mpeg']['audio']['bitrate'];
  910. $info_audio['bitrate_mode'] = strtolower($getid3->info['mpeg']['audio']['bitrate_mode']);
  911. if (!empty($getid3->info['mpeg']['audio']['codec'])) {
  912. $info_audio['codec'] = $getid3->info['mpeg']['audio']['codec'].' '.$info_audio['codec'];
  913. }
  914. if (!empty($info_audio['streams'])) {
  915. foreach ($info_audio['streams'] as $streamnumber => $streamdata) {
  916. if ($streamdata['dataformat'] == $info_audio_dataformat) {
  917. $info_audio['streams'][$streamnumber]['sample_rate'] = $info_audio['sample_rate'];
  918. $info_audio['streams'][$streamnumber]['channels'] = $info_audio['channels'];
  919. $info_audio['streams'][$streamnumber]['bitrate'] = $info_audio['bitrate'];
  920. $info_audio['streams'][$streamnumber]['bitrate_mode'] = $info_audio['bitrate_mode'];
  921. $info_audio['streams'][$streamnumber]['codec'] = $info_audio['codec'];
  922. }
  923. }
  924. }
  925. $info_audio['encoder_options'] = getid3_mp3::GuessEncoderOptions($getid3->info);
  926. }
  927. if (!empty($info_riff_raw['fmt ']['wBitsPerSample']) && ($info_riff_raw['fmt ']['wBitsPerSample'] > 0)) {
  928. switch ($info_audio_dataformat) {
  929. case 'ac3':
  930. // ignore bits_per_sample
  931. break;
  932. default:
  933. $info_audio['bits_per_sample'] = $info_riff_raw['fmt ']['wBitsPerSample'];
  934. break;
  935. }
  936. }
  937. if (empty($info_riff_raw)) {
  938. unset($info_riff['raw']);
  939. }
  940. if (empty($info_riff_audio)) {
  941. unset($info_riff['audio']);
  942. }
  943. if (empty($info_riff_video)) {
  944. unset($info_riff['video']);
  945. }
  946. if (empty($info_audio_dataformat)) {
  947. unset($info_audio['dataformat']);
  948. }
  949. if (empty($getid3->info['audio'])) {
  950. unset($getid3->info['audio']);
  951. }
  952. if (empty($info_video)) {
  953. unset($getid3->info['video']);
  954. }
  955. return true;
  956. }
  957. public function ParseRIFF($start_offset, $max_offset) {
  958. $getid3 = $this->getid3;
  959. $info = &$getid3->info;
  960. $endian_function = $this->endian_function;
  961. $max_offset = min($max_offset, $info['avdataend']);
  962. $riff_chunk = false;
  963. $this->fseek($start_offset, SEEK_SET);
  964. while ($this->ftell() < $max_offset) {
  965. $chunk_name = $this->fread(4);
  966. if (strlen($chunk_name) < 4) {
  967. throw new getid3_exception('Expecting chunk name at offset '.($this->ftell() - 4).' but found nothing. Aborting RIFF parsing.');
  968. }
  969. $chunk_size = getid3_lib::$endian_function($this->fread(4));
  970. if ($chunk_size == 0) {
  971. continue;
  972. throw new getid3_exception('Chunk size at offset '.($this->ftell() - 4).' is zero. Aborting RIFF parsing.');
  973. }
  974. if (($chunk_size % 2) != 0) {
  975. // all structures are packed on word boundaries
  976. $chunk_size++;
  977. }
  978. switch ($chunk_name) {
  979. case 'LIST':
  980. $list_name = $this->fread(4);
  981. switch ($list_name) {
  982. case 'movi':
  983. case 'rec ':
  984. $riff_chunk[$list_name]['offset'] = $this->ftell() - 4;
  985. $riff_chunk[$list_name]['size'] = $chunk_size;
  986. static $parsed_audio_stream = false;
  987. if (!$parsed_audio_stream) {
  988. $where_we_were = $this->ftell();
  989. $audio_chunk_header = $this->fread(12);
  990. $audio_chunk_stream_num = substr($audio_chunk_header, 0, 2);
  991. $audio_chunk_stream_type = substr($audio_chunk_header, 2, 2);
  992. $audio_chunk_size = getid3_lib::LittleEndian2Int(substr($audio_chunk_header, 4, 4));
  993. if ($audio_chunk_stream_type == 'wb') {
  994. $first_four_bytes = substr($audio_chunk_header, 8, 4);
  995. //// MPEG
  996. if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', $first_four_bytes)) {
  997. if (!$getid3->include_module_optional('audio.mp3')) {
  998. $getid3->warning('MP3 skipped because mp3 module is missing.');
  999. }
  1000. elseif (getid3_mp3::MPEGaudioHeaderBytesValid($first_four_bytes)) {
  1001. // Clone getid3 - messing with offsets - better safe than sorry
  1002. $clone = clone $getid3;
  1003. $clone->info['avdataoffset'] = $this->ftell() - 4;
  1004. $clone->info['avdataend'] = $this->ftell() + $audio_chunk_size;
  1005. $mp3 = new getid3_mp3($clone);
  1006. $mp3->AnalyzeMPEGaudioInfo();
  1007. // Import from clone and destroy
  1008. if (isset($clone->info['mpeg']['audio'])) {
  1009. $info['mpeg']['audio'] = $clone->info['mpeg']['audio'];
  1010. $info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer'];
  1011. $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
  1012. $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
  1013. $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
  1014. $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
  1015. $info['bitrate'] = $info['audio']['bitrate'];
  1016. $getid3->warning($clone->warnings());
  1017. unset($clone);
  1018. }
  1019. }
  1020. }
  1021. //// AC3-WAVE
  1022. elseif (preg_match('/^\x0B\x77/s', $first_four_bytes)) {
  1023. if (!$getid3->include_module_optional('audio.ac3')) {
  1024. $getid3->warning('AC3 skipped because ac3 module is missing.');
  1025. }
  1026. else {
  1027. // Clone getid3 - messing with offsets - better safe than sorry
  1028. $clone = clone $getid3;
  1029. $clone->info['avdataoffset'] = $this->ftell() - 4;
  1030. $clone->info['avdataend'] = $this->ftell() + $audio_chunk_size;
  1031. // Analyze clone by fp
  1032. $ac3 = new getid3_ac3($clone);
  1033. $ac3->Analyze();
  1034. // Import from clone and destroy
  1035. $info['audio'] = $clone->info['audio'];
  1036. $info['ac3'] = $clone->info['ac3'];
  1037. $getid3->warning($clone->warnings());
  1038. unset($clone);
  1039. }
  1040. }
  1041. }
  1042. $parsed_audio_stream = true;
  1043. $this->fseek($where_we_were, SEEK_SET);
  1044. }
  1045. $this->fseek($chunk_size - 4, SEEK_CUR);
  1046. break;
  1047. default:
  1048. if (!isset($riff_chunk[$list_name])) {
  1049. $riff_chunk[$list_name] = array ();
  1050. }
  1051. $list_chunk_parent = $list_name;
  1052. $list_chunk_max_offset = $this->ftell() - 4 + $chunk_size;
  1053. if ($parsed_chunk = $this->ParseRIFF($this->ftell(), $this->ftell() + $chunk_size - 4)) {
  1054. $riff_chunk[$list_name] = array_merge_recursive($riff_chunk[$list_name], $parsed_chunk);
  1055. }
  1056. break;
  1057. }
  1058. break;
  1059. default:
  1060. $this_index = 0;
  1061. if (isset($riff_chunk[$chunk_name]) && is_array($riff_chunk[$chunk_name])) {
  1062. $this_index = count($riff_chunk[$chunk_name]);
  1063. }
  1064. $riff_chunk[$chunk_name][$this_index]['offset'] = $this->ftell() - 8;
  1065. $riff_chunk[$chunk_name][$this_index]['size'] = $chunk_size;
  1066. switch ($chunk_name) {
  1067. case 'data':
  1068. $info['avdataoffset'] = $this->ftell();
  1069. $info['avdataend'] = $info['avdataoffset'] + $chunk_size;
  1070. $riff_data_chunk_contents_test = $this->fread(36);
  1071. //// This is probably MP3 data
  1072. if ((strlen($riff_data_chunk_contents_test) > 0) && preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', substr($riff_data_chunk_contents_test, 0, 4))) {
  1073. try {
  1074. if (!$getid3->include_module_optional('audio.mp3')) {
  1075. $getid3->warning('MP3 skipped because mp3 module is missing.');
  1076. }
  1077. // Clone getid3 - messing with offsets - better safe than sorry
  1078. $clone = clone $getid3;
  1079. if (getid3_mp3::MPEGaudioHeaderBytesValid(substr($riff_data_chunk_contents_test, 0, 4))) {
  1080. $mp3 = new getid3_mp3($clone);
  1081. $mp3->AnalyzeMPEGaudioInfo();
  1082. // Import from clone and destroy
  1083. if (isset($clone->info['mpeg']['audio'])) {
  1084. $info['mpeg']['audio'] = $clone->info['mpeg']['audio'];
  1085. $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
  1086. $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
  1087. $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
  1088. $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
  1089. $info['bitrate'] = $info['audio']['bitrate'];
  1090. $getid3->warning($clone->warnings());
  1091. unset($clone);
  1092. }
  1093. }
  1094. }
  1095. catch (Exception $e) {
  1096. // do nothing - not MP3 data
  1097. }
  1098. }
  1099. //// This is probably AC-3 data
  1100. elseif ((strlen($riff_data_chunk_contents_test) > 0) && (substr($riff_data_chunk_contents_test, 0, 2) == "\x0B\x77")) {
  1101. if (!$getid3->include_module_optional('audio.ac3')) {
  1102. $getid3->warning('AC3 skipped because ac3 module is missing.');
  1103. }
  1104. else {
  1105. // Clone getid3 - messing with offsets - better safe than sorry
  1106. $clone = clone $getid3;
  1107. $clone->info['avdataoffset'] = $riff_chunk[$chunk_name][$this_index]['offset'];
  1108. $clone->info['avdataend'] = $clone->info['avdataoffset'] + $riff_chunk[$chunk_name][$this_index]['size'];
  1109. // Analyze clone by fp
  1110. $ac3 = new getid3_ac3($clone);
  1111. $ac3->Analyze();
  1112. // Import from clone and destroy
  1113. $info['audio'] = $clone->info['audio'];
  1114. $info['ac3'] = $clone->info['ac3'];
  1115. $getid3->warning($clone->warnings());
  1116. unset($clone);
  1117. }
  1118. }
  1119. // Dolby Digital WAV
  1120. // AC-3 content, but not encoded in same format as normal AC-3 file
  1121. // For one thing, byte order is swapped
  1122. elseif ((strlen($riff_data_chunk_contents_test) > 0) && (substr($riff_data_chunk_contents_test, 8, 2) == "\x77\x0B")) {
  1123. if (!$getid3->include_module_optional('audio.ac3')) {
  1124. $getid3->warning('AC3 skipped because ac3 module is missing.');
  1125. }
  1126. else {
  1127. // Extract ac3 data to string
  1128. $ac3_data = '';
  1129. for ($i = 0; $i < 28; $i += 2) {
  1130. // swap byte order
  1131. $ac3_data .= substr($riff_data_chunk_contents_test, 8 + $i + 1, 1);
  1132. $ac3_data .= substr($riff_data_chunk_contents_test, 8 + $i + 0, 1);
  1133. }
  1134. // Clone getid3 - messing with offsets - better safe than sorry
  1135. $clone = clone $getid3;
  1136. $clone->info['avdataoffset'] = 0;
  1137. $clone->info['avdataend'] = 20;
  1138. // Analyse clone by string
  1139. $ac3 = new getid3_ac3($clone);
  1140. $ac3->AnalyzeString($ac3_data);
  1141. // Import from clone and destroy
  1142. $info['audio'] = $clone->info['audio'];
  1143. $info['ac3'] = $clone->info['ac3'];
  1144. $getid3->warning($clone->warnings());
  1145. unset($clone);
  1146. }
  1147. }
  1148. if ((strlen($riff_data_chunk_contents_test) > 0) && (substr($riff_data_chunk_contents_test, 0, 4) == 'wvpk')) {
  1149. // This is WavPack data
  1150. $info['wavpack']['offset'] = $riff_chunk[$chunk_name][$this_index]['offset'];
  1151. $info['wavpack']['size'] = getid3_lib::LittleEndian2Int(substr($riff_data_chunk_contents_test, 4, 4));
  1152. $this->RIFFparseWavPackHeader(substr($riff_data_chunk_contents_test, 8, 28));
  1153. } else {
  1154. // This is some other kind of data (quite possibly just PCM)
  1155. // do nothing special, just skip it
  1156. }
  1157. $this->fseek($riff_chunk[$chunk_name][$this_index]['offset'] + 8 + $chunk_size, SEEK_SET);
  1158. break;
  1159. case 'bext':
  1160. case 'cart':
  1161. case 'fmt ':
  1162. case 'MEXT':
  1163. case 'DISP':
  1164. // always read data in
  1165. $riff_chunk[$chunk_name][$this_index]['data'] = $this->fread($chunk_size);
  1166. break;
  1167. default:
  1168. if (!empty($list_chunk_parent) && (($riff_chunk[$chunk_name][$this_index]['offset'] + $riff_chunk[$chunk_name][$this_index]['size']) <= $list_chunk_max_offset)) {
  1169. $riff_chunk[$list_chunk_parent][$chunk_name][$this_index]['offset'] = $riff_chunk[$chunk_name][$this_index]['offset'];
  1170. $riff_chunk[$list_chunk_parent][$chunk_name][$this_index]['size'] = $riff_chunk[$chunk_name][$this_index]['size'];
  1171. unset($riff_chunk[$chunk_name][$this_index]['offset']);
  1172. unset($riff_chunk[$chunk_name][$this_index]['size']);
  1173. if (isset($riff_chunk[$chunk_name][$this_index]) && empty($riff_chunk[$chunk_name][$this_index])) {
  1174. unset($riff_chunk[$chunk_name][$this_index]);
  1175. }
  1176. if (isset($riff_chunk[$chunk_name]) && empty($riff_chunk[$chunk_name])) {
  1177. unset($riff_chunk[$chunk_name]);
  1178. }
  1179. $riff_chunk[$list_chunk_parent][$chunk_name][$this_index]['data'] = $this->fread($chunk_size);
  1180. } elseif ($chunk_size < 2048) {
  1181. // only read data in if smaller than 2kB
  1182. $riff_chunk[$chunk_name][$this_index]['data'] = $this->fread($chunk_size);
  1183. } else {
  1184. $this->fseek($chunk_size, SEEK_CUR);
  1185. }
  1186. break;
  1187. }
  1188. break;
  1189. }
  1190. }
  1191. return $riff_chunk;
  1192. }
  1193. private function RIFFparseWavPackHeader($wavpack3_chunk_data) {
  1194. // typedef struct {
  1195. // char ckID [4];
  1196. // long ckSize;
  1197. // short version;
  1198. // short bits; // added for version 2.00
  1199. // short flags, shift; // added for version 3.00
  1200. // long total_samples, crc, crc2;
  1201. // char extension [4], extra_bc, extras [3];
  1202. // } WavpackHeader;
  1203. $this->getid3->info['wavpack'] = array ();
  1204. $info_wavpack = &$this->getid3->info['wavpack'];
  1205. $info_wavpack['version'] = getid3_lib::LittleEndian2Int(substr($wavpack3_chunk_data, 0, 2));
  1206. if ($info_wavpack['version'] >= 2) {
  1207. $info_wavpack['bits'] = getid3_lib::LittleEndian2Int(substr($wavpack3_chunk_data, 2, 2));
  1208. }
  1209. if ($info_wavpack['version'] >= 3) {
  1210. getid3_lib::ReadSequence('LittleEndian2Int', $info_wavpack, $wavpack3_chunk_data, 4,
  1211. array (
  1212. 'flags_raw' => 2,
  1213. 'shift' => 2,
  1214. 'total_samples' => 4,
  1215. 'crc1' => 4,
  1216. 'crc2' => 4,
  1217. 'extension' => -4,
  1218. 'extra_bc' => 1
  1219. )
  1220. );
  1221. for ($i = 0; $i < 3; $i++) {
  1222. $info_wavpack['extras'][] = getid3_lib::LittleEndian2Int($wavpack3_chunk_data{25 + $i});
  1223. }
  1224. $info_wavpack['flags'] = array ();
  1225. $info_wavpack_flags = &$info_wavpack['flags'];
  1226. $info_wavpack_flags['mono'] = (bool)($info_wavpack['flags_raw'] & 0x000001);
  1227. $info_wavpack_flags['fast_mode'] = (bool)($info_wavpack['flags_raw'] & 0x000002);
  1228. $info_wavpack_flags['raw_mode'] = (bool)($info_wavpack['flags_raw'] & 0x000004);
  1229. $info_wavpack_flags['calc_noise'] = (bool)($info_wavpack['flags_raw'] & 0x000008);
  1230. $info_wavpack_flags['high_quality'] = (bool)($info_wavpack['flags_raw'] & 0x000010);
  1231. $info_wavpack_flags['3_byte_samples'] = (bool)($info_wavpack['flags_raw'] & 0x000020);
  1232. $info_wavpack_flags['over_20_bits'] = (bool)($info_wavpack['flags_raw'] & 0x000040);
  1233. $info_wavpack_flags['use_wvc'] = (bool)($info_wavpack['flags_raw'] & 0x000080);
  1234. $info_wavpack_flags['noiseshaping'] = (bool)($info_wavpack['flags_raw'] & 0x000100);
  1235. $info_wavpack_flags['very_fast_mode'] = (bool)($info_wavpack['flags_raw'] & 0x000200);
  1236. $info_wavpack_flags['new_high_quality'] = (bool)($info_wavpack['flags_raw'] & 0x000400);
  1237. $info_wavpack_flags['cancel_extreme'] = (bool)($info_wavpack['flags_raw'] & 0x000800);
  1238. $info_wavpack_flags['cross_decorrelation'] = (bool)($info_wavpack['flags_raw'] & 0x001000);
  1239. $info_wavpack_flags['new_decorrelation'] = (bool)($info_wavpack['flags_raw'] & 0x002000);
  1240. $info_wavpack_flags['joint_stereo'] = (bool)($info_wavpack['flags_raw'] & 0x004000);
  1241. $info_wavpack_flags['extra_decorrelation'] = (bool)($info_wavpack['flags_raw'] & 0x008000);
  1242. $info_wavpack_flags['override_noiseshape'] = (bool)($info_wavpack['flags_raw'] & 0x010000);
  1243. $info_wavpack_flags['override_jointstereo'] = (bool)($info_wavpack['flags_raw'] & 0x020000);
  1244. $info_wavpack_flags['copy_source_filetime'] = (bool)($info_wavpack['flags_raw'] & 0x040000);
  1245. $info_wavpack_flags['create_exe'] = (bool)($info_wavpack['flags_raw'] & 0x080000);
  1246. }
  1247. return true;
  1248. }
  1249. public function AnalyzeString(&$string) {
  1250. // Rewrite header_size in header
  1251. $new_header_size = getid3_lib::LittleEndian2String(strlen($string), 4);
  1252. for ($i = 0; $i < 4; $i++) {
  1253. $string{$i + 4} = $new_header_size{$i};
  1254. }
  1255. return parent::AnalyzeString($string);
  1256. }
  1257. public static function RIFFparseWAVEFORMATex($wave_format_ex_data) {
  1258. $wave_format_ex['raw'] = array ();
  1259. $wave_format_ex_raw = &$wave_format_ex['raw'];
  1260. getid3_lib::ReadSequence('LittleEndian2Int', $wave_format_ex_raw, $wave_format_ex_data, 0,
  1261. array (
  1262. 'wFormatTag' => 2,
  1263. 'nChannels' => 2,
  1264. 'nSamplesPerSec' => 4,
  1265. 'nAvgBytesPerSec' => 4,
  1266. 'nBlockAlign' => 2,
  1267. 'wBitsPerSample' => 2
  1268. )
  1269. );
  1270. if (strlen($wave_format_ex_data) > 16) {
  1271. $wave_format_ex_raw['cbSize'] = getid3_lib::LittleEndian2Int(substr($wave_format_ex_data, 16, 2));
  1272. }
  1273. $wave_format_ex['codec'] = getid3_riff::RIFFwFormatTagLookup($wave_format_ex_raw['wFormatTag']);
  1274. $wave_format_ex['channels'] = $wave_format_ex_raw['nChannels'];
  1275. $wave_format_ex['sample_rate'] = $wave_format_ex_raw['nSamplesPerSec'];
  1276. $wave_format_ex['bitrate'] = $wave_format_ex_raw['nAvgBytesPerSec'] * 8;
  1277. if (@$wave_format_ex_raw['wBitsPerSample']) {
  1278. $wave_format_ex['bits_per_sample'] = $wave_format_ex_raw['wBitsPerSample'];
  1279. }
  1280. return $wave_format_ex;
  1281. }
  1282. public static function RIFFwaveSNDMtagLookup($tagshortname) {
  1283. static $lookup = array(
  1284. 'Škwd' => 'keywords',
  1285. 'ŠBPM' => 'bpm',
  1286. 'Štrt' => 'tracktitle',
  1287. 'Šdes' => 'description',
  1288. 'Šgen' => 'category',
  1289. 'Šfin' => 'featuredinstrument',
  1290. 'ŠLID' => 'longid',
  1291. 'Šbex' => 'bwdescription',
  1292. 'Špub' => 'publisher',
  1293. 'Šcdt' => 'cdtitle',
  1294. 'Šalb' => 'library',
  1295. 'Šcom' => 'composer',
  1296. );
  1297. return @$lookup[$tagshortname];
  1298. }
  1299. public static function RIFFwFormatTagLookup($w_format_tag) {
  1300. static $lookup = array (
  1301. 0x0000 => 'Microsoft Unknown Wave Format',
  1302. 0x0001 => 'Pulse Code Modulation (PCM)',
  1303. 0x0002 => 'Microsoft ADPCM',
  1304. 0x0003 => 'IEEE Float',
  1305. 0x0004 => 'Compaq Computer VSELP',
  1306. 0x0005 => 'IBM CVSD',
  1307. 0x0006 => 'Microsoft A-Law',
  1308. 0x0007 => 'Microsoft mu-Law',
  1309. 0x0008 => 'Microsoft DTS',
  1310. 0x0010 => 'OKI ADPCM',
  1311. 0x0011 => 'Intel DVI/IMA ADPCM',
  1312. 0x0012 => 'Videologic MediaSpace ADPCM',
  1313. 0x0013 => 'Sierra Semiconductor ADPCM',
  1314. 0x0014 => 'Antex Electronics G.723 ADPCM',
  1315. 0x0015 => 'DSP Solutions DigiSTD',
  1316. 0x0016 => 'DSP Solutions DigiFIX',
  1317. 0x0017 => 'Dialogic OKI ADPCM',
  1318. 0x0018 => 'MediaVision ADPCM',
  1319. 0x0019 => 'Hewlett-Packard CU',
  1320. 0x0020 => 'Yamaha ADPCM',
  1321. 0x0021 => 'Speech Compression Sonarc',
  1322. 0x0022 => 'DSP Group TrueSpeech',
  1323. 0x0023 => 'Echo Speech EchoSC1',
  1324. 0x0024 => 'Audiofile AF36',
  1325. 0x0025 => 'Audio Processing Technology APTX',
  1326. 0x0026 => 'AudioFile AF10',
  1327. 0x0027 => 'Prosody 1612',
  1328. 0x0028 => 'LRC',
  1329. 0x0030 => 'Dolby AC2',
  1330. 0x0031 => 'Microsoft GSM 6.10',
  1331. 0x0032 => 'MSNAudio',
  1332. 0x0033 => 'Antex Electronics ADPCME',
  1333. 0x0034 => 'Control Resources VQLPC',
  1334. 0x0035 => 'DSP Solutions DigiREAL',
  1335. 0x0036 => 'DSP Solutions DigiADPCM',
  1336. 0x0037 => 'Control Resources CR10',
  1337. 0x0038 => 'Natural MicroSystems VBXADPCM',
  1338. 0x0039 => 'Crystal Semiconductor IMA ADPCM',
  1339. 0x003A => 'EchoSC3',
  1340. 0x003B => 'Rockwell ADPCM',
  1341. 0x003C => 'Rockwell Digit LK',
  1342. 0x003D => 'Xebec',
  1343. 0x0040 => 'Antex Electronics G.721 ADPCM',
  1344. 0x0041 => 'G.728 CELP',
  1345. 0x0042 => 'MSG723',
  1346. 0x0050 => 'MPEG Layer-2 or Layer-1',
  1347. 0x0052 => 'RT24',
  1348. 0x0053 => 'PAC',
  1349. 0x0055 => 'MPEG Layer-3',
  1350. 0x0059 => 'Lucent G.723',
  1351. 0x0060 => 'Cirrus',
  1352. 0x0061 => 'ESPCM',
  1353. 0x0062 => 'Voxware',
  1354. 0x0063 => 'Canopus Atrac',
  1355. 0x0064 => 'G.726 ADPCM',
  1356. 0x0065 => 'G.722 ADPCM',
  1357. 0x0066 => 'DSAT',
  1358. 0x0067 => 'DSAT Display',
  1359. 0x0069 => 'Voxware Byte Aligned',
  1360. 0x0070 => 'Voxware AC8',
  1361. 0x0071 => 'Voxware AC10',
  1362. 0x0072 => 'Voxware AC16',
  1363. 0x0073 => 'Voxware AC20',
  1364. 0x0074 => 'Voxware MetaVoice',
  1365. 0x0075 => 'Voxware MetaSound',
  1366. 0x0076 => 'Voxware RT29HW',
  1367. 0x0077 => 'Voxware VR12',
  1368. 0x0078 => 'Voxware VR18',
  1369. 0x0079 => 'Voxware TQ40',
  1370. 0x0080 => 'Softsound',
  1371. 0x0081 => 'Voxware TQ60',
  1372. 0x0082 => 'MSRT24',
  1373. 0x0083 => 'G.729A',
  1374. 0x0084 => 'MVI MV12',
  1375. 0x0085 => 'DF G.726',
  1376. 0x0086 => 'DF GSM610',
  1377. 0x0088 => 'ISIAudio',
  1378. 0x0089 => 'Onlive',
  1379. 0x0091 => 'SBC24',
  1380. 0x0092 => 'Dolby AC3 SPDIF',
  1381. 0x0093 => 'MediaSonic G.723',
  1382. 0x0094 => 'Aculab PLC Prosody 8kbps',
  1383. 0x0097 => 'ZyXEL ADPCM',
  1384. 0x0098 => 'Philips LPCBB',
  1385. 0x0099 => 'Packed',
  1386. 0x00FF => 'AAC',
  1387. 0x0100 => 'Rhetorex ADPCM',
  1388. 0x0101 => 'IBM mu-law',
  1389. 0x0102 => 'IBM A-law',
  1390. 0x0103 => 'IBM AVC Adaptive Differential Pulse Code Modulation (ADPCM)',
  1391. 0x0111 => 'Vivo G.723',
  1392. 0x0112 => 'Vivo Siren',
  1393. 0x0123 => 'Digital G.723',
  1394. 0x0125 => 'Sanyo LD ADPCM',
  1395. 0x0130 => 'Sipro Lab Telecom ACELP NET',
  1396. 0x0131 => 'Sipro Lab Telecom ACELP 4800',
  1397. 0x0132 => 'Sipro Lab Telecom ACELP 8V3',
  1398. 0x0133 => 'Sipro Lab Telecom G.729',
  1399. 0x0134 => 'Sipro Lab Telecom G.729A',
  1400. 0x0135 => 'Sipro Lab Telecom Kelvin',
  1401. 0x0140 => 'Windows Media Video V8',
  1402. 0x0150 => 'Qualcomm PureVoice',
  1403. 0x0151 => 'Qualcomm HalfRate',
  1404. 0x0155 => 'Ring Zero Systems TUB GSM',
  1405. 0x0160 => 'Microsoft Audio 1',
  1406. 0x0161 => 'Windows Media Audio V7 / V8 / V9',
  1407. 0x0162 => 'Windows Media Audio Professional V9',
  1408. 0x0163 => 'Windows Media Audio Lossless V9',
  1409. 0x0200 => 'Creative Labs ADPCM',
  1410. 0x0202 => 'Creative Labs Fastspeech8',
  1411. 0x0203 => 'Creative Labs Fastspeech10',
  1412. 0x0210 => 'UHER Informatic GmbH ADPCM',
  1413. 0x0220 => 'Quarterdeck',
  1414. 0x0230 => 'I-link Worldwide VC',
  1415. 0x0240 => 'Aureal RAW Sport',
  1416. 0x0250 => 'Interactive Products HSX',
  1417. 0x0251 => 'Interactive Products RPELP',
  1418. 0x0260 => 'Consistent Software CS2',
  1419. 0x0270 => 'Sony SCX',
  1420. 0x0300 => 'Fujitsu FM Towns Snd',
  1421. 0x0400 => 'BTV Digital',
  1422. 0x0401 => 'Intel Music Coder',
  1423. 0x0450 => 'QDesign Music',
  1424. 0x0680 => 'VME VMPCM',
  1425. 0x0681 => 'AT&T Labs TPC',
  1426. 0x08AE => 'ClearJump LiteWave',
  1427. 0x1000 => 'Olivetti GSM',
  1428. 0x1001 => 'Olivetti ADPCM',
  1429. 0x1002 => 'Olivetti CELP',
  1430. 0x1003 => 'Olivetti SBC',
  1431. 0x1004 => 'Olivetti OPR',
  1432. 0x1100 => 'Lernout & Hauspie Codec (0x1100)',
  1433. 0x1101 => 'Lernout & Hauspie CELP Codec (0x1101)',
  1434. 0x1102 => 'Lernout & Hauspie SBC Codec (0x1102)',
  1435. 0x1103 => 'Lernout & Hauspie SBC Codec (0x1103)',
  1436. 0x1104 => 'Lernout & Hauspie SBC Codec (0x1104)',
  1437. 0x1400 => 'Norris',
  1438. 0x1401 => 'AT&T ISIAudio',
  1439. 0x1500 => 'Soundspace Music Compression',
  1440. 0x181C => 'VoxWare RT24 Speech',
  1441. 0x1FC4 => 'NCT Soft ALF2CD (www.nctsoft.com)',
  1442. 0x2000 => 'Dolby AC3',
  1443. 0x2001 => 'Dolby DTS',
  1444. 0x2002 => 'WAVE_FORMAT_14_4',
  1445. 0x2003 => 'WAVE_FORMAT_28_8',
  1446. 0x2004 => 'WAVE_FORMAT_COOK',
  1447. 0x2005 => 'WAVE_FORMAT_DNET',
  1448. 0x674F => 'Ogg Vorbis 1',
  1449. 0x6750 => 'Ogg Vorbis 2',
  1450. 0x6751 => 'Ogg Vorbis 3',
  1451. 0x676F => 'Ogg Vorbis 1+',
  1452. 0x6770 => 'Ogg Vorbis 2+',
  1453. 0x6771 => 'Ogg Vorbis 3+',
  1454. 0x7A21 => 'GSM-AMR (CBR, no SID)',
  1455. 0x7A22 => 'GSM-AMR (VBR, including SID)',
  1456. 0xFFFE => 'WAVE_FORMAT_EXTENSIBLE',
  1457. 0xFFFF => 'WAVE_FORMAT_DEVELOPMENT'
  1458. );
  1459. return @$lookup[$w_format_tag];
  1460. }
  1461. public static function RIFFfourccLookup($four_cc) {
  1462. static $lookup = array (
  1463. 'swot' => 'http://developer.apple.com/qa/snd/snd07.html',
  1464. '____' => 'No Codec (____)',
  1465. '_BIT' => 'BI_BITFIELDS (Raw RGB)',
  1466. '_JPG' => 'JPEG compressed',
  1467. '_PNG' => 'PNG compressed W3C/ISO/IEC (RFC-2083)',
  1468. '_RAW' => 'Full Frames (Uncompressed)',
  1469. '_RGB' => 'Raw RGB Bitmap',
  1470. '_RL4' => 'RLE 4bpp RGB',
  1471. '_RL8' => 'RLE 8bpp RGB',
  1472. '3IV1' => '3ivx MPEG-4 v1',
  1473. '3IV2' => '3ivx MPEG-4 v2',
  1474. '3IVX' => '3ivx MPEG-4',
  1475. 'AASC' => 'Autodesk Animator',
  1476. 'ABYR' => 'Kensington ?ABYR?',
  1477. 'AEMI' => 'Array Microsystems VideoONE MPEG1-I Capture',
  1478. 'AFLC' => 'Autodesk Animator FLC',
  1479. 'AFLI' => 'Autodesk Animator FLI',
  1480. 'AMPG' => 'Array Microsystems VideoONE MPEG',
  1481. 'ANIM' => 'Intel RDX (ANIM)',
  1482. 'AP41' => 'AngelPotion Definitive',
  1483. 'ASV1' => 'Asus Video v1',
  1484. 'ASV2' => 'Asus Video v2',
  1485. 'ASVX' => 'Asus Video 2.0 (audio)',
  1486. 'AUR2' => 'AuraVision Aura 2 Codec - YUV 4:2:2',
  1487. 'AURA' => 'AuraVision Aura 1 Codec - YUV 4:1:1',
  1488. 'AVDJ' => 'Independent JPEG Group\'s codec (AVDJ)',
  1489. 'AVRN' => 'Independent JPEG Group\'s codec (AVRN)',
  1490. 'AYUV' => '4:4:4 YUV (AYUV)',
  1491. 'AZPR' => 'Quicktime Apple Video (AZPR)',
  1492. 'BGR ' => 'Raw RGB32',
  1493. 'BLZ0' => 'FFmpeg MPEG-4',
  1494. 'BTVC' => 'Conexant Composite Video',
  1495. 'BINK' => 'RAD Game Tools Bink Video',
  1496. 'BT20' => 'Conexant Prosumer Video',
  1497. 'BTCV' => 'Conexant Composite Video Codec',
  1498. 'BW10' => 'Data Translation Broadway MPEG Capture',
  1499. 'CC12' => 'Intel YUV12',
  1500. 'CDVC' => 'Canopus DV',
  1501. 'CFCC' => 'Digital Processing Systems DPS Perception',
  1502. 'CGDI' => 'Microsoft Office 97 Camcorder Video',
  1503. 'CHAM' => 'Winnov Caviara Champagne',
  1504. 'CJPG' => 'Creative WebCam JPEG',
  1505. 'CLJR' => 'Cirrus Logic YUV 4:1:1',
  1506. 'CMYK' => 'Common Data Format in Printing (Colorgraph)',
  1507. 'CPLA' => 'Weitek 4:2:0 YUV Planar',
  1508. 'CRAM' => 'Microsoft Video 1 (CRAM)',
  1509. 'cvid' => 'Radius Cinepak',
  1510. 'CVID' => 'Radius Cinepak',
  1511. 'CWLT' => 'Microsoft Color WLT DIB',
  1512. 'CYUV' => 'Creative Labs YUV',
  1513. 'CYUY' => 'ATI YUV',
  1514. 'D261' => 'H.261',
  1515. 'D263' => 'H.263',
  1516. 'DIB ' => 'Device Independent Bitmap',
  1517. 'DIV1' => 'FFmpeg OpenDivX',
  1518. 'DIV2' => 'Microsoft MPEG-4 v1/v2',
  1519. 'DIV3' => 'DivX ;-) MPEG-4 v3.x Low-Motion',
  1520. 'DIV4' => 'DivX ;-) MPEG-4 v3.x Fast-Motion',
  1521. 'DIV5' => 'DivX MPEG-4 v5.x',
  1522. 'DIV6' => 'DivX ;-) (MS MPEG-4 v3.x)',
  1523. 'DIVX' => 'DivX MPEG-4 v4 (OpenDivX / Project Mayo)',
  1524. 'divx' => 'DivX MPEG-4',
  1525. 'DMB1' => 'Matrox Rainbow Runner hardware MJPEG',
  1526. 'DMB2' => 'Paradigm MJPEG',
  1527. 'DSVD' => '?DSVD?',
  1528. 'DUCK' => 'Duck TrueMotion 1.0',
  1529. 'DPS0' => 'DPS/Leitch Reality Motion JPEG',
  1530. 'DPSC' => 'DPS/Leitch PAR Motion JPEG',
  1531. 'DV25' => 'Matrox DVCPRO codec',
  1532. 'DV50' => 'Matrox DVCPRO50 codec',
  1533. 'DVC ' => 'IEC 61834 and SMPTE 314M (DVC/DV Video)',
  1534. 'DVCP' => 'IEC 61834 and SMPTE 314M (DVC/DV Video)',
  1535. 'DVHD' => 'IEC Standard DV 1125 lines @ 30fps / 1250 lines @ 25fps',
  1536. 'DVMA' => 'Darim Vision DVMPEG (dummy for MPEG compressor) (www.darvision.com)',
  1537. 'DVSL' => 'IEC Standard DV compressed in SD (SDL)',
  1538. 'DVAN' => '?DVAN?',
  1539. 'DVE2' => 'InSoft DVE-2 Videoconferencing',
  1540. 'dvsd' => 'IEC 61834 and SMPTE 314M DVC/DV Video',
  1541. 'DVSD' => 'IEC 61834 and SMPTE 314M DVC/DV Video',
  1542. 'DVX1' => 'Lucent DVX1000SP Video Decoder',
  1543. 'DVX2' => 'Lucent DVX2000S Video Decoder',
  1544. 'DVX3' => 'Lucent DVX3000S Video Decoder',
  1545. 'DX50' => 'DivX v5',
  1546. 'DXT1' => 'Microsoft DirectX Compressed Texture (DXT1)',
  1547. 'DXT2' => 'Microsoft DirectX Compressed Texture (DXT2)',
  1548. 'DXT3' => 'Microsoft DirectX Compressed Texture (DXT3)',
  1549. 'DXT4' => 'Microsoft DirectX Compressed Texture (DXT4)',
  1550. 'DXT5' => 'Microsoft DirectX Compressed Texture (DXT5)',
  1551. 'DXTC' => 'Microsoft DirectX Compressed Texture (DXTC)',
  1552. 'DXTn' => 'Microsoft DirectX Compressed Texture (DXTn)',
  1553. 'EM2V' => 'Etymonix MPEG-2 I-frame (www.etymonix.com)',
  1554. 'EKQ0' => 'Elsa ?EKQ0?',
  1555. 'ELK0' => 'Elsa ?ELK0?',
  1556. 'ESCP' => 'Eidos Escape',
  1557. 'ETV1' => 'eTreppid Video ETV1',
  1558. 'ETV2' => 'eTreppid Video ETV2',
  1559. 'ETVC' => 'eTreppid Video ETVC',
  1560. 'FLIC' => 'Autodesk FLI/FLC Animation',
  1561. 'FRWT' => 'Darim Vision Forward Motion JPEG (www.darvision.com)',
  1562. 'FRWU' => 'Darim Vision Forward Uncompressed (www.darvision.com)',
  1563. 'FLJP' => 'D-Vision Field Encoded Motion JPEG',
  1564. 'FRWA' => 'SoftLab-Nsk Forward Motion JPEG w/ alpha channel',
  1565. 'FRWD' => 'SoftLab-Nsk Forward Motion JPEG',
  1566. 'FVF1' => 'Iterated Systems Fractal Video Frame',
  1567. 'GLZW' => 'Motion LZW (gabest@freemail.hu)',
  1568. 'GPEG' => 'Motion JPEG (gabest@freemail.hu)',
  1569. 'GWLT' => 'Microsoft Greyscale WLT DIB',
  1570. 'H260' => 'Intel ITU H.260 Videoconferencing',
  1571. 'H261' => 'Intel ITU H.261 Videoconferencing',
  1572. 'H262' => 'Intel ITU H.262 Videoconferencing',
  1573. 'H263' => 'Intel ITU H.263 Videoconferencing',
  1574. 'H264' => 'Intel ITU H.264 Videoconferencing',
  1575. 'H265' => 'Intel ITU H.265 Videoconferencing',
  1576. 'H266' => 'Intel ITU H.266 Videoconferencing',
  1577. 'H267' => 'Intel ITU H.267 Videoconferencing',
  1578. 'H268' => 'Intel ITU H.268 Videoconferencing',
  1579. 'H269' => 'Intel ITU H.269 Videoconferencing',
  1580. 'HFYU' => 'Huffman Lossless Codec',
  1581. 'HMCR' => 'Rendition Motion Compensation Format (HMCR)',
  1582. 'HMRR' => 'Rendition Motion Compensation Format (HMRR)',
  1583. 'I263' => 'FFmpeg I263 decoder',
  1584. 'IF09' => 'Indeo YVU9 ("YVU9 with additional delta-frame info after the U plane")',
  1585. 'IUYV' => 'Interlaced version of UYVY (www.leadtools.com)',
  1586. 'IY41' => 'Interlaced version of Y41P (www.leadtools.com)',
  1587. 'IYU1' => '12 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec IEEE standard',
  1588. 'IYU2' => '24 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec IEEE standard',
  1589. 'IYUV' => 'Planar YUV format (8-bpp Y plane, followed by 8-bpp 2×2 U and V planes)',
  1590. 'i263' => 'Intel ITU H.263 Videoconferencing (i263)',
  1591. 'I420' => 'Intel Indeo 4',
  1592. 'IAN ' => 'Intel Indeo 4 (RDX)',
  1593. 'ICLB' => 'InSoft CellB Videoconferencing',
  1594. 'IGOR' => 'Power DVD',
  1595. 'IJPG' => 'Intergraph JPEG',
  1596. 'ILVC' => 'Intel Layered Video',
  1597. 'ILVR' => 'ITU-T H.263+',
  1598. 'IPDV' => 'I-O Data Device Giga AVI DV Codec',
  1599. 'IR21' => 'Intel Indeo 2.1',
  1600. 'IRAW' => 'Intel YUV Uncompressed',
  1601. 'IV30' => 'Intel Indeo 3.0',
  1602. 'IV31' => 'Intel Indeo 3.1',
  1603. 'IV32' => 'Ligos Indeo 3.2',
  1604. 'IV33' => 'Ligos Indeo 3.3',
  1605. 'IV34' => 'Ligos Indeo 3.4',
  1606. 'IV35' => 'Ligos Indeo 3.5',
  1607. 'IV36' => 'Ligos Indeo 3.6',
  1608. 'IV37' => 'Ligos Indeo 3.7',
  1609. 'IV38' => 'Ligos Indeo 3.8',
  1610. 'IV39' => 'Ligos Indeo 3.9',
  1611. 'IV40' => 'Ligos Indeo Interactive 4.0',
  1612. 'IV41' => 'Ligos Indeo Interactive 4.1',
  1613. 'IV42' => 'Ligos Indeo Interactive 4.2',
  1614. 'IV43' => 'Ligos Indeo Interactive 4.3',
  1615. 'IV44' => 'Ligos Indeo Interactive 4.4',
  1616. 'IV45' => 'Ligos Indeo Interactive 4.5',
  1617. 'IV46' => 'Ligos Indeo Interactive 4.6',
  1618. 'IV47' => 'Ligos Indeo Interactive 4.7',
  1619. 'IV48' => 'Ligos Indeo Interactive 4.8',
  1620. 'IV49' => 'Ligos Indeo Interactive 4.9',
  1621. 'IV50' => 'Ligos Indeo Interactive 5.0',
  1622. 'JBYR' => 'Kensington ?JBYR?',
  1623. 'JPEG' => 'Still Image JPEG DIB',
  1624. 'JPGL' => 'Pegasus Lossless Motion JPEG',
  1625. 'KMVC' => 'Team17 Software Karl Morton\'s Video Codec',
  1626. 'LSVM' => 'Vianet Lighting Strike Vmail (Streaming) (www.vianet.com)',
  1627. 'LEAD' => 'LEAD Video Codec',
  1628. 'Ljpg' => 'LEAD MJPEG Codec',
  1629. 'MDVD' => 'Alex MicroDVD Video (hacked MS MPEG-4) (www.tiasoft.de)',
  1630. 'MJPA' => 'Morgan Motion JPEG (MJPA) (www.morgan-multimedia.com)',
  1631. 'MJPB' => 'Morgan Motion JPEG (MJPB) (www.morgan-multimedia.com)',
  1632. 'MMES' => 'Matrox MPEG-2 I-frame',
  1633. 'MP2v' => 'Microsoft S-Mpeg 4 version 1 (MP2v)',
  1634. 'MP42' => 'Microsoft S-Mpeg 4 version 2 (MP42)',
  1635. 'MP43' => 'Microsoft S-Mpeg 4 version 3 (MP43)',
  1636. 'MP4S' => 'Microsoft S-Mpeg 4 version 3 (MP4S)',
  1637. 'MP4V' => 'FFmpeg MPEG-4',
  1638. 'MPG1' => 'FFmpeg MPEG 1/2',
  1639. 'MPG2' => 'FFmpeg MPEG 1/2',
  1640. 'MPG3' => 'FFmpeg DivX ;-) (MS MPEG-4 v3)',
  1641. 'MPG4' => 'Microsoft MPEG-4',
  1642. 'MPGI' => 'Sigma Designs MPEG',
  1643. 'MPNG' => 'PNG images decoder',
  1644. 'MSS1' => 'Microsoft Windows Screen Video',
  1645. 'MSZH' => 'LCL (Lossless Codec Library) (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm)',
  1646. 'M261' => 'Microsoft H.261',
  1647. 'M263' => 'Microsoft H.263',
  1648. 'M4S2' => 'Microsoft Fully Compliant MPEG-4 v2 simple profile (M4S2)',
  1649. 'm4s2' => 'Microsoft Fully Compliant MPEG-4 v2 simple profile (m4s2)',
  1650. 'MC12' => 'ATI Motion Compensation Format (MC12)',
  1651. 'MCAM' => 'ATI Motion Compensation Format (MCAM)',
  1652. 'MJ2C' => 'Morgan Multimedia Motion JPEG2000',
  1653. 'mJPG' => 'IBM Motion JPEG w/ Huffman Tables',
  1654. 'MJPG' => 'Microsoft Motion JPEG DIB',
  1655. 'MP42' => 'Microsoft MPEG-4 (low-motion)',
  1656. 'MP43' => 'Microsoft MPEG-4 (fast-motion)',
  1657. 'MP4S' => 'Microsoft MPEG-4 (MP4S)',
  1658. 'mp4s' => 'Microsoft MPEG-4 (mp4s)',
  1659. 'MPEG' => 'Chromatic Research MPEG-1 Video I-Frame',
  1660. 'MPG4' => 'Microsoft MPEG-4 Video High Speed Compressor',
  1661. 'MPGI' => 'Sigma Designs MPEG',
  1662. 'MRCA' => 'FAST Multimedia Martin Regen Codec',
  1663. 'MRLE' => 'Microsoft Run Length Encoding',
  1664. 'MSVC' => 'Microsoft Video 1',
  1665. 'MTX1' => 'Matrox ?MTX1?',
  1666. 'MTX2' => 'Matrox ?MTX2?',
  1667. 'MTX3' => 'Matrox ?MTX3?',
  1668. 'MTX4' => 'Matrox ?MTX4?',
  1669. 'MTX5' => 'Matrox ?MTX5?',
  1670. 'MTX6' => 'Matrox ?MTX6?',
  1671. 'MTX7' => 'Matrox ?MTX7?',
  1672. 'MTX8' => 'Matrox ?MTX8?',
  1673. 'MTX9' => 'Matrox ?MTX9?',
  1674. 'MV12' => 'Motion Pixels Codec (old)',
  1675. 'MWV1' => 'Aware Motion Wavelets',
  1676. 'nAVI' => 'SMR Codec (hack of Microsoft MPEG-4) (IRC #shadowrealm)',
  1677. 'NT00' => 'NewTek LightWave HDTV YUV w/ Alpha (www.newtek.com)',
  1678. 'NUV1' => 'NuppelVideo',
  1679. 'NTN1' => 'Nogatech Video Compression 1',
  1680. 'NVS0' => 'nVidia GeForce Texture (NVS0)',
  1681. 'NVS1' => 'nVidia GeForce Texture (NVS1)',
  1682. 'NVS2' => 'nVidia GeForce Texture (NVS2)',
  1683. 'NVS3' => 'nVidia GeForce Texture (NVS3)',
  1684. 'NVS4' => 'nVidia GeForce Texture (NVS4)',
  1685. 'NVS5' => 'nVidia GeForce Texture (NVS5)',
  1686. 'NVT0' => 'nVidia GeForce Texture (NVT0)',
  1687. 'NVT1' => 'nVidia GeForce Texture (NVT1)',
  1688. 'NVT2' => 'nVidia GeForce Texture (NVT2)',
  1689. 'NVT3' => 'nVidia GeForce Texture (NVT3)',
  1690. 'NVT4' => 'nVidia GeForce Texture (NVT4)',
  1691. 'NVT5' => 'nVidia GeForce Texture (NVT5)',
  1692. 'PIXL' => 'MiroXL, Pinnacle PCTV',
  1693. 'PDVC' => 'I-O Data Device Digital Video Capture DV codec',
  1694. 'PGVV' => 'Radius Video Vision',
  1695. 'PHMO' => 'IBM Photomotion',
  1696. 'PIM1' => 'MPEG Realtime (Pinnacle Cards)',
  1697. 'PIM2' => 'Pegasus Imaging ?PIM2?',
  1698. 'PIMJ' => 'Pegasus Imaging Lossless JPEG',
  1699. 'PVEZ' => 'Horizons Technology PowerEZ',
  1700. 'PVMM' => 'PacketVideo Corporation MPEG-4',
  1701. 'PVW2' => 'Pegasus Imaging Wavelet Compression',
  1702. 'Q1.0' => 'Q-Team\'s QPEG 1.0 (www.q-team.de)',
  1703. 'Q1.1' => 'Q-Team\'s QPEG 1.1 (www.q-team.de)',
  1704. 'QPEG' => 'Q-Team QPEG 1.0',
  1705. 'qpeq' => 'Q-Team QPEG 1.1',
  1706. 'RGB ' => 'Raw BGR32',
  1707. 'RGBA' => 'Raw RGB w/ Alpha',
  1708. 'RMP4' => 'REALmagic MPEG-4 (unauthorized XVID copy) (www.sigmadesigns.com)',
  1709. 'ROQV' => 'Id RoQ File Video Decoder',
  1710. 'RPZA' => 'Quicktime Apple Video (RPZA)',
  1711. 'RUD0' => 'Rududu video codec (http://rududu.ifrance.com/rududu/)',
  1712. 'RV10' => 'RealVideo 1.0 (aka RealVideo 5.0)',
  1713. 'RV13' => 'RealVideo 1.0 (RV13)',
  1714. 'RV20' => 'RealVideo G2',
  1715. 'RV30' => 'RealVideo 8',
  1716. 'RV40' => 'RealVideo 9',
  1717. 'RGBT' => 'Raw RGB w/ Transparency',
  1718. 'RLE ' => 'Microsoft Run Length Encoder',
  1719. 'RLE4' => 'Run Length Encoded (4bpp, 16-color)',
  1720. 'RLE8' => 'Run Length Encoded (8bpp, 256-color)',
  1721. 'RT21' => 'Intel Indeo RealTime Video 2.1',
  1722. 'rv20' => 'RealVideo G2',
  1723. 'rv30' => 'RealVideo 8',
  1724. 'RVX ' => 'Intel RDX (RVX )',
  1725. 'SMC ' => 'Apple Graphics (SMC )',
  1726. 'SP54' => 'Logitech Sunplus Sp54 Codec for Mustek GSmart Mini 2',
  1727. 'SPIG' => 'Radius Spigot',
  1728. 'SVQ3' => 'Sorenson Video 3 (Apple Quicktime 5)',
  1729. 's422' => 'Tekram VideoCap C210 YUV 4:2:2',
  1730. 'SDCC' => 'Sun Communication Digital Camera Codec',
  1731. 'SFMC' => 'CrystalNet Surface Fitting Method',
  1732. 'SMSC' => 'Radius SMSC',
  1733. 'SMSD' => 'Radius SMSD',
  1734. 'smsv' => 'WorldConnect Wavelet Video',
  1735. 'SPIG' => 'Radius Spigot',
  1736. 'SPLC' => 'Splash Studios ACM Audio Codec (www.splashstudios.net)',
  1737. 'SQZ2' => 'Microsoft VXTreme Video Codec V2',
  1738. 'STVA' => 'ST Microelectronics CMOS Imager Data (Bayer)',
  1739. 'STVB' => 'ST Microelectronics CMOS Imager Data (Nudged Bayer)',
  1740. 'STVC' => 'ST Microelectronics CMOS Imager Data (Bunched)',
  1741. 'STVX' => 'ST Microelectronics CMOS Imager Data (Extended CODEC Data Format)',
  1742. 'STVY' => 'ST Microelectronics CMOS Imager Data (Extended CODEC Data Format with Correction Data)',
  1743. 'SV10' => 'Sorenson Video R1',
  1744. 'SVQ1' => 'Sorenson Video',
  1745. 'T420' => 'Toshiba YUV 4:2:0',
  1746. 'TM2A' => 'Duck TrueMotion Archiver 2.0 (www.duck.com)',
  1747. 'TVJP' => 'Pinnacle/Truevision Targa 2000 board (TVJP)',
  1748. 'TVMJ' => 'Pinnacle/Truevision Targa 2000 board (TVMJ)',
  1749. 'TY0N' => 'Tecomac Low-Bit Rate Codec (www.tecomac.com)',
  1750. 'TY2C' => 'Trident Decompression Driver',
  1751. 'TLMS' => 'TeraLogic Motion Intraframe Codec (TLMS)',
  1752. 'TLST' => 'TeraLogic Motion Intraframe Codec (TLST)',
  1753. 'TM20' => 'Duck TrueMotion 2.0',
  1754. 'TM2X' => 'Duck TrueMotion 2X',
  1755. 'TMIC' => 'TeraLogic Motion Intraframe Codec (TMIC)',
  1756. 'TMOT' => 'Horizons Technology TrueMotion S',
  1757. 'tmot' => 'Horizons TrueMotion Video Compression',
  1758. 'TR20' => 'Duck TrueMotion RealTime 2.0',
  1759. 'TSCC' => 'TechSmith Screen Capture Codec',
  1760. 'TV10' => 'Tecomac Low-Bit Rate Codec',
  1761. 'TY2N' => 'Trident ?TY2N?',
  1762. 'U263' => 'UB Video H.263/H.263+/H.263++ Decoder',
  1763. 'UMP4' => 'UB Video MPEG 4 (www.ubvideo.com)',
  1764. 'UYNV' => 'Nvidia UYVY packed 4:2:2',
  1765. 'UYVP' => 'Evans & Sutherland YCbCr 4:2:2 extended precision',
  1766. 'UCOD' => 'eMajix.com ClearVideo',
  1767. 'ULTI' => 'IBM Ultimotion',
  1768. 'UYVY' => 'UYVY packed 4:2:2',
  1769. 'V261' => 'Lucent VX2000S',
  1770. 'VIFP' => 'VFAPI Reader Codec (www.yks.ne.jp/~hori/)',
  1771. 'VIV1' => 'FFmpeg H263+ decoder',
  1772. 'VIV2' => 'Vivo H.263',
  1773. 'VQC2' => 'Vector-quantised codec 2 (research) http://eprints.ecs.soton.ac.uk/archive/00001310/01/VTC97-js.pdf)',
  1774. 'VTLP' => 'Alaris VideoGramPiX',
  1775. 'VYU9' => 'ATI YUV (VYU9)',
  1776. 'VYUY' => 'ATI YUV (VYUY)',
  1777. 'V261' => 'Lucent VX2000S',
  1778. 'V422' => 'Vitec Multimedia 24-bit YUV 4:2:2 Format',
  1779. 'V655' => 'Vitec Multimedia 16-bit YUV 4:2:2 Format',
  1780. 'VCR1' => 'ATI Video Codec 1',
  1781. 'VCR2' => 'ATI Video Codec 2',
  1782. 'VCR3' => 'ATI VCR 3.0',
  1783. 'VCR4' => 'ATI VCR 4.0',
  1784. 'VCR5' => 'ATI VCR 5.0',
  1785. 'VCR6' => 'ATI VCR 6.0',
  1786. 'VCR7' => 'ATI VCR 7.0',
  1787. 'VCR8' => 'ATI VCR 8.0',
  1788. 'VCR9' => 'ATI VCR 9.0',
  1789. 'VDCT' => 'Vitec Multimedia Video Maker Pro DIB',
  1790. 'VDOM' => 'VDOnet VDOWave',
  1791. 'VDOW' => 'VDOnet VDOLive (H.263)',
  1792. 'VDTZ' => 'Darim Vison VideoTizer YUV',
  1793. 'VGPX' => 'Alaris VideoGramPiX',
  1794. 'VIDS' => 'Vitec Multimedia YUV 4:2:2 CCIR 601 for V422',
  1795. 'VIVO' => 'Vivo H.263 v2.00',
  1796. 'vivo' => 'Vivo H.263',
  1797. 'VIXL' => 'Miro/Pinnacle Video XL',
  1798. 'VLV1' => 'VideoLogic/PURE Digital Videologic Capture',
  1799. 'VP30' => 'On2 VP3.0',
  1800. 'VP31' => 'On2 VP3.1',
  1801. 'VX1K' => 'Lucent VX1000S Video Codec',
  1802. 'VX2K' => 'Lucent VX2000S Video Codec',
  1803. 'VXSP' => 'Lucent VX1000SP Video Codec',
  1804. 'WBVC' => 'Winbond W9960',
  1805. 'WHAM' => 'Microsoft Video 1 (WHAM)',
  1806. 'WINX' => 'Winnov Software Compression',
  1807. 'WJPG' => 'AverMedia Winbond JPEG',
  1808. 'WMV1' => 'Windows Media Video V7',
  1809. 'WMV2' => 'Windows Media Video V8',
  1810. 'WMV3' => 'Windows Media Video V9',
  1811. 'WNV1' => 'Winnov Hardware Compression',
  1812. 'XYZP' => 'Extended PAL format XYZ palette (www.riff.org)',
  1813. 'x263' => 'Xirlink H.263',
  1814. 'XLV0' => 'NetXL Video Decoder',
  1815. 'XMPG' => 'Xing MPEG (I-Frame only)',
  1816. 'XVID' => 'XviD MPEG-4 (www.xvid.org)',
  1817. 'XXAN' => '?XXAN?',
  1818. 'YU92' => 'Intel YUV (YU92)',
  1819. 'YUNV' => 'Nvidia Uncompressed YUV 4:2:2',
  1820. 'YUVP' => 'Extended PAL format YUV palette (www.riff.org)',
  1821. 'Y211' => 'YUV 2:1:1 Packed',
  1822. 'Y411' => 'YUV 4:1:1 Packed',
  1823. 'Y41B' => 'Weitek YUV 4:1:1 Planar',
  1824. 'Y41P' => 'Brooktree PC1 YUV 4:1:1 Packed',
  1825. 'Y41T' => 'Brooktree PC1 YUV 4:1:1 with transparency',
  1826. 'Y42B' => 'Weitek YUV 4:2:2 Planar',
  1827. 'Y42T' => 'Brooktree UYUV 4:2:2 with transparency',
  1828. 'Y422' => 'ADS Technologies Copy of UYVY used in Pyro WebCam firewire camera',
  1829. 'Y800' => 'Simple, single Y plane for monochrome images',
  1830. 'Y8 ' => 'Grayscale video',
  1831. 'YC12' => 'Intel YUV 12 codec',
  1832. 'YUV8' => 'Winnov Caviar YUV8',
  1833. 'YUV9' => 'Intel YUV9',
  1834. 'YUY2' => 'Uncompressed YUV 4:2:2',
  1835. 'YUYV' => 'Canopus YUV',
  1836. 'YV12' => 'YVU12 Planar',
  1837. 'YVU9' => 'Intel YVU9 Planar (8-bpp Y plane, followed by 8-bpp 4x4 U and V planes)',
  1838. 'YVYU' => 'YVYU 4:2:2 Packed',
  1839. 'ZLIB' => 'Lossless Codec Library zlib compression (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm)',
  1840. 'ZPEG' => 'Metheus Video Zipper'
  1841. );
  1842. return @$lookup[$four_cc];
  1843. }
  1844. public static function RIFFcommentsParse(&$riff_info_aray, &$comments_target_array) {
  1845. static $lookup = array(
  1846. 'IARL' => 'archivallocation',
  1847. 'IART' => 'artist',
  1848. 'ICDS' => 'costumedesigner',
  1849. 'ICMS' => 'commissionedby',
  1850. 'ICMT' => 'comment',
  1851. 'ICNT' => 'country',
  1852. 'ICOP' => 'copyright',
  1853. 'ICRD' => 'creationdate',
  1854. 'IDIM' => 'dimensions',
  1855. 'IDIT' => 'digitizationdate',
  1856. 'IDPI' => 'resolution',
  1857. 'IDST' => 'distributor',
  1858. 'IEDT' => 'editor',
  1859. 'IENG' => 'engineers',
  1860. 'IFRM' => 'accountofparts',
  1861. 'IGNR' => 'genre',
  1862. 'IKEY' => 'keywords',
  1863. 'ILGT' => 'lightness',
  1864. 'ILNG' => 'language',
  1865. 'IMED' => 'orignalmedium',
  1866. 'IMUS' => 'composer',
  1867. 'INAM' => 'title',
  1868. 'IPDS' => 'productiondesigner',
  1869. 'IPLT' => 'palette',
  1870. 'IPRD' => 'product',
  1871. 'IPRO' => 'producer',
  1872. 'IPRT' => 'part',
  1873. 'IRTD' => 'rating',
  1874. 'ISBJ' => 'subject',
  1875. 'ISFT' => 'software',
  1876. 'ISGN' => 'secondarygenre',
  1877. 'ISHP' => 'sharpness',
  1878. 'ISRC' => 'sourcesupplier',
  1879. 'ISRF' => 'digitizationsource',
  1880. 'ISTD' => 'productionstudio',
  1881. 'ISTR' => 'starring',
  1882. 'ITCH' => 'encoded_by',
  1883. 'IWEB' => 'url',
  1884. 'IWRI' => 'writer'
  1885. );
  1886. foreach ($lookup as $key => $value) {
  1887. if (isset($riff_info_aray[$key])) {
  1888. foreach ($riff_info_aray[$key] as $comment_id => $comment_data) {
  1889. if (trim($comment_data['data']) != '') {
  1890. @$comments_target_array[$value][] = trim($comment_data['data']);
  1891. }
  1892. }
  1893. }
  1894. }
  1895. return true;
  1896. }
  1897. public static function array_merge_noclobber($array1, $array2) {
  1898. if (!is_array($array1) || !is_array($array2)) {
  1899. return false;
  1900. }
  1901. $new_array = $array1;
  1902. foreach ($array2 as $key => $val) {
  1903. if (is_array($val) && isset($new_array[$key]) && is_array($new_array[$key])) {
  1904. $new_array[$key] = getid3_riff::array_merge_noclobber($new_array[$key], $val);
  1905. } elseif (!isset($new_array[$key])) {
  1906. $new_array[$key] = $val;
  1907. }
  1908. }
  1909. return $new_array;
  1910. }
  1911. public static function DateMac2Unix($mac_date) {
  1912. // Macintosh timestamp: seconds since 00:00h January 1, 1904
  1913. // UNIX timestamp: seconds since 00:00h January 1, 1970
  1914. return (int)($mac_date - 2082844800);
  1915. }
  1916. public static function FixedPoint16_16($raw_data) {
  1917. return getid3_lib::BigEndian2Int(substr($raw_data, 0, 2)) + (float)(getid3_lib::BigEndian2Int(substr($raw_data, 2, 2)) / 65536); // pow(2, 16) = 65536
  1918. }
  1919. function BigEndian2Float($byte_word) {
  1920. // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
  1921. // http://www.psc.edu/general/software/packages/ieee/ieee.html
  1922. // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
  1923. $bit_word = getid3_lib::BigEndian2Bin($byte_word);
  1924. $sign_bit = $bit_word{0};
  1925. switch (strlen($byte_word) * 8) {
  1926. case 32:
  1927. $exponent_bits = 8;
  1928. $fraction_bits = 23;
  1929. break;
  1930. case 64:
  1931. $exponent_bits = 11;
  1932. $fraction_bits = 52;
  1933. break;
  1934. case 80:
  1935. // 80-bit Apple SANE format
  1936. // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
  1937. $exponent_string = substr($bit_word, 1, 15);
  1938. $is_normalized = intval($bit_word{16});
  1939. $fraction_string = substr($bit_word, 17, 63);
  1940. $exponent = pow(2, bindec($exponent_string) - 16383);
  1941. $fraction = $is_normalized + bindec($fraction_string) / bindec('1'.str_repeat('0', strlen($fraction_string)));
  1942. $float_value = $exponent * $fraction;
  1943. if ($sign_bit == '1') {
  1944. $float_value *= -1;
  1945. }
  1946. return $float_value;
  1947. break;
  1948. default:
  1949. return false;
  1950. break;
  1951. }
  1952. $exponent_string = substr($bit_word, 1, $exponent_bits);
  1953. $fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits);
  1954. $exponent = bindec($exponent_string);
  1955. $fraction = bindec($fraction_string);
  1956. if (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction != 0)) {
  1957. // Not a Number
  1958. $float_value = false;
  1959. } elseif (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction == 0)) {
  1960. if ($sign_bit == '1') {
  1961. $float_value = '-infinity';
  1962. } else {
  1963. $float_value = '+infinity';
  1964. }
  1965. } elseif (($exponent == 0) && ($fraction == 0)) {
  1966. if ($sign_bit == '1') {
  1967. $float_value = -0;
  1968. } else {
  1969. $float_value = 0;
  1970. }
  1971. $float_value = ($sign_bit ? 0 : -0);
  1972. } elseif (($exponent == 0) && ($fraction != 0)) {
  1973. // These are 'unnormalized' values
  1974. $float_value = pow(2, (-1 * (pow(2, $exponent_bits - 1) - 2))) * bindec($fraction_string) / bindec('1'.str_repeat('0', strlen($fraction_string)));
  1975. if ($sign_bit == '1') {
  1976. $float_value *= -1;
  1977. }
  1978. } elseif ($exponent != 0) {
  1979. $float_value = pow(2, ($exponent - (pow(2, $exponent_bits - 1) - 1))) * (1 + bindec($fraction_string) / bindec('1'.str_repeat('0', strlen($fraction_string))));
  1980. if ($sign_bit == '1') {
  1981. $float_value *= -1;
  1982. }
  1983. }
  1984. return (float) $float_value;
  1985. }
  1986. }
  1987. ?>