當前位置: 首頁>>代碼示例>>PHP>>正文


PHP getid3_lib::CastAsInt方法代碼示例

本文整理匯總了PHP中getid3_lib::CastAsInt方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::CastAsInt方法的具體用法?PHP getid3_lib::CastAsInt怎麽用?PHP getid3_lib::CastAsInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在getid3_lib的用法示例。


在下文中一共展示了getid3_lib::CastAsInt方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: CastAsAppropriate

 public function CastAsAppropriate($value)
 {
     if (is_array($value)) {
         return $value;
     } elseif (preg_match('#^[0-9]+/[0-9]+$#', $value)) {
         return getid3_lib::DecimalizeFraction($value);
     } elseif (preg_match('#^[0-9]+$#', $value)) {
         return getid3_lib::CastAsInt($value);
     } elseif (preg_match('#^[0-9\\.]+$#', $value)) {
         return (double) $value;
     }
     return $value;
 }
開發者ID:idiscussforum,項目名稱:providence,代碼行數:13,代碼來源:module.graphic.jpg.php

示例2: DateMac2Unix

 static function DateMac2Unix($macdate)
 {
     // Macintosh timestamp: seconds since 00:00h January 1, 1904
     // UNIX timestamp:      seconds since 00:00h January 1, 1970
     return getid3_lib::CastAsInt($macdate - 2082844800);
 }
開發者ID:par-orillonsoft,項目名稱:phpwebsite,代碼行數:6,代碼來源:getid3.lib.php

示例3: getid3_riff


//.........這裏部分代碼省略.........
                 $thisfile_riff_raw_rgad['nAudiophileRgAdjust'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($rgadData, 6, 2));
                 $nRadioRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
                 $nAudiophileRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
                 $thisfile_riff_raw_rgad_track['name'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 0, 3));
                 $thisfile_riff_raw_rgad_track['originator'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 3, 3));
                 $thisfile_riff_raw_rgad_track['signbit'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 6, 1));
                 $thisfile_riff_raw_rgad_track['adjustment'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 7, 9));
                 $thisfile_riff_raw_rgad_album['name'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 0, 3));
                 $thisfile_riff_raw_rgad_album['originator'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 3, 3));
                 $thisfile_riff_raw_rgad_album['signbit'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 6, 1));
                 $thisfile_riff_raw_rgad_album['adjustment'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 7, 9));
                 $thisfile_riff['rgad']['peakamplitude'] = $thisfile_riff_raw_rgad['fPeakAmplitude'];
                 if ($thisfile_riff_raw_rgad_track['name'] != 0 && $thisfile_riff_raw_rgad_track['originator'] != 0) {
                     $thisfile_riff['rgad']['track']['name'] = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_track['name']);
                     $thisfile_riff['rgad']['track']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_track['originator']);
                     $thisfile_riff['rgad']['track']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_track['adjustment'], $thisfile_riff_raw_rgad_track['signbit']);
                 }
                 if ($thisfile_riff_raw_rgad_album['name'] != 0 && $thisfile_riff_raw_rgad_album['originator'] != 0) {
                     $thisfile_riff['rgad']['album']['name'] = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_album['name']);
                     $thisfile_riff['rgad']['album']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_album['originator']);
                     $thisfile_riff['rgad']['album']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_album['adjustment'], $thisfile_riff_raw_rgad_album['signbit']);
                 }
             }
             if (isset($thisfile_riff_WAVE['fact'][0]['data'])) {
                 $thisfile_riff_raw['fact']['NumberOfSamples'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_WAVE['fact'][0]['data'], 0, 4));
                 // This should be a good way of calculating exact playtime,
                 // but some sample files have had incorrect number of samples,
                 // so cannot use this method
                 // if (!empty($thisfile_riff_raw['fmt ']['nSamplesPerSec'])) {
                 //     $ThisFileInfo['playtime_seconds'] = (float) $thisfile_riff_raw['fact']['NumberOfSamples'] / $thisfile_riff_raw['fmt ']['nSamplesPerSec'];
                 // }
             }
             if (!empty($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'])) {
                 $thisfile_audio['bitrate'] = getid3_lib::CastAsInt($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'] * 8);
             }
             if (isset($thisfile_riff_WAVE['bext'][0]['data'])) {
                 // shortcut
                 $thisfile_riff_WAVE_bext_0 =& $thisfile_riff_WAVE['bext'][0];
                 $thisfile_riff_WAVE_bext_0['title'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 0, 256));
                 $thisfile_riff_WAVE_bext_0['author'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 256, 32));
                 $thisfile_riff_WAVE_bext_0['reference'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 288, 32));
                 $thisfile_riff_WAVE_bext_0['origin_date'] = substr($thisfile_riff_WAVE_bext_0['data'], 320, 10);
                 $thisfile_riff_WAVE_bext_0['origin_time'] = substr($thisfile_riff_WAVE_bext_0['data'], 330, 8);
                 $thisfile_riff_WAVE_bext_0['time_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 338, 8));
                 $thisfile_riff_WAVE_bext_0['bwf_version'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 346, 1));
                 $thisfile_riff_WAVE_bext_0['reserved'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 347, 254));
                 $thisfile_riff_WAVE_bext_0['coding_history'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601)));
                 $thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime(substr($thisfile_riff_WAVE_bext_0['origin_time'], 0, 2), substr($thisfile_riff_WAVE_bext_0['origin_time'], 3, 2), substr($thisfile_riff_WAVE_bext_0['origin_time'], 6, 2), substr($thisfile_riff_WAVE_bext_0['origin_date'], 5, 2), substr($thisfile_riff_WAVE_bext_0['origin_date'], 8, 2), substr($thisfile_riff_WAVE_bext_0['origin_date'], 0, 4));
                 $thisfile_riff['comments']['author'][] = $thisfile_riff_WAVE_bext_0['author'];
                 $thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_bext_0['title'];
             }
             if (isset($thisfile_riff_WAVE['MEXT'][0]['data'])) {
                 // shortcut
                 $thisfile_riff_WAVE_MEXT_0 =& $thisfile_riff_WAVE['MEXT'][0];
                 $thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 0, 2));
                 $thisfile_riff_WAVE_MEXT_0['flags']['homogenous'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x1);
                 if ($thisfile_riff_WAVE_MEXT_0['flags']['homogenous']) {
                     $thisfile_riff_WAVE_MEXT_0['flags']['padding'] = $thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x2 ? false : true;
                     $thisfile_riff_WAVE_MEXT_0['flags']['22_or_44'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x4);
                     $thisfile_riff_WAVE_MEXT_0['flags']['free_format'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x8);
                     $thisfile_riff_WAVE_MEXT_0['nominal_frame_size'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 2, 2));
                 }
                 $thisfile_riff_WAVE_MEXT_0['anciliary_data_length'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 6, 2));
                 $thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 8, 2));
                 $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_left'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x1);
                 $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_free'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x2);
