annotate e2gallerypro/e2upload/Backend/Assets/getid3/module.audio-video.riff.php @ 22:be17de86e80d judyates

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