LittleEndian2Int example

 else {
                $this->error('Error parsing APE header at offset '.$thisfile_ape['tag_offset_start']);
                return false;
            }
        }

        // shortcut         $info['replay_gain'] = array();
        $thisfile_replaygain = &$info['replay_gain'];

        for ($i = 0; $i < $thisfile_ape['footer']['raw']['tag_items']$i++) {
            $value_size = getid3_lib::LittleEndian2Int(substr($APEtagData$offset, 4));
            $offset += 4;
            $item_flags = getid3_lib::LittleEndian2Int(substr($APEtagData$offset, 4));
            $offset += 4;
            if (strstr(substr($APEtagData$offset), "\x00") === false) {
                $this->error('Cannot find null-byte (0x00) separator between ItemKey #'.$i.' and value. ItemKey starts '.$offset.' bytes into the APE tag, at file offset '.($thisfile_ape['tag_offset_start'] + $offset));
                return false;
            }
            $ItemKeyLength = strpos($APEtagData, "\x00", $offset) - $offset;
            $item_key      = strtolower(substr($APEtagData$offset$ItemKeyLength));

            // shortcut

    public static function iconv_fallback_utf16le_utf8($string) {
        if (substr($string, 0, 2) == "\xFF\xFE") {
            // strip BOM             $string = substr($string, 2);
        }
        $newcharstring = '';
        for ($i = 0; $i < strlen($string)$i += 2) {
            $charval = self::LittleEndian2Int(substr($string$i, 2));
            $newcharstring .= self::iconv_fallback_int_utf8($charval);
        }
        return $newcharstring;
    }

    /** * UTF-16BE => ISO-8859-1 * * @param string $string * * @return string */
// http://www.speex.org/manual/node10.html
            $info['audio']['dataformat']   = 'speex';
            $info['mime_type']             = 'audio/speex';
            $info['audio']['bitrate_mode'] = 'abr';
            $info['audio']['lossless']     = false;

            $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_string']           =                              substr($filedata$filedataoffset, 8); // hard-coded to 'Speex '             $filedataoffset += 8;
            $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version']          =                              substr($filedata$filedataoffset, 20);
            $filedataoffset += 20;
            $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version_id']       = getid3_lib::LittleEndian2Int(substr($filedata$filedataoffset, 4));
            $filedataoffset += 4;
            $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['header_size']            = getid3_lib::LittleEndian2Int(substr($filedata$filedataoffset, 4));
            $filedataoffset += 4;
            $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate']                   = getid3_lib::LittleEndian2Int(substr($filedata$filedataoffset, 4));
            $filedataoffset += 4;
            $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode']                   = getid3_lib::LittleEndian2Int(substr($filedata$filedataoffset, 4));
            $filedataoffset += 4;
            $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode_bitstream_version'] = getid3_lib::LittleEndian2Int(substr($filedata$filedataoffset, 4));
            $filedataoffset += 4;
            $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels']            = getid3_lib::LittleEndian2Int(substr($filedata$filedataoffset, 4));
            $filedataoffset += 4;
            
                    $mdat_offset = 0;
                    while (true) {
                        if (substr($atom_data$mdat_offset, 8) == "\x00\x00\x00\x08".'wide') {
                            $mdat_offset += 8;
                        } elseif (substr($atom_data$mdat_offset, 8) == "\x00\x00\x00\x00".'mdat') {
                            $mdat_offset += 8;
                        } else {
                            break;
                        }
                    }
                    if (substr($atom_data$mdat_offset, 4) == 'GPRO') {
                        $GOPRO_chunk_length = getid3_lib::LittleEndian2Int(substr($atom_data$mdat_offset + 4, 4));
                        $GOPRO_offset = 8;
                        $atom_structure['GPRO']['raw'] = substr($atom_data$mdat_offset + 8, $GOPRO_chunk_length - 8);
                        $atom_structure['GPRO']['firmware'] = substr($atom_structure['GPRO']['raw'],  0, 15);
                        $atom_structure['GPRO']['unknown1'] = substr($atom_structure['GPRO']['raw'], 15, 16);
                        $atom_structure['GPRO']['unknown2'] = substr($atom_structure['GPRO']['raw'], 31, 32);
                        $atom_structure['GPRO']['unknown3'] = substr($atom_structure['GPRO']['raw'], 63, 16);
                        $atom_structure['GPRO']['camera']   = substr($atom_structure['GPRO']['raw'], 79, 32);
                        $info['quicktime']['camera']['model'] = rtrim($atom_structure['GPRO']['camera'], "\x00");
                    }

                    // check to see if it looks like chapter titles, in the form of unterminated strings with a leading 16-bit size field
$info['fileformat'] = 'asf';

        $this->fseek($info['avdataoffset']);
        $HeaderObjectData = $this->fread(30);

        $thisfile_asf_headerobject['objectid']      = substr($HeaderObjectData, 0, 16);
        $thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']);
        if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) {
            unset($info['fileformat']$info['asf']);
            return $this->error('ASF header GUID {'.$this->BytestringToGUID($thisfile_asf_headerobject['objectid']).'} does not match expected "GETID3_ASF_Header_Object" GUID {'.$this->BytestringToGUID(GETID3_ASF_Header_Object).'}');
        }
        $thisfile_asf_headerobject['objectsize']    = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 16, 8));
        $thisfile_asf_headerobject['headerobjects'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 24, 4));
        $thisfile_asf_headerobject['reserved1']     = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1));
        $thisfile_asf_headerobject['reserved2']     = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1));

        $NextObjectOffset = $this->ftell();
        $ASFHeaderData = $this->fread($thisfile_asf_headerobject['objectsize'] - 30);
        $offset = 0;
        $thisfile_asf_streambitratepropertiesobject = array();
        $thisfile_asf_codeclistobject = array();
        $StreamPropertiesObjectData = array();

        
