當前位置: 首頁>>代碼示例>>PHP>>正文


PHP getid3_lib::BigEndian2Int方法代碼示例

本文整理匯總了PHP中getid3_lib::BigEndian2Int方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::BigEndian2Int方法的具體用法?PHP getid3_lib::BigEndian2Int怎麽用?PHP getid3_lib::BigEndian2Int使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在getid3_lib的用法示例。


在下文中一共展示了getid3_lib::BigEndian2Int方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Analyze

 public function Analyze()
 {
     $getid3 = $this->getid3;
     fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
     $au_header = fread($getid3->fp, 8);
     // Magic bytes: .snd
     $getid3->info['au'] = array();
     $info_au =& $getid3->info['au'];
     $getid3->info['fileformat'] = 'au';
     $getid3->info['audio']['dataformat'] = 'au';
     $getid3->info['audio']['bitrate_mode'] = 'cbr';
     $info_au['encoding'] = 'ISO-8859-1';
     $info_au['header_length'] = getid3_lib::BigEndian2Int(substr($au_header, 4, 4));
     $au_header .= fread($getid3->fp, $info_au['header_length'] - 8);
     $getid3->info['avdataoffset'] += $info_au['header_length'];
     getid3_lib::ReadSequence('BigEndian2Int', $info_au, $au_header, 8, array('data_size' => 4, 'data_format_id' => 4, 'sample_rate' => 4, 'channels' => 4));
     $info_au['comments']['comment'][] = trim(substr($au_header, 24));
     $info_au['data_format'] = getid3_au::AUdataFormatNameLookup($info_au['data_format_id']);
     $info_au['used_bits_per_sample'] = getid3_au::AUdataFormatUsedBitsPerSampleLookup($info_au['data_format_id']);
     if ($info_au['bits_per_sample'] = getid3_au::AUdataFormatBitsPerSampleLookup($info_au['data_format_id'])) {
         $getid3->info['audio']['bits_per_sample'] = $info_au['bits_per_sample'];
     } else {
         unset($info_au['bits_per_sample']);
     }
     $getid3->info['audio']['sample_rate'] = $info_au['sample_rate'];
     $getid3->info['audio']['channels'] = $info_au['channels'];
     if ($getid3->info['avdataoffset'] + $info_au['data_size'] > $getid3->info['avdataend']) {
         $getid3->warning('Possible truncated file - expecting "' . $info_au['data_size'] . '" bytes of audio data, only found ' . ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) . ' bytes"');
     }
     $getid3->info['playtime_seconds'] = $info_au['data_size'] / ($info_au['sample_rate'] * $info_au['channels'] * ($info_au['used_bits_per_sample'] / 8));
     $getid3->info['audio']['bitrate'] = $info_au['data_size'] * 8 / $getid3->info['playtime_seconds'];
     return true;
 }
開發者ID:pheski,項目名稱:Scribite,代碼行數:33,代碼來源:module.audio.au.php

示例2: Analyze

 function Analyze()
 {
     $info =& $this->getid3->info;
     fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     $SZIPHeader = fread($this->getid3->fp, 6);
     if (substr($SZIPHeader, 0, 4) != "SZ\n") {
         $info['error'][] = 'Expecting "53 5A 0A 04" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($SZIPHeader, 0, 4)) . '"';
         return false;
     }
     $info['fileformat'] = 'szip';
     $info['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 4, 1));
     $info['szip']['minor_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 5, 1));
     while (!feof($this->getid3->fp)) {
         $NextBlockID = fread($this->getid3->fp, 2);
         switch ($NextBlockID) {
             case 'SZ':
                 // Note that szip files can be concatenated, this has the same effect as
                 // concatenating the files. this also means that global header blocks
                 // might be present between directory/data blocks.
                 fseek($this->getid3->fp, 4, SEEK_CUR);
                 break;
             case 'BH':
                 $BHheaderbytes = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 3));
                 $BHheaderdata = fread($this->getid3->fp, $BHheaderbytes);
                 $BHheaderoffset = 0;
                 while (strpos($BHheaderdata, "", $BHheaderoffset) > 0) {
                     //filename as \0 terminated string  (empty string indicates end)
                     //owner as \0 terminated string (empty is same as last file)
                     //group as \0 terminated string (empty is same as last file)
                     //3 byte filelength in this block
                     //2 byte access flags
                     //4 byte creation time (like in unix)
                     //4 byte modification time (like in unix)
                     //4 byte access time (like in unix)
                     $BHdataArray['filename'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, ""));
                     $BHheaderoffset += strlen($BHdataArray['filename']) + 1;
                     $BHdataArray['owner'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, ""));
                     $BHheaderoffset += strlen($BHdataArray['owner']) + 1;
                     $BHdataArray['group'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, ""));
                     $BHheaderoffset += strlen($BHdataArray['group']) + 1;
                     $BHdataArray['filelength'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 3));
                     $BHheaderoffset += 3;
                     $BHdataArray['access_flags'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 2));
                     $BHheaderoffset += 2;
                     $BHdataArray['creation_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
                     $BHheaderoffset += 4;
                     $BHdataArray['modification_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
                     $BHheaderoffset += 4;
                     $BHdataArray['access_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
                     $BHheaderoffset += 4;
                     $info['szip']['BH'][] = $BHdataArray;
                 }
                 break;
             default:
                 break 2;
         }
     }
     return true;
 }
開發者ID:thelectronicnub,項目名稱:shimmie2,代碼行數:59,代碼來源:module.archive.szip.php

示例3: Analyze

 public function Analyze()
 {
     $getid3 = $this->getid3;
     fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
     $szip_rkau = fread($getid3->fp, 6);
     // Magic bytes:  'SZ'."\x0A\x04"
     $getid3->info['fileformat'] = 'szip';
     $getid3->info['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($szip_rkau, 4, 1));
     $getid3->info['szip']['minor_version'] = getid3_lib::BigEndian2Int(substr($szip_rkau, 5, 1));
     while (!feof($getid3->fp)) {
         $next_block_id = fread($getid3->fp, 2);
         switch ($next_block_id) {
             case 'SZ':
                 // Note that szip files can be concatenated, this has the same effect as
                 // concatenating the files. this also means that global header blocks
                 // might be present between directory/data blocks.
                 fseek($getid3->fp, 4, SEEK_CUR);
                 break;
             case 'BH':
                 $bh_header_bytes = getid3_lib::BigEndian2Int(fread($getid3->fp, 3));
                 $bh_header_data = fread($getid3->fp, $bh_header_bytes);
                 $bh_header_offset = 0;
                 while (strpos($bh_header_data, "", $bh_header_offset) > 0) {
                     //filename as \0 terminated string  (empty string indicates end)
                     //owner as \0 terminated string (empty is same as last file)
                     //group as \0 terminated string (empty is same as last file)
                     //3 byte filelength in this block
                     //2 byte access flags
                     //4 byte creation time (like in unix)
                     //4 byte modification time (like in unix)
                     //4 byte access time (like in unix)
                     $bh_data_array['filename'] = substr($bh_header_data, $bh_header_offset, strcspn($bh_header_data, ""));
                     $bh_header_offset += strlen($bh_data_array['filename']) + 1;
                     $bh_data_array['owner'] = substr($bh_header_data, $bh_header_offset, strcspn($bh_header_data, ""));
                     $bh_header_offset += strlen($bh_data_array['owner']) + 1;
                     $bh_data_array['group'] = substr($bh_header_data, $bh_header_offset, strcspn($bh_header_data, ""));
                     $bh_header_offset += strlen($bh_data_array['group']) + 1;
                     $bh_data_array['filelength'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 3));
                     $bh_header_offset += 3;
                     $bh_data_array['access_flags'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 2));
                     $bh_header_offset += 2;
                     $bh_data_array['creation_time'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 4));
                     $bh_header_offset += 4;
                     $bh_data_array['modification_time'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 4));
                     $bh_header_offset += 4;
                     $bh_data_array['access_time'] = getid3_lib::BigEndian2Int(substr($bh_header_data, $bh_header_offset, 4));
                     $bh_header_offset += 4;
                     $getid3->info['szip']['BH'][] = $bh_data_array;
                 }
                 break;
             default:
                 break 2;
         }
     }
     return true;
 }
