本文整理匯總了PHP中getid3_lib::ReadSequence方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::ReadSequence方法的具體用法?PHP getid3_lib::ReadSequence怎麽用?PHP getid3_lib::ReadSequence使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類getid3_lib
的用法示例。
在下文中一共展示了getid3_lib::ReadSequence方法的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;
}
示例2: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
$getid3->info['fileformat'] = 'tta';
$getid3->info['audio']['dataformat'] = 'tta';
$getid3->info['audio']['lossless'] = true;
$getid3->info['audio']['bitrate_mode'] = 'vbr';
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$tta_header = fread($getid3->fp, 26);
$getid3->info['tta']['magic'] = 'TTA';
// Magic bytes
switch ($tta_header[3]) {
case "":
// TTA v1.x
// TTA v1.x
case "":
// TTA v1.x
// TTA v1.x
case "":
// TTA v1.x
// "It was the demo-version of the TTA encoder. There is no released format with such header. TTA encoder v1 is not supported about a year."
$getid3->info['tta']['major_version'] = 1;
$getid3->info['avdataoffset'] += 16;
getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4, array('channels' => 2, 'bits_per_sample' => 2, 'sample_rate' => 4, 'samples_per_channel' => 4));
$getid3->info['tta']['compression_level'] = ord($tta_header[3]);
$getid3->info['audio']['encoder_options'] = '-e' . $getid3->info['tta']['compression_level'];
$getid3->info['playtime_seconds'] = $getid3->info['tta']['samples_per_channel'] / $getid3->info['tta']['sample_rate'];
break;
case '2':
// TTA v2.x
// "I have hurried to release the TTA 2.0 encoder. Format documentation is removed from our site. This format still in development. Please wait the TTA2 format, encoder v4."
$getid3->info['tta']['major_version'] = 2;
$getid3->info['avdataoffset'] += 20;
getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4, array('compression_level' => 2, 'audio_format' => 2, 'channels' => 2, 'bits_per_sample' => 2, 'sample_rate' => 4, 'data_length' => 4));
$getid3->info['audio']['encoder_options'] = '-e' . $getid3->info['tta']['compression_level'];
$getid3->info['playtime_seconds'] = $getid3->info['tta']['data_length'] / $getid3->info['tta']['sample_rate'];
break;
case '1':
// TTA v3.x
// "This is a first stable release of the TTA format. It will be supported by the encoders v3 or higher."
$getid3->info['tta']['major_version'] = 3;
$getid3->info['avdataoffset'] += 26;
getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4, array('audio_format' => 2, 'channels' => 2, 'bits_per_sample' => 2, 'sample_rate' => 4, 'data_length' => 4, 'crc32_footer' => -4, 'seek_point' => 4));
$getid3->info['playtime_seconds'] = $getid3->info['tta']['data_length'] / $getid3->info['tta']['sample_rate'];
break;
default:
throw new getid3_exception('This version of getID3() only knows how to handle TTA v1, v2 and v3 - it may not work correctly with this file which appears to be TTA v' . $tta_header[3]);
return false;
break;
}
$getid3->info['audio']['encoder'] = 'TTA v' . $getid3->info['tta']['major_version'];
$getid3->info['audio']['bits_per_sample'] = $getid3->info['tta']['bits_per_sample'];
$getid3->info['audio']['sample_rate'] = $getid3->info['tta']['sample_rate'];
$getid3->info['audio']['channels'] = $getid3->info['tta']['channels'];
$getid3->info['audio']['bitrate'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8 / $getid3->info['playtime_seconds'];
return true;
}
示例3: 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;
}
示例4: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
$getid3->info['fileformat'] = 'gif';
$getid3->info['video']['dataformat'] = 'gif';
$getid3->info['video']['lossless'] = true;
$getid3->info['video']['pixel_aspect_ratio'] = (double) 1;
$getid3->info['gif']['header'] = array();
$info_gif_header =& $getid3->info['gif']['header'];
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$gif_header = fread($getid3->fp, 13);
// Magic bytes
$info_gif_header['raw']['identifier'] = 'GIF';
getid3_lib::ReadSequence('LittleEndian2Int', $info_gif_header['raw'], $gif_header, 3, array('version' => -3, 'width' => 2, 'height' => 2, 'flags' => 1, 'bg_color_index' => 1, 'aspect_ratio' => 1));
$getid3->info['video']['resolution_x'] = $info_gif_header['raw']['width'];
$getid3->info['video']['resolution_y'] = $info_gif_header['raw']['height'];
$getid3->info['gif']['version'] = $info_gif_header['raw']['version'];
$info_gif_header['flags']['global_color_table'] = (bool) ($info_gif_header['raw']['flags'] & 0x80);
if ($info_gif_header['raw']['flags'] & 0x80) {
// Number of bits per primary color available to the original image, minus 1
$info_gif_header['bits_per_pixel'] = 3 * ((($info_gif_header['raw']['flags'] & 0x70) >> 4) + 1);
} else {
$info_gif_header['bits_per_pixel'] = 0;
}
$info_gif_header['flags']['global_color_sorted'] = (bool) ($info_gif_header['raw']['flags'] & 0x40);
if ($info_gif_header['flags']['global_color_table']) {
// the number of bytes contained in the Global Color Table. To determine that
// actual size of the color table, raise 2 to [the value of the field + 1]
$info_gif_header['global_color_size'] = pow(2, ($info_gif_header['raw']['flags'] & 0x7) + 1);
$getid3->info['video']['bits_per_sample'] = ($info_gif_header['raw']['flags'] & 0x7) + 1;
} else {
$info_gif_header['global_color_size'] = 0;
}
if ($info_gif_header['raw']['aspect_ratio'] != 0) {
// Aspect Ratio = (Pixel Aspect Ratio + 15) / 64
$info_gif_header['aspect_ratio'] = ($info_gif_header['raw']['aspect_ratio'] + 15) / 64;
}
return true;
}
示例5: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
$getid3->info['midi']['raw'] = array();
$info_midi =& $getid3->info['midi'];
$info_midi_raw =& $info_midi['raw'];
$getid3->info['fileformat'] = 'midi';
$getid3->info['audio']['dataformat'] = 'midi';
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$midi_data = fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
// Magic bytes: 'MThd'
getid3_lib::ReadSequence('BigEndian2Int', $info_midi_raw, $midi_data, 4, array('headersize' => 4, 'fileformat' => 2, 'tracks' => 2, 'ticksperqnote' => 2));
$offset = 14;
for ($i = 0; $i < $info_midi_raw['tracks']; $i++) {
if (strlen($midi_data) - $offset < 8) {
$midi_data .= fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
}
$track_id = substr($midi_data, $offset, 4);
$offset += 4;
if ($track_id != 'MTrk') {
throw new getid3_exception('Expecting "MTrk" at ' . $offset . ', found ' . $track_id . ' instead');
}
$track_size = getid3_lib::BigEndian2Int(substr($midi_data, $offset, 4));
$offset += 4;
$track_data_array[$i] = substr($midi_data, $offset, $track_size);
$offset += $track_size;
}
if (!isset($track_data_array) || !is_array($track_data_array)) {
throw new getid3_exception('Cannot find MIDI track information');
}
$info_midi['totalticks'] = 0;
$getid3->info['playtime_seconds'] = 0;
$current_ms_per_beat = 500000;
// 120 beats per minute; 60,000,000 microseconds per minute -> 500,000 microseconds per beat
$current_beats_per_min = 120;
// 120 beats per minute; 60,000,000 microseconds per minute -> 500,000 microseconds per beat
$ms_per_quarter_note_after = array();
foreach ($track_data_array as $track_number => $track_data) {
$events_offset = $last_issued_midi_command = $last_issued_midi_channel = $cumulative_delta_time = $ticks_at_current_bpm = 0;
while ($events_offset < strlen($track_data)) {
$event_id = 0;
if (isset($midi_events[$track_number]) && is_array($midi_events[$track_number])) {
$event_id = count($midi_events[$track_number]);
}
$delta_time = 0;
for ($i = 0; $i < 4; $i++) {
$delta_time_byte = ord($track_data[$events_offset++]);
$delta_time = ($delta_time << 7) + ($delta_time_byte & 0x7f);
if ($delta_time_byte & 0x80) {
// another byte follows
} else {
break;
}
}
$cumulative_delta_time += $delta_time;
$ticks_at_current_bpm += $delta_time;
$midi_events[$track_number][$event_id]['deltatime'] = $delta_time;
$midi_event_channel = ord($track_data[$events_offset++]);
// OK, normal event - MIDI command has MSB set
if ($midi_event_channel & 0x80) {
$last_issued_midi_command = $midi_event_channel >> 4;
$last_issued_midi_channel = $midi_event_channel & 0xf;
} else {
$events_offset--;
}
$midi_events[$track_number][$event_id]['eventid'] = $last_issued_midi_command;
$midi_events[$track_number][$event_id]['channel'] = $last_issued_midi_channel;
switch ($midi_events[$track_number][$event_id]['eventid']) {
case 0x8:
// Note off (key is released)
// Note off (key is released)
case 0x9:
// Note on (key is pressed)
// Note on (key is pressed)
case 0xa:
// Key after-touch
//$notenumber = ord($track_data{$events_offset++});
//$velocity = ord($track_data{$events_offset++});
$events_offset += 2;
break;
case 0xb:
// Control Change
//$controllernum = ord($track_data{$events_offset++});
//$newvalue = ord($track_data{$events_offset++});
$events_offset += 2;
break;
case 0xc:
// Program (patch) change
$new_program_num = ord($track_data[$events_offset++]);
$info_midi_raw['track'][$track_number]['instrumentid'] = $new_program_num;
$info_midi_raw['track'][$track_number]['instrument'] = $track_number == 10 ? getid3_midi::GeneralMIDIpercussionLookup($new_program_num) : getid3_midi::GeneralMIDIinstrumentLookup($new_program_num);
break;
case 0xd:
// Channel after-touch
//$channelnumber = ord($track_data{$events_offset++});
break;
case 0xe:
// Pitch wheel change (2000H is normal or no change)
//$changeLSB = ord($track_data{$events_offset++});
//$changeMSB = ord($track_data{$events_offset++});
//.........這裏部分代碼省略.........
示例6: ParseAPEheaderFooter
protected function ParseAPEheaderFooter($data, &$target)
{
// http://www.uni-jena.de/~pfk/mpp/sv8/apeheader.html
if (substr($data, 0, 8) != 'APETAGEX') {
return false;
}
// shortcut
$target['raw'] = array();
$target_raw =& $target['raw'];
$target_raw['footer_tag'] = 'APETAGEX';
getid3_lib::ReadSequence("LittleEndian2Int", $target_raw, $data, 8, array('version' => 4, 'tagsize' => 4, 'tag_items' => 4, 'global_flags' => 4));
$target_raw['reserved'] = substr($data, 24, 8);
$target['tag_version'] = $target_raw['version'] / 1000;
if ($target['tag_version'] >= 2) {
$target['flags'] = $this->ParseAPEtagFlags($target_raw['global_flags']);
}
return true;
}
示例7: ZIPparseEndOfCentralDirectory
private function ZIPparseEndOfCentralDirectory()
{
// shortcut
$getid3 = $this->getid3;
$end_of_central_directory['offset'] = ftell($getid3->fp);
$zip_end_of_central_directory = fread($getid3->fp, 22);
$end_of_central_directory['signature'] = getid3_lib::LittleEndian2Int(substr($zip_end_of_central_directory, 0, 4));
// invalid End Of Central Directory Signature
if ($end_of_central_directory['signature'] != 0x6054b50) {
fseek($getid3->fp, $end_of_central_directory['offset'], SEEK_SET);
// seek back to where filepointer originally was so it can be handled properly
return false;
}
getid3_lib::ReadSequence('LittleEndian2Int', $end_of_central_directory, $zip_end_of_central_directory, 4, array('disk_number_current' => 2, 'disk_number_start_directory' => 2, 'directory_entries_this_disk' => 2, 'directory_entries_total' => 2, 'directory_size' => 4, 'directory_offset' => 4, 'comment_length' => 2));
if ($end_of_central_directory['comment_length'] > 0) {
$end_of_central_directory['comment'] = fread($getid3->fp, $end_of_central_directory['comment_length']);
}
return $end_of_central_directory;
}
示例8: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
$original_av_data_offset = $getid3->info['avdataoffset'];
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$voc_header = fread($getid3->fp, 26);
// Magic bytes: 'Creative Voice File'
$info_audio =& $getid3->info['audio'];
$getid3->info['voc'] = array();
$info_voc =& $getid3->info['voc'];
$getid3->info['fileformat'] = 'voc';
$info_audio['dataformat'] = 'voc';
$info_audio['bitrate_mode'] = 'cbr';
$info_audio['lossless'] = true;
$info_audio['channels'] = 1;
// might be overriden below
$info_audio['bits_per_sample'] = 8;
// might be overriden below
// byte # Description
// ------ ------------------------------------------
// 00-12 'Creative Voice File'
// 13 1A (eof to abort printing of file)
// 14-15 Offset of first datablock in .voc file (std 1A 00 in Intel Notation)
// 16-17 Version number (minor,major) (VOC-HDR puts 0A 01)
// 18-19 2's Comp of Ver. # + 1234h (VOC-HDR puts 29 11)
getid3_lib::ReadSequence('LittleEndian2Int', $info_voc['header'], $voc_header, 20, array('datablock_offset' => 2, 'minor_version' => 1, 'major_version' => 1));
do {
$block_offset = ftell($getid3->fp);
$block_data = fread($getid3->fp, 4);
$block_type = ord($block_data[0]);
$block_size = getid3_lib::LittleEndian2Int(substr($block_data, 1, 3));
$this_block = array();
@$info_voc['blocktypes'][$block_type]++;
switch ($block_type) {
case 0:
// Terminator
// do nothing, we'll break out of the loop down below
break;
case 1:
// Sound data
$block_data .= fread($getid3->fp, 2);
if ($getid3->info['avdataoffset'] <= $original_av_data_offset) {
$getid3->info['avdataoffset'] = ftell($getid3->fp);
}
fseek($getid3->fp, $block_size - 2, SEEK_CUR);
getid3_lib::ReadSequence('LittleEndian2Int', $this_block, $block_data, 4, array('sample_rate_id' => 1, 'compression_type' => 1));
$this_block['compression_name'] = getid3_voc::VOCcompressionTypeLookup($this_block['compression_type']);
if ($this_block['compression_type'] <= 3) {
$info_voc['compressed_bits_per_sample'] = (int) str_replace('-bit', '', $this_block['compression_name']);
}
// Less accurate sample_rate calculation than the Extended block (#8) data (but better than nothing if Extended Block is not available)
if (empty($info_audio['sample_rate'])) {
// SR byte = 256 - (1000000 / sample_rate)
$info_audio['sample_rate'] = (int) floor(1000000 / (256 - $this_block['sample_rate_id']) / $info_audio['channels']);
}
break;
case 2:
// Sound continue
// Sound continue
case 3:
// Silence
// Silence
case 4:
// Marker
// Marker
case 6:
// Repeat
// Repeat
case 7:
// End repeat
// nothing useful, just skip
fseek($getid3->fp, $block_size, SEEK_CUR);
break;
case 8:
// Extended
$block_data .= fread($getid3->fp, 4);
//00-01 Time Constant:
// Mono: 65536 - (256000000 / sample_rate)
// Stereo: 65536 - (256000000 / (sample_rate * 2))
getid3_lib::ReadSequence('LittleEndian2Int', $this_block, $block_data, 4, array('time_constant' => 2, 'pack_method' => 1, 'stereo' => 1));
$this_block['stereo'] = (bool) $this_block['stereo'];
$info_audio['channels'] = $this_block['stereo'] ? 2 : 1;
$info_audio['sample_rate'] = (int) floor(256000000 / (65536 - $this_block['time_constant']) / $info_audio['channels']);
break;
case 9:
// data block that supersedes blocks 1 and 8. Used for stereo, 16 bit
$block_data .= fread($getid3->fp, 12);
if ($getid3->info['avdataoffset'] <= $original_av_data_offset) {
$getid3->info['avdataoffset'] = ftell($getid3->fp);
}
fseek($getid3->fp, $block_size - 12, SEEK_CUR);
getid3_lib::ReadSequence('LittleEndian2Int', $this_block, $block_data, 4, array('sample_rate' => 4, 'bits_per_sample' => 1, 'channels' => 1, 'wFormat' => 2));
$this_block['compression_name'] = getid3_voc::VOCwFormatLookup($this_block['wFormat']);
if (getid3_voc::VOCwFormatActualBitsPerSampleLookup($this_block['wFormat'])) {
$info_voc['compressed_bits_per_sample'] = getid3_voc::VOCwFormatActualBitsPerSampleLookup($this_block['wFormat']);
}
$info_audio['sample_rate'] = $this_block['sample_rate'];
$info_audio['bits_per_sample'] = $this_block['bits_per_sample'];
$info_audio['channels'] = $this_block['channels'];
break;
//.........這裏部分代碼省略.........
示例9: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
// based loosely on code from TTwinVQ by Jurgen Faul <jfaulØgmx*de>
// http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
$getid3->info['fileformat'] = 'vqf';
$getid3->info['audio']['dataformat'] = 'vqf';
$getid3->info['audio']['bitrate_mode'] = 'cbr';
$getid3->info['audio']['lossless'] = false;
// Shortcuts
$getid3->info['vqf']['raw'] = array();
$info_vqf =& $getid3->info['vqf'];
$info_vqf_raw =& $info_vqf['raw'];
// Get header
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$vqf_header_data = fread($getid3->fp, 16);
$info_vqf_raw['header_tag'] = 'TWIN';
// Magic bytes
$info_vqf_raw['version'] = substr($vqf_header_data, 4, 8);
$info_vqf_raw['size'] = getid3_lib::BigEndian2Int(substr($vqf_header_data, 12, 4));
while (ftell($getid3->fp) < $getid3->info['avdataend']) {
$chunk_base_offset = ftell($getid3->fp);
$chunk_data = fread($getid3->fp, 8);
$chunk_name = substr($chunk_data, 0, 4);
if ($chunk_name == 'DATA') {
$getid3->info['avdataoffset'] = $chunk_base_offset;
break;
}
$chunk_size = getid3_lib::BigEndian2Int(substr($chunk_data, 4, 4));
if ($chunk_size > $getid3->info['avdataend'] - ftell($getid3->fp)) {
throw new getid3_exception('Invalid chunk size (' . $chunk_size . ') for chunk "' . $chunk_name . '" at offset 8.');
}
if ($chunk_size > 0) {
$chunk_data .= fread($getid3->fp, $chunk_size);
}
switch ($chunk_name) {
case 'COMM':
$info_vqf['COMM'] = array();
getid3_lib::ReadSequence('BigEndian2Int', $info_vqf['COMM'], $chunk_data, 8, array('channel_mode' => 4, 'bitrate' => 4, 'sample_rate' => 4, 'security_level' => 4));
$getid3->info['audio']['channels'] = $info_vqf['COMM']['channel_mode'] + 1;
$getid3->info['audio']['sample_rate'] = getid3_vqf::VQFchannelFrequencyLookup($info_vqf['COMM']['sample_rate']);
$getid3->info['audio']['bitrate'] = $info_vqf['COMM']['bitrate'] * 1000;
$getid3->info['audio']['encoder_options'] = 'CBR' . ceil($getid3->info['audio']['bitrate'] / 1000);
if ($getid3->info['audio']['bitrate'] == 0) {
throw new getid3_exception('Corrupt VQF file: bitrate_audio == zero');
}
break;
case 'NAME':
case 'AUTH':
case '(c) ':
case 'FILE':
case 'COMT':
case 'ALBM':
$info_vqf['comments'][getid3_vqf::VQFcommentNiceNameLookup($chunk_name)][] = trim(substr($chunk_data, 8));
break;
case 'DSIZ':
$info_vqf['DSIZ'] = getid3_lib::BigEndian2Int(substr($chunk_data, 8, 4));
break;
default:
$getid3->warning('Unhandled chunk type "' . $chunk_name . '" at offset 8');
break;
}
}
$getid3->info['playtime_seconds'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8 / $getid3->info['audio']['bitrate'];
if (isset($info_vqf['DSIZ']) && $info_vqf['DSIZ'] != $getid3->info['avdataend'] - $getid3->info['avdataoffset'] - strlen('DATA')) {
switch ($info_vqf['DSIZ']) {
case 0:
case 1:
$getid3->warning('Invalid DSIZ value "' . $info_vqf['DSIZ'] . '". This is known to happen with VQF files encoded by Ahead Nero, and seems to be its way of saying this is TwinVQF v' . ($info_vqf['DSIZ'] + 1) . '.0');
$getid3->info['audio']['encoder'] = 'Ahead Nero';
break;
default:
$getid3->warning('Probable corrupted file - should be ' . $info_vqf['DSIZ'] . ' bytes, actually ' . ($getid3->info['avdataend'] - $getid3->info['avdataoffset'] - strlen('DATA')));
break;
}
}
return true;
}
示例10: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
$getid3->include_module('audio-video.riff');
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$raw_data = fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
$getid3->info['fileformat'] = 'la';
$getid3->info['audio']['dataformat'] = 'la';
$getid3->info['audio']['lossless'] = true;
$getid3->info['la']['version_major'] = (int) $raw_data[2];
$getid3->info['la']['version_minor'] = (int) $raw_data[3];
$getid3->info['la']['version'] = (double) $getid3->info['la']['version_major'] + $getid3->info['la']['version_minor'] / 10;
$getid3->info['la']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($raw_data, 4, 4));
$wave_chunk = substr($raw_data, 8, 4);
if ($wave_chunk !== 'WAVE') {
throw new getid3_exception('Expected "WAVE" (' . getid3_lib::PrintHexBytes('WAVE') . ') at offset 8, found "' . $wave_chunk . '" (' . getid3_lib::PrintHexBytes($wave_chunk) . ') instead.');
}
$offset = 12;
$getid3->info['la']['fmt_size'] = 24;
if ($getid3->info['la']['version'] >= 0.3) {
$getid3->info['la']['fmt_size'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
$getid3->info['la']['header_size'] = 49 + $getid3->info['la']['fmt_size'] - 24;
$offset += 4;
} else {
// version 0.2 didn't support additional data blocks
$getid3->info['la']['header_size'] = 41;
}
$fmt_chunk = substr($raw_data, $offset, 4);
if ($fmt_chunk !== 'fmt ') {
throw new getid3_exception('Expected "fmt " (' . getid3_lib::PrintHexBytes('fmt ') . ') at offset ' . $offset . ', found "' . $fmt_chunk . '" (' . getid3_lib::PrintHexBytes($fmt_chunk) . ') instead.');
}
$offset += 4;
$fmt_size = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
$offset += 4;
$getid3->info['la']['raw']['format'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 2));
$offset += 2;
getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['la'], $raw_data, $offset, array('channels' => 2, 'sample_rate' => 4, 'bytes_per_second' => 4, 'bytes_per_sample' => 2, 'bits_per_sample' => 2, 'samples' => 4));
$offset += 18;
$getid3->info['la']['raw']['flags'] = getid3_lib::LittleEndian2Int($raw_data[$offset++]);
$getid3->info['la']['flags']['seekable'] = (bool) ($getid3->info['la']['raw']['flags'] & 0x1);
if ($getid3->info['la']['version'] >= 0.4) {
$getid3->info['la']['flags']['high_compression'] = (bool) ($getid3->info['la']['raw']['flags'] & 0x2);
}
$getid3->info['la']['original_crc'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
$offset += 4;
// mikeØbevin*de
// Basically, the blocksize/seekevery are 61440/19 in La0.4 and 73728/16
// in earlier versions. A seekpoint is added every blocksize * seekevery
// samples, so 4 * int(totalSamples / (blockSize * seekEvery)) should
// give the number of bytes used for the seekpoints. Of course, if seeking
// is disabled, there are no seekpoints stored.
if ($getid3->info['la']['version'] >= 0.4) {
$getid3->info['la']['blocksize'] = 61440;
$getid3->info['la']['seekevery'] = 19;
} else {
$getid3->info['la']['blocksize'] = 73728;
$getid3->info['la']['seekevery'] = 16;
}
$getid3->info['la']['seekpoint_count'] = 0;
if ($getid3->info['la']['flags']['seekable']) {
$getid3->info['la']['seekpoint_count'] = floor($getid3->info['la']['samples'] / ($getid3->info['la']['blocksize'] * $getid3->info['la']['seekevery']));
for ($i = 0; $i < $getid3->info['la']['seekpoint_count']; $i++) {
$getid3->info['la']['seekpoints'][] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
$offset += 4;
}
}
if ($getid3->info['la']['version'] >= 0.3) {
// Following the main header information, the program outputs all of the
// seekpoints. Following these is what I called the 'footer start',
// i.e. the position immediately after the La audio data is finished.
$getid3->info['la']['footerstart'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
$offset += 4;
if ($getid3->info['la']['footerstart'] > $getid3->info['filesize']) {
$getid3->warning('FooterStart value points to offset ' . $getid3->info['la']['footerstart'] . ' which is beyond end-of-file (' . $getid3->info['filesize'] . ')');
$getid3->info['la']['footerstart'] = $getid3->info['filesize'];
}
} else {
// La v0.2 didn't have FooterStart value
$getid3->info['la']['footerstart'] = $getid3->info['avdataend'];
}
if ($getid3->info['la']['footerstart'] < $getid3->info['avdataend']) {
// Create riff header
$riff_data = 'WAVE';
if ($getid3->info['la']['version'] == 0.2) {
$riff_data .= substr($raw_data, 12, 24);
} else {
$riff_data .= substr($raw_data, 16, 24);
}
if ($getid3->info['la']['footerstart'] < $getid3->info['avdataend']) {
fseek($getid3->fp, $getid3->info['la']['footerstart'], SEEK_SET);
$riff_data .= fread($getid3->fp, $getid3->info['avdataend'] - $getid3->info['la']['footerstart']);
}
$riff_data = 'RIFF' . getid3_lib::LittleEndian2String(strlen($riff_data), 4, false) . $riff_data;
// Clone getid3 - messing with offsets - better safe than sorry
$clone = clone $getid3;
// Analyze clone by string
$riff = new getid3_riff($clone);
$riff->AnalyzeString($riff_data);
// Import from clone and destroy
$getid3->info['riff'] = $clone->info['riff'];
//.........這裏部分代碼省略.........
示例11: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
// BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
// all versions
// WORD bfType;
// DWORD bfSize;
// WORD bfReserved1;
// WORD bfReserved2;
// DWORD bfOffBits;
// shortcuts
$getid3->info['bmp']['header']['raw'] = array();
$info_bmp =& $getid3->info['bmp'];
$info_bmp_header =& $info_bmp['header'];
$info_bmp_header_raw =& $info_bmp_header['raw'];
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$bmp_header = fread($getid3->fp, 14 + 40);
// Magic bytes
$info_bmp_header_raw['identifier'] = 'BM';
getid3_lib::ReadSequence('LittleEndian2Int', $info_bmp_header_raw, $bmp_header, 2, array('filesize' => 4, 'reserved1' => 2, 'reserved2' => 2, 'data_offset' => 4, 'header_size' => 4));
// Check if the hardcoded-to-1 "planes" is at offset 22 or 26
$planes22 = getid3_lib::LittleEndian2Int(substr($bmp_header, 22, 2));
$planes26 = getid3_lib::LittleEndian2Int(substr($bmp_header, 26, 2));
if ($planes22 == 1 && $planes26 != 1) {
$info_bmp['type_os'] = 'OS/2';
$info_bmp['type_version'] = 1;
} elseif ($planes26 == 1 && $planes22 != 1) {
$info_bmp['type_os'] = 'Windows';
$info_bmp['type_version'] = 1;
} elseif ($info_bmp_header_raw['header_size'] == 12) {
$info_bmp['type_os'] = 'OS/2';
$info_bmp['type_version'] = 1;
} elseif ($info_bmp_header_raw['header_size'] == 40) {
$info_bmp['type_os'] = 'Windows';
$info_bmp['type_version'] = 1;
} elseif ($info_bmp_header_raw['header_size'] == 84) {
$info_bmp['type_os'] = 'Windows';
$info_bmp['type_version'] = 4;
} elseif ($info_bmp_header_raw['header_size'] == 100) {
$info_bmp['type_os'] = 'Windows';
$info_bmp['type_version'] = 5;
} else {
throw new getid3_exception('Unknown BMP subtype (or not a BMP file)');
}
$getid3->info['fileformat'] = 'bmp';
$getid3->info['video']['dataformat'] = 'bmp';
$getid3->info['video']['lossless'] = true;
$getid3->info['video']['pixel_aspect_ratio'] = (double) 1;
if ($info_bmp['type_os'] == 'OS/2') {
// OS/2-format BMP
// http://netghost.narod.ru/gff/graphics/summary/os2bmp.htm
// DWORD Size; /* Size of this structure in bytes */
// DWORD Width; /* Bitmap width in pixels */
// DWORD Height; /* Bitmap height in pixel */
// WORD NumPlanes; /* Number of bit planes (color depth) */
// WORD BitsPerPixel; /* Number of bits per pixel per plane */
getid3_lib::ReadSequence('LittleEndian2Int', $info_bmp_header_raw, $bmp_header, 18, array('width' => 2, 'height' => 2, 'planes' => 2, 'bits_per_pixel' => 2));
$getid3->info['video']['resolution_x'] = $info_bmp_header_raw['width'];
$getid3->info['video']['resolution_y'] = $info_bmp_header_raw['height'];
$getid3->info['video']['codec'] = 'BI_RGB ' . $info_bmp_header_raw['bits_per_pixel'] . '-bit';
$getid3->info['video']['bits_per_sample'] = $info_bmp_header_raw['bits_per_pixel'];
if ($info_bmp['type_version'] >= 2) {
// DWORD Compression; /* Bitmap compression scheme */
// DWORD ImageDataSize; /* Size of bitmap data in bytes */
// DWORD XResolution; /* X resolution of display device */
// DWORD YResolution; /* Y resolution of display device */
// DWORD ColorsUsed; /* Number of color table indices used */
// DWORD ColorsImportant; /* Number of important color indices */
// WORD Units; /* Type of units used to measure resolution */
// WORD Reserved; /* Pad structure to 4-byte boundary */
// WORD Recording; /* Recording algorithm */
// WORD Rendering; /* Halftoning algorithm used */
// DWORD Size1; /* Reserved for halftoning algorithm use */
// DWORD Size2; /* Reserved for halftoning algorithm use */
// DWORD ColorEncoding; /* Color model used in bitmap */
// DWORD Identifier; /* Reserved for application use */
getid3_lib::ReadSequence('LittleEndian2Int', $info_bmp_header_raw, $bmp_header, 26, array('compression' => 4, 'bmp_data_size' => 4, 'resolution_h' => 4, 'resolution_v' => 4, 'colors_used' => 4, 'colors_important' => 4, 'resolution_units' => 2, 'reserved1' => 2, 'recording' => 2, 'rendering' => 2, 'size1' => 4, 'size2' => 4, 'color_encoding' => 4, 'identifier' => 4));
$info_bmp_header['compression'] = getid3_bmp::BMPcompressionOS2Lookup($info_bmp_header_raw['compression']);
$getid3->info['video']['codec'] = $info_bmp_header['compression'] . ' ' . $info_bmp_header_raw['bits_per_pixel'] . '-bit';
}
return true;
}
if ($info_bmp['type_os'] == 'Windows') {
// Windows-format BMP
// BITMAPINFOHEADER - [40 bytes] http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp
// all versions
// DWORD biSize;
// LONG biWidth;
// LONG biHeight;
// WORD biPlanes;
// WORD biBitCount;
// DWORD biCompression;
// DWORD biSizeImage;
// LONG biXPelsPerMeter;
// LONG biYPelsPerMeter;
// DWORD biClrUsed;
// DWORD biClrImportant;
getid3_lib::ReadSequence('LittleEndian2Int', $info_bmp_header_raw, $bmp_header, 18, array('width' => -4, 'height' => -4, 'planes' => 2, 'bits_per_pixel' => 2, 'compression' => 4, 'bmp_data_size' => 4, 'resolution_h' => -4, 'resolution_v' => -4, 'colors_used' => 4, 'colors_important' => 4));
foreach (array('width', 'height', 'resolution_h', 'resolution_v') as $key) {
$info_bmp_header_raw[$key] = getid3_lib::LittleEndian2Int($info_bmp_header_raw[$key], true);
//.........這裏部分代碼省略.........
示例12: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
$getid3->info['png'] = array();
$info_png =& $getid3->info['png'];
$getid3->info['fileformat'] = 'png';
$getid3->info['video']['dataformat'] = 'png';
$getid3->info['video']['lossless'] = false;
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$png_filedata = fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
// Magic bytes "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A"
$offset = 8;
while (ftell($getid3->fp) - (strlen($png_filedata) - $offset) < $getid3->info['filesize']) {
$chunk['data_length'] = getid3_lib::BigEndian2Int(substr($png_filedata, $offset, 4));
$offset += 4;
while (strlen($png_filedata) - $offset < $chunk['data_length'] + 4 && ftell($getid3->fp) < $getid3->info['filesize']) {
$png_filedata .= fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
}
$chunk['type_text'] = substr($png_filedata, $offset, 4);
$chunk['type_raw'] = getid3_lib::BigEndian2Int($chunk['type_text']);
$offset += 4;
$chunk['data'] = substr($png_filedata, $offset, $chunk['data_length']);
$offset += $chunk['data_length'];
$chunk['crc'] = getid3_lib::BigEndian2Int(substr($png_filedata, $offset, 4));
$offset += 4;
$chunk['flags']['ancilliary'] = (bool) ($chunk['type_raw'] & 0x20000000);
$chunk['flags']['private'] = (bool) ($chunk['type_raw'] & 0x200000);
$chunk['flags']['reserved'] = (bool) ($chunk['type_raw'] & 0x2000);
$chunk['flags']['safe_to_copy'] = (bool) ($chunk['type_raw'] & 0x20);
// shortcut
$info_png[$chunk['type_text']] = array();
$info_png_chunk_type_text =& $info_png[$chunk['type_text']];
switch ($chunk['type_text']) {
case 'IHDR':
// Image Header
$info_png_chunk_type_text['header'] = $chunk;
$info_png_chunk_type_text['width'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 4));
$info_png_chunk_type_text['height'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 4, 4));
getid3_lib::ReadSequence('BigEndian2Int', $info_png_chunk_type_text['raw'], $chunk['data'], 8, array('bit_depth' => 1, 'color_type' => 1, 'compression_method' => 1, 'filter_method' => 1, 'interlace_method' => 1));
$info_png_chunk_type_text['compression_method_text'] = getid3_png::PNGcompressionMethodLookup($info_png_chunk_type_text['raw']['compression_method']);
$info_png_chunk_type_text['color_type']['palette'] = (bool) ($info_png_chunk_type_text['raw']['color_type'] & 0x1);
$info_png_chunk_type_text['color_type']['true_color'] = (bool) ($info_png_chunk_type_text['raw']['color_type'] & 0x2);
$info_png_chunk_type_text['color_type']['alpha'] = (bool) ($info_png_chunk_type_text['raw']['color_type'] & 0x4);
$getid3->info['video']['resolution_x'] = $info_png_chunk_type_text['width'];
$getid3->info['video']['resolution_y'] = $info_png_chunk_type_text['height'];
$getid3->info['video']['bits_per_sample'] = getid3_png::IHDRcalculateBitsPerSample($info_png_chunk_type_text['raw']['color_type'], $info_png_chunk_type_text['raw']['bit_depth']);
break;
case 'PLTE':
// Palette
$info_png_chunk_type_text['header'] = $chunk;
$palette_offset = 0;
for ($i = 0; $i <= 255; $i++) {
$red = @getid3_lib::BigEndian2Int($chunk['data'][$palette_offset++]);
$green = @getid3_lib::BigEndian2Int($chunk['data'][$palette_offset++]);
$blue = @getid3_lib::BigEndian2Int($chunk['data'][$palette_offset++]);
$info_png_chunk_type_text[$i] = $red << 16 | $green << 8 | $blue;
}
break;
case 'tRNS':
// Transparency
$info_png_chunk_type_text['header'] = $chunk;
switch ($info_png['IHDR']['raw']['color_type']) {
case 0:
$info_png_chunk_type_text['transparent_color_gray'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 2));
break;
case 2:
$info_png_chunk_type_text['transparent_color_red'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 2));
$info_png_chunk_type_text['transparent_color_green'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 2, 2));
$info_png_chunk_type_text['transparent_color_blue'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 4, 2));
break;
case 3:
for ($i = 0; $i < strlen($chunk['data']); $i++) {
$info_png_chunk_type_text['palette_opacity'][$i] = getid3_lib::BigEndian2Int($chunk['data'][$i]);
}
break;
case 4:
case 6:
throw new getid3_exception('Invalid color_type in tRNS chunk: ' . $info_png['IHDR']['raw']['color_type']);
default:
$getid3->warning('Unhandled color_type in tRNS chunk: ' . $info_png['IHDR']['raw']['color_type']);
break;
}
break;
case 'gAMA':
// Image Gamma
$info_png_chunk_type_text['header'] = $chunk;
$info_png_chunk_type_text['gamma'] = getid3_lib::BigEndian2Int($chunk['data']) / 100000;
break;
case 'cHRM':
// Primary Chromaticities
$info_png_chunk_type_text['header'] = $chunk;
$info_png_chunk_type_text['white_x'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 4)) / 100000;
$info_png_chunk_type_text['white_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 4, 4)) / 100000;
$info_png_chunk_type_text['red_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 8, 4)) / 100000;
$info_png_chunk_type_text['red_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 12, 4)) / 100000;
$info_png_chunk_type_text['green_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 16, 4)) / 100000;
$info_png_chunk_type_text['green_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 20, 4)) / 100000;
$info_png_chunk_type_text['blue_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 24, 4)) / 100000;
$info_png_chunk_type_text['blue_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 28, 4)) / 100000;
break;
//.........這裏部分代碼省略.........
示例13: HandleBonkTags
private function HandleBonkTags(&$bonk_tag_name)
{
// Shortcut to getid3 pointer
$getid3 = $this->getid3;
$info_audio =& $getid3->info['audio'];
switch ($bonk_tag_name) {
case 'BONK':
// shortcut
$info_bonk_BONK =& $getid3->info['bonk']['BONK'];
$bonk_data = "" . 'BONK' . fread($getid3->fp, 17);
getid3_lib::ReadSequence('LittleEndian2Int', $info_bonk_BONK, $bonk_data, 5, array('version' => 1, 'number_samples' => 4, 'sample_rate' => 4, 'channels' => 1, 'lossless' => 1, 'joint_stereo' => 1, 'number_taps' => 2, 'downsampling_ratio' => 1, 'samples_per_packet' => 2));
$info_bonk_BONK['lossless'] = (bool) $info_bonk_BONK['lossless'];
$info_bonk_BONK['joint_stereo'] = (bool) $info_bonk_BONK['joint_stereo'];
$getid3->info['avdataoffset'] = $info_bonk_BONK['offset'] + 5 + 17;
$getid3->info['avdataend'] = $info_bonk_BONK['offset'] + $info_bonk_BONK['size'];
$getid3->info['fileformat'] = 'bonk';
$info_audio['dataformat'] = 'bonk';
$info_audio['bitrate_mode'] = 'vbr';
// assumed
$info_audio['channels'] = $info_bonk_BONK['channels'];
$info_audio['sample_rate'] = $info_bonk_BONK['sample_rate'];
$info_audio['channelmode'] = $info_bonk_BONK['joint_stereo'] ? 'joint stereo' : 'stereo';
$info_audio['lossless'] = $info_bonk_BONK['lossless'];
$info_audio['codec'] = 'bonk';
$getid3->info['playtime_seconds'] = $info_bonk_BONK['number_samples'] / ($info_bonk_BONK['sample_rate'] * $info_bonk_BONK['channels']);
if ($getid3->info['playtime_seconds'] > 0) {
$info_audio['bitrate'] = ($getid3->info['bonk']['dataend'] - $getid3->info['bonk']['dataoffset']) * 8 / $getid3->info['playtime_seconds'];
}
break;
case 'INFO':
// shortcut
$info_bonk_INFO =& $getid3->info['bonk']['INFO'];
$info_bonk_INFO['version'] = getid3_lib::LittleEndian2Int(fread($getid3->fp, 1));
$info_bonk_INFO['entries_count'] = 0;
$next_info_data_pair = fread($getid3->fp, 5);
if (!getid3_bonk::BonkIsValidTagName(substr($next_info_data_pair, 1, 4))) {
while (!feof($getid3->fp)) {
$next_info_data_pair = fread($getid3->fp, 5);
if (getid3_bonk::BonkIsValidTagName(substr($next_info_data_pair, 1, 4))) {
fseek($getid3->fp, -5, SEEK_CUR);
break;
}
$info_bonk_INFO['entries_count']++;
}
}
break;
case 'META':
$bonk_data = "" . 'META' . fread($getid3->fp, $getid3->info['bonk']['META']['size'] - 5);
$getid3->info['bonk']['META']['version'] = getid3_lib::LittleEndian2Int(substr($bonk_data, 5, 1));
$meta_tag_entries = floor((strlen($bonk_data) - 8 - 6) / 8);
// BonkData - xxxxmeta - ØMETA
$offset = 6;
for ($i = 0; $i < $meta_tag_entries; $i++) {
$meta_entry_tag_name = substr($bonk_data, $offset, 4);
$offset += 4;
$meta_entry_tag_offset = getid3_lib::LittleEndian2Int(substr($bonk_data, $offset, 4));
$offset += 4;
$getid3->info['bonk']['META']['tags'][$meta_entry_tag_name] = $meta_entry_tag_offset;
}
break;
case ' ID3':
$info_audio['encoder'] = 'Extended BONK v0.9+';
// ID3v2 checking is optional
if (class_exists('getid3_id3v2')) {
$id3v2 = new getid3_id3v2($getid3);
$id3v2->option_starting_offset = $getid3->info['bonk'][' ID3']['offset'] + 2;
$getid3->info['bonk'][' ID3']['valid'] = $id3v2->Analyze();
}
break;
default:
$getid3->warning('Unexpected Bonk tag "' . $bonk_tag_name . '" at offset ' . $getid3->info['bonk'][$bonk_tag_name]['offset']);
break;
}
}
示例14: QuicktimeParseAtom
//.........這裏部分代碼省略.........
//
//
case 'MCPS':
// Media Cleaner PRo
// Media Cleaner PRo
case '@PRM':
// adobe PReMiere version
// adobe PReMiere version
case '@PRQ':
// adobe PRemiere Quicktime version
$atom_structure['data'] = $atom_data;
break;
case 'cmvd':
// Compressed MooV Data atom
// Code by ubergeekØubergeek*tv based on information from
// http://developer.apple.com/quicktime/icefloe/dispatch012.html
$atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
$compressed_file_data = substr($atom_data, 4);
if (!function_exists('gzuncompress')) {
$getid3->warning('PHP does not have zlib support - cannot decompress MOV atom at offset ' . $atom_structure['offset']);
} elseif ($uncompressed_header = @gzuncompress($compressed_file_data)) {
$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($uncompressed_header, 0, $atom_hierarchy);
} else {
$getid3->warning('Error decompressing compressed MOV atom at offset ' . $atom_structure['offset']);
}
break;
case 'dcom':
// Data COMpression atom
$atom_structure['compression_id'] = $atom_data;
$atom_structure['compression_text'] = getid3_quicktime::QuicktimeDCOMLookup($atom_data);
break;
case 'rdrf':
// Reference movie Data ReFerence atom
getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, array('version' => 1, 'flags_raw' => 3, 'reference_type_name' => -4, 'reference_length' => 4));
$atom_structure['flags']['internal_data'] = (bool) ($atom_structure['flags_raw'] & 0x1);
switch ($atom_structure['reference_type_name']) {
case 'url ':
$atom_structure['url'] = $this->NoNullString(substr($atom_data, 12));
break;
case 'alis':
$atom_structure['file_alias'] = substr($atom_data, 12);
break;
case 'rsrc':
$atom_structure['resource_alias'] = substr($atom_data, 12);
break;
default:
$atom_structure['data'] = substr($atom_data, 12);
break;
}
break;
case 'rmqu':
// Reference Movie QUality atom
$atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data);
break;
case 'rmcs':
// Reference Movie Cpu Speed atom
getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, array('version' => 1, 'flags_raw' => 3, 'cpu_speed_rating' => 2));
break;
case 'rmvc':
// Reference Movie Version Check atom
getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, array('version' => 1, 'flags_raw' => 3, 'gestalt_selector' => -4, 'gestalt_value_mask' => 4, 'gestalt_value' => 4, 'gestalt_check_type' => 2));
break;
case 'rmcd':
// Reference Movie Component check atom
getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, array('version' => 1, 'flags_raw' => 3, 'component_type' => -4, 'component_subtype' => -4, 'component_manufacturer' => -4, 'component_flags_raw' => 4, 'component_flags_mask' => 4, 'component_min_version' => 4));
break;
示例15: ParseDirectoryRecord
private function ParseDirectoryRecord($directory_data)
{
$getid3 = $this->getid3;
$text_encoding = isset($getid3->info['iso']['supplementary_volume_descriptor']) ? 'UTF-16BE' : 'ISO-8859-1';
fseek($getid3->fp, $directory_data['location_bytes'], SEEK_SET);
$directory_record_data = fread($getid3->fp, 1);
while (ord($directory_record_data[0]) > 33) {
$directory_record_data .= fread($getid3->fp, ord($directory_record_data[0]) - 1);
$this_directory_record = array();
$this_directory_record['raw'] = array();
$this_directory_record_raw =& $this_directory_record['raw'];
getid3_lib::ReadSequence('LittleEndian2Int', $this_directory_record_raw, $directory_record_data, 0, array('length' => 1, 'extended_attribute_length' => 1, 'offset_logical' => 4, 'IGNORE-1' => 4, 'filesize' => 4, 'IGNORE-2' => 4, 'recording_date_time' => -7, 'file_flags' => 1, 'file_unit_size' => 1, 'interleave_gap_size' => 1, 'volume_sequence_number' => 2, 'IGNORE-3' => 2, 'file_identifier_length' => 1));
$this_directory_record_raw['file_identifier'] = substr($directory_record_data, 33, $this_directory_record_raw['file_identifier_length']);
$this_directory_record['file_identifier_ascii'] = $getid3->iconv($text_encoding, $getid3->encoding, $this_directory_record_raw['file_identifier'], true);
$this_directory_record['filesize'] = $this_directory_record_raw['filesize'];
$this_directory_record['offset_bytes'] = $this_directory_record_raw['offset_logical'] * 2048;
$this_directory_record['file_flags']['hidden'] = (bool) ($this_directory_record_raw['file_flags'] & 0x1);
$this_directory_record['file_flags']['directory'] = (bool) ($this_directory_record_raw['file_flags'] & 0x2);
$this_directory_record['file_flags']['associated'] = (bool) ($this_directory_record_raw['file_flags'] & 0x4);
$this_directory_record['file_flags']['extended'] = (bool) ($this_directory_record_raw['file_flags'] & 0x8);
$this_directory_record['file_flags']['permissions'] = (bool) ($this_directory_record_raw['file_flags'] & 0x10);
$this_directory_record['file_flags']['multiple'] = (bool) ($this_directory_record_raw['file_flags'] & 0x80);
$this_directory_record['recording_timestamp'] = getid3_iso::ISOtime2UNIXtime($this_directory_record_raw['recording_date_time']);
if ($this_directory_record['file_flags']['directory']) {
$this_directory_record['filename'] = $directory_data['full_path'];
} else {
$this_directory_record['filename'] = $directory_data['full_path'] . getid3_iso::ISOstripFilenameVersion($this_directory_record['file_identifier_ascii']);
$getid3->info['iso']['files'] = getid3_iso::array_merge_clobber($getid3->info['iso']['files'], getid3_iso::CreateDeepArray($this_directory_record['filename'], '/', $this_directory_record['filesize']));
}
$directory_record[] = $this_directory_record;
$directory_record_data = fread($getid3->fp, 1);
}
return $directory_record;
}