開發者ID:ioanok,項目名稱:symfoxid,代碼行數:67,代碼來源:module.audio-video.riff.php

示例4: getid3_id3v2


//.........這裏部分代碼省略.........
                         $id3v2_majorversion = 3;
                         $frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 4, 4), 0);
                         // 32-bit integer
                     }
                 }
                 $frame_flags = getid3_lib::BigEndian2Int(substr($frame_header, 8, 2));
             }
             if ($id3v2_majorversion == 2 && $frame_name == "" || $frame_name == "") {
                 // padding encountered
                 $thisfile_id3v2['padding']['start'] = $framedataoffset;
                 $thisfile_id3v2['padding']['length'] = strlen($frame_header) + strlen($framedata);
                 $thisfile_id3v2['padding']['valid'] = true;
                 $len = strlen($framedata);
                 for ($i = 0; $i < $len; $i++) {
                     if ($framedata[$i] != "") {
                         $thisfile_id3v2['padding']['valid'] = false;
                         $thisfile_id3v2['padding']['errorpos'] = $thisfile_id3v2['padding']['start'] + $i;
                         $ThisFileInfo['warning'][] = 'Invalid ID3v2 padding found at offset ' . $thisfile_id3v2['padding']['errorpos'] . ' (the remaining ' . ($thisfile_id3v2['padding']['length'] - $i) . ' bytes are considered invalid)';
                         break;
                     }
                 }
                 break;
                 // skip rest of ID3v2 header
             }
             if ($frame_name == 'COM ') {
                 $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 iTunes (versions "X v2.0.3", "v3.0.1" are known-guilty, probably others too)]';
                 $frame_name = 'COMM';
             }
             if ($frame_size <= strlen($framedata) && $this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion)) {
                 unset($parsedFrame);
                 $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':
開發者ID:scottatron,項目名稱:opentape,代碼行數:67,代碼來源:module.tag.id3v2.php

示例5: Analyze


//.........這裏部分代碼省略.........
                 $thisfile_riff_raw_rgad['nAudiophileRgAdjust'] = $this->EitherEndian2Int(substr($rgadData, 6, 2));
                 $nRadioRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
                 $nAudiophileRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
                 $thisfile_riff_raw_rgad_track['name'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 0, 3));
                 $thisfile_riff_raw_rgad_track['originator'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 3, 3));
                 $thisfile_riff_raw_rgad_track['signbit'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 6, 1));
                 $thisfile_riff_raw_rgad_track['adjustment'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 7, 9));
                 $thisfile_riff_raw_rgad_album['name'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 0, 3));
                 $thisfile_riff_raw_rgad_album['originator'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 3, 3));
                 $thisfile_riff_raw_rgad_album['signbit'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 6, 1));
                 $thisfile_riff_raw_rgad_album['adjustment'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 7, 9));
                 $thisfile_riff['rgad']['peakamplitude'] = $thisfile_riff_raw_rgad['fPeakAmplitude'];
                 if ($thisfile_riff_raw_rgad_track['name'] != 0 && $thisfile_riff_raw_rgad_track['originator'] != 0) {
                     $thisfile_riff['rgad']['track']['name'] = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_track['name']);
                     $thisfile_riff['rgad']['track']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_track['originator']);
                     $thisfile_riff['rgad']['track']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_track['adjustment'], $thisfile_riff_raw_rgad_track['signbit']);
                 }
                 if ($thisfile_riff_raw_rgad_album['name'] != 0 && $thisfile_riff_raw_rgad_album['originator'] != 0) {
                     $thisfile_riff['rgad']['album']['name'] = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_album['name']);
                     $thisfile_riff['rgad']['album']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_album['originator']);
                     $thisfile_riff['rgad']['album']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_album['adjustment'], $thisfile_riff_raw_rgad_album['signbit']);
                 }
             }
             if (isset($thisfile_riff_WAVE['fact'][0]['data'])) {
                 $thisfile_riff_raw['fact']['NumberOfSamples'] = $this->EitherEndian2Int(substr($thisfile_riff_WAVE['fact'][0]['data'], 0, 4));
                 // This should be a good way of calculating exact playtime,
                 // but some sample files have had incorrect number of samples,
                 // so cannot use this method
                 // if (!empty($thisfile_riff_raw['fmt ']['nSamplesPerSec'])) {
                 //     $info['playtime_seconds'] = (float) $thisfile_riff_raw['fact']['NumberOfSamples'] / $thisfile_riff_raw['fmt ']['nSamplesPerSec'];
                 // }
             }
             if (!empty($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'])) {
                 $thisfile_audio['bitrate'] = getid3_lib::CastAsInt($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'] * 8);
             }
             if (isset($thisfile_riff_WAVE['bext'][0]['data'])) {
                 // shortcut
                 $thisfile_riff_WAVE_bext_0 =& $thisfile_riff_WAVE['bext'][0];
                 $thisfile_riff_WAVE_bext_0['title'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 0, 256));
                 $thisfile_riff_WAVE_bext_0['author'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 256, 32));
                 $thisfile_riff_WAVE_bext_0['reference'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 288, 32));
                 $thisfile_riff_WAVE_bext_0['origin_date'] = substr($thisfile_riff_WAVE_bext_0['data'], 320, 10);
                 $thisfile_riff_WAVE_bext_0['origin_time'] = substr($thisfile_riff_WAVE_bext_0['data'], 330, 8);
                 $thisfile_riff_WAVE_bext_0['time_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 338, 8));
                 $thisfile_riff_WAVE_bext_0['bwf_version'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 346, 1));
                 $thisfile_riff_WAVE_bext_0['reserved'] = substr($thisfile_riff_WAVE_bext_0['data'], 347, 254);
                 $thisfile_riff_WAVE_bext_0['coding_history'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601)));
                 if (preg_match('#^([0-9]{4}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_date'], $matches_bext_date)) {
                     if (preg_match('#^([0-9]{2}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_time'], $matches_bext_time)) {
                         list($dummy, $bext_timestamp['year'], $bext_timestamp['month'], $bext_timestamp['day']) = $matches_bext_date;
                         list($dummy, $bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second']) = $matches_bext_time;
                         $thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime($bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second'], $bext_timestamp['month'], $bext_timestamp['day'], $bext_timestamp['year']);
                     } else {
                         $info['warning'][] = 'RIFF.WAVE.BEXT.origin_time is invalid';
                     }
                 } else {
                     $info['warning'][] = 'RIFF.WAVE.BEXT.origin_date is invalid';
                 }
                 $thisfile_riff['comments']['author'][] = $thisfile_riff_WAVE_bext_0['author'];
                 $thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_bext_0['title'];
             }
             if (isset($thisfile_riff_WAVE['MEXT'][0]['data'])) {
                 // shortcut
                 $thisfile_riff_WAVE_MEXT_0 =& $thisfile_riff_WAVE['MEXT'][0];
                 $thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 0, 2));
                 $thisfile_riff_WAVE_MEXT_0['flags']['homogenous'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x1);
