getid3_ogg::ParseVorbisComments(): bool
- Source
wp-includes/ID3/module.audio.ogg.php:593
Compatibility
- WordPress
- core
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Return value
bool
Performance profile
How much work a call to getid3_ogg::ParseVorbisComments() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Light
- Scaling
- Scales with input
- Instructions
- 13–203
- Plugin surface
- None
- Called by
- 1
Touches nothing outside its own arguments.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 540.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What one call costs · 11 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost getid3_ogg::ParseVorbisComments() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 13 | ->ftell() |
!$i | 68–77 | ->ftell(), ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ->fseek() |
$i | 78–87 | ->ftell(), ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ->warning(), ->fseek() |
!$i | 81–98 | ->ftell(), ->fseek(), ::OggPageSegmentLength(), ->fread(), ::getid3_lib(), ::getid3_lib(), ->fseek() |
$i | 91–108 | ->ftell(), ->fseek(), ::OggPageSegmentLength(), ->fread(), ::getid3_lib(), ::getid3_lib(), ->warning(), ->fseek() |
| always | 123–136 | ->ftell(), ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ->ftell(), ::getid3_lib(), number_format(), ->warning(), ->fseek() |
| always | 127–140 | ->ftell(), ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ->ftell(), ->ParseOggPageHeader(), ::getid3_lib(), number_format(), ->warning(), ->fseek() |
| always | 136–157 | ->ftell(), ->fseek(), ::OggPageSegmentLength(), ->fread(), ::getid3_lib(), ::getid3_lib(), ->ftell(), ::getid3_lib(), number_format(), ->warning(), ->fseek() |
| always | 140–161 | ->ftell(), ->fseek(), ::OggPageSegmentLength(), ->fread(), ::getid3_lib(), ::getid3_lib(), ->ftell(), ->ParseOggPageHeader(), ::getid3_lib(), number_format(), ->warning(), ->fseek() |
| always | 169–182 | ->ftell(), ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ->ftell(), ->ParseOggPageHeader(), str_repeat(), ->OggPageSegmentLength(), ->fread(), ::getid3_lib(), number_format(), ->warning(), ->fseek() |
| always | 182–203 | ->ftell(), ->fseek(), ::OggPageSegmentLength(), ->fread(), ::getid3_lib(), ::getid3_lib(), ->ftell(), ->ParseOggPageHeader(), str_repeat(), ->OggPageSegmentLength(), ->fread(), ::getid3_lib(), number_format(), ->warning(), ->fseek() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 540 | 13–203 | 37 | |
| 8.5 | 540 | 13–203 | 37 | |
| 8.4 | 540 | 13–203 | 37 | 30 fewer instructions than PHP 8.3 |
| 8.3 | 570 | 13–221 | 37 | |
| 8.2 | 570 | 13–221 | 37 | 2 more instructions than PHP 8.1 |
| 8.1 | 568 | 13–221 | 37 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 569 | 13–221 | 37 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 11
- getid3_ogg::ftell()
- getid3_ogg::fseek()
- getid3_ogg::fread()
- getid3_ogg::OggPageSegmentLength()
- getid3_lib::LittleEndian2Int()
- getid3_ogg::warning()
- getid3_ogg::ParseOggPageHeader()
- getid3_flac::__construct()
- getid3_ogg::notice()
- getid3_lib::GetDataImageSize()
- getid3_ogg::__construct()
Used by · 1
Source code
public function ParseVorbisComments() { $info = &$this->getid3->info; $OriginalOffset = $this->ftell(); $commentdata = null; $commentdataoffset = 0; $VorbisCommentPage = 1; $CommentStartOffset = 0; switch ($info['audio']['dataformat']) { case 'vorbis': case 'speex': case 'opus': $CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block $this->fseek($CommentStartOffset); $commentdataoffset = 27 + $info['ogg']['pageheader'][$VorbisCommentPage]['page_segments']; $commentdata = $this->fread(self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset); if ($info['audio']['dataformat'] == 'vorbis') { $commentdataoffset += (strlen('vorbis') + 1); } else if ($info['audio']['dataformat'] == 'opus') { $commentdataoffset += strlen('OpusTags'); } break; case 'flac': $CommentStartOffset = $info['flac']['VORBIS_COMMENT']['raw']['offset'] + 4; $this->fseek($CommentStartOffset); $commentdata = $this->fread($info['flac']['VORBIS_COMMENT']['raw']['block_length']); break; default: return false; } $VendorSize = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4)); $commentdataoffset += 4; $info['ogg']['vendor'] = substr($commentdata, $commentdataoffset, $VendorSize); $commentdataoffset += $VendorSize; $CommentsCount = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4)); $commentdataoffset += 4; $info['avdataoffset'] = $CommentStartOffset + $commentdataoffset; $basicfields = array('TITLE', 'ARTIST', 'ALBUM', 'TRACKNUMBER', 'GENRE', 'DATE', 'DESCRIPTION', 'COMMENT'); $ThisFileInfo_ogg_comments_raw = &$info['ogg']['comments_raw']; for ($i = 0; $i < $CommentsCount; $i++) { if ($i >= 10000) { // https://github.com/owncloud/music/issues/212#issuecomment-43082336 $this->warning('Unexpectedly large number ('.$CommentsCount.') of Ogg comments - breaking after reading '.$i.' comments'); break; } $ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] = $CommentStartOffset + $commentdataoffset; if ($this->ftell() < ($ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + 4)) { if ($oggpageinfo = $this->ParseOggPageHeader()) { $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo; $VorbisCommentPage++; // First, save what we haven't read yet $AsYetUnusedData = substr($commentdata, $commentdataoffset); // Then take that data off the end $commentdata = substr($commentdata, 0, $commentdataoffset); // Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct $commentdata .= str_repeat("\x00", 27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']); $commentdataoffset += (27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']); // Finally, stick the unused data back on the end $commentdata .= $AsYetUnusedData; //$commentdata .= $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']); $commentdata .= $this->fread($this->OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1));Changelog
Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/ID3/module.audio.ogg.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.