wppaste
WordPress

getid3_quicktime::Analyze(): bool

Source
wp-includes/ID3/module.audio-video.quicktime.php:52

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_quicktime::Analyze() 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 how much data it finds.

Instructions
111–155

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What one call costs · 2 distinct outcomes

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

WhenInstructionsCalls it makes
!$info && $offset && ::getid3_lib() && $atomsize != 1 && $atomsize == 0 && empty($info) && !isset($value) && empty($value)111–143->fseek(), ::getid3_lib(), ->fseek(), ->fread(), ::getid3_lib()
!$info && $offset && ::getid3_lib() && $atomsize != 1 && $atomsize == 0 && empty($info) && !isset($value)131–155->fseek(), ::getid3_lib(), ->fseek(), ->fread(), ::getid3_lib(), ->error()

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

PHPCompiledExecutedBranchesNotes
8.6-dev739111–15587
8.5739111–15587
8.4739111–1558757 fewer instructions than PHP 8.3
8.3796117–161873 fewer instructions than PHP 8.2
8.2799117–1618710 fewer instructions than PHP 8.1
8.1809117–161872 fewer instructions than PHP 7.4
7.4811118–16287

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

Source code

	public function Analyze() {		$info = &$this->getid3->info; 		$this->metaDATAkey = 1;		$info['fileformat'] = 'quicktime';		$info['quicktime']['hinting']    = false;		$info['quicktime']['controller'] = 'standard'; // may be overridden if 'ctyp' atom is present 		$this->fseek($info['avdataoffset']); 		$offset      = 0;		$atomcounter = 0;		$atom_data_read_buffer_size = $info['php_memory_limit'] ? round($info['php_memory_limit'] / 4) : $this->getid3->option_fread_buffer_size * 1024; // set read buffer to 25% of PHP memory limit (if one is specified), otherwise use option_fread_buffer_size [default: 32MB]		while ($offset < $info['avdataend']) {			if (!getid3_lib::intValueSupported($offset)) {				$this->error('Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions');				break;			}			$this->fseek($offset);			$AtomHeader = $this->fread(8); 			// https://github.com/JamesHeinrich/getID3/issues/382			// Atom sizes are stored as 32-bit number in most cases, but sometimes (notably for "mdat")			// a 64-bit value is required, in which case the normal 32-bit size field is set to 0x00000001			// and the 64-bit "real" size value is the next 8 bytes.			$atom_size_extended_bytes = 0;			$atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));			$atomname = substr($AtomHeader, 4, 4);			if ($atomsize == 1) {				$atom_size_extended_bytes = 8;				$atomsize = getid3_lib::BigEndian2Int($this->fread($atom_size_extended_bytes));			} 			if (($offset + $atomsize) > $info['avdataend']) {				$info['quicktime'][$atomname]['name']   = $atomname;				$info['quicktime'][$atomname]['size']   = $atomsize;				$info['quicktime'][$atomname]['offset'] = $offset;				$this->error('Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)');				return false;			}			if ($atomsize == 0) {				// Furthermore, for historical reasons the list of atoms is optionally				// terminated by a 32-bit integer set to 0. If you are writing a program				// to read user data atoms, you should allow for the terminating 0.				$info['quicktime'][$atomname]['name']   = $atomname;				$info['quicktime'][$atomname]['size']   = $atomsize;				$info['quicktime'][$atomname]['offset'] = $offset;				break;			}			$atomHierarchy = array();			$parsedAtomData = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread(min($atomsize - $atom_size_extended_bytes, $atom_data_read_buffer_size)), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);			$parsedAtomData['name']   = $atomname;			$parsedAtomData['size']   = $atomsize;			$parsedAtomData['offset'] = $offset;			if ($atom_size_extended_bytes) {				$parsedAtomData['xsize_bytes'] = $atom_size_extended_bytes;			}			if (in_array($atomname, array('uuid'))) {				@$info['quicktime'][$atomname][] = $parsedAtomData;			} else {				$info['quicktime'][$atomname] = $parsedAtomData;			} 			$offset += $atomsize;			$atomcounter++;		} 		if (!empty($info['avdataend_tmp'])) {			// this value is assigned to a temp value and then erased because			// otherwise any atoms beyond the 'mdat' atom would not get parsed			$info['avdataend'] = $info['avdataend_tmp'];			unset($info['avdataend_tmp']);		} 		if (isset($info['quicktime']['comments']['chapters']) && is_array($info['quicktime']['comments']['chapters']) && (count($info['quicktime']['comments']['chapters']) > 0)) {			$durations = $this->quicktime_time_to_sample_table($info);			for ($i = 0; $i < count($info['quicktime']['comments']['chapters']); $i++) {				$bookmark = array();				$bookmark['title'] = $info['quicktime']['comments']['chapters'][$i];				if (isset($durations[$i])) {

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.quicktime.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.