Mercurial > judyates
diff e2gallerypro/e2upload/Backend/Assets/getid3/module.audio-video.riff.php @ 3:3f6b44aa6b35 judyates
[svn r4] added ability to buy stuff, from a Prints page, but it doesn't work well with the css, and it also has not been fitted into the perl make system.
author | rlm |
---|---|
date | Mon, 22 Feb 2010 08:02:39 -0500 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/e2gallerypro/e2upload/Backend/Assets/getid3/module.audio-video.riff.php Mon Feb 22 08:02:39 2010 -0500 1.3 @@ -0,0 +1,2319 @@ 1.4 +<?php 1.5 +// +----------------------------------------------------------------------+ 1.6 +// | PHP version 5 | 1.7 +// +----------------------------------------------------------------------+ 1.8 +// | Copyright (c) 2002-2006 James Heinrich, Allan Hansen | 1.9 +// +----------------------------------------------------------------------+ 1.10 +// | This source file is subject to version 2 of the GPL license, | 1.11 +// | that is bundled with this package in the file license.txt and is | 1.12 +// | available through the world-wide-web at the following url: | 1.13 +// | http://www.gnu.org/copyleft/gpl.html | 1.14 +// +----------------------------------------------------------------------+ 1.15 +// | getID3() - http://getid3.sourceforge.net or http://www.getid3.org | 1.16 +// +----------------------------------------------------------------------+ 1.17 +// | Authors: James Heinrich <infoØgetid3*org> | 1.18 +// | Allan Hansen <ahØartemis*dk> | 1.19 +// +----------------------------------------------------------------------+ 1.20 +// | module.audio-video.riff.php | 1.21 +// | module for analyzing RIFF files: | 1.22 +// | Wave, AVI, AIFF/AIFC, (MP3,AC3)/RIFF, Wavpack3, 8SVX | 1.23 +// | dependencies: module.audio.mp3.php (optional) | 1.24 +// | module.audio.ac3.php (optional) | 1.25 +// | module.audio.dts.php (optional) | 1.26 +// | module.audio-video.mpeg.php (optional) | 1.27 +// +----------------------------------------------------------------------+ 1.28 +// 1.29 +// $Id: module.audio-video.riff.php,v 1.10 2006/12/03 20:13:17 ah Exp $ 1.30 + 1.31 + 1.32 + 1.33 +class getid3_riff extends getid3_handler 1.34 +{ 1.35 + 1.36 + private $endian_function = 'LittleEndian2Int'; 1.37 + 1.38 + 1.39 + public function Analyze() { 1.40 + 1.41 + $getid3 = $this->getid3; 1.42 + 1.43 + $getid3->info['riff']['raw'] = array (); 1.44 + $info_riff = &$getid3->info['riff']; 1.45 + $info_riff_raw = &$info_riff['raw']; 1.46 + $info_audio = &$getid3->info['audio']; 1.47 + $info_video = &$getid3->info['video']; 1.48 + $info_avdataoffset = &$getid3->info['avdataoffset']; 1.49 + $info_avdataend = &$getid3->info['avdataend']; 1.50 + $info_audio_dataformat = &$info_audio['dataformat']; 1.51 + $info_riff_audio = &$info_riff['audio']; 1.52 + $info_riff_video = &$info_riff['video']; 1.53 + 1.54 + $original['avdataend'] = $info_avdataend; 1.55 + 1.56 + $this->fseek($info_avdataoffset, SEEK_SET); 1.57 + $riff_header = $this->fread(12); 1.58 + 1.59 + $riff_sub_type = substr($riff_header, 8, 4); 1.60 + 1.61 + switch (substr($riff_header, 0, 4)) { 1.62 + 1.63 + case 'FORM': 1.64 + $getid3->info['fileformat'] = 'aiff'; 1.65 + $this->endian_function = 'BigEndian2Int'; 1.66 + $riff_header_size = getid3_lib::BigEndian2Int(substr($riff_header, 4, 4)); 1.67 + $info_riff[$riff_sub_type] = $this->ParseRIFF($info_avdataoffset + 12, $info_avdataoffset + $riff_header_size); 1.68 + $info_riff['header_size'] = $riff_header_size; 1.69 + break; 1.70 + 1.71 + 1.72 + case 'RIFF': 1.73 + case 'SDSS': // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com) 1.74 + case 'RMP3': // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s 1.75 + 1.76 + if ($riff_sub_type == 'RMP3') { 1.77 + $riff_sub_type = 'WAVE'; 1.78 + } 1.79 + 1.80 + $getid3->info['fileformat'] = 'riff'; 1.81 + $this->endian_function = 'LittleEndian2Int'; 1.82 + $riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_header, 4, 4)); 1.83 + $info_riff[$riff_sub_type] = $this->ParseRIFF($info_avdataoffset + 12, $info_avdataoffset + $riff_header_size); 1.84 + $info_riff['header_size'] = $riff_header_size; 1.85 + if ($riff_sub_type == 'WAVE') { 1.86 + $info_riff_wave = &$info_riff['WAVE']; 1.87 + } 1.88 + break; 1.89 + 1.90 + 1.91 + default: 1.92 + 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'); 1.93 + } 1.94 + 1.95 + $endian_function = $this->endian_function; 1.96 + 1.97 + $stream_index = 0; 1.98 + switch ($riff_sub_type) { 1.99 + 1.100 + case 'WAVE': 1.101 + 1.102 + if (empty($info_audio['bitrate_mode'])) { 1.103 + $info_audio['bitrate_mode'] = 'cbr'; 1.104 + } 1.105 + 1.106 + if (empty($info_audio_dataformat)) { 1.107 + $info_audio_dataformat = 'wav'; 1.108 + } 1.109 + 1.110 + if (isset($info_riff_wave['data'][0]['offset'])) { 1.111 + $info_avdataoffset = $info_riff_wave['data'][0]['offset'] + 8; 1.112 + $info_avdataend = $info_avdataoffset + $info_riff_wave['data'][0]['size']; 1.113 + } 1.114 + 1.115 + if (isset($info_riff_wave['fmt '][0]['data'])) { 1.116 + 1.117 + $info_riff_audio[$stream_index] = getid3_riff::RIFFparseWAVEFORMATex($info_riff_wave['fmt '][0]['data']); 1.118 + $info_audio['wformattag'] = $info_riff_audio[$stream_index]['raw']['wFormatTag']; 1.119 + $info_riff_raw['fmt '] = $info_riff_audio[$stream_index]['raw']; 1.120 + unset($info_riff_audio[$stream_index]['raw']); 1.121 + $info_audio['streams'][$stream_index] = $info_riff_audio[$stream_index]; 1.122 + 1.123 + $info_audio = getid3_riff::array_merge_noclobber($info_audio, $info_riff_audio[$stream_index]); 1.124 + if (substr($info_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') { 1.125 + $getid3->warning('Audio codec = '.$info_audio['codec']); 1.126 + } 1.127 + $info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate']; 1.128 + 1.129 + $getid3->info['playtime_seconds'] = (float)((($info_avdataend - $info_avdataoffset) * 8) / $info_audio['bitrate']); 1.130 + 1.131 + $info_audio['lossless'] = false; 1.132 + 1.133 + if (isset($info_riff_wave['data'][0]['offset']) && isset($info_riff_raw['fmt ']['wFormatTag'])) { 1.134 + 1.135 + switch ($info_riff_raw['fmt ']['wFormatTag']) { 1.136 + 1.137 + case 0x0001: // PCM 1.138 + $info_audio['lossless'] = true; 1.139 + break; 1.140 + 1.141 + case 0x2000: // AC-3 1.142 + $info_audio_dataformat = 'ac3'; 1.143 + break; 1.144 + 1.145 + default: 1.146 + // do nothing 1.147 + break; 1.148 + 1.149 + } 1.150 + } 1.151 + 1.152 + $info_audio['streams'][$stream_index]['wformattag'] = $info_audio['wformattag']; 1.153 + $info_audio['streams'][$stream_index]['bitrate_mode'] = $info_audio['bitrate_mode']; 1.154 + $info_audio['streams'][$stream_index]['lossless'] = $info_audio['lossless']; 1.155 + $info_audio['streams'][$stream_index]['dataformat'] = $info_audio_dataformat; 1.156 + } 1.157 + 1.158 + 1.159 + if (isset($info_riff_wave['rgad'][0]['data'])) { 1.160 + 1.161 + // shortcuts 1.162 + $rgadData = &$info_riff_wave['rgad'][0]['data']; 1.163 + $info_riff_raw['rgad'] = array ('track'=>array(), 'album'=>array()); 1.164 + $info_riff_raw_rgad = &$info_riff_raw['rgad']; 1.165 + $info_riff_raw_rgad_track = &$info_riff_raw_rgad['track']; 1.166 + $info_riff_raw_rgad_album = &$info_riff_raw_rgad['album']; 1.167 + 1.168 + $info_riff_raw_rgad['fPeakAmplitude'] = getid3_riff::BigEndian2Float(strrev(substr($rgadData, 0, 4))); // LittleEndian2Float() 1.169 + $info_riff_raw_rgad['nRadioRgAdjust'] = getid3_lib::$endian_function(substr($rgadData, 4, 2)); 1.170 + $info_riff_raw_rgad['nAudiophileRgAdjust'] = getid3_lib::$endian_function(substr($rgadData, 6, 2)); 1.171 + 1.172 + $n_track_rg_adjust_bit_string = str_pad(decbin($info_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT); 1.173 + $n_album_rg_adjust_bit_string = str_pad(decbin($info_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT); 1.174 + 1.175 + $info_riff_raw_rgad_track['name'] = bindec(substr($n_track_rg_adjust_bit_string, 0, 3)); 1.176 + $info_riff_raw_rgad_track['originator'] = bindec(substr($n_track_rg_adjust_bit_string, 3, 3)); 1.177 + $info_riff_raw_rgad_track['signbit'] = bindec($n_track_rg_adjust_bit_string[6]); 1.178 + $info_riff_raw_rgad_track['adjustment'] = bindec(substr($n_track_rg_adjust_bit_string, 7, 9)); 1.179 + $info_riff_raw_rgad_album['name'] = bindec(substr($n_album_rg_adjust_bit_string, 0, 3)); 1.180 + $info_riff_raw_rgad_album['originator'] = bindec(substr($n_album_rg_adjust_bit_string, 3, 3)); 1.181 + $info_riff_raw_rgad_album['signbit'] = bindec($n_album_rg_adjust_bit_string[6]); 1.182 + $info_riff_raw_rgad_album['adjustment'] = bindec(substr($n_album_rg_adjust_bit_string, 7, 9)); 1.183 + 1.184 + $info_riff['rgad']['peakamplitude'] = $info_riff_raw_rgad['fPeakAmplitude']; 1.185 + if (($info_riff_raw_rgad_track['name'] != 0) && ($info_riff_raw_rgad_track['originator'] != 0)) { 1.186 + $info_riff['rgad']['track']['name'] = getid3_lib_replaygain::NameLookup($info_riff_raw_rgad_track['name']); 1.187 + $info_riff['rgad']['track']['originator'] = getid3_lib_replaygain::OriginatorLookup($info_riff_raw_rgad_track['originator']); 1.188 + $info_riff['rgad']['track']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($info_riff_raw_rgad_track['adjustment'], $info_riff_raw_rgad_track['signbit']); 1.189 + } 1.190 + 1.191 + if (($info_riff_raw_rgad_album['name'] != 0) && ($info_riff_raw_rgad_album['originator'] != 0)) { 1.192 + $info_riff['rgad']['album']['name'] = getid3_lib_replaygain::NameLookup($info_riff_raw_rgad_album['name']); 1.193 + $info_riff['rgad']['album']['originator'] = getid3_lib_replaygain::OriginatorLookup($info_riff_raw_rgad_album['originator']); 1.194 + $info_riff['rgad']['album']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($info_riff_raw_rgad_album['adjustment'], $info_riff_raw_rgad_album['signbit']); 1.195 + } 1.196 + } 1.197 + 1.198 + if (isset($info_riff_wave['fact'][0]['data'])) { 1.199 + 1.200 + $info_riff_raw['fact']['NumberOfSamples'] = getid3_lib::$endian_function(substr($info_riff_wave['fact'][0]['data'], 0, 4)); 1.201 + 1.202 + // 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 1.203 + // if (!empty($info_riff_raw['fmt ']['nSamplesPerSec'])) { 1.204 + // $getid3->info['playtime_seconds'] = (float)$info_riff_raw['fact']['NumberOfSamples'] / $info_riff_raw['fmt ']['nSamplesPerSec']; 1.205 + // } 1.206 + } 1.207 + 1.208 + 1.209 + if (!empty($info_riff_raw['fmt ']['nAvgBytesPerSec'])) { 1.210 + $info_audio['bitrate'] = (int)$info_riff_raw['fmt ']['nAvgBytesPerSec'] * 8; 1.211 + } 1.212 + 1.213 + if (isset($info_riff_wave['bext'][0]['data'])) { 1.214 + 1.215 + $info_riff_wave_bext_0 = &$info_riff_wave['bext'][0]; 1.216 + 1.217 + getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_wave_bext_0, $info_riff_wave_bext_0['data'], 0, 1.218 + array ( 1.219 + 'title' => -256, 1.220 + 'author' => -32, 1.221 + 'reference' => -32, 1.222 + 'origin_date' => -10, 1.223 + 'origin_time' => -8, 1.224 + 'time_reference' => 8, 1.225 + 'bwf_version' => 1, 1.226 + 'reserved' => 254 1.227 + ) 1.228 + ); 1.229 + 1.230 + foreach (array ('title', 'author', 'reference') as $key) { 1.231 + $info_riff_wave_bext_0[$key] = trim($info_riff_wave_bext_0[$key]); 1.232 + } 1.233 + 1.234 + $info_riff_wave_bext_0['coding_history'] = explode("\r\n", trim(substr($info_riff_wave_bext_0['data'], 601))); 1.235 + 1.236 + $info_riff_wave_bext_0['origin_date_unix'] = gmmktime(substr($info_riff_wave_bext_0['origin_time'], 0, 2), 1.237 + substr($info_riff_wave_bext_0['origin_time'], 3, 2), 1.238 + substr($info_riff_wave_bext_0['origin_time'], 6, 2), 1.239 + substr($info_riff_wave_bext_0['origin_date'], 5, 2), 1.240 + substr($info_riff_wave_bext_0['origin_date'], 8, 2), 1.241 + substr($info_riff_wave_bext_0['origin_date'], 0, 4)); 1.242 + 1.243 + $info_riff['comments']['author'][] = $info_riff_wave_bext_0['author']; 1.244 + $info_riff['comments']['title'][] = $info_riff_wave_bext_0['title']; 1.245 + } 1.246 + 1.247 + if (isset($info_riff_wave['MEXT'][0]['data'])) { 1.248 + 1.249 + $info_riff_wave_mext_0 = &$info_riff_wave['MEXT'][0]; 1.250 + 1.251 + $info_riff_wave_mext_0['raw']['sound_information'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 0, 2)); 1.252 + $info_riff_wave_mext_0['flags']['homogenous'] = (bool)($info_riff_wave_mext_0['raw']['sound_information'] & 0x0001); 1.253 + if ($info_riff_wave_mext_0['flags']['homogenous']) { 1.254 + $info_riff_wave_mext_0['flags']['padding'] = ($info_riff_wave_mext_0['raw']['sound_information'] & 0x0002) ? false : true; 1.255 + $info_riff_wave_mext_0['flags']['22_or_44'] = (bool)($info_riff_wave_mext_0['raw']['sound_information'] & 0x0004); 1.256 + $info_riff_wave_mext_0['flags']['free_format'] = (bool)($info_riff_wave_mext_0['raw']['sound_information'] & 0x0008); 1.257 + 1.258 + $info_riff_wave_mext_0['nominal_frame_size'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 2, 2)); 1.259 + } 1.260 + $info_riff_wave_mext_0['anciliary_data_length'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 6, 2)); 1.261 + $info_riff_wave_mext_0['raw']['anciliary_data_def'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 8, 2)); 1.262 + $info_riff_wave_mext_0['flags']['anciliary_data_left'] = (bool)($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x0001); 1.263 + $info_riff_wave_mext_0['flags']['anciliary_data_free'] = (bool)($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x0002); 1.264 + $info_riff_wave_mext_0['flags']['anciliary_data_right'] = (bool)($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x0004); 1.265 + } 1.266 + 1.267 + if (isset($info_riff_wave['cart'][0]['data'])) { 1.268 + 1.269 + $info_riff_wave_cart_0 = &$info_riff_wave['cart'][0]; 1.270 + 1.271 + getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_wave_cart_0, $info_riff_wave_cart_0['data'], 0, 1.272 + array ( 1.273 + 'version' => -4, 1.274 + 'title' => -64, 1.275 + 'artist' => -64, 1.276 + 'cut_id' => -64, 1.277 + 'client_id' => -64, 1.278 + 'category' => -64, 1.279 + 'classification' => -64, 1.280 + 'out_cue' => -64, 1.281 + 'start_date' => -10, 1.282 + 'start_time' => -8, 1.283 + 'end_date' => -10, 1.284 + 'end_time' => -8, 1.285 + 'producer_app_id' => -64, 1.286 + 'producer_app_version' => -64, 1.287 + 'user_defined_text' => -64, 1.288 + ) 1.289 + ); 1.290 + 1.291 + 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) { 1.292 + $info_riff_wave_cart_0[$key] = trim($info_riff_wave_cart_0[$key]); 1.293 + } 1.294 + 1.295 + $info_riff_wave_cart_0['zero_db_reference'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_cart_0['data'], 680, 4), true); 1.296 + 1.297 + for ($i = 0; $i < 8; $i++) { 1.298 + $info_riff_wave_cart_0['post_time'][$i]['usage_fourcc'] = substr($info_riff_wave_cart_0['data'], 684 + ($i * 8), 4); 1.299 + $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)); 1.300 + } 1.301 + $info_riff_wave_cart_0['url'] = trim(substr($info_riff_wave_cart_0['data'], 748, 1024)); 1.302 + $info_riff_wave_cart_0['tag_text'] = explode("\r\n", trim(substr($info_riff_wave_cart_0['data'], 1772))); 1.303 + 1.304 + $info_riff['comments']['artist'][] = $info_riff_wave_cart_0['artist']; 1.305 + $info_riff['comments']['title'][] = $info_riff_wave_cart_0['title']; 1.306 + } 1.307 + 1.308 + if (!isset($info_audio['bitrate']) && isset($info_riff_audio[$stream_index]['bitrate'])) { 1.309 + $info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate']; 1.310 + $getid3->info['playtime_seconds'] = (float)((($info_avdataend - $info_avdataoffset) * 8) / $info_audio['bitrate']); 1.311 + } 1.312 + 1.313 + if (@$getid3->info['wavpack']) { 1.314 + 1.315 + if (!$this->data_string_flag) { 1.316 + 1.317 + $info_audio_dataformat = 'wavpack'; 1.318 + $info_audio['bitrate_mode'] = 'vbr'; 1.319 + $info_audio['encoder'] = 'WavPack v'.$getid3->info['wavpack']['version']; 1.320 + 1.321 + // Reset to the way it was - RIFF parsing will have messed this up 1.322 + $info_avdataend = $original['avdataend']; 1.323 + $info_audio['bitrate'] = (($info_avdataend - $info_avdataoffset) * 8) / $getid3->info['playtime_seconds']; 1.324 + 1.325 + $this->fseek($info_avdataoffset - 44, SEEK_SET); 1.326 + $riff_data = $this->fread(44); 1.327 + $orignal_riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_data, 4, 4)) + 8; 1.328 + $orignal_riff_data_size = getid3_lib::LittleEndian2Int(substr($riff_data, 40, 4)) + 44; 1.329 + 1.330 + if ($orignal_riff_header_size > $orignal_riff_data_size) { 1.331 + $info_avdataend -= ($orignal_riff_header_size - $orignal_riff_data_size); 1.332 + $this->fseek($info_avdataend, SEEK_SET); 1.333 + $riff_data .= $this->fread($orignal_riff_header_size - $orignal_riff_data_size); 1.334 + } 1.335 + 1.336 + // move the data chunk after all other chunks (if any) 1.337 + // so that the RIFF parser doesn't see EOF when trying 1.338 + // to skip over the data chunk 1.339 + $riff_data = substr($riff_data, 0, 36).substr($riff_data, 44).substr($riff_data, 36, 8); 1.340 + 1.341 + // Save audio info key 1.342 + $saved_info_audio = $info_audio; 1.343 + 1.344 + // Analyze riff_data 1.345 + $this->AnalyzeString($riff_data); 1.346 + 1.347 + // Restore info key 1.348 + $info_audio = $saved_info_audio; 1.349 + } 1.350 + } 1.351 + 1.352 + if (isset($info_riff_raw['fmt ']['wFormatTag'])) { 1.353 + 1.354 + switch ($info_riff_raw['fmt ']['wFormatTag']) { 1.355 + 1.356 + case 0x08AE: // ClearJump LiteWave 1.357 + $info_audio['bitrate_mode'] = 'vbr'; 1.358 + $info_audio_dataformat = 'litewave'; 1.359 + 1.360 + //typedef struct tagSLwFormat { 1.361 + // WORD m_wCompFormat; // low byte defines compression method, high byte is compression flags 1.362 + // DWORD m_dwScale; // scale factor for lossy compression 1.363 + // DWORD m_dwBlockSize; // number of samples in encoded blocks 1.364 + // WORD m_wQuality; // alias for the scale factor 1.365 + // WORD m_wMarkDistance; // distance between marks in bytes 1.366 + // WORD m_wReserved; 1.367 + // 1.368 + // //following paramters are ignored if CF_FILESRC is not set 1.369 + // DWORD m_dwOrgSize; // original file size in bytes 1.370 + // WORD m_bFactExists; // indicates if 'fact' chunk exists in the original file 1.371 + // DWORD m_dwRiffChunkSize; // riff chunk size in the original file 1.372 + // 1.373 + // PCMWAVEFORMAT m_OrgWf; // original wave format 1.374 + // }SLwFormat, *PSLwFormat; 1.375 + 1.376 + $info_riff['litewave']['raw'] = array (); 1.377 + $info_riff_litewave = &$info_riff['litewave']; 1.378 + $info_riff_litewave_raw = &$info_riff_litewave['raw']; 1.379 + 1.380 + getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_litewave_raw, $info_riff_wave['fmt '][0]['data'], 18, 1.381 + array ( 1.382 + 'compression_method' => 1, 1.383 + 'compression_flags' => 1, 1.384 + 'm_dwScale' => 4, 1.385 + 'm_dwBlockSize' => 4, 1.386 + 'm_wQuality' => 2, 1.387 + 'm_wMarkDistance' => 2, 1.388 + 'm_wReserved' => 2, 1.389 + 'm_dwOrgSize' => 4, 1.390 + 'm_bFactExists' => 2, 1.391 + 'm_dwRiffChunkSize' => 4 1.392 + ) 1.393 + ); 1.394 + 1.395 + //$info_riff_litewave['quality_factor'] = intval(round((2000 - $info_riff_litewave_raw['m_dwScale']) / 20)); 1.396 + $info_riff_litewave['quality_factor'] = $info_riff_litewave_raw['m_wQuality']; 1.397 + 1.398 + $info_riff_litewave['flags']['raw_source'] = ($info_riff_litewave_raw['compression_flags'] & 0x01) ? false : true; 1.399 + $info_riff_litewave['flags']['vbr_blocksize'] = ($info_riff_litewave_raw['compression_flags'] & 0x02) ? false : true; 1.400 + $info_riff_litewave['flags']['seekpoints'] = (bool)($info_riff_litewave_raw['compression_flags'] & 0x04); 1.401 + 1.402 + $info_audio['lossless'] = (($info_riff_litewave_raw['m_wQuality'] == 100) ? true : false); 1.403 + $info_audio['encoder_options'] = '-q'.$info_riff_litewave['quality_factor']; 1.404 + break; 1.405 + } 1.406 + } 1.407 + 1.408 + if ($info_avdataend > $getid3->info['filesize']) { 1.409 + 1.410 + switch (@$info_audio_dataformat) { 1.411 + 1.412 + case 'wavpack': // WavPack 1.413 + case 'lpac': // LPAC 1.414 + case 'ofr': // OptimFROG 1.415 + case 'ofs': // OptimFROG DualStream 1.416 + // lossless compressed audio formats that keep original RIFF headers - skip warning 1.417 + break; 1.418 + 1.419 + 1.420 + case 'litewave': 1.421 + 1.422 + if (($info_avdataend - $getid3->info['filesize']) == 1) { 1.423 + // LiteWave appears to incorrectly *not* pad actual output file 1.424 + // to nearest WORD boundary so may appear to be short by one 1.425 + // byte, in which case - skip warning 1.426 + } else { 1.427 + // Short by more than one byte, throw warning 1.428 + $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)'); 1.429 + } 1.430 + break; 1.431 + 1.432 + 1.433 + default: 1.434 + 1.435 + if ((($info_avdataend - $getid3->info['filesize']) == 1) && (($info_riff[$riff_sub_type]['data'][0]['size'] % 2) == 0) && ((($getid3->info['filesize'] - $info_avdataoffset) % 2) == 1)) { 1.436 + // output file appears to be incorrectly *not* padded to nearest WORD boundary 1.437 + // Output less severe warning 1.438 + $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)'); 1.439 + $info_avdataend = $getid3->info['filesize']; 1.440 + break; 1.441 + 1.442 + } 1.443 + // Short by more than one byte, throw warning 1.444 + $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)'); 1.445 + $info_avdataend = $getid3->info['filesize']; 1.446 + break; 1.447 + } 1.448 + } 1.449 + 1.450 + if (!empty($getid3->info['mpeg']['audio']['LAME']['audio_bytes'])) { 1.451 + if ((($info_avdataend - $info_avdataoffset) - $getid3->info['mpeg']['audio']['LAME']['audio_bytes']) == 1) { 1.452 + $info_avdataend--; 1.453 + $getid3->warning('Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored'); 1.454 + } 1.455 + } 1.456 + 1.457 + if (@$info_audio_dataformat == 'ac3') { 1.458 + unset($info_audio['bits_per_sample']); 1.459 + if (!empty($getid3->info['ac3']['bitrate']) && ($getid3->info['ac3']['bitrate'] != $info_audio['bitrate'])) { 1.460 + $info_audio['bitrate'] = $getid3->info['ac3']['bitrate']; 1.461 + } 1.462 + } 1.463 + break; 1.464 + 1.465 + 1.466 + case 'AVI ': 1.467 + $info_video['bitrate_mode'] = 'vbr'; // maybe not, but probably 1.468 + $info_video['dataformat'] = 'avi'; 1.469 + $getid3->info['mime_type'] = 'video/avi'; 1.470 + 1.471 + if (isset($info_riff[$riff_sub_type]['movi']['offset'])) { 1.472 + $info_avdataoffset = $info_riff[$riff_sub_type]['movi']['offset'] + 8; 1.473 + $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['movi']['size']; 1.474 + if ($info_avdataend > $getid3->info['filesize']) { 1.475 + $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)'); 1.476 + $info_avdataend = $getid3->info['filesize']; 1.477 + } 1.478 + } 1.479 + 1.480 + if (isset($info_riff['AVI ']['hdrl']['avih'][$stream_index]['data'])) { 1.481 + $avihData = $info_riff['AVI ']['hdrl']['avih'][$stream_index]['data']; 1.482 + 1.483 + $info_riff_raw['avih'] = array (); 1.484 + $info_riff_raw_avih = &$info_riff_raw['avih']; 1.485 + 1.486 + getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_avih, $avihData, 0, 1.487 + array ( 1.488 + 'dwMicroSecPerFrame' => 4, // frame display rate (or 0L) 1.489 + 'dwMaxBytesPerSec' => 4, // max. transfer rate 1.490 + 'dwPaddingGranularity' => 4, // pad to multiples of this size; normally 2K. 1.491 + 'dwFlags' => 4, // the ever-present flags 1.492 + 'dwTotalFrames' => 4, // # frames in file 1.493 + 'dwInitialFrames' => 4, 1.494 + 'dwStreams' => 4, 1.495 + 'dwSuggestedBufferSize' => 4, 1.496 + 'dwWidth' => 4, 1.497 + 'dwHeight' => 4, 1.498 + 'dwScale' => 4, 1.499 + 'dwRate' => 4, 1.500 + 'dwStart' => 4, 1.501 + 'dwLength' => 4 1.502 + ) 1.503 + ); 1.504 + 1.505 + $info_riff_raw_avih['flags']['hasindex'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000010); 1.506 + $info_riff_raw_avih['flags']['mustuseindex'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000020); 1.507 + $info_riff_raw_avih['flags']['interleaved'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000100); 1.508 + $info_riff_raw_avih['flags']['trustcktype'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000800); 1.509 + $info_riff_raw_avih['flags']['capturedfile'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00010000); 1.510 + $info_riff_raw_avih['flags']['copyrighted'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00020010); 1.511 + 1.512 + $info_riff_video[$stream_index] = array (); 1.513 + $info_riff_video_current = &$info_riff_video[$stream_index]; 1.514 + 1.515 + if ($info_riff_raw_avih['dwWidth'] > 0) { 1.516 + $info_riff_video_current['frame_width'] = $info_riff_raw_avih['dwWidth']; 1.517 + $info_video['resolution_x'] = $info_riff_video_current['frame_width']; 1.518 + } 1.519 + 1.520 + if ($info_riff_raw_avih['dwHeight'] > 0) { 1.521 + $info_riff_video_current['frame_height'] = $info_riff_raw_avih['dwHeight']; 1.522 + $info_video['resolution_y'] = $info_riff_video_current['frame_height']; 1.523 + } 1.524 + 1.525 + if ($info_riff_raw_avih['dwTotalFrames'] > 0) { 1.526 + $info_riff_video_current['total_frames'] = $info_riff_raw_avih['dwTotalFrames']; 1.527 + $info_video['total_frames'] = $info_riff_video_current['total_frames']; 1.528 + } 1.529 + 1.530 + $info_riff_video_current['frame_rate'] = round(1000000 / $info_riff_raw_avih['dwMicroSecPerFrame'], 3); 1.531 + $info_video['frame_rate'] = $info_riff_video_current['frame_rate']; 1.532 + } 1.533 + 1.534 + if (isset($info_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) { 1.535 + if (is_array($info_riff['AVI ']['hdrl']['strl']['strh'])) { 1.536 + for ($i = 0; $i < count($info_riff['AVI ']['hdrl']['strl']['strh']); $i++) { 1.537 + if (isset($info_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'])) { 1.538 + $strh_data = $info_riff['AVI ']['hdrl']['strl']['strh'][$i]['data']; 1.539 + $strh_fcc_type = substr($strh_data, 0, 4); 1.540 + 1.541 + if (isset($info_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) { 1.542 + $strf_data = $info_riff['AVI ']['hdrl']['strl']['strf'][$i]['data']; 1.543 + 1.544 + // shortcut 1.545 + $info_riff_raw_strf_strh_fcc_type_stream_index = &$info_riff_raw['strf'][$strh_fcc_type][$stream_index]; 1.546 + 1.547 + switch ($strh_fcc_type) { 1.548 + case 'auds': 1.549 + $info_audio['bitrate_mode'] = 'cbr'; 1.550 + $info_audio_dataformat = 'wav'; 1.551 + if (isset($info_riff_audio) && is_array($info_riff_audio)) { 1.552 + $stream_index = count($info_riff_audio); 1.553 + } 1.554 + 1.555 + $info_riff_audio[$stream_index] = getid3_riff::RIFFparseWAVEFORMATex($strf_data); 1.556 + $info_audio['wformattag'] = $info_riff_audio[$stream_index]['raw']['wFormatTag']; 1.557 + 1.558 + // shortcut 1.559 + $info_audio['streams'][$stream_index] = $info_riff_audio[$stream_index]; 1.560 + $info_audio_streams_currentstream = &$info_audio['streams'][$stream_index]; 1.561 + 1.562 + if (@$info_audio_streams_currentstream['bits_per_sample'] === 0) { 1.563 + unset($info_audio_streams_currentstream['bits_per_sample']); 1.564 + } 1.565 + $info_audio_streams_currentstream['wformattag'] = $info_audio_streams_currentstream['raw']['wFormatTag']; 1.566 + unset($info_audio_streams_currentstream['raw']); 1.567 + 1.568 + // shortcut 1.569 + $info_riff_raw['strf'][$strh_fcc_type][$stream_index] = $info_riff_audio[$stream_index]['raw']; 1.570 + 1.571 + unset($info_riff_audio[$stream_index]['raw']); 1.572 + $info_audio = getid3_riff::array_merge_noclobber($info_audio, $info_riff_audio[$stream_index]); 1.573 + 1.574 + $info_audio['lossless'] = false; 1.575 + switch ($info_riff_raw_strf_strh_fcc_type_stream_index['wFormatTag']) { 1.576 + 1.577 + case 0x0001: // PCM 1.578 + $info_audio_dataformat = 'wav'; 1.579 + $info_audio['lossless'] = true; 1.580 + break; 1.581 + 1.582 + case 0x0050: // MPEG Layer 2 or Layer 1 1.583 + $info_audio_dataformat = 'mp2'; // Assume Layer-2 1.584 + break; 1.585 + 1.586 + case 0x0055: // MPEG Layer 3 1.587 + $info_audio_dataformat = 'mp3'; 1.588 + break; 1.589 + 1.590 + case 0x00FF: // AAC 1.591 + $info_audio_dataformat = 'aac'; 1.592 + break; 1.593 + 1.594 + case 0x0161: // Windows Media v7 / v8 / v9 1.595 + case 0x0162: // Windows Media Professional v9 1.596 + case 0x0163: // Windows Media Lossess v9 1.597 + $info_audio_dataformat = 'wma'; 1.598 + break; 1.599 + 1.600 + case 0x2000: // AC-3 1.601 + $info_audio_dataformat = 'ac3'; 1.602 + break; 1.603 + 1.604 + case 0x2001: // DTS 1.605 + $info_audio_dataformat = 'dts'; 1.606 + break; 1.607 + 1.608 + default: 1.609 + $info_audio_dataformat = 'wav'; 1.610 + break; 1.611 + } 1.612 + $info_audio_streams_currentstream['dataformat'] = $info_audio_dataformat; 1.613 + $info_audio_streams_currentstream['lossless'] = $info_audio['lossless']; 1.614 + $info_audio_streams_currentstream['bitrate_mode'] = $info_audio['bitrate_mode']; 1.615 + break; 1.616 + 1.617 + 1.618 + case 'iavs': 1.619 + case 'vids': 1.620 + // shortcut 1.621 + $info_riff_raw['strh'][$i] = array (); 1.622 + $info_riff_raw_strh_current = &$info_riff_raw['strh'][$i]; 1.623 + 1.624 + getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_strh_current, $strh_data, 0, 1.625 + array ( 1.626 + 'fccType' => -4, // same as $strh_fcc_type; 1.627 + 'fccHandler' => -4, 1.628 + 'dwFlags' => 4, // Contains AVITF_* flags 1.629 + 'wPriority' => 2, 1.630 + 'wLanguage' => 2, 1.631 + 'dwInitialFrames' => 4, 1.632 + 'dwScale' => 4, 1.633 + 'dwRate' => 4, 1.634 + 'dwStart' => 4, 1.635 + 'dwLength' => 4, 1.636 + 'dwSuggestedBufferSize' => 4, 1.637 + 'dwQuality' => 4, 1.638 + 'dwSampleSize' => 4, 1.639 + 'rcFrame' => 4 1.640 + ) 1.641 + ); 1.642 + 1.643 + $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strh_current['fccHandler']); 1.644 + $info_video['fourcc'] = $info_riff_raw_strh_current['fccHandler']; 1.645 + 1.646 + 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'])) { 1.647 + $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']); 1.648 + $info_video['fourcc'] = $info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']; 1.649 + } 1.650 + 1.651 + $info_video['codec'] = $info_riff_video_current['codec']; 1.652 + $info_video['pixel_aspect_ratio'] = (float)1; 1.653 + 1.654 + switch ($info_riff_raw_strh_current['fccHandler']) { 1.655 + 1.656 + case 'HFYU': // Huffman Lossless Codec 1.657 + case 'IRAW': // Intel YUV Uncompressed 1.658 + case 'YUY2': // Uncompressed YUV 4:2:2 1.659 + $info_video['lossless'] = true; 1.660 + break; 1.661 + 1.662 + default: 1.663 + $info_video['lossless'] = false; 1.664 + break; 1.665 + } 1.666 + 1.667 + switch ($strh_fcc_type) { 1.668 + 1.669 + case 'vids': 1.670 + getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_strf_strh_fcc_type_stream_index, $strf_data, 0, 1.671 + array ( 1.672 + 'biSize' => 4, // number of bytes required by the BITMAPINFOHEADER structure 1.673 + 'biWidth' => 4, // width of the bitmap in pixels 1.674 + '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 1.675 + 'biPlanes' => 2, // number of color planes on the target device. In most cases this value must be set to 1 1.676 + 'biBitCount' => 2, // Specifies the number of bits per pixels 1.677 + 'fourcc' => -4, // 1.678 + 'biSizeImage' => 4, // size of the bitmap data section of the image (the actual pixel data, excluding BITMAPINFOHEADER and RGBQUAD structures) 1.679 + 'biXPelsPerMeter' => 4, // horizontal resolution, in pixels per metre, of the target device 1.680 + 'biYPelsPerMeter' => 4, // vertical resolution, in pixels per metre, of the target device 1.681 + '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 1.682 + 'biClrImportant' => 4 // number of color indices that are considered important for displaying the bitmap. If this value is zero, all colors are important 1.683 + ) 1.684 + ); 1.685 + 1.686 + $info_video['bits_per_sample'] = $info_riff_raw_strf_strh_fcc_type_stream_index['biBitCount']; 1.687 + 1.688 + if ($info_riff_video_current['codec'] == 'DV') { 1.689 + $info_riff_video_current['dv_type'] = 2; 1.690 + } 1.691 + break; 1.692 + 1.693 + case 'iavs': 1.694 + $info_riff_video_current['dv_type'] = 1; 1.695 + break; 1.696 + } 1.697 + break; 1.698 + 1.699 + default: 1.700 + $getid3->warning('Unhandled fccType for stream ('.$i.'): "'.$strh_fcc_type.'"'); 1.701 + break; 1.702 + 1.703 + } 1.704 + } 1.705 + } 1.706 + 1.707 + 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'])) { 1.708 + 1.709 + $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']); 1.710 + $info_video['codec'] = $info_riff_video_current['codec']; 1.711 + $info_video['fourcc'] = $info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']; 1.712 + 1.713 + switch ($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']) { 1.714 + 1.715 + case 'HFYU': // Huffman Lossless Codec 1.716 + case 'IRAW': // Intel YUV Uncompressed 1.717 + case 'YUY2': // Uncompressed YUV 4:2:2 1.718 + $info_video['lossless'] = true; 1.719 + $info_video['bits_per_sample'] = 24; 1.720 + break; 1.721 + 1.722 + default: 1.723 + $info_video['lossless'] = false; 1.724 + $info_video['bits_per_sample'] = 24; 1.725 + break; 1.726 + } 1.727 + 1.728 + } 1.729 + } 1.730 + } 1.731 + } 1.732 + break; 1.733 + 1.734 + 1.735 + case 'CDDA': 1.736 + $info_audio['bitrate_mode'] = 'cbr'; 1.737 + $info_audio_dataformat = 'cda'; 1.738 + $info_audio['lossless'] = true; 1.739 + unset($getid3->info['mime_type']); 1.740 + 1.741 + $info_avdataoffset = 44; 1.742 + 1.743 + if (isset($info_riff['CDDA']['fmt '][0]['data'])) { 1.744 + 1.745 + $info_riff_cdda_fmt_0 = &$info_riff['CDDA']['fmt '][0]; 1.746 + 1.747 + getid3_lib::ReadSequence($this->endian_function, $info_riff_cdda_fmt_0, $info_riff_cdda_fmt_0['data'], 0, 1.748 + array ( 1.749 + 'unknown1' => 2, 1.750 + 'track_num' => 2, 1.751 + 'disc_id' => 4, 1.752 + 'start_offset_frame' => 4, 1.753 + 'playtime_frames' => 4, 1.754 + 'unknown6' => 4, 1.755 + 'unknown7' => 4 1.756 + ) 1.757 + ); 1.758 + 1.759 + $info_riff_cdda_fmt_0['start_offset_seconds'] = (float)$info_riff_cdda_fmt_0['start_offset_frame'] / 75; 1.760 + $info_riff_cdda_fmt_0['playtime_seconds'] = (float)$info_riff_cdda_fmt_0['playtime_frames'] / 75; 1.761 + $getid3->info['comments']['track'] = $info_riff_cdda_fmt_0['track_num']; 1.762 + $getid3->info['playtime_seconds'] = $info_riff_cdda_fmt_0['playtime_seconds']; 1.763 + 1.764 + // hardcoded data for CD-audio 1.765 + $info_audio['sample_rate'] = 44100; 1.766 + $info_audio['channels'] = 2; 1.767 + $info_audio['bits_per_sample'] = 16; 1.768 + $info_audio['bitrate'] = $info_audio['sample_rate'] * $info_audio['channels'] * $info_audio['bits_per_sample']; 1.769 + $info_audio['bitrate_mode'] = 'cbr'; 1.770 + } 1.771 + break; 1.772 + 1.773 + 1.774 + case 'AIFF': 1.775 + case 'AIFC': 1.776 + $info_audio['bitrate_mode'] = 'cbr'; 1.777 + $info_audio_dataformat = 'aiff'; 1.778 + $info_audio['lossless'] = true; 1.779 + $getid3->info['mime_type'] = 'audio/x-aiff'; 1.780 + 1.781 + if (isset($info_riff[$riff_sub_type]['SSND'][0]['offset'])) { 1.782 + $info_avdataoffset = $info_riff[$riff_sub_type]['SSND'][0]['offset'] + 8; 1.783 + $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['SSND'][0]['size']; 1.784 + if ($info_avdataend > $getid3->info['filesize']) { 1.785 + if (($info_avdataend == ($getid3->info['filesize'] + 1)) && (($getid3->info['filesize'] % 2) == 1)) { 1.786 + // structures rounded to 2-byte boundary, but dumb encoders 1.787 + // forget to pad end of file to make this actually work 1.788 + } else { 1.789 + $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'); 1.790 + } 1.791 + $info_avdataend = $getid3->info['filesize']; 1.792 + } 1.793 + } 1.794 + 1.795 + if (isset($info_riff[$riff_sub_type]['COMM'][0]['data'])) { 1.796 + 1.797 + // shortcut 1.798 + $info_riff_RIFFsubtype_COMM_0_data = &$info_riff[$riff_sub_type]['COMM'][0]['data']; 1.799 + 1.800 + $info_riff_audio['channels'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 0, 2)); 1.801 + $info_riff_audio['total_samples'] = getid3_lib::BigEndian2Int( substr($info_riff_RIFFsubtype_COMM_0_data, 2, 4)); 1.802 + $info_riff_audio['bits_per_sample'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 6, 2)); 1.803 + $info_riff_audio['sample_rate'] = (int)getid3_riff::BigEndian2Float(substr($info_riff_RIFFsubtype_COMM_0_data, 8, 10)); 1.804 + 1.805 + if ($info_riff[$riff_sub_type]['COMM'][0]['size'] > 18) { 1.806 + $info_riff_audio['codec_fourcc'] = substr($info_riff_RIFFsubtype_COMM_0_data, 18, 4); 1.807 + $codec_name_size = getid3_lib::BigEndian2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 22, 1)); 1.808 + $info_riff_audio['codec_name'] = substr($info_riff_RIFFsubtype_COMM_0_data, 23, $codec_name_size); 1.809 + 1.810 + switch ($info_riff_audio['codec_name']) { 1.811 + 1.812 + case 'NONE': 1.813 + $info_audio['codec'] = 'Pulse Code Modulation (PCM)'; 1.814 + $info_audio['lossless'] = true; 1.815 + break; 1.816 + 1.817 + case '': 1.818 + switch ($info_riff_audio['codec_fourcc']) { 1.819 + 1.820 + // http://developer.apple.com/qa/snd/snd07.html 1.821 + case 'sowt': 1.822 + $info_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM'; 1.823 + $info_audio['lossless'] = true; 1.824 + break; 1.825 + 1.826 + case 'twos': 1.827 + $info_riff_audio['codec_name'] = 'Two\'s Compliment Big-Endian PCM'; 1.828 + $info_audio['lossless'] = true; 1.829 + break; 1.830 + 1.831 + default: 1.832 + break; 1.833 + } 1.834 + break; 1.835 + 1.836 + default: 1.837 + $info_audio['codec'] = $info_riff_audio['codec_name']; 1.838 + $info_audio['lossless'] = false; 1.839 + break; 1.840 + } 1.841 + } 1.842 + 1.843 + $info_audio['channels'] = $info_riff_audio['channels']; 1.844 + 1.845 + if ($info_riff_audio['bits_per_sample'] > 0) { 1.846 + $info_audio['bits_per_sample'] = $info_riff_audio['bits_per_sample']; 1.847 + } 1.848 + 1.849 + $info_audio['sample_rate'] = $info_riff_audio['sample_rate']; 1.850 + $getid3->info['playtime_seconds'] = $info_riff_audio['total_samples'] / $info_audio['sample_rate']; 1.851 + } 1.852 + 1.853 + if (isset($info_riff[$riff_sub_type]['COMT'])) { 1.854 + 1.855 + $comment_count = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], 0, 2)); 1.856 + $offset = 2; 1.857 + 1.858 + for ($i = 0; $i < $comment_count; $i++) { 1.859 + 1.860 + $getid3->info['comments_raw'][$i]['timestamp'] = getid3_lib::BigEndian2Int( substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 4)); 1.861 + $offset += 4; 1.862 + 1.863 + $getid3->info['comments_raw'][$i]['marker_id'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 2)); 1.864 + $offset += 2; 1.865 + 1.866 + $comment_length = getid3_lib::BigEndian2Int( substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 2)); 1.867 + $offset += 2; 1.868 + 1.869 + $getid3->info['comments_raw'][$i]['comment'] = substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, $comment_length); 1.870 + $offset += $comment_length; 1.871 + 1.872 + $getid3->info['comments_raw'][$i]['timestamp_unix'] = getid3_riff::DateMac2Unix($getid3->info['comments_raw'][$i]['timestamp']); 1.873 + $info_riff['comments']['comment'][] = $getid3->info['comments_raw'][$i]['comment']; 1.874 + } 1.875 + } 1.876 + 1.877 + foreach (array ('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment') as $key => $value) { 1.878 + if (isset($info_riff[$riff_sub_type][$key][0]['data'])) { 1.879 + $info_riff['comments'][$value][] = $info_riff[$riff_sub_type][$key][0]['data']; 1.880 + } 1.881 + } 1.882 + break; 1.883 + 1.884 + 1.885 + case '8SVX': 1.886 + $info_audio['bitrate_mode'] = 'cbr'; 1.887 + $info_audio_dataformat = '8svx'; 1.888 + $info_audio['bits_per_sample'] = 8; 1.889 + $info_audio['channels'] = 1; // overridden below, if need be 1.890 + $getid3->info['mime_type'] = 'audio/x-aiff'; 1.891 + 1.892 + if (isset($info_riff[$riff_sub_type]['BODY'][0]['offset'])) { 1.893 + $info_avdataoffset = $info_riff[$riff_sub_type]['BODY'][0]['offset'] + 8; 1.894 + $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['BODY'][0]['size']; 1.895 + if ($info_avdataend > $getid3->info['filesize']) { 1.896 + $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'); 1.897 + } 1.898 + } 1.899 + 1.900 + if (isset($info_riff[$riff_sub_type]['VHDR'][0]['offset'])) { 1.901 + // shortcut 1.902 + $info_riff_riff_sub_type_vhdr_0 = &$info_riff[$riff_sub_type]['VHDR'][0]; 1.903 + 1.904 + getid3_lib::ReadSequence('BigEndian2Int', $info_riff_riff_sub_type_vhdr_0, $info_riff_riff_sub_type_vhdr_0['data'], 0, 1.905 + array ( 1.906 + 'oneShotHiSamples' => 4, 1.907 + 'repeatHiSamples' => 4, 1.908 + 'samplesPerHiCycle' => 4, 1.909 + 'samplesPerSec' => 2, 1.910 + 'ctOctave' => 1, 1.911 + 'sCompression' => 1, 1.912 + 'Volume' => -4 1.913 + ) 1.914 + ); 1.915 + 1.916 + $info_riff_riff_sub_type_vhdr_0['Volume'] = getid3_riff::FixedPoint16_16($info_riff_riff_sub_type_vhdr_0['Volume']); 1.917 + 1.918 + $info_audio['sample_rate'] = $info_riff_riff_sub_type_vhdr_0['samplesPerSec']; 1.919 + 1.920 + switch ($info_riff_riff_sub_type_vhdr_0['sCompression']) { 1.921 + case 0: 1.922 + $info_audio['codec'] = 'Pulse Code Modulation (PCM)'; 1.923 + $info_audio['lossless'] = true; 1.924 + $actual_bits_per_sample = 8; 1.925 + break; 1.926 + 1.927 + case 1: 1.928 + $info_audio['codec'] = 'Fibonacci-delta encoding'; 1.929 + $info_audio['lossless'] = false; 1.930 + $actual_bits_per_sample = 4; 1.931 + break; 1.932 + 1.933 + default: 1.934 + $getid3->warning('Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "'.sCompression.'"'); 1.935 + break; 1.936 + } 1.937 + } 1.938 + 1.939 + if (isset($info_riff[$riff_sub_type]['CHAN'][0]['data'])) { 1.940 + $ChannelsIndex = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['CHAN'][0]['data'], 0, 4)); 1.941 + switch ($ChannelsIndex) { 1.942 + case 6: // Stereo 1.943 + $info_audio['channels'] = 2; 1.944 + break; 1.945 + 1.946 + case 2: // Left channel only 1.947 + case 4: // Right channel only 1.948 + $info_audio['channels'] = 1; 1.949 + break; 1.950 + 1.951 + default: 1.952 + $getid3->warning('Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "'.$ChannelsIndex.'"'); 1.953 + break; 1.954 + } 1.955 + 1.956 + } 1.957 + 1.958 + foreach (array ('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment') as $key => $value) { 1.959 + if (isset($info_riff[$riff_sub_type][$key][0]['data'])) { 1.960 + $info_riff['comments'][$value][] = $info_riff[$riff_sub_type][$key][0]['data']; 1.961 + } 1.962 + } 1.963 + 1.964 + $info_audio['bitrate'] = $info_audio['sample_rate'] * $actual_bits_per_sample * $info_audio['channels']; 1.965 + if (!empty($info_audio['bitrate'])) { 1.966 + $getid3->info['playtime_seconds'] = ($info_avdataend - $info_avdataoffset) / ($info_audio['bitrate'] / 8); 1.967 + } 1.968 + break; 1.969 + 1.970 + 1.971 + case 'CDXA': 1.972 + 1.973 + $getid3->info['mime_type'] = 'video/mpeg'; 1.974 + if (!empty($info_riff['CDXA']['data'][0]['size'])) { 1.975 + $GETID3_ERRORARRAY = &$getid3->info['warning']; 1.976 + 1.977 + if (!$getid3->include_module_optional('audio-video.mpeg')) { 1.978 + $getid3->warning('MPEG skipped because mpeg module is missing.'); 1.979 + } 1.980 + 1.981 + else { 1.982 + 1.983 + // Clone getid3 - messing with offsets - better safe than sorry 1.984 + $clone = clone $getid3; 1.985 + 1.986 + // Analyse 1.987 + $mpeg = new getid3_mpeg($clone); 1.988 + $mpeg->Analyze(); 1.989 + 1.990 + // Import from clone and destroy 1.991 + $getid3->info['audio'] = $clone->info['audio']; 1.992 + $getid3->info['video'] = $clone->info['video']; 1.993 + $getid3->info['mpeg'] = $clone->info['mpeg']; 1.994 + $getid3->info['warning'] = $clone->info['warning']; 1.995 + 1.996 + unset($clone); 1.997 + } 1.998 + } 1.999 + 1.1000 + break; 1.1001 + 1.1002 + 1.1003 + default: 1.1004 + throw new getid3_exception('Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "'.$riff_sub_type.'" instead'); 1.1005 + } 1.1006 + 1.1007 + 1.1008 + if (@$info_riff_raw['fmt ']['wFormatTag'] == 1) { 1.1009 + 1.1010 + // http://www.mega-nerd.com/erikd/Blog/Windiots/dts.html 1.1011 + $this->fseek($getid3->info['avdataoffset'], SEEK_SET); 1.1012 + $bytes4 = $this->fread(4); 1.1013 + 1.1014 + // DTSWAV 1.1015 + if (preg_match('/^\xFF\x1F\x00\xE8/s', $bytes4)) { 1.1016 + $info_audio_dataformat = 'dts'; 1.1017 + } 1.1018 + 1.1019 + // DTS, but this probably shouldn't happen 1.1020 + elseif (preg_match('/^\x7F\xFF\x80\x01/s', $bytes4)) { 1.1021 + $info_audio_dataformat = 'dts'; 1.1022 + } 1.1023 + } 1.1024 + 1.1025 + if (@is_array($info_riff_wave['DISP'])) { 1.1026 + $info_riff['comments']['title'][] = trim(substr($info_riff_wave['DISP'][count($info_riff_wave['DISP']) - 1]['data'], 4)); 1.1027 + } 1.1028 + 1.1029 + if (@is_array($info_riff_wave['INFO'])) { 1.1030 + getid3_riff::RIFFCommentsParse($info_riff_wave['INFO'], $info_riff['comments']); 1.1031 + } 1.1032 + 1.1033 + if (isset($info_riff_wave['INFO']) && is_array($info_riff_wave['INFO'])) { 1.1034 + 1.1035 + 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) { 1.1036 + if (isset($info_riff_wave['INFO'][$key])) { 1.1037 + foreach ($info_riff_wave['INFO'][$key] as $comment_id => $comment_data) { 1.1038 + if (trim($comment_data['data']) != '') { 1.1039 + $info_riff['comments'][$value][] = trim($comment_data['data']); 1.1040 + } 1.1041 + } 1.1042 + } 1.1043 + } 1.1044 + } 1.1045 + 1.1046 + if (empty($info_audio['encoder']) && !empty($getid3->info['mpeg']['audio']['LAME']['short_version'])) { 1.1047 + $info_audio['encoder'] = $getid3->info['mpeg']['audio']['LAME']['short_version']; 1.1048 + } 1.1049 + 1.1050 + if (!isset($getid3->info['playtime_seconds'])) { 1.1051 + $getid3->info['playtime_seconds'] = 0; 1.1052 + } 1.1053 + 1.1054 + if (isset($info_riff_raw['avih']['dwTotalFrames']) && isset($info_riff_raw['avih']['dwMicroSecPerFrame'])) { 1.1055 + $getid3->info['playtime_seconds'] = $info_riff_raw['avih']['dwTotalFrames'] * ($info_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000); 1.1056 + } 1.1057 + 1.1058 + if ($getid3->info['playtime_seconds'] > 0) { 1.1059 + if (isset($info_riff_audio) && isset($info_riff_video)) { 1.1060 + 1.1061 + if (!isset($getid3->info['bitrate'])) { 1.1062 + $getid3->info['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8); 1.1063 + } 1.1064 + 1.1065 + } elseif (isset($info_riff_audio) && !isset($info_riff_video)) { 1.1066 + 1.1067 + if (!isset($info_audio['bitrate'])) { 1.1068 + $info_audio['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8); 1.1069 + } 1.1070 + 1.1071 + } elseif (!isset($info_riff_audio) && isset($info_riff_video)) { 1.1072 + 1.1073 + if (!isset($info_video['bitrate'])) { 1.1074 + $info_video['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8); 1.1075 + } 1.1076 + 1.1077 + } 1.1078 + } 1.1079 + 1.1080 + 1.1081 + if (isset($info_riff_video) && isset($info_audio['bitrate']) && ($info_audio['bitrate'] > 0) && ($getid3->info['playtime_seconds'] > 0)) { 1.1082 + 1.1083 + $getid3->info['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8); 1.1084 + $info_audio['bitrate'] = 0; 1.1085 + $info_video['bitrate'] = $getid3->info['bitrate']; 1.1086 + foreach ($info_riff_audio as $channelnumber => $audioinfoarray) { 1.1087 + $info_video['bitrate'] -= $audioinfoarray['bitrate']; 1.1088 + $info_audio['bitrate'] += $audioinfoarray['bitrate']; 1.1089 + } 1.1090 + if ($info_video['bitrate'] <= 0) { 1.1091 + unset($info_video['bitrate']); 1.1092 + } 1.1093 + if ($info_audio['bitrate'] <= 0) { 1.1094 + unset($info_audio['bitrate']); 1.1095 + } 1.1096 + } 1.1097 + 1.1098 + if (isset($getid3->info['mpeg']['audio'])) { 1.1099 + $info_audio_dataformat = 'mp'.$getid3->info['mpeg']['audio']['layer']; 1.1100 + $info_audio['sample_rate'] = $getid3->info['mpeg']['audio']['sample_rate']; 1.1101 + $info_audio['channels'] = $getid3->info['mpeg']['audio']['channels']; 1.1102 + $info_audio['bitrate'] = $getid3->info['mpeg']['audio']['bitrate']; 1.1103 + $info_audio['bitrate_mode'] = strtolower($getid3->info['mpeg']['audio']['bitrate_mode']); 1.1104 + 1.1105 + if (!empty($getid3->info['mpeg']['audio']['codec'])) { 1.1106 + $info_audio['codec'] = $getid3->info['mpeg']['audio']['codec'].' '.$info_audio['codec']; 1.1107 + } 1.1108 + 1.1109 + if (!empty($info_audio['streams'])) { 1.1110 + foreach ($info_audio['streams'] as $streamnumber => $streamdata) { 1.1111 + if ($streamdata['dataformat'] == $info_audio_dataformat) { 1.1112 + $info_audio['streams'][$streamnumber]['sample_rate'] = $info_audio['sample_rate']; 1.1113 + $info_audio['streams'][$streamnumber]['channels'] = $info_audio['channels']; 1.1114 + $info_audio['streams'][$streamnumber]['bitrate'] = $info_audio['bitrate']; 1.1115 + $info_audio['streams'][$streamnumber]['bitrate_mode'] = $info_audio['bitrate_mode']; 1.1116 + $info_audio['streams'][$streamnumber]['codec'] = $info_audio['codec']; 1.1117 + } 1.1118 + } 1.1119 + } 1.1120 + $info_audio['encoder_options'] = getid3_mp3::GuessEncoderOptions($getid3->info); 1.1121 + } 1.1122 + 1.1123 + 1.1124 + if (!empty($info_riff_raw['fmt ']['wBitsPerSample']) && ($info_riff_raw['fmt ']['wBitsPerSample'] > 0)) { 1.1125 + switch ($info_audio_dataformat) { 1.1126 + case 'ac3': 1.1127 + // ignore bits_per_sample 1.1128 + break; 1.1129 + 1.1130 + default: 1.1131 + $info_audio['bits_per_sample'] = $info_riff_raw['fmt ']['wBitsPerSample']; 1.1132 + break; 1.1133 + } 1.1134 + } 1.1135 + 1.1136 + 1.1137 + if (empty($info_riff_raw)) { 1.1138 + unset($info_riff['raw']); 1.1139 + } 1.1140 + if (empty($info_riff_audio)) { 1.1141 + unset($info_riff['audio']); 1.1142 + } 1.1143 + if (empty($info_riff_video)) { 1.1144 + unset($info_riff['video']); 1.1145 + } 1.1146 + if (empty($info_audio_dataformat)) { 1.1147 + unset($info_audio['dataformat']); 1.1148 + } 1.1149 + if (empty($getid3->info['audio'])) { 1.1150 + unset($getid3->info['audio']); 1.1151 + } 1.1152 + if (empty($info_video)) { 1.1153 + unset($getid3->info['video']); 1.1154 + } 1.1155 + 1.1156 + return true; 1.1157 + } 1.1158 + 1.1159 + 1.1160 + 1.1161 + public function ParseRIFF($start_offset, $max_offset) { 1.1162 + 1.1163 + $getid3 = $this->getid3; 1.1164 + 1.1165 + $info = &$getid3->info; 1.1166 + 1.1167 + $endian_function = $this->endian_function; 1.1168 + 1.1169 + $max_offset = min($max_offset, $info['avdataend']); 1.1170 + 1.1171 + $riff_chunk = false; 1.1172 + 1.1173 + $this->fseek($start_offset, SEEK_SET); 1.1174 + 1.1175 + while ($this->ftell() < $max_offset) { 1.1176 + 1.1177 + $chunk_name = $this->fread(4); 1.1178 + 1.1179 + if (strlen($chunk_name) < 4) { 1.1180 + throw new getid3_exception('Expecting chunk name at offset '.($this->ftell() - 4).' but found nothing. Aborting RIFF parsing.'); 1.1181 + } 1.1182 + 1.1183 + $chunk_size = getid3_lib::$endian_function($this->fread(4)); 1.1184 + 1.1185 + if ($chunk_size == 0) { 1.1186 + continue; 1.1187 + throw new getid3_exception('Chunk size at offset '.($this->ftell() - 4).' is zero. Aborting RIFF parsing.'); 1.1188 + } 1.1189 + 1.1190 + if (($chunk_size % 2) != 0) { 1.1191 + // all structures are packed on word boundaries 1.1192 + $chunk_size++; 1.1193 + } 1.1194 + 1.1195 + switch ($chunk_name) { 1.1196 + 1.1197 + case 'LIST': 1.1198 + $list_name = $this->fread(4); 1.1199 + 1.1200 + switch ($list_name) { 1.1201 + 1.1202 + case 'movi': 1.1203 + case 'rec ': 1.1204 + $riff_chunk[$list_name]['offset'] = $this->ftell() - 4; 1.1205 + $riff_chunk[$list_name]['size'] = $chunk_size; 1.1206 + 1.1207 + static $parsed_audio_stream = false; 1.1208 + 1.1209 + if (!$parsed_audio_stream) { 1.1210 + $where_we_were = $this->ftell(); 1.1211 + $audio_chunk_header = $this->fread(12); 1.1212 + $audio_chunk_stream_num = substr($audio_chunk_header, 0, 2); 1.1213 + $audio_chunk_stream_type = substr($audio_chunk_header, 2, 2); 1.1214 + $audio_chunk_size = getid3_lib::LittleEndian2Int(substr($audio_chunk_header, 4, 4)); 1.1215 + 1.1216 + if ($audio_chunk_stream_type == 'wb') { 1.1217 + $first_four_bytes = substr($audio_chunk_header, 8, 4); 1.1218 + 1.1219 + 1.1220 + //// MPEG 1.1221 + 1.1222 + if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', $first_four_bytes)) { 1.1223 + 1.1224 + if (!$getid3->include_module_optional('audio.mp3')) { 1.1225 + $getid3->warning('MP3 skipped because mp3 module is missing.'); 1.1226 + } 1.1227 + 1.1228 + elseif (getid3_mp3::MPEGaudioHeaderBytesValid($first_four_bytes)) { 1.1229 + 1.1230 + // Clone getid3 - messing with offsets - better safe than sorry 1.1231 + $clone = clone $getid3; 1.1232 + $clone->info['avdataoffset'] = $this->ftell() - 4; 1.1233 + $clone->info['avdataend'] = $this->ftell() + $audio_chunk_size; 1.1234 + 1.1235 + $mp3 = new getid3_mp3($clone); 1.1236 + $mp3->AnalyzeMPEGaudioInfo(); 1.1237 + 1.1238 + // Import from clone and destroy 1.1239 + if (isset($clone->info['mpeg']['audio'])) { 1.1240 + 1.1241 + $info['mpeg']['audio'] = $clone->info['mpeg']['audio']; 1.1242 + 1.1243 + $info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer']; 1.1244 + $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate']; 1.1245 + $info['audio']['channels'] = $info['mpeg']['audio']['channels']; 1.1246 + $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate']; 1.1247 + $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']); 1.1248 + $info['bitrate'] = $info['audio']['bitrate']; 1.1249 + 1.1250 + $getid3->warning($clone->warnings()); 1.1251 + unset($clone); 1.1252 + } 1.1253 + } 1.1254 + } 1.1255 + 1.1256 + //// AC3-WAVE 1.1257 + 1.1258 + elseif (preg_match('/^\x0B\x77/s', $first_four_bytes)) { 1.1259 + 1.1260 + if (!$getid3->include_module_optional('audio.ac3')) { 1.1261 + $getid3->warning('AC3 skipped because ac3 module is missing.'); 1.1262 + } 1.1263 + 1.1264 + else { 1.1265 + 1.1266 + // Clone getid3 - messing with offsets - better safe than sorry 1.1267 + $clone = clone $getid3; 1.1268 + $clone->info['avdataoffset'] = $this->ftell() - 4; 1.1269 + $clone->info['avdataend'] = $this->ftell() + $audio_chunk_size; 1.1270 + 1.1271 + // Analyze clone by fp 1.1272 + $ac3 = new getid3_ac3($clone); 1.1273 + $ac3->Analyze(); 1.1274 + 1.1275 + // Import from clone and destroy 1.1276 + $info['audio'] = $clone->info['audio']; 1.1277 + $info['ac3'] = $clone->info['ac3']; 1.1278 + $getid3->warning($clone->warnings()); 1.1279 + unset($clone); 1.1280 + } 1.1281 + } 1.1282 + } 1.1283 + 1.1284 + $parsed_audio_stream = true; 1.1285 + $this->fseek($where_we_were, SEEK_SET); 1.1286 + 1.1287 + } 1.1288 + $this->fseek($chunk_size - 4, SEEK_CUR); 1.1289 + break; 1.1290 + 1.1291 + default: 1.1292 + if (!isset($riff_chunk[$list_name])) { 1.1293 + $riff_chunk[$list_name] = array (); 1.1294 + } 1.1295 + $list_chunk_parent = $list_name; 1.1296 + $list_chunk_max_offset = $this->ftell() - 4 + $chunk_size; 1.1297 + if ($parsed_chunk = $this->ParseRIFF($this->ftell(), $this->ftell() + $chunk_size - 4)) { 1.1298 + $riff_chunk[$list_name] = array_merge_recursive($riff_chunk[$list_name], $parsed_chunk); 1.1299 + } 1.1300 + break; 1.1301 + } 1.1302 + break; 1.1303 + 1.1304 + 1.1305 + default: 1.1306 + 1.1307 + $this_index = 0; 1.1308 + if (isset($riff_chunk[$chunk_name]) && is_array($riff_chunk[$chunk_name])) { 1.1309 + $this_index = count($riff_chunk[$chunk_name]); 1.1310 + } 1.1311 + $riff_chunk[$chunk_name][$this_index]['offset'] = $this->ftell() - 8; 1.1312 + $riff_chunk[$chunk_name][$this_index]['size'] = $chunk_size; 1.1313 + switch ($chunk_name) { 1.1314 + case 'data': 1.1315 + $info['avdataoffset'] = $this->ftell(); 1.1316 + $info['avdataend'] = $info['avdataoffset'] + $chunk_size; 1.1317 + 1.1318 + $riff_data_chunk_contents_test = $this->fread(36); 1.1319 + 1.1320 + 1.1321 + //// This is probably MP3 data 1.1322 + 1.1323 + 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))) { 1.1324 + 1.1325 + try { 1.1326 + 1.1327 + if (!$getid3->include_module_optional('audio.mp3')) { 1.1328 + $getid3->warning('MP3 skipped because mp3 module is missing.'); 1.1329 + } 1.1330 + 1.1331 + 1.1332 + // Clone getid3 - messing with offsets - better safe than sorry 1.1333 + $clone = clone $getid3; 1.1334 + 1.1335 + if (getid3_mp3::MPEGaudioHeaderBytesValid(substr($riff_data_chunk_contents_test, 0, 4))) { 1.1336 + 1.1337 + $mp3 = new getid3_mp3($clone); 1.1338 + $mp3->AnalyzeMPEGaudioInfo(); 1.1339 + 1.1340 + // Import from clone and destroy 1.1341 + if (isset($clone->info['mpeg']['audio'])) { 1.1342 + 1.1343 + $info['mpeg']['audio'] = $clone->info['mpeg']['audio']; 1.1344 + 1.1345 + $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate']; 1.1346 + $info['audio']['channels'] = $info['mpeg']['audio']['channels']; 1.1347 + $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate']; 1.1348 + $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']); 1.1349 + $info['bitrate'] = $info['audio']['bitrate']; 1.1350 + 1.1351 + $getid3->warning($clone->warnings()); 1.1352 + unset($clone); 1.1353 + } 1.1354 + } 1.1355 + } 1.1356 + catch (Exception $e) { 1.1357 + // do nothing - not MP3 data 1.1358 + } 1.1359 + } 1.1360 + 1.1361 + 1.1362 + //// This is probably AC-3 data 1.1363 + 1.1364 + elseif ((strlen($riff_data_chunk_contents_test) > 0) && (substr($riff_data_chunk_contents_test, 0, 2) == "\x0B\x77")) { 1.1365 + 1.1366 + if (!$getid3->include_module_optional('audio.ac3')) { 1.1367 + $getid3->warning('AC3 skipped because ac3 module is missing.'); 1.1368 + } 1.1369 + 1.1370 + else { 1.1371 + 1.1372 + // Clone getid3 - messing with offsets - better safe than sorry 1.1373 + $clone = clone $getid3; 1.1374 + $clone->info['avdataoffset'] = $riff_chunk[$chunk_name][$this_index]['offset']; 1.1375 + $clone->info['avdataend'] = $clone->info['avdataoffset'] + $riff_chunk[$chunk_name][$this_index]['size']; 1.1376 + 1.1377 + // Analyze clone by fp 1.1378 + $ac3 = new getid3_ac3($clone); 1.1379 + $ac3->Analyze(); 1.1380 + 1.1381 + // Import from clone and destroy 1.1382 + $info['audio'] = $clone->info['audio']; 1.1383 + $info['ac3'] = $clone->info['ac3']; 1.1384 + $getid3->warning($clone->warnings()); 1.1385 + unset($clone); 1.1386 + } 1.1387 + } 1.1388 + 1.1389 + 1.1390 + // Dolby Digital WAV 1.1391 + // AC-3 content, but not encoded in same format as normal AC-3 file 1.1392 + // For one thing, byte order is swapped 1.1393 + 1.1394 + elseif ((strlen($riff_data_chunk_contents_test) > 0) && (substr($riff_data_chunk_contents_test, 8, 2) == "\x77\x0B")) { 1.1395 + 1.1396 + if (!$getid3->include_module_optional('audio.ac3')) { 1.1397 + $getid3->warning('AC3 skipped because ac3 module is missing.'); 1.1398 + } 1.1399 + 1.1400 + else { 1.1401 + 1.1402 + // Extract ac3 data to string 1.1403 + $ac3_data = ''; 1.1404 + for ($i = 0; $i < 28; $i += 2) { 1.1405 + // swap byte order 1.1406 + $ac3_data .= substr($riff_data_chunk_contents_test, 8 + $i + 1, 1); 1.1407 + $ac3_data .= substr($riff_data_chunk_contents_test, 8 + $i + 0, 1); 1.1408 + } 1.1409 + 1.1410 + // Clone getid3 - messing with offsets - better safe than sorry 1.1411 + $clone = clone $getid3; 1.1412 + $clone->info['avdataoffset'] = 0; 1.1413 + $clone->info['avdataend'] = 20; 1.1414 + 1.1415 + // Analyse clone by string 1.1416 + $ac3 = new getid3_ac3($clone); 1.1417 + $ac3->AnalyzeString($ac3_data); 1.1418 + 1.1419 + // Import from clone and destroy 1.1420 + $info['audio'] = $clone->info['audio']; 1.1421 + $info['ac3'] = $clone->info['ac3']; 1.1422 + $getid3->warning($clone->warnings()); 1.1423 + unset($clone); 1.1424 + } 1.1425 + } 1.1426 + 1.1427 + 1.1428 + if ((strlen($riff_data_chunk_contents_test) > 0) && (substr($riff_data_chunk_contents_test, 0, 4) == 'wvpk')) { 1.1429 + 1.1430 + // This is WavPack data 1.1431 + $info['wavpack']['offset'] = $riff_chunk[$chunk_name][$this_index]['offset']; 1.1432 + $info['wavpack']['size'] = getid3_lib::LittleEndian2Int(substr($riff_data_chunk_contents_test, 4, 4)); 1.1433 + $this->RIFFparseWavPackHeader(substr($riff_data_chunk_contents_test, 8, 28)); 1.1434 + 1.1435 + } else { 1.1436 + 1.1437 + // This is some other kind of data (quite possibly just PCM) 1.1438 + // do nothing special, just skip it 1.1439 + 1.1440 + } 1.1441 + $this->fseek($riff_chunk[$chunk_name][$this_index]['offset'] + 8 + $chunk_size, SEEK_SET); 1.1442 + break; 1.1443 + 1.1444 + case 'bext': 1.1445 + case 'cart': 1.1446 + case 'fmt ': 1.1447 + case 'MEXT': 1.1448 + case 'DISP': 1.1449 + // always read data in 1.1450 + $riff_chunk[$chunk_name][$this_index]['data'] = $this->fread($chunk_size); 1.1451 + break; 1.1452 + 1.1453 + default: 1.1454 + if (!empty($list_chunk_parent) && (($riff_chunk[$chunk_name][$this_index]['offset'] + $riff_chunk[$chunk_name][$this_index]['size']) <= $list_chunk_max_offset)) { 1.1455 + $riff_chunk[$list_chunk_parent][$chunk_name][$this_index]['offset'] = $riff_chunk[$chunk_name][$this_index]['offset']; 1.1456 + $riff_chunk[$list_chunk_parent][$chunk_name][$this_index]['size'] = $riff_chunk[$chunk_name][$this_index]['size']; 1.1457 + unset($riff_chunk[$chunk_name][$this_index]['offset']); 1.1458 + unset($riff_chunk[$chunk_name][$this_index]['size']); 1.1459 + if (isset($riff_chunk[$chunk_name][$this_index]) && empty($riff_chunk[$chunk_name][$this_index])) { 1.1460 + unset($riff_chunk[$chunk_name][$this_index]); 1.1461 + } 1.1462 + if (isset($riff_chunk[$chunk_name]) && empty($riff_chunk[$chunk_name])) { 1.1463 + unset($riff_chunk[$chunk_name]); 1.1464 + } 1.1465 + $riff_chunk[$list_chunk_parent][$chunk_name][$this_index]['data'] = $this->fread($chunk_size); 1.1466 + } elseif ($chunk_size < 2048) { 1.1467 + // only read data in if smaller than 2kB 1.1468 + $riff_chunk[$chunk_name][$this_index]['data'] = $this->fread($chunk_size); 1.1469 + } else { 1.1470 + $this->fseek($chunk_size, SEEK_CUR); 1.1471 + } 1.1472 + break; 1.1473 + } 1.1474 + break; 1.1475 + 1.1476 + } 1.1477 + 1.1478 + } 1.1479 + 1.1480 + return $riff_chunk; 1.1481 + } 1.1482 + 1.1483 + 1.1484 + 1.1485 + private function RIFFparseWavPackHeader($wavpack3_chunk_data) { 1.1486 + 1.1487 + // typedef struct { 1.1488 + // char ckID [4]; 1.1489 + // long ckSize; 1.1490 + // short version; 1.1491 + // short bits; // added for version 2.00 1.1492 + // short flags, shift; // added for version 3.00 1.1493 + // long total_samples, crc, crc2; 1.1494 + // char extension [4], extra_bc, extras [3]; 1.1495 + // } WavpackHeader; 1.1496 + 1.1497 + $this->getid3->info['wavpack'] = array (); 1.1498 + $info_wavpack = &$this->getid3->info['wavpack']; 1.1499 + 1.1500 + $info_wavpack['version'] = getid3_lib::LittleEndian2Int(substr($wavpack3_chunk_data, 0, 2)); 1.1501 + 1.1502 + if ($info_wavpack['version'] >= 2) { 1.1503 + $info_wavpack['bits'] = getid3_lib::LittleEndian2Int(substr($wavpack3_chunk_data, 2, 2)); 1.1504 + } 1.1505 + 1.1506 + if ($info_wavpack['version'] >= 3) { 1.1507 + 1.1508 + getid3_lib::ReadSequence('LittleEndian2Int', $info_wavpack, $wavpack3_chunk_data, 4, 1.1509 + array ( 1.1510 + 'flags_raw' => 2, 1.1511 + 'shift' => 2, 1.1512 + 'total_samples' => 4, 1.1513 + 'crc1' => 4, 1.1514 + 'crc2' => 4, 1.1515 + 'extension' => -4, 1.1516 + 'extra_bc' => 1 1.1517 + ) 1.1518 + ); 1.1519 + 1.1520 + for ($i = 0; $i < 3; $i++) { 1.1521 + $info_wavpack['extras'][] = getid3_lib::LittleEndian2Int($wavpack3_chunk_data{25 + $i}); 1.1522 + } 1.1523 + 1.1524 + $info_wavpack['flags'] = array (); 1.1525 + $info_wavpack_flags = &$info_wavpack['flags']; 1.1526 + 1.1527 + $info_wavpack_flags['mono'] = (bool)($info_wavpack['flags_raw'] & 0x000001); 1.1528 + $info_wavpack_flags['fast_mode'] = (bool)($info_wavpack['flags_raw'] & 0x000002); 1.1529 + $info_wavpack_flags['raw_mode'] = (bool)($info_wavpack['flags_raw'] & 0x000004); 1.1530 + $info_wavpack_flags['calc_noise'] = (bool)($info_wavpack['flags_raw'] & 0x000008); 1.1531 + $info_wavpack_flags['high_quality'] = (bool)($info_wavpack['flags_raw'] & 0x000010); 1.1532 + $info_wavpack_flags['3_byte_samples'] = (bool)($info_wavpack['flags_raw'] & 0x000020); 1.1533 + $info_wavpack_flags['over_20_bits'] = (bool)($info_wavpack['flags_raw'] & 0x000040); 1.1534 + $info_wavpack_flags['use_wvc'] = (bool)($info_wavpack['flags_raw'] & 0x000080); 1.1535 + $info_wavpack_flags['noiseshaping'] = (bool)($info_wavpack['flags_raw'] & 0x000100); 1.1536 + $info_wavpack_flags['very_fast_mode'] = (bool)($info_wavpack['flags_raw'] & 0x000200); 1.1537 + $info_wavpack_flags['new_high_quality'] = (bool)($info_wavpack['flags_raw'] & 0x000400); 1.1538 + $info_wavpack_flags['cancel_extreme'] = (bool)($info_wavpack['flags_raw'] & 0x000800); 1.1539 + $info_wavpack_flags['cross_decorrelation'] = (bool)($info_wavpack['flags_raw'] & 0x001000); 1.1540 + $info_wavpack_flags['new_decorrelation'] = (bool)($info_wavpack['flags_raw'] & 0x002000); 1.1541 + $info_wavpack_flags['joint_stereo'] = (bool)($info_wavpack['flags_raw'] & 0x004000); 1.1542 + $info_wavpack_flags['extra_decorrelation'] = (bool)($info_wavpack['flags_raw'] & 0x008000); 1.1543 + $info_wavpack_flags['override_noiseshape'] = (bool)($info_wavpack['flags_raw'] & 0x010000); 1.1544 + $info_wavpack_flags['override_jointstereo'] = (bool)($info_wavpack['flags_raw'] & 0x020000); 1.1545 + $info_wavpack_flags['copy_source_filetime'] = (bool)($info_wavpack['flags_raw'] & 0x040000); 1.1546 + $info_wavpack_flags['create_exe'] = (bool)($info_wavpack['flags_raw'] & 0x080000); 1.1547 + } 1.1548 + 1.1549 + return true; 1.1550 + } 1.1551 + 1.1552 + 1.1553 + 1.1554 + public function AnalyzeString(&$string) { 1.1555 + 1.1556 + // Rewrite header_size in header 1.1557 + $new_header_size = getid3_lib::LittleEndian2String(strlen($string), 4); 1.1558 + for ($i = 0; $i < 4; $i++) { 1.1559 + $string{$i + 4} = $new_header_size{$i}; 1.1560 + } 1.1561 + 1.1562 + return parent::AnalyzeString($string); 1.1563 + } 1.1564 + 1.1565 + 1.1566 + 1.1567 + public static function RIFFparseWAVEFORMATex($wave_format_ex_data) { 1.1568 + 1.1569 + $wave_format_ex['raw'] = array (); 1.1570 + $wave_format_ex_raw = &$wave_format_ex['raw']; 1.1571 + 1.1572 + getid3_lib::ReadSequence('LittleEndian2Int', $wave_format_ex_raw, $wave_format_ex_data, 0, 1.1573 + array ( 1.1574 + 'wFormatTag' => 2, 1.1575 + 'nChannels' => 2, 1.1576 + 'nSamplesPerSec' => 4, 1.1577 + 'nAvgBytesPerSec' => 4, 1.1578 + 'nBlockAlign' => 2, 1.1579 + 'wBitsPerSample' => 2 1.1580 + ) 1.1581 + ); 1.1582 + 1.1583 + if (strlen($wave_format_ex_data) > 16) { 1.1584 + $wave_format_ex_raw['cbSize'] = getid3_lib::LittleEndian2Int(substr($wave_format_ex_data, 16, 2)); 1.1585 + } 1.1586 + 1.1587 + $wave_format_ex['codec'] = getid3_riff::RIFFwFormatTagLookup($wave_format_ex_raw['wFormatTag']); 1.1588 + $wave_format_ex['channels'] = $wave_format_ex_raw['nChannels']; 1.1589 + $wave_format_ex['sample_rate'] = $wave_format_ex_raw['nSamplesPerSec']; 1.1590 + $wave_format_ex['bitrate'] = $wave_format_ex_raw['nAvgBytesPerSec'] * 8; 1.1591 + if (@$wave_format_ex_raw['wBitsPerSample']) { 1.1592 + $wave_format_ex['bits_per_sample'] = $wave_format_ex_raw['wBitsPerSample']; 1.1593 + } 1.1594 + 1.1595 + return $wave_format_ex; 1.1596 + } 1.1597 + 1.1598 + 1.1599 + 1.1600 + public static function RIFFwFormatTagLookup($w_format_tag) { 1.1601 + 1.1602 + static $lookup = array ( 1.1603 + 0x0000 => 'Microsoft Unknown Wave Format', 1.1604 + 0x0001 => 'Pulse Code Modulation (PCM)', 1.1605 + 0x0002 => 'Microsoft ADPCM', 1.1606 + 0x0003 => 'IEEE Float', 1.1607 + 0x0004 => 'Compaq Computer VSELP', 1.1608 + 0x0005 => 'IBM CVSD', 1.1609 + 0x0006 => 'Microsoft A-Law', 1.1610 + 0x0007 => 'Microsoft mu-Law', 1.1611 + 0x0008 => 'Microsoft DTS', 1.1612 + 0x0010 => 'OKI ADPCM', 1.1613 + 0x0011 => 'Intel DVI/IMA ADPCM', 1.1614 + 0x0012 => 'Videologic MediaSpace ADPCM', 1.1615 + 0x0013 => 'Sierra Semiconductor ADPCM', 1.1616 + 0x0014 => 'Antex Electronics G.723 ADPCM', 1.1617 + 0x0015 => 'DSP Solutions DigiSTD', 1.1618 + 0x0016 => 'DSP Solutions DigiFIX', 1.1619 + 0x0017 => 'Dialogic OKI ADPCM', 1.1620 + 0x0018 => 'MediaVision ADPCM', 1.1621 + 0x0019 => 'Hewlett-Packard CU', 1.1622 + 0x0020 => 'Yamaha ADPCM', 1.1623 + 0x0021 => 'Speech Compression Sonarc', 1.1624 + 0x0022 => 'DSP Group TrueSpeech', 1.1625 + 0x0023 => 'Echo Speech EchoSC1', 1.1626 + 0x0024 => 'Audiofile AF36', 1.1627 + 0x0025 => 'Audio Processing Technology APTX', 1.1628 + 0x0026 => 'AudioFile AF10', 1.1629 + 0x0027 => 'Prosody 1612', 1.1630 + 0x0028 => 'LRC', 1.1631 + 0x0030 => 'Dolby AC2', 1.1632 + 0x0031 => 'Microsoft GSM 6.10', 1.1633 + 0x0032 => 'MSNAudio', 1.1634 + 0x0033 => 'Antex Electronics ADPCME', 1.1635 + 0x0034 => 'Control Resources VQLPC', 1.1636 + 0x0035 => 'DSP Solutions DigiREAL', 1.1637 + 0x0036 => 'DSP Solutions DigiADPCM', 1.1638 + 0x0037 => 'Control Resources CR10', 1.1639 + 0x0038 => 'Natural MicroSystems VBXADPCM', 1.1640 + 0x0039 => 'Crystal Semiconductor IMA ADPCM', 1.1641 + 0x003A => 'EchoSC3', 1.1642 + 0x003B => 'Rockwell ADPCM', 1.1643 + 0x003C => 'Rockwell Digit LK', 1.1644 + 0x003D => 'Xebec', 1.1645 + 0x0040 => 'Antex Electronics G.721 ADPCM', 1.1646 + 0x0041 => 'G.728 CELP', 1.1647 + 0x0042 => 'MSG723', 1.1648 + 0x0050 => 'MPEG Layer-2 or Layer-1', 1.1649 + 0x0052 => 'RT24', 1.1650 + 0x0053 => 'PAC', 1.1651 + 0x0055 => 'MPEG Layer-3', 1.1652 + 0x0059 => 'Lucent G.723', 1.1653 + 0x0060 => 'Cirrus', 1.1654 + 0x0061 => 'ESPCM', 1.1655 + 0x0062 => 'Voxware', 1.1656 + 0x0063 => 'Canopus Atrac', 1.1657 + 0x0064 => 'G.726 ADPCM', 1.1658 + 0x0065 => 'G.722 ADPCM', 1.1659 + 0x0066 => 'DSAT', 1.1660 + 0x0067 => 'DSAT Display', 1.1661 + 0x0069 => 'Voxware Byte Aligned', 1.1662 + 0x0070 => 'Voxware AC8', 1.1663 + 0x0071 => 'Voxware AC10', 1.1664 + 0x0072 => 'Voxware AC16', 1.1665 + 0x0073 => 'Voxware AC20', 1.1666 + 0x0074 => 'Voxware MetaVoice', 1.1667 + 0x0075 => 'Voxware MetaSound', 1.1668 + 0x0076 => 'Voxware RT29HW', 1.1669 + 0x0077 => 'Voxware VR12', 1.1670 + 0x0078 => 'Voxware VR18', 1.1671 + 0x0079 => 'Voxware TQ40', 1.1672 + 0x0080 => 'Softsound', 1.1673 + 0x0081 => 'Voxware TQ60', 1.1674 + 0x0082 => 'MSRT24', 1.1675 + 0x0083 => 'G.729A', 1.1676 + 0x0084 => 'MVI MV12', 1.1677 + 0x0085 => 'DF G.726', 1.1678 + 0x0086 => 'DF GSM610', 1.1679 + 0x0088 => 'ISIAudio', 1.1680 + 0x0089 => 'Onlive', 1.1681 + 0x0091 => 'SBC24', 1.1682 + 0x0092 => 'Dolby AC3 SPDIF', 1.1683 + 0x0093 => 'MediaSonic G.723', 1.1684 + 0x0094 => 'Aculab PLC Prosody 8kbps', 1.1685 + 0x0097 => 'ZyXEL ADPCM', 1.1686 + 0x0098 => 'Philips LPCBB', 1.1687 + 0x0099 => 'Packed', 1.1688 + 0x00FF => 'AAC', 1.1689 + 0x0100 => 'Rhetorex ADPCM', 1.1690 + 0x0101 => 'IBM mu-law', 1.1691 + 0x0102 => 'IBM A-law', 1.1692 + 0x0103 => 'IBM AVC Adaptive Differential Pulse Code Modulation (ADPCM)', 1.1693 + 0x0111 => 'Vivo G.723', 1.1694 + 0x0112 => 'Vivo Siren', 1.1695 + 0x0123 => 'Digital G.723', 1.1696 + 0x0125 => 'Sanyo LD ADPCM', 1.1697 + 0x0130 => 'Sipro Lab Telecom ACELP NET', 1.1698 + 0x0131 => 'Sipro Lab Telecom ACELP 4800', 1.1699 + 0x0132 => 'Sipro Lab Telecom ACELP 8V3', 1.1700 + 0x0133 => 'Sipro Lab Telecom G.729', 1.1701 + 0x0134 => 'Sipro Lab Telecom G.729A', 1.1702 + 0x0135 => 'Sipro Lab Telecom Kelvin', 1.1703 + 0x0140 => 'Windows Media Video V8', 1.1704 + 0x0150 => 'Qualcomm PureVoice', 1.1705 + 0x0151 => 'Qualcomm HalfRate', 1.1706 + 0x0155 => 'Ring Zero Systems TUB GSM', 1.1707 + 0x0160 => 'Microsoft Audio 1', 1.1708 + 0x0161 => 'Windows Media Audio V7 / V8 / V9', 1.1709 + 0x0162 => 'Windows Media Audio Professional V9', 1.1710 + 0x0163 => 'Windows Media Audio Lossless V9', 1.1711 + 0x0200 => 'Creative Labs ADPCM', 1.1712 + 0x0202 => 'Creative Labs Fastspeech8', 1.1713 + 0x0203 => 'Creative Labs Fastspeech10', 1.1714 + 0x0210 => 'UHER Informatic GmbH ADPCM', 1.1715 + 0x0220 => 'Quarterdeck', 1.1716 + 0x0230 => 'I-link Worldwide VC', 1.1717 + 0x0240 => 'Aureal RAW Sport', 1.1718 + 0x0250 => 'Interactive Products HSX', 1.1719 + 0x0251 => 'Interactive Products RPELP', 1.1720 + 0x0260 => 'Consistent Software CS2', 1.1721 + 0x0270 => 'Sony SCX', 1.1722 + 0x0300 => 'Fujitsu FM Towns Snd', 1.1723 + 0x0400 => 'BTV Digital', 1.1724 + 0x0401 => 'Intel Music Coder', 1.1725 + 0x0450 => 'QDesign Music', 1.1726 + 0x0680 => 'VME VMPCM', 1.1727 + 0x0681 => 'AT&T Labs TPC', 1.1728 + 0x08AE => 'ClearJump LiteWave', 1.1729 + 0x1000 => 'Olivetti GSM', 1.1730 + 0x1001 => 'Olivetti ADPCM', 1.1731 + 0x1002 => 'Olivetti CELP', 1.1732 + 0x1003 => 'Olivetti SBC', 1.1733 + 0x1004 => 'Olivetti OPR', 1.1734 + 0x1100 => 'Lernout & Hauspie Codec (0x1100)', 1.1735 + 0x1101 => 'Lernout & Hauspie CELP Codec (0x1101)', 1.1736 + 0x1102 => 'Lernout & Hauspie SBC Codec (0x1102)', 1.1737 + 0x1103 => 'Lernout & Hauspie SBC Codec (0x1103)', 1.1738 + 0x1104 => 'Lernout & Hauspie SBC Codec (0x1104)', 1.1739 + 0x1400 => 'Norris', 1.1740 + 0x1401 => 'AT&T ISIAudio', 1.1741 + 0x1500 => 'Soundspace Music Compression', 1.1742 + 0x181C => 'VoxWare RT24 Speech', 1.1743 + 0x1FC4 => 'NCT Soft ALF2CD (www.nctsoft.com)', 1.1744 + 0x2000 => 'Dolby AC3', 1.1745 + 0x2001 => 'Dolby DTS', 1.1746 + 0x2002 => 'WAVE_FORMAT_14_4', 1.1747 + 0x2003 => 'WAVE_FORMAT_28_8', 1.1748 + 0x2004 => 'WAVE_FORMAT_COOK', 1.1749 + 0x2005 => 'WAVE_FORMAT_DNET', 1.1750 + 0x674F => 'Ogg Vorbis 1', 1.1751 + 0x6750 => 'Ogg Vorbis 2', 1.1752 + 0x6751 => 'Ogg Vorbis 3', 1.1753 + 0x676F => 'Ogg Vorbis 1+', 1.1754 + 0x6770 => 'Ogg Vorbis 2+', 1.1755 + 0x6771 => 'Ogg Vorbis 3+', 1.1756 + 0x7A21 => 'GSM-AMR (CBR, no SID)', 1.1757 + 0x7A22 => 'GSM-AMR (VBR, including SID)', 1.1758 + 0xFFFE => 'WAVE_FORMAT_EXTENSIBLE', 1.1759 + 0xFFFF => 'WAVE_FORMAT_DEVELOPMENT' 1.1760 + ); 1.1761 + 1.1762 + return @$lookup[$w_format_tag]; 1.1763 + } 1.1764 + 1.1765 + 1.1766 + 1.1767 + public static function RIFFfourccLookup($four_cc) { 1.1768 + 1.1769 + static $lookup = array ( 1.1770 + 'swot' => 'http://developer.apple.com/qa/snd/snd07.html', 1.1771 + '____' => 'No Codec (____)', 1.1772 + '_BIT' => 'BI_BITFIELDS (Raw RGB)', 1.1773 + '_JPG' => 'JPEG compressed', 1.1774 + '_PNG' => 'PNG compressed W3C/ISO/IEC (RFC-2083)', 1.1775 + '_RAW' => 'Full Frames (Uncompressed)', 1.1776 + '_RGB' => 'Raw RGB Bitmap', 1.1777 + '_RL4' => 'RLE 4bpp RGB', 1.1778 + '_RL8' => 'RLE 8bpp RGB', 1.1779 + '3IV1' => '3ivx MPEG-4 v1', 1.1780 + '3IV2' => '3ivx MPEG-4 v2', 1.1781 + '3IVX' => '3ivx MPEG-4', 1.1782 + 'AASC' => 'Autodesk Animator', 1.1783 + 'ABYR' => 'Kensington ?ABYR?', 1.1784 + 'AEMI' => 'Array Microsystems VideoONE MPEG1-I Capture', 1.1785 + 'AFLC' => 'Autodesk Animator FLC', 1.1786 + 'AFLI' => 'Autodesk Animator FLI', 1.1787 + 'AMPG' => 'Array Microsystems VideoONE MPEG', 1.1788 + 'ANIM' => 'Intel RDX (ANIM)', 1.1789 + 'AP41' => 'AngelPotion Definitive', 1.1790 + 'ASV1' => 'Asus Video v1', 1.1791 + 'ASV2' => 'Asus Video v2', 1.1792 + 'ASVX' => 'Asus Video 2.0 (audio)', 1.1793 + 'AUR2' => 'AuraVision Aura 2 Codec - YUV 4:2:2', 1.1794 + 'AURA' => 'AuraVision Aura 1 Codec - YUV 4:1:1', 1.1795 + 'AVDJ' => 'Independent JPEG Group\'s codec (AVDJ)', 1.1796 + 'AVRN' => 'Independent JPEG Group\'s codec (AVRN)', 1.1797 + 'AYUV' => '4:4:4 YUV (AYUV)', 1.1798 + 'AZPR' => 'Quicktime Apple Video (AZPR)', 1.1799 + 'BGR ' => 'Raw RGB32', 1.1800 + 'BLZ0' => 'FFmpeg MPEG-4', 1.1801 + 'BTVC' => 'Conexant Composite Video', 1.1802 + 'BINK' => 'RAD Game Tools Bink Video', 1.1803 + 'BT20' => 'Conexant Prosumer Video', 1.1804 + 'BTCV' => 'Conexant Composite Video Codec', 1.1805 + 'BW10' => 'Data Translation Broadway MPEG Capture', 1.1806 + 'CC12' => 'Intel YUV12', 1.1807 + 'CDVC' => 'Canopus DV', 1.1808 + 'CFCC' => 'Digital Processing Systems DPS Perception', 1.1809 + 'CGDI' => 'Microsoft Office 97 Camcorder Video', 1.1810 + 'CHAM' => 'Winnov Caviara Champagne', 1.1811 + 'CJPG' => 'Creative WebCam JPEG', 1.1812 + 'CLJR' => 'Cirrus Logic YUV 4:1:1', 1.1813 + 'CMYK' => 'Common Data Format in Printing (Colorgraph)', 1.1814 + 'CPLA' => 'Weitek 4:2:0 YUV Planar', 1.1815 + 'CRAM' => 'Microsoft Video 1 (CRAM)', 1.1816 + 'cvid' => 'Radius Cinepak', 1.1817 + 'CVID' => 'Radius Cinepak', 1.1818 + 'CWLT' => 'Microsoft Color WLT DIB', 1.1819 + 'CYUV' => 'Creative Labs YUV', 1.1820 + 'CYUY' => 'ATI YUV', 1.1821 + 'D261' => 'H.261', 1.1822 + 'D263' => 'H.263', 1.1823 + 'DIB ' => 'Device Independent Bitmap', 1.1824 + 'DIV1' => 'FFmpeg OpenDivX', 1.1825 + 'DIV2' => 'Microsoft MPEG-4 v1/v2', 1.1826 + 'DIV3' => 'DivX ;-) MPEG-4 v3.x Low-Motion', 1.1827 + 'DIV4' => 'DivX ;-) MPEG-4 v3.x Fast-Motion', 1.1828 + 'DIV5' => 'DivX MPEG-4 v5.x', 1.1829 + 'DIV6' => 'DivX ;-) (MS MPEG-4 v3.x)', 1.1830 + 'DIVX' => 'DivX MPEG-4 v4 (OpenDivX / Project Mayo)', 1.1831 + 'divx' => 'DivX MPEG-4', 1.1832 + 'DMB1' => 'Matrox Rainbow Runner hardware MJPEG', 1.1833 + 'DMB2' => 'Paradigm MJPEG', 1.1834 + 'DSVD' => '?DSVD?', 1.1835 + 'DUCK' => 'Duck TrueMotion 1.0', 1.1836 + 'DPS0' => 'DPS/Leitch Reality Motion JPEG', 1.1837 + 'DPSC' => 'DPS/Leitch PAR Motion JPEG', 1.1838 + 'DV25' => 'Matrox DVCPRO codec', 1.1839 + 'DV50' => 'Matrox DVCPRO50 codec', 1.1840 + 'DVC ' => 'IEC 61834 and SMPTE 314M (DVC/DV Video)', 1.1841 + 'DVCP' => 'IEC 61834 and SMPTE 314M (DVC/DV Video)', 1.1842 + 'DVHD' => 'IEC Standard DV 1125 lines @ 30fps / 1250 lines @ 25fps', 1.1843 + 'DVMA' => 'Darim Vision DVMPEG (dummy for MPEG compressor) (www.darvision.com)', 1.1844 + 'DVSL' => 'IEC Standard DV compressed in SD (SDL)', 1.1845 + 'DVAN' => '?DVAN?', 1.1846 + 'DVE2' => 'InSoft DVE-2 Videoconferencing', 1.1847 + 'dvsd' => 'IEC 61834 and SMPTE 314M DVC/DV Video', 1.1848 + 'DVSD' => 'IEC 61834 and SMPTE 314M DVC/DV Video', 1.1849 + 'DVX1' => 'Lucent DVX1000SP Video Decoder', 1.1850 + 'DVX2' => 'Lucent DVX2000S Video Decoder', 1.1851 + 'DVX3' => 'Lucent DVX3000S Video Decoder', 1.1852 + 'DX50' => 'DivX v5', 1.1853 + 'DXT1' => 'Microsoft DirectX Compressed Texture (DXT1)', 1.1854 + 'DXT2' => 'Microsoft DirectX Compressed Texture (DXT2)', 1.1855 + 'DXT3' => 'Microsoft DirectX Compressed Texture (DXT3)', 1.1856 + 'DXT4' => 'Microsoft DirectX Compressed Texture (DXT4)', 1.1857 + 'DXT5' => 'Microsoft DirectX Compressed Texture (DXT5)', 1.1858 + 'DXTC' => 'Microsoft DirectX Compressed Texture (DXTC)', 1.1859 + 'DXTn' => 'Microsoft DirectX Compressed Texture (DXTn)', 1.1860 + 'EM2V' => 'Etymonix MPEG-2 I-frame (www.etymonix.com)', 1.1861 + 'EKQ0' => 'Elsa ?EKQ0?', 1.1862 + 'ELK0' => 'Elsa ?ELK0?', 1.1863 + 'ESCP' => 'Eidos Escape', 1.1864 + 'ETV1' => 'eTreppid Video ETV1', 1.1865 + 'ETV2' => 'eTreppid Video ETV2', 1.1866 + 'ETVC' => 'eTreppid Video ETVC', 1.1867 + 'FLIC' => 'Autodesk FLI/FLC Animation', 1.1868 + 'FRWT' => 'Darim Vision Forward Motion JPEG (www.darvision.com)', 1.1869 + 'FRWU' => 'Darim Vision Forward Uncompressed (www.darvision.com)', 1.1870 + 'FLJP' => 'D-Vision Field Encoded Motion JPEG', 1.1871 + 'FRWA' => 'SoftLab-Nsk Forward Motion JPEG w/ alpha channel', 1.1872 + 'FRWD' => 'SoftLab-Nsk Forward Motion JPEG', 1.1873 + 'FVF1' => 'Iterated Systems Fractal Video Frame', 1.1874 + 'GLZW' => 'Motion LZW (gabest@freemail.hu)', 1.1875 + 'GPEG' => 'Motion JPEG (gabest@freemail.hu)', 1.1876 + 'GWLT' => 'Microsoft Greyscale WLT DIB', 1.1877 + 'H260' => 'Intel ITU H.260 Videoconferencing', 1.1878 + 'H261' => 'Intel ITU H.261 Videoconferencing', 1.1879 + 'H262' => 'Intel ITU H.262 Videoconferencing', 1.1880 + 'H263' => 'Intel ITU H.263 Videoconferencing', 1.1881 + 'H264' => 'Intel ITU H.264 Videoconferencing', 1.1882 + 'H265' => 'Intel ITU H.265 Videoconferencing', 1.1883 + 'H266' => 'Intel ITU H.266 Videoconferencing', 1.1884 + 'H267' => 'Intel ITU H.267 Videoconferencing', 1.1885 + 'H268' => 'Intel ITU H.268 Videoconferencing', 1.1886 + 'H269' => 'Intel ITU H.269 Videoconferencing', 1.1887 + 'HFYU' => 'Huffman Lossless Codec', 1.1888 + 'HMCR' => 'Rendition Motion Compensation Format (HMCR)', 1.1889 + 'HMRR' => 'Rendition Motion Compensation Format (HMRR)', 1.1890 + 'I263' => 'FFmpeg I263 decoder', 1.1891 + 'IF09' => 'Indeo YVU9 ("YVU9 with additional delta-frame info after the U plane")', 1.1892 + 'IUYV' => 'Interlaced version of UYVY (www.leadtools.com)', 1.1893 + 'IY41' => 'Interlaced version of Y41P (www.leadtools.com)', 1.1894 + 'IYU1' => '12 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec IEEE standard', 1.1895 + 'IYU2' => '24 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec IEEE standard', 1.1896 + 'IYUV' => 'Planar YUV format (8-bpp Y plane, followed by 8-bpp 2×2 U and V planes)', 1.1897 + 'i263' => 'Intel ITU H.263 Videoconferencing (i263)', 1.1898 + 'I420' => 'Intel Indeo 4', 1.1899 + 'IAN ' => 'Intel Indeo 4 (RDX)', 1.1900 + 'ICLB' => 'InSoft CellB Videoconferencing', 1.1901 + 'IGOR' => 'Power DVD', 1.1902 + 'IJPG' => 'Intergraph JPEG', 1.1903 + 'ILVC' => 'Intel Layered Video', 1.1904 + 'ILVR' => 'ITU-T H.263+', 1.1905 + 'IPDV' => 'I-O Data Device Giga AVI DV Codec', 1.1906 + 'IR21' => 'Intel Indeo 2.1', 1.1907 + 'IRAW' => 'Intel YUV Uncompressed', 1.1908 + 'IV30' => 'Intel Indeo 3.0', 1.1909 + 'IV31' => 'Intel Indeo 3.1', 1.1910 + 'IV32' => 'Ligos Indeo 3.2', 1.1911 + 'IV33' => 'Ligos Indeo 3.3', 1.1912 + 'IV34' => 'Ligos Indeo 3.4', 1.1913 + 'IV35' => 'Ligos Indeo 3.5', 1.1914 + 'IV36' => 'Ligos Indeo 3.6', 1.1915 + 'IV37' => 'Ligos Indeo 3.7', 1.1916 + 'IV38' => 'Ligos Indeo 3.8', 1.1917 + 'IV39' => 'Ligos Indeo 3.9', 1.1918 + 'IV40' => 'Ligos Indeo Interactive 4.0', 1.1919 + 'IV41' => 'Ligos Indeo Interactive 4.1', 1.1920 + 'IV42' => 'Ligos Indeo Interactive 4.2', 1.1921 + 'IV43' => 'Ligos Indeo Interactive 4.3', 1.1922 + 'IV44' => 'Ligos Indeo Interactive 4.4', 1.1923 + 'IV45' => 'Ligos Indeo Interactive 4.5', 1.1924 + 'IV46' => 'Ligos Indeo Interactive 4.6', 1.1925 + 'IV47' => 'Ligos Indeo Interactive 4.7', 1.1926 + 'IV48' => 'Ligos Indeo Interactive 4.8', 1.1927 + 'IV49' => 'Ligos Indeo Interactive 4.9', 1.1928 + 'IV50' => 'Ligos Indeo Interactive 5.0', 1.1929 + 'JBYR' => 'Kensington ?JBYR?', 1.1930 + 'JPEG' => 'Still Image JPEG DIB', 1.1931 + 'JPGL' => 'Pegasus Lossless Motion JPEG', 1.1932 + 'KMVC' => 'Team17 Software Karl Morton\'s Video Codec', 1.1933 + 'LSVM' => 'Vianet Lighting Strike Vmail (Streaming) (www.vianet.com)', 1.1934 + 'LEAD' => 'LEAD Video Codec', 1.1935 + 'Ljpg' => 'LEAD MJPEG Codec', 1.1936 + 'MDVD' => 'Alex MicroDVD Video (hacked MS MPEG-4) (www.tiasoft.de)', 1.1937 + 'MJPA' => 'Morgan Motion JPEG (MJPA) (www.morgan-multimedia.com)', 1.1938 + 'MJPB' => 'Morgan Motion JPEG (MJPB) (www.morgan-multimedia.com)', 1.1939 + 'MMES' => 'Matrox MPEG-2 I-frame', 1.1940 + 'MP2v' => 'Microsoft S-Mpeg 4 version 1 (MP2v)', 1.1941 + 'MP42' => 'Microsoft S-Mpeg 4 version 2 (MP42)', 1.1942 + 'MP43' => 'Microsoft S-Mpeg 4 version 3 (MP43)', 1.1943 + 'MP4S' => 'Microsoft S-Mpeg 4 version 3 (MP4S)', 1.1944 + 'MP4V' => 'FFmpeg MPEG-4', 1.1945 + 'MPG1' => 'FFmpeg MPEG 1/2', 1.1946 + 'MPG2' => 'FFmpeg MPEG 1/2', 1.1947 + 'MPG3' => 'FFmpeg DivX ;-) (MS MPEG-4 v3)', 1.1948 + 'MPG4' => 'Microsoft MPEG-4', 1.1949 + 'MPGI' => 'Sigma Designs MPEG', 1.1950 + 'MPNG' => 'PNG images decoder', 1.1951 + 'MSS1' => 'Microsoft Windows Screen Video', 1.1952 + 'MSZH' => 'LCL (Lossless Codec Library) (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm)', 1.1953 + 'M261' => 'Microsoft H.261', 1.1954 + 'M263' => 'Microsoft H.263', 1.1955 + 'M4S2' => 'Microsoft Fully Compliant MPEG-4 v2 simple profile (M4S2)', 1.1956 + 'm4s2' => 'Microsoft Fully Compliant MPEG-4 v2 simple profile (m4s2)', 1.1957 + 'MC12' => 'ATI Motion Compensation Format (MC12)', 1.1958 + 'MCAM' => 'ATI Motion Compensation Format (MCAM)', 1.1959 + 'MJ2C' => 'Morgan Multimedia Motion JPEG2000', 1.1960 + 'mJPG' => 'IBM Motion JPEG w/ Huffman Tables', 1.1961 + 'MJPG' => 'Microsoft Motion JPEG DIB', 1.1962 + 'MP42' => 'Microsoft MPEG-4 (low-motion)', 1.1963 + 'MP43' => 'Microsoft MPEG-4 (fast-motion)', 1.1964 + 'MP4S' => 'Microsoft MPEG-4 (MP4S)', 1.1965 + 'mp4s' => 'Microsoft MPEG-4 (mp4s)', 1.1966 + 'MPEG' => 'Chromatic Research MPEG-1 Video I-Frame', 1.1967 + 'MPG4' => 'Microsoft MPEG-4 Video High Speed Compressor', 1.1968 + 'MPGI' => 'Sigma Designs MPEG', 1.1969 + 'MRCA' => 'FAST Multimedia Martin Regen Codec', 1.1970 + 'MRLE' => 'Microsoft Run Length Encoding', 1.1971 + 'MSVC' => 'Microsoft Video 1', 1.1972 + 'MTX1' => 'Matrox ?MTX1?', 1.1973 + 'MTX2' => 'Matrox ?MTX2?', 1.1974 + 'MTX3' => 'Matrox ?MTX3?', 1.1975 + 'MTX4' => 'Matrox ?MTX4?', 1.1976 + 'MTX5' => 'Matrox ?MTX5?', 1.1977 + 'MTX6' => 'Matrox ?MTX6?', 1.1978 + 'MTX7' => 'Matrox ?MTX7?', 1.1979 + 'MTX8' => 'Matrox ?MTX8?', 1.1980 + 'MTX9' => 'Matrox ?MTX9?', 1.1981 + 'MV12' => 'Motion Pixels Codec (old)', 1.1982 + 'MWV1' => 'Aware Motion Wavelets', 1.1983 + 'nAVI' => 'SMR Codec (hack of Microsoft MPEG-4) (IRC #shadowrealm)', 1.1984 + 'NT00' => 'NewTek LightWave HDTV YUV w/ Alpha (www.newtek.com)', 1.1985 + 'NUV1' => 'NuppelVideo', 1.1986 + 'NTN1' => 'Nogatech Video Compression 1', 1.1987 + 'NVS0' => 'nVidia GeForce Texture (NVS0)', 1.1988 + 'NVS1' => 'nVidia GeForce Texture (NVS1)', 1.1989 + 'NVS2' => 'nVidia GeForce Texture (NVS2)', 1.1990 + 'NVS3' => 'nVidia GeForce Texture (NVS3)', 1.1991 + 'NVS4' => 'nVidia GeForce Texture (NVS4)', 1.1992 + 'NVS5' => 'nVidia GeForce Texture (NVS5)', 1.1993 + 'NVT0' => 'nVidia GeForce Texture (NVT0)', 1.1994 + 'NVT1' => 'nVidia GeForce Texture (NVT1)', 1.1995 + 'NVT2' => 'nVidia GeForce Texture (NVT2)', 1.1996 + 'NVT3' => 'nVidia GeForce Texture (NVT3)', 1.1997 + 'NVT4' => 'nVidia GeForce Texture (NVT4)', 1.1998 + 'NVT5' => 'nVidia GeForce Texture (NVT5)', 1.1999 + 'PIXL' => 'MiroXL, Pinnacle PCTV', 1.2000 + 'PDVC' => 'I-O Data Device Digital Video Capture DV codec', 1.2001 + 'PGVV' => 'Radius Video Vision', 1.2002 + 'PHMO' => 'IBM Photomotion', 1.2003 + 'PIM1' => 'MPEG Realtime (Pinnacle Cards)', 1.2004 + 'PIM2' => 'Pegasus Imaging ?PIM2?', 1.2005 + 'PIMJ' => 'Pegasus Imaging Lossless JPEG', 1.2006 + 'PVEZ' => 'Horizons Technology PowerEZ', 1.2007 + 'PVMM' => 'PacketVideo Corporation MPEG-4', 1.2008 + 'PVW2' => 'Pegasus Imaging Wavelet Compression', 1.2009 + 'Q1.0' => 'Q-Team\'s QPEG 1.0 (www.q-team.de)', 1.2010 + 'Q1.1' => 'Q-Team\'s QPEG 1.1 (www.q-team.de)', 1.2011 + 'QPEG' => 'Q-Team QPEG 1.0', 1.2012 + 'qpeq' => 'Q-Team QPEG 1.1', 1.2013 + 'RGB ' => 'Raw BGR32', 1.2014 + 'RGBA' => 'Raw RGB w/ Alpha', 1.2015 + 'RMP4' => 'REALmagic MPEG-4 (unauthorized XVID copy) (www.sigmadesigns.com)', 1.2016 + 'ROQV' => 'Id RoQ File Video Decoder', 1.2017 + 'RPZA' => 'Quicktime Apple Video (RPZA)', 1.2018 + 'RUD0' => 'Rududu video codec (http://rududu.ifrance.com/rududu/)', 1.2019 + 'RV10' => 'RealVideo 1.0 (aka RealVideo 5.0)', 1.2020 + 'RV13' => 'RealVideo 1.0 (RV13)', 1.2021 + 'RV20' => 'RealVideo G2', 1.2022 + 'RV30' => 'RealVideo 8', 1.2023 + 'RV40' => 'RealVideo 9', 1.2024 + 'RGBT' => 'Raw RGB w/ Transparency', 1.2025 + 'RLE ' => 'Microsoft Run Length Encoder', 1.2026 + 'RLE4' => 'Run Length Encoded (4bpp, 16-color)', 1.2027 + 'RLE8' => 'Run Length Encoded (8bpp, 256-color)', 1.2028 + 'RT21' => 'Intel Indeo RealTime Video 2.1', 1.2029 + 'rv20' => 'RealVideo G2', 1.2030 + 'rv30' => 'RealVideo 8', 1.2031 + 'RVX ' => 'Intel RDX (RVX )', 1.2032 + 'SMC ' => 'Apple Graphics (SMC )', 1.2033 + 'SP54' => 'Logitech Sunplus Sp54 Codec for Mustek GSmart Mini 2', 1.2034 + 'SPIG' => 'Radius Spigot', 1.2035 + 'SVQ3' => 'Sorenson Video 3 (Apple Quicktime 5)', 1.2036 + 's422' => 'Tekram VideoCap C210 YUV 4:2:2', 1.2037 + 'SDCC' => 'Sun Communication Digital Camera Codec', 1.2038 + 'SFMC' => 'CrystalNet Surface Fitting Method', 1.2039 + 'SMSC' => 'Radius SMSC', 1.2040 + 'SMSD' => 'Radius SMSD', 1.2041 + 'smsv' => 'WorldConnect Wavelet Video', 1.2042 + 'SPIG' => 'Radius Spigot', 1.2043 + 'SPLC' => 'Splash Studios ACM Audio Codec (www.splashstudios.net)', 1.2044 + 'SQZ2' => 'Microsoft VXTreme Video Codec V2', 1.2045 + 'STVA' => 'ST Microelectronics CMOS Imager Data (Bayer)', 1.2046 + 'STVB' => 'ST Microelectronics CMOS Imager Data (Nudged Bayer)', 1.2047 + 'STVC' => 'ST Microelectronics CMOS Imager Data (Bunched)', 1.2048 + 'STVX' => 'ST Microelectronics CMOS Imager Data (Extended CODEC Data Format)', 1.2049 + 'STVY' => 'ST Microelectronics CMOS Imager Data (Extended CODEC Data Format with Correction Data)', 1.2050 + 'SV10' => 'Sorenson Video R1', 1.2051 + 'SVQ1' => 'Sorenson Video', 1.2052 + 'T420' => 'Toshiba YUV 4:2:0', 1.2053 + 'TM2A' => 'Duck TrueMotion Archiver 2.0 (www.duck.com)', 1.2054 + 'TVJP' => 'Pinnacle/Truevision Targa 2000 board (TVJP)', 1.2055 + 'TVMJ' => 'Pinnacle/Truevision Targa 2000 board (TVMJ)', 1.2056 + 'TY0N' => 'Tecomac Low-Bit Rate Codec (www.tecomac.com)', 1.2057 + 'TY2C' => 'Trident Decompression Driver', 1.2058 + 'TLMS' => 'TeraLogic Motion Intraframe Codec (TLMS)', 1.2059 + 'TLST' => 'TeraLogic Motion Intraframe Codec (TLST)', 1.2060 + 'TM20' => 'Duck TrueMotion 2.0', 1.2061 + 'TM2X' => 'Duck TrueMotion 2X', 1.2062 + 'TMIC' => 'TeraLogic Motion Intraframe Codec (TMIC)', 1.2063 + 'TMOT' => 'Horizons Technology TrueMotion S', 1.2064 + 'tmot' => 'Horizons TrueMotion Video Compression', 1.2065 + 'TR20' => 'Duck TrueMotion RealTime 2.0', 1.2066 + 'TSCC' => 'TechSmith Screen Capture Codec', 1.2067 + 'TV10' => 'Tecomac Low-Bit Rate Codec', 1.2068 + 'TY2N' => 'Trident ?TY2N?', 1.2069 + 'U263' => 'UB Video H.263/H.263+/H.263++ Decoder', 1.2070 + 'UMP4' => 'UB Video MPEG 4 (www.ubvideo.com)', 1.2071 + 'UYNV' => 'Nvidia UYVY packed 4:2:2', 1.2072 + 'UYVP' => 'Evans & Sutherland YCbCr 4:2:2 extended precision', 1.2073 + 'UCOD' => 'eMajix.com ClearVideo', 1.2074 + 'ULTI' => 'IBM Ultimotion', 1.2075 + 'UYVY' => 'UYVY packed 4:2:2', 1.2076 + 'V261' => 'Lucent VX2000S', 1.2077 + 'VIFP' => 'VFAPI Reader Codec (www.yks.ne.jp/~hori/)', 1.2078 + 'VIV1' => 'FFmpeg H263+ decoder', 1.2079 + 'VIV2' => 'Vivo H.263', 1.2080 + 'VQC2' => 'Vector-quantised codec 2 (research) http://eprints.ecs.soton.ac.uk/archive/00001310/01/VTC97-js.pdf)', 1.2081 + 'VTLP' => 'Alaris VideoGramPiX', 1.2082 + 'VYU9' => 'ATI YUV (VYU9)', 1.2083 + 'VYUY' => 'ATI YUV (VYUY)', 1.2084 + 'V261' => 'Lucent VX2000S', 1.2085 + 'V422' => 'Vitec Multimedia 24-bit YUV 4:2:2 Format', 1.2086 + 'V655' => 'Vitec Multimedia 16-bit YUV 4:2:2 Format', 1.2087 + 'VCR1' => 'ATI Video Codec 1', 1.2088 + 'VCR2' => 'ATI Video Codec 2', 1.2089 + 'VCR3' => 'ATI VCR 3.0', 1.2090 + 'VCR4' => 'ATI VCR 4.0', 1.2091 + 'VCR5' => 'ATI VCR 5.0', 1.2092 + 'VCR6' => 'ATI VCR 6.0', 1.2093 + 'VCR7' => 'ATI VCR 7.0', 1.2094 + 'VCR8' => 'ATI VCR 8.0', 1.2095 + 'VCR9' => 'ATI VCR 9.0', 1.2096 + 'VDCT' => 'Vitec Multimedia Video Maker Pro DIB', 1.2097 + 'VDOM' => 'VDOnet VDOWave', 1.2098 + 'VDOW' => 'VDOnet VDOLive (H.263)', 1.2099 + 'VDTZ' => 'Darim Vison VideoTizer YUV', 1.2100 + 'VGPX' => 'Alaris VideoGramPiX', 1.2101 + 'VIDS' => 'Vitec Multimedia YUV 4:2:2 CCIR 601 for V422', 1.2102 + 'VIVO' => 'Vivo H.263 v2.00', 1.2103 + 'vivo' => 'Vivo H.263', 1.2104 + 'VIXL' => 'Miro/Pinnacle Video XL', 1.2105 + 'VLV1' => 'VideoLogic/PURE Digital Videologic Capture', 1.2106 + 'VP30' => 'On2 VP3.0', 1.2107 + 'VP31' => 'On2 VP3.1', 1.2108 + 'VX1K' => 'Lucent VX1000S Video Codec', 1.2109 + 'VX2K' => 'Lucent VX2000S Video Codec', 1.2110 + 'VXSP' => 'Lucent VX1000SP Video Codec', 1.2111 + 'WBVC' => 'Winbond W9960', 1.2112 + 'WHAM' => 'Microsoft Video 1 (WHAM)', 1.2113 + 'WINX' => 'Winnov Software Compression', 1.2114 + 'WJPG' => 'AverMedia Winbond JPEG', 1.2115 + 'WMV1' => 'Windows Media Video V7', 1.2116 + 'WMV2' => 'Windows Media Video V8', 1.2117 + 'WMV3' => 'Windows Media Video V9', 1.2118 + 'WNV1' => 'Winnov Hardware Compression', 1.2119 + 'XYZP' => 'Extended PAL format XYZ palette (www.riff.org)', 1.2120 + 'x263' => 'Xirlink H.263', 1.2121 + 'XLV0' => 'NetXL Video Decoder', 1.2122 + 'XMPG' => 'Xing MPEG (I-Frame only)', 1.2123 + 'XVID' => 'XviD MPEG-4 (www.xvid.org)', 1.2124 + 'XXAN' => '?XXAN?', 1.2125 + 'YU92' => 'Intel YUV (YU92)', 1.2126 + 'YUNV' => 'Nvidia Uncompressed YUV 4:2:2', 1.2127 + 'YUVP' => 'Extended PAL format YUV palette (www.riff.org)', 1.2128 + 'Y211' => 'YUV 2:1:1 Packed', 1.2129 + 'Y411' => 'YUV 4:1:1 Packed', 1.2130 + 'Y41B' => 'Weitek YUV 4:1:1 Planar', 1.2131 + 'Y41P' => 'Brooktree PC1 YUV 4:1:1 Packed', 1.2132 + 'Y41T' => 'Brooktree PC1 YUV 4:1:1 with transparency', 1.2133 + 'Y42B' => 'Weitek YUV 4:2:2 Planar', 1.2134 + 'Y42T' => 'Brooktree UYUV 4:2:2 with transparency', 1.2135 + 'Y422' => 'ADS Technologies Copy of UYVY used in Pyro WebCam firewire camera', 1.2136 + 'Y800' => 'Simple, single Y plane for monochrome images', 1.2137 + 'Y8 ' => 'Grayscale video', 1.2138 + 'YC12' => 'Intel YUV 12 codec', 1.2139 + 'YUV8' => 'Winnov Caviar YUV8', 1.2140 + 'YUV9' => 'Intel YUV9', 1.2141 + 'YUY2' => 'Uncompressed YUV 4:2:2', 1.2142 + 'YUYV' => 'Canopus YUV', 1.2143 + 'YV12' => 'YVU12 Planar', 1.2144 + 'YVU9' => 'Intel YVU9 Planar (8-bpp Y plane, followed by 8-bpp 4x4 U and V planes)', 1.2145 + 'YVYU' => 'YVYU 4:2:2 Packed', 1.2146 + 'ZLIB' => 'Lossless Codec Library zlib compression (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm)', 1.2147 + 'ZPEG' => 'Metheus Video Zipper' 1.2148 + ); 1.2149 + 1.2150 + return @$lookup[$four_cc]; 1.2151 + } 1.2152 + 1.2153 + 1.2154 + 1.2155 + public static function RIFFcommentsParse(&$riff_info_aray, &$comments_target_array) { 1.2156 + 1.2157 + static $lookup = array( 1.2158 + 'IARL' => 'archivallocation', 1.2159 + 'IART' => 'artist', 1.2160 + 'ICDS' => 'costumedesigner', 1.2161 + 'ICMS' => 'commissionedby', 1.2162 + 'ICMT' => 'comment', 1.2163 + 'ICNT' => 'country', 1.2164 + 'ICOP' => 'copyright', 1.2165 + 'ICRD' => 'creationdate', 1.2166 + 'IDIM' => 'dimensions', 1.2167 + 'IDIT' => 'digitizationdate', 1.2168 + 'IDPI' => 'resolution', 1.2169 + 'IDST' => 'distributor', 1.2170 + 'IEDT' => 'editor', 1.2171 + 'IENG' => 'engineers', 1.2172 + 'IFRM' => 'accountofparts', 1.2173 + 'IGNR' => 'genre', 1.2174 + 'IKEY' => 'keywords', 1.2175 + 'ILGT' => 'lightness', 1.2176 + 'ILNG' => 'language', 1.2177 + 'IMED' => 'orignalmedium', 1.2178 + 'IMUS' => 'composer', 1.2179 + 'INAM' => 'title', 1.2180 + 'IPDS' => 'productiondesigner', 1.2181 + 'IPLT' => 'palette', 1.2182 + 'IPRD' => 'product', 1.2183 + 'IPRO' => 'producer', 1.2184 + 'IPRT' => 'part', 1.2185 + 'IRTD' => 'rating', 1.2186 + 'ISBJ' => 'subject', 1.2187 + 'ISFT' => 'software', 1.2188 + 'ISGN' => 'secondarygenre', 1.2189 + 'ISHP' => 'sharpness', 1.2190 + 'ISRC' => 'sourcesupplier', 1.2191 + 'ISRF' => 'digitizationsource', 1.2192 + 'ISTD' => 'productionstudio', 1.2193 + 'ISTR' => 'starring', 1.2194 + 'ITCH' => 'encoded_by', 1.2195 + 'IWEB' => 'url', 1.2196 + 'IWRI' => 'writer' 1.2197 + ); 1.2198 + 1.2199 + foreach ($lookup as $key => $value) { 1.2200 + if (isset($riff_info_aray[$key])) { 1.2201 + foreach ($riff_info_aray[$key] as $comment_id => $comment_data) { 1.2202 + if (trim($comment_data['data']) != '') { 1.2203 + @$comments_target_array[$value][] = trim($comment_data['data']); 1.2204 + } 1.2205 + } 1.2206 + } 1.2207 + } 1.2208 + return true; 1.2209 + } 1.2210 + 1.2211 + 1.2212 + 1.2213 + public static function array_merge_noclobber($array1, $array2) { 1.2214 + if (!is_array($array1) || !is_array($array2)) { 1.2215 + return false; 1.2216 + } 1.2217 + $new_array = $array1; 1.2218 + foreach ($array2 as $key => $val) { 1.2219 + if (is_array($val) && isset($new_array[$key]) && is_array($new_array[$key])) { 1.2220 + $new_array[$key] = getid3_riff::array_merge_noclobber($new_array[$key], $val); 1.2221 + } elseif (!isset($new_array[$key])) { 1.2222 + $new_array[$key] = $val; 1.2223 + } 1.2224 + } 1.2225 + return $new_array; 1.2226 + } 1.2227 + 1.2228 + 1.2229 + 1.2230 + public static function DateMac2Unix($mac_date) { 1.2231 + 1.2232 + // Macintosh timestamp: seconds since 00:00h January 1, 1904 1.2233 + // UNIX timestamp: seconds since 00:00h January 1, 1970 1.2234 + return (int)($mac_date - 2082844800); 1.2235 + } 1.2236 + 1.2237 + 1.2238 + 1.2239 + public static function FixedPoint16_16($raw_data) { 1.2240 + 1.2241 + return getid3_lib::BigEndian2Int(substr($raw_data, 0, 2)) + (float)(getid3_lib::BigEndian2Int(substr($raw_data, 2, 2)) / 65536); // pow(2, 16) = 65536 1.2242 + } 1.2243 + 1.2244 + 1.2245 + 1.2246 + function BigEndian2Float($byte_word) { 1.2247 + 1.2248 + // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic 1.2249 + // http://www.psc.edu/general/software/packages/ieee/ieee.html 1.2250 + // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html 1.2251 + 1.2252 + $bit_word = getid3_lib::BigEndian2Bin($byte_word); 1.2253 + $sign_bit = $bit_word{0}; 1.2254 + 1.2255 + switch (strlen($byte_word) * 8) { 1.2256 + case 32: 1.2257 + $exponent_bits = 8; 1.2258 + $fraction_bits = 23; 1.2259 + break; 1.2260 + 1.2261 + case 64: 1.2262 + $exponent_bits = 11; 1.2263 + $fraction_bits = 52; 1.2264 + break; 1.2265 + 1.2266 + case 80: 1.2267 + // 80-bit Apple SANE format 1.2268 + // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/ 1.2269 + $exponent_string = substr($bit_word, 1, 15); 1.2270 + $is_normalized = intval($bit_word{16}); 1.2271 + $fraction_string = substr($bit_word, 17, 63); 1.2272 + $exponent = pow(2, bindec($exponent_string) - 16383); 1.2273 + $fraction = $is_normalized + bindec($fraction_string) / bindec('1'.str_repeat('0', strlen($fraction_string))); 1.2274 + $float_value = $exponent * $fraction; 1.2275 + if ($sign_bit == '1') { 1.2276 + $float_value *= -1; 1.2277 + } 1.2278 + return $float_value; 1.2279 + break; 1.2280 + 1.2281 + default: 1.2282 + return false; 1.2283 + break; 1.2284 + } 1.2285 + $exponent_string = substr($bit_word, 1, $exponent_bits); 1.2286 + $fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits); 1.2287 + $exponent = bindec($exponent_string); 1.2288 + $fraction = bindec($fraction_string); 1.2289 + 1.2290 + if (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction != 0)) { 1.2291 + // Not a Number 1.2292 + $float_value = false; 1.2293 + } elseif (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction == 0)) { 1.2294 + if ($sign_bit == '1') { 1.2295 + $float_value = '-infinity'; 1.2296 + } else { 1.2297 + $float_value = '+infinity'; 1.2298 + } 1.2299 + } elseif (($exponent == 0) && ($fraction == 0)) { 1.2300 + if ($sign_bit == '1') { 1.2301 + $float_value = -0; 1.2302 + } else { 1.2303 + $float_value = 0; 1.2304 + } 1.2305 + $float_value = ($sign_bit ? 0 : -0); 1.2306 + } elseif (($exponent == 0) && ($fraction != 0)) { 1.2307 + // These are 'unnormalized' values 1.2308 + $float_value = pow(2, (-1 * (pow(2, $exponent_bits - 1) - 2))) * bindec($fraction_string) / bindec('1'.str_repeat('0', strlen($fraction_string))); 1.2309 + if ($sign_bit == '1') { 1.2310 + $float_value *= -1; 1.2311 + } 1.2312 + } elseif ($exponent != 0) { 1.2313 + $float_value = pow(2, ($exponent - (pow(2, $exponent_bits - 1) - 1))) * (1 + bindec($fraction_string) / bindec('1'.str_repeat('0', strlen($fraction_string)))); 1.2314 + if ($sign_bit == '1') { 1.2315 + $float_value *= -1; 1.2316 + } 1.2317 + } 1.2318 + return (float) $float_value; 1.2319 + } 1.2320 +} 1.2321 + 1.2322 +?> 1.2323 \ No newline at end of file