BigEndian2Int example

                break;

            case 4:
                // %abcd0000 in v2.4                 $thisfile_id3v2_flags['unsynch']     = (bool) ($id3_flags & 0x80); // a - Unsynchronisation                 $thisfile_id3v2_flags['exthead']     = (bool) ($id3_flags & 0x40); // b - Extended header                 $thisfile_id3v2_flags['experim']     = (bool) ($id3_flags & 0x20); // c - Experimental indicator                 $thisfile_id3v2_flags['isfooter']    = (bool) ($id3_flags & 0x10); // d - Footer present                 break;
        }

        $thisfile_id3v2['headerlength'] = getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
        $thisfile_id3v2['tag_offset_start'] = $this->StartingOffset;
        $thisfile_id3v2['tag_offset_end']   = $thisfile_id3v2['tag_offset_start'] + $thisfile_id3v2['headerlength'];



        // create 'encoding' key - used by getid3::HandleAllTags()         // in ID3v2 every field can have it's own encoding type         // so force everything to UTF-8 so it can be handled consistantly         $thisfile_id3v2['encoding'] = 'UTF-8';


    
        // 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']).'"');
            }
        }

        

            }

            // ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier             if (!$this->option_tag_id3v2) {
                fseek($this->fp, 0);
                $header = fread($this->fp, 10);
                if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) {
                    $this->info['id3v2']['header']        = true;
                    $this->info['id3v2']['majorversion']  = ord($header[3]);
                    $this->info['id3v2']['minorversion']  = ord($header[4]);
                    $this->info['avdataoffset']          += getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length                 }
            }

            // read 32 kb file data             fseek($this->fp, $this->info['avdataoffset']);
            $formattest = fread($this->fp, 32774);

            // determine format             $determined_format = $this->GetFileFormat($formattest($original_filename ? $original_filename : $filename));

            // unable to determine file format
$this->error('Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions');
                break;
            }
            $this->fseek($offset);
            $AtomHeader = $this->fread(8);

            // https://github.com/JamesHeinrich/getID3/issues/382             // Atom sizes are stored as 32-bit number in most cases, but sometimes (notably for "mdat")             // a 64-bit value is required, in which case the normal 32-bit size field is set to 0x00000001             // and the 64-bit "real" size value is the next 8 bytes.             $atom_size_extended_bytes = 0;
            $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
            $atomname = substr($AtomHeader, 4, 4);
            if ($atomsize == 1) {
                $atom_size_extended_bytes = 8;
                $atomsize = getid3_lib::BigEndian2Int($this->fread($atom_size_extended_bytes));
            }

            if (($offset + $atomsize) > $info['avdataend']) {
                $info['quicktime'][$atomname]['name']   = $atomname;
                $info['quicktime'][$atomname]['size']   = $atomsize;
                $info['quicktime'][$atomname]['offset'] = $offset;
                $this->error('Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)');
                

        return self::CastAsInt($intvalue);
    }

    /** * @param string $byteword * @param bool $signed * * @return int|float|false */
    public static function LittleEndian2Int($byteword$signed=false) {
        return self::BigEndian2Int(strrev($byteword), false, $signed);
    }

    /** * @param string $byteword * * @return string */
    public static function LittleEndian2Bin($byteword) {
        return self::BigEndian2Bin(strrev($byteword));
    }

    
