getid3_ac3::Analyze(): bool
- Source
wp-includes/ID3/module.audio.ac3.php:38
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_ac3::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
- Scaling
- Scales with input
- Instructions
- 77–300
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 1454.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What one call costs · 10 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost getid3_ac3::Analyze() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 77 | ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->error() |
!isset($thisfile_ac3_raw_bsi) && empty($thisfile_ac3_raw_bsi) | 259–274 | ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->version(), ->error(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::blocksPerSyncFrame(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::sampleRateCodeLookup(), ::audioCodingModeLookup(), ::channelsEnabledLookup() |
!isset($thisfile_ac3_raw_bsi) && empty($thisfile_ac3_raw_bsi) | 259–274 | ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->version(), ->error(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::blocksPerSyncFrame(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::sampleRateCodeLookup(), ->warning(), ::audioCodingModeLookup(), ::channelsEnabledLookup() |
empty($thisfile_ac3_raw_bsi) | 271–284 | ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->version(), ->error(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::blocksPerSyncFrame(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::sampleRateCodeLookup(), ::serviceTypeLookup(), ::audioCodingModeLookup(), ::channelsEnabledLookup() |
empty($thisfile_ac3_raw_bsi) | 271–284 | ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->version(), ->error(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::blocksPerSyncFrame(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::sampleRateCodeLookup(), ->warning(), ::serviceTypeLookup(), ::audioCodingModeLookup(), ::channelsEnabledLookup() |
!isset($thisfile_ac3_raw_bsi) && !empty($thisfile_ac3_raw_bsi) | 274–286 | ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->version(), ->error(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::blocksPerSyncFrame(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::sampleRateCodeLookup(), round(), ::audioCodingModeLookup(), ::channelsEnabledLookup() |
!isset($thisfile_ac3_raw_bsi) && !empty($thisfile_ac3_raw_bsi) | 274–289 | ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->version(), ->error(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::blocksPerSyncFrame(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::sampleRateCodeLookup(), ->warning(), round(), ::audioCodingModeLookup(), ::channelsEnabledLookup() |
| always | 275–290 | ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->version(), ->error(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::blocksPerSyncFrame(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::sampleRateCodeLookup(), ->warning(), ::frameSizeLookup(), ::bitrateLookup(), ::audioCodingModeLookup(), ::channelsEnabledLookup() |
!empty($thisfile_ac3_raw_bsi) | 286–299 | ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->version(), ->error(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::blocksPerSyncFrame(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::sampleRateCodeLookup(), ->warning(), round(), ::serviceTypeLookup(), ::audioCodingModeLookup(), ::channelsEnabledLookup() |
| always | 287–300 | ->fseek(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->version(), ->error(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::blocksPerSyncFrame(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ->readHeaderBSI(), ::sampleRateCodeLookup(), ->warning(), ::frameSizeLookup(), ::bitrateLookup(), ::serviceTypeLookup(), ::audioCodingModeLookup(), ::channelsEnabledLookup() |
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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 1454 | 77–300 | 88 | |
| 8.5 | 1454 | 77–300 | 88 | |
| 8.4 | 1454 | 77–300 | 88 | 16 fewer instructions than PHP 8.3 |
| 8.3 | 1470 | 86–309 | 88 | |
| 8.2 | 1470 | 86–309 | 88 | 1 more instruction than PHP 8.1 |
| 8.1 | 1469 | 86–309 | 88 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 1470 | 86–309 | 88 |
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 · 23
- getid3_ac3::fseek()
- getid3_ac3::fread()
- getid3_lib::BigEndian2Int()
- getid3_lib::BigEndian2Bin()
- getid3_lib::LittleEndian2Int()
- getid3_ac3::isDependencyFor()
- getid3_ac3::error()
- getid3_lib::Bin2Dec()
- getid3_ac3::readHeaderBSI()
- getid3_ac3::warning()
- getid3_ac3::centerMixLevelLookup()
- getid3_ac3::surroundMixLevelLookup()
Show all 23
- getid3_ac3::dolbySurroundModeLookup()
- getid3_ac3::heavyCompression()
- getid3_ac3::roomTypeLookup()
- getid3_ac3::blocksPerSyncFrame()
- getid3_ac3::sampleRateCodeLookup2()
- getid3_ac3::sampleRateCodeLookup()
- getid3_ac3::frameSizeLookup()
- getid3_ac3::bitrateLookup()
- getid3_ac3::serviceTypeLookup()
- getid3_ac3::audioCodingModeLookup()
- getid3_ac3::channelsEnabledLookup()
Source code
public function Analyze() { $info = &$this->getid3->info; ///AH $info['ac3']['raw']['bsi'] = array(); $thisfile_ac3 = &$info['ac3']; $thisfile_ac3_raw = &$thisfile_ac3['raw']; $thisfile_ac3_raw_bsi = &$thisfile_ac3_raw['bsi']; // http://www.atsc.org/standards/a_52a.pdf $info['fileformat'] = 'ac3'; // An AC-3 serial coded audio bit stream is made up of a sequence of synchronization frames // Each synchronization frame contains 6 coded audio blocks (AB), each of which represent 256 // new audio samples per channel. A synchronization information (SI) header at the beginning // of each frame contains information needed to acquire and maintain synchronization. A // bit stream information (BSI) header follows SI, and contains parameters describing the coded // audio service. The coded audio blocks may be followed by an auxiliary data (Aux) field. At the // end of each frame is an error check field that includes a CRC word for error detection. An // additional CRC word is located in the SI header, the use of which, by a decoder, is optional. // // syncinfo() | bsi() | AB0 | AB1 | AB2 | AB3 | AB4 | AB5 | Aux | CRC // syncinfo() { // syncword 16 // crc1 16 // fscod 2 // frmsizecod 6 // } /* end of syncinfo */ $this->fseek($info['avdataoffset']); $tempAC3header = $this->fread(100); // should be enough to cover all data, there are some variable-length fields...? $this->AC3header['syncinfo'] = getid3_lib::BigEndian2Int(substr($tempAC3header, 0, 2)); $this->AC3header['bsi'] = getid3_lib::BigEndian2Bin(substr($tempAC3header, 2)); $thisfile_ac3_raw_bsi['bsid'] = (getid3_lib::LittleEndian2Int(substr($tempAC3header, 5, 1)) & 0xF8) >> 3; // AC3 and E-AC3 put the "bsid" version identifier in the same place, but unfortnately the 4 bytes between the syncword and the version identifier are interpreted differently, so grab it here so the following code structure can make sense unset($tempAC3header); if ($this->AC3header['syncinfo'] !== self::syncword) { if (!$this->isDependencyFor('matroska')) { unset($info['fileformat'], $info['ac3']); return $this->error('Expecting "'.dechex(self::syncword).'" at offset '.$info['avdataoffset'].', found "'.dechex($this->AC3header['syncinfo']).'"'); } } $info['audio']['dataformat'] = 'ac3'; $info['audio']['bitrate_mode'] = 'cbr'; $info['audio']['lossless'] = false; if ($thisfile_ac3_raw_bsi['bsid'] <= 8) { $thisfile_ac3_raw_bsi['crc1'] = getid3_lib::Bin2Dec($this->readHeaderBSI(16)); $thisfile_ac3_raw_bsi['fscod'] = $this->readHeaderBSI(2); // 5.4.1.3 $thisfile_ac3_raw_bsi['frmsizecod'] = $this->readHeaderBSI(6); // 5.4.1.4 if ($thisfile_ac3_raw_bsi['frmsizecod'] > 37) { // binary: 100101 - see Table 5.18 Frame Size Code Table (1 word = 16 bits) $this->warning('Unexpected ac3.bsi.frmsizecod value: '.$thisfile_ac3_raw_bsi['frmsizecod'].', bitrate not set correctly'); } $thisfile_ac3_raw_bsi['bsid'] = $this->readHeaderBSI(5); // we already know this from pre-parsing the version identifier, but re-read it to let the bitstream flow as intended $thisfile_ac3_raw_bsi['bsmod'] = $this->readHeaderBSI(3); $thisfile_ac3_raw_bsi['acmod'] = $this->readHeaderBSI(3); if ($thisfile_ac3_raw_bsi['acmod'] & 0x01) { // If the lsb of acmod is a 1, center channel is in use and cmixlev follows in the bit stream. $thisfile_ac3_raw_bsi['cmixlev'] = $this->readHeaderBSI(2); $thisfile_ac3['center_mix_level'] = self::centerMixLevelLookup($thisfile_ac3_raw_bsi['cmixlev']); } if ($thisfile_ac3_raw_bsi['acmod'] & 0x04) { // If the msb of acmod is a 1, surround channels are in use and surmixlev follows in the bit stream. $thisfile_ac3_raw_bsi['surmixlev'] = $this->readHeaderBSI(2); $thisfile_ac3['surround_mix_level'] = self::surroundMixLevelLookup($thisfile_ac3_raw_bsi['surmixlev']); } if ($thisfile_ac3_raw_bsi['acmod'] == 0x02) { // When operating in the two channel mode, this 2-bit code indicates whether or not the program has been encoded in Dolby Surround. $thisfile_ac3_raw_bsi['dsurmod'] = $this->readHeaderBSI(2); $thisfile_ac3['dolby_surround_mode'] = self::dolbySurroundModeLookup($thisfile_ac3_raw_bsi['dsurmod']); }Changelog
Unchanged from 6.7.7 through 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.