wppaste
WordPress

getid3_matroska::HandleEMBLClusterBlock( array $element, int $block_type, array $info ): array

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

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

$elementarray
$block_typeint
$infoarray

Return value

array

Performance profile

How much work a call to getid3_matroska::HandleEMBLClusterBlock() 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
67–127

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
1

1 place 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::HandleEMBLClusterBlock() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always67–94->readEBMLint(), ->readEBMLelementData(), ::getid3_lib(), ->readEBMLelementData(), ::getid3_lib(), ::BlockLacingType()
always80–116->readEBMLint(), ->readEBMLelementData(), ::getid3_lib(), ->readEBMLelementData(), ::getid3_lib(), ::BlockLacingType(), ->readEBMLelementData(), ::getid3_lib()
!$i100–127->readEBMLint(), ->readEBMLelementData(), ::getid3_lib(), ->readEBMLelementData(), ::getid3_lib(), ::BlockLacingType(), ->readEBMLelementData(), ::getid3_lib(), array_sum()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 153 instructions, 67–127 executed per call, 9 branches. The work does not change between versions.

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

Used by · 1

Source code

	private function HandleEMBLClusterBlock($element, $block_type, &$info) {		// http://www.matroska.org/technical/specs/index.html#block_structure		// http://www.matroska.org/technical/specs/index.html#simpleblock_structure 		$block_data = array();		$block_data['tracknumber'] = $this->readEBMLint();		$block_data['timecode']    = getid3_lib::BigEndian2Int($this->readEBMLelementData(2), false, true);		$block_data['flags_raw']   = getid3_lib::BigEndian2Int($this->readEBMLelementData(1)); 		if ($block_type == EBML_ID_CLUSTERSIMPLEBLOCK) {			$block_data['flags']['keyframe']  = (($block_data['flags_raw'] & 0x80) >> 7);			//$block_data['flags']['reserved1'] = (($block_data['flags_raw'] & 0x70) >> 4);		}		else {			//$block_data['flags']['reserved1'] = (($block_data['flags_raw'] & 0xF0) >> 4);		}		$block_data['flags']['invisible'] = (bool)(($block_data['flags_raw'] & 0x08) >> 3);		$block_data['flags']['lacing']    =       (($block_data['flags_raw'] & 0x06) >> 1);  // 00=no lacing; 01=Xiph lacing; 11=EBML lacing; 10=fixed-size lacing		if ($block_type == EBML_ID_CLUSTERSIMPLEBLOCK) {			$block_data['flags']['discardable'] = (($block_data['flags_raw'] & 0x01));		}		else {			//$block_data['flags']['reserved2'] = (($block_data['flags_raw'] & 0x01) >> 0);		}		$block_data['flags']['lacing_type'] = self::BlockLacingType($block_data['flags']['lacing']); 		// Lace (when lacing bit is set)		if ($block_data['flags']['lacing'] > 0) {			$block_data['lace_frames'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1)) + 1; // Number of frames in the lace-1 (uint8)			if ($block_data['flags']['lacing'] != 0x02) {				for ($i = 1; $i < $block_data['lace_frames']; $i ++) { // Lace-coded size of each frame of the lace, except for the last one (multiple uint8). *This is not used with Fixed-size lacing as it is calculated automatically from (total size of lace) / (number of frames in lace).					if ($block_data['flags']['lacing'] == 0x03) { // EBML lacing						$block_data['lace_frames_size'][$i] = $this->readEBMLint(); // TODO: read size correctly, calc size for the last frame. For now offsets are deteminded OK with readEBMLint() and that's the most important thing.					}					else { // Xiph lacing						$block_data['lace_frames_size'][$i] = 0;						do {							$size = getid3_lib::BigEndian2Int($this->readEBMLelementData(1));							$block_data['lace_frames_size'][$i] += $size;						}						while ($size == 255);					}				}				if ($block_data['flags']['lacing'] == 0x01) { // calc size of the last frame only for Xiph lacing, till EBML sizes are now anyway determined incorrectly					$block_data['lace_frames_size'][] = $element['end'] - $this->current_offset - array_sum($block_data['lace_frames_size']);				}			}		} 		if (!isset($info['matroska']['track_data_offsets'][$block_data['tracknumber']])) {			$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['offset'] = $this->current_offset;			$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['length'] = $element['end'] - $this->current_offset;			//$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['total_length'] = 0;		}		//$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['total_length'] += $info['matroska']['track_data_offsets'][$block_data['tracknumber']]['length'];		//$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['duration']      = $block_data['timecode'] * ((isset($info['matroska']['info'][0]['TimecodeScale']) ? $info['matroska']['info'][0]['TimecodeScale'] : 1000000) / 1000000000); 		// set offset manually		$this->current_offset = $element['end']; 		return $block_data;	}

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.