本文整理匯總了PHP中getid3_lib::array_merge_noclobber方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::array_merge_noclobber方法的具體用法?PHP getid3_lib::array_merge_noclobber怎麽用?PHP getid3_lib::array_merge_noclobber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類getid3_lib
的用法示例。
在下文中一共展示了getid3_lib::array_merge_noclobber方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getid3_asf
//.........這裏部分代碼省略.........
// stream number isn't known until halfway through decoding the structure, hence it
// it is decoded to a temporary variable and then stuck in the appropriate index later
$StreamPropertiesObjectData['objectid'] = $NextObjectGUID;
$StreamPropertiesObjectData['objectid_guid'] = $NextObjectGUIDtext;
$StreamPropertiesObjectData['objectsize'] = $NextObjectSize;
$StreamPropertiesObjectData['stream_type'] = substr($ASFHeaderData, $offset, 16);
$offset += 16;
$StreamPropertiesObjectData['stream_type_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['stream_type']);
$StreamPropertiesObjectData['error_correct_type'] = substr($ASFHeaderData, $offset, 16);
$offset += 16;
$StreamPropertiesObjectData['error_correct_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['error_correct_type']);
$StreamPropertiesObjectData['time_offset'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
$offset += 8;
$StreamPropertiesObjectData['type_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
$offset += 4;
$StreamPropertiesObjectData['error_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
$offset += 4;
$StreamPropertiesObjectData['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
$offset += 2;
$StreamPropertiesObjectStreamNumber = $StreamPropertiesObjectData['flags_raw'] & 0x7f;
$StreamPropertiesObjectData['flags']['encrypted'] = (bool) ($StreamPropertiesObjectData['flags_raw'] & 0x8000);
$offset += 4;
// reserved - DWORD
$StreamPropertiesObjectData['type_specific_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['type_data_length']);
$offset += $StreamPropertiesObjectData['type_data_length'];
$StreamPropertiesObjectData['error_correct_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['error_data_length']);
$offset += $StreamPropertiesObjectData['error_data_length'];
switch ($StreamPropertiesObjectData['stream_type']) {
case GETID3_ASF_Audio_Media:
$thisfile_audio['dataformat'] = !empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf';
$thisfile_audio['bitrate_mode'] = !empty($thisfile_audio['bitrate_mode']) ? $thisfile_audio['bitrate_mode'] : 'cbr';
$audiodata = getid3_riff::RIFFparseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16));
unset($audiodata['raw']);
$thisfile_audio = getid3_lib::array_merge_noclobber($audiodata, $thisfile_audio);
break;
case GETID3_ASF_Video_Media:
$thisfile_video['dataformat'] = !empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf';
$thisfile_video['bitrate_mode'] = !empty($thisfile_video['bitrate_mode']) ? $thisfile_video['bitrate_mode'] : 'cbr';
break;
case GETID3_ASF_Command_Media:
default:
// do nothing
break;
}
$thisfile_asf['stream_properties_object'][$StreamPropertiesObjectStreamNumber] = $StreamPropertiesObjectData;
unset($StreamPropertiesObjectData);
// clear for next stream, if any
break;
case GETID3_ASF_Header_Extension_Object:
// Header Extension Object: (mandatory, one only)
// Field Name Field Type Size (bits)
// Object ID GUID 128 // GUID for Header Extension object - GETID3_ASF_Header_Extension_Object
// Object Size QWORD 64 // size of Header Extension object, including 46 bytes of Header Extension Object header
// Reserved Field 1 GUID 128 // hardcoded: GETID3_ASF_Reserved_1
// Reserved Field 2 WORD 16 // hardcoded: 0x00000006
// Header Extension Data Size DWORD 32 // in bytes. valid: 0, or > 24. equals object size minus 46
// Header Extension Data BYTESTREAM variable // array of zero or more extended header objects
// shortcut
$thisfile_asf['header_extension_object'] = array();
$thisfile_asf_headerextensionobject =& $thisfile_asf['header_extension_object'];
$thisfile_asf_headerextensionobject['objectid'] = $NextObjectGUID;
$thisfile_asf_headerextensionobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_headerextensionobject['objectsize'] = $NextObjectSize;
$thisfile_asf_headerextensionobject['reserved_1'] = substr($ASFHeaderData, $offset, 16);
$offset += 16;
$thisfile_asf_headerextensionobject['reserved_1_guid'] = $this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']);
示例2: getid3_riff
function getid3_riff(&$fd, &$ThisFileInfo)
{
// initialize these values to an empty array, otherwise they default to NULL
// and you can't append array values to a NULL value
$ThisFileInfo['riff'] = array('raw' => array());
// Shortcuts
$thisfile_riff =& $ThisFileInfo['riff'];
$thisfile_riff_raw =& $thisfile_riff['raw'];
$thisfile_audio =& $ThisFileInfo['audio'];
$thisfile_video =& $ThisFileInfo['video'];
$thisfile_avdataoffset =& $ThisFileInfo['avdataoffset'];
$thisfile_avdataend =& $ThisFileInfo['avdataend'];
$thisfile_audio_dataformat =& $thisfile_audio['dataformat'];
$thisfile_riff_audio =& $thisfile_riff['audio'];
$thisfile_riff_video =& $thisfile_riff['video'];
$Original['avdataoffset'] = $thisfile_avdataoffset;
$Original['avdataend'] = $thisfile_avdataend;
fseek($fd, $thisfile_avdataoffset, SEEK_SET);
$RIFFheader = fread($fd, 12);
$RIFFsubtype = substr($RIFFheader, 8, 4);
switch (substr($RIFFheader, 0, 4)) {
case 'FORM':
$ThisFileInfo['fileformat'] = 'aiff';
$RIFFheaderSize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($RIFFheader, 4, 4));
$thisfile_riff[$RIFFsubtype] = getid3_riff::ParseRIFF($fd, $thisfile_avdataoffset + 12, $thisfile_avdataoffset + $RIFFheaderSize, $ThisFileInfo);
$thisfile_riff['header_size'] = $RIFFheaderSize;
break;
case 'RIFF':
case 'SDSS':
// SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
// SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
case 'RMP3':
// RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s
if ($RIFFsubtype == 'RMP3') {
// RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s
$RIFFsubtype = 'WAVE';
}
$ThisFileInfo['fileformat'] = 'riff';
$RIFFheaderSize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($RIFFheader, 4, 4));
$thisfile_riff[$RIFFsubtype] = getid3_riff::ParseRIFF($fd, $thisfile_avdataoffset + 12, $thisfile_avdataoffset + $RIFFheaderSize, $ThisFileInfo);
$thisfile_riff['header_size'] = $RIFFheaderSize;
if ($RIFFsubtype == 'WAVE') {
$thisfile_riff_WAVE =& $thisfile_riff['WAVE'];
}
break;
default:
$ThisFileInfo['error'][] = 'Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "' . $RIFFsubtype . '" instead';
unset($ThisFileInfo['fileformat']);
return false;
break;
}
$streamindex = 0;
switch ($RIFFsubtype) {
case 'WAVE':
if (empty($thisfile_audio['bitrate_mode'])) {
$thisfile_audio['bitrate_mode'] = 'cbr';
}
if (empty($thisfile_audio_dataformat)) {
$thisfile_audio_dataformat = 'wav';
}
if (isset($thisfile_riff_WAVE['data'][0]['offset'])) {
$thisfile_avdataoffset = $thisfile_riff_WAVE['data'][0]['offset'] + 8;
$thisfile_avdataend = $thisfile_avdataoffset + $thisfile_riff_WAVE['data'][0]['size'];
}
if (isset($thisfile_riff_WAVE['fmt '][0]['data'])) {
$thisfile_riff_audio[$streamindex] = getid3_riff::RIFFparseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']);
$thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
if (@$thisfile_riff_audio[$streamindex]['bitrate'] == 0) {
$ThisFileInfo['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';
return false;
}
$thisfile_riff_raw['fmt '] = $thisfile_riff_audio[$streamindex]['raw'];
unset($thisfile_riff_audio[$streamindex]['raw']);
$thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex];
$thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
if (substr($thisfile_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
$ThisFileInfo['warning'][] = 'Audio codec = ' . $thisfile_audio['codec'];
}
$thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
$ThisFileInfo['playtime_seconds'] = (double) (($thisfile_avdataend - $thisfile_avdataoffset) * 8 / $thisfile_audio['bitrate']);
$thisfile_audio['lossless'] = false;
if (isset($thisfile_riff_WAVE['data'][0]['offset']) && isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
case 0x1:
// PCM
$thisfile_audio['lossless'] = true;
break;
case 0x2000:
// AC-3
$thisfile_audio_dataformat = 'ac3';
break;
default:
// do nothing
break;
}
}
$thisfile_audio['streams'][$streamindex]['wformattag'] = $thisfile_audio['wformattag'];
$thisfile_audio['streams'][$streamindex]['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
$thisfile_audio['streams'][$streamindex]['lossless'] = $thisfile_audio['lossless'];
$thisfile_audio['streams'][$streamindex]['dataformat'] = $thisfile_audio_dataformat;
//.........這裏部分代碼省略.........
示例3: Analyze
//.........這裏部分代碼省略.........
$thisfile_riff_WAVE =& $thisfile_riff['WAVE'];
}
break;
default:
$this->error('Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "' . $RIFFsubtype . '" instead');
//unset($info['fileformat']);
return false;
}
$streamindex = 0;
switch ($RIFFsubtype) {
// http://en.wikipedia.org/wiki/Wav
case 'WAVE':
$info['fileformat'] = 'wav';
if (empty($thisfile_audio['bitrate_mode'])) {
$thisfile_audio['bitrate_mode'] = 'cbr';
}
if (empty($thisfile_audio_dataformat)) {
$thisfile_audio_dataformat = 'wav';
}
if (isset($thisfile_riff_WAVE['data'][0]['offset'])) {
$info['avdataoffset'] = $thisfile_riff_WAVE['data'][0]['offset'] + 8;
$info['avdataend'] = $info['avdataoffset'] + $thisfile_riff_WAVE['data'][0]['size'];
}
if (isset($thisfile_riff_WAVE['fmt '][0]['data'])) {
$thisfile_riff_audio[$streamindex] = self::parseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']);
$thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
if (!isset($thisfile_riff_audio[$streamindex]['bitrate']) || $thisfile_riff_audio[$streamindex]['bitrate'] == 0) {
$info['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';
return false;
}
$thisfile_riff_raw['fmt '] = $thisfile_riff_audio[$streamindex]['raw'];
unset($thisfile_riff_audio[$streamindex]['raw']);
$thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex];
$thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
if (substr($thisfile_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
$info['warning'][] = 'Audio codec = ' . $thisfile_audio['codec'];
}
$thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
if (empty($info['playtime_seconds'])) {
// may already be set (e.g. DTS-WAV)
$info['playtime_seconds'] = (double) (($info['avdataend'] - $info['avdataoffset']) * 8 / $thisfile_audio['bitrate']);
}
$thisfile_audio['lossless'] = false;
if (isset($thisfile_riff_WAVE['data'][0]['offset']) && isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
case 0x1:
// PCM
$thisfile_audio['lossless'] = true;
break;
case 0x2000:
// AC-3
$thisfile_audio_dataformat = 'ac3';
break;
default:
// do nothing
break;
}
}
$thisfile_audio['streams'][$streamindex]['wformattag'] = $thisfile_audio['wformattag'];
$thisfile_audio['streams'][$streamindex]['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
$thisfile_audio['streams'][$streamindex]['lossless'] = $thisfile_audio['lossless'];
$thisfile_audio['streams'][$streamindex]['dataformat'] = $thisfile_audio_dataformat;
}
if (isset($thisfile_riff_WAVE['rgad'][0]['data'])) {
// shortcuts
$rgadData =& $thisfile_riff_WAVE['rgad'][0]['data'];
示例4: array_merge_noclobber
static function array_merge_noclobber($array1, $array2)
{
if (!is_array($array1) || !is_array($array2)) {
return false;
}
$newarray = $array1;
foreach ($array2 as $key => $val) {
if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
$newarray[$key] = getid3_lib::array_merge_noclobber($newarray[$key], $val);
} elseif (!isset($newarray[$key])) {
$newarray[$key] = $val;
}
}
return $newarray;
}
示例5: getid3_id3v2
//.........這裏部分代碼省略.........
$parsedFrame['frame_name'] = $frame_name;
$parsedFrame['frame_flags_raw'] = $frame_flags;
$parsedFrame['data'] = substr($framedata, 0, $frame_size);
$parsedFrame['datalength'] = getid3_lib::CastAsInt($frame_size);
$parsedFrame['dataoffset'] = $framedataoffset;
$this->ParseID3v2Frame($parsedFrame, $ThisFileInfo);
$thisfile_id3v2[$frame_name][] = $parsedFrame;
$framedata = substr($framedata, $frame_size);
} else {
// invalid frame length or FrameID
if ($frame_size <= strlen($framedata)) {
if ($this->IsValidID3v2FrameName(substr($framedata, $frame_size, 4), $id3v2_majorversion)) {
// next frame is valid, just skip the current frame
$framedata = substr($framedata, $frame_size);
$ThisFileInfo['warning'][] = 'Next ID3v2 frame is valid, skipping current frame.';
} else {
// next frame is invalid too, abort processing
//unset($framedata);
$framedata = null;
$ThisFileInfo['error'][] = 'Next ID3v2 frame is also invalid, aborting processing.';
}
} elseif ($frame_size == strlen($framedata)) {
// this is the last frame, just skip
$ThisFileInfo['warning'][] = 'This was the last ID3v2 frame.';
} else {
// next frame is invalid too, abort processing
//unset($framedata);
$framedata = null;
$ThisFileInfo['warning'][] = 'Invalid ID3v2 frame size, aborting.';
}
if (!$this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion)) {
switch ($frame_name) {
case "" . 'MP':
case "" . 'MP3':
case ' MP3':
case 'MP3e':
case "" . 'MP':
case ' MP':
case 'MP3':
$ThisFileInfo['warning'][] = 'error parsing "' . $frame_name . '" (' . $framedataoffset . ' bytes into the ID3v2.' . $id3v2_majorversion . ' tag). (ERROR: !IsValidID3v2FrameName("' . str_replace("", ' ', $frame_name) . '", ' . $id3v2_majorversion . '))). [Note: this particular error has been known to happen with tags edited by "MP3ext (www.mutschler.de/mp3ext/)"]';
break;
default:
$ThisFileInfo['warning'][] = 'error parsing "' . $frame_name . '" (' . $framedataoffset . ' bytes into the ID3v2.' . $id3v2_majorversion . ' tag). (ERROR: !IsValidID3v2FrameName("' . str_replace("", ' ', $frame_name) . '", ' . $id3v2_majorversion . '))).';
break;
}
} elseif ($frame_size > strlen(@$framedata)) {
$ThisFileInfo['error'][] = 'error parsing "' . $frame_name . '" (' . $framedataoffset . ' bytes into the ID3v2.' . $id3v2_majorversion . ' tag). (ERROR: $frame_size (' . $frame_size . ') > strlen($framedata) (' . strlen($framedata) . ')).';
} else {
$ThisFileInfo['error'][] = 'error parsing "' . $frame_name . '" (' . $framedataoffset . ' bytes into the ID3v2.' . $id3v2_majorversion . ' tag).';
}
}
$framedataoffset += $frame_size + $this->ID3v2HeaderLength($id3v2_majorversion);
}
}
// Footer
// The footer is a copy of the header, but with a different identifier.
// ID3v2 identifier "3DI"
// ID3v2 version $04 00
// ID3v2 flags %abcd0000
// ID3v2 size 4 * %0xxxxxxx
if (isset($thisfile_id3v2_flags['isfooter']) && $thisfile_id3v2_flags['isfooter']) {
$footer = fread($fd, 10);
if (substr($footer, 0, 3) == '3DI') {
$thisfile_id3v2['footer'] = true;
$thisfile_id3v2['majorversion_footer'] = ord($footer[3]);
$thisfile_id3v2['minorversion_footer'] = ord($footer[4]);
}
if ($thisfile_id3v2['majorversion_footer'] <= 4) {
$id3_flags = ord(substr($footer[5]));
$thisfile_id3v2_flags['unsynch_footer'] = (bool) ($id3_flags & 0x80);
$thisfile_id3v2_flags['extfoot_footer'] = (bool) ($id3_flags & 0x40);
$thisfile_id3v2_flags['experim_footer'] = (bool) ($id3_flags & 0x20);
$thisfile_id3v2_flags['isfooter_footer'] = (bool) ($id3_flags & 0x10);
$thisfile_id3v2['footerlength'] = getid3_lib::BigEndian2Int(substr($footer, 6, 4), 1);
}
}
// end footer
if (isset($thisfile_id3v2['comments']['genre'])) {
foreach ($thisfile_id3v2['comments']['genre'] as $key => $value) {
unset($thisfile_id3v2['comments']['genre'][$key]);
$thisfile_id3v2['comments'] = getid3_lib::array_merge_noclobber($thisfile_id3v2['comments'], $this->ParseID3v2GenreString($value));
}
}
if (isset($thisfile_id3v2['comments']['track'])) {
foreach ($thisfile_id3v2['comments']['track'] as $key => $value) {
if (strstr($value, '/')) {
list($thisfile_id3v2['comments']['tracknum'][$key], $thisfile_id3v2['comments']['totaltracks'][$key]) = explode('/', $thisfile_id3v2['comments']['track'][$key]);
}
}
}
if (!isset($thisfile_id3v2['comments']['year']) && ereg('^([0-9]{4})', trim(@$thisfile_id3v2['comments']['recording_time'][0]), $matches)) {
$thisfile_id3v2['comments']['year'] = array($matches[1]);
}
// Set avdataoffset
$ThisFileInfo['avdataoffset'] = $thisfile_id3v2['headerlength'];
if (isset($thisfile_id3v2['footer'])) {
$ThisFileInfo['avdataoffset'] += 10;
}
return true;
}