Changeset 29734 for trunk/src/wp-includes/ID3/module.audio.mp3.php
- Timestamp:
- 09/11/2014 07:06:33 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/module.audio.mp3.php
r23766 r29734 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // … … 96 97 // Not sure what version of LAME this is - look in padding of last frame for longer version string 97 98 $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); 100 101 switch (substr($CurrentDataLAMEversionString, -1)) { 101 102 case 'a': … … 423 424 } 424 425 425 if ( fseek($this->getid3->fp, $offset, SEEK_SET) != 0) {426 if ($this->fseek($offset) != 0) { 426 427 $info['error'][] = 'decodeMPEGaudioHeader() failed to seek to next offset at '.$offset; 427 428 return false; 428 429 } 429 //$headerstring = fread($this->getid3->fp,1441); // worst-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame430 $headerstring = fread($this->getid3->fp,226); // LAME header at offset 36 + 190 bytes of Xing/LAME data430 //$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 431 432 432 433 // MP3 audio frame structure: … … 891 892 if (($ExpectedNumberOfAudioBytes > 0) && ($ExpectedNumberOfAudioBytes != ($info['avdataend'] - $info['avdataoffset']))) { 892 893 if ($ExpectedNumberOfAudioBytes > ($info['avdataend'] - $info['avdataoffset'])) { 893 if ( isset($info['fileformat']) && ($info['fileformat'] =='riff')) {894 if ($this->isDependencyFor('matroska') || $this->isDependencyFor('riff')) { 894 895 // 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)'); 899 902 } 900 903 } else { 901 904 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); 906 909 // if ($PossibleNullByte === "\x00") { 907 910 $info['avdataend']--; … … 1119 1122 $info = &$this->getid3->info; 1120 1123 1121 fseek($this->getid3->fp, $offset, SEEK_SET);1122 $MPEGaudioData = fread($this->getid3->fp,32768);1124 $this->fseek($offset); 1125 $MPEGaudioData = $this->fread(32768); 1123 1126 1124 1127 $SyncPattern1 = substr($MPEGaudioData, 0, 4); … … 1167 1170 $nextoffset = $offset + $framelength; 1168 1171 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); 1171 1174 if ((substr($NextSyncPattern, 1, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 1, strlen($SyncPattern2)) == $SyncPattern2)) { 1172 1175 // good - found where expected … … 1216 1219 1217 1220 $info = &$this->getid3->info; 1218 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);1221 $this->fseek($info['avdataoffset']); 1219 1222 1220 1223 $max_frames_scan = 5000; … … 1222 1225 1223 1226 $previousvalidframe = $info['avdataoffset']; 1224 while ( ftell($this->getid3->fp) < $info['avdataend']) {1227 while ($this->ftell() < $info['avdataend']) { 1225 1228 set_time_limit(30); 1226 $head4 = fread($this->getid3->fp,4);1229 $head4 = $this->fread(4); 1227 1230 if (strlen($head4) < 4) { 1228 1231 break; … … 1231 1234 for ($i = 1; $i < 4; $i++) { 1232 1235 if ($head4{$i} == "\xFF") { 1233 fseek($this->getid3->fp,$i - 4, SEEK_CUR);1236 $this->fseek($i - 4, SEEK_CUR); 1234 1237 continue 2; 1235 1238 } … … 1259 1262 } 1260 1263 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); 1264 1267 if ($next4{0} == "\xFF") { 1265 1268 if (!isset($MPEGaudioHeaderDecodeCache[$next4])) { … … 1270 1273 } 1271 1274 if ($MPEGaudioHeaderValidCache[$next4]) { 1272 fseek($this->getid3->fp,-4, SEEK_CUR);1275 $this->fseek(-4, SEEK_CUR); 1273 1276 1274 1277 getid3_lib::safe_inc($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]); … … 1278 1281 getid3_lib::safe_inc($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]); 1279 1282 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']); 1281 1284 $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.'; 1282 1285 foreach ($Distribution as $key1 => $value1) { … … 1291 1294 } 1292 1295 unset($next4); 1293 fseek($this->getid3->fp, $WhereWeWere - 3, SEEK_SET);1296 $this->fseek($WhereWeWere - 3); 1294 1297 } 1295 1298 … … 1356 1359 } 1357 1360 1358 fseek($this->getid3->fp, $avdataoffset, SEEK_SET);1361 $this->fseek($avdataoffset); 1359 1362 $sync_seek_buffer_size = min(128 * 1024, $info['avdataend'] - $avdataoffset); 1360 1363 if ($sync_seek_buffer_size <= 0) { … … 1362 1365 return false; 1363 1366 } 1364 $header = fread($this->getid3->fp,$sync_seek_buffer_size);1367 $header = $this->fread($sync_seek_buffer_size); 1365 1368 $sync_seek_buffer_size = strlen($header); 1366 1369 $SynchSeekOffset = 0; … … 1474 1477 $dummy = array('error'=>$info['error'], 'warning'=>$info['warning'], 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']); 1475 1478 $synchstartoffset = $info['avdataoffset']; 1476 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);1479 $this->fseek($info['avdataoffset']); 1477 1480 1478 1481 // you can play with these numbers: … … 1489 1492 for ($current_segment = 0; $current_segment < $max_scan_segments; $current_segment++) { 1490 1493 $frames_scanned_this_segment = 0; 1491 if ( ftell($this->getid3->fp) >= $info['avdataend']) {1494 if ($this->ftell() >= $info['avdataend']) { 1492 1495 break; 1493 1496 } 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))); 1495 1498 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); 1498 1501 for ($j = 0; $j < (strlen($buffer_4k) - 4); $j++) { 1499 1502 if (($buffer_4k{$j} == "\xFF") && ($buffer_4k{($j + 1)} > "\xE0")) { // synch detected … … 1524 1527 $frames_scanned++; 1525 1528 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']); 1527 1530 if (($current_segment == 0) && (($this_pct_scanned * $max_scan_segments) >= 1)) { 1528 1531 // file likely contains < $max_frames_scan, just scan as one segment
Note: See TracChangeset
for help on using the changeset viewer.