| Conditions | 180 |
| Paths | 14 |
| Total Lines | 1171 |
| Code Lines | 773 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 33 | public function Analyze() |
||
| 34 | { |
||
| 35 | $getid3 = $this->getid3; |
||
| 36 | |||
| 37 | $getid3->info['riff']['raw'] = []; |
||
| 38 | $info_riff = &$getid3->info['riff']; |
||
| 39 | $info_riff_raw = &$info_riff['raw']; |
||
| 40 | $info_audio = &$getid3->info['audio']; |
||
| 41 | $info_video = &$getid3->info['video']; |
||
| 42 | $info_avdataoffset = &$getid3->info['avdataoffset']; |
||
| 43 | $info_avdataend = &$getid3->info['avdataend']; |
||
| 44 | $info_audio_dataformat = &$info_audio['dataformat']; |
||
| 45 | $info_riff_audio = &$info_riff['audio']; |
||
| 46 | $info_riff_video = &$info_riff['video']; |
||
| 47 | |||
| 48 | $original['avdataend'] = $info_avdataend; |
||
|
|
|||
| 49 | |||
| 50 | $this->fseek($info_avdataoffset, SEEK_SET); |
||
| 51 | $riff_header = $this->fread(12); |
||
| 52 | |||
| 53 | $riff_sub_type = substr($riff_header, 8, 4); |
||
| 54 | |||
| 55 | switch (substr($riff_header, 0, 4)) { |
||
| 56 | case 'FORM': |
||
| 57 | $getid3->info['fileformat'] = 'aiff'; |
||
| 58 | $this->endian_function = 'BigEndian2Int'; |
||
| 59 | $riff_header_size = getid3_lib::BigEndian2Int(substr($riff_header, 4, 4)); |
||
| 60 | $info_riff[$riff_sub_type] = $this->ParseRIFF($info_avdataoffset + 12, $info_avdataoffset + $riff_header_size); |
||
| 61 | $info_riff['header_size'] = $riff_header_size; |
||
| 62 | break; |
||
| 63 | |||
| 64 | case 'RIFF': |
||
| 65 | case 'SDSS': // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com) |
||
| 66 | case 'RMP3': // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s |
||
| 67 | |||
| 68 | if ('RMP3' == $riff_sub_type) { |
||
| 69 | $riff_sub_type = 'WAVE'; |
||
| 70 | } |
||
| 71 | |||
| 72 | $getid3->info['fileformat'] = 'riff'; |
||
| 73 | $this->endian_function = 'LittleEndian2Int'; |
||
| 74 | $riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_header, 4, 4)); |
||
| 75 | $info_riff[$riff_sub_type] = $this->ParseRIFF($info_avdataoffset + 12, $info_avdataoffset + $riff_header_size); |
||
| 76 | $info_riff['header_size'] = $riff_header_size; |
||
| 77 | if ('WAVE' == $riff_sub_type) { |
||
| 78 | $info_riff_wave = &$info_riff['WAVE']; |
||
| 79 | } |
||
| 80 | break; |
||
| 81 | |||
| 82 | default: |
||
| 83 | 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'); |
||
| 84 | } |
||
| 85 | |||
| 86 | $endian_function = $this->endian_function; |
||
| 87 | |||
| 88 | $stream_index = 0; |
||
| 89 | switch ($riff_sub_type) { |
||
| 90 | case 'WAVE': |
||
| 91 | |||
| 92 | if (empty($info_audio['bitrate_mode'])) { |
||
| 93 | $info_audio['bitrate_mode'] = 'cbr'; |
||
| 94 | } |
||
| 95 | |||
| 96 | if (empty($info_audio_dataformat)) { |
||
| 97 | $info_audio_dataformat = 'wav'; |
||
| 98 | } |
||
| 99 | |||
| 100 | if (isset($info_riff_wave['data'][0]['offset'])) { |
||
| 101 | $info_avdataoffset = $info_riff_wave['data'][0]['offset'] + 8; |
||
| 102 | $info_avdataend = $info_avdataoffset + $info_riff_wave['data'][0]['size']; |
||
| 103 | } |
||
| 104 | |||
| 105 | if (isset($info_riff_wave['fmt '][0]['data'])) { |
||
| 106 | $info_riff_audio[$stream_index] = getid3_riff::RIFFparseWAVEFORMATex($info_riff_wave['fmt '][0]['data']); |
||
| 107 | $info_audio['wformattag'] = $info_riff_audio[$stream_index]['raw']['wFormatTag']; |
||
| 108 | $info_riff_raw['fmt '] = $info_riff_audio[$stream_index]['raw']; |
||
| 109 | unset($info_riff_audio[$stream_index]['raw']); |
||
| 110 | $info_audio['streams'][$stream_index] = $info_riff_audio[$stream_index]; |
||
| 111 | |||
| 112 | $info_audio = getid3_riff::array_merge_noclobber($info_audio, $info_riff_audio[$stream_index]); |
||
| 113 | if ('unknown: 0x' == substr($info_audio['codec'], 0, strlen('unknown: 0x'))) { |
||
| 114 | $getid3->warning('Audio codec = ' . $info_audio['codec']); |
||
| 115 | } |
||
| 116 | $info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate']; |
||
| 117 | |||
| 118 | $getid3->info['playtime_seconds'] = (float)((($info_avdataend - $info_avdataoffset) * 8) / $info_audio['bitrate']); |
||
| 119 | |||
| 120 | $info_audio['lossless'] = false; |
||
| 121 | |||
| 122 | if (isset($info_riff_wave['data'][0]['offset']) && isset($info_riff_raw['fmt ']['wFormatTag'])) { |
||
| 123 | switch ($info_riff_raw['fmt ']['wFormatTag']) { |
||
| 124 | case 0x0001: // PCM |
||
| 125 | $info_audio['lossless'] = true; |
||
| 126 | break; |
||
| 127 | |||
| 128 | case 0x2000: // AC-3 |
||
| 129 | $info_audio_dataformat = 'ac3'; |
||
| 130 | break; |
||
| 131 | |||
| 132 | default: |
||
| 133 | // do nothing |
||
| 134 | break; |
||
| 135 | } |
||
| 136 | } |
||
| 137 | |||
| 138 | $info_audio['streams'][$stream_index]['wformattag'] = $info_audio['wformattag']; |
||
| 139 | $info_audio['streams'][$stream_index]['bitrate_mode'] = $info_audio['bitrate_mode']; |
||
| 140 | $info_audio['streams'][$stream_index]['lossless'] = $info_audio['lossless']; |
||
| 141 | $info_audio['streams'][$stream_index]['dataformat'] = $info_audio_dataformat; |
||
| 142 | } |
||
| 143 | |||
| 144 | if (isset($info_riff_wave['rgad'][0]['data'])) { |
||
| 145 | // shortcuts |
||
| 146 | $rgadData = &$info_riff_wave['rgad'][0]['data']; |
||
| 147 | $info_riff_raw['rgad'] = ['track' => [], 'album' => []]; |
||
| 148 | $info_riff_raw_rgad = &$info_riff_raw['rgad']; |
||
| 149 | $info_riff_raw_rgad_track = &$info_riff_raw_rgad['track']; |
||
| 150 | $info_riff_raw_rgad_album = &$info_riff_raw_rgad['album']; |
||
| 151 | |||
| 152 | $info_riff_raw_rgad['fPeakAmplitude'] = getid3_riff::BigEndian2Float(strrev(substr($rgadData, 0, 4))); // LittleEndian2Float() |
||
| 153 | $info_riff_raw_rgad['nRadioRgAdjust'] = getid3_lib::$endian_function(substr($rgadData, 4, 2)); |
||
| 154 | $info_riff_raw_rgad['nAudiophileRgAdjust'] = getid3_lib::$endian_function(substr($rgadData, 6, 2)); |
||
| 155 | |||
| 156 | $n_track_rg_adjust_bit_string = str_pad(decbin($info_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT); |
||
| 157 | $n_album_rg_adjust_bit_string = str_pad(decbin($info_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT); |
||
| 158 | |||
| 159 | $info_riff_raw_rgad_track['name'] = bindec(substr($n_track_rg_adjust_bit_string, 0, 3)); |
||
| 160 | $info_riff_raw_rgad_track['originator'] = bindec(substr($n_track_rg_adjust_bit_string, 3, 3)); |
||
| 161 | $info_riff_raw_rgad_track['signbit'] = bindec($n_track_rg_adjust_bit_string[6]); |
||
| 162 | $info_riff_raw_rgad_track['adjustment'] = bindec(substr($n_track_rg_adjust_bit_string, 7, 9)); |
||
| 163 | $info_riff_raw_rgad_album['name'] = bindec(substr($n_album_rg_adjust_bit_string, 0, 3)); |
||
| 164 | $info_riff_raw_rgad_album['originator'] = bindec(substr($n_album_rg_adjust_bit_string, 3, 3)); |
||
| 165 | $info_riff_raw_rgad_album['signbit'] = bindec($n_album_rg_adjust_bit_string[6]); |
||
| 166 | $info_riff_raw_rgad_album['adjustment'] = bindec(substr($n_album_rg_adjust_bit_string, 7, 9)); |
||
| 167 | |||
| 168 | $info_riff['rgad']['peakamplitude'] = $info_riff_raw_rgad['fPeakAmplitude']; |
||
| 169 | if ((0 != $info_riff_raw_rgad_track['name']) && (0 != $info_riff_raw_rgad_track['originator'])) { |
||
| 170 | $info_riff['rgad']['track']['name'] = getid3_lib_replaygain::NameLookup($info_riff_raw_rgad_track['name']); |
||
| 171 | $info_riff['rgad']['track']['originator'] = getid3_lib_replaygain::OriginatorLookup($info_riff_raw_rgad_track['originator']); |
||
| 172 | $info_riff['rgad']['track']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($info_riff_raw_rgad_track['adjustment'], $info_riff_raw_rgad_track['signbit']); |
||
| 173 | } |
||
| 174 | |||
| 175 | if ((0 != $info_riff_raw_rgad_album['name']) && (0 != $info_riff_raw_rgad_album['originator'])) { |
||
| 176 | $info_riff['rgad']['album']['name'] = getid3_lib_replaygain::NameLookup($info_riff_raw_rgad_album['name']); |
||
| 177 | $info_riff['rgad']['album']['originator'] = getid3_lib_replaygain::OriginatorLookup($info_riff_raw_rgad_album['originator']); |
||
| 178 | $info_riff['rgad']['album']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($info_riff_raw_rgad_album['adjustment'], $info_riff_raw_rgad_album['signbit']); |
||
| 179 | } |
||
| 180 | } |
||
| 181 | |||
| 182 | if (isset($info_riff_wave['fact'][0]['data'])) { |
||
| 183 | $info_riff_raw['fact']['NumberOfSamples'] = getid3_lib::$endian_function(substr($info_riff_wave['fact'][0]['data'], 0, 4)); |
||
| 184 | |||
| 185 | // 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 |
||
| 186 | // if (!empty($info_riff_raw['fmt ']['nSamplesPerSec'])) { |
||
| 187 | // $getid3->info['playtime_seconds'] = (float)$info_riff_raw['fact']['NumberOfSamples'] / $info_riff_raw['fmt ']['nSamplesPerSec']; |
||
| 188 | // } |
||
| 189 | } |
||
| 190 | |||
| 191 | if (!empty($info_riff_raw['fmt ']['nAvgBytesPerSec'])) { |
||
| 192 | $info_audio['bitrate'] = (int)$info_riff_raw['fmt ']['nAvgBytesPerSec'] * 8; |
||
| 193 | } |
||
| 194 | |||
| 195 | if (isset($info_riff_wave['bext'][0]['data'])) { |
||
| 196 | $info_riff_wave_bext_0 = &$info_riff_wave['bext'][0]; |
||
| 197 | |||
| 198 | getid3_lib::ReadSequence( |
||
| 199 | 'LittleEndian2Int', |
||
| 200 | $info_riff_wave_bext_0, |
||
| 201 | $info_riff_wave_bext_0['data'], |
||
| 202 | 0, |
||
| 203 | [ |
||
| 204 | 'title' => -256, |
||
| 205 | 'author' => -32, |
||
| 206 | 'reference' => -32, |
||
| 207 | 'origin_date' => -10, |
||
| 208 | 'origin_time' => -8, |
||
| 209 | 'time_reference' => 8, |
||
| 210 | 'bwf_version' => 1, |
||
| 211 | 'reserved' => 254 |
||
| 212 | ] |
||
| 213 | ); |
||
| 214 | |||
| 215 | foreach (['title', 'author', 'reference'] as $key) { |
||
| 216 | $info_riff_wave_bext_0[$key] = trim($info_riff_wave_bext_0[$key]); |
||
| 217 | } |
||
| 218 | |||
| 219 | $info_riff_wave_bext_0['coding_history'] = explode("\r\n", trim(substr($info_riff_wave_bext_0['data'], 601))); |
||
| 220 | |||
| 221 | $info_riff_wave_bext_0['origin_date_unix'] = gmmktime( |
||
| 222 | substr($info_riff_wave_bext_0['origin_time'], 0, 2), |
||
| 223 | substr($info_riff_wave_bext_0['origin_time'], 3, 2), |
||
| 224 | substr($info_riff_wave_bext_0['origin_time'], 6, 2), |
||
| 225 | substr($info_riff_wave_bext_0['origin_date'], 5, 2), |
||
| 226 | substr($info_riff_wave_bext_0['origin_date'], 8, 2), |
||
| 227 | substr($info_riff_wave_bext_0['origin_date'], 0, 4) |
||
| 228 | ); |
||
| 229 | |||
| 230 | $info_riff['comments']['author'][] = $info_riff_wave_bext_0['author']; |
||
| 231 | $info_riff['comments']['title'][] = $info_riff_wave_bext_0['title']; |
||
| 232 | } |
||
| 233 | |||
| 234 | if (isset($info_riff_wave['MEXT'][0]['data'])) { |
||
| 235 | $info_riff_wave_mext_0 = &$info_riff_wave['MEXT'][0]; |
||
| 236 | |||
| 237 | $info_riff_wave_mext_0['raw']['sound_information'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 0, 2)); |
||
| 238 | $info_riff_wave_mext_0['flags']['homogenous'] = (bool)($info_riff_wave_mext_0['raw']['sound_information'] & 0x0001); |
||
| 239 | if ($info_riff_wave_mext_0['flags']['homogenous']) { |
||
| 240 | $info_riff_wave_mext_0['flags']['padding'] = ($info_riff_wave_mext_0['raw']['sound_information'] & 0x0002) ? false : true; |
||
| 241 | $info_riff_wave_mext_0['flags']['22_or_44'] = (bool)($info_riff_wave_mext_0['raw']['sound_information'] & 0x0004); |
||
| 242 | $info_riff_wave_mext_0['flags']['free_format'] = (bool)($info_riff_wave_mext_0['raw']['sound_information'] & 0x0008); |
||
| 243 | |||
| 244 | $info_riff_wave_mext_0['nominal_frame_size'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 2, 2)); |
||
| 245 | } |
||
| 246 | $info_riff_wave_mext_0['anciliary_data_length'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 6, 2)); |
||
| 247 | $info_riff_wave_mext_0['raw']['anciliary_data_def'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 8, 2)); |
||
| 248 | $info_riff_wave_mext_0['flags']['anciliary_data_left'] = (bool)($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x0001); |
||
| 249 | $info_riff_wave_mext_0['flags']['anciliary_data_free'] = (bool)($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x0002); |
||
| 250 | $info_riff_wave_mext_0['flags']['anciliary_data_right'] = (bool)($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x0004); |
||
| 251 | } |
||
| 252 | |||
| 253 | if (isset($info_riff_wave['cart'][0]['data'])) { |
||
| 254 | $info_riff_wave_cart_0 = &$info_riff_wave['cart'][0]; |
||
| 255 | |||
| 256 | getid3_lib::ReadSequence( |
||
| 257 | 'LittleEndian2Int', |
||
| 258 | $info_riff_wave_cart_0, |
||
| 259 | $info_riff_wave_cart_0['data'], |
||
| 260 | 0, |
||
| 261 | [ |
||
| 262 | 'version' => -4, |
||
| 263 | 'title' => -64, |
||
| 264 | 'artist' => -64, |
||
| 265 | 'cut_id' => -64, |
||
| 266 | 'client_id' => -64, |
||
| 267 | 'category' => -64, |
||
| 268 | 'classification' => -64, |
||
| 269 | 'out_cue' => -64, |
||
| 270 | 'start_date' => -10, |
||
| 271 | 'start_time' => -8, |
||
| 272 | 'end_date' => -10, |
||
| 273 | 'end_time' => -8, |
||
| 274 | 'producer_app_id' => -64, |
||
| 275 | 'producer_app_version' => -64, |
||
| 276 | 'user_defined_text' => -64, |
||
| 277 | ] |
||
| 278 | ); |
||
| 279 | |||
| 280 | foreach (['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) { |
||
| 281 | $info_riff_wave_cart_0[$key] = trim($info_riff_wave_cart_0[$key]); |
||
| 282 | } |
||
| 283 | |||
| 284 | $info_riff_wave_cart_0['zero_db_reference'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_cart_0['data'], 680, 4), true); |
||
| 285 | |||
| 286 | for ($i = 0; $i < 8; $i++) { |
||
| 287 | $info_riff_wave_cart_0['post_time'][$i]['usage_fourcc'] = substr($info_riff_wave_cart_0['data'], 684 + ($i * 8), 4); |
||
| 288 | $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)); |
||
| 289 | } |
||
| 290 | $info_riff_wave_cart_0['url'] = trim(substr($info_riff_wave_cart_0['data'], 748, 1024)); |
||
| 291 | $info_riff_wave_cart_0['tag_text'] = explode("\r\n", trim(substr($info_riff_wave_cart_0['data'], 1772))); |
||
| 292 | |||
| 293 | $info_riff['comments']['artist'][] = $info_riff_wave_cart_0['artist']; |
||
| 294 | $info_riff['comments']['title'][] = $info_riff_wave_cart_0['title']; |
||
| 295 | } |
||
| 296 | |||
| 297 | if (!isset($info_audio['bitrate']) && isset($info_riff_audio[$stream_index]['bitrate'])) { |
||
| 298 | $info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate']; |
||
| 299 | $getid3->info['playtime_seconds'] = (float)((($info_avdataend - $info_avdataoffset) * 8) / $info_audio['bitrate']); |
||
| 300 | } |
||
| 301 | |||
| 302 | if (@$getid3->info['wavpack']) { |
||
| 303 | if (!$this->data_string_flag) { |
||
| 304 | $info_audio_dataformat = 'wavpack'; |
||
| 305 | $info_audio['bitrate_mode'] = 'vbr'; |
||
| 306 | $info_audio['encoder'] = 'WavPack v' . $getid3->info['wavpack']['version']; |
||
| 307 | |||
| 308 | // Reset to the way it was - RIFF parsing will have messed this up |
||
| 309 | $info_avdataend = $original['avdataend']; |
||
| 310 | $info_audio['bitrate'] = (($info_avdataend - $info_avdataoffset) * 8) / $getid3->info['playtime_seconds']; |
||
| 311 | |||
| 312 | $this->fseek($info_avdataoffset - 44, SEEK_SET); |
||
| 313 | $riff_data = $this->fread(44); |
||
| 314 | $orignal_riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_data, 4, 4)) + 8; |
||
| 315 | $orignal_riff_data_size = getid3_lib::LittleEndian2Int(substr($riff_data, 40, 4)) + 44; |
||
| 316 | |||
| 317 | if ($orignal_riff_header_size > $orignal_riff_data_size) { |
||
| 318 | $info_avdataend -= ($orignal_riff_header_size - $orignal_riff_data_size); |
||
| 319 | $this->fseek($info_avdataend, SEEK_SET); |
||
| 320 | $riff_data .= $this->fread($orignal_riff_header_size - $orignal_riff_data_size); |
||
| 321 | } |
||
| 322 | |||
| 323 | // move the data chunk after all other chunks (if any) |
||
| 324 | // so that the RIFF parser doesn't see EOF when trying |
||
| 325 | // to skip over the data chunk |
||
| 326 | $riff_data = substr($riff_data, 0, 36) . substr($riff_data, 44) . substr($riff_data, 36, 8); |
||
| 327 | |||
| 328 | // Save audio info key |
||
| 329 | $saved_info_audio = $info_audio; |
||
| 330 | |||
| 331 | // Analyze riff_data |
||
| 332 | $this->AnalyzeString($riff_data); |
||
| 333 | |||
| 334 | // Restore info key |
||
| 335 | $info_audio = $saved_info_audio; |
||
| 336 | } |
||
| 337 | } |
||
| 338 | |||
| 339 | if (isset($info_riff_raw['fmt ']['wFormatTag'])) { |
||
| 340 | switch ($info_riff_raw['fmt ']['wFormatTag']) { |
||
| 341 | case 0x08AE: // ClearJump LiteWave |
||
| 342 | $info_audio['bitrate_mode'] = 'vbr'; |
||
| 343 | $info_audio_dataformat = 'litewave'; |
||
| 344 | |||
| 345 | //typedef struct tagSLwFormat { |
||
| 346 | // WORD m_wCompFormat; // low byte defines compression method, high byte is compression flags |
||
| 347 | // DWORD m_dwScale; // scale factor for lossy compression |
||
| 348 | // DWORD m_dwBlockSize; // number of samples in encoded blocks |
||
| 349 | // WORD m_wQuality; // alias for the scale factor |
||
| 350 | // WORD m_wMarkDistance; // distance between marks in bytes |
||
| 351 | // WORD m_wReserved; |
||
| 352 | // |
||
| 353 | // //following paramters are ignored if CF_FILESRC is not set |
||
| 354 | // DWORD m_dwOrgSize; // original file size in bytes |
||
| 355 | // WORD m_bFactExists; // indicates if 'fact' chunk exists in the original file |
||
| 356 | // DWORD m_dwRiffChunkSize; // riff chunk size in the original file |
||
| 357 | // |
||
| 358 | // PCMWAVEFORMAT m_OrgWf; // original wave format |
||
| 359 | // }SLwFormat, *PSLwFormat; |
||
| 360 | |||
| 361 | $info_riff['litewave']['raw'] = []; |
||
| 362 | $info_riff_litewave = &$info_riff['litewave']; |
||
| 363 | $info_riff_litewave_raw = &$info_riff_litewave['raw']; |
||
| 364 | |||
| 365 | getid3_lib::ReadSequence( |
||
| 366 | 'LittleEndian2Int', |
||
| 367 | $info_riff_litewave_raw, |
||
| 368 | $info_riff_wave['fmt '][0]['data'], |
||
| 369 | 18, |
||
| 370 | [ |
||
| 371 | 'compression_method' => 1, |
||
| 372 | 'compression_flags' => 1, |
||
| 373 | 'm_dwScale' => 4, |
||
| 374 | 'm_dwBlockSize' => 4, |
||
| 375 | 'm_wQuality' => 2, |
||
| 376 | 'm_wMarkDistance' => 2, |
||
| 377 | 'm_wReserved' => 2, |
||
| 378 | 'm_dwOrgSize' => 4, |
||
| 379 | 'm_bFactExists' => 2, |
||
| 380 | 'm_dwRiffChunkSize' => 4 |
||
| 381 | ] |
||
| 382 | ); |
||
| 383 | |||
| 384 | //$info_riff_litewave['quality_factor'] = intval(round((2000 - $info_riff_litewave_raw['m_dwScale']) / 20)); |
||
| 385 | $info_riff_litewave['quality_factor'] = $info_riff_litewave_raw['m_wQuality']; |
||
| 386 | |||
| 387 | $info_riff_litewave['flags']['raw_source'] = ($info_riff_litewave_raw['compression_flags'] & 0x01) ? false : true; |
||
| 388 | $info_riff_litewave['flags']['vbr_blocksize'] = ($info_riff_litewave_raw['compression_flags'] & 0x02) ? false : true; |
||
| 389 | $info_riff_litewave['flags']['seekpoints'] = (bool)($info_riff_litewave_raw['compression_flags'] & 0x04); |
||
| 390 | |||
| 391 | $info_audio['lossless'] = ((100 == $info_riff_litewave_raw['m_wQuality']) ? true : false); |
||
| 392 | $info_audio['encoder_options'] = '-q' . $info_riff_litewave['quality_factor']; |
||
| 393 | break; |
||
| 394 | } |
||
| 395 | } |
||
| 396 | |||
| 397 | if ($info_avdataend > $getid3->info['filesize']) { |
||
| 398 | switch (@$info_audio_dataformat) { |
||
| 399 | case 'wavpack': // WavPack |
||
| 400 | case 'lpac': // LPAC |
||
| 401 | case 'ofr': // OptimFROG |
||
| 402 | case 'ofs': // OptimFROG DualStream |
||
| 403 | // lossless compressed audio formats that keep original RIFF headers - skip warning |
||
| 404 | break; |
||
| 405 | |||
| 406 | case 'litewave': |
||
| 407 | |||
| 408 | if (1 == ($info_avdataend - $getid3->info['filesize'])) { |
||
| 409 | // LiteWave appears to incorrectly *not* pad actual output file |
||
| 410 | // to nearest WORD boundary so may appear to be short by one |
||
| 411 | // byte, in which case - skip warning |
||
| 412 | } else { |
||
| 413 | // Short by more than one byte, throw warning |
||
| 414 | $getid3->warning( |
||
| 415 | 'Probably truncated file - expecting ' |
||
| 416 | . $info_riff[$riff_sub_type]['data'][0]['size'] |
||
| 417 | . ' bytes of data, only found ' |
||
| 418 | . ($getid3->info['filesize'] - $info_avdataoffset) |
||
| 419 | . ' (short by ' |
||
| 420 | . ($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] |
||
| 421 | - $info_avdataoffset)) |
||
| 422 | . ' bytes)' |
||
| 423 | ); |
||
| 424 | } |
||
| 425 | break; |
||
| 426 | |||
| 427 | default: |
||
| 428 | |||
| 429 | if ((1 == ($info_avdataend - $getid3->info['filesize'])) && (0 == ($info_riff[$riff_sub_type]['data'][0]['size'] % 2)) && (1 == (($getid3->info['filesize'] - $info_avdataoffset) % 2))) { |
||
| 430 | // output file appears to be incorrectly *not* padded to nearest WORD boundary |
||
| 431 | // Output less severe warning |
||
| 432 | $getid3->warning( |
||
| 433 | 'File should probably be padded to nearest WORD boundary, but it is not (expecting ' |
||
| 434 | . $info_riff[$riff_sub_type]['data'][0]['size'] |
||
| 435 | . ' bytes of data, only found ' |
||
| 436 | . ($getid3->info['filesize'] - $info_avdataoffset) |
||
| 437 | . ' therefore short by ' |
||
| 438 | . ($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] - $info_avdataoffset)) |
||
| 439 | . ' bytes)' |
||
| 440 | ); |
||
| 441 | $info_avdataend = $getid3->info['filesize']; |
||
| 442 | break; |
||
| 443 | } |
||
| 444 | // Short by more than one byte, throw warning |
||
| 445 | $getid3->warning( |
||
| 446 | 'Probably truncated file - expecting ' |
||
| 447 | . $info_riff[$riff_sub_type]['data'][0]['size'] |
||
| 448 | . ' bytes of data, only found ' |
||
| 449 | . ($getid3->info['filesize'] - $info_avdataoffset) |
||
| 450 | . ' (short by ' |
||
| 451 | . ($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] |
||
| 452 | - $info_avdataoffset)) |
||
| 453 | . ' bytes)' |
||
| 454 | ); |
||
| 455 | $info_avdataend = $getid3->info['filesize']; |
||
| 456 | break; |
||
| 457 | } |
||
| 458 | } |
||
| 459 | |||
| 460 | if (!empty($getid3->info['mpeg']['audio']['LAME']['audio_bytes'])) { |
||
| 461 | if (1 == (($info_avdataend - $info_avdataoffset) - $getid3->info['mpeg']['audio']['LAME']['audio_bytes'])) { |
||
| 462 | $info_avdataend--; |
||
| 463 | $getid3->warning('Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored'); |
||
| 464 | } |
||
| 465 | } |
||
| 466 | |||
| 467 | if ('ac3' == @$info_audio_dataformat) { |
||
| 468 | unset($info_audio['bits_per_sample']); |
||
| 469 | if (!empty($getid3->info['ac3']['bitrate']) && ($getid3->info['ac3']['bitrate'] != $info_audio['bitrate'])) { |
||
| 470 | $info_audio['bitrate'] = $getid3->info['ac3']['bitrate']; |
||
| 471 | } |
||
| 472 | } |
||
| 473 | break; |
||
| 474 | |||
| 475 | case 'AVI ': |
||
| 476 | $info_video['bitrate_mode'] = 'vbr'; // maybe not, but probably |
||
| 477 | $info_video['dataformat'] = 'avi'; |
||
| 478 | $getid3->info['mime_type'] = 'video/avi'; |
||
| 479 | |||
| 480 | if (isset($info_riff[$riff_sub_type]['movi']['offset'])) { |
||
| 481 | $info_avdataoffset = $info_riff[$riff_sub_type]['movi']['offset'] + 8; |
||
| 482 | $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['movi']['size']; |
||
| 483 | if ($info_avdataend > $getid3->info['filesize']) { |
||
| 484 | $getid3->warning( |
||
| 485 | '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'] |
||
| 486 | - $info_avdataoffset)) . ' bytes)' |
||
| 487 | ); |
||
| 488 | $info_avdataend = $getid3->info['filesize']; |
||
| 489 | } |
||
| 490 | } |
||
| 491 | |||
| 492 | if (isset($info_riff['AVI ']['hdrl']['avih'][$stream_index]['data'])) { |
||
| 493 | $avihData = $info_riff['AVI ']['hdrl']['avih'][$stream_index]['data']; |
||
| 494 | |||
| 495 | $info_riff_raw['avih'] = []; |
||
| 496 | $info_riff_raw_avih = &$info_riff_raw['avih']; |
||
| 497 | |||
| 498 | getid3_lib::ReadSequence( |
||
| 499 | $this->endian_function, |
||
| 500 | $info_riff_raw_avih, |
||
| 501 | $avihData, |
||
| 502 | 0, |
||
| 503 | [ |
||
| 504 | 'dwMicroSecPerFrame' => 4, // frame display rate (or 0L) |
||
| 505 | 'dwMaxBytesPerSec' => 4, // max. transfer rate |
||
| 506 | 'dwPaddingGranularity' => 4, // pad to multiples of this size; normally 2K. |
||
| 507 | 'dwFlags' => 4, // the ever-present flags |
||
| 508 | 'dwTotalFrames' => 4, // # frames in file |
||
| 509 | 'dwInitialFrames' => 4, |
||
| 510 | 'dwStreams' => 4, |
||
| 511 | 'dwSuggestedBufferSize' => 4, |
||
| 512 | 'dwWidth' => 4, |
||
| 513 | 'dwHeight' => 4, |
||
| 514 | 'dwScale' => 4, |
||
| 515 | 'dwRate' => 4, |
||
| 516 | 'dwStart' => 4, |
||
| 517 | 'dwLength' => 4 |
||
| 518 | ] |
||
| 519 | ); |
||
| 520 | |||
| 521 | $info_riff_raw_avih['flags']['hasindex'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000010); |
||
| 522 | $info_riff_raw_avih['flags']['mustuseindex'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000020); |
||
| 523 | $info_riff_raw_avih['flags']['interleaved'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000100); |
||
| 524 | $info_riff_raw_avih['flags']['trustcktype'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00000800); |
||
| 525 | $info_riff_raw_avih['flags']['capturedfile'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00010000); |
||
| 526 | $info_riff_raw_avih['flags']['copyrighted'] = (bool)($info_riff_raw_avih['dwFlags'] & 0x00020010); |
||
| 527 | |||
| 528 | $info_riff_video[$stream_index] = []; |
||
| 529 | $info_riff_video_current = &$info_riff_video[$stream_index]; |
||
| 530 | |||
| 531 | if ($info_riff_raw_avih['dwWidth'] > 0) { |
||
| 532 | $info_riff_video_current['frame_width'] = $info_riff_raw_avih['dwWidth']; |
||
| 533 | $info_video['resolution_x'] = $info_riff_video_current['frame_width']; |
||
| 534 | } |
||
| 535 | |||
| 536 | if ($info_riff_raw_avih['dwHeight'] > 0) { |
||
| 537 | $info_riff_video_current['frame_height'] = $info_riff_raw_avih['dwHeight']; |
||
| 538 | $info_video['resolution_y'] = $info_riff_video_current['frame_height']; |
||
| 539 | } |
||
| 540 | |||
| 541 | if ($info_riff_raw_avih['dwTotalFrames'] > 0) { |
||
| 542 | $info_riff_video_current['total_frames'] = $info_riff_raw_avih['dwTotalFrames']; |
||
| 543 | $info_video['total_frames'] = $info_riff_video_current['total_frames']; |
||
| 544 | } |
||
| 545 | |||
| 546 | $info_riff_video_current['frame_rate'] = round(1000000 / $info_riff_raw_avih['dwMicroSecPerFrame'], 3); |
||
| 547 | $info_video['frame_rate'] = $info_riff_video_current['frame_rate']; |
||
| 548 | } |
||
| 549 | |||
| 550 | if (isset($info_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) { |
||
| 551 | if (is_array($info_riff['AVI ']['hdrl']['strl']['strh'])) { |
||
| 552 | for ($i = 0; $i < count($info_riff['AVI ']['hdrl']['strl']['strh']); $i++) { |
||
| 553 | if (isset($info_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'])) { |
||
| 554 | $strh_data = $info_riff['AVI ']['hdrl']['strl']['strh'][$i]['data']; |
||
| 555 | $strh_fcc_type = substr($strh_data, 0, 4); |
||
| 556 | |||
| 557 | if (isset($info_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) { |
||
| 558 | $strf_data = $info_riff['AVI ']['hdrl']['strl']['strf'][$i]['data']; |
||
| 559 | |||
| 560 | // shortcut |
||
| 561 | $info_riff_raw_strf_strh_fcc_type_stream_index = &$info_riff_raw['strf'][$strh_fcc_type][$stream_index]; |
||
| 562 | |||
| 563 | switch ($strh_fcc_type) { |
||
| 564 | case 'auds': |
||
| 565 | $info_audio['bitrate_mode'] = 'cbr'; |
||
| 566 | $info_audio_dataformat = 'wav'; |
||
| 567 | if (isset($info_riff_audio) && is_array($info_riff_audio)) { |
||
| 568 | $stream_index = count($info_riff_audio); |
||
| 569 | } |
||
| 570 | |||
| 571 | $info_riff_audio[$stream_index] = getid3_riff::RIFFparseWAVEFORMATex($strf_data); |
||
| 572 | $info_audio['wformattag'] = $info_riff_audio[$stream_index]['raw']['wFormatTag']; |
||
| 573 | |||
| 574 | // shortcut |
||
| 575 | $info_audio['streams'][$stream_index] = $info_riff_audio[$stream_index]; |
||
| 576 | $info_audio_streams_currentstream = &$info_audio['streams'][$stream_index]; |
||
| 577 | |||
| 578 | if (0 === @$info_audio_streams_currentstream['bits_per_sample']) { |
||
| 579 | unset($info_audio_streams_currentstream['bits_per_sample']); |
||
| 580 | } |
||
| 581 | $info_audio_streams_currentstream['wformattag'] = $info_audio_streams_currentstream['raw']['wFormatTag']; |
||
| 582 | unset($info_audio_streams_currentstream['raw']); |
||
| 583 | |||
| 584 | // shortcut |
||
| 585 | $info_riff_raw['strf'][$strh_fcc_type][$stream_index] = $info_riff_audio[$stream_index]['raw']; |
||
| 586 | |||
| 587 | unset($info_riff_audio[$stream_index]['raw']); |
||
| 588 | $info_audio = getid3_riff::array_merge_noclobber($info_audio, $info_riff_audio[$stream_index]); |
||
| 589 | |||
| 590 | $info_audio['lossless'] = false; |
||
| 591 | switch ($info_riff_raw_strf_strh_fcc_type_stream_index['wFormatTag']) { |
||
| 592 | case 0x0001: // PCM |
||
| 593 | $info_audio_dataformat = 'wav'; |
||
| 594 | $info_audio['lossless'] = true; |
||
| 595 | break; |
||
| 596 | |||
| 597 | case 0x0050: // MPEG Layer 2 or Layer 1 |
||
| 598 | $info_audio_dataformat = 'mp2'; // Assume Layer-2 |
||
| 599 | break; |
||
| 600 | |||
| 601 | case 0x0055: // MPEG Layer 3 |
||
| 602 | $info_audio_dataformat = 'mp3'; |
||
| 603 | break; |
||
| 604 | |||
| 605 | case 0x00FF: // AAC |
||
| 606 | $info_audio_dataformat = 'aac'; |
||
| 607 | break; |
||
| 608 | |||
| 609 | case 0x0161: // Windows Media v7 / v8 / v9 |
||
| 610 | case 0x0162: // Windows Media Professional v9 |
||
| 611 | case 0x0163: // Windows Media Lossess v9 |
||
| 612 | $info_audio_dataformat = 'wma'; |
||
| 613 | break; |
||
| 614 | |||
| 615 | case 0x2000: // AC-3 |
||
| 616 | $info_audio_dataformat = 'ac3'; |
||
| 617 | break; |
||
| 618 | |||
| 619 | case 0x2001: // DTS |
||
| 620 | $info_audio_dataformat = 'dts'; |
||
| 621 | break; |
||
| 622 | |||
| 623 | default: |
||
| 624 | $info_audio_dataformat = 'wav'; |
||
| 625 | break; |
||
| 626 | } |
||
| 627 | $info_audio_streams_currentstream['dataformat'] = $info_audio_dataformat; |
||
| 628 | $info_audio_streams_currentstream['lossless'] = $info_audio['lossless']; |
||
| 629 | $info_audio_streams_currentstream['bitrate_mode'] = $info_audio['bitrate_mode']; |
||
| 630 | break; |
||
| 631 | |||
| 632 | case 'iavs': |
||
| 633 | case 'vids': |
||
| 634 | // shortcut |
||
| 635 | $info_riff_raw['strh'][$i] = []; |
||
| 636 | $info_riff_raw_strh_current = &$info_riff_raw['strh'][$i]; |
||
| 637 | |||
| 638 | getid3_lib::ReadSequence( |
||
| 639 | $this->endian_function, |
||
| 640 | $info_riff_raw_strh_current, |
||
| 641 | $strh_data, |
||
| 642 | 0, |
||
| 643 | [ |
||
| 644 | 'fccType' => -4, // same as $strh_fcc_type; |
||
| 645 | 'fccHandler' => -4, |
||
| 646 | 'dwFlags' => 4, // Contains AVITF_* flags |
||
| 647 | 'wPriority' => 2, |
||
| 648 | 'wLanguage' => 2, |
||
| 649 | 'dwInitialFrames' => 4, |
||
| 650 | 'dwScale' => 4, |
||
| 651 | 'dwRate' => 4, |
||
| 652 | 'dwStart' => 4, |
||
| 653 | 'dwLength' => 4, |
||
| 654 | 'dwSuggestedBufferSize' => 4, |
||
| 655 | 'dwQuality' => 4, |
||
| 656 | 'dwSampleSize' => 4, |
||
| 657 | 'rcFrame' => 4 |
||
| 658 | ] |
||
| 659 | ); |
||
| 660 | |||
| 661 | $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strh_current['fccHandler']); |
||
| 662 | $info_video['fourcc'] = $info_riff_raw_strh_current['fccHandler']; |
||
| 663 | |||
| 664 | 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'])) { |
||
| 665 | $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']); |
||
| 666 | $info_video['fourcc'] = $info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']; |
||
| 667 | } |
||
| 668 | |||
| 669 | $info_video['codec'] = $info_riff_video_current['codec']; |
||
| 670 | $info_video['pixel_aspect_ratio'] = (float)1; |
||
| 671 | |||
| 672 | switch ($info_riff_raw_strh_current['fccHandler']) { |
||
| 673 | case 'HFYU': // Huffman Lossless Codec |
||
| 674 | case 'IRAW': // Intel YUV Uncompressed |
||
| 675 | case 'YUY2': // Uncompressed YUV 4:2:2 |
||
| 676 | $info_video['lossless'] = true; |
||
| 677 | break; |
||
| 678 | |||
| 679 | default: |
||
| 680 | $info_video['lossless'] = false; |
||
| 681 | break; |
||
| 682 | } |
||
| 683 | |||
| 684 | switch ($strh_fcc_type) { |
||
| 685 | case 'vids': |
||
| 686 | getid3_lib::ReadSequence( |
||
| 687 | $this->endian_function, |
||
| 688 | $info_riff_raw_strf_strh_fcc_type_stream_index, |
||
| 689 | $strf_data, |
||
| 690 | 0, |
||
| 691 | [ |
||
| 692 | 'biSize' => 4, |
||
| 693 | // number of bytes required by the BITMAPINFOHEADER structure |
||
| 694 | 'biWidth' => 4, |
||
| 695 | // width of the bitmap in pixels |
||
| 696 | 'biHeight' => 4, |
||
| 697 | // 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 |
||
| 698 | 'biPlanes' => 2, |
||
| 699 | // number of color planes on the target device. In most cases this value must be set to 1 |
||
| 700 | 'biBitCount' => 2, |
||
| 701 | // Specifies the number of bits per pixels |
||
| 702 | 'fourcc' => -4, |
||
| 703 | // |
||
| 704 | 'biSizeImage' => 4, |
||
| 705 | // size of the bitmap data section of the image (the actual pixel data, excluding BITMAPINFOHEADER and RGBQUAD structures) |
||
| 706 | 'biXPelsPerMeter' => 4, |
||
| 707 | // horizontal resolution, in pixels per metre, of the target device |
||
| 708 | 'biYPelsPerMeter' => 4, |
||
| 709 | // vertical resolution, in pixels per metre, of the target device |
||
| 710 | 'biClrUsed' => 4, |
||
| 711 | // 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 |
||
| 712 | 'biClrImportant' => 4 |
||
| 713 | // number of color indices that are considered important for displaying the bitmap. If this value is zero, all colors are important |
||
| 714 | ] |
||
| 715 | ); |
||
| 716 | |||
| 717 | $info_video['bits_per_sample'] = $info_riff_raw_strf_strh_fcc_type_stream_index['biBitCount']; |
||
| 718 | |||
| 719 | if ('DV' == $info_riff_video_current['codec']) { |
||
| 720 | $info_riff_video_current['dv_type'] = 2; |
||
| 721 | } |
||
| 722 | break; |
||
| 723 | |||
| 724 | case 'iavs': |
||
| 725 | $info_riff_video_current['dv_type'] = 1; |
||
| 726 | break; |
||
| 727 | } |
||
| 728 | break; |
||
| 729 | |||
| 730 | default: |
||
| 731 | $getid3->warning('Unhandled fccType for stream (' . $i . '): "' . $strh_fcc_type . '"'); |
||
| 732 | break; |
||
| 733 | } |
||
| 734 | } |
||
| 735 | } |
||
| 736 | |||
| 737 | 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'])) { |
||
| 738 | $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']); |
||
| 739 | $info_video['codec'] = $info_riff_video_current['codec']; |
||
| 740 | $info_video['fourcc'] = $info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']; |
||
| 741 | |||
| 742 | switch ($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']) { |
||
| 743 | case 'HFYU': // Huffman Lossless Codec |
||
| 744 | case 'IRAW': // Intel YUV Uncompressed |
||
| 745 | case 'YUY2': // Uncompressed YUV 4:2:2 |
||
| 746 | $info_video['lossless'] = true; |
||
| 747 | $info_video['bits_per_sample'] = 24; |
||
| 748 | break; |
||
| 749 | |||
| 750 | default: |
||
| 751 | $info_video['lossless'] = false; |
||
| 752 | $info_video['bits_per_sample'] = 24; |
||
| 753 | break; |
||
| 754 | } |
||
| 755 | } |
||
| 756 | } |
||
| 757 | } |
||
| 758 | } |
||
| 759 | break; |
||
| 760 | |||
| 761 | case 'CDDA': |
||
| 762 | $info_audio['bitrate_mode'] = 'cbr'; |
||
| 763 | $info_audio_dataformat = 'cda'; |
||
| 764 | $info_audio['lossless'] = true; |
||
| 765 | unset($getid3->info['mime_type']); |
||
| 766 | |||
| 767 | $info_avdataoffset = 44; |
||
| 768 | |||
| 769 | if (isset($info_riff['CDDA']['fmt '][0]['data'])) { |
||
| 770 | $info_riff_cdda_fmt_0 = &$info_riff['CDDA']['fmt '][0]; |
||
| 771 | |||
| 772 | getid3_lib::ReadSequence( |
||
| 773 | $this->endian_function, |
||
| 774 | $info_riff_cdda_fmt_0, |
||
| 775 | $info_riff_cdda_fmt_0['data'], |
||
| 776 | 0, |
||
| 777 | [ |
||
| 778 | 'unknown1' => 2, |
||
| 779 | 'track_num' => 2, |
||
| 780 | 'disc_id' => 4, |
||
| 781 | 'start_offset_frame' => 4, |
||
| 782 | 'playtime_frames' => 4, |
||
| 783 | 'unknown6' => 4, |
||
| 784 | 'unknown7' => 4 |
||
| 785 | ] |
||
| 786 | ); |
||
| 787 | |||
| 788 | $info_riff_cdda_fmt_0['start_offset_seconds'] = (float)$info_riff_cdda_fmt_0['start_offset_frame'] / 75; |
||
| 789 | $info_riff_cdda_fmt_0['playtime_seconds'] = (float)$info_riff_cdda_fmt_0['playtime_frames'] / 75; |
||
| 790 | $getid3->info['comments']['track'] = $info_riff_cdda_fmt_0['track_num']; |
||
| 791 | $getid3->info['playtime_seconds'] = $info_riff_cdda_fmt_0['playtime_seconds']; |
||
| 792 | |||
| 793 | // hardcoded data for CD-audio |
||
| 794 | $info_audio['sample_rate'] = 44100; |
||
| 795 | $info_audio['channels'] = 2; |
||
| 796 | $info_audio['bits_per_sample'] = 16; |
||
| 797 | $info_audio['bitrate'] = $info_audio['sample_rate'] * $info_audio['channels'] * $info_audio['bits_per_sample']; |
||
| 798 | $info_audio['bitrate_mode'] = 'cbr'; |
||
| 799 | } |
||
| 800 | break; |
||
| 801 | |||
| 802 | case 'AIFF': |
||
| 803 | case 'AIFC': |
||
| 804 | $info_audio['bitrate_mode'] = 'cbr'; |
||
| 805 | $info_audio_dataformat = 'aiff'; |
||
| 806 | $info_audio['lossless'] = true; |
||
| 807 | $getid3->info['mime_type'] = 'audio/x-aiff'; |
||
| 808 | |||
| 809 | if (isset($info_riff[$riff_sub_type]['SSND'][0]['offset'])) { |
||
| 810 | $info_avdataoffset = $info_riff[$riff_sub_type]['SSND'][0]['offset'] + 8; |
||
| 811 | $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['SSND'][0]['size']; |
||
| 812 | if ($info_avdataend > $getid3->info['filesize']) { |
||
| 813 | if (($info_avdataend == ($getid3->info['filesize'] + 1)) && (1 == ($getid3->info['filesize'] % 2))) { |
||
| 814 | // structures rounded to 2-byte boundary, but dumb encoders |
||
| 815 | // forget to pad end of file to make this actually work |
||
| 816 | } else { |
||
| 817 | $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'); |
||
| 818 | } |
||
| 819 | $info_avdataend = $getid3->info['filesize']; |
||
| 820 | } |
||
| 821 | } |
||
| 822 | |||
| 823 | if (isset($info_riff[$riff_sub_type]['COMM'][0]['data'])) { |
||
| 824 | // shortcut |
||
| 825 | $info_riff_RIFFsubtype_COMM_0_data = &$info_riff[$riff_sub_type]['COMM'][0]['data']; |
||
| 826 | |||
| 827 | $info_riff_audio['channels'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 0, 2)); |
||
| 828 | $info_riff_audio['total_samples'] = getid3_lib::BigEndian2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 2, 4)); |
||
| 829 | $info_riff_audio['bits_per_sample'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 6, 2)); |
||
| 830 | $info_riff_audio['sample_rate'] = (int)getid3_riff::BigEndian2Float(substr($info_riff_RIFFsubtype_COMM_0_data, 8, 10)); |
||
| 831 | |||
| 832 | if ($info_riff[$riff_sub_type]['COMM'][0]['size'] > 18) { |
||
| 833 | $info_riff_audio['codec_fourcc'] = substr($info_riff_RIFFsubtype_COMM_0_data, 18, 4); |
||
| 834 | $codec_name_size = getid3_lib::BigEndian2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 22, 1)); |
||
| 835 | $info_riff_audio['codec_name'] = substr($info_riff_RIFFsubtype_COMM_0_data, 23, $codec_name_size); |
||
| 836 | |||
| 837 | switch ($info_riff_audio['codec_name']) { |
||
| 838 | case 'NONE': |
||
| 839 | $info_audio['codec'] = 'Pulse Code Modulation (PCM)'; |
||
| 840 | $info_audio['lossless'] = true; |
||
| 841 | break; |
||
| 842 | |||
| 843 | case '': |
||
| 844 | switch ($info_riff_audio['codec_fourcc']) { |
||
| 845 | // http://developer.apple.com/qa/snd/snd07.html |
||
| 846 | case 'sowt': |
||
| 847 | $info_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM'; |
||
| 848 | $info_audio['lossless'] = true; |
||
| 849 | break; |
||
| 850 | |||
| 851 | case 'twos': |
||
| 852 | $info_riff_audio['codec_name'] = 'Two\'s Compliment Big-Endian PCM'; |
||
| 853 | $info_audio['lossless'] = true; |
||
| 854 | break; |
||
| 855 | |||
| 856 | default: |
||
| 857 | break; |
||
| 858 | } |
||
| 859 | break; |
||
| 860 | |||
| 861 | default: |
||
| 862 | $info_audio['codec'] = $info_riff_audio['codec_name']; |
||
| 863 | $info_audio['lossless'] = false; |
||
| 864 | break; |
||
| 865 | } |
||
| 866 | } |
||
| 867 | |||
| 868 | $info_audio['channels'] = $info_riff_audio['channels']; |
||
| 869 | |||
| 870 | if ($info_riff_audio['bits_per_sample'] > 0) { |
||
| 871 | $info_audio['bits_per_sample'] = $info_riff_audio['bits_per_sample']; |
||
| 872 | } |
||
| 873 | |||
| 874 | $info_audio['sample_rate'] = $info_riff_audio['sample_rate']; |
||
| 875 | $getid3->info['playtime_seconds'] = $info_riff_audio['total_samples'] / $info_audio['sample_rate']; |
||
| 876 | } |
||
| 877 | |||
| 878 | if (isset($info_riff[$riff_sub_type]['COMT'])) { |
||
| 879 | $comment_count = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], 0, 2)); |
||
| 880 | $offset = 2; |
||
| 881 | |||
| 882 | for ($i = 0; $i < $comment_count; $i++) { |
||
| 883 | $getid3->info['comments_raw'][$i]['timestamp'] = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 4)); |
||
| 884 | $offset += 4; |
||
| 885 | |||
| 886 | $getid3->info['comments_raw'][$i]['marker_id'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 2)); |
||
| 887 | $offset += 2; |
||
| 888 | |||
| 889 | $comment_length = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 2)); |
||
| 890 | $offset += 2; |
||
| 891 | |||
| 892 | $getid3->info['comments_raw'][$i]['comment'] = substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, $comment_length); |
||
| 893 | $offset += $comment_length; |
||
| 894 | |||
| 895 | $getid3->info['comments_raw'][$i]['timestamp_unix'] = getid3_riff::DateMac2Unix($getid3->info['comments_raw'][$i]['timestamp']); |
||
| 896 | $info_riff['comments']['comment'][] = $getid3->info['comments_raw'][$i]['comment']; |
||
| 897 | } |
||
| 898 | } |
||
| 899 | |||
| 900 | foreach (['NAME' => 'title', 'author' => 'artist', '(c) ' => 'copyright', 'ANNO' => 'comment'] as $key => $value) { |
||
| 901 | if (isset($info_riff[$riff_sub_type][$key][0]['data'])) { |
||
| 902 | $info_riff['comments'][$value][] = $info_riff[$riff_sub_type][$key][0]['data']; |
||
| 903 | } |
||
| 904 | } |
||
| 905 | break; |
||
| 906 | |||
| 907 | case '8SVX': |
||
| 908 | $info_audio['bitrate_mode'] = 'cbr'; |
||
| 909 | $info_audio_dataformat = '8svx'; |
||
| 910 | $info_audio['bits_per_sample'] = 8; |
||
| 911 | $info_audio['channels'] = 1; // overridden below, if need be |
||
| 912 | $getid3->info['mime_type'] = 'audio/x-aiff'; |
||
| 913 | |||
| 914 | if (isset($info_riff[$riff_sub_type]['BODY'][0]['offset'])) { |
||
| 915 | $info_avdataoffset = $info_riff[$riff_sub_type]['BODY'][0]['offset'] + 8; |
||
| 916 | $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['BODY'][0]['size']; |
||
| 917 | if ($info_avdataend > $getid3->info['filesize']) { |
||
| 918 | $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'); |
||
| 919 | } |
||
| 920 | } |
||
| 921 | |||
| 922 | if (isset($info_riff[$riff_sub_type]['VHDR'][0]['offset'])) { |
||
| 923 | // shortcut |
||
| 924 | $info_riff_riff_sub_type_vhdr_0 = &$info_riff[$riff_sub_type]['VHDR'][0]; |
||
| 925 | |||
| 926 | getid3_lib::ReadSequence( |
||
| 927 | 'BigEndian2Int', |
||
| 928 | $info_riff_riff_sub_type_vhdr_0, |
||
| 929 | $info_riff_riff_sub_type_vhdr_0['data'], |
||
| 930 | 0, |
||
| 931 | [ |
||
| 932 | 'oneShotHiSamples' => 4, |
||
| 933 | 'repeatHiSamples' => 4, |
||
| 934 | 'samplesPerHiCycle' => 4, |
||
| 935 | 'samplesPerSec' => 2, |
||
| 936 | 'ctOctave' => 1, |
||
| 937 | 'sCompression' => 1, |
||
| 938 | 'Volume' => -4 |
||
| 939 | ] |
||
| 940 | ); |
||
| 941 | |||
| 942 | $info_riff_riff_sub_type_vhdr_0['Volume'] = getid3_riff::FixedPoint16_16($info_riff_riff_sub_type_vhdr_0['Volume']); |
||
| 943 | |||
| 944 | $info_audio['sample_rate'] = $info_riff_riff_sub_type_vhdr_0['samplesPerSec']; |
||
| 945 | |||
| 946 | switch ($info_riff_riff_sub_type_vhdr_0['sCompression']) { |
||
| 947 | case 0: |
||
| 948 | $info_audio['codec'] = 'Pulse Code Modulation (PCM)'; |
||
| 949 | $info_audio['lossless'] = true; |
||
| 950 | $actual_bits_per_sample = 8; |
||
| 951 | break; |
||
| 952 | |||
| 953 | case 1: |
||
| 954 | $info_audio['codec'] = 'Fibonacci-delta encoding'; |
||
| 955 | $info_audio['lossless'] = false; |
||
| 956 | $actual_bits_per_sample = 4; |
||
| 957 | break; |
||
| 958 | |||
| 959 | default: |
||
| 960 | $getid3->warning('Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "' . sCompression . '"'); |
||
| 961 | break; |
||
| 962 | } |
||
| 963 | } |
||
| 964 | |||
| 965 | if (isset($info_riff[$riff_sub_type]['CHAN'][0]['data'])) { |
||
| 966 | $ChannelsIndex = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['CHAN'][0]['data'], 0, 4)); |
||
| 967 | switch ($ChannelsIndex) { |
||
| 968 | case 6: // Stereo |
||
| 969 | $info_audio['channels'] = 2; |
||
| 970 | break; |
||
| 971 | |||
| 972 | case 2: // Left channel only |
||
| 973 | case 4: // Right channel only |
||
| 974 | $info_audio['channels'] = 1; |
||
| 975 | break; |
||
| 976 | |||
| 977 | default: |
||
| 978 | $getid3->warning('Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "' . $ChannelsIndex . '"'); |
||
| 979 | break; |
||
| 980 | } |
||
| 981 | } |
||
| 982 | |||
| 983 | foreach (['NAME' => 'title', 'author' => 'artist', '(c) ' => 'copyright', 'ANNO' => 'comment'] as $key => $value) { |
||
| 984 | if (isset($info_riff[$riff_sub_type][$key][0]['data'])) { |
||
| 985 | $info_riff['comments'][$value][] = $info_riff[$riff_sub_type][$key][0]['data']; |
||
| 986 | } |
||
| 987 | } |
||
| 988 | |||
| 989 | $info_audio['bitrate'] = $info_audio['sample_rate'] * $actual_bits_per_sample * $info_audio['channels']; |
||
| 990 | if (!empty($info_audio['bitrate'])) { |
||
| 991 | $getid3->info['playtime_seconds'] = ($info_avdataend - $info_avdataoffset) / ($info_audio['bitrate'] / 8); |
||
| 992 | } |
||
| 993 | break; |
||
| 994 | |||
| 995 | case 'CDXA': |
||
| 996 | |||
| 997 | $getid3->info['mime_type'] = 'video/mpeg'; |
||
| 998 | if (!empty($info_riff['CDXA']['data'][0]['size'])) { |
||
| 999 | $GETID3_ERRORARRAY = &$getid3->info['warning']; |
||
| 1000 | |||
| 1001 | if (!$getid3->include_module_optional('audio-video.mpeg')) { |
||
| 1002 | $getid3->warning('MPEG skipped because mpeg module is missing.'); |
||
| 1003 | } else { |
||
| 1004 | // Clone getid3 - messing with offsets - better safe than sorry |
||
| 1005 | $clone = clone $getid3; |
||
| 1006 | |||
| 1007 | // Analyse |
||
| 1008 | $mpeg = new getid3_mpeg($clone); |
||
| 1009 | $mpeg->Analyze(); |
||
| 1010 | |||
| 1011 | // Import from clone and destroy |
||
| 1012 | $getid3->info['audio'] = $clone->info['audio']; |
||
| 1013 | $getid3->info['video'] = $clone->info['video']; |
||
| 1014 | $getid3->info['mpeg'] = $clone->info['mpeg']; |
||
| 1015 | $getid3->info['warning'] = $clone->info['warning']; |
||
| 1016 | |||
| 1017 | unset($clone); |
||
| 1018 | } |
||
| 1019 | } |
||
| 1020 | |||
| 1021 | break; |
||
| 1022 | |||
| 1023 | default: |
||
| 1024 | throw new getid3_exception('Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "' . $riff_sub_type . '" instead'); |
||
| 1025 | } |
||
| 1026 | |||
| 1027 | if (1 == @$info_riff_raw['fmt ']['wFormatTag']) { |
||
| 1028 | // http://www.mega-nerd.com/erikd/Blog/Windiots/dts.html |
||
| 1029 | $this->fseek($getid3->info['avdataoffset'], SEEK_SET); |
||
| 1030 | $bytes4 = $this->fread(4); |
||
| 1031 | |||
| 1032 | // DTSWAV |
||
| 1033 | if (preg_match('/^\xFF\x1F\x00\xE8/s', $bytes4)) { |
||
| 1034 | $info_audio_dataformat = 'dts'; |
||
| 1035 | } // DTS, but this probably shouldn't happen |
||
| 1036 | elseif (preg_match('/^\x7F\xFF\x80\x01/s', $bytes4)) { |
||
| 1037 | $info_audio_dataformat = 'dts'; |
||
| 1038 | } |
||
| 1039 | } |
||
| 1040 | |||
| 1041 | if (@is_array($info_riff_wave['DISP'])) { |
||
| 1042 | $info_riff['comments']['title'][] = trim(substr($info_riff_wave['DISP'][count($info_riff_wave['DISP']) - 1]['data'], 4)); |
||
| 1043 | } |
||
| 1044 | |||
| 1045 | if (@is_array($info_riff_wave['INFO'])) { |
||
| 1046 | getid3_riff::RIFFCommentsParse($info_riff_wave['INFO'], $info_riff['comments']); |
||
| 1047 | } |
||
| 1048 | |||
| 1049 | if (isset($info_riff_wave['INFO']) && is_array($info_riff_wave['INFO'])) { |
||
| 1050 | foreach ( |
||
| 1051 | [ |
||
| 1052 | 'IARL' => 'archivallocation', |
||
| 1053 | 'IART' => 'artist', |
||
| 1054 | 'ICDS' => 'costumedesigner', |
||
| 1055 | 'ICMS' => 'commissionedby', |
||
| 1056 | 'ICMT' => 'comment', |
||
| 1057 | 'ICNT' => 'country', |
||
| 1058 | 'ICOP' => 'copyright', |
||
| 1059 | 'ICRD' => 'creationdate', |
||
| 1060 | 'IDIM' => 'dimensions', |
||
| 1061 | 'IDIT' => 'digitizationdate', |
||
| 1062 | 'IDPI' => 'resolution', |
||
| 1063 | 'IDST' => 'distributor', |
||
| 1064 | 'IEDT' => 'editor', |
||
| 1065 | 'IENG' => 'engineers', |
||
| 1066 | 'IFRM' => 'accountofparts', |
||
| 1067 | 'IGNR' => 'genre', |
||
| 1068 | 'IKEY' => 'keywords', |
||
| 1069 | 'ILGT' => 'lightness', |
||
| 1070 | 'ILNG' => 'language', |
||
| 1071 | 'IMED' => 'orignalmedium', |
||
| 1072 | 'IMUS' => 'composer', |
||
| 1073 | 'INAM' => 'title', |
||
| 1074 | 'IPDS' => 'productiondesigner', |
||
| 1075 | 'IPLT' => 'palette', |
||
| 1076 | 'IPRD' => 'product', |
||
| 1077 | 'IPRO' => 'producer', |
||
| 1078 | 'IPRT' => 'part', |
||
| 1079 | 'IRTD' => 'rating', |
||
| 1080 | 'ISBJ' => 'subject', |
||
| 1081 | 'ISFT' => 'software', |
||
| 1082 | 'ISGN' => 'secondarygenre', |
||
| 1083 | 'ISHP' => 'sharpness', |
||
| 1084 | 'ISRC' => 'sourcesupplier', |
||
| 1085 | 'ISRF' => 'digitizationsource', |
||
| 1086 | 'ISTD' => 'productionstudio', |
||
| 1087 | 'ISTR' => 'starring', |
||
| 1088 | 'ITCH' => 'encoded_by', |
||
| 1089 | 'IWEB' => 'url', |
||
| 1090 | 'IWRI' => 'writer' |
||
| 1091 | ] as $key => $value |
||
| 1092 | ) { |
||
| 1093 | if (isset($info_riff_wave['INFO'][$key])) { |
||
| 1094 | foreach ($info_riff_wave['INFO'][$key] as $comment_id => $comment_data) { |
||
| 1095 | if ('' != trim($comment_data['data'])) { |
||
| 1096 | $info_riff['comments'][$value][] = trim($comment_data['data']); |
||
| 1097 | } |
||
| 1098 | } |
||
| 1099 | } |
||
| 1100 | } |
||
| 1101 | } |
||
| 1102 | |||
| 1103 | if (empty($info_audio['encoder']) && !empty($getid3->info['mpeg']['audio']['LAME']['short_version'])) { |
||
| 1104 | $info_audio['encoder'] = $getid3->info['mpeg']['audio']['LAME']['short_version']; |
||
| 1105 | } |
||
| 1106 | |||
| 1107 | if (!isset($getid3->info['playtime_seconds'])) { |
||
| 1108 | $getid3->info['playtime_seconds'] = 0; |
||
| 1109 | } |
||
| 1110 | |||
| 1111 | if (isset($info_riff_raw['avih']['dwTotalFrames']) && isset($info_riff_raw['avih']['dwMicroSecPerFrame'])) { |
||
| 1112 | $getid3->info['playtime_seconds'] = $info_riff_raw['avih']['dwTotalFrames'] * ($info_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000); |
||
| 1113 | } |
||
| 1114 | |||
| 1115 | if ($getid3->info['playtime_seconds'] > 0) { |
||
| 1116 | if (isset($info_riff_audio) && isset($info_riff_video)) { |
||
| 1117 | if (!isset($getid3->info['bitrate'])) { |
||
| 1118 | $getid3->info['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8); |
||
| 1119 | } |
||
| 1120 | } elseif (isset($info_riff_audio) && !isset($info_riff_video)) { |
||
| 1121 | if (!isset($info_audio['bitrate'])) { |
||
| 1122 | $info_audio['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8); |
||
| 1123 | } |
||
| 1124 | } elseif (!isset($info_riff_audio) && isset($info_riff_video)) { |
||
| 1125 | if (!isset($info_video['bitrate'])) { |
||
| 1126 | $info_video['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8); |
||
| 1127 | } |
||
| 1128 | } |
||
| 1129 | } |
||
| 1130 | |||
| 1131 | if (isset($info_riff_video) && isset($info_audio['bitrate']) && ($info_audio['bitrate'] > 0) && ($getid3->info['playtime_seconds'] > 0)) { |
||
| 1132 | $getid3->info['bitrate'] = ((($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds']) * 8); |
||
| 1133 | $info_audio['bitrate'] = 0; |
||
| 1134 | $info_video['bitrate'] = $getid3->info['bitrate']; |
||
| 1135 | foreach ($info_riff_audio as $channelnumber => $audioinfoarray) { |
||
| 1136 | $info_video['bitrate'] -= $audioinfoarray['bitrate']; |
||
| 1137 | $info_audio['bitrate'] += $audioinfoarray['bitrate']; |
||
| 1138 | } |
||
| 1139 | if ($info_video['bitrate'] <= 0) { |
||
| 1140 | unset($info_video['bitrate']); |
||
| 1141 | } |
||
| 1142 | if ($info_audio['bitrate'] <= 0) { |
||
| 1143 | unset($info_audio['bitrate']); |
||
| 1144 | } |
||
| 1145 | } |
||
| 1146 | |||
| 1147 | if (isset($getid3->info['mpeg']['audio'])) { |
||
| 1148 | $info_audio_dataformat = 'mp' . $getid3->info['mpeg']['audio']['layer']; |
||
| 1149 | $info_audio['sample_rate'] = $getid3->info['mpeg']['audio']['sample_rate']; |
||
| 1150 | $info_audio['channels'] = $getid3->info['mpeg']['audio']['channels']; |
||
| 1151 | $info_audio['bitrate'] = $getid3->info['mpeg']['audio']['bitrate']; |
||
| 1152 | $info_audio['bitrate_mode'] = strtolower($getid3->info['mpeg']['audio']['bitrate_mode']); |
||
| 1153 | |||
| 1154 | if (!empty($getid3->info['mpeg']['audio']['codec'])) { |
||
| 1155 | $info_audio['codec'] = $getid3->info['mpeg']['audio']['codec'] . ' ' . $info_audio['codec']; |
||
| 1156 | } |
||
| 1157 | |||
| 1158 | if (!empty($info_audio['streams'])) { |
||
| 1159 | foreach ($info_audio['streams'] as $streamnumber => $streamdata) { |
||
| 1160 | if ($streamdata['dataformat'] == $info_audio_dataformat) { |
||
| 1161 | $info_audio['streams'][$streamnumber]['sample_rate'] = $info_audio['sample_rate']; |
||
| 1162 | $info_audio['streams'][$streamnumber]['channels'] = $info_audio['channels']; |
||
| 1163 | $info_audio['streams'][$streamnumber]['bitrate'] = $info_audio['bitrate']; |
||
| 1164 | $info_audio['streams'][$streamnumber]['bitrate_mode'] = $info_audio['bitrate_mode']; |
||
| 1165 | $info_audio['streams'][$streamnumber]['codec'] = $info_audio['codec']; |
||
| 1166 | } |
||
| 1167 | } |
||
| 1168 | } |
||
| 1169 | $info_audio['encoder_options'] = getid3_mp3::GuessEncoderOptions($getid3->info); |
||
| 1170 | } |
||
| 1171 | |||
| 1172 | if (!empty($info_riff_raw['fmt ']['wBitsPerSample']) && ($info_riff_raw['fmt ']['wBitsPerSample'] > 0)) { |
||
| 1173 | switch ($info_audio_dataformat) { |
||
| 1174 | case 'ac3': |
||
| 1175 | // ignore bits_per_sample |
||
| 1176 | break; |
||
| 1177 | |||
| 1178 | default: |
||
| 1179 | $info_audio['bits_per_sample'] = $info_riff_raw['fmt ']['wBitsPerSample']; |
||
| 1180 | break; |
||
| 1181 | } |
||
| 1182 | } |
||
| 1183 | |||
| 1184 | if (empty($info_riff_raw)) { |
||
| 1185 | unset($info_riff['raw']); |
||
| 1186 | } |
||
| 1187 | if (empty($info_riff_audio)) { |
||
| 1188 | unset($info_riff['audio']); |
||
| 1189 | } |
||
| 1190 | if (empty($info_riff_video)) { |
||
| 1191 | unset($info_riff['video']); |
||
| 1192 | } |
||
| 1193 | if (empty($info_audio_dataformat)) { |
||
| 1194 | unset($info_audio['dataformat']); |
||
| 1195 | } |
||
| 1196 | if (empty($getid3->info['audio'])) { |
||
| 1197 | unset($getid3->info['audio']); |
||
| 1198 | } |
||
| 1199 | if (empty($info_video)) { |
||
| 1200 | unset($getid3->info['video']); |
||
| 1201 | } |
||
| 1202 | |||
| 1203 | return true; |
||
| 1204 | } |
||
| 2315 |