Make WordPress Core


Ignore:
Timestamp:
09/14/2019 07:06:09 PM (6 years ago)
Author:
jorbin
Message:

Update getID3 library to fix issues with PHP7.4

Updates to trunk version that includes fixes for PHP7.4

Changelog:
https://github.com/JamesHeinrich/getID3/compare/v1.9.14...00f3fbfd77e583099ca70a3cf0bc092e113d2b20

See: #47751,#47783.
Fixes: #48040.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ID3/module.audio.ac3.php

    r41196 r46112  
    11<?php
     2
    23/////////////////////////////////////////////////////////////////
    34/// 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                            //
    99/////////////////////////////////////////////////////////////////
    1010//                                                             //
     
    1818class getid3_ac3 extends getid3_handler
    1919{
    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     */
    2535    public function Analyze() {
    2636        $info = &$this->getid3->info;
     
    188198
    189199
    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.');
    191201            $info['audio']['dataformat'] = 'eac3';
    192202
     
    413423
    414424            $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             unset($info['ac3']);
     425            unset($info['ac3']);
    416426            return false;
    417427
     
    432442            $thisfile_ac3['bitrate']      = self::bitrateLookup($thisfile_ac3_raw_bsi['frmsizecod']);
    433443        } 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!
    436446            $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;
    439449        }
    440450        $info['audio']['bitrate'] = $thisfile_ac3['bitrate'];
    441451
    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        }
    443455        $ac3_coding_mode = self::audioCodingModeLookup($thisfile_ac3_raw_bsi['acmod']);
    444456        foreach($ac3_coding_mode as $key => $value) {
     
    471483    }
    472484
     485    /**
     486     * @param int $length
     487     *
     488     * @return float|int
     489     */
    473490    private function readHeaderBSI($length) {
    474491        $data = substr($this->AC3header['bsi'], $this->BSIoffset, $length);
     
    478495    }
    479496
     497    /**
     498     * @param int $fscod
     499     *
     500     * @return int|string|false
     501     */
    480502    public static function sampleRateCodeLookup($fscod) {
    481503        static $sampleRateCodeLookup = array(
     
    488510    }
    489511
     512    /**
     513     * @param int $fscod2
     514     *
     515     * @return int|string|false
     516     */
    490517    public static function sampleRateCodeLookup2($fscod2) {
    491518        static $sampleRateCodeLookup2 = array(
     
    498525    }
    499526
     527    /**
     528     * @param int $bsmod
     529     * @param int $acmod
     530     *
     531     * @return string|false
     532     */
    500533    public static function serviceTypeLookup($bsmod, $acmod) {
    501534        static $serviceTypeLookup = array();
     
    519552    }
    520553
     554    /**
     555     * @param int $acmod
     556     *
     557     * @return array|false
     558     */
    521559    public static function audioCodingModeLookup($acmod) {
    522560        // array(channel configuration, # channels (not incl LFE), channel order)
     
    534572    }
    535573
     574    /**
     575     * @param int $cmixlev
     576     *
     577     * @return int|float|string|false
     578     */
    536579    public static function centerMixLevelLookup($cmixlev) {
    537580        static $centerMixLevelLookup;
     
    547590    }
    548591
     592    /**
     593     * @param int $surmixlev
     594     *
     595     * @return int|float|string|false
     596     */
    549597    public static function surroundMixLevelLookup($surmixlev) {
    550598        static $surroundMixLevelLookup;
     
    560608    }
    561609
     610    /**
     611     * @param int $dsurmod
     612     *
     613     * @return string|false
     614     */
    562615    public static function dolbySurroundModeLookup($dsurmod) {
    563616        static $dolbySurroundModeLookup = array(
     
    570623    }
    571624
     625    /**
     626     * @param int  $acmod
     627     * @param bool $lfeon
     628     *
     629     * @return array
     630     */
    572631    public static function channelsEnabledLookup($acmod, $lfeon) {
    573632        $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),
    578637            'center'=>(bool) ($acmod & 0x01),
    579638            'surround_mono'=>false,
     
    595654    }
    596655
     656    /**
     657     * @param int $compre
     658     *
     659     * @return float|int
     660     */
    597661    public static function heavyCompression($compre) {
    598662        // The first four bits indicate gain changes in 6.02dB increments which can be
     
    624688
    625689        $fourbit = str_pad(decbin(($compre & 0xF0) >> 4), 4, '0', STR_PAD_LEFT);
    626         if ($fourbit{0} == '1') {
     690        if ($fourbit[0] == '1') {
    627691            $log_gain = -8 + bindec(substr($fourbit, 1));
    628692        } else {
     
    645709    }
    646710
     711    /**
     712     * @param int $roomtyp
     713     *
     714     * @return string|false
     715     */
    647716    public static function roomTypeLookup($roomtyp) {
    648717        static $roomTypeLookup = array(
     
    655724    }
    656725
     726    /**
     727     * @param int $frmsizecod
     728     * @param int $fscod
     729     *
     730     * @return int|false
     731     */
    657732    public static function frameSizeLookup($frmsizecod, $fscod) {
    658733        // LSB is whether padding is used or not
     
    684759            );
    685760        }
     761        $paddingBytes = 0;
    686762        if (($fscod == 1) && $padding) {
    687763            // 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     */
    693775    public static function bitrateLookup($frmsizecod) {
    694776        // LSB is whether padding is used or not
     
    720802    }
    721803
     804    /**
     805     * @param int $numblkscod
     806     *
     807     * @return int|false
     808     */
    722809    public static function blocksPerSyncFrame($numblkscod) {
    723810        static $blocksPerSyncFrameLookup = array(
Note: See TracChangeset for help on using the changeset viewer.