wppaste
WordPress

getid3_ac3

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

Compatibility

WordPress
core
  • 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).

Properties · 2

$AC3headerarrayprivate
$BSIoffsetintprivate

Methods · 15

Source code

class getid3_ac3 extends getid3_handler{	/**	 * @var array	 */	private $AC3header = array(); 	/**	 * @var int	 */	private $BSIoffset = 0; 	const syncword = 0x0B77; 	/**	 * @return bool	 */	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);

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.