getid3_ogg::Analyze() –

You appear to be a bot. Output may be restricted

Description

Usage

$bool = getid3_ogg::Analyze();

Parameters

Returns

bool

Source

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

1 to 100 of 383
  public function Analyze() {
    $info = &$this->getid3->info;

    $info['fileformat'] = 'ogg';

    // Warn about illegal tags - only vorbiscomments are allowed
    if (isset($info['id3v2'])) {
      $this->warning('Illegal ID3v2 tag present.');
    }
    if (isset($info['id3v1'])) {
      $this->warning('Illegal ID3v1 tag present.');
    }
    if (isset($info['ape'])) {
      $this->warning('Illegal APE tag present.');
    }


    // Page 1 - Stream Header

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

    $oggpageinfo = $this->getid3_ogg::ParseOggPageHeader();
    $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;

    if ($this->ftell() >= $this->getid3->fread_buffer_size()) {
      $this->error('Could not find start of Ogg page in the first '.$this->getid3->fread_buffer_size().' bytes (this might not be an Ogg-Vorbis file?)');
      unset($info['fileformat']);
      unset($info['ogg']);
      return false;
    }

    $filedata = $this->fread($oggpageinfo['page_length']);
    $filedataoffset = 0;

    if (substr($filedata, 0, 4) == 'fLaC') {

      $info['audio']['dataformat']   = 'flac';
      $info['audio']['bitrate_mode'] = 'vbr';
      $info['audio']['lossless']     = true;

    } elseif (substr($filedata, 1, 6) == 'vorbis') {

      $this->getid3_ogg::ParseVorbisPageHeader($filedata, $filedataoffset, $oggpageinfo);

    } elseif (substr($filedata, 0, 8) == 'OpusHead') {

      if ($this->getid3_ogg::ParseOpusPageHeader($filedata, $filedataoffset, $oggpageinfo) === false) {
        return false;
      }

    } elseif (substr($filedata, 0, 8) == 'Speex   ') {

      // http://www.speex.org/manual/node10.html

      $info['audio']['dataformat']   = 'speex';
      $info['mime_type']             = 'audio/speex';
      $info['audio']['bitrate_mode'] = 'abr';
      $info['audio']['lossless']     = false;

      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_string']           =                              substr($filedata, $filedataoffset, 8); // hard-coded to 'Speex   '
      $filedataoffset += 8;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version']          =                              substr($filedata, $filedataoffset, 20);
      $filedataoffset += 20;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version_id']       = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['header_size']            = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate']                   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode']                   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode_bitstream_version'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels']            = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['bitrate']                = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['framesize']              = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['vbr']                    = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['frames_per_packet']      = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['extra_headers']          = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['reserved1']              = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;
      $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['reserved2']              = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
      $filedataoffset += 4;

      $info['speex']['speex_version'] = trim($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version']);
      $info['speex']['sample_rate']   = $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate'];
      $info['speex']['channels']      = $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels'];
      $info['speex']['vbr']           = (bool) $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['vbr'];
      $info['speex']['band_type']     = $this->getid3_ogg::SpeexBandModeLookup($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode']);

      $info['audio']['sample_rate']   = $info['speex']['sample_rate'];
      $info['audio']['channels']      = $info['speex']['channels'];
      if ($info['speex']['vbr']) {
        $info['audio']['bitrate_mode'] = 'vbr';
 

 View on GitHub View on Trac