wppaste
WordPress

getid3_ac3::heavyCompression( int $compre ): float|int

Source
wp-includes/ID3/module.audio.ac3.php:664

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

$compreint

Return value

float|int

Performance profile

How much work a call to getid3_ac3::heavyCompression() 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
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
30–32

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

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 · 1 distinct outcome

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

WhenInstructionsCalls it makes
always30–32decbin(), str_pad(), bindec(), ::getid3_lib()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev3630–321
8.53630–321
8.43630–3216 fewer instructions than PHP 8.3
8.34233–351
8.24233–351
8.14233–351
7.44233–351

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

Used by · 1

Source code

	public static function heavyCompression($compre) {		// The first four bits indicate gain changes in 6.02dB increments which can be		// implemented with an arithmetic shift operation. The following four bits		// indicate linear gain changes, and require a 5-bit multiply.		// We will represent the two 4-bit fields of compr as follows:		//   X0 X1 X2 X3 . Y4 Y5 Y6 Y7		// The meaning of the X values is most simply described by considering X to represent a 4-bit		// signed integer with values from -8 to +7. The gain indicated by X is then (X + 1) * 6.02 dB. The		// following table shows this in detail. 		// Meaning of 4 msb of compr		//  7    +48.16 dB		//  6    +42.14 dB		//  5    +36.12 dB		//  4    +30.10 dB		//  3    +24.08 dB		//  2    +18.06 dB		//  1    +12.04 dB		//  0     +6.02 dB		// -1         0 dB		// -2     -6.02 dB		// -3    -12.04 dB		// -4    -18.06 dB		// -5    -24.08 dB		// -6    -30.10 dB		// -7    -36.12 dB		// -8    -42.14 dB 		$fourbit = str_pad(decbin(($compre & 0xF0) >> 4), 4, '0', STR_PAD_LEFT);		if ($fourbit[0] == '1') {			$log_gain = -8 + bindec(substr($fourbit, 1));		} else {			$log_gain = bindec(substr($fourbit, 1));		}		$log_gain = ($log_gain + 1) * getid3_lib::RGADamplitude2dB(2); 		// The value of Y is a linear representation of a gain change of up to -6 dB. Y is considered to		// be an unsigned fractional integer, with a leading value of 1, or: 0.1 Y4 Y5 Y6 Y7 (base 2). Y can		// represent values between 0.111112 (or 31/32) and 0.100002 (or 1/2). Thus, Y can represent gain		// changes from -0.28 dB to -6.02 dB. 		$lin_gain = (16 + ($compre & 0x0F)) / 32; 		// The combination of X and Y values allows compr to indicate gain changes from		//  48.16 - 0.28 = +47.89 dB, to		// -42.14 - 6.02 = -48.16 dB. 		return $log_gain - $lin_gain;	}

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