WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/11/2014 07:06:33 PM (5 years ago)
Author:
wonderboymusic
Message:

Update getID3 library to 1.9.8.

Changes:
https://github.com/JamesHeinrich/getID3/compare/1.9.7...v1.9.8

Fixes #29627.

File:
1 edited

Legend:

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

    r23766 r29734  
    44//  available at http://getid3.sourceforge.net                 //
    55//            or http://www.getid3.org                         //
     6//          also https://github.com/JamesHeinrich/getID3       //
    67/////////////////////////////////////////////////////////////////
    78// See readme.txt for more details                             //
     
    9697            // Not sure what version of LAME this is - look in padding of last frame for longer version string
    9798            $PossibleLAMEversionStringOffset = $info['avdataend'] - $PossiblyLongerLAMEversion_FrameLength;
    98             fseek($this->getid3->fp, $PossibleLAMEversionStringOffset);
    99             $PossiblyLongerLAMEversion_Data = fread($this->getid3->fp, $PossiblyLongerLAMEversion_FrameLength);
     99            $this->fseek($PossibleLAMEversionStringOffset);
     100            $PossiblyLongerLAMEversion_Data = $this->fread($PossiblyLongerLAMEversion_FrameLength);
    100101            switch (substr($CurrentDataLAMEversionString, -1)) {
    101102                case 'a':
     
    423424        }
    424425
    425         if (fseek($this->getid3->fp, $offset, SEEK_SET) != 0) {
     426        if ($this->fseek($offset) != 0) {
    426427            $info['error'][] = 'decodeMPEGaudioHeader() failed to seek to next offset at '.$offset;
    427428            return false;
    428429        }
    429         //$headerstring = fread($this->getid3->fp, 1441); // worst-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame
    430         $headerstring = fread($this->getid3->fp, 226); // LAME header at offset 36 + 190 bytes of Xing/LAME data
     430        //$headerstring = $this->fread(1441); // worst-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame
     431        $headerstring = $this->fread(226); // LAME header at offset 36 + 190 bytes of Xing/LAME data
    431432
    432433        // MP3 audio frame structure:
     
    891892        if (($ExpectedNumberOfAudioBytes > 0) && ($ExpectedNumberOfAudioBytes != ($info['avdataend'] - $info['avdataoffset']))) {
    892893            if ($ExpectedNumberOfAudioBytes > ($info['avdataend'] - $info['avdataoffset'])) {
    893                 if (isset($info['fileformat']) && ($info['fileformat'] == 'riff')) {
     894                if ($this->isDependencyFor('matroska') || $this->isDependencyFor('riff')) {
    894895                    // ignore, audio data is broken into chunks so will always be data "missing"
    895                 } elseif (($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])) == 1) {
    896                     $info['warning'][] = 'Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)';
    897                 } else {
    898                     $info['warning'][] = 'Probable truncated file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, only found '.($info['avdataend'] - $info['avdataoffset']).' (short by '.($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])).' bytes)';
     896                }
     897                elseif (($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])) == 1) {
     898                    $this->warning('Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)');
     899                }
     900                else {
     901                    $this->warning('Probable truncated file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, only found '.($info['avdataend'] - $info['avdataoffset']).' (short by '.($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])).' bytes)');
    899902                }
    900903            } else {
    901904                if ((($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes) == 1) {
    902                 //  $prenullbytefileoffset = ftell($this->getid3->fp);
    903                 //  fseek($this->getid3->fp, $info['avdataend'], SEEK_SET);
    904                 //  $PossibleNullByte = fread($this->getid3->fp, 1);
    905                 //  fseek($this->getid3->fp, $prenullbytefileoffset, SEEK_SET);
     905                //  $prenullbytefileoffset = $this->ftell();
     906                //  $this->fseek($info['avdataend']);
     907                //  $PossibleNullByte = $this->fread(1);
     908                //  $this->fseek($prenullbytefileoffset);
    906909                //  if ($PossibleNullByte === "\x00") {
    907910                        $info['avdataend']--;
     
    11191122        $info = &$this->getid3->info;
    11201123
    1121         fseek($this->getid3->fp, $offset, SEEK_SET);
    1122         $MPEGaudioData = fread($this->getid3->fp, 32768);
     1124        $this->fseek($offset);
     1125        $MPEGaudioData = $this->fread(32768);
    11231126
    11241127        $SyncPattern1 = substr($MPEGaudioData, 0, 4);
     
    11671170            $nextoffset = $offset + $framelength;
    11681171            while ($nextoffset < ($info['avdataend'] - 6)) {
    1169                 fseek($this->getid3->fp, $nextoffset - 1, SEEK_SET);
    1170                 $NextSyncPattern = fread($this->getid3->fp, 6);
     1172                $this->fseek($nextoffset - 1);
     1173                $NextSyncPattern = $this->fread(6);
    11711174                if ((substr($NextSyncPattern, 1, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 1, strlen($SyncPattern2)) == $SyncPattern2)) {
    11721175                    // good - found where expected
     
    12161219
    12171220        $info = &$this->getid3->info;
    1218         fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     1221        $this->fseek($info['avdataoffset']);
    12191222
    12201223        $max_frames_scan = 5000;
     
    12221225
    12231226        $previousvalidframe = $info['avdataoffset'];
    1224         while (ftell($this->getid3->fp) < $info['avdataend']) {
     1227        while ($this->ftell() < $info['avdataend']) {
    12251228            set_time_limit(30);
    1226             $head4 = fread($this->getid3->fp, 4);
     1229            $head4 = $this->fread(4);
    12271230            if (strlen($head4) < 4) {
    12281231                break;
     
    12311234                for ($i = 1; $i < 4; $i++) {
    12321235                    if ($head4{$i} == "\xFF") {
    1233                         fseek($this->getid3->fp, $i - 4, SEEK_CUR);
     1236                        $this->fseek($i - 4, SEEK_CUR);
    12341237                        continue 2;
    12351238                    }
     
    12591262                }
    12601263                if ($MPEGaudioHeaderLengthCache[$head4] > 4) {
    1261                     $WhereWeWere = ftell($this->getid3->fp);
    1262                     fseek($this->getid3->fp, $MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR);
    1263                     $next4 = fread($this->getid3->fp, 4);
     1264                    $WhereWeWere = $this->ftell();
     1265                    $this->fseek($MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR);
     1266                    $next4 = $this->fread(4);
    12641267                    if ($next4{0} == "\xFF") {
    12651268                        if (!isset($MPEGaudioHeaderDecodeCache[$next4])) {
     
    12701273                        }
    12711274                        if ($MPEGaudioHeaderValidCache[$next4]) {
    1272                             fseek($this->getid3->fp, -4, SEEK_CUR);
     1275                            $this->fseek(-4, SEEK_CUR);
    12731276
    12741277                            getid3_lib::safe_inc($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]);
     
    12781281                            getid3_lib::safe_inc($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]);
    12791282                            if ($max_frames_scan && (++$frames_scanned >= $max_frames_scan)) {
    1280                                 $pct_data_scanned = (ftell($this->getid3->fp) - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']);
     1283                                $pct_data_scanned = ($this->ftell() - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']);
    12811284                                $info['warning'][] = 'too many MPEG audio frames to scan, only scanned first '.$max_frames_scan.' frames ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.';
    12821285                                foreach ($Distribution as $key1 => $value1) {
     
    12911294                    }
    12921295                    unset($next4);
    1293                     fseek($this->getid3->fp, $WhereWeWere - 3, SEEK_SET);
     1296                    $this->fseek($WhereWeWere - 3);
    12941297                }
    12951298
     
    13561359        }
    13571360
    1358         fseek($this->getid3->fp, $avdataoffset, SEEK_SET);
     1361        $this->fseek($avdataoffset);
    13591362        $sync_seek_buffer_size = min(128 * 1024, $info['avdataend'] - $avdataoffset);
    13601363        if ($sync_seek_buffer_size <= 0) {
     
    13621365            return false;
    13631366        }
    1364         $header = fread($this->getid3->fp, $sync_seek_buffer_size);
     1367        $header = $this->fread($sync_seek_buffer_size);
    13651368        $sync_seek_buffer_size = strlen($header);
    13661369        $SynchSeekOffset = 0;
     
    14741477                        $dummy = array('error'=>$info['error'], 'warning'=>$info['warning'], 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']);
    14751478                        $synchstartoffset = $info['avdataoffset'];
    1476                         fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     1479                        $this->fseek($info['avdataoffset']);
    14771480
    14781481                        // you can play with these numbers:
     
    14891492                        for ($current_segment = 0; $current_segment < $max_scan_segments; $current_segment++) {
    14901493                            $frames_scanned_this_segment = 0;
    1491                             if (ftell($this->getid3->fp) >= $info['avdataend']) {
     1494                            if ($this->ftell() >= $info['avdataend']) {
    14921495                                break;
    14931496                            }
    1494                             $scan_start_offset[$current_segment] = max(ftell($this->getid3->fp), $info['avdataoffset'] + round($current_segment * (($info['avdataend'] - $info['avdataoffset']) / $max_scan_segments)));
     1497                            $scan_start_offset[$current_segment] = max($this->ftell(), $info['avdataoffset'] + round($current_segment * (($info['avdataend'] - $info['avdataoffset']) / $max_scan_segments)));
    14951498                            if ($current_segment > 0) {
    1496                                 fseek($this->getid3->fp, $scan_start_offset[$current_segment], SEEK_SET);
    1497                                 $buffer_4k = fread($this->getid3->fp, 4096);
     1499                                $this->fseek($scan_start_offset[$current_segment]);
     1500                                $buffer_4k = $this->fread(4096);
    14981501                                for ($j = 0; $j < (strlen($buffer_4k) - 4); $j++) {
    14991502                                    if (($buffer_4k{$j} == "\xFF") && ($buffer_4k{($j + 1)} > "\xE0")) { // synch detected
     
    15241527                                $frames_scanned++;
    15251528                                if ($frames_scan_per_segment && (++$frames_scanned_this_segment >= $frames_scan_per_segment)) {
    1526                                     $this_pct_scanned = (ftell($this->getid3->fp) - $scan_start_offset[$current_segment]) / ($info['avdataend'] - $info['avdataoffset']);
     1529                                    $this_pct_scanned = ($this->ftell() - $scan_start_offset[$current_segment]) / ($info['avdataend'] - $info['avdataoffset']);
    15271530                                    if (($current_segment == 0) && (($this_pct_scanned * $max_scan_segments) >= 1)) {
    15281531                                        // file likely contains < $max_frames_scan, just scan as one segment
Note: See TracChangeset for help on using the changeset viewer.