開發者ID:peterlindkvist,項目名稱:apache-player,代碼行數:56,代碼來源:module.archive.szip.php

示例4: Analyze

 public function Analyze()
 {
     $info =& $this->getid3->info;
     fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     $AUheader = fread($this->getid3->fp, 8);
     $magic = '.snd';
     if (substr($AUheader, 0, 4) != $magic) {
         $info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" (".snd") at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($AUheader, 0, 4)) . '"';
         return false;
     }
     // shortcut
     $info['au'] = array();
     $thisfile_au =& $info['au'];
     $info['fileformat'] = 'au';
     $info['audio']['dataformat'] = 'au';
     $info['audio']['bitrate_mode'] = 'cbr';
     $thisfile_au['encoding'] = 'ISO-8859-1';
     $thisfile_au['header_length'] = getid3_lib::BigEndian2Int(substr($AUheader, 4, 4));
     $AUheader .= fread($this->getid3->fp, $thisfile_au['header_length'] - 8);
     $info['avdataoffset'] += $thisfile_au['header_length'];
     $thisfile_au['data_size'] = getid3_lib::BigEndian2Int(substr($AUheader, 8, 4));
     $thisfile_au['data_format_id'] = getid3_lib::BigEndian2Int(substr($AUheader, 12, 4));
     $thisfile_au['sample_rate'] = getid3_lib::BigEndian2Int(substr($AUheader, 16, 4));
     $thisfile_au['channels'] = getid3_lib::BigEndian2Int(substr($AUheader, 20, 4));
     $thisfile_au['comments']['comment'][] = trim(substr($AUheader, 24));
     $thisfile_au['data_format'] = $this->AUdataFormatNameLookup($thisfile_au['data_format_id']);
     $thisfile_au['used_bits_per_sample'] = $this->AUdataFormatUsedBitsPerSampleLookup($thisfile_au['data_format_id']);
     if ($thisfile_au['bits_per_sample'] = $this->AUdataFormatBitsPerSampleLookup($thisfile_au['data_format_id'])) {
         $info['audio']['bits_per_sample'] = $thisfile_au['bits_per_sample'];
     } else {
         unset($thisfile_au['bits_per_sample']);
     }
     $info['audio']['sample_rate'] = $thisfile_au['sample_rate'];
     $info['audio']['channels'] = $thisfile_au['channels'];
     if ($info['avdataoffset'] + $thisfile_au['data_size'] > $info['avdataend']) {
         $info['warning'][] = 'Possible truncated file - expecting "' . $thisfile_au['data_size'] . '" bytes of audio data, only found ' . ($info['avdataend'] - $info['avdataoffset']) . ' bytes"';
     }
     $info['playtime_seconds'] = $thisfile_au['data_size'] / ($thisfile_au['sample_rate'] * $thisfile_au['channels'] * ($thisfile_au['used_bits_per_sample'] / 8));
     $info['audio']['bitrate'] = $thisfile_au['data_size'] * 8 / $info['playtime_seconds'];
     return true;
 }
開發者ID:cyrilix,項目名稱:rompr,代碼行數:41,代碼來源:module.audio.au.php

示例5: EBML2Int

 function EBML2Int($EBMLstring)
 {
     // http://matroska.org/specs/
     // Element ID coded with an UTF-8 like system:
     // 1xxx xxxx                                  - Class A IDs (2^7 -2 possible values) (base 0x8X)
     // 01xx xxxx  xxxx xxxx                       - Class B IDs (2^14-2 possible values) (base 0x4X 0xXX)
     // 001x xxxx  xxxx xxxx  xxxx xxxx            - Class C IDs (2^21-2 possible values) (base 0x2X 0xXX 0xXX)
     // 0001 xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx - Class D IDs (2^28-2 possible values) (base 0x1X 0xXX 0xXX 0xXX)
     // Values with all x at 0 and 1 are reserved (hence the -2).
     // Data size, in octets, is also coded with an UTF-8 like system :
     // 1xxx xxxx                                                                              - value 0 to  2^7-2
     // 01xx xxxx  xxxx xxxx                                                                   - value 0 to 2^14-2
     // 001x xxxx  xxxx xxxx  xxxx xxxx                                                        - value 0 to 2^21-2
     // 0001 xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx                                             - value 0 to 2^28-2
     // 0000 1xxx  xxxx xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx                                  - value 0 to 2^35-2
     // 0000 01xx  xxxx xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx                       - value 0 to 2^42-2
     // 0000 001x  xxxx xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx            - value 0 to 2^49-2
     // 0000 0001  xxxx xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx  xxxx xxxx - value 0 to 2^56-2
     if (0x80 & ord($EBMLstring[0])) {
         $EBMLstring[0] = chr(ord($EBMLstring[0]) & 0x7f);
     } elseif (0x40 & ord($EBMLstring[0])) {
         $EBMLstring[0] = chr(ord($EBMLstring[0]) & 0x3f);
     } elseif (0x20 & ord($EBMLstring[0])) {
         $EBMLstring[0] = chr(ord($EBMLstring[0]) & 0x1f);
     } elseif (0x10 & ord($EBMLstring[0])) {
         $EBMLstring[0] = chr(ord($EBMLstring[0]) & 0xf);
     } elseif (0x8 & ord($EBMLstring[0])) {
         $EBMLstring[0] = chr(ord($EBMLstring[0]) & 0x7);
     } elseif (0x4 & ord($EBMLstring[0])) {
         $EBMLstring[0] = chr(ord($EBMLstring[0]) & 0x3);
     } elseif (0x2 & ord($EBMLstring[0])) {
         $EBMLstring[0] = chr(ord($EBMLstring[0]) & 0x1);
     } elseif (0x1 & ord($EBMLstring[0])) {
         $EBMLstring[0] = chr(ord($EBMLstring[0]) & 0x0);
     } else {
         return false;
     }
     return getid3_lib::BigEndian2Int($EBMLstring);
 }
