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:

201 to 300 of 383
          $filedataoffset += 4;
          $info['ogg']['skeleton']['fisbone']['raw']['serial_number']           = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  4));
          $filedataoffset += 4;
          $info['ogg']['skeleton']['fisbone']['raw']['number_header_packets']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  4));
          $filedataoffset += 4;
          $info['ogg']['skeleton']['fisbone']['raw']['granulerate_numerator']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  8));
          $filedataoffset += 8;
          $info['ogg']['skeleton']['fisbone']['raw']['granulerate_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  8));
          $filedataoffset += 8;
          $info['ogg']['skeleton']['fisbone']['raw']['basegranule']             = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  8));
          $filedataoffset += 8;
          $info['ogg']['skeleton']['fisbone']['raw']['preroll']                 = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  4));
          $filedataoffset += 4;
          $info['ogg']['skeleton']['fisbone']['raw']['granuleshift']            = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  1));
          $filedataoffset += 1;
          $info['ogg']['skeleton']['fisbone']['raw']['padding']                 =                              substr($filedata, $filedataoffset,  3);
          $filedataoffset += 3;

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

          $info['video']['dataformat'] = 'theora1';
          $this->error('Ogg Theora (v1) not correctly handled in this version of getID3 ['.$this->getid3->version().']');
          //break;

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

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

        } else {
          $this->error('unexpected');
          //break;
        }
      //} while ($oggpageinfo['page_seqno'] == 0);
      } while (($oggpageinfo['page_seqno'] == 0) && (substr($filedata, 0, 8) != "fisbone\x00"));

      $this->fseek($oggpageinfo['page_start_offset']);

      $this->error('Ogg Skeleton not correctly handled in this version of getID3 ['.$this->getid3->version().']');
      //return false;

    } elseif (substr($filedata, 0, 5) == "\x7F".'FLAC') {
      // https://xiph.org/flac/ogg_mapping.html

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

      $info['ogg']['flac']['header']['version_major']  =                         ord(substr($filedata,  5, 1));
      $info['ogg']['flac']['header']['version_minor']  =                         ord(substr($filedata,  6, 1));
      $info['ogg']['flac']['header']['header_packets'] =   getid3_lib::BigEndian2Int(substr($filedata,  7, 2)) + 1; // "A two-byte, big-endian binary number signifying the number of header (non-audio) packets, not including this one. This number may be zero (0x0000) to signify 'unknown' but be aware that some decoders may not be able to handle such streams."
      $info['ogg']['flac']['header']['magic']          =                             substr($filedata,  9, 4);
      if ($info['ogg']['flac']['header']['magic'] != 'fLaC') {
        $this->error('Ogg-FLAC expecting "fLaC", found "'.$info['ogg']['flac']['header']['magic'].'" ('.trim(getid3_lib::PrintHexBytes($info['ogg']['flac']['header']['magic'])).')');
        return false;
      }
      $info['ogg']['flac']['header']['STREAMINFO_bytes'] = getid3_lib::BigEndian2Int(substr($filedata, 13, 4));
      $info['flac']['STREAMINFO'] = getid3_flac::getid3_flac::parseSTREAMINFOdata(substr($filedata, 17, 34));
      if (!empty($info['flac']['STREAMINFO']['sample_rate'])) {
        $info['audio']['bitrate_mode']    = 'vbr';
        $info['audio']['sample_rate']     = $info['flac']['STREAMINFO']['sample_rate'];
        $info['audio']['channels']        = $info['flac']['STREAMINFO']['channels'];
        $info['audio']['bits_per_sample'] = $info['flac']['STREAMINFO']['bits_per_sample'];
        $info['playtime_seconds']         = $info['flac']['STREAMINFO']['samples_stream'] / $info['flac']['STREAMINFO']['sample_rate'];
      }

    } else {

      $this->error('Expecting one of "vorbis", "Speex", "OpusHead", "vorbis", "fishhead", "theora", "fLaC" identifier strings, found "'.substr($filedata, 0, 8).'"');
      unset($info['ogg']);
      unset($info['mime_type']);
      return false;

    }

    // Page 2 - Comment Header
    $oggpageinfo = $this->getid3_ogg::ParseOggPageHeader();
    $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;

    switch ($info['audio']['dataformat']) {
      case 'vorbis':
        $filedata = $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
        $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, 0, 1));
        $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] =                              substr($filedata, 1, 6); // hard-coded to 'vorbis'

        $this->getid3_ogg::ParseVorbisComments();
        break;

      case 'flac':
        $flac = new getid3_flac($this->getid3);
        if (!$flac->parseMETAdata()) {
          $this->error('Failed to parse FLAC headers');
          return false;
        }
        unset($flac);
        break;

      case 'speex':
        $this->fseek($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length'], SEEK_CUR);
        $this->getid3_ogg::ParseVorbisComments();
        break;
 

 View on GitHub View on Trac