wppaste
WordPress

getid3_matroska::parseEBML( array $info )

Source
wp-includes/ID3/module.audio-video.matroska.php:578

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.

Parameters

$infoarray

Performance profile

How much work a call to getid3_matroska::parseEBML() 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

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
13–137

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 1756.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
2

2 places in core call this, so the cost is paid more often than your own code shows.

What one call costs · 3 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost getid3_matroska::parseEBML() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!->getEBMLelement()13->getEBMLelement()
->getEBMLelement()99–132->getEBMLelement(), ->getEBMLelement()
->getEBMLelement()100–137->getEBMLelement(), ->getEBMLelement(), ->playtimeFromMetadata()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev175613–137192
8.5175613–137192
8.4175613–137192
8.3175613–137192
8.2175613–13719235 more instructions than PHP 8.1
8.117211721192
7.417211721192

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 · 16

Show all 16

Used by · 2

Source code

	private function parseEBML(&$info) {		// http://www.matroska.org/technical/specs/index.html#EBMLBasics		$this->current_offset = $info['avdataoffset']; 		while ($this->getEBMLelement($top_element, $info['avdataend'])) {			switch ($top_element['id']) { 				case EBML_ID_EBML:					$info['matroska']['header']['offset'] = $top_element['offset'];					$info['matroska']['header']['length'] = $top_element['length']; 					while ($this->getEBMLelement($element_data, $top_element['end'], true)) {						switch ($element_data['id']) { 							case EBML_ID_EBMLVERSION:							case EBML_ID_EBMLREADVERSION:							case EBML_ID_EBMLMAXIDLENGTH:							case EBML_ID_EBMLMAXSIZELENGTH:							case EBML_ID_DOCTYPEVERSION:							case EBML_ID_DOCTYPEREADVERSION:								$element_data['data'] = getid3_lib::BigEndian2Int($element_data['data']);								break; 							case EBML_ID_DOCTYPE:								$element_data['data'] = getid3_lib::trimNullByte($element_data['data']);								$info['matroska']['doctype'] = $element_data['data'];								$info['fileformat'] = $element_data['data'];								break; 							default:								$this->unhandledElement('header', __LINE__, $element_data);								break;						} 						unset($element_data['offset'], $element_data['end']);						$info['matroska']['header']['elements'][] = $element_data;					}					break; 				case EBML_ID_SEGMENT:					$info['matroska']['segment'][0]['offset'] = $top_element['offset'];					$info['matroska']['segment'][0]['length'] = $top_element['length']; 					while ($this->getEBMLelement($element_data, $top_element['end'])) {						if ($element_data['id'] != EBML_ID_CLUSTER || !$this->hide_clusters) { // collect clusters only if required							$info['matroska']['segments'][] = $element_data;						}						switch ($element_data['id']) { 							case EBML_ID_SEEKHEAD: // Contains the position of other level 1 elements. 								while ($this->getEBMLelement($seek_entry, $element_data['end'])) {									switch ($seek_entry['id']) { 										case EBML_ID_SEEK: // Contains a single seek entry to an EBML element											while ($this->getEBMLelement($sub_seek_entry, $seek_entry['end'], true)) { 												switch ($sub_seek_entry['id']) { 													case EBML_ID_SEEKID:														$seek_entry['target_id']   = self::EBML2Int($sub_seek_entry['data']);														$seek_entry['target_name'] = self::EBMLidName($seek_entry['target_id']);														break; 													case EBML_ID_SEEKPOSITION:														$seek_entry['target_offset'] = $element_data['offset'] + getid3_lib::BigEndian2Int($sub_seek_entry['data']);														break; 													default:														$this->unhandledElement('seekhead.seek', __LINE__, $sub_seek_entry);												}														break;											}											if (!isset($seek_entry['target_id'])) {												$this->warning('seek_entry[target_id] unexpectedly not set at '.$seek_entry['offset']);												break;											}											if (($seek_entry['target_id'] != EBML_ID_CLUSTER) || !$this->hide_clusters) { // collect clusters only if required												$info['matroska']['seek'][] = $seek_entry;											}											break;

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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-video.matroska.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.