getid3_mp3::getOnlyMPEGaudioInfoBruteForce() –

You appear to be a bot. Output may be restricted

Description

Usage

$bool = getid3_mp3::getOnlyMPEGaudioInfoBruteForce();

Parameters

Returns

bool

Source

File name: wordpress/wp-includes/ID3/module.audio.mp3.php
Lines:

1 to 100 of 147
  public function getOnlyMPEGaudioInfoBruteForce() {
    $MPEGaudioHeaderDecodeCache   = array();
    $MPEGaudioHeaderValidCache    = array();
    $MPEGaudioHeaderLengthCache   = array();
    $MPEGaudioVersionLookup       = self::MPEGaudioVersionArray();
    $MPEGaudioLayerLookup         = self::MPEGaudioLayerArray();
    $MPEGaudioBitrateLookup       = self::MPEGaudioBitrateArray();
    $MPEGaudioFrequencyLookup     = self::MPEGaudioFrequencyArray();
    $MPEGaudioChannelModeLookup   = self::MPEGaudioChannelModeArray();
    $MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray();
    $MPEGaudioEmphasisLookup      = self::MPEGaudioEmphasisArray();
    $LongMPEGversionLookup        = array();
    $LongMPEGlayerLookup          = array();
    $LongMPEGbitrateLookup        = array();
    $LongMPEGpaddingLookup        = array();
    $LongMPEGfrequencyLookup      = array();
    $Distribution                 = array();
    $Distribution['bitrate']      = array();
    $Distribution['frequency']    = array();
    $Distribution['layer']        = array();
    $Distribution['version']      = array();
    $Distribution['padding']      = array();

    $info = &$this->getid3->info;
    $this->fseek($info['avdataoffset']);

    $max_frames_scan = 5000;
    $frames_scanned  = 0;

    $previousvalidframe = $info['avdataoffset'];
    while ($this->ftell() < $info['avdataend']) {
      set_time_limit(30);
      $head4 = $this->fread(4);
      if (strlen($head4) < 4) {
        break;
      }
      if ($head4[0] != "\xFF") {
        for ($i = 1; $i < 4; $i++) {
          if ($head4[$i] == "\xFF") {
            $this->fseek($i - 4, SEEK_CUR);
            continue 2;
          }
        }
        continue;
      }
      if (!isset($MPEGaudioHeaderDecodeCache[$head4])) {
        $MPEGaudioHeaderDecodeCache[$head4] = self::MPEGaudioHeaderDecode($head4);
      }
      if (!isset($MPEGaudioHeaderValidCache[$head4])) {
        $MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$head4], false, false);
      }
      if ($MPEGaudioHeaderValidCache[$head4]) {

        if (!isset($MPEGaudioHeaderLengthCache[$head4])) {
          $LongMPEGversionLookup[$head4]   = $MPEGaudioVersionLookup[$MPEGaudioHeaderDecodeCache[$head4]['version']];
          $LongMPEGlayerLookup[$head4]     = $MPEGaudioLayerLookup[$MPEGaudioHeaderDecodeCache[$head4]['layer']];
          $LongMPEGbitrateLookup[$head4]   = $MPEGaudioBitrateLookup[$LongMPEGversionLookup[$head4]][$LongMPEGlayerLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['bitrate']];
          $LongMPEGpaddingLookup[$head4]   = (bool) $MPEGaudioHeaderDecodeCache[$head4]['padding'];
          $LongMPEGfrequencyLookup[$head4] = $MPEGaudioFrequencyLookup[$LongMPEGversionLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['sample_rate']];
          $MPEGaudioHeaderLengthCache[$head4] = self::MPEGaudioFrameLength(
            $LongMPEGbitrateLookup[$head4],
            $LongMPEGversionLookup[$head4],
            $LongMPEGlayerLookup[$head4],
            $LongMPEGpaddingLookup[$head4],
            $LongMPEGfrequencyLookup[$head4]);
        }
        if ($MPEGaudioHeaderLengthCache[$head4] > 4) {
          $WhereWeWere = $this->ftell();
          $this->fseek($MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR);
          $next4 = $this->fread(4);
          if ($next4[0] == "\xFF") {
            if (!isset($MPEGaudioHeaderDecodeCache[$next4])) {
              $MPEGaudioHeaderDecodeCache[$next4] = self::MPEGaudioHeaderDecode($next4);
            }
            if (!isset($MPEGaudioHeaderValidCache[$next4])) {
              $MPEGaudioHeaderValidCache[$next4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false);
            }
            if ($MPEGaudioHeaderValidCache[$next4]) {
              $this->fseek(-4, SEEK_CUR);

              $Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]] = isset($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]) ? ++$Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]] : 1;
              $Distribution['layer'][$LongMPEGlayerLookup[$head4]] = isset($Distribution['layer'][$LongMPEGlayerLookup[$head4]]) ? ++$Distribution['layer'][$LongMPEGlayerLookup[$head4]] : 1;
              $Distribution['version'][$LongMPEGversionLookup[$head4]] = isset($Distribution['version'][$LongMPEGversionLookup[$head4]]) ? ++$Distribution['version'][$LongMPEGversionLookup[$head4]] : 1;
              $Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])] = isset($Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]) ? ++$Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])] : 1;
              $Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]] = isset($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]) ? ++$Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]] : 1;
              if (++$frames_scanned >= $max_frames_scan) {
                $pct_data_scanned = ($this->ftell() - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']);
                $this->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.');
                foreach ($Distribution as $key1 => $value1) {
                  foreach ($value1 as $key2 => $value2) {
                    $Distribution[$key1][$key2] = round($value2 / $pct_data_scanned);
                  }
                }
                break;
              }
              continue;
            }
          }
          unset($next4);
          $this->fseek($WhereWeWere - 3);
 

 View on GitHub View on Trac