本文整理匯總了PHP中getid3_lib::LittleEndian2Int方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::LittleEndian2Int方法的具體用法?PHP getid3_lib::LittleEndian2Int怎麽用?PHP getid3_lib::LittleEndian2Int使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類getid3_lib
的用法示例。
在下文中一共展示了getid3_lib::LittleEndian2Int方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getid3_exe
function getid3_exe(&$fd, &$ThisFileInfo)
{
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
$EXEheader = fread($fd, 28);
if (substr($EXEheader, 0, 2) != 'MZ') {
$ThisFileInfo['error'][] = 'Expecting "MZ" at offset ' . $ThisFileInfo['avdataoffset'] . ', found "' . substr($EXEheader, 0, 2) . '" instead.';
return false;
}
$ThisFileInfo['fileformat'] = 'exe';
$ThisFileInfo['exe']['mz']['magic'] = 'MZ';
$ThisFileInfo['exe']['mz']['raw']['last_page_size'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 2, 2));
$ThisFileInfo['exe']['mz']['raw']['page_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 4, 2));
$ThisFileInfo['exe']['mz']['raw']['relocation_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 6, 2));
$ThisFileInfo['exe']['mz']['raw']['header_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 8, 2));
$ThisFileInfo['exe']['mz']['raw']['min_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 10, 2));
$ThisFileInfo['exe']['mz']['raw']['max_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 12, 2));
$ThisFileInfo['exe']['mz']['raw']['initial_ss'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 14, 2));
$ThisFileInfo['exe']['mz']['raw']['initial_sp'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 16, 2));
$ThisFileInfo['exe']['mz']['raw']['checksum'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 18, 2));
$ThisFileInfo['exe']['mz']['raw']['cs_ip'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 20, 4));
$ThisFileInfo['exe']['mz']['raw']['relocation_table_offset'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 24, 2));
$ThisFileInfo['exe']['mz']['raw']['overlay_number'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 26, 2));
$ThisFileInfo['exe']['mz']['byte_size'] = ($ThisFileInfo['exe']['mz']['raw']['page_count'] - 1) * 512 + $ThisFileInfo['exe']['mz']['raw']['last_page_size'];
$ThisFileInfo['exe']['mz']['header_size'] = $ThisFileInfo['exe']['mz']['raw']['header_paragraphs'] * 16;
$ThisFileInfo['exe']['mz']['memory_minimum'] = $ThisFileInfo['exe']['mz']['raw']['min_memory_paragraphs'] * 16;
$ThisFileInfo['exe']['mz']['memory_recommended'] = $ThisFileInfo['exe']['mz']['raw']['max_memory_paragraphs'] * 16;
$ThisFileInfo['error'][] = 'EXE parsing not enabled in this version of getID3()';
return false;
}
示例2: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
$this->fseek($info['avdataoffset']);
$EXEheader = $this->fread(28);
$magic = 'MZ';
if (substr($EXEheader, 0, 2) != $magic) {
$info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($EXEheader, 0, 2)) . '"';
return false;
}
$info['fileformat'] = 'exe';
$info['exe']['mz']['magic'] = 'MZ';
$info['exe']['mz']['raw']['last_page_size'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 2, 2));
$info['exe']['mz']['raw']['page_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 4, 2));
$info['exe']['mz']['raw']['relocation_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 6, 2));
$info['exe']['mz']['raw']['header_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 8, 2));
$info['exe']['mz']['raw']['min_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 10, 2));
$info['exe']['mz']['raw']['max_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 12, 2));
$info['exe']['mz']['raw']['initial_ss'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 14, 2));
$info['exe']['mz']['raw']['initial_sp'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 16, 2));
$info['exe']['mz']['raw']['checksum'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 18, 2));
$info['exe']['mz']['raw']['cs_ip'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 20, 4));
$info['exe']['mz']['raw']['relocation_table_offset'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 24, 2));
$info['exe']['mz']['raw']['overlay_number'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 26, 2));
$info['exe']['mz']['byte_size'] = ($info['exe']['mz']['raw']['page_count'] - 1) * 512 + $info['exe']['mz']['raw']['last_page_size'];
$info['exe']['mz']['header_size'] = $info['exe']['mz']['raw']['header_paragraphs'] * 16;
$info['exe']['mz']['memory_minimum'] = $info['exe']['mz']['raw']['min_memory_paragraphs'] * 16;
$info['exe']['mz']['memory_recommended'] = $info['exe']['mz']['raw']['max_memory_paragraphs'] * 16;
$info['error'][] = 'EXE parsing not enabled in this version of getID3() [' . $this->getid3->version() . ']';
return false;
}
示例3: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
// http://www.uni-jena.de/~pfk/mpp/sv8/header.html
$getid3->info['mpc']['header'] = array();
$info_mpc_header =& $getid3->info['mpc']['header'];
$getid3->info['fileformat'] = 'mpc';
$getid3->info['audio']['dataformat'] = 'mpc';
$getid3->info['audio']['bitrate_mode'] = 'vbr';
$getid3->info['audio']['channels'] = 2;
// the format appears to be hardcoded for stereo only
$getid3->info['audio']['lossless'] = false;
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$info_mpc_header['size'] = 8;
$getid3->info['avdataoffset'] += $info_mpc_header['size'];
$mpc_header_data = fread($getid3->fp, $info_mpc_header['size']);
// Most of this code adapted from Jurgen Faul's MPEGplus source code - thanks Jurgen! :)
$header_dword[0] = getid3_lib::LittleEndian2Int(substr($mpc_header_data, 0, 4));
$header_dword[1] = getid3_lib::LittleEndian2Int(substr($mpc_header_data, 4, 4));
// DDDD DDDD CCCC CCCC BBBB BBBB AAAA AAAA
// aaaa aaaa abcd dddd dddd deee eeff ffff
//
// a = bitrate = anything
// b = IS = anything
// c = MS = anything
// d = streamversion = 0000000004 or 0000000005 or 0000000006
// e = maxband = anything
// f = blocksize = 000001 for SV5+, anything(?) for SV4
$info_mpc_header['target_bitrate'] = ($header_dword[0] & 4286578688.0) >> 23;
$info_mpc_header['intensity_stereo'] = (bool) (($header_dword[0] & 0x400000) >> 22);
$info_mpc_header['mid-side_stereo'] = (bool) (($header_dword[0] & 0x200000) >> 21);
$info_mpc_header['stream_major_version'] = ($header_dword[0] & 0x1ff800) >> 11;
$info_mpc_header['stream_minor_version'] = 0;
$info_mpc_header['max_band'] = ($header_dword[0] & 0x7c0) >> 6;
// related to lowpass frequency, not sure how it translates exactly
$info_mpc_header['block_size'] = $header_dword[0] & 0x3f;
switch ($info_mpc_header['stream_major_version']) {
case 4:
$info_mpc_header['frame_count'] = $header_dword[1] >> 16;
break;
case 5:
case 6:
$info_mpc_header['frame_count'] = $header_dword[1];
break;
default:
throw new getid3_exception('Expecting 4, 5 or 6 in version field, found ' . $info_mpc_header['stream_major_version'] . ' instead');
}
if ($info_mpc_header['stream_major_version'] > 4 && $info_mpc_header['block_size'] != 1) {
$getid3->warning('Block size expected to be 1, actual value found: ' . $info_mpc_header['block_size']);
}
$info_mpc_header['sample_rate'] = $getid3->info['audio']['sample_rate'] = 44100;
// AB: used by all files up to SV7
$info_mpc_header['samples'] = $info_mpc_header['frame_count'] * 1152 * $getid3->info['audio']['channels'];
$getid3->info['audio']['bitrate_mode'] = $info_mpc_header['target_bitrate'] == 0 ? 'vbr' : 'cbr';
$getid3->info['mpc']['bitrate'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8 * 44100 / $info_mpc_header['frame_count'] / 1152;
$getid3->info['audio']['bitrate'] = $getid3->info['mpc']['bitrate'];
$getid3->info['audio']['encoder'] = 'SV' . $info_mpc_header['stream_major_version'];
return true;
}
示例4: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
$this->fseek($info['avdataoffset']);
$DSSheader = $this->fread(1540);
if (!preg_match('#^[\\x02-\\x06]ds[s2]#', $DSSheader)) {
$info['error'][] = 'Expecting "[02-06] 64 73 [73|32]" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($DSSheader, 0, 4)) . '"';
return false;
}
// some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
$info['encoding'] = 'ISO-8859-1';
// not certain, but assumed
$info['dss'] = array();
$info['fileformat'] = 'dss';
$info['mime_type'] = 'audio/x-' . substr($DSSheader, 1, 3);
// "audio/x-dss" or "audio/x-ds2"
$info['audio']['dataformat'] = substr($DSSheader, 1, 3);
// "dss" or "ds2"
$info['audio']['bitrate_mode'] = 'cbr';
$info['dss']['version'] = ord(substr($DSSheader, 0, 1));
$info['dss']['hardware'] = trim(substr($DSSheader, 12, 16));
// identification string for hardware used to create the file, e.g. "DPM 9600", "DS2400"
$info['dss']['unknown1'] = getid3_lib::LittleEndian2Int(substr($DSSheader, 28, 4));
// 32-37 = "FE FF FE FF F7 FF" in all the sample files I've seen
$info['dss']['date_create_unix'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 38, 12));
$info['dss']['date_complete_unix'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 50, 12));
$info['dss']['playtime_sec'] = intval(substr($DSSheader, 62, 2) * 3600 + substr($DSSheader, 64, 2) * 60 + substr($DSSheader, 66, 2));
// approximate file playtime in HHMMSS
if ($info['dss']['version'] <= 3) {
$info['dss']['playtime_ms'] = getid3_lib::LittleEndian2Int(substr($DSSheader, 512, 4));
// exact file playtime in milliseconds. Has also been observed at offset 530 in one sample file, with something else (unknown) at offset 512
$info['dss']['priority'] = ord(substr($DSSheader, 793, 1));
$info['dss']['comments'] = trim(substr($DSSheader, 798, 100));
$info['dss']['sample_rate_index'] = ord(substr($DSSheader, 1538, 1));
// this isn't certain, this may or may not be where the sample rate info is stored, but it seems consistent on my small selection of sample files
$info['audio']['sample_rate'] = $this->DSSsampleRateLookup($info['dss']['sample_rate_index']);
} else {
$this->getid3->warning('DSS above version 3 not fully supported in this version of getID3. Any additional documentation or format specifications would be welcome. This file is version ' . $info['dss']['version']);
}
$info['audio']['bits_per_sample'] = 16;
// maybe, maybe not -- most compressed audio formats don't have a fixed bits-per-sample value, but this is a reasonable approximation
$info['audio']['channels'] = 1;
if (!empty($info['dss']['playtime_ms']) && floor($info['dss']['playtime_ms'] / 1000) == $info['dss']['playtime_sec']) {
// *should* just be playtime_ms / 1000 but at least one sample file has playtime_ms at offset 530 instead of offset 512, so safety check
$info['playtime_seconds'] = $info['dss']['playtime_ms'] / 1000;
} else {
$info['playtime_seconds'] = $info['dss']['playtime_sec'];
if (!empty($info['dss']['playtime_ms'])) {
$this->getid3->warning('playtime_ms (' . number_format($info['dss']['playtime_ms'] / 1000, 3) . ') does not match playtime_sec (' . number_format($info['dss']['playtime_sec']) . ') - using playtime_sec value');
}
}
$info['audio']['bitrate'] = $info['filesize'] * 8 / $info['playtime_seconds'];
return true;
}
示例5: ParseBink
function ParseBink(&$fd, &$ThisFileInfo)
{
$ThisFileInfo['fileformat'] = 'bink';
$ThisFileInfo['video']['dataformat'] = 'bink';
$fileData = 'BIK' . fread($fd, 13);
$ThisFileInfo['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
$ThisFileInfo['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
if ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'] != $ThisFileInfo['bink']['data_size'] + 8) {
$ThisFileInfo['error'][] = 'Probably truncated file: expecting ' . $ThisFileInfo['bink']['data_size'] . ' bytes, found ' . ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']);
}
return true;
}
示例6: getid3_tta
function getid3_tta(&$fd, &$ThisFileInfo)
{
$ThisFileInfo['fileformat'] = 'tta';
$ThisFileInfo['audio']['dataformat'] = 'tta';
$ThisFileInfo['audio']['lossless'] = true;
$ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
$ttaheader = fread($fd, 20);
$ThisFileInfo['tta']['magic'] = substr($ttaheader, 0, 3);
if ($ThisFileInfo['tta']['magic'] != 'TTA') {
$ThisFileInfo['error'][] = 'Expecting "TTA" at offset ' . $ThisFileInfo['avdataoffset'] . ', found "' . $ThisFileInfo['tta']['magic'] . '"';
unset($ThisFileInfo['fileformat']);
unset($ThisFileInfo['audio']);
unset($ThisFileInfo['tta']);
return false;
}
switch ($ttaheader[3]) {
case "":
case "":
case "":
$ThisFileInfo['tta']['major_version'] = 1;
$ThisFileInfo['avdataoffset'] = 16;
$ThisFileInfo['tta']['compression_level'] = ord($ttaheader[3]);
$ThisFileInfo['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2));
$ThisFileInfo['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
$ThisFileInfo['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 4));
$ThisFileInfo['tta']['samples_per_channel'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12, 4));
$ThisFileInfo['playtime_seconds'] = $ThisFileInfo['tta']['samples_per_channel'] / $ThisFileInfo['tta']['sample_rate'];
break;
case '2':
$ThisFileInfo['tta']['major_version'] = 2;
$ThisFileInfo['avdataoffset'] = 20;
$ThisFileInfo['tta']['compression_level'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2));
$ThisFileInfo['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
$ThisFileInfo['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 2));
$ThisFileInfo['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 10, 2));
$ThisFileInfo['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12, 4));
$ThisFileInfo['tta']['data_length'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 16, 4));
$ThisFileInfo['playtime_seconds'] = $ThisFileInfo['tta']['data_length'] / $ThisFileInfo['tta']['sample_rate'];
break;
default:
$ThisFileInfo['error'][] = 'This version of getID3() only knows how to handle TTA v1 and v2 - it may not work correctly with this file which appears to be TTA v' . $ttaheader[3];
break;
}
$ThisFileInfo['audio']['encoder_options'] = '-e' . $ThisFileInfo['tta']['compression_level'];
$ThisFileInfo['audio']['encoder'] = 'TTA v' . $ThisFileInfo['tta']['major_version'];
$ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['tta']['bits_per_sample'];
$ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['tta']['sample_rate'];
$ThisFileInfo['audio']['channels'] = $ThisFileInfo['tta']['channels'];
$ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['playtime_seconds'];
return true;
}
示例7: ParseBink
public function ParseBink()
{
$info =& $this->getid3->info;
$info['fileformat'] = 'bink';
$info['video']['dataformat'] = 'bink';
$fileData = 'BIK' . fread($this->getid3->fp, 13);
$info['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
$info['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
if ($info['avdataend'] - $info['avdataoffset'] != $info['bink']['data_size'] + 8) {
$info['error'][] = 'Probably truncated file: expecting ' . $info['bink']['data_size'] . ' bytes, found ' . ($info['avdataend'] - $info['avdataoffset']);
}
return true;
}
示例8: Analyze
function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$RKAUHeader = fread($this->getid3->fp, 20);
$magic = 'RKA';
if (substr($RKAUHeader, 0, 3) != $magic) {
$info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($RKAUHeader, 0, 3)) . '"';
return false;
}
$info['fileformat'] = 'rkau';
$info['audio']['dataformat'] = 'rkau';
$info['audio']['bitrate_mode'] = 'vbr';
$info['rkau']['raw']['version'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 3, 1));
$info['rkau']['version'] = '1.' . str_pad($info['rkau']['raw']['version'] & 0xf, 2, '0', STR_PAD_LEFT);
if ($info['rkau']['version'] > 1.07 || $info['rkau']['version'] < 1.06) {
$info['error'][] = 'This version of getID3() [' . $this->getid3->version() . '] can only parse RKAU files v1.06 and 1.07 (this file is v' . $info['rkau']['version'] . ')';
unset($info['rkau']);
return false;
}
$info['rkau']['source_bytes'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 4, 4));
$info['rkau']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 8, 4));
$info['rkau']['channels'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 12, 1));
$info['rkau']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 13, 1));
$info['rkau']['raw']['quality'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 14, 1));
$this->RKAUqualityLookup($info['rkau']);
$info['rkau']['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 15, 1));
$info['rkau']['flags']['joint_stereo'] = (bool) (!($info['rkau']['raw']['flags'] & 0x1));
$info['rkau']['flags']['streaming'] = (bool) ($info['rkau']['raw']['flags'] & 0x2);
$info['rkau']['flags']['vrq_lossy_mode'] = (bool) ($info['rkau']['raw']['flags'] & 0x4);
if ($info['rkau']['flags']['streaming']) {
$info['avdataoffset'] += 20;
$info['rkau']['compressed_bytes'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 16, 4));
} else {
$info['avdataoffset'] += 16;
$info['rkau']['compressed_bytes'] = $info['avdataend'] - $info['avdataoffset'] - 1;
}
// Note: compressed_bytes does not always equal what appears to be the actual number of compressed bytes,
// sometimes it's more, sometimes less. No idea why(?)
$info['audio']['lossless'] = $info['rkau']['lossless'];
$info['audio']['channels'] = $info['rkau']['channels'];
$info['audio']['bits_per_sample'] = $info['rkau']['bits_per_sample'];
$info['audio']['sample_rate'] = $info['rkau']['sample_rate'];
$info['playtime_seconds'] = $info['rkau']['source_bytes'] / ($info['rkau']['sample_rate'] * $info['rkau']['channels'] * ($info['rkau']['bits_per_sample'] / 8));
$info['audio']['bitrate'] = $info['rkau']['compressed_bytes'] * 8 / $info['playtime_seconds'];
return true;
}
示例9: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
$getid3->include_module('audio-video.riff');
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$shn_header = fread($getid3->fp, 8);
// Magic bytes: "ajkg"
$getid3->info['fileformat'] = 'shn';
$getid3->info['audio']['dataformat'] = 'shn';
$getid3->info['audio']['lossless'] = true;
$getid3->info['audio']['bitrate_mode'] = 'vbr';
$getid3->info['shn']['version'] = getid3_lib::LittleEndian2Int($shn_header[4]);
fseek($getid3->fp, $getid3->info['avdataend'] - 12, SEEK_SET);
$seek_table_signature_test = fread($getid3->fp, 12);
$getid3->info['shn']['seektable']['present'] = (bool) (substr($seek_table_signature_test, 4, 8) == 'SHNAMPSK');
if ($getid3->info['shn']['seektable']['present']) {
$getid3->info['shn']['seektable']['length'] = getid3_lib::LittleEndian2Int(substr($seek_table_signature_test, 0, 4));
$getid3->info['shn']['seektable']['offset'] = $getid3->info['avdataend'] - $getid3->info['shn']['seektable']['length'];
fseek($getid3->fp, $getid3->info['shn']['seektable']['offset'], SEEK_SET);
$seek_table_magic = fread($getid3->fp, 4);
if ($seek_table_magic != 'SEEK') {
throw new getid3_exception('Expecting "SEEK" at offset ' . $getid3->info['shn']['seektable']['offset'] . ', found "' . $seek_table_magic . '"');
}
$seek_table_data = fread($getid3->fp, $getid3->info['shn']['seektable']['length'] - 16);
$getid3->info['shn']['seektable']['entry_count'] = floor(strlen($seek_table_data) / 80);
}
$commandline = 'shorten -x ' . escapeshellarg(realpath($getid3->filename)) . ' - | head -c 64';
$output = `{$commandline}`;
if (@$output && substr($output, 12, 4) == 'fmt ') {
$fmt_size = getid3_lib::LittleEndian2Int(substr($output, 16, 4));
$decoded_wav_format_ex = getid3_riff::RIFFparseWAVEFORMATex(substr($output, 20, $fmt_size));
$getid3->info['audio']['channels'] = $decoded_wav_format_ex['channels'];
$getid3->info['audio']['bits_per_sample'] = $decoded_wav_format_ex['bits_per_sample'];
$getid3->info['audio']['sample_rate'] = $decoded_wav_format_ex['sample_rate'];
if (substr($output, 20 + $fmt_size, 4) == 'data') {
$getid3->info['playtime_seconds'] = getid3_lib::LittleEndian2Int(substr($output, 20 + 4 + $fmt_size, 4)) / $decoded_wav_format_ex['raw']['nAvgBytesPerSec'];
} else {
throw new getid3_exception('shorten failed to decode DATA chunk to expected location, cannot determine playtime');
}
$getid3->info['audio']['bitrate'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) / $getid3->info['playtime_seconds'] * 8;
} else {
throw new getid3_exception('shorten failed to decode file to WAV for parsing');
return false;
}
return true;
}
示例10: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$rkau_header = fread($getid3->fp, 20);
// Magic bytes 'RKA'
$getid3->info['fileformat'] = 'rkau';
$getid3->info['audio']['dataformat'] = 'rkau';
$getid3->info['audio']['bitrate_mode'] = 'vbr';
// Shortcut
$getid3->info['rkau'] = array();
$info_rkau =& $getid3->info['rkau'];
$info_rkau['raw']['version'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 3, 1));
$info_rkau['version'] = '1.' . str_pad($info_rkau['raw']['version'] & 0xf, 2, '0', STR_PAD_LEFT);
if ($info_rkau['version'] > 1.07 || $info_rkau['version'] < 1.06) {
throw new getid3_exception('This version of getID3() can only parse RKAU files v1.06 and 1.07 (this file is v' . $info_rkau['version'] . ')');
}
getid3_lib::ReadSequence('LittleEndian2Int', $info_rkau, $rkau_header, 4, array('source_bytes' => 4, 'sample_rate' => 4, 'channels' => 1, 'bits_per_sample' => 1));
$info_rkau['raw']['quality'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 14, 1));
$quality = $info_rkau['raw']['quality'] & 0xf;
$info_rkau['lossless'] = $quality == 0 ? true : false;
$info_rkau['compression_level'] = (($info_rkau['raw']['quality'] & 0xf0) >> 4) + 1;
if (!$info_rkau['lossless']) {
$info_rkau['quality_setting'] = $quality;
}
$info_rkau['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 15, 1));
$info_rkau['flags']['joint_stereo'] = (bool) (!($info_rkau['raw']['flags'] & 0x1));
$info_rkau['flags']['streaming'] = (bool) ($info_rkau['raw']['flags'] & 0x2);
$info_rkau['flags']['vrq_lossy_mode'] = (bool) ($info_rkau['raw']['flags'] & 0x4);
if ($info_rkau['flags']['streaming']) {
$getid3->info['avdataoffset'] += 20;
$info_rkau['compressed_bytes'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 16, 4));
} else {
$getid3->info['avdataoffset'] += 16;
$info_rkau['compressed_bytes'] = $getid3->info['avdataend'] - $getid3->info['avdataoffset'] - 1;
}
// Note: compressed_bytes does not always equal what appears to be the actual number of compressed bytes,
// sometimes it's more, sometimes less. No idea why(?)
$getid3->info['audio']['lossless'] = $info_rkau['lossless'];
$getid3->info['audio']['channels'] = $info_rkau['channels'];
$getid3->info['audio']['bits_per_sample'] = $info_rkau['bits_per_sample'];
$getid3->info['audio']['sample_rate'] = $info_rkau['sample_rate'];
$getid3->info['playtime_seconds'] = $info_rkau['source_bytes'] / ($info_rkau['sample_rate'] * $info_rkau['channels'] * ($info_rkau['bits_per_sample'] / 8));
$getid3->info['audio']['bitrate'] = $info_rkau['compressed_bytes'] * 8 / $getid3->info['playtime_seconds'];
return true;
}
示例11: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$DSSheader = fread($this->getid3->fp, 1256);
if (!preg_match('#^(\\x02|\\x03)ds[s2]#', $DSSheader)) {
$info['error'][] = 'Expecting "[02-03] 64 73 [73|32]" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($DSSheader, 0, 4)) . '"';
return false;
}
// some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
$info['encoding'] = 'ISO-8859-1';
// not certain, but assumed
$info['dss'] = array();
$info['fileformat'] = 'dss';
$info['mime_type'] = 'audio/x-' . substr($DSSheader, 1, 3);
// "audio/x-dss" or "audio/x-ds2"
$info['audio']['dataformat'] = substr($DSSheader, 1, 3);
// "dss" or "ds2"
$info['audio']['bitrate_mode'] = 'cbr';
$info['dss']['version'] = ord(substr($DSSheader, 0, 1));
$info['dss']['hardware'] = trim(substr($DSSheader, 12, 16));
// identification string for hardware used to create the file, e.g. "DPM 9600", "DS2400"
$info['dss']['unknown1'] = getid3_lib::LittleEndian2Int(substr($DSSheader, 28, 4));
// 32-37 = "FE FF FE FF F7 FF" in all the sample files I've seen
$info['dss']['date_create'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 38, 12));
$info['dss']['date_complete'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 50, 12));
$info['dss']['playtime_sec'] = intval(substr($DSSheader, 62, 2) * 3600 + substr($DSSheader, 64, 2) * 60 + substr($DSSheader, 66, 2));
// approximate file playtime in HHMMSS
$info['dss']['playtime_ms'] = getid3_lib::LittleEndian2Int(substr($DSSheader, 512, 4));
// exact file playtime in milliseconds. Has also been observed at offset 530 in one sample file, with something else (unknown) at offset 512
$info['dss']['priority'] = ord(substr($DSSheader, 793, 1));
$info['dss']['comments'] = trim(substr($DSSheader, 798, 100));
//$info['audio']['bits_per_sample'] = ?;
//$info['audio']['sample_rate'] = ?;
$info['audio']['channels'] = 1;
$info['playtime_seconds'] = $info['dss']['playtime_ms'] / 1000;
if (floor($info['dss']['playtime_ms'] / 1000) != $info['dss']['playtime_sec']) {
// *should* just be playtime_ms / 1000 but at least one sample file has playtime_ms at offset 530 instead of offset 512, so safety check
$info['playtime_seconds'] = $info['dss']['playtime_sec'];
$this->getid3->warning('playtime_ms (' . number_format($info['dss']['playtime_ms'] / 1000, 3) . ') does not match playtime_sec (' . number_format($info['dss']['playtime_sec']) . ') - using playtime_sec value');
}
$info['audio']['bitrate'] = $info['filesize'] * 8 / $info['playtime_seconds'];
return true;
}
示例12: getid3_svg
function getid3_svg(&$fd, &$ThisFileInfo)
{
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
// I'm making this up, please modify as appropriate
$SVGheader = fread($fd, 32);
$ThisFileInfo['svg']['magic'] = substr($SVGheader, 0, 4);
if ($ThisFileInfo['svg']['magic'] == 'aBcD') {
$ThisFileInfo['fileformat'] = 'svg';
$ThisFileInfo['video']['dataformat'] = 'svg';
$ThisFileInfo['video']['lossless'] = true;
$ThisFileInfo['video']['bits_per_sample'] = 24;
$ThisFileInfo['video']['pixel_aspect_ratio'] = (double) 1;
$ThisFileInfo['svg']['width'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
$ThisFileInfo['svg']['height'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 4));
$ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['svg']['width'];
$ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['svg']['height'];
return true;
}
$ThisFileInfo['error'][] = 'Did not find SVG magic bytes "aBcD" at ' . $ThisFileInfo['avdataoffset'];
unset($ThisFileInfo['fileformat']);
return false;
}
開發者ID:Teino1978-Corp,項目名稱:Teino1978-Corp-owncloud_.htaccess-,代碼行數:22,代碼來源:owncloud_apps_media_getID3_getid3_module.graphic.svg.php
示例13: EitherEndian2Int
function EitherEndian2Int(&$ThisFileInfo, $byteword, $signed = false)
{
if ($ThisFileInfo['fileformat'] == 'riff') {
return getid3_lib::LittleEndian2Int($byteword, $signed);
}
return getid3_lib::BigEndian2Int($byteword, false, $signed);
}
示例14: Analyze
function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
while (true) {
$wavpackheader = fread($this->getid3->fp, 32);
if (ftell($this->getid3->fp) >= $info['avdataend']) {
break;
} elseif (feof($this->getid3->fp)) {
break;
} elseif (isset($info['wavpack']['blockheader']['total_samples']) && isset($info['wavpack']['blockheader']['block_samples']) && $info['wavpack']['blockheader']['total_samples'] > 0 && $info['wavpack']['blockheader']['block_samples'] > 0 && (!isset($info['wavpack']['riff_trailer_size']) || $info['wavpack']['riff_trailer_size'] <= 0) && (isset($info['wavpack']['config_flags']['md5_checksum']) && $info['wavpack']['config_flags']['md5_checksum'] === false || !empty($info['md5_data_source']))) {
break;
}
$blockheader_offset = ftell($this->getid3->fp) - 32;
$blockheader_magic = substr($wavpackheader, 0, 4);
$blockheader_size = getid3_lib::LittleEndian2Int(substr($wavpackheader, 4, 4));
$magic = 'wvpk';
if ($blockheader_magic != $magic) {
$info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" at offset ' . $blockheader_offset . ', found "' . getid3_lib::PrintHexBytes($blockheader_magic) . '"';
switch (isset($info['audio']['dataformat']) ? $info['audio']['dataformat'] : '') {
case 'wavpack':
case 'wvc':
break;
default:
unset($info['fileformat']);
unset($info['audio']);
unset($info['wavpack']);
break;
}
return false;
}
if (empty($info['wavpack']['blockheader']['block_samples']) || empty($info['wavpack']['blockheader']['total_samples']) || $info['wavpack']['blockheader']['block_samples'] <= 0 || $info['wavpack']['blockheader']['total_samples'] <= 0) {
// Also, it is possible that the first block might not have
// any samples (block_samples == 0) and in this case you should skip blocks
// until you find one with samples because the other information (like
// total_samples) are not guaranteed to be correct until (block_samples > 0)
// Finally, I have defined a format for files in which the length is not known
// (for example when raw files are created using pipes). In these cases
// total_samples will be -1 and you must seek to the final block to determine
// the total number of samples.
$info['audio']['dataformat'] = 'wavpack';
$info['fileformat'] = 'wavpack';
$info['audio']['lossless'] = true;
$info['audio']['bitrate_mode'] = 'vbr';
$info['wavpack']['blockheader']['offset'] = $blockheader_offset;
$info['wavpack']['blockheader']['magic'] = $blockheader_magic;
$info['wavpack']['blockheader']['size'] = $blockheader_size;
if ($info['wavpack']['blockheader']['size'] >= 0x100000) {
$info['error'][] = 'Expecting WavPack block size less than "0x100000", found "' . $info['wavpack']['blockheader']['size'] . '" at offset ' . $info['wavpack']['blockheader']['offset'];
switch (isset($info['audio']['dataformat']) ? $info['audio']['dataformat'] : '') {
case 'wavpack':
case 'wvc':
break;
default:
unset($info['fileformat']);
unset($info['audio']);
unset($info['wavpack']);
break;
}
return false;
}
$info['wavpack']['blockheader']['minor_version'] = ord($wavpackheader[8]);
$info['wavpack']['blockheader']['major_version'] = ord($wavpackheader[9]);
if ($info['wavpack']['blockheader']['major_version'] != 4 || $info['wavpack']['blockheader']['minor_version'] < 4 && $info['wavpack']['blockheader']['minor_version'] > 16) {
$info['error'][] = 'Expecting WavPack version between "4.2" and "4.16", found version "' . $info['wavpack']['blockheader']['major_version'] . '.' . $info['wavpack']['blockheader']['minor_version'] . '" at offset ' . $info['wavpack']['blockheader']['offset'];
switch (isset($info['audio']['dataformat']) ? $info['audio']['dataformat'] : '') {
case 'wavpack':
case 'wvc':
break;
default:
unset($info['fileformat']);
unset($info['audio']);
unset($info['wavpack']);
break;
}
return false;
}
$info['wavpack']['blockheader']['track_number'] = ord($wavpackheader[10]);
// unused
$info['wavpack']['blockheader']['index_number'] = ord($wavpackheader[11]);
// unused
$info['wavpack']['blockheader']['total_samples'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 12, 4));
$info['wavpack']['blockheader']['block_index'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 16, 4));
$info['wavpack']['blockheader']['block_samples'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 20, 4));
$info['wavpack']['blockheader']['flags_raw'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 24, 4));
$info['wavpack']['blockheader']['crc'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 28, 4));
$info['wavpack']['blockheader']['flags']['bytes_per_sample'] = 1 + ($info['wavpack']['blockheader']['flags_raw'] & 0x3);
$info['wavpack']['blockheader']['flags']['mono'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x4);
$info['wavpack']['blockheader']['flags']['hybrid'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x8);
$info['wavpack']['blockheader']['flags']['joint_stereo'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x10);
$info['wavpack']['blockheader']['flags']['cross_decorrelation'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x20);
$info['wavpack']['blockheader']['flags']['hybrid_noiseshape'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x40);
$info['wavpack']['blockheader']['flags']['ieee_32bit_float'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x80);
$info['wavpack']['blockheader']['flags']['int_32bit'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x100);
$info['wavpack']['blockheader']['flags']['hybrid_bitrate_noise'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x200);
$info['wavpack']['blockheader']['flags']['hybrid_balance_noise'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x400);
$info['wavpack']['blockheader']['flags']['multichannel_initial'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x800);
$info['wavpack']['blockheader']['flags']['multichannel_final'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x1000);
$info['audio']['lossless'] = !$info['wavpack']['blockheader']['flags']['hybrid'];
}
//.........這裏部分代碼省略.........
示例15: MultiByteCharString2HTML
static function MultiByteCharString2HTML($string, $charset = 'ISO-8859-1')
{
$HTMLstring = '';
switch ($charset) {
case 'ISO-8859-1':
case 'ISO8859-1':
case 'ISO-8859-15':
case 'ISO8859-15':
case 'cp866':
case 'ibm866':
case '866':
case 'cp1251':
case 'Windows-1251':
case 'win-1251':
case '1251':
case 'cp1252':
case 'Windows-1252':
case '1252':
case 'KOI8-R':
case 'koi8-ru':
case 'koi8r':
case 'BIG5':
case '950':
case 'GB2312':
case '936':
case 'BIG5-HKSCS':
case 'Shift_JIS':
case 'SJIS':
case '932':
case 'EUC-JP':
case 'EUCJP':
$HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
break;
case 'UTF-8':
$strlen = strlen($string);
for ($i = 0; $i < $strlen; $i++) {
$char_ord_val = ord($string[$i]);
$charval = 0;
if ($char_ord_val < 0x80) {
$charval = $char_ord_val;
} elseif (($char_ord_val & 0xf0) >> 4 == 0xf && $i + 3 < $strlen) {
$charval = ($char_ord_val & 0x7) << 18;
$charval += (ord($string[++$i]) & 0x3f) << 12;
$charval += (ord($string[++$i]) & 0x3f) << 6;
$charval += ord($string[++$i]) & 0x3f;
} elseif (($char_ord_val & 0xe0) >> 5 == 0x7 && $i + 2 < $strlen) {
$charval = ($char_ord_val & 0xf) << 12;
$charval += (ord($string[++$i]) & 0x3f) << 6;
$charval += ord($string[++$i]) & 0x3f;
} elseif (($char_ord_val & 0xc0) >> 6 == 0x3 && $i + 1 < $strlen) {
$charval = ($char_ord_val & 0x1f) << 6;
$charval += ord($string[++$i]) & 0x3f;
}
if ($charval >= 32 && $charval <= 127) {
$HTMLstring .= htmlentities(chr($charval));
} else {
$HTMLstring .= '&#' . $charval . ';';
}
}
break;
case 'UTF-16LE':
for ($i = 0; $i < strlen($string); $i += 2) {
$charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
if ($charval >= 32 && $charval <= 127) {
$HTMLstring .= chr($charval);
} else {
$HTMLstring .= '&#' . $charval . ';';
}
}
break;
case 'UTF-16BE':
for ($i = 0; $i < strlen($string); $i += 2) {
$charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
if ($charval >= 32 && $charval <= 127) {
$HTMLstring .= chr($charval);
} else {
$HTMLstring .= '&#' . $charval . ';';
}
}
break;
default:
$HTMLstring = 'ERROR: Character set "' . $charset . '" not supported in MultiByteCharString2HTML()';
break;
}
return $HTMLstring;
}