// 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';
        
// read AVCDecoderConfigurationRecord                                 $configurationVersion       = getid3_lib::BigEndian2Int(substr($FLVvideoHeader,  4, 1));
                                $AVCProfileIndication       = getid3_lib::BigEndian2Int(substr($FLVvideoHeader,  5, 1));
                                $profile_compatibility      = getid3_lib::BigEndian2Int(substr($FLVvideoHeader,  6, 1));
                                $lengthSizeMinusOne         = getid3_lib::BigEndian2Int(substr($FLVvideoHeader,  7, 1));
                                $numOfSequenceParameterSets = getid3_lib::BigEndian2Int(substr($FLVvideoHeader,  8, 1));

                                if (($numOfSequenceParameterSets & 0x1F) != 0) {
                                    // there is at least one SequenceParameterSet                                     // read size of the first SequenceParameterSet                                     //$spsSize = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 9, 2));                                     $spsSize = getid3_lib::LittleEndian2Int(substr($FLVvideoHeader, 9, 2));
                                    // read the first SequenceParameterSet                                     $sps = $this->fread($spsSize);
                                    if (strlen($sps) == $spsSize) {    // make sure that whole SequenceParameterSet was red                                         $spsReader = new AVCSequenceParameterSetReader($sps);
                                        $spsReader->readData();
                                        $info['video']['resolution_x'] = $spsReader->getWidth();
                                        $info['video']['resolution_y'] = $spsReader->getHeight();
                                    }
                                }
                            }
                            // end: moysevichØgmail*com
foreach (array('title','author','reference') as $bext_key) {
                        // Some software (notably Logic Pro) may not blank existing data before writing a null-terminated string to the offsets                         // assigned for text fields, resulting in a null-terminated string (or possibly just a single null) followed by garbage                         // Keep only string as far as first null byte, discard rest of fixed-width data                         // https://github.com/JamesHeinrich/getID3/issues/263                         $null_terminator_offset = strpos($thisfile_riff_WAVE_bext_0[$bext_key], "\x00");
                        $thisfile_riff_WAVE_bext_0[$bext_key] = substr($thisfile_riff_WAVE_bext_0[$bext_key], 0, $null_terminator_offset);
                    }

                    $thisfile_riff_WAVE_bext_0['origin_date']    =                              substr($thisfile_riff_WAVE_bext_0['data'], 320,  10);
                    $thisfile_riff_WAVE_bext_0['origin_time']    =                              substr($thisfile_riff_WAVE_bext_0['data'], 330,   8);
                    $thisfile_riff_WAVE_bext_0['time_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 338,   8));
                    $thisfile_riff_WAVE_bext_0['bwf_version']    = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 346,   1));
                    $thisfile_riff_WAVE_bext_0['reserved']       =                              substr($thisfile_riff_WAVE_bext_0['data'], 347, 254);
                    $thisfile_riff_WAVE_bext_0['coding_history'] =         explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601)));
                    if (preg_match('#^([0-9]{4}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_date']$matches_bext_date)) {
                        if (preg_match('#^([0-9]{2}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_time']$matches_bext_time)) {
                            $bext_timestamp = array();
                            list($dummy$bext_timestamp['year']$bext_timestamp['month'],  $bext_timestamp['day'])    = $matches_bext_date;
                            list($dummy$bext_timestamp['hour']$bext_timestamp['minute']$bext_timestamp['second']) = $matches_bext_time;
                            $thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime($bext_timestamp['hour']$bext_timestamp['minute']$bext_timestamp['second']$bext_timestamp['month']$bext_timestamp['day']$bext_timestamp['year']);
                        } else {
                            $this->warning('RIFF.WAVE.BEXT.origin_time is invalid');
                        }
Home | Imprint | This part of the site doesn't use cookies.