開發者ID:harrisonsmith,項目名稱:active-progression,代碼行數:67,代碼來源:module.audio-video.riff.php

示例6: ParseMPCsv7

 public function ParseMPCsv7()
 {
     // this is SV7
     // http://www.uni-jena.de/~pfk/mpp/sv8/header.html
     $info =& $this->getid3->info;
     $thisfile_mpc_header =& $info['mpc']['header'];
     $offset = 0;
     $thisfile_mpc_header['size'] = 28;
     $MPCheaderData = $info['mpc']['header']['preamble'];
     $MPCheaderData .= fread($this->getid3->fp, $thisfile_mpc_header['size'] - strlen($info['mpc']['header']['preamble']));
     $offset = strlen('MP+');
     $StreamVersionByte = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
     $offset += 1;
     $thisfile_mpc_header['stream_version_major'] = ($StreamVersionByte & 0xf) >> 0;
     $thisfile_mpc_header['stream_version_minor'] = ($StreamVersionByte & 0xf0) >> 4;
     // should always be 0, subversions no longer exist in SV8
     $thisfile_mpc_header['frame_count'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
     $offset += 4;
     if ($thisfile_mpc_header['stream_version_major'] != 7) {
         $info['error'][] = 'Only Musepack SV7 supported (this file claims to be v' . $thisfile_mpc_header['stream_version_major'] . ')';
         return false;
     }
     $FlagsDWORD1 = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
     $offset += 4;
     $thisfile_mpc_header['intensity_stereo'] = (bool) (($FlagsDWORD1 & 0x80000000) >> 31);
     $thisfile_mpc_header['mid_side_stereo'] = (bool) (($FlagsDWORD1 & 0x40000000) >> 30);
     $thisfile_mpc_header['max_subband'] = ($FlagsDWORD1 & 0x3f000000) >> 24;
     $thisfile_mpc_header['raw']['profile'] = ($FlagsDWORD1 & 0xf00000) >> 20;
     $thisfile_mpc_header['begin_loud'] = (bool) (($FlagsDWORD1 & 0x80000) >> 19);
     $thisfile_mpc_header['end_loud'] = (bool) (($FlagsDWORD1 & 0x40000) >> 18);
     $thisfile_mpc_header['raw']['sample_rate'] = ($FlagsDWORD1 & 0x30000) >> 16;
     $thisfile_mpc_header['max_level'] = $FlagsDWORD1 & 0xffff;
     $thisfile_mpc_header['raw']['title_peak'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2));
     $offset += 2;
     $thisfile_mpc_header['raw']['title_gain'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2), true);
     $offset += 2;
     $thisfile_mpc_header['raw']['album_peak'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2));
     $offset += 2;
     $thisfile_mpc_header['raw']['album_gain'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2), true);
     $offset += 2;
     $FlagsDWORD2 = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
     $offset += 4;
     $thisfile_mpc_header['true_gapless'] = (bool) (($FlagsDWORD2 & 0x80000000) >> 31);
     $thisfile_mpc_header['last_frame_length'] = ($FlagsDWORD2 & 0x7ff00000) >> 20;
     $thisfile_mpc_header['raw']['not_sure_what'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 3));
     $offset += 3;
     $thisfile_mpc_header['raw']['encoder_version'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
     $offset += 1;
     $thisfile_mpc_header['profile'] = $this->MPCprofileNameLookup($thisfile_mpc_header['raw']['profile']);
     $thisfile_mpc_header['sample_rate'] = $this->MPCfrequencyLookup($thisfile_mpc_header['raw']['sample_rate']);
     if ($thisfile_mpc_header['sample_rate'] == 0) {
         $info['error'][] = 'Corrupt MPC file: frequency == zero';
         return false;
     }
     $info['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
     $thisfile_mpc_header['samples'] = (($thisfile_mpc_header['frame_count'] - 1) * 1152 + $thisfile_mpc_header['last_frame_length']) * $info['audio']['channels'];
     $info['playtime_seconds'] = $thisfile_mpc_header['samples'] / $info['audio']['channels'] / $info['audio']['sample_rate'];
     if ($info['playtime_seconds'] == 0) {
         $info['error'][] = 'Corrupt MPC file: playtime_seconds == zero';
         return false;
     }
     // add size of file header to avdataoffset - calc bitrate correctly + MD5 data
     $info['avdataoffset'] += $thisfile_mpc_header['size'];
     $info['audio']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
     $thisfile_mpc_header['title_peak'] = $thisfile_mpc_header['raw']['title_peak'];
     $thisfile_mpc_header['title_peak_db'] = $this->MPCpeakDBLookup($thisfile_mpc_header['title_peak']);
     if ($thisfile_mpc_header['raw']['title_gain'] < 0) {
         $thisfile_mpc_header['title_gain_db'] = (double) (32768 + $thisfile_mpc_header['raw']['title_gain']) / -100;
     } else {
         $thisfile_mpc_header['title_gain_db'] = (double) $thisfile_mpc_header['raw']['title_gain'] / 100;
     }
     $thisfile_mpc_header['album_peak'] = $thisfile_mpc_header['raw']['album_peak'];
     $thisfile_mpc_header['album_peak_db'] = $this->MPCpeakDBLookup($thisfile_mpc_header['album_peak']);
     if ($thisfile_mpc_header['raw']['album_gain'] < 0) {
         $thisfile_mpc_header['album_gain_db'] = (double) (32768 + $thisfile_mpc_header['raw']['album_gain']) / -100;
     } else {
         $thisfile_mpc_header['album_gain_db'] = (double) $thisfile_mpc_header['raw']['album_gain'] / 100;
     }
     $thisfile_mpc_header['encoder_version'] = $this->MPCencoderVersionLookup($thisfile_mpc_header['raw']['encoder_version']);
     $info['replay_gain']['track']['adjustment'] = $thisfile_mpc_header['title_gain_db'];
     $info['replay_gain']['album']['adjustment'] = $thisfile_mpc_header['album_gain_db'];
     if ($thisfile_mpc_header['title_peak'] > 0) {
         $info['replay_gain']['track']['peak'] = $thisfile_mpc_header['title_peak'];
     } elseif (round($thisfile_mpc_header['max_level'] * 1.18) > 0) {
         $info['replay_gain']['track']['peak'] = getid3_lib::CastAsInt(round($thisfile_mpc_header['max_level'] * 1.18));
         // why? I don't know - see mppdec.c
     }
     if ($thisfile_mpc_header['album_peak'] > 0) {
         $info['replay_gain']['album']['peak'] = $thisfile_mpc_header['album_peak'];
     }
     //$info['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_version_major'].'.'.$thisfile_mpc_header['stream_version_minor'].', '.$thisfile_mpc_header['encoder_version'];
     $info['audio']['encoder'] = $thisfile_mpc_header['encoder_version'];
     $info['audio']['encoder_options'] = $thisfile_mpc_header['profile'];
     $thisfile_mpc_header['quality'] = (double) ($thisfile_mpc_header['raw']['profile'] - 5);
     // values can range from 0 to 15, of which 0..4 are "reserved/experimental", and 5..15 are mapped to qualities of 0.0 to 10.0
     return true;
 }
開發者ID:kaibosh,項目名稱:nZEDb,代碼行數:97,代碼來源:module.audio.mpc.php

示例7: getOnlyMPEGaudioInfo


//.........這裏部分代碼省略.........
                         }
                         $synchstartoffset = $scan_start_offset[$current_segment];
                         while ($this->decodeMPEGaudioHeader($synchstartoffset, $dummy, false, false, $FastMode)) {
                             $FastMode = true;
                             $thisframebitrate = $MPEGaudioBitrateLookup[$MPEGaudioVersionLookup[$dummy['mpeg']['audio']['raw']['version']]][$MPEGaudioLayerLookup[$dummy['mpeg']['audio']['raw']['layer']]][$dummy['mpeg']['audio']['raw']['bitrate']];
                             if (empty($dummy['mpeg']['audio']['framelength'])) {
                                 $SynchErrorsFound++;
                                 $synchstartoffset++;
                             } else {
                                 getid3_lib::safe_inc($info['mpeg']['audio']['bitrate_distribution'][$thisframebitrate]);
                                 getid3_lib::safe_inc($info['mpeg']['audio']['stereo_distribution'][$dummy['mpeg']['audio']['channelmode']]);
                                 getid3_lib::safe_inc($info['mpeg']['audio']['version_distribution'][$dummy['mpeg']['audio']['version']]);
                                 $synchstartoffset += $dummy['mpeg']['audio']['framelength'];
                             }
                             $frames_scanned++;
                             if ($frames_scan_per_segment && ++$frames_scanned_this_segment >= $frames_scan_per_segment) {
                                 $this_pct_scanned = ($this->ftell() - $scan_start_offset[$current_segment]) / ($info['avdataend'] - $info['avdataoffset']);
                                 if ($current_segment == 0 && $this_pct_scanned * $max_scan_segments >= 1) {
                                     // file likely contains < $max_frames_scan, just scan as one segment
                                     $max_scan_segments = 1;
                                     $frames_scan_per_segment = $max_frames_scan;
                                 } else {
                                     $pct_data_scanned += $this_pct_scanned;
                                     break;
                                 }
                             }
                         }
                     }
                     if ($pct_data_scanned > 0) {
                         $info['warning'][] = 'too many MPEG audio frames to scan, only scanned ' . $frames_scanned . ' frames in ' . $max_scan_segments . ' segments (' . number_format($pct_data_scanned * 100, 1) . '% of file) and extrapolated distribution, playtime and bitrate may be incorrect.';
                         foreach ($info['mpeg']['audio'] as $key1 => $value1) {
                             if (!preg_match('#_distribution$#i', $key1)) {
                                 continue;
                             }
                             foreach ($value1 as $key2 => $value2) {
                                 $info['mpeg']['audio'][$key1][$key2] = round($value2 / $pct_data_scanned);
                             }
                         }
                     }
                     if ($SynchErrorsFound > 0) {
                         $info['warning'][] = 'Found ' . $SynchErrorsFound . ' synch errors in histogram analysis';
                         //return false;
                     }
                     $bittotal = 0;
                     $framecounter = 0;
                     foreach ($info['mpeg']['audio']['bitrate_distribution'] as $bitratevalue => $bitratecount) {
                         $framecounter += $bitratecount;
                         if ($bitratevalue != 'free') {
                             $bittotal += $bitratevalue * $bitratecount;
                         }
                     }
                     if ($framecounter == 0) {
                         $info['error'][] = 'Corrupt MP3 file: framecounter == zero';
                         return false;
                     }
                     $info['mpeg']['audio']['frame_count'] = getid3_lib::CastAsInt($framecounter);
                     $info['mpeg']['audio']['bitrate'] = $bittotal / $framecounter;
                     $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
                     // Definitively set VBR vs CBR, even if the Xing/LAME/VBRI header says differently
                     $distinct_bitrates = 0;
                     foreach ($info['mpeg']['audio']['bitrate_distribution'] as $bitrate_value => $bitrate_count) {
                         if ($bitrate_count > 0) {
                             $distinct_bitrates++;
                         }
                     }
                     if ($distinct_bitrates > 1) {
                         $info['mpeg']['audio']['bitrate_mode'] = 'vbr';
                     } else {
                         $info['mpeg']['audio']['bitrate_mode'] = 'cbr';
                     }
                     $info['audio']['bitrate_mode'] = $info['mpeg']['audio']['bitrate_mode'];
                 }
                 break;
                 // exit while()
             }
         }
         $SynchSeekOffset++;
         if ($avdataoffset + $SynchSeekOffset >= $info['avdataend']) {
             // end of file/data
             if (empty($info['mpeg']['audio'])) {
                 $info['error'][] = 'could not find valid MPEG synch before end of file';
                 if (isset($info['audio']['bitrate'])) {
                     unset($info['audio']['bitrate']);
                 }
                 if (isset($info['mpeg']['audio'])) {
                     unset($info['mpeg']['audio']);
                 }
                 if (isset($info['mpeg']) && (!is_array($info['mpeg']) || empty($info['mpeg']))) {
                     unset($info['mpeg']);
                 }
                 return false;
             }
             break;
         }
     }
     $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
     $info['audio']['channelmode'] = $info['mpeg']['audio']['channelmode'];
     $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
     return true;
 }
