本文整理匯總了PHP中getid3_lib::BigEndianSyncSafe2Int方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::BigEndianSyncSafe2Int方法的具體用法?PHP getid3_lib::BigEndianSyncSafe2Int怎麽用?PHP getid3_lib::BigEndianSyncSafe2Int使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類getid3_lib
的用法示例。
在下文中一共展示了getid3_lib::BigEndianSyncSafe2Int方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
// dependency
$getid3->include_module('tag.id3v1');
if ($getid3->option_tags_images) {
$getid3->include_module('lib.image_size');
}
// Overall tag structure:
// +-----------------------------+
// | Header (10 bytes) |
// +-----------------------------+
// | Extended Header |
// | (variable length, OPTIONAL) |
// +-----------------------------+
// | Frames (variable length) |
// +-----------------------------+
// | Padding |
// | (variable length, OPTIONAL) |
// +-----------------------------+
// | Footer (10 bytes, OPTIONAL) |
// +-----------------------------+
//
// Header
// ID3v2/file identifier "ID3"
// ID3v2 version $04 00
// ID3v2 flags (%ab000000 in v2.2, %abc00000 in v2.3, %abcd0000 in v2.4.x)
// ID3v2 size 4 * %0xxxxxxx
// shortcuts
$getid3->info['id3v2']['header'] = true;
$info_id3v2 =& $getid3->info['id3v2'];
$info_id3v2['flags'] = array();
$info_id3v2_flags =& $info_id3v2['flags'];
$this->fseek($this->option_starting_offset, SEEK_SET);
$header = $this->fread(10);
if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) {
$info_id3v2['majorversion'] = ord($header[3]);
$info_id3v2['minorversion'] = ord($header[4]);
// shortcut
$id3v2_major_version =& $info_id3v2['majorversion'];
} else {
unset($getid3->info['id3v2']);
return false;
}
if ($id3v2_major_version > 4) {
// this script probably won't correctly parse ID3v2.5.x and above (if it ever exists)
throw new getid3_exception('this script only parses up to ID3v2.4.x - this tag is ID3v2.' . $id3v2_major_version . '.' . $info_id3v2['minorversion']);
}
$id3_flags = ord($header[5]);
switch ($id3v2_major_version) {
case 2:
// %ab000000 in v2.2
$info_id3v2_flags['unsynch'] = (bool) ($id3_flags & 0x80);
// a - Unsynchronisation
$info_id3v2_flags['compression'] = (bool) ($id3_flags & 0x40);
// b - Compression
break;
case 3:
// %abc00000 in v2.3
$info_id3v2_flags['unsynch'] = (bool) ($id3_flags & 0x80);
// a - Unsynchronisation
$info_id3v2_flags['exthead'] = (bool) ($id3_flags & 0x40);
// b - Extended header
$info_id3v2_flags['experim'] = (bool) ($id3_flags & 0x20);
// c - Experimental indicator
break;
case 4:
// %abcd0000 in v2.4
$info_id3v2_flags['unsynch'] = (bool) ($id3_flags & 0x80);
// a - Unsynchronisation
$info_id3v2_flags['exthead'] = (bool) ($id3_flags & 0x40);
// b - Extended header
$info_id3v2_flags['experim'] = (bool) ($id3_flags & 0x20);
// c - Experimental indicator
$info_id3v2_flags['isfooter'] = (bool) ($id3_flags & 0x10);
// d - Footer present
break;
}
$info_id3v2['headerlength'] = getid3_lib::BigEndianSyncSafe2Int(substr($header, 6, 4)) + 10;
// length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
$info_id3v2['tag_offset_start'] = $this->option_starting_offset;
$info_id3v2['tag_offset_end'] = $info_id3v2['tag_offset_start'] + $info_id3v2['headerlength'];
// Frames
// All ID3v2 frames consists of one frame header followed by one or more
// fields containing the actual information. The header is always 10
// bytes and laid out as follows:
//
// Frame ID $xx xx xx xx (four characters)
// Size 4 * %0xxxxxxx
// Flags $xx xx
$size_of_frames = $info_id3v2['headerlength'] - 10;
// not including 10-byte initial header
if (@$info_id3v2['exthead']['length']) {
$size_of_frames -= $info_id3v2['exthead']['length'] + 4;
}
if (@$info_id3v2_flags['isfooter']) {
$size_of_frames -= 10;
// footer takes last 10 bytes of ID3v2 header, after frame data, before audio
}
if ($size_of_frames > 0) {
//.........這裏部分代碼省略.........
示例2: Analyze
//.........這裏部分代碼省略.........
$info_riff_cdda_fmt_0['playtime_seconds'] = (double) $info_riff_cdda_fmt_0['playtime_frames'] / 75;
$getid3->info['comments']['track'] = $info_riff_cdda_fmt_0['track_num'];
$getid3->info['playtime_seconds'] = $info_riff_cdda_fmt_0['playtime_seconds'];
// hardcoded data for CD-audio
$info_audio['sample_rate'] = 44100;
$info_audio['channels'] = 2;
$info_audio['bits_per_sample'] = 16;
$info_audio['bitrate'] = $info_audio['sample_rate'] * $info_audio['channels'] * $info_audio['bits_per_sample'];
$info_audio['bitrate_mode'] = 'cbr';
}
break;
case 'AIFF':
case 'AIFC':
$info_audio['bitrate_mode'] = 'cbr';
$info_audio_dataformat = 'aiff';
$info_audio['lossless'] = true;
$getid3->info['mime_type'] = 'audio/x-aiff';
if (isset($info_riff[$riff_sub_type]['SSND'][0]['offset'])) {
$info_avdataoffset = $info_riff[$riff_sub_type]['SSND'][0]['offset'] + 8;
$info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['SSND'][0]['size'];
if ($info_avdataend > $getid3->info['filesize']) {
if ($info_avdataend == $getid3->info['filesize'] + 1 && $getid3->info['filesize'] % 2 == 1) {
// structures rounded to 2-byte boundary, but dumb encoders
// forget to pad end of file to make this actually work
} else {
$getid3->warning('Probable truncated AIFF file: expecting ' . $info_riff[$riff_sub_type]['SSND'][0]['size'] . ' bytes of audio data, only ' . ($getid3->info['filesize'] - $info_avdataoffset) . ' bytes found');
}
$info_avdataend = $getid3->info['filesize'];
}
}
if (isset($info_riff[$riff_sub_type]['COMM'][0]['data'])) {
// shortcut
$info_riff_RIFFsubtype_COMM_0_data =& $info_riff[$riff_sub_type]['COMM'][0]['data'];
$info_riff_audio['channels'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 0, 2));
$info_riff_audio['total_samples'] = getid3_lib::BigEndian2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 2, 4));
$info_riff_audio['bits_per_sample'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 6, 2));
$info_riff_audio['sample_rate'] = (int) getid3_riff::BigEndian2Float(substr($info_riff_RIFFsubtype_COMM_0_data, 8, 10));
if ($info_riff[$riff_sub_type]['COMM'][0]['size'] > 18) {
$info_riff_audio['codec_fourcc'] = substr($info_riff_RIFFsubtype_COMM_0_data, 18, 4);
$codec_name_size = getid3_lib::BigEndian2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 22, 1));
$info_riff_audio['codec_name'] = substr($info_riff_RIFFsubtype_COMM_0_data, 23, $codec_name_size);
switch ($info_riff_audio['codec_name']) {
case 'NONE':
$info_audio['codec'] = 'Pulse Code Modulation (PCM)';
$info_audio['lossless'] = true;
break;
case '':
switch ($info_riff_audio['codec_fourcc']) {
// http://developer.apple.com/qa/snd/snd07.html
case 'sowt':
$info_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM';
$info_audio['lossless'] = true;
break;
case 'twos':
$info_riff_audio['codec_name'] = 'Two\'s Compliment Big-Endian PCM';
$info_audio['lossless'] = true;
break;
default:
break;
}
break;
default:
$info_audio['codec'] = $info_riff_audio['codec_name'];
$info_audio['lossless'] = false;
break;
}