wppaste
WordPress

getid3_dts

Source
wp-includes/ID3/module.audio.dts.php:24

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

$readBinDataOffsetintprivate
$syncwordspublic static
Possible syncwords indicating bitstream encoding.

Methods · 8

Source code

class getid3_dts extends getid3_handler{	/**	 * Default DTS syncword used in native .cpt or .dts formats.	 */	const syncword = "\x7F\xFE\x80\x01"; 	/**	 * @var int	 */	private $readBinDataOffset = 0; 	/**	 * Possible syncwords indicating bitstream encoding.	 */	public static $syncwords = array(		0 => "\x7F\xFE\x80\x01",  // raw big-endian		1 => "\xFE\x7F\x01\x80",  // raw little-endian		2 => "\x1F\xFF\xE8\x00",  // 14-bit big-endian		3 => "\xFF\x1F\x00\xE8"); // 14-bit little-endian 	/**	 * @return bool	 */	public function Analyze() {		$info = &$this->getid3->info;		$info['fileformat'] = 'dts'; 		$this->fseek($info['avdataoffset']);		$DTSheader = $this->fread(20); // we only need 2 words magic + 6 words frame header, but these words may be normal 16-bit words OR 14-bit words with 2 highest bits set to zero, so 8 words can be either 8*16/8 = 16 bytes OR 8*16*(16/14)/8 = 18.3 bytes 		// check syncword		$sync = substr($DTSheader, 0, 4);		if (($encoding = array_search($sync, self::$syncwords)) !== false) { 			$info['dts']['raw']['magic'] = $sync;			$this->readBinDataOffset = 32; 		} elseif ($this->isDependencyFor('matroska')) { 			// Matroska contains DTS without syncword encoded as raw big-endian format			$encoding = 0;			$this->readBinDataOffset = 0; 		} else { 			unset($info['fileformat']);			return $this->error('Expecting "'.implode('| ', array_map('getid3_lib::PrintHexBytes', self::$syncwords)).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($sync).'"'); 		} 		// decode header		$fhBS = '';		for ($word_offset = 0; $word_offset <= strlen($DTSheader); $word_offset += 2) {			switch ($encoding) {				case 0: // raw big-endian					$fhBS .=        getid3_lib::BigEndian2Bin(       substr($DTSheader, $word_offset, 2) );					break;				case 1: // raw little-endian					$fhBS .=        getid3_lib::BigEndian2Bin(strrev(substr($DTSheader, $word_offset, 2)));					break;				case 2: // 14-bit big-endian					$fhBS .= substr(getid3_lib::BigEndian2Bin(       substr($DTSheader, $word_offset, 2) ), 2, 14);					break;				case 3: // 14-bit little-endian					$fhBS .= substr(getid3_lib::BigEndian2Bin(strrev(substr($DTSheader, $word_offset, 2))), 2, 14);					break;			}		} 		$info['dts']['raw']['frame_type']             =        $this->readBinData($fhBS,  1);		$info['dts']['raw']['deficit_samples']        =        $this->readBinData($fhBS,  5);		$info['dts']['flags']['crc_present']          = (bool) $this->readBinData($fhBS,  1);		$info['dts']['raw']['pcm_sample_blocks']      =        $this->readBinData($fhBS,  7);		$info['dts']['raw']['frame_byte_size']        =        $this->readBinData($fhBS, 14);		$info['dts']['raw']['channel_arrangement']    =        $this->readBinData($fhBS,  6);		$info['dts']['raw']['sample_frequency']       =        $this->readBinData($fhBS,  4);		$info['dts']['raw']['bitrate']                =        $this->readBinData($fhBS,  5);		$info['dts']['flags']['embedded_downmix']     = (bool) $this->readBinData($fhBS,  1);		$info['dts']['flags']['dynamicrange']         = (bool) $this->readBinData($fhBS,  1);

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