開發者ID:rauldobrota,項目名稱:zenphoto,代碼行數:101,代碼來源:module.audio.mp3.php

示例8: Analyze


//.........這裏部分代碼省略.........
                                 break;
                             case 3:
                                 $info['video']['resolution_x'] = 176;
                                 $info['video']['resolution_y'] = 144;
                                 break;
                             case 4:
                                 $info['video']['resolution_x'] = 128;
                                 $info['video']['resolution_y'] = 96;
                                 break;
                             case 5:
                                 $info['video']['resolution_x'] = 320;
                                 $info['video']['resolution_y'] = 240;
                                 break;
                             case 6:
                                 $info['video']['resolution_x'] = 160;
                                 $info['video']['resolution_y'] = 120;
                                 break;
                             default:
                                 $info['video']['resolution_x'] = 0;
                                 $info['video']['resolution_y'] = 0;
                                 break;
                         }
                     }
                     $info['video']['pixel_aspect_ratio'] = $info['video']['resolution_x'] / $info['video']['resolution_y'];
                 }
                 break;
                 // Meta tag
             // Meta tag
             case GETID3_FLV_TAG_META:
                 if (!$found_meta) {
                     $found_meta = true;
                     fseek($this->getid3->fp, -1, SEEK_CUR);
                     $datachunk = fread($this->getid3->fp, $DataLength);
                     $AMFstream = new AMFStream($datachunk);
                     $reader = new AMFReader($AMFstream);
                     $eventName = $reader->readData();
                     $info['flv']['meta'][$eventName] = $reader->readData();
                     unset($reader);
                     $copykeys = array('framerate' => 'frame_rate', 'width' => 'resolution_x', 'height' => 'resolution_y', 'audiodatarate' => 'bitrate', 'videodatarate' => 'bitrate');
                     foreach ($copykeys as $sourcekey => $destkey) {
                         if (isset($info['flv']['meta']['onMetaData'][$sourcekey])) {
                             switch ($sourcekey) {
                                 case 'width':
                                 case 'height':
                                     $info['video'][$destkey] = intval(round($info['flv']['meta']['onMetaData'][$sourcekey]));
                                     break;
                                 case 'audiodatarate':
                                     $info['audio'][$destkey] = getid3_lib::CastAsInt(round($info['flv']['meta']['onMetaData'][$sourcekey] * 1000));
                                     break;
                                 case 'videodatarate':
                                 case 'frame_rate':
                                 default:
                                     $info['video'][$destkey] = $info['flv']['meta']['onMetaData'][$sourcekey];
                                     break;
                             }
                         }
                     }
                     if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
                         $found_valid_meta_playtime = true;
                     }
                 }
                 break;
             default:
                 // noop
                 break;
         }
         fseek($this->getid3->fp, $NextOffset, SEEK_SET);
     }
     $info['playtime_seconds'] = $Duration / 1000;
     if ($info['playtime_seconds'] > 0) {
         $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
     }
     if ($info['flv']['header']['hasAudio']) {
         $info['audio']['codec'] = $this->FLVaudioFormat($info['flv']['audio']['audioFormat']);
         $info['audio']['sample_rate'] = $this->FLVaudioRate($info['flv']['audio']['audioRate']);
         $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info['flv']['audio']['audioSampleSize']);
         $info['audio']['channels'] = $info['flv']['audio']['audioType'] + 1;
         // 0=mono,1=stereo
         $info['audio']['lossless'] = $info['flv']['audio']['audioFormat'] ? false : true;
         // 0=uncompressed
         $info['audio']['dataformat'] = 'flv';
     }
     if (!empty($info['flv']['header']['hasVideo'])) {
         $info['video']['codec'] = $this->FLVvideoCodec($info['flv']['video']['videoCodec']);
         $info['video']['dataformat'] = 'flv';
         $info['video']['lossless'] = false;
     }
     // Set information from meta
     if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
         $info['playtime_seconds'] = $info['flv']['meta']['onMetaData']['duration'];
         $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
     }
     if (isset($info['flv']['meta']['onMetaData']['audiocodecid'])) {
         $info['audio']['codec'] = $this->FLVaudioFormat($info['flv']['meta']['onMetaData']['audiocodecid']);
     }
     if (isset($info['flv']['meta']['onMetaData']['videocodecid'])) {
         $info['video']['codec'] = $this->FLVvideoCodec($info['flv']['meta']['onMetaData']['videocodecid']);
     }
     return true;
 }
