本文整理汇总了PHP中getid3_riff::EitherEndian2Int方法的典型用法代码示例。如果您正苦于以下问题:PHP getid3_riff::EitherEndian2Int方法的具体用法?PHP getid3_riff::EitherEndian2Int怎么用?PHP getid3_riff::EitherEndian2Int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类getid3_riff
的用法示例。
在下文中一共展示了getid3_riff::EitherEndian2Int方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ParseRIFF
function ParseRIFF(&$fd, $startoffset, $maxoffset, &$ThisFileInfo)
{
$maxoffset = min($maxoffset, $ThisFileInfo['avdataend']);
$RIFFchunk = false;
fseek($fd, $startoffset, SEEK_SET);
while (ftell($fd) < $maxoffset) {
$chunkname = fread($fd, 4);
if (strlen($chunkname) < 4) {
$ThisFileInfo['error'][] = 'Expecting chunk name at offset ' . (ftell($fd) - 4) . ' but found nothing. Aborting RIFF parsing.';
break;
}
$chunksize = getid3_riff::EitherEndian2Int($ThisFileInfo, fread($fd, 4));
if ($chunksize == 0) {
$ThisFileInfo['error'][] = 'Chunk size at offset ' . (ftell($fd) - 4) . ' is zero. Aborting RIFF parsing.';
break;
}
if ($chunksize % 2 != 0) {
// all structures are packed on word boundaries
$chunksize++;
}
switch ($chunkname) {
case 'LIST':
$listname = fread($fd, 4);
switch ($listname) {
case 'movi':
case 'rec ':
$RIFFchunk[$listname]['offset'] = ftell($fd) - 4;
$RIFFchunk[$listname]['size'] = $chunksize;
static $ParsedAudioStream = false;
if ($ParsedAudioStream) {
// skip over
} else {
$WhereWeWere = ftell($fd);
$AudioChunkHeader = fread($fd, 12);
$AudioChunkStreamNum = substr($AudioChunkHeader, 0, 2);
$AudioChunkStreamType = substr($AudioChunkHeader, 2, 2);
$AudioChunkSize = getid3_lib::LittleEndian2Int(substr($AudioChunkHeader, 4, 4));
if ($AudioChunkStreamType == 'wb') {
$FirstFourBytes = substr($AudioChunkHeader, 8, 4);
if (preg_match('/^\\xFF[\\xE2-\\xE7\\xF2-\\xF7\\xFA-\\xFF][\\x00-\\xEB]/s', $FirstFourBytes)) {
// MP3
if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) {
$dummy = $ThisFileInfo;
$dummy['avdataoffset'] = ftell($fd) - 4;
$dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
getid3_mp3::getOnlyMPEGaudioInfo($fd, $dummy, $dummy['avdataoffset'], false);
if (isset($dummy['mpeg']['audio'])) {
$ThisFileInfo = $dummy;
$ThisFileInfo['audio']['dataformat'] = 'mp' . $ThisFileInfo['mpeg']['audio']['layer'];
$ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
$ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
$ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
$ThisFileInfo['bitrate'] = $ThisFileInfo['audio']['bitrate'];
$ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
}
}
} elseif (preg_match('/^\\x0B\\x77/s', $FirstFourBytes)) {
// AC3
$GETID3_ERRORARRAY =& $ThisFileInfo['warning'];
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio.ac3.php', __FILE__, false)) {
$dummy = $ThisFileInfo;
$dummy['avdataoffset'] = ftell($fd) - 4;
$dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
$dummy['error'] = array();
$ac3_tag = new getid3_ac3($fd, $dummy);
if (empty($dummy['error'])) {
$ThisFileInfo['audio'] = $dummy['audio'];
$ThisFileInfo['ac3'] = $dummy['ac3'];
$ThisFileInfo['warning'] = $dummy['warning'];
}
}
}
}
$ParsedAudioStream = true;
fseek($fd, $WhereWeWere, SEEK_SET);
}
fseek($fd, $chunksize - 4, SEEK_CUR);
break;
default:
if (!isset($RIFFchunk[$listname])) {
$RIFFchunk[$listname] = array();
}
$LISTchunkParent = $listname;
$LISTchunkMaxOffset = ftell($fd) - 4 + $chunksize;
if ($parsedChunk = getid3_riff::ParseRIFF($fd, ftell($fd), ftell($fd) + $chunksize - 4, $ThisFileInfo)) {
$RIFFchunk[$listname] = array_merge_recursive($RIFFchunk[$listname], $parsedChunk);
}
break;
}
break;
default:
$thisindex = 0;
if (isset($RIFFchunk[$chunkname]) && is_array($RIFFchunk[$chunkname])) {
$thisindex = count($RIFFchunk[$chunkname]);
}
$RIFFchunk[$chunkname][$thisindex]['offset'] = ftell($fd) - 8;
$RIFFchunk[$chunkname][$thisindex]['size'] = $chunksize;
switch ($chunkname) {
case 'data':
$ThisFileInfo['avdataoffset'] = ftell($fd);
//.........这里部分代码省略.........
示例2: ParseRIFF
static function ParseRIFF(&$fd, $startoffset, $maxoffset, &$ThisFileInfo)
{
$maxoffset = min($maxoffset, $ThisFileInfo['avdataend']);
$RIFFchunk = false;
$FoundAllChunksWeNeed = false;
if ($startoffset < 0 || !getid3_lib::intValueSupported($startoffset)) {
$ThisFileInfo['warning'][] = 'Unable to ParseRIFF() at ' . $startoffset . ' because beyond ' . round(PHP_INT_MAX / 1073741824) . 'GB limit of PHP filesystem functions';
return false;
}
$max_usable_offset = min(PHP_INT_MAX - 1024, $maxoffset);
if ($maxoffset > $max_usable_offset) {
$ThisFileInfo['warning'][] = 'ParseRIFF() may return incomplete data for chunk starting at ' . $startoffset . ' because beyond it extends to ' . $maxoffset . ', which is beyond the ' . round(PHP_INT_MAX / 1073741824) . 'GB limit of PHP filesystem functions';
}
fseek($fd, $startoffset, SEEK_SET);
while (ftell($fd) < $max_usable_offset) {
$chunknamesize = fread($fd, 8);
$chunkname = substr($chunknamesize, 0, 4);
$chunksize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($chunknamesize, 4, 4));
if (strlen($chunkname) < 4) {
$ThisFileInfo['error'][] = 'Expecting chunk name at offset ' . (ftell($fd) - 4) . ' but found nothing. Aborting RIFF parsing.';
break;
}
if ($chunksize == 0) {
if ($chunkname == 'JUNK') {
// we'll allow zero-size JUNK frames
} else {
$ThisFileInfo['warning'][] = 'Chunk size at offset ' . (ftell($fd) - 4) . ' is zero. Aborting RIFF parsing.';
break;
}
}
if ($chunksize % 2 != 0) {
// all structures are packed on word boundaries
$chunksize++;
}
switch ($chunkname) {
case 'LIST':
$listname = fread($fd, 4);
if (preg_match('#^(movi|rec )$#i', $listname)) {
$RIFFchunk[$listname]['offset'] = ftell($fd) - 4;
$RIFFchunk[$listname]['size'] = $chunksize;
if ($FoundAllChunksWeNeed) {
// skip over
} else {
$WhereWeWere = ftell($fd);
$AudioChunkHeader = fread($fd, 12);
$AudioChunkStreamNum = substr($AudioChunkHeader, 0, 2);
$AudioChunkStreamType = substr($AudioChunkHeader, 2, 2);
$AudioChunkSize = getid3_lib::LittleEndian2Int(substr($AudioChunkHeader, 4, 4));
if ($AudioChunkStreamType == 'wb') {
$FirstFourBytes = substr($AudioChunkHeader, 8, 4);
if (preg_match('/^\\xFF[\\xE2-\\xE7\\xF2-\\xF7\\xFA-\\xFF][\\x00-\\xEB]/s', $FirstFourBytes)) {
// MP3
if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) {
$dummy = $ThisFileInfo;
$dummy['avdataoffset'] = ftell($fd) - 4;
$dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
getid3_mp3::getOnlyMPEGaudioInfo($fd, $dummy, $dummy['avdataoffset'], false);
if (isset($dummy['mpeg']['audio'])) {
$ThisFileInfo = $dummy;
$ThisFileInfo['audio']['dataformat'] = 'mp' . $ThisFileInfo['mpeg']['audio']['layer'];
$ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
$ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
$ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
$ThisFileInfo['bitrate'] = $ThisFileInfo['audio']['bitrate'];
$ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
}
unset($dummy);
}
} elseif (preg_match('/^\\x0B\\x77/s', $FirstFourBytes)) {
// AC3
$GETID3_ERRORARRAY =& $ThisFileInfo['warning'];
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio.ac3.php', __FILE__, false)) {
$dummy = $ThisFileInfo;
$dummy['avdataoffset'] = ftell($fd) - 4;
$dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
$dummy['error'] = array();
$ac3_tag = new getid3_ac3($fd, $dummy);
if (empty($dummy['error'])) {
$ThisFileInfo['audio'] = $dummy['audio'];
$ThisFileInfo['ac3'] = $dummy['ac3'];
$ThisFileInfo['warning'] = $dummy['warning'];
}
unset($ac3_tag);
}
}
}
$FoundAllChunksWeNeed = true;
fseek($fd, $WhereWeWere, SEEK_SET);
}
fseek($fd, $chunksize - 4, SEEK_CUR);
//} elseif (preg_match('#^[0-9]{2}(wb|pc|dc|db)$#i', $listname)) {
//
// // data chunk, ignore
//
} else {
if (!isset($RIFFchunk[$listname])) {
$RIFFchunk[$listname] = array();
}
$LISTchunkParent = $listname;
$LISTchunkMaxOffset = ftell($fd) - 4 + $chunksize;
//.........这里部分代码省略.........