$thisfile_mpeg_audio['protection']    = !$thisfile_mpeg_audio['raw']['protection'];
            $thisfile_mpeg_audio['private']       = (bool) $thisfile_mpeg_audio['raw']['private'];
            $thisfile_mpeg_audio['modeextension'] = $MPEGaudioModeExtensionLookup[$thisfile_mpeg_audio['layer']][$thisfile_mpeg_audio['raw']['modeextension']];
            $thisfile_mpeg_audio['copyright']     = (bool) $thisfile_mpeg_audio['raw']['copyright'];
            $thisfile_mpeg_audio['original']      = (bool) $thisfile_mpeg_audio['raw']['original'];
            $thisfile_mpeg_audio['emphasis']      = $MPEGaudioEmphasisLookup[$thisfile_mpeg_audio['raw']['emphasis']];

            $info['audio']['channels']    = $thisfile_mpeg_audio['channels'];
            $info['audio']['sample_rate'] = $thisfile_mpeg_audio['sample_rate'];

            if ($thisfile_mpeg_audio['protection']) {
                $thisfile_mpeg_audio['crc'] = getid3_lib::BigEndian2Int(substr($headerstring, 4, 2));
            }
        }

        if ($thisfile_mpeg_audio['raw']['bitrate'] == 15) {
            // http://www.hydrogenaudio.org/?act=ST&f=16&t=9682&st=0             $this->warning('Invalid bitrate index (15), this is a known bug in free-format MP3s encoded by LAME v3.90 - 3.93.1');
            $thisfile_mpeg_audio['raw']['bitrate'] = 0;
        }
        $thisfile_mpeg_audio['padding'] = (bool) $thisfile_mpeg_audio['raw']['padding'];
        $thisfile_mpeg_audio['bitrate'] = $MPEGaudioBitrateLookup[$thisfile_mpeg_audio['version']][$thisfile_mpeg_audio['layer']][$thisfile_mpeg_audio['raw']['bitrate']];

        

    public function Analyze() {
        $info = &$this->getid3->info;

        $this->fseek($info['avdataoffset']);

        $FLVdataLength = $info['avdataend'] - $info['avdataoffset'];
        $FLVheader = $this->fread(5);

        $info['fileformat'] = 'flv';
        $info['flv']['header']['signature'] =                           substr($FLVheader, 0, 3);
        $info['flv']['header']['version']   = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
        $TypeFlags                          = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));

        if ($info['flv']['header']['signature'] != self::magic) {
            $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['flv']['header']['signature']).'"');
            unset($info['flv']$info['fileformat']);
            return false;
        }

        $info['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04);
        $info['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01);

        
if (isset($thisfile_riff_WAVE['SNDM'][0]['data'])) {
                    // SoundMiner metadata
                    // shortcuts                     $thisfile_riff_WAVE_SNDM_0      = &$thisfile_riff_WAVE['SNDM'][0];
                    $thisfile_riff_WAVE_SNDM_0_data = &$thisfile_riff_WAVE_SNDM_0['data'];
                    $SNDM_startoffset = 0;
                    $SNDM_endoffset   = $thisfile_riff_WAVE_SNDM_0['size'];

                    while ($SNDM_startoffset < $SNDM_endoffset) {
                        $SNDM_thisTagOffset = 0;
                        $SNDM_thisTagSize      = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data$SNDM_startoffset + $SNDM_thisTagOffset, 4));
                        $SNDM_thisTagOffset += 4;
                        $SNDM_thisTagKey       =                           substr($thisfile_riff_WAVE_SNDM_0_data$SNDM_startoffset + $SNDM_thisTagOffset, 4);
                        $SNDM_thisTagOffset += 4;
                        $SNDM_thisTagDataSize  = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data$SNDM_startoffset + $SNDM_thisTagOffset, 2));
                        $SNDM_thisTagOffset += 2;
                        $SNDM_thisTagDataFlags = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data$SNDM_startoffset + $SNDM_thisTagOffset, 2));
                        $SNDM_thisTagOffset += 2;
                        $SNDM_thisTagDataText =                            substr($thisfile_riff_WAVE_SNDM_0_data$SNDM_startoffset + $SNDM_thisTagOffset$SNDM_thisTagDataSize);
                        $SNDM_thisTagOffset += $SNDM_thisTagDataSize;

                        if ($SNDM_thisTagSize != (4 + 4 + 2 + 2 + $SNDM_thisTagDataSize)) {
                            
$info['audio']['channels']      = $info['speex']['channels'];
            if ($info['speex']['vbr']) {
                $info['audio']['bitrate_mode'] = 'vbr';
            }

        } elseif (substr($filedata, 0, 7) == "\x80".'theora') {

            // http://www.theora.org/doc/Theora.pdf (section 6.2)
            $info['ogg']['pageheader']['theora']['theora_magic']             =                           substr($filedata$filedataoffset,  7); // hard-coded to "\x80.'theora'             $filedataoffset += 7;
            $info['ogg']['pageheader']['theora']['version_major']            = getid3_lib::BigEndian2Int(substr($filedata$filedataoffset,  1));
            $filedataoffset += 1;
            $info['ogg']['pageheader']['theora']['version_minor']            = getid3_lib::BigEndian2Int(substr($filedata$filedataoffset,  1));
            $filedataoffset += 1;
            $info['ogg']['pageheader']['theora']['version_revision']         = getid3_lib::BigEndian2Int(substr($filedata$filedataoffset,  1));
            $filedataoffset += 1;
            $info['ogg']['pageheader']['theora']['frame_width_macroblocks']  = getid3_lib::BigEndian2Int(substr($filedata$filedataoffset,  2));
            $filedataoffset += 2;
            $info['ogg']['pageheader']['theora']['frame_height_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata$filedataoffset,  2));
            $filedataoffset += 2;
            $info['ogg']['pageheader']['theora']['resolution_x']             = getid3_lib::BigEndian2Int(substr($filedata$filedataoffset,  3));
            $filedataoffset += 3;
            
$info['matroska']['header']['length'] = $top_element['length'];

                    while ($this->getEBMLelement($element_data$top_element['end'], true)) {
                        switch ($element_data['id']) {

                            case EBML_ID_EBMLVERSION:
                            case EBML_ID_EBMLREADVERSION:
                            case EBML_ID_EBMLMAXIDLENGTH:
                            case EBML_ID_EBMLMAXSIZELENGTH:
                            case EBML_ID_DOCTYPEVERSION:
                            case EBML_ID_DOCTYPEREADVERSION:
                                $element_data['data'] = getid3_lib::BigEndian2Int($element_data['data']);
                                break;

                            case EBML_ID_DOCTYPE:
                                $element_data['data'] = getid3_lib::trimNullByte($element_data['data']);
                                $info['matroska']['doctype'] = $element_data['data'];
                                $info['fileformat'] = $element_data['data'];
                                break;

                            default:
                                $this->unhandledElement('header', __LINE__, $element_data);
                                break;
                        }
        return $this->parseMETAdata();
    }

    /** * @return bool */
    public function parseMETAdata() {
        $info = &$this->getid3->info;
        do {
            $BlockOffset   = $this->ftell();
            $BlockHeader   = $this->fread(4);
            $LBFBT         = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1));  // LBFBT = LastBlockFlag + BlockType             $LastBlockFlag = (bool) ($LBFBT & 0x80);
            $BlockType     =        ($LBFBT & 0x7F);
            $BlockLength   = getid3_lib::BigEndian2Int(substr($BlockHeader, 1, 3));
            $BlockTypeText = self::metaBlockTypeLookup($BlockType);

            if (($BlockOffset + 4 + $BlockLength) > $info['avdataend']) {
                $this->warning('METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockTypeText.') at offset '.$BlockOffset.' extends beyond end of file');
                break;
            }
            if ($BlockLength < 1) {
                if ($BlockTypeText != 'reserved') {
                    
Home | Imprint | This part of the site doesn't use cookies.