開發者ID:mostafiz93,項目名稱:PrintfScanf,代碼行數:101,代碼來源:module.audio-video.flv.php

示例9: Analyze

 function Analyze()
 {
     $info =& $this->getid3->info;
     $OriginalAVdataOffset = $info['avdataoffset'];
     fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     $VOCheader = fread($this->getid3->fp, 26);
     $magic = 'Creative Voice File';
     if (substr($VOCheader, 0, 19) != $magic) {
         $info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($VOCheader, 0, 19)) . '"';
         return false;
     }
     // shortcuts
     $thisfile_audio =& $info['audio'];
     $info['voc'] = array();
     $thisfile_voc =& $info['voc'];
     $info['fileformat'] = 'voc';
     $thisfile_audio['dataformat'] = 'voc';
     $thisfile_audio['bitrate_mode'] = 'cbr';
     $thisfile_audio['lossless'] = true;
     $thisfile_audio['channels'] = 1;
     // might be overriden below
     $thisfile_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)
     $thisfile_voc['header']['datablock_offset'] = getid3_lib::LittleEndian2Int(substr($VOCheader, 20, 2));
     $thisfile_voc['header']['minor_version'] = getid3_lib::LittleEndian2Int(substr($VOCheader, 22, 1));
     $thisfile_voc['header']['major_version'] = getid3_lib::LittleEndian2Int(substr($VOCheader, 23, 1));
     do {
         $BlockOffset = ftell($this->getid3->fp);
         $BlockData = fread($this->getid3->fp, 4);
         $BlockType = ord($BlockData[0]);
         $BlockSize = getid3_lib::LittleEndian2Int(substr($BlockData, 1, 3));
         $ThisBlock = array();
         getid3_lib::safe_inc($thisfile_voc['blocktypes'][$BlockType], 1);
         switch ($BlockType) {
             case 0:
                 // Terminator
                 // do nothing, we'll break out of the loop down below
                 break;
             case 1:
                 // Sound data
                 $BlockData .= fread($this->getid3->fp, 2);
                 if ($info['avdataoffset'] <= $OriginalAVdataOffset) {
                     $info['avdataoffset'] = ftell($this->getid3->fp);
                 }
                 fseek($this->getid3->fp, $BlockSize - 2, SEEK_CUR);
                 $ThisBlock['sample_rate_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, 4, 1));
                 $ThisBlock['compression_type'] = getid3_lib::LittleEndian2Int(substr($BlockData, 5, 1));
                 $ThisBlock['compression_name'] = $this->VOCcompressionTypeLookup($ThisBlock['compression_type']);
                 if ($ThisBlock['compression_type'] <= 3) {
                     $thisfile_voc['compressed_bits_per_sample'] = getid3_lib::CastAsInt(str_replace('-bit', '', $ThisBlock['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($thisfile_audio['sample_rate'])) {
                     // SR byte = 256 - (1000000 / sample_rate)
                     $thisfile_audio['sample_rate'] = getid3_lib::trunc(1000000 / (256 - $ThisBlock['sample_rate_id']) / $thisfile_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($this->getid3->fp, $BlockSize, SEEK_CUR);
                 break;
             case 8:
                 // Extended
                 $BlockData .= fread($this->getid3->fp, 4);
                 //00-01  Time Constant:
                 //   Mono: 65536 - (256000000 / sample_rate)
                 // Stereo: 65536 - (256000000 / (sample_rate * 2))
                 $ThisBlock['time_constant'] = getid3_lib::LittleEndian2Int(substr($BlockData, 4, 2));
                 $ThisBlock['pack_method'] = getid3_lib::LittleEndian2Int(substr($BlockData, 6, 1));
                 $ThisBlock['stereo'] = (bool) getid3_lib::LittleEndian2Int(substr($BlockData, 7, 1));
                 $thisfile_audio['channels'] = $ThisBlock['stereo'] ? 2 : 1;
                 $thisfile_audio['sample_rate'] = getid3_lib::trunc(256000000 / (65536 - $ThisBlock['time_constant']) / $thisfile_audio['channels']);
                 break;
             case 9:
                 // data block that supersedes blocks 1 and 8. Used for stereo, 16 bit
                 $BlockData .= fread($this->getid3->fp, 12);
                 if ($info['avdataoffset'] <= $OriginalAVdataOffset) {
                     $info['avdataoffset'] = ftell($this->getid3->fp);
                 }
                 fseek($this->getid3->fp, $BlockSize - 12, SEEK_CUR);
//.........這裏部分代碼省略.........
開發者ID:hackersforcharity,項目名稱:rachelpiOS,代碼行數:101,代碼來源:module.audio.voc.php

示例10: getid3_mpc


//.........這裏部分代碼省略.........
             $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
         }
         $ThisFileInfo['mpc']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 * 44100 / $thisfile_mpc_header['frame_count'] / 1152;
         $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpc']['bitrate'];
         $ThisFileInfo['audio']['encoder'] = 'SV' . $thisfile_mpc_header['stream_major_version'];
         return true;
     } else {
         $ThisFileInfo['error'][] = 'Expecting "MP+" at offset ' . $ThisFileInfo['avdataoffset'] . ', found "' . substr($MPCheaderData, $offset, 3) . '"';
         unset($ThisFileInfo['fileformat']);
         unset($ThisFileInfo['mpc']);
         return false;
     }
     // Continue with SV7+ handling
     $StreamVersionByte = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
     $offset += 1;
     $thisfile_mpc_header['stream_major_version'] = $StreamVersionByte & 0xf;
     $thisfile_mpc_header['stream_minor_version'] = ($StreamVersionByte & 0xf0) >> 4;
     $thisfile_mpc_header['frame_count'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
     $offset += 4;
     switch ($thisfile_mpc_header['stream_major_version']) {
         case 7:
             //$ThisFileInfo['fileformat'] = 'SV7';
             break;
         default:
             $ThisFileInfo['error'][] = 'Only Musepack SV7 supported';
             return false;
     }
     $FlagsDWORD1 = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
     $offset += 4;
     $thisfile_mpc_header['intensity_stereo'] = (bool) (($FlagsDWORD1 & 2147483648.0) >> 31);
     $thisfile_mpc_header['mid_side_stereo'] = (bool) (($FlagsDWORD1 & 0x40000000) >> 30);
     $thisfile_mpc_header['max_subband'] = ($FlagsDWORD1 & 0x3f000000) >> 24;
     $thisfile_mpc_header['raw']['profile'] = ($FlagsDWORD1 & 0xf00000) >> 20;
     $thisfile_mpc_header['begin_loud'] = (bool) (($FlagsDWORD1 & 0x80000) >> 19);
     $thisfile_mpc_header['end_loud'] = (bool) (($FlagsDWORD1 & 0x40000) >> 18);
     $thisfile_mpc_header['raw']['sample_rate'] = ($FlagsDWORD1 & 0x30000) >> 16;
     $thisfile_mpc_header['max_level'] = $FlagsDWORD1 & 0xffff;
     $thisfile_mpc_header['raw']['title_peak'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2));
     $offset += 2;
     $thisfile_mpc_header['raw']['title_gain'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2), true);
     $offset += 2;
     $thisfile_mpc_header['raw']['album_peak'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2));
     $offset += 2;
     $thisfile_mpc_header['raw']['album_gain'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2), true);
     $offset += 2;
     $FlagsDWORD2 = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
     $offset += 4;
     $thisfile_mpc_header['true_gapless'] = (bool) (($FlagsDWORD2 & 2147483648.0) >> 31);
     $thisfile_mpc_header['last_frame_length'] = ($FlagsDWORD2 & 0x7ff00000) >> 20;
     $thisfile_mpc_header['raw']['not_sure_what'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 3));
     $offset += 3;
     $thisfile_mpc_header['raw']['encoder_version'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
     $offset += 1;
     $thisfile_mpc_header['profile'] = $this->MPCprofileNameLookup($thisfile_mpc_header['raw']['profile']);
     $thisfile_mpc_header['sample_rate'] = $this->MPCfrequencyLookup($thisfile_mpc_header['raw']['sample_rate']);
     if ($thisfile_mpc_header['sample_rate'] == 0) {
         $ThisFileInfo['error'][] = 'Corrupt MPC file: frequency == zero';
         return false;
     }
     $ThisFileInfo['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
     $thisfile_mpc_header['samples'] = (($thisfile_mpc_header['frame_count'] - 1) * 1152 + $thisfile_mpc_header['last_frame_length']) * $ThisFileInfo['audio']['channels'];
     $ThisFileInfo['playtime_seconds'] = $thisfile_mpc_header['samples'] / $ThisFileInfo['audio']['channels'] / $ThisFileInfo['audio']['sample_rate'];
     if ($ThisFileInfo['playtime_seconds'] == 0) {
         $ThisFileInfo['error'][] = 'Corrupt MPC file: playtime_seconds == zero';
         return false;
     }
     // add size of file header to avdataoffset - calc bitrate correctly + MD5 data
     $ThisFileInfo['avdataoffset'] += $thisfile_mpc_header['size'];
     $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['playtime_seconds'];
     $thisfile_mpc_header['title_peak'] = $thisfile_mpc_header['raw']['title_peak'];
     $thisfile_mpc_header['title_peak_db'] = $this->MPCpeakDBLookup($thisfile_mpc_header['title_peak']);
     if ($thisfile_mpc_header['raw']['title_gain'] < 0) {
         $thisfile_mpc_header['title_gain_db'] = (double) (32768 + $thisfile_mpc_header['raw']['title_gain']) / -100;
     } else {
         $thisfile_mpc_header['title_gain_db'] = (double) $thisfile_mpc_header['raw']['title_gain'] / 100;
     }
     $thisfile_mpc_header['album_peak'] = $thisfile_mpc_header['raw']['album_peak'];
     $thisfile_mpc_header['album_peak_db'] = $this->MPCpeakDBLookup($thisfile_mpc_header['album_peak']);
     if ($thisfile_mpc_header['raw']['album_gain'] < 0) {
         $thisfile_mpc_header['album_gain_db'] = (double) (32768 + $thisfile_mpc_header['raw']['album_gain']) / -100;
     } else {
         $thisfile_mpc_header['album_gain_db'] = (double) $thisfile_mpc_header['raw']['album_gain'] / 100;
     }
     $thisfile_mpc_header['encoder_version'] = $this->MPCencoderVersionLookup($thisfile_mpc_header['raw']['encoder_version']);
     $ThisFileInfo['replay_gain']['track']['adjustment'] = $thisfile_mpc_header['title_gain_db'];
     $ThisFileInfo['replay_gain']['album']['adjustment'] = $thisfile_mpc_header['album_gain_db'];
     if ($thisfile_mpc_header['title_peak'] > 0) {
         $ThisFileInfo['replay_gain']['track']['peak'] = $thisfile_mpc_header['title_peak'];
     } elseif (round($thisfile_mpc_header['max_level'] * 1.18) > 0) {
         $ThisFileInfo['replay_gain']['track']['peak'] = getid3_lib::CastAsInt(round($thisfile_mpc_header['max_level'] * 1.18));
         // why? I don't know - see mppdec.c
     }
     if ($thisfile_mpc_header['album_peak'] > 0) {
         $ThisFileInfo['replay_gain']['album']['peak'] = $thisfile_mpc_header['album_peak'];
     }
     //$ThisFileInfo['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_major_version'].'.'.$thisfile_mpc_header['stream_minor_version'].', '.$thisfile_mpc_header['encoder_version'];
     $ThisFileInfo['audio']['encoder'] = $thisfile_mpc_header['encoder_version'];
     $ThisFileInfo['audio']['encoder_options'] = $thisfile_mpc_header['profile'];
     return true;
 }
開發者ID:BGCX261,項目名稱:zoom-gallery-svn-to-git,代碼行數:101,代碼來源:module.audio.mpc.php


注:本文中的getid3_lib::CastAsInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。