Changeset 46112 for trunk/src/wp-includes/ID3/module.audio.ac3.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.ac3.php
r41196 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 // // … … 18 18 class getid3_ac3 extends getid3_handler 19 19 { 20 private $AC3header = array(); 21 private $BSIoffset = 0; 22 23 const syncword = 0x0B77; 24 20 /** 21 * @var array 22 */ 23 private $AC3header = array(); 24 25 /** 26 * @var int 27 */ 28 private $BSIoffset = 0; 29 30 const syncword = 0x0B77; 31 32 /** 33 * @return bool 34 */ 25 35 public function Analyze() { 26 36 $info = &$this->getid3->info; … … 188 198 189 199 190 $this->error('E-AC3 parsing is incomplete and experimental in this version of getID3 ('.$this->getid3->version().'). Notably the bitrate calculations are wrong -- value might (or not) be correct, but it is not calculated correctly. Email info@getid3.org if you know how to calculate EAC3 bitrate correctly.');200 $this->error('E-AC3 parsing is incomplete and experimental in this version of getID3 ('.$this->getid3->version().'). Notably the bitrate calculations are wrong -- value might (or not) be correct, but it is not calculated correctly. Email info@getid3.org if you know how to calculate EAC3 bitrate correctly.'); 191 201 $info['audio']['dataformat'] = 'eac3'; 192 202 … … 413 423 414 424 $this->error('Bit stream identification is version '.$thisfile_ac3_raw_bsi['bsid'].', but getID3() only understands up to version 16. Please submit a support ticket with a sample file.'); 415 425 unset($info['ac3']); 416 426 return false; 417 427 … … 432 442 $thisfile_ac3['bitrate'] = self::bitrateLookup($thisfile_ac3_raw_bsi['frmsizecod']); 433 443 } elseif (!empty($thisfile_ac3_raw_bsi['frmsiz'])) { 434 // this isn't right, but it's (usually) close, roughly 5% less than it should be.435 // but WHERE is the actual bitrate value stored in EAC3?? email info@getid3.org if you know!444 // this isn't right, but it's (usually) close, roughly 5% less than it should be. 445 // but WHERE is the actual bitrate value stored in EAC3?? email info@getid3.org if you know! 436 446 $thisfile_ac3['bitrate'] = ($thisfile_ac3_raw_bsi['frmsiz'] + 1) * 16 * 30; // The frmsiz field shall contain a value one less than the overall size of the coded syncframe in 16-bit words. That is, this field may assume a value ranging from 0 to 2047, and these values correspond to syncframe sizes ranging from 1 to 2048. 437 // kludge-fix to make it approximately the expected value, still not "right":438 $thisfile_ac3['bitrate'] = round(($thisfile_ac3['bitrate'] * 1.05) / 16000) * 16000;447 // kludge-fix to make it approximately the expected value, still not "right": 448 $thisfile_ac3['bitrate'] = round(($thisfile_ac3['bitrate'] * 1.05) / 16000) * 16000; 439 449 } 440 450 $info['audio']['bitrate'] = $thisfile_ac3['bitrate']; 441 451 442 $thisfile_ac3['service_type'] = self::serviceTypeLookup($thisfile_ac3_raw_bsi['bsmod'], $thisfile_ac3_raw_bsi['acmod']); 452 if (isset($thisfile_ac3_raw_bsi['bsmod']) && isset($thisfile_ac3_raw_bsi['acmod'])) { 453 $thisfile_ac3['service_type'] = self::serviceTypeLookup($thisfile_ac3_raw_bsi['bsmod'], $thisfile_ac3_raw_bsi['acmod']); 454 } 443 455 $ac3_coding_mode = self::audioCodingModeLookup($thisfile_ac3_raw_bsi['acmod']); 444 456 foreach($ac3_coding_mode as $key => $value) { … … 471 483 } 472 484 485 /** 486 * @param int $length 487 * 488 * @return float|int 489 */ 473 490 private function readHeaderBSI($length) { 474 491 $data = substr($this->AC3header['bsi'], $this->BSIoffset, $length); … … 478 495 } 479 496 497 /** 498 * @param int $fscod 499 * 500 * @return int|string|false 501 */ 480 502 public static function sampleRateCodeLookup($fscod) { 481 503 static $sampleRateCodeLookup = array( … … 488 510 } 489 511 512 /** 513 * @param int $fscod2 514 * 515 * @return int|string|false 516 */ 490 517 public static function sampleRateCodeLookup2($fscod2) { 491 518 static $sampleRateCodeLookup2 = array( … … 498 525 } 499 526 527 /** 528 * @param int $bsmod 529 * @param int $acmod 530 * 531 * @return string|false 532 */ 500 533 public static function serviceTypeLookup($bsmod, $acmod) { 501 534 static $serviceTypeLookup = array(); … … 519 552 } 520 553 554 /** 555 * @param int $acmod 556 * 557 * @return array|false 558 */ 521 559 public static function audioCodingModeLookup($acmod) { 522 560 // array(channel configuration, # channels (not incl LFE), channel order) … … 534 572 } 535 573 574 /** 575 * @param int $cmixlev 576 * 577 * @return int|float|string|false 578 */ 536 579 public static function centerMixLevelLookup($cmixlev) { 537 580 static $centerMixLevelLookup; … … 547 590 } 548 591 592 /** 593 * @param int $surmixlev 594 * 595 * @return int|float|string|false 596 */ 549 597 public static function surroundMixLevelLookup($surmixlev) { 550 598 static $surroundMixLevelLookup; … … 560 608 } 561 609 610 /** 611 * @param int $dsurmod 612 * 613 * @return string|false 614 */ 562 615 public static function dolbySurroundModeLookup($dsurmod) { 563 616 static $dolbySurroundModeLookup = array( … … 570 623 } 571 624 625 /** 626 * @param int $acmod 627 * @param bool $lfeon 628 * 629 * @return array 630 */ 572 631 public static function channelsEnabledLookup($acmod, $lfeon) { 573 632 $lookup = array( 574 'ch1'=>( bool) ($acmod == 0),575 'ch2'=>( bool) ($acmod == 0),576 'left'=>( bool) ($acmod > 1),577 'right'=>( bool) ($acmod > 1),633 'ch1'=>($acmod == 0), 634 'ch2'=>($acmod == 0), 635 'left'=>($acmod > 1), 636 'right'=>($acmod > 1), 578 637 'center'=>(bool) ($acmod & 0x01), 579 638 'surround_mono'=>false, … … 595 654 } 596 655 656 /** 657 * @param int $compre 658 * 659 * @return float|int 660 */ 597 661 public static function heavyCompression($compre) { 598 662 // The first four bits indicate gain changes in 6.02dB increments which can be … … 624 688 625 689 $fourbit = str_pad(decbin(($compre & 0xF0) >> 4), 4, '0', STR_PAD_LEFT); 626 if ($fourbit {0}== '1') {690 if ($fourbit[0] == '1') { 627 691 $log_gain = -8 + bindec(substr($fourbit, 1)); 628 692 } else { … … 645 709 } 646 710 711 /** 712 * @param int $roomtyp 713 * 714 * @return string|false 715 */ 647 716 public static function roomTypeLookup($roomtyp) { 648 717 static $roomTypeLookup = array( … … 655 724 } 656 725 726 /** 727 * @param int $frmsizecod 728 * @param int $fscod 729 * 730 * @return int|false 731 */ 657 732 public static function frameSizeLookup($frmsizecod, $fscod) { 658 733 // LSB is whether padding is used or not … … 684 759 ); 685 760 } 761 $paddingBytes = 0; 686 762 if (($fscod == 1) && $padding) { 687 763 // frame lengths are padded by 1 word (16 bits) at 44100 688 $frameSizeLookup[$frmsizecod] += 2; 689 } 690 return (isset($frameSizeLookup[$framesizeid][$fscod]) ? $frameSizeLookup[$framesizeid][$fscod] : false); 691 } 692 764 // (fscode==1) means 44100Hz (see sampleRateCodeLookup) 765 $paddingBytes = 2; 766 } 767 return (isset($frameSizeLookup[$framesizeid][$fscod]) ? $frameSizeLookup[$framesizeid][$fscod] + $paddingBytes : false); 768 } 769 770 /** 771 * @param int $frmsizecod 772 * 773 * @return int|false 774 */ 693 775 public static function bitrateLookup($frmsizecod) { 694 776 // LSB is whether padding is used or not … … 720 802 } 721 803 804 /** 805 * @param int $numblkscod 806 * 807 * @return int|false 808 */ 722 809 public static function blocksPerSyncFrame($numblkscod) { 723 810 static $blocksPerSyncFrameLookup = array(
Note: See TracChangeset
for help on using the changeset viewer.