getid3_ac3::Analyze() –

You appear to be a bot. Output may be restricted

Description

Usage

$bool = getid3_ac3::Analyze();

Parameters

Returns

bool

Source

File name: wordpress/wp-includes/ID3/module.audio.ac3.php
Lines:

1 to 100 of 449
  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->getid3_ac3::readHeaderBSI(16));
      $thisfile_ac3_raw_bsi['fscod']      =                     $this->getid3_ac3::readHeaderBSI(2);   // 5.4.1.3
      $thisfile_ac3_raw_bsi['frmsizecod'] =                     $this->getid3_ac3::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->getid3_ac3::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->getid3_ac3::readHeaderBSI(3);
      $thisfile_ac3_raw_bsi['acmod'] = $this->getid3_ac3::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->getid3_ac3::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->getid3_ac3::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->getid3_ac3::readHeaderBSI(2);
        $thisfile_ac3['dolby_surround_mode'] = self::dolbySurroundModeLookup($thisfile_ac3_raw_bsi['dsurmod']);
      }

      $thisfile_ac3_raw_bsi['flags']['lfeon'] = (bool) $this->getid3_ac3::readHeaderBSI(1);

      // This indicates how far the average dialogue level is below digital 100 percent. Valid values are 1-31.
      // The value of 0 is reserved. The values of 1 to 31 are interpreted as -1 dB to -31 dB with respect to digital 100 percent.
      $thisfile_ac3_raw_bsi['dialnorm'] = $this->getid3_ac3::readHeaderBSI(5);                 // 5.4.2.8 dialnorm: Dialogue Normalization, 5 Bits

      $thisfile_ac3_raw_bsi['flags']['compr'] = (bool) $this->getid3_ac3::readHeaderBSI(1);       // 5.4.2.9 compre: Compression Gain Word Exists, 1 Bit
      if ($thisfile_ac3_raw_bsi['flags']['compr']) {
        $thisfile_ac3_raw_bsi['compr'] = $this->getid3_ac3::readHeaderBSI(8);                // 5.4.2.10 compr: Compression Gain Word, 8 Bits
        $thisfile_ac3['heavy_compression'] = self::heavyCompression($thisfile_ac3_raw_bsi['compr']);
      }

      $thisfile_ac3_raw_bsi['flags']['langcod'] = (bool) $this->getid3_ac3::readHeaderBSI(1);     // 5.4.2.11 langcode: Language Code Exists, 1 Bit
      if ($thisfile_ac3_raw_bsi['flags']['langcod']) {
        $thisfile_ac3_raw_bsi['langcod'] = $this->getid3_ac3::readHeaderBSI(8);              // 5.4.2.12 langcod: Language Code, 8 Bits
      }

      $thisfile_ac3_raw_bsi['flags']['audprodinfo'] = (bool) $this->getid3_ac3::readHeaderBSI(1);  // 5.4.2.13 audprodie: Audio Production Information Exists, 1 Bit
      if ($thisfile_ac3_raw_bsi['flags']['audprodinfo']) {
 

 View on GitHub View on Trac