Parsed: 112521

  public function ParseOpusPageHeader(&$filedata, &$filedataoffset, &$oggpageinfo) {
    $info = &$this->getid3->info;
    $info['audio']['dataformat']   = 'opus';
    $info['mime_type']             = 'audio/ogg; codecs=opus';

    
/** @todo find a usable way to detect abr (vbr that is padded to be abr) */
    $info['audio']['bitrate_mode'] = 'vbr';

    $info['audio']['lossless']     = false;

    $info['ogg']['pageheader']['opus']['opus_magic'] = substr($filedata, $filedataoffset, 8); // hard-coded to 'OpusHead'
    $filedataoffset += 8;
    $info['ogg']['pageheader']['opus']['version']    = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  1));
    $filedataoffset += 1;

    if ($info['ogg']['pageheader']['opus']['version'] < 1 || $info['ogg']['pageheader']['opus']['version'] > 15) {
      $this->error('Unknown opus version number (only accepting 1-15)');
      return false;
    }

    $info['ogg']['pageheader']['opus']['out_channel_count'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  1));
    $filedataoffset += 1;

    if ($info['ogg']['pageheader']['opus']['out_channel_count'] == 0) {
      $this->error('Invalid channel count in opus header (must not be zero)');
      return false;
    }

    $info['ogg']['pageheader']['opus']['pre_skip'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  2));
    $filedataoffset += 2;

    $info['ogg']['pageheader']['opus']['input_sample_rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  4));
    $filedataoffset += 4;

    //$info['ogg']['pageheader']['opus']['output_gain'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  2));
    //$filedataoffset += 2;

    //$info['ogg']['pageheader']['opus']['channel_mapping_family'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset,  1));
    //$filedataoffset += 1;

    $info['opus']['opus_version']       = $info['ogg']['pageheader']['opus']['version'];
    $info['opus']['sample_rate_input']  = $info['ogg']['pageheader']['opus']['input_sample_rate'];
    $info['opus']['out_channel_count']  = $info['ogg']['pageheader']['opus']['out_channel_count'];

    $info['audio']['channels']          = $info['opus']['out_channel_count'];
    $info['audio']['sample_rate_input'] = $info['opus']['sample_rate_input'];
    $info['audio']['sample_rate']       = 48000; // "All Opus audio is coded at 48 kHz, and should also be decoded at 48 kHz for playback (unless the target hardware does not support this sampling rate). However, this field may be used to resample the audio back to the original sampling rate, for example, when saving the output to a file." -- https://mf4.xiph.org/jenkins/view/opus/job/opusfile-unix/ws/doc/html/structOpusHead.html
    return true;
  }