開發者ID:BGCX261,項目名稱:zoom-gallery-svn-to-git,代碼行數:39,代碼來源:module.audio-video.matroska.php

示例6: getid3_dts

 function getid3_dts(&$fd, &$ThisFileInfo)
 {
     // Specs taken from "DTS Coherent Acoustics;Core and Extensions,  ETSI TS 102 114 V1.2.1 (2002-12)"
     // (http://pda.etsi.org/pda/queryform.asp)
     // With thanks to Gambit <macteam@users.sourceforge.net> http://mac.sourceforge.net/atl/
     $ThisFileInfo['fileformat'] = 'dts';
     fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
     $DTSheader = fread($fd, 16);
     $ThisFileInfo['dts']['raw']['magic'] = getid3_lib::BigEndian2Int(substr($DTSheader, 0, 4));
     if ($ThisFileInfo['dts']['raw']['magic'] != 0x7ffe8001) {
         $ThisFileInfo['error'][] = 'Expecting "0x7FFE8001" at offset ' . $ThisFileInfo['avdataoffset'] . ', found "0x' . str_pad(strtoupper(dechex($ThisFileInfo['dts']['raw']['magic'])), 8, '0', STR_PAD_LEFT) . '"';
         unset($ThisFileInfo['fileformat']);
         unset($ThisFileInfo['dts']);
         return false;
     }
     $fhBS = getid3_lib::BigEndian2Bin(substr($DTSheader, 4, 12));
     $bsOffset = 0;
     $ThisFileInfo['dts']['raw']['frame_type'] = bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['raw']['deficit_samples'] = bindec(substr($fhBS, $bsOffset, 5));
     $bsOffset += 5;
     $ThisFileInfo['dts']['flags']['crc_present'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['raw']['pcm_sample_blocks'] = bindec(substr($fhBS, $bsOffset, 7));
     $bsOffset += 7;
     $ThisFileInfo['dts']['raw']['frame_byte_size'] = bindec(substr($fhBS, $bsOffset, 14));
     $bsOffset += 14;
     $ThisFileInfo['dts']['raw']['channel_arrangement'] = bindec(substr($fhBS, $bsOffset, 6));
     $bsOffset += 6;
     $ThisFileInfo['dts']['raw']['sample_frequency'] = bindec(substr($fhBS, $bsOffset, 4));
     $bsOffset += 4;
     $ThisFileInfo['dts']['raw']['bitrate'] = bindec(substr($fhBS, $bsOffset, 5));
     $bsOffset += 5;
     $ThisFileInfo['dts']['flags']['embedded_downmix'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['flags']['dynamicrange'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['flags']['timestamp'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['flags']['auxdata'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['flags']['hdcd'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['raw']['extension_audio'] = bindec(substr($fhBS, $bsOffset, 3));
     $bsOffset += 3;
     $ThisFileInfo['dts']['flags']['extended_coding'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['flags']['audio_sync_insertion'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['raw']['lfe_effects'] = bindec(substr($fhBS, $bsOffset, 2));
     $bsOffset += 2;
     $ThisFileInfo['dts']['flags']['predictor_history'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     if ($ThisFileInfo['dts']['flags']['crc_present']) {
         $ThisFileInfo['dts']['raw']['crc16'] = bindec(substr($fhBS, $bsOffset, 16));
         $bsOffset += 16;
     }
     $ThisFileInfo['dts']['flags']['mri_perfect_reconst'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['raw']['encoder_soft_version'] = bindec(substr($fhBS, $bsOffset, 4));
     $bsOffset += 4;
     $ThisFileInfo['dts']['raw']['copy_history'] = bindec(substr($fhBS, $bsOffset, 2));
     $bsOffset += 2;
     $ThisFileInfo['dts']['raw']['bits_per_sample'] = bindec(substr($fhBS, $bsOffset, 2));
     $bsOffset += 2;
     $ThisFileInfo['dts']['flags']['surround_es'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['flags']['front_sum_diff'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['flags']['surround_sum_diff'] = (bool) bindec(substr($fhBS, $bsOffset, 1));
     $bsOffset += 1;
     $ThisFileInfo['dts']['raw']['dialog_normalization'] = bindec(substr($fhBS, $bsOffset, 4));
     $bsOffset += 4;
     $ThisFileInfo['dts']['bitrate'] = $this->DTSbitrateLookup($ThisFileInfo['dts']['raw']['bitrate']);
     $ThisFileInfo['dts']['bits_per_sample'] = $this->DTSbitPerSampleLookup($ThisFileInfo['dts']['raw']['bits_per_sample']);
     $ThisFileInfo['dts']['sample_rate'] = $this->DTSsampleRateLookup($ThisFileInfo['dts']['raw']['sample_frequency']);
     $ThisFileInfo['dts']['dialog_normalization'] = $this->DTSdialogNormalization($ThisFileInfo['dts']['raw']['dialog_normalization'], $ThisFileInfo['dts']['raw']['encoder_soft_version']);
     $ThisFileInfo['dts']['flags']['lossless'] = $ThisFileInfo['dts']['raw']['bitrate'] == 31 ? true : false;
     $ThisFileInfo['dts']['bitrate_mode'] = $ThisFileInfo['dts']['raw']['bitrate'] == 30 ? 'vbr' : 'cbr';
     $ThisFileInfo['dts']['channels'] = $this->DTSnumChannelsLookup($ThisFileInfo['dts']['raw']['channel_arrangement']);
     $ThisFileInfo['dts']['channel_arrangement'] = $this->DTSchannelArrangementLookup($ThisFileInfo['dts']['raw']['channel_arrangement']);
     $ThisFileInfo['audio']['dataformat'] = 'dts';
     $ThisFileInfo['audio']['lossless'] = $ThisFileInfo['dts']['flags']['lossless'];
     $ThisFileInfo['audio']['bitrate_mode'] = $ThisFileInfo['dts']['bitrate_mode'];
     $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['dts']['bits_per_sample'];
     $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['dts']['sample_rate'];
     $ThisFileInfo['audio']['channels'] = $ThisFileInfo['dts']['channels'];
     $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['dts']['bitrate'];
     if (isset($ThisFileInfo['avdataend'])) {
         $ThisFileInfo['playtime_seconds'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) / ($ThisFileInfo['dts']['bitrate'] / 8);
     }
     return true;
 }
開發者ID:sahartak,項目名稱:newsroyal,代碼行數:93,代碼來源:module.audio.dts.php

示例7: ParseID3v2Frame

 function ParseID3v2Frame(&$parsedFrame, &$ThisFileInfo)
 {
     // shortcuts
     $id3v2_majorversion = $ThisFileInfo['id3v2']['majorversion'];
     $parsedFrame['framenamelong'] = $this->FrameNameLongLookup($parsedFrame['frame_name']);
     if (empty($parsedFrame['framenamelong'])) {
         unset($parsedFrame['framenamelong']);
     }
     $parsedFrame['framenameshort'] = $this->FrameNameShortLookup($parsedFrame['frame_name']);
     if (empty($parsedFrame['framenameshort'])) {
         unset($parsedFrame['framenameshort']);
     }
     if ($id3v2_majorversion >= 3) {
         // frame flags are not part of the ID3v2.2 standard
         if ($id3v2_majorversion == 3) {
             //    Frame Header Flags
             //    %abc00000 %ijk00000
             $parsedFrame['flags']['TagAlterPreservation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x8000);
             // a - Tag alter preservation
             $parsedFrame['flags']['FileAlterPreservation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x4000);
             // b - File alter preservation
             $parsedFrame['flags']['ReadOnly'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x2000);
             // c - Read only
             $parsedFrame['flags']['compression'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x80);
             // i - Compression
             $parsedFrame['flags']['Encryption'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x40);
             // j - Encryption
             $parsedFrame['flags']['GroupingIdentity'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x20);
             // k - Grouping identity
         } elseif ($id3v2_majorversion == 4) {
             //    Frame Header Flags
             //    %0abc0000 %0h00kmnp
             $parsedFrame['flags']['TagAlterPreservation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x4000);
             // a - Tag alter preservation
             $parsedFrame['flags']['FileAlterPreservation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x2000);
             // b - File alter preservation
             $parsedFrame['flags']['ReadOnly'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x1000);
             // c - Read only
             $parsedFrame['flags']['GroupingIdentity'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x40);
             // h - Grouping identity
             $parsedFrame['flags']['compression'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x8);
             // k - Compression
             $parsedFrame['flags']['Encryption'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x4);
             // m - Encryption
             $parsedFrame['flags']['Unsynchronisation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x2);
             // n - Unsynchronisation
             $parsedFrame['flags']['DataLengthIndicator'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x1);
             // p - Data length indicator
             // Frame-level de-unsynchronisation - ID3v2.4
             if ($parsedFrame['flags']['Unsynchronisation']) {
                 $parsedFrame['data'] = $this->DeUnsynchronise($parsedFrame['data']);
             }
         }
         //    Frame-level de-compression
         if ($parsedFrame['flags']['compression']) {
             $parsedFrame['decompressed_size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4));
             if (!function_exists('gzuncompress')) {
                 $ThisFileInfo['warning'][] = 'gzuncompress() support required to decompress ID3v2 frame "' . $parsedFrame['frame_name'] . '"';
             } elseif ($decompresseddata = @gzuncompress(substr($parsedFrame['data'], 4))) {
                 $parsedFrame['data'] = $decompresseddata;
             } else {
                 $ThisFileInfo['warning'][] = 'gzuncompress() failed on compressed contents of ID3v2 frame "' . $parsedFrame['frame_name'] . '"';
             }
         }
     }
     if (isset($parsedFrame['datalength']) && $parsedFrame['datalength'] == 0) {
         $warning = 'Frame "' . $parsedFrame['frame_name'] . '" at offset ' . $parsedFrame['dataoffset'] . ' has no data portion';
         switch ($parsedFrame['frame_name']) {
             case 'WCOM':
                 $warning .= ' (this is known to happen with files tagged by RioPort)';
                 break;
             default:
                 break;
         }
         $ThisFileInfo['warning'][] = $warning;
     } elseif ($id3v2_majorversion >= 3 && $parsedFrame['frame_name'] == 'UFID' || $id3v2_majorversion == 2 && $parsedFrame['frame_name'] == 'UFI') {
         // 4.1   UFI  Unique file identifier
         //   There may be more than one 'UFID' frame in a tag,
         //   but only one with the same 'Owner identifier'.
         // <Header for 'Unique file identifier', ID: 'UFID'>
         // Owner identifier        <text string> $00
         // Identifier              <up to 64 bytes binary data>
         $frame_terminatorpos = strpos($parsedFrame['data'], "");
         $frame_idstring = substr($parsedFrame['data'], 0, $frame_terminatorpos);
         $parsedFrame['ownerid'] = $frame_idstring;
         $parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen(""));
         unset($parsedFrame['data']);
     } elseif ($id3v2_majorversion >= 3 && $parsedFrame['frame_name'] == 'TXXX' || $id3v2_majorversion == 2 && $parsedFrame['frame_name'] == 'TXX') {
         // 4.2.2 TXX  User defined text information frame
         //   There may be more than one 'TXXX' frame in each tag,
         //   but only one with the same description.
         // <Header for 'User defined text information frame', ID: 'TXXX'>
         // Text encoding     $xx
         // Description       <text string according to encoding> $00 (00)
         // Value             <text string according to encoding>
         $frame_offset = 0;
         $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
         if ($id3v2_majorversion <= 3 && $frame_textencoding > 1 || $id3v2_majorversion == 4 && $frame_textencoding > 3) {
             $ThisFileInfo['warning'][] = 'Invalid text encoding byte (' . $frame_textencoding . ') in frame "' . $parsedFrame['frame_name'] . '" - defaulting to ISO-8859-1 encoding';
         }
//.........這裏部分代碼省略.........
開發者ID:scottatron,項目名稱:opentape,代碼行數:101,代碼來源:module.tag.id3v2.php

示例8: analyze

 function analyze($filename)
 {
     if (!empty($this->startup_error)) {
         return $this->error($this->startup_error);
     }
     if (!empty($this->startup_warning)) {
         $this->warning($this->startup_warning);
     }
     // init result array and set parameters
     $this->info = array();
     $this->info['GETID3_VERSION'] = GETID3_VERSION;
     // Check encoding/iconv support
     if (!function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
         $errormessage = 'iconv() support is needed for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
         if (GETID3_OS_ISWINDOWS) {
             $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
         } else {
             $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
         }
         return $this->error($errormessage);
     }
     // Disable magic_quotes_runtime, if neccesary
     $old_magic_quotes_runtime = get_magic_quotes_runtime();
     // store current setting of magic_quotes_runtime
     if ($old_magic_quotes_runtime) {
         set_magic_quotes_runtime(0);
         // turn off magic_quotes_runtime
         if (get_magic_quotes_runtime()) {
             return $this->error('Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled');
         }
     }
     // remote files not supported
     if (preg_match('/^(ht|f)tp:\\/\\//', $filename)) {
         return $this->error('Remote files are not supported in this version of getID3() - please copy the file locally first');
     }
     // open local file
     if (!($fp = @fopen($filename, 'rb'))) {
         return $this->error('Could not open file "' . $filename . '"');
     }
     // set parameters
     $this->info['filesize'] = filesize($filename);
     // option_max_2gb_check
     if ($this->option_max_2gb_check) {
         // PHP doesn't support integers larger than 31-bit (~2GB)
         // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
         // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
         fseek($fp, 0, SEEK_END);
         if ($this->info['filesize'] != 0 && ftell($fp) == 0 || $this->info['filesize'] < 0 || ftell($fp) < 0) {
             unset($this->info['filesize']);
             fclose($fp);
             return $this->error('File is most likely larger than 2GB and is not supported by PHP');
         }
     }
     // set more parameters
     $this->info['avdataoffset'] = 0;
     $this->info['avdataend'] = $this->info['filesize'];
     $this->info['fileformat'] = '';
     // filled in later
     $this->info['audio']['dataformat'] = '';
     // filled in later, unset if not used
     $this->info['video']['dataformat'] = '';
     // filled in later, unset if not used
     $this->info['tags'] = array();
     // filled in later, unset if not used
     $this->info['error'] = array();
     // filled in later, unset if not used
     $this->info['warning'] = array();
     // filled in later, unset if not used
     $this->info['comments'] = array();
     // filled in later, unset if not used
     $this->info['encoding'] = $this->encoding;
     // required by id3v2 and iso modules - can be unset at the end if desired
     // set redundant parameters - might be needed in some include file
     $this->info['filename'] = basename($filename);
     $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
     $this->info['filenamepath'] = $this->info['filepath'] . '/' . $this->info['filename'];
     // handle ID3v2 tag - done first - already at beginning of file
     // ID3v2 detection (even if not parsing) is always done otherwise fileformat is much harder to detect
     if ($this->option_tag_id3v2) {
         $GETID3_ERRORARRAY =& $this->info['warning'];
         if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.tag.id3v2.php', __FILE__, false)) {
             $tag = new getid3_id3v2($fp, $this->info);
         }
     } else {
         fseek($fp, 0, SEEK_SET);
         $header = fread($fp, 10);
         if (substr($header, 0, 3) == 'ID3') {
             $this->info['id3v2']['header'] = true;
             $this->info['id3v2']['majorversion'] = ord($header[3]);
             $this->info['id3v2']['minorversion'] = ord($header[4]);
             $this->info['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
             $this->info['id3v2']['tag_offset_start'] = 0;
             $this->info['id3v2']['tag_offset_end'] = $this->info['id3v2']['tag_offset_start'] + $this->info['id3v2']['headerlength'];
             $this->info['avdataoffset'] = $this->info['id3v2']['tag_offset_end'];
         }
     }
     // handle ID3v1 tag
     if ($this->option_tag_id3v1) {
         if (!@(include_once GETID3_INCLUDEPATH . 'module.tag.id3v1.php')) {
//.........這裏部分代碼省略.........
開發者ID:omalettie,項目名稱:PHP-Streaming-Audio,代碼行數:101,代碼來源:getid3.php

示例9: getid3_flv

 function getid3_flv(&$fd, &$ThisFileInfo, $ReturnAllTagData = false)
 {
     fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
     $FLVdataLength = $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'];
     $FLVheader = fread($fd, 5);
     $ThisFileInfo['fileformat'] = 'flv';
     $ThisFileInfo['flv']['header']['signature'] = substr($FLVheader, 0, 3);
     $ThisFileInfo['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
     $TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));
     if ($ThisFileInfo['flv']['header']['signature'] != 'FLV') {
         $ThisFileInfo['error'][] = 'Expecting "FLV" at offset ' . $ThisFileInfo['avdataoffset'] . ', found "' . $ThisFileInfo['flv']['header']['signature'] . '"';
         unset($ThisFileInfo['flv']);
         unset($ThisFileInfo['fileformat']);
         return false;
     }
     $ThisFileInfo['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x4);
     $ThisFileInfo['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x1);
     $FrameSizeDataLength = getid3_lib::BigEndian2Int(fread($fd, 4));
     $FLVheaderFrameLength = 9;
     if ($FrameSizeDataLength > $FLVheaderFrameLength) {
         fseek($fd, $FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
     }
     $Duration = 0;
     while (ftell($fd) + 1 < $ThisFileInfo['avdataend']) {
         //if (!$ThisFileInfo['flv']['header']['hasAudio'] || isset($ThisFileInfo['flv']['audio']['audioFormat'])) {
         //	if (!$ThisFileInfo['flv']['header']['hasVideo'] || isset($ThisFileInfo['flv']['video']['videoCodec'])) {
         //		break;
         //	}
         //}
         $ThisTagHeader = fread($fd, 16);
         $PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4));
         $TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1));
         $DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3));
         $Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3));
         $LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1));
         $NextOffset = ftell($fd) - 1 + $DataLength;
         switch ($TagType) {
             case GETID3_FLV_TAG_AUDIO:
                 if (!isset($ThisFileInfo['flv']['audio']['audioFormat'])) {
                     $ThisFileInfo['flv']['audio']['audioFormat'] = $LastHeaderByte & 0x7;
                     $ThisFileInfo['flv']['audio']['audioRate'] = ($LastHeaderByte & 0x30) / 0x10;
                     $ThisFileInfo['flv']['audio']['audioSampleSize'] = ($LastHeaderByte & 0x40) / 0x40;
                     $ThisFileInfo['flv']['audio']['audioType'] = ($LastHeaderByte & 0x80) / 0x80;
                 }
                 break;
             case GETID3_FLV_TAG_VIDEO:
                 if (!isset($ThisFileInfo['flv']['video']['videoCodec'])) {
                     $ThisFileInfo['flv']['video']['videoCodec'] = $LastHeaderByte & 0x7;
                     switch ($ThisFileInfo['flv']['video']['videoCodec']) {
                         case GETID3_FLV_VIDEO_H263:
                             $FLVvideoHeader = fread($fd, 11);
                             $PictureSizeType = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 3, 2)) >> 7;
                             $PictureSizeType = $PictureSizeType & 0x7;
                             $ThisFileInfo['flv']['header']['videoSizeType'] = $PictureSizeType;
                             switch ($PictureSizeType) {
                                 case 0:
                                     $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
                                     $PictureSizeEnc <<= 1;
                                     $ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xff00) >> 8;
                                     $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
                                     $PictureSizeEnc <<= 1;
                                     $ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xff00) >> 8;
                                     break;
                                 case 1:
                                     $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 4));
                                     $PictureSizeEnc <<= 1;
                                     $ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xffff0000) >> 16;
                                     $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 4));
                                     $PictureSizeEnc <<= 1;
                                     $ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xffff0000) >> 16;
                                     break;
                                 case 2:
                                     $ThisFileInfo['video']['resolution_x'] = 352;
                                     $ThisFileInfo['video']['resolution_y'] = 288;
                                     break;
                                 case 3:
                                     $ThisFileInfo['video']['resolution_x'] = 176;
                                     $ThisFileInfo['video']['resolution_y'] = 144;
                                     break;
                                 case 4:
                                     $ThisFileInfo['video']['resolution_x'] = 128;
                                     $ThisFileInfo['video']['resolution_y'] = 96;
                                     break;
                                 case 5:
                                     $ThisFileInfo['video']['resolution_x'] = 320;
                                     $ThisFileInfo['video']['resolution_y'] = 240;
                                     break;
                                 case 6:
                                     $ThisFileInfo['video']['resolution_x'] = 160;
                                     $ThisFileInfo['video']['resolution_y'] = 120;
                                     break;
                                 default:
                                     $ThisFileInfo['video']['resolution_x'] = 0;
                                     $ThisFileInfo['video']['resolution_y'] = 0;
                                     break;
                             }
                             break;
                         case GETID3_FLV_VIDEO_SCREEN:
                             $bits = new BitStreamReader(fread($fd, $DataLength));
                             $bits->seek(4, SEEK_CUR);
//.........這裏部分代碼省略.........
開發者ID:VierlingMt,項目名稱:joomla-3.x,代碼行數:101,代碼來源:module.audio-video.flv.php

示例10: Analyze

 public function Analyze()
 {
     $getid3 = $this->getid3;
     $getid3->include_module('audio-video.riff');
     // Magic bytes - 'LPAC'
     fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
     $lpac_header = fread($getid3->fp, 14);
     $getid3->info['avdataoffset'] += 14;
     $getid3->info['lpac'] = array();
     $info_lpac =& $getid3->info['lpac'];
     $getid3->info['fileformat'] = 'lpac';
     $getid3->info['audio']['dataformat'] = 'lpac';
     $getid3->info['audio']['lossless'] = true;
     $getid3->info['audio']['bitrate_mode'] = 'vbr';
     $info_lpac['file_version'] = getid3_lib::BigEndian2Int($lpac_header[4]);
     $flags['audio_type'] = getid3_lib::BigEndian2Int($lpac_header[5]);
     $info_lpac['total_samples'] = getid3_lib::BigEndian2Int(substr($lpac_header, 6, 4));
     $flags['parameters'] = getid3_lib::BigEndian2Int(substr($lpac_header, 10, 4));
     $info_lpac['flags']['is_wave'] = (bool) ($flags['audio_type'] & 0x40);
     $info_lpac['flags']['stereo'] = (bool) ($flags['audio_type'] & 0x4);
     $info_lpac['flags']['24_bit'] = (bool) ($flags['audio_type'] & 0x2);
     $info_lpac['flags']['16_bit'] = (bool) ($flags['audio_type'] & 0x1);
     if ($info_lpac['flags']['24_bit'] && $info_lpac['flags']['16_bit']) {
         $getid3->warning('24-bit and 16-bit flags cannot both be set');
     }
     $info_lpac['flags']['fast_compress'] = (bool) ($flags['parameters'] & 0x40000000);
     $info_lpac['flags']['random_access'] = (bool) ($flags['parameters'] & 0x8000000);
     $info_lpac['block_length'] = pow(2, ($flags['parameters'] & 0x7000000) >> 24) * 256;
     $info_lpac['flags']['adaptive_prediction_order'] = (bool) ($flags['parameters'] & 0x800000);
     $info_lpac['flags']['adaptive_quantization'] = (bool) ($flags['parameters'] & 0x400000);
     $info_lpac['flags']['joint_stereo'] = (bool) ($flags['parameters'] & 0x40000);
     $info_lpac['quantization'] = ($flags['parameters'] & 0x1f00) >> 8;
     $info_lpac['max_prediction_order'] = $flags['parameters'] & 0x3f;
     if ($info_lpac['flags']['fast_compress'] && $info_lpac['max_prediction_order'] != 3) {
         $getid3->warning('max_prediction_order expected to be "3" if fast_compress is true, actual value is "' . $info_lpac['max_prediction_order'] . '"');
     }
     switch ($info_lpac['file_version']) {
         case 6:
             if ($info_lpac['flags']['adaptive_quantization']) {
                 $getid3->warning('adaptive_quantization expected to be false in LPAC file stucture v6, actually true');
             }
             if ($info_lpac['quantization'] != 20) {
                 $getid3->warning('Quantization expected to be 20 in LPAC file stucture v6, actually ' . $info_lpac['flags']['Q']);
             }
             break;
         default:
             //$getid3->warning('This version of getID3() only supports LPAC file format version 6, this file is version '.$info_lpac['file_version'].' - please report to info@getid3.org');
             break;
     }
     // Clone getid3 - messing with something - better safe than sorry
     $clone = clone $getid3;
     // Analyze clone by fp
     $riff = new getid3_riff($clone);
     $riff->Analyze();
     // Import from clone and destroy
     $getid3->info['avdataoffset'] = $clone->info['avdataoffset'];
     $getid3->info['riff'] = $clone->info['riff'];
     //$info_lpac['comments']['comment'] = $clone->info['comments'];
     $getid3->info['audio']['sample_rate'] = $clone->info['audio']['sample_rate'];
     $getid3->warnings($clone->warnings());
     unset($clone);
     $getid3->info['audio']['channels'] = $info_lpac['flags']['stereo'] ? 2 : 1;
     if ($info_lpac['flags']['24_bit']) {
         $getid3->info['audio']['bits_per_sample'] = $getid3->info['riff']['audio'][0]['bits_per_sample'];
     } elseif ($info_lpac['flags']['16_bit']) {
         $getid3->info['audio']['bits_per_sample'] = 16;
     } else {
         $getid3->info['audio']['bits_per_sample'] = 8;
     }
     if ($info_lpac['flags']['fast_compress']) {
         // fast
         $getid3->info['audio']['encoder_options'] = '-1';
     } else {
         switch ($info_lpac['max_prediction_order']) {
             case 20:
                 // simple
                 $getid3->info['audio']['encoder_options'] = '-2';
                 break;
             case 30:
                 // medium
                 $getid3->info['audio']['encoder_options'] = '-3';
                 break;
             case 40:
                 // high
                 $getid3->info['audio']['encoder_options'] = '-4';
                 break;
             case 60:
                 // extrahigh
                 $getid3->info['audio']['encoder_options'] = '-5';
                 break;
         }
     }
     $getid3->info['playtime_seconds'] = $info_lpac['total_samples'] / $getid3->info['audio']['sample_rate'];
     $getid3->info['audio']['bitrate'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8 / $getid3->info['playtime_seconds'];
     return true;
 }
開發者ID:jwlynch,項目名稱:openacs.core,代碼行數:96,代碼來源:module.audio.lpac.php

示例11: Analyze

 function Analyze()
 {
     $info =& $this->getid3->info;
     // shortcut
     $info['midi']['raw'] = array();
     $thisfile_midi =& $info['midi'];
     $thisfile_midi_raw =& $thisfile_midi['raw'];
     $info['fileformat'] = 'midi';
     $info['audio']['dataformat'] = 'midi';
     fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     $MIDIdata = fread($this->getid3->fp, $this->getid3->fread_buffer_size());
     $offset = 0;
     $MIDIheaderID = substr($MIDIdata, $offset, 4);
     // 'MThd'
     if ($MIDIheaderID != GETID3_MIDI_MAGIC_MTHD) {
         $info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes(GETID3_MIDI_MAGIC_MTHD) . '" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes($MIDIheaderID) . '"';
         unset($info['fileformat']);
         return false;
     }
     $offset += 4;
     $thisfile_midi_raw['headersize'] = getid3_lib::BigEndian2Int(substr($MIDIdata, $offset, 4));
     $offset += 4;
     $thisfile_midi_raw['fileformat'] = getid3_lib::BigEndian2Int(substr($MIDIdata, $offset, 2));
     $offset += 2;
     $thisfile_midi_raw['tracks'] = getid3_lib::BigEndian2Int(substr($MIDIdata, $offset, 2));
     $offset += 2;
     $thisfile_midi_raw['ticksperqnote'] = getid3_lib::BigEndian2Int(substr($MIDIdata, $offset, 2));
     $offset += 2;
     for ($i = 0; $i < $thisfile_midi_raw['tracks']; $i++) {
         while (strlen($MIDIdata) - $offset < 8) {
             $MIDIdata .= fread($this->getid3->fp, $this->getid3->fread_buffer_size());
         }
         $trackID = substr($MIDIdata, $offset, 4);
         $offset += 4;
         if ($trackID == GETID3_MIDI_MAGIC_MTRK) {
             $tracksize = getid3_lib::BigEndian2Int(substr($MIDIdata, $offset, 4));
             $offset += 4;
             // $thisfile_midi['tracks'][$i]['size'] = $tracksize;
             $trackdataarray[$i] = substr($MIDIdata, $offset, $tracksize);
             $offset += $tracksize;
         } else {
             $info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes(GETID3_MIDI_MAGIC_MTRK) . '" at ' . ($offset - 4) . ', found "' . getid3_lib::PrintHexBytes($trackID) . '" instead';
             return false;
         }
     }
     if (!isset($trackdataarray) || !is_array($trackdataarray)) {
         $info['error'][] = 'Cannot find MIDI track information';
         unset($thisfile_midi);
         unset($info['fileformat']);
         return false;
     }
     if ($this->scanwholefile) {
         // this can take quite a long time, so have the option to bypass it if speed is very important
         $thisfile_midi['totalticks'] = 0;
         $info['playtime_seconds'] = 0;
         $CurrentMicroSecondsPerBeat = 500000;
         // 120 beats per minute;  60,000,000 microseconds per minute -> 500,000 microseconds per beat
         $CurrentBeatsPerMinute = 120;
         // 120 beats per minute;  60,000,000 microseconds per minute -> 500,000 microseconds per beat
         $MicroSecondsPerQuarterNoteAfter = array();
         foreach ($trackdataarray as $tracknumber => $trackdata) {
             $eventsoffset = 0;
             $LastIssuedMIDIcommand = 0;
             $LastIssuedMIDIchannel = 0;
             $CumulativeDeltaTime = 0;
             $TicksAtCurrentBPM = 0;
             while ($eventsoffset < strlen($trackdata)) {
                 $eventid = 0;
                 if (isset($MIDIevents[$tracknumber]) && is_array($MIDIevents[$tracknumber])) {
                     $eventid = count($MIDIevents[$tracknumber]);
                 }
                 $deltatime = 0;
                 for ($i = 0; $i < 4; $i++) {
                     $deltatimebyte = ord(substr($trackdata, $eventsoffset++, 1));
                     $deltatime = ($deltatime << 7) + ($deltatimebyte & 0x7f);
                     if ($deltatimebyte & 0x80) {
                         // another byte follows
                     } else {
                         break;
                     }
                 }
                 $CumulativeDeltaTime += $deltatime;
                 $TicksAtCurrentBPM += $deltatime;
                 $MIDIevents[$tracknumber][$eventid]['deltatime'] = $deltatime;
                 $MIDI_event_channel = ord(substr($trackdata, $eventsoffset++, 1));
                 if ($MIDI_event_channel & 0x80) {
                     // OK, normal event - MIDI command has MSB set
                     $LastIssuedMIDIcommand = $MIDI_event_channel >> 4;
                     $LastIssuedMIDIchannel = $MIDI_event_channel & 0xf;
                 } else {
                     // running event - assume last command
                     $eventsoffset--;
                 }
                 $MIDIevents[$tracknumber][$eventid]['eventid'] = $LastIssuedMIDIcommand;
                 $MIDIevents[$tracknumber][$eventid]['channel'] = $LastIssuedMIDIchannel;
                 if ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x8) {
                     // Note off (key is released)
                     $notenumber = ord(substr($trackdata, $eventsoffset++, 1));
                     $velocity = ord(substr($trackdata, $eventsoffset++, 1));
                 } elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x9) {
//.........這裏部分代碼省略.........
開發者ID:tlxyz,項目名稱:online-disk,代碼行數:101,代碼來源:module.audio.midi.php

示例12: parsePICTURE

 /**
  * Parse METADATA_BLOCK_PICTURE flac structure and extract attachment
  * External usage: audio.ogg
  */
 public function parsePICTURE()
 {
     $info =& $this->getid3->info;
     $picture['typeid'] = getid3_lib::BigEndian2Int($this->fread(4));
     $picture['picturetype'] = self::pictureTypeLookup($picture['typeid']);
     $picture['image_mime'] = $this->fread(getid3_lib::BigEndian2Int($this->fread(4)));
     $descr_length = getid3_lib::BigEndian2Int($this->fread(4));
     if ($descr_length) {
         $picture['description'] = $this->fread($descr_length);
     }
     $picture['image_width'] = getid3_lib::BigEndian2Int($this->fread(4));
     $picture['image_height'] = getid3_lib::BigEndian2Int($this->fread(4));
     $picture['color_depth'] = getid3_lib::BigEndian2Int($this->fread(4));
     $picture['colors_indexed'] = getid3_lib::BigEndian2Int($this->fread(4));
     $picture['datalength'] = getid3_lib::BigEndian2Int($this->fread(4));
     if ($picture['image_mime'] == '-->') {
         $picture['data'] = $this->fread($picture['datalength']);
     } else {
         $picture['data'] = $this->saveAttachment(str_replace('/', '_', $picture['picturetype']) . '_' . $this->ftell(), $this->ftell(), $picture['datalength'], $picture['image_mime']);
     }
     $info['flac']['PICTURE'][] = $picture;
     return true;
 }
開發者ID:kadrim1,項目名稱:metsayhistu,代碼行數:27,代碼來源:module.audio.flac.php

示例13: Analyze

 public function Analyze()
 {
     $info =& $this->getid3->info;
     $info['fileformat'] = 'swf';
     $info['video']['dataformat'] = 'swf';
     // http://www.openswf.org/spec/SWFfileformat.html
     $this->fseek($info['avdataoffset']);
     $SWFfileData = $this->fread($info['avdataend'] - $info['avdataoffset']);
     // 8 + 2 + 2 + max(9) bytes NOT including Frame_Size RECT data
     $info['swf']['header']['signature'] = substr($SWFfileData, 0, 3);
     switch ($info['swf']['header']['signature']) {
         case 'FWS':
             $info['swf']['header']['compressed'] = false;
             break;
         case 'CWS':
             $info['swf']['header']['compressed'] = true;
             break;
         default:
             $info['error'][] = 'Expecting "FWS" or "CWS" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes($info['swf']['header']['signature']) . '"';
             unset($info['swf']);
             unset($info['fileformat']);
             return false;
             break;
     }
     $info['swf']['header']['version'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 3, 1));
     $info['swf']['header']['length'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 4, 4));
     if ($info['swf']['header']['compressed']) {
         $SWFHead = substr($SWFfileData, 0, 8);
         $SWFfileData = substr($SWFfileData, 8);
         if ($decompressed = @gzuncompress($SWFfileData)) {
             $SWFfileData = $SWFHead . $decompressed;
         } else {
             $info['error'][] = 'Error decompressing compressed SWF data (' . strlen($SWFfileData) . ' bytes compressed, should be ' . ($info['swf']['header']['length'] - 8) . ' bytes uncompressed)';
             return false;
         }
     }
     $FrameSizeBitsPerValue = (ord(substr($SWFfileData, 8, 1)) & 0xf8) >> 3;
     $FrameSizeDataLength = ceil((5 + 4 * $FrameSizeBitsPerValue) / 8);
     $FrameSizeDataString = str_pad(decbin(ord(substr($SWFfileData, 8, 1)) & 0x7), 3, '0', STR_PAD_LEFT);
     for ($i = 1; $i < $FrameSizeDataLength; $i++) {
         $FrameSizeDataString .= str_pad(decbin(ord(substr($SWFfileData, 8 + $i, 1))), 8, '0', STR_PAD_LEFT);
     }
     list($X1, $X2, $Y1, $Y2) = explode("\n", wordwrap($FrameSizeDataString, $FrameSizeBitsPerValue, "\n", 1));
     $info['swf']['header']['frame_width'] = getid3_lib::Bin2Dec($X2);
     $info['swf']['header']['frame_height'] = getid3_lib::Bin2Dec($Y2);
     // http://www-lehre.informatik.uni-osnabrueck.de/~fbstark/diplom/docs/swf/Flash_Uncovered.htm
     // Next in the header is the frame rate, which is kind of weird.
     // It is supposed to be stored as a 16bit integer, but the first byte
     // (or last depending on how you look at it) is completely ignored.
     // Example: 0x000C  ->  0x0C  ->  12     So the frame rate is 12 fps.
     // Byte at (8 + $FrameSizeDataLength) is always zero and ignored
     $info['swf']['header']['frame_rate'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 9 + $FrameSizeDataLength, 1));
     $info['swf']['header']['frame_count'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 10 + $FrameSizeDataLength, 2));
     $info['video']['frame_rate'] = $info['swf']['header']['frame_rate'];
     $info['video']['resolution_x'] = intval(round($info['swf']['header']['frame_width'] / 20));
     $info['video']['resolution_y'] = intval(round($info['swf']['header']['frame_height'] / 20));
     $info['video']['pixel_aspect_ratio'] = (double) 1;
     if ($info['swf']['header']['frame_count'] > 0 && $info['swf']['header']['frame_rate'] > 0) {
         $info['playtime_seconds'] = $info['swf']['header']['frame_count'] / $info['swf']['header']['frame_rate'];
     }
     //echo __LINE__.'='.number_format(microtime(true) - $start_time, 3).'<br>';
     // SWF tags
     $CurrentOffset = 12 + $FrameSizeDataLength;
     $SWFdataLength = strlen($SWFfileData);
     while ($CurrentOffset < $SWFdataLength) {
         //echo __LINE__.'='.number_format(microtime(true) - $start_time, 3).'<br>';
         $TagIDTagLength = getid3_lib::LittleEndian2Int(substr($SWFfileData, $CurrentOffset, 2));
         $TagID = ($TagIDTagLength & 0xfffc) >> 6;
         $TagLength = $TagIDTagLength & 0x3f;
         $CurrentOffset += 2;
         if ($TagLength == 0x3f) {
             $TagLength = getid3_lib::LittleEndian2Int(substr($SWFfileData, $CurrentOffset, 4));
             $CurrentOffset += 4;
         }
         unset($TagData);
         $TagData['offset'] = $CurrentOffset;
         $TagData['size'] = $TagLength;
         $TagData['id'] = $TagID;
         $TagData['data'] = substr($SWFfileData, $CurrentOffset, $TagLength);
         switch ($TagID) {
             case 0:
                 // end of movie
                 break 2;
             case 9:
                 // Set background color
                 //$info['swf']['tags'][] = $TagData;
                 $info['swf']['bgcolor'] = strtoupper(str_pad(dechex(getid3_lib::BigEndian2Int($TagData['data'])), 6, '0', STR_PAD_LEFT));
                 break;
             default:
                 if ($this->ReturnAllTagData) {
                     $info['swf']['tags'][] = $TagData;
                 }
                 break;
         }
         $CurrentOffset += $TagLength;
     }
     return true;
 }
開發者ID:beesheer,項目名稱:freehdfootage,代碼行數:98,代碼來源:module.audio-video.swf.php

示例14: MPEGaudioHeaderDecode

 public static function MPEGaudioHeaderDecode($Header4Bytes)
 {
     // AAAA AAAA  AAAB BCCD  EEEE FFGH  IIJJ KLMM
     // A - Frame sync (all bits set)
     // B - MPEG Audio version ID
     // C - Layer description
     // D - Protection bit
     // E - Bitrate index
     // F - Sampling rate frequency index
     // G - Padding bit
     // H - Private bit
     // I - Channel Mode
     // J - Mode extension (Only if Joint stereo)
     // K - Copyright
     // L - Original
     // M - Emphasis
     if (strlen($Header4Bytes) != 4) {
         return false;
     }
     $MPEGrawHeader['synch'] = (getid3_lib::BigEndian2Int(substr($Header4Bytes, 0, 2)) & 0xffe0) >> 4;
     $MPEGrawHeader['version'] = (ord($Header4Bytes[1]) & 0x18) >> 3;
     //    BB
     $MPEGrawHeader['layer'] = (ord($Header4Bytes[1]) & 0x6) >> 1;
     //      CC
     $MPEGrawHeader['protection'] = ord($Header4Bytes[1]) & 0x1;
     //        D
     $MPEGrawHeader['bitrate'] = (ord($Header4Bytes[2]) & 0xf0) >> 4;
     // EEEE
     $MPEGrawHeader['sample_rate'] = (ord($Header4Bytes[2]) & 0xc) >> 2;
     //     FF
     $MPEGrawHeader['padding'] = (ord($Header4Bytes[2]) & 0x2) >> 1;
     //       G
     $MPEGrawHeader['private'] = ord($Header4Bytes[2]) & 0x1;
     //        H
     $MPEGrawHeader['channelmode'] = (ord($Header4Bytes[3]) & 0xc0) >> 6;
     // II
     $MPEGrawHeader['modeextension'] = (ord($Header4Bytes[3]) & 0x30) >> 4;
     //   JJ
     $MPEGrawHeader['copyright'] = (ord($Header4Bytes[3]) & 0x8) >> 3;
     //     K
     $MPEGrawHeader['original'] = (ord($Header4Bytes[3]) & 0x4) >> 2;
     //      L
     $MPEGrawHeader['emphasis'] = ord($Header4Bytes[3]) & 0x3;
     //       MM
     return $MPEGrawHeader;
 }
開發者ID:rauldobrota,項目名稱:zenphoto,代碼行數:46,代碼來源:module.audio.mp3.php

示例15: TIFFendian2Int

 function TIFFendian2Int($bytestring, $byteorder)
 {
     if ($byteorder == 'Intel') {
         return getid3_lib::LittleEndian2Int($bytestring);
     } elseif ($byteorder == 'Motorola') {
         return getid3_lib::BigEndian2Int($bytestring);
     }
     return false;
 }
開發者ID:sahartak,項目名稱:newsroyal,代碼行數:9,代碼來源:module.graphic.tiff.php


注:本文中的getid3_lib::BigEndian2Int方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。