Bin2Dec example

$thisfile_riff_raw['rgad']    = array('track'=>array(), 'album'=>array());
                    $thisfile_riff_raw_rgad       = &$thisfile_riff_raw['rgad'];
                    $thisfile_riff_raw_rgad_track = &$thisfile_riff_raw_rgad['track'];
                    $thisfile_riff_raw_rgad_album = &$thisfile_riff_raw_rgad['album'];

                    $thisfile_riff_raw_rgad['fPeakAmplitude']      = getid3_lib::LittleEndian2Float(substr($rgadData, 0, 4));
                    $thisfile_riff_raw_rgad['nRadioRgAdjust']      =        $this->EitherEndian2Int(substr($rgadData, 4, 2));
                    $thisfile_riff_raw_rgad['nAudiophileRgAdjust'] =        $this->EitherEndian2Int(substr($rgadData, 6, 2));

                    $nRadioRgAdjustBitstring      = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
                    $nAudiophileRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
                    $thisfile_riff_raw_rgad_track['name']       = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 0, 3));
                    $thisfile_riff_raw_rgad_track['originator'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 3, 3));
                    $thisfile_riff_raw_rgad_track['signbit']    = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 6, 1));
                    $thisfile_riff_raw_rgad_track['adjustment'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 7, 9));
                    $thisfile_riff_raw_rgad_album['name']       = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 0, 3));
                    $thisfile_riff_raw_rgad_album['originator'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 3, 3));
                    $thisfile_riff_raw_rgad_album['signbit']    = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 6, 1));
                    $thisfile_riff_raw_rgad_album['adjustment'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 7, 9));

                    $thisfile_riff['rgad']['peakamplitude'] = $thisfile_riff_raw_rgad['fPeakAmplitude'];
                    if (($thisfile_riff_raw_rgad_track['name'] != 0) && ($thisfile_riff_raw_rgad_track['originator'] != 0)) {
                        $thisfile_riff['rgad']['track']['name']            = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_track['name']);
                        
public static function DecimalizeFraction($fraction) {
        list($numerator$denominator) = explode('/', $fraction);
        return $numerator / ($denominator ? $denominator : 1);
    }

    /** * @param string $binarynumerator * * @return float */
    public static function DecimalBinary2Float($binarynumerator) {
        $numerator   = self::Bin2Dec($binarynumerator);
        $denominator = self::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
        return ($numerator / $denominator);
    }

    /** * @link http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html * * @param string $binarypointnumber * @param int $maxbits * * @return array */
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) {
                

    public static function parseSTREAMINFOdata($BlockData) {
        $streaminfo = array();
        $streaminfo['min_block_size']  = getid3_lib::BigEndian2Int(substr($BlockData, 0, 2));
        $streaminfo['max_block_size']  = getid3_lib::BigEndian2Int(substr($BlockData, 2, 2));
        $streaminfo['min_frame_size']  = getid3_lib::BigEndian2Int(substr($BlockData, 4, 3));
        $streaminfo['max_frame_size']  = getid3_lib::BigEndian2Int(substr($BlockData, 7, 3));

        $SRCSBSS                       = getid3_lib::BigEndian2Bin(substr($BlockData, 10, 8));
        $streaminfo['sample_rate']     = getid3_lib::Bin2Dec(substr($SRCSBSS,  0, 20));
        $streaminfo['channels']        = getid3_lib::Bin2Dec(substr($SRCSBSS, 20,  3)) + 1;
        $streaminfo['bits_per_sample'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 23,  5)) + 1;
        $streaminfo['samples_stream']  = getid3_lib::Bin2Dec(substr($SRCSBSS, 28, 36));

        $streaminfo['audio_signature'] =                           substr($BlockData, 18, 16);

        return $streaminfo;
    }

    /** * @param string $BlockData * * @return bool */
Home | Imprint | This part of the site doesn't use cookies.