Changeset 46112 for trunk/src/wp-includes/ID3/module.audio.flac.php
- Timestamp:
- 09/14/2019 07:06:09 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/module.audio.flac.php
r32979 r46112 1 1 <?php 2 2 3 ///////////////////////////////////////////////////////////////// 3 4 /// getID3() by James Heinrich <info@getid3.org> // 4 // available at http://getid3.sourceforge.net // 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 7 ///////////////////////////////////////////////////////////////// 8 // See readme.txt for more details // 5 // available at https://github.com/JamesHeinrich/getID3 // 6 // or https://www.getid3.org // 7 // or http://getid3.sourceforge.net // 8 // see readme.txt for more details // 9 9 ///////////////////////////////////////////////////////////////// 10 10 // // … … 25 25 const syncword = 'fLaC'; 26 26 27 /** 28 * @return bool 29 */ 27 30 public function Analyze() { 28 31 $info = &$this->getid3->info; … … 42 45 } 43 46 47 /** 48 * @return bool 49 */ 44 50 public function parseMETAdata() { 45 51 $info = &$this->getid3->info; … … 47 53 $BlockOffset = $this->ftell(); 48 54 $BlockHeader = $this->fread(4); 49 $LBFBT = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1)); 55 $LBFBT = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1)); // LBFBT = LastBlockFlag + BlockType 50 56 $LastBlockFlag = (bool) ($LBFBT & 0x80); 51 57 $BlockType = ($LBFBT & 0x7F); … … 54 60 55 61 if (($BlockOffset + 4 + $BlockLength) > $info['avdataend']) { 56 $this-> error('METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockTypeText.') at offset '.$BlockOffset.' extends beyond end of file');62 $this->warning('METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockTypeText.') at offset '.$BlockOffset.' extends beyond end of file'); 57 63 break; 58 64 } 59 65 if ($BlockLength < 1) { 66 if ($BlockTypeText != 'reserved') { 67 // probably supposed to be zero-length 68 $this->warning('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockTypeText.') at offset '.$BlockOffset.' is zero bytes'); 69 continue; 70 } 60 71 $this->error('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockLength.') at offset '.$BlockOffset.' is invalid'); 61 72 break; … … 168 179 169 180 if ($info['flac']['STREAMINFO']['audio_signature'] === str_repeat("\x00", 16)) { 170 181 $this->warning('FLAC STREAMINFO.audio_signature is null (known issue with libOggFLAC)'); 171 182 } 172 183 else { … … 195 206 } 196 207 197 private function parseSTREAMINFO($BlockData) { 198 $info = &$this->getid3->info; 199 200 $info['flac']['STREAMINFO'] = array(); 201 $streaminfo = &$info['flac']['STREAMINFO']; 202 208 209 /** 210 * @param string $BlockData 211 * 212 * @return array 213 */ 214 public static function parseSTREAMINFOdata($BlockData) { 215 $streaminfo = array(); 203 216 $streaminfo['min_block_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 0, 2)); 204 217 $streaminfo['max_block_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 2, 2)); … … 212 225 $streaminfo['samples_stream'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 28, 36)); 213 226 214 $streaminfo['audio_signature'] = substr($BlockData, 18, 16); 215 216 if (!empty($streaminfo['sample_rate'])) { 227 $streaminfo['audio_signature'] = substr($BlockData, 18, 16); 228 229 return $streaminfo; 230 } 231 232 /** 233 * @param string $BlockData 234 * 235 * @return bool 236 */ 237 private function parseSTREAMINFO($BlockData) { 238 $info = &$this->getid3->info; 239 240 $info['flac']['STREAMINFO'] = self::parseSTREAMINFOdata($BlockData); 241 242 if (!empty($info['flac']['STREAMINFO']['sample_rate'])) { 217 243 218 244 $info['audio']['bitrate_mode'] = 'vbr'; 219 $info['audio']['sample_rate'] = $ streaminfo['sample_rate'];220 $info['audio']['channels'] = $ streaminfo['channels'];221 $info['audio']['bits_per_sample'] = $ streaminfo['bits_per_sample'];222 $info['playtime_seconds'] = $ streaminfo['samples_stream'] / $streaminfo['sample_rate'];245 $info['audio']['sample_rate'] = $info['flac']['STREAMINFO']['sample_rate']; 246 $info['audio']['channels'] = $info['flac']['STREAMINFO']['channels']; 247 $info['audio']['bits_per_sample'] = $info['flac']['STREAMINFO']['bits_per_sample']; 248 $info['playtime_seconds'] = $info['flac']['STREAMINFO']['samples_stream'] / $info['flac']['STREAMINFO']['sample_rate']; 223 249 if ($info['playtime_seconds'] > 0) { 224 250 if (!$this->isDependencyFor('matroska')) { … … 237 263 } 238 264 265 /** 266 * @param string $BlockData 267 * 268 * @return bool 269 */ 239 270 private function parseAPPLICATION($BlockData) { 240 271 $info = &$this->getid3->info; … … 247 278 } 248 279 280 /** 281 * @param string $BlockData 282 * 283 * @return bool 284 */ 249 285 private function parseSEEKTABLE($BlockData) { 250 286 $info = &$this->getid3->info; … … 276 312 } 277 313 314 /** 315 * @param string $BlockData 316 * 317 * @return bool 318 */ 278 319 private function parseVORBIS_COMMENT($BlockData) { 279 320 $info = &$this->getid3->info; … … 295 336 } 296 337 338 /** 339 * @param string $BlockData 340 * 341 * @return bool 342 */ 297 343 private function parseCUESHEET($BlockData) { 298 344 $info = &$this->getid3->info; … … 347 393 348 394 /** 349 * Parse METADATA_BLOCK_PICTURE flac structure and extract attachment 350 * External usage: audio.ogg 351 */ 395 * Parse METADATA_BLOCK_PICTURE flac structure and extract attachment 396 * External usage: audio.ogg 397 * 398 * @return bool 399 */ 352 400 public function parsePICTURE() { 353 401 $info = &$this->getid3->info; … … 381 429 } 382 430 431 /** 432 * @param int $blocktype 433 * 434 * @return string 435 */ 383 436 public static function metaBlockTypeLookup($blocktype) { 384 437 static $lookup = array( … … 394 447 } 395 448 449 /** 450 * @param int $applicationid 451 * 452 * @return string 453 */ 396 454 public static function applicationIDLookup($applicationid) { 397 455 // http://flac.sourceforge.net/id.html … … 424 482 } 425 483 484 /** 485 * @param int $type_id 486 * 487 * @return string 488 */ 426 489 public static function pictureTypeLookup($type_id) { 427 490 static $lookup = array (
Note: See TracChangeset
for help on using the changeset viewer.