wppaste
WordPress

getid3_riff::Analyze(): bool

Source
wp-includes/ID3/module.audio-video.riff.php:42

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_riff::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
181–253

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

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

WhenInstructionsCalls it makes
$RIFFsize != "\x00\x00\x00\x00" && !empty($thisfile_audio) && !empty($thisfile_audio_dataformat) && !isset($value) && empty($value) && isset($thisfile_audio) && empty($info) && $thisfile_audio_dataformat != "ac3" && !isset($thisfile_riff_WAVE) && isset($info)181–198->fseek(), ->fread(), ->ftell(), ->EitherEndian2Int(), ->ParseRIFF()
$RIFFsize != "\x00\x00\x00\x00" && !empty($thisfile_audio) && !empty($thisfile_audio_dataformat) && empty($value) && isset($thisfile_audio) && empty($info) && $thisfile_audio_dataformat != "ac3" && !isset($thisfile_riff_WAVE) && isset($info)226–253->fseek(), ->fread(), ->ftell(), ->EitherEndian2Int(), ->ParseRIFF(), strtolower(), ->GuessEncoderOptions()

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-dev3917181–2532821 fewer instruction than PHP 8.5
8.53918181–253282
8.43918181–253282449 fewer instructions than PHP 8.3
8.34367190–262282
8.24367190–26228216 more instructions than PHP 8.1
8.14351190–261282
7.44351190–261282

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

Show all 39

Source code

	public function Analyze() {		$info = &$this->getid3->info; 		// initialize these values to an empty array, otherwise they default to NULL		// and you can't append array values to a NULL value		$info['riff'] = array('raw'=>array()); 		// Shortcuts		$thisfile_riff             = &$info['riff'];		$thisfile_riff_raw         = &$thisfile_riff['raw'];		$thisfile_audio            = &$info['audio'];		$thisfile_video            = &$info['video'];		$thisfile_audio_dataformat = &$thisfile_audio['dataformat'];		$thisfile_riff_audio       = &$thisfile_riff['audio'];		$thisfile_riff_video       = &$thisfile_riff['video'];		$thisfile_riff_WAVE        = array(); 		$Original                 = array();		$Original['avdataoffset'] = $info['avdataoffset'];		$Original['avdataend']    = $info['avdataend']; 		$this->fseek($info['avdataoffset']);		$RIFFheader = $this->fread(12);		$offset = $this->ftell();		$RIFFtype    = substr($RIFFheader, 0, 4);		$RIFFsize    = substr($RIFFheader, 4, 4);		$RIFFsubtype = substr($RIFFheader, 8, 4); 		if ($RIFFsize == "\x00\x00\x00\x00") {			// https://github.com/JamesHeinrich/getID3/issues/468			// may occur in streaming files where the data size is unknown			$thisfile_riff['header_size'] = $info['avdataend'] - 8;			$this->warning('RIFF size field is empty, assuming the correct value is filesize-8 ('.$thisfile_riff['header_size'].')');		} else {			$thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);		} 		switch ($RIFFtype) {			case 'FORM':  // AIFF, AIFC				//$info['fileformat']   = 'aiff';				$this->container = 'aiff';				$thisfile_riff[$RIFFsubtype]  = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4));				break; 			case 'RIFF':  // AVI, WAV, etc			case 'SDSS':  // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)			case 'RMP3':  // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s				//$info['fileformat']   = 'riff';				$this->container = 'riff';				if ($RIFFsubtype == 'RMP3') {					// RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s					$RIFFsubtype = 'WAVE';				}				if ($RIFFsubtype != 'AMV ') {					// AMV files are RIFF-AVI files with parts of the spec deliberately broken, such as chunk size fields hardcoded to zero (because players known in hardware that these fields are always a certain size					// Handled separately in ParseRIFFAMV()					$thisfile_riff[$RIFFsubtype]  = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4));				}				if (($info['avdataend'] - $info['filesize']) == 1) {					// LiteWave appears to incorrectly *not* pad actual output file					// to nearest WORD boundary so may appear to be short by one					// byte, in which case - skip warning					$info['avdataend'] = $info['filesize'];				} 				$nextRIFFoffset = (int) $Original['avdataoffset'] + 8 + (int) $thisfile_riff['header_size']; // 8 = "RIFF" + 32-bit offset				while ($nextRIFFoffset < min($info['filesize'], $info['avdataend'])) {					try {						$this->fseek($nextRIFFoffset);					} catch (getid3_exception $e) {						if ($e->getCode() == 10) {							//$this->warning('RIFF parser: '.$e->getMessage());							$this->error('AVI extends beyond '.round(PHP_INT_MAX / 1073741824).'GB and PHP filesystem functions cannot read that far, playtime may be wrong');							$this->warning('[avdataend] value may be incorrect, multiple AVIX chunks may be present');							break;						} else {							throw $e;						}					}					$nextRIFFheader = $this->fread(12);

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