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


PHP getid3_lib::Bin2Dec方法代碼示例

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


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

示例1: getid3_riff


//.........這裏部分代碼省略.........
                 $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'];
                 $thisfile_riff_raw['rgad'] = array('track' => array(), 'album' => array());
                 $thisfile_riff_raw_rgad =& $thisfile_riff_raw['rgad'];
                 $thisfile_riff_raw_rgad_track =& $thisfile_riff_raw_rgad['track'];
                 $thisfile_riff_raw_rgad_album =& $thisfile_riff_raw_rgad['album'];
                 $thisfile_riff_raw_rgad['fPeakAmplitude'] = getid3_lib::LittleEndian2Float(substr($rgadData, 0, 4));
                 $thisfile_riff_raw_rgad['nRadioRgAdjust'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($rgadData, 4, 2));
                 $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'])) {
開發者ID:ioanok,項目名稱:symfoxid,代碼行數:67,代碼來源:module.audio-video.riff.php

示例2: Analyze

 public function Analyze()
 {
     $info =& $this->getid3->info;
     $info['fileformat'] = 'swf';
     $info['video']['dataformat'] = 'swf';
     // http://www.openswf.org/spec/SWFfileformat.html
     $this->fseek($info['avdataoffset']);
     $SWFfileData = $this->fread($info['avdataend'] - $info['avdataoffset']);
     // 8 + 2 + 2 + max(9) bytes NOT including Frame_Size RECT data
     $info['swf']['header']['signature'] = substr($SWFfileData, 0, 3);
     switch ($info['swf']['header']['signature']) {
         case 'FWS':
             $info['swf']['header']['compressed'] = false;
             break;
         case 'CWS':
             $info['swf']['header']['compressed'] = true;
             break;
         default:
             $info['error'][] = 'Expecting "FWS" or "CWS" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes($info['swf']['header']['signature']) . '"';
             unset($info['swf']);
             unset($info['fileformat']);
             return false;
             break;
     }
     $info['swf']['header']['version'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 3, 1));
     $info['swf']['header']['length'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 4, 4));
     if ($info['swf']['header']['compressed']) {
         $SWFHead = substr($SWFfileData, 0, 8);
         $SWFfileData = substr($SWFfileData, 8);
         if ($decompressed = @gzuncompress($SWFfileData)) {
             $SWFfileData = $SWFHead . $decompressed;
         } else {
             $info['error'][] = 'Error decompressing compressed SWF data (' . strlen($SWFfileData) . ' bytes compressed, should be ' . ($info['swf']['header']['length'] - 8) . ' bytes uncompressed)';
             return false;
         }
     }
     $FrameSizeBitsPerValue = (ord(substr($SWFfileData, 8, 1)) & 0xf8) >> 3;
     $FrameSizeDataLength = ceil((5 + 4 * $FrameSizeBitsPerValue) / 8);
     $FrameSizeDataString = str_pad(decbin(ord(substr($SWFfileData, 8, 1)) & 0x7), 3, '0', STR_PAD_LEFT);
     for ($i = 1; $i < $FrameSizeDataLength; $i++) {
         $FrameSizeDataString .= str_pad(decbin(ord(substr($SWFfileData, 8 + $i, 1))), 8, '0', STR_PAD_LEFT);
     }
     list($X1, $X2, $Y1, $Y2) = explode("\n", wordwrap($FrameSizeDataString, $FrameSizeBitsPerValue, "\n", 1));
     $info['swf']['header']['frame_width'] = getid3_lib::Bin2Dec($X2);
     $info['swf']['header']['frame_height'] = getid3_lib::Bin2Dec($Y2);
     // http://www-lehre.informatik.uni-osnabrueck.de/~fbstark/diplom/docs/swf/Flash_Uncovered.htm
     // Next in the header is the frame rate, which is kind of weird.
     // It is supposed to be stored as a 16bit integer, but the first byte
     // (or last depending on how you look at it) is completely ignored.
     // Example: 0x000C  ->  0x0C  ->  12     So the frame rate is 12 fps.
     // Byte at (8 + $FrameSizeDataLength) is always zero and ignored
     $info['swf']['header']['frame_rate'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 9 + $FrameSizeDataLength, 1));
     $info['swf']['header']['frame_count'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 10 + $FrameSizeDataLength, 2));
     $info['video']['frame_rate'] = $info['swf']['header']['frame_rate'];
     $info['video']['resolution_x'] = intval(round($info['swf']['header']['frame_width'] / 20));
     $info['video']['resolution_y'] = intval(round($info['swf']['header']['frame_height'] / 20));
     $info['video']['pixel_aspect_ratio'] = (double) 1;
     if ($info['swf']['header']['frame_count'] > 0 && $info['swf']['header']['frame_rate'] > 0) {
         $info['playtime_seconds'] = $info['swf']['header']['frame_count'] / $info['swf']['header']['frame_rate'];
     }
     //echo __LINE__.'='.number_format(microtime(true) - $start_time, 3).'<br>';
     // SWF tags
     $CurrentOffset = 12 + $FrameSizeDataLength;
     $SWFdataLength = strlen($SWFfileData);
     while ($CurrentOffset < $SWFdataLength) {
         //echo __LINE__.'='.number_format(microtime(true) - $start_time, 3).'<br>';
         $TagIDTagLength = getid3_lib::LittleEndian2Int(substr($SWFfileData, $CurrentOffset, 2));
         $TagID = ($TagIDTagLength & 0xfffc) >> 6;
         $TagLength = $TagIDTagLength & 0x3f;
         $CurrentOffset += 2;
         if ($TagLength == 0x3f) {
             $TagLength = getid3_lib::LittleEndian2Int(substr($SWFfileData, $CurrentOffset, 4));
             $CurrentOffset += 4;
         }
         unset($TagData);
         $TagData['offset'] = $CurrentOffset;
         $TagData['size'] = $TagLength;
         $TagData['id'] = $TagID;
         $TagData['data'] = substr($SWFfileData, $CurrentOffset, $TagLength);
         switch ($TagID) {
             case 0:
                 // end of movie
                 break 2;
             case 9:
                 // Set background color
                 //$info['swf']['tags'][] = $TagData;
                 $info['swf']['bgcolor'] = strtoupper(str_pad(dechex(getid3_lib::BigEndian2Int($TagData['data'])), 6, '0', STR_PAD_LEFT));
                 break;
             default:
                 if ($this->ReturnAllTagData) {
                     $info['swf']['tags'][] = $TagData;
                 }
                 break;
         }
         $CurrentOffset += $TagLength;
     }
     return true;
 }
開發者ID:beesheer,項目名稱:freehdfootage,代碼行數:98,代碼來源:module.audio-video.swf.php

示例3: FixedPoint2_30

 static function FixedPoint2_30($rawdata)
 {
     $binarystring = getid3_lib::BigEndian2Bin($rawdata);
     return getid3_lib::Bin2Dec(substr($binarystring, 0, 2)) + (double) (getid3_lib::Bin2Dec(substr($binarystring, 2, 30)) / 1073741824);
 }
開發者ID:par-orillonsoft,項目名稱:phpwebsite,代碼行數:5,代碼來源:getid3.lib.php

示例4: Analyze


//.........這裏部分代碼省略.........
                 $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'];
                 $thisfile_riff_raw['rgad'] = array('track' => array(), 'album' => array());
                 $thisfile_riff_raw_rgad =& $thisfile_riff_raw['rgad'];
                 $thisfile_riff_raw_rgad_track =& $thisfile_riff_raw_rgad['track'];
                 $thisfile_riff_raw_rgad_album =& $thisfile_riff_raw_rgad['album'];
                 $thisfile_riff_raw_rgad['fPeakAmplitude'] = getid3_lib::LittleEndian2Float(substr($rgadData, 0, 4));
                 $thisfile_riff_raw_rgad['nRadioRgAdjust'] = $this->EitherEndian2Int(substr($rgadData, 4, 2));
                 $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'])) {
開發者ID:harrisonsmith,項目名稱:active-progression,代碼行數:67,代碼來源:module.audio-video.riff.php

示例5: parseSTREAMINFO

 private function parseSTREAMINFO($BlockData)
 {
     $info =& $this->getid3->info;
     $info['flac']['STREAMINFO'] = array();
     $streaminfo =& $info['flac']['STREAMINFO'];
     $streaminfo['min_block_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 0, 2));
     $streaminfo['max_block_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 2, 2));
     $streaminfo['min_frame_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 4, 3));
     $streaminfo['max_frame_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 7, 3));
     $SRCSBSS = getid3_lib::BigEndian2Bin(substr($BlockData, 10, 8));
     $streaminfo['sample_rate'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 0, 20));
     $streaminfo['channels'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 20, 3)) + 1;
     $streaminfo['bits_per_sample'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 23, 5)) + 1;
     $streaminfo['samples_stream'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 28, 36));
     $streaminfo['audio_signature'] = substr($BlockData, 18, 16);
     if (!empty($streaminfo['sample_rate'])) {
         $info['audio']['bitrate_mode'] = 'vbr';
         $info['audio']['sample_rate'] = $streaminfo['sample_rate'];
         $info['audio']['channels'] = $streaminfo['channels'];
         $info['audio']['bits_per_sample'] = $streaminfo['bits_per_sample'];
         $info['playtime_seconds'] = $streaminfo['samples_stream'] / $streaminfo['sample_rate'];
         if ($info['playtime_seconds'] > 0) {
             if (!$this->isDependencyFor('matroska')) {
                 $info['audio']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
             } else {
                 $this->warning('Cannot determine audio bitrate because total stream size is unknown');
             }
         }
     } else {
         return $this->error('Corrupt METAdata block: STREAMINFO');
     }
     return true;
 }
開發者ID:kadrim1,項目名稱:metsayhistu,代碼行數:33,代碼來源:module.audio.flac.php

示例6: getAACADIFheaderFilepointer

 function getAACADIFheaderFilepointer()
 {
     $info =& $this->getid3->info;
     $info['fileformat'] = 'aac';
     $info['audio']['dataformat'] = 'aac';
     $info['audio']['lossless'] = false;
     fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     $AACheader = fread($this->getid3->fp, 1024);
     $offset = 0;
     if (substr($AACheader, 0, 4) == 'ADIF') {
         // http://faac.sourceforge.net/wiki/index.php?page=ADIF
         // http://libmpeg.org/mpeg4/doc/w2203tfs.pdf
         // adif_header() {
         //     adif_id                                32
         //     copyright_id_present                    1
         //     if( copyright_id_present )
         //         copyright_id                       72
         //     original_copy                           1
         //     home                                    1
         //     bitstream_type                          1
         //     bitrate                                23
         //     num_program_config_elements             4
         //     for (i = 0; i < num_program_config_elements + 1; i++ ) {
         //         if( bitstream_type == '0' )
         //             adif_buffer_fullness           20
         //         program_config_element()
         //     }
         // }
         $AACheaderBitstream = getid3_lib::BigEndian2Bin($AACheader);
         $bitoffset = 0;
         $info['aac']['header_type'] = 'ADIF';
         $bitoffset += 32;
         $info['aac']['header']['mpeg_version'] = 4;
         $info['aac']['header']['copyright'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
         $bitoffset += 1;
         if ($info['aac']['header']['copyright']) {
             $info['aac']['header']['copyright_id'] = getid3_lib::Bin2String(substr($AACheaderBitstream, $bitoffset, 72));
             $bitoffset += 72;
         }
         $info['aac']['header']['original_copy'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
         $bitoffset += 1;
         $info['aac']['header']['home'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
         $bitoffset += 1;
         $info['aac']['header']['is_vbr'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
         $bitoffset += 1;
         if ($info['aac']['header']['is_vbr']) {
             $info['audio']['bitrate_mode'] = 'vbr';
             $info['aac']['header']['bitrate_max'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 23));
             $bitoffset += 23;
         } else {
             $info['audio']['bitrate_mode'] = 'cbr';
             $info['aac']['header']['bitrate'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 23));
             $bitoffset += 23;
             $info['audio']['bitrate'] = $info['aac']['header']['bitrate'];
         }
         if ($info['audio']['bitrate'] == 0) {
             $info['error'][] = 'Corrupt AAC file: bitrate_audio == zero';
             return false;
         }
         $info['aac']['header']['num_program_configs'] = 1 + getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
         $bitoffset += 4;
         for ($i = 0; $i < $info['aac']['header']['num_program_configs']; $i++) {
             // http://www.audiocoding.com/wiki/index.php?page=program_config_element
             // buffer_fullness                       20
             // element_instance_tag                   4
             // object_type                            2
             // sampling_frequency_index               4
             // num_front_channel_elements             4
             // num_side_channel_elements              4
             // num_back_channel_elements              4
             // num_lfe_channel_elements               2
             // num_assoc_data_elements                3
             // num_valid_cc_elements                  4
             // mono_mixdown_present                   1
             // mono_mixdown_element_number            4   if mono_mixdown_present == 1
             // stereo_mixdown_present                 1
             // stereo_mixdown_element_number          4   if stereo_mixdown_present == 1
             // matrix_mixdown_idx_present             1
             // matrix_mixdown_idx                     2   if matrix_mixdown_idx_present == 1
             // pseudo_surround_enable                 1   if matrix_mixdown_idx_present == 1
             // for (i = 0; i < num_front_channel_elements; i++) {
             //     front_element_is_cpe[i]            1
             //     front_element_tag_select[i]        4
             // }
             // for (i = 0; i < num_side_channel_elements; i++) {
             //     side_element_is_cpe[i]             1
             //     side_element_tag_select[i]         4
             // }
             // for (i = 0; i < num_back_channel_elements; i++) {
             //     back_element_is_cpe[i]             1
             //     back_element_tag_select[i]         4
             // }
             // for (i = 0; i < num_lfe_channel_elements; i++) {
             //     lfe_element_tag_select[i]          4
             // }
             // for (i = 0; i < num_assoc_data_elements; i++) {
             //     assoc_data_element_tag_select[i]   4
             // }
             // for (i = 0; i < num_valid_cc_elements; i++) {
             //     cc_element_is_ind_sw[i]            1
//.........這裏部分代碼省略.........
開發者ID:ricofreak,項目名稱:omekaArchiveProject,代碼行數:101,代碼來源:module.audio.aac.php

示例7: ParseID3v2Frame


//.........這裏部分代碼省略.........
         $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset);
     } elseif ($id3v2_majorversion >= 3 && $parsedFrame['frame_name'] == 'PRIV') {
         // 4.27  PRIV Private frame (ID3v2.3+ only)
         //   The tag may contain more than one 'PRIV' frame
         //   but only with different contents
         // <Header for 'Private frame', ID: 'PRIV'>
         // Owner identifier      <text string> $00
         // The private data      <binary data>
         $frame_offset = 0;
         $frame_terminatorpos = @strpos($parsedFrame['data'], "", $frame_offset);
         $frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
         if (ord($frame_ownerid) === 0) {
             $frame_ownerid = '';
         }
         $frame_offset = $frame_terminatorpos + strlen("");
         $parsedFrame['ownerid'] = $frame_ownerid;
         $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset);
     } elseif ($id3v2_majorversion >= 4 && $parsedFrame['frame_name'] == 'SIGN') {
         // 4.28  SIGN Signature frame (ID3v2.4+ only)
         //   There may be more than one 'signature frame' in a tag,
         //   but no two may be identical
         // <Header for 'Signature frame', ID: 'SIGN'>
         // Group symbol      $xx
         // Signature         <binary data>
         $frame_offset = 0;
         $parsedFrame['groupsymbol'] = ord(substr($parsedFrame['data'], $frame_offset++, 1));
         $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset);
     } elseif ($id3v2_majorversion >= 4 && $parsedFrame['frame_name'] == 'SEEK') {
         // 4.29  SEEK Seek frame (ID3v2.4+ only)
         //   There may only be one 'seek frame' in a tag
         // <Header for 'Seek frame', ID: 'SEEK'>
         // Minimum offset to next tag       $xx xx xx xx
         $frame_offset = 0;
         $parsedFrame['data'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
     } elseif ($id3v2_majorversion >= 4 && $parsedFrame['frame_name'] == 'ASPI') {
         // 4.30  ASPI Audio seek point index (ID3v2.4+ only)
         //   There may only be one 'audio seek point index' frame in a tag
         // <Header for 'Seek Point Index', ID: 'ASPI'>
         // Indexed data start (S)         $xx xx xx xx
         // Indexed data length (L)        $xx xx xx xx
         // Number of index points (N)     $xx xx
         // Bits per index point (b)       $xx
         //   Then for every index point the following data is included:
         // Fraction at index (Fi)          $xx (xx)
         $frame_offset = 0;
         $parsedFrame['datastart'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
         $frame_offset += 4;
         $parsedFrame['indexeddatalength'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
         $frame_offset += 4;
         $parsedFrame['indexpoints'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 2));
         $frame_offset += 2;
         $parsedFrame['bitsperpoint'] = ord(substr($parsedFrame['data'], $frame_offset++, 1));
         $frame_bytesperpoint = ceil($parsedFrame['bitsperpoint'] / 8);
         for ($i = 0; $i < $frame_indexpoints; $i++) {
             $parsedFrame['indexes'][$i] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesperpoint));
             $frame_offset += $frame_bytesperpoint;
         }
         unset($parsedFrame['data']);
     } elseif ($id3v2_majorversion >= 3 && $parsedFrame['frame_name'] == 'RGAD') {
         // Replay Gain Adjustment
         // http://privatewww.essex.ac.uk/~djmrob/replaygain/file_format_id3v2.html
         //   There may only be one 'RGAD' frame in a tag
         // <Header for 'Replay Gain Adjustment', ID: 'RGAD'>
         // Peak Amplitude                      $xx $xx $xx $xx
         // Radio Replay Gain Adjustment        %aaabbbcd %dddddddd
         // Audiophile Replay Gain Adjustment   %aaabbbcd %dddddddd
         //   a - name code
         //   b - originator code
         //   c - sign bit
         //   d - replay gain adjustment
         $frame_offset = 0;
         $parsedFrame['peakamplitude'] = getid3_lib::BigEndian2Float(substr($parsedFrame['data'], $frame_offset, 4));
         $frame_offset += 4;
         $rg_track_adjustment = getid3_lib::Dec2Bin(substr($parsedFrame['data'], $frame_offset, 2));
         $frame_offset += 2;
         $rg_album_adjustment = getid3_lib::Dec2Bin(substr($parsedFrame['data'], $frame_offset, 2));
         $frame_offset += 2;
         $parsedFrame['raw']['track']['name'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 0, 3));
         $parsedFrame['raw']['track']['originator'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 3, 3));
         $parsedFrame['raw']['track']['signbit'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 6, 1));
         $parsedFrame['raw']['track']['adjustment'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 7, 9));
         $parsedFrame['raw']['album']['name'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 0, 3));
         $parsedFrame['raw']['album']['originator'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 3, 3));
         $parsedFrame['raw']['album']['signbit'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 6, 1));
         $parsedFrame['raw']['album']['adjustment'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 7, 9));
         $parsedFrame['track']['name'] = getid3_lib::RGADnameLookup($parsedFrame['raw']['track']['name']);
         $parsedFrame['track']['originator'] = getid3_lib::RGADoriginatorLookup($parsedFrame['raw']['track']['originator']);
         $parsedFrame['track']['adjustment'] = getid3_lib::RGADadjustmentLookup($parsedFrame['raw']['track']['adjustment'], $parsedFrame['raw']['track']['signbit']);
         $parsedFrame['album']['name'] = getid3_lib::RGADnameLookup($parsedFrame['raw']['album']['name']);
         $parsedFrame['album']['originator'] = getid3_lib::RGADoriginatorLookup($parsedFrame['raw']['album']['originator']);
         $parsedFrame['album']['adjustment'] = getid3_lib::RGADadjustmentLookup($parsedFrame['raw']['album']['adjustment'], $parsedFrame['raw']['album']['signbit']);
         $ThisFileInfo['replay_gain']['track']['peak'] = $parsedFrame['peakamplitude'];
         $ThisFileInfo['replay_gain']['track']['originator'] = $parsedFrame['track']['originator'];
         $ThisFileInfo['replay_gain']['track']['adjustment'] = $parsedFrame['track']['adjustment'];
         $ThisFileInfo['replay_gain']['album']['originator'] = $parsedFrame['album']['originator'];
         $ThisFileInfo['replay_gain']['album']['adjustment'] = $parsedFrame['album']['adjustment'];
         unset($parsedFrame['data']);
     }
     return true;
 }
開發者ID:scottatron,項目名稱:opentape,代碼行數:101,代碼來源:module.tag.id3v2.php

示例8: getAACADTSheaderFilepointer

 function getAACADTSheaderFilepointer(&$fd, &$ThisFileInfo, $MaxFramesToScan = 1000000, $ReturnExtendedInfo = false)
 {
     // based loosely on code from AACfile by Jurgen Faul  <jfaulØgmx.de>
     // http://jfaul.de/atl  or  http://j-faul.virtualave.net/atl/atl.html
     // http://faac.sourceforge.net/wiki/index.php?page=ADTS
     // * ADTS Fixed Header: these don't change from frame to frame
     // syncword                                       12    always: '111111111111'
     // ID                                              1    0: MPEG-4, 1: MPEG-2
     // layer                                           2    always: '00'
     // protection_absent                               1
     // profile                                         2
     // sampling_frequency_index                        4
     // private_bit                                     1
     // channel_configuration                           3
     // original/copy                                   1
     // home                                            1
     // emphasis                                        2    only if ID == 0 (ie MPEG-4)
     // * ADTS Variable Header: these can change from frame to frame
     // copyright_identification_bit                    1
     // copyright_identification_start                  1
     // aac_frame_length                               13    length of the frame including header (in bytes)
     // adts_buffer_fullness                           11    0x7FF indicates VBR
     // no_raw_data_blocks_in_frame                     2
     // * ADTS Error check
     // crc_check                                      16    only if protection_absent == 0
     $byteoffset = 0;
     $framenumber = 0;
     // Init bit pattern array
     static $decbin = array();
     // Populate $bindec
     for ($i = 0; $i < 256; $i++) {
         $decbin[chr($i)] = str_pad(decbin($i), 8, '0', STR_PAD_LEFT);
     }
     // used to calculate bitrate below
     $BitrateCache = array();
     while (true) {
         // breaks out when end-of-file encountered, or invalid data found,
         // or MaxFramesToScan frames have been scanned
         if ($offset >= pow(2, 31)) {
             $ThisFileInfo['warning'][] = 'Unable to parse AAC file beyond ' . ftell($fd) . ' (PHP does not support file operations beyond 2GB)';
             return false;
         }
         fseek($fd, $byteoffset, SEEK_SET);
         // First get substring
         $substring = fread($fd, 10);
         $substringlength = strlen($substring);
         if ($substringlength != 10) {
             $ThisFileInfo['error'][] = 'Failed to read 10 bytes at offset ' . (ftell($fd) - $substringlength) . ' (only read ' . $substringlength . ' bytes)';
             return false;
         }
         // Initialise $AACheaderBitstream
         $AACheaderBitstream = '';
         // Loop thru substring chars
         for ($i = 0; $i < 10; $i++) {
             $AACheaderBitstream .= $decbin[$substring[$i]];
         }
         $bitoffset = 0;
         $synctest = bindec(substr($AACheaderBitstream, $bitoffset, 12));
         $bitoffset += 12;
         if ($synctest != 0xfff) {
             $ThisFileInfo['error'][] = 'Synch pattern (0x0FFF) not found at offset ' . (ftell($fd) - 10) . ' (found 0x0' . strtoupper(dechex($synctest)) . ' instead)';
             if ($ThisFileInfo['fileformat'] == 'aac') {
                 return true;
             }
             return false;
         }
         // Gather info for first frame only - this takes time to do 1000 times!
         if ($framenumber > 0) {
             if (!$AACheaderBitstream[$bitoffset]) {
                 // MPEG-4
                 $bitoffset += 20;
             } else {
                 // MPEG-2
                 $bitoffset += 18;
             }
         } else {
             $ThisFileInfo['aac']['header_type'] = 'ADTS';
             $ThisFileInfo['aac']['header']['synch'] = $synctest;
             $ThisFileInfo['fileformat'] = 'aac';
             $ThisFileInfo['audio']['dataformat'] = 'aac';
             $ThisFileInfo['aac']['header']['mpeg_version'] = substr($AACheaderBitstream, $bitoffset, 1) == '0' ? 4 : 2;
             $bitoffset += 1;
             $ThisFileInfo['aac']['header']['layer'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
             $bitoffset += 2;
             if ($ThisFileInfo['aac']['header']['layer'] != 0) {
                 $ThisFileInfo['error'][] = 'Layer error - expected 0x00, found 0x' . dechex($ThisFileInfo['aac']['header']['layer']) . ' instead';
                 return false;
             }
             $ThisFileInfo['aac']['header']['crc_present'] = substr($AACheaderBitstream, $bitoffset, 1) == '0' ? true : false;
             $bitoffset += 1;
             $ThisFileInfo['aac']['header']['profile_id'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
             $bitoffset += 2;
             $ThisFileInfo['aac']['header']['profile_text'] = $this->AACprofileLookup($ThisFileInfo['aac']['header']['profile_id'], $ThisFileInfo['aac']['header']['mpeg_version']);
             $ThisFileInfo['aac']['header']['sample_frequency_index'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
             $bitoffset += 4;
             $ThisFileInfo['aac']['header']['sample_frequency'] = $this->AACsampleRateLookup($ThisFileInfo['aac']['header']['sample_frequency_index']);
             if ($ThisFileInfo['aac']['header']['sample_frequency'] == 0) {
                 $ThisFileInfo['error'][] = 'Corrupt AAC file: sample_frequency == zero';
                 return false;
             }
//.........這裏部分代碼省略.........
開發者ID:ekuznets,項目名稱:Tech-Noid-Systems-Legacy-,代碼行數:101,代碼來源:module.audio.aac.php

示例9: BigEndian2Float

 public static function BigEndian2Float($byte_word)
 {
     // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
     // http://www.psc.edu/general/software/packages/ieee/ieee.html
     // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
     $bit_word = getid3_lib::BigEndian2Bin($byte_word);
     if (!$bit_word) {
         return 0;
     }
     $sign_bit = $bit_word[0];
     switch (strlen($byte_word) * 8) {
         case 32:
             $exponent_bits = 8;
             $fraction_bits = 23;
             break;
         case 64:
             $exponent_bits = 11;
             $fraction_bits = 52;
             break;
         case 80:
             // 80-bit Apple SANE format
             // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
             $exponent_string = substr($bit_word, 1, 15);
             $is_normalized = intval($bit_word[16]);
             $fraction_string = substr($bit_word, 17, 63);
             $exponent = pow(2, getid3_lib::Bin2Dec($exponent_string) - 16383);
             $fraction = $is_normalized + getid3_lib::DecimalBinary2Float($fraction_string);
             $float_value = $exponent * $fraction;
             if ($sign_bit == '1') {
                 $float_value *= -1;
             }
             return $float_value;
             break;
         default:
             return false;
             break;
     }
     $exponent_string = substr($bit_word, 1, $exponent_bits);
     $fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits);
     $exponent = bindec($exponent_string);
     $fraction = bindec($fraction_string);
     if ($exponent == pow(2, $exponent_bits) - 1 && $fraction != 0) {
         // Not a Number
         $float_value = false;
     } elseif ($exponent == pow(2, $exponent_bits) - 1 && $fraction == 0) {
         if ($sign_bit == '1') {
             $float_value = '-infinity';
         } else {
             $float_value = '+infinity';
         }
     } elseif ($exponent == 0 && $fraction == 0) {
         if ($sign_bit == '1') {
             $float_value = -0;
         } else {
             $float_value = 0;
         }
         $float_value = $sign_bit ? 0 : -0;
     } elseif ($exponent == 0 && $fraction != 0) {
         // These are 'unnormalized' values
         $float_value = pow(2, -1 * (pow(2, $exponent_bits - 1) - 2)) * getid3_lib::DecimalBinary2Float($fraction_string);
         if ($sign_bit == '1') {
             $float_value *= -1;
         }
     } elseif ($exponent != 0) {
         $float_value = pow(2, $exponent - (pow(2, $exponent_bits - 1) - 1)) * (1 + getid3_lib::DecimalBinary2Float($fraction_string));
         if ($sign_bit == '1') {
             $float_value *= -1;
         }
     }
     return (double) $float_value;
 }
開發者ID:rabyunghwa,項目名稱:sslscrobbler,代碼行數:71,代碼來源:getid3.php

示例10: FLACparseSTREAMINFO

 function FLACparseSTREAMINFO($METAdataBlockData, &$ThisFileInfo)
 {
     $offset = 0;
     $ThisFileInfo['flac']['STREAMINFO']['min_block_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 2));
     $offset += 2;
     $ThisFileInfo['flac']['STREAMINFO']['max_block_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 2));
     $offset += 2;
     $ThisFileInfo['flac']['STREAMINFO']['min_frame_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 3));
     $offset += 3;
     $ThisFileInfo['flac']['STREAMINFO']['max_frame_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 3));
     $offset += 3;
     $SampleRateChannelsSampleBitsStreamSamples = getid3_lib::BigEndian2Bin(substr($METAdataBlockData, $offset, 8));
     $ThisFileInfo['flac']['STREAMINFO']['sample_rate'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 0, 20));
     $ThisFileInfo['flac']['STREAMINFO']['channels'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 20, 3)) + 1;
     $ThisFileInfo['flac']['STREAMINFO']['bits_per_sample'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 23, 5)) + 1;
     $ThisFileInfo['flac']['STREAMINFO']['samples_stream'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 28, 36));
     $offset += 8;
     $ThisFileInfo['flac']['STREAMINFO']['audio_signature'] = substr($METAdataBlockData, $offset, 16);
     $offset += 16;
     if (!empty($ThisFileInfo['flac']['STREAMINFO']['sample_rate'])) {
         $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
         $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['flac']['STREAMINFO']['sample_rate'];
         $ThisFileInfo['audio']['channels'] = $ThisFileInfo['flac']['STREAMINFO']['channels'];
         $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['flac']['STREAMINFO']['bits_per_sample'];
         $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['flac']['STREAMINFO']['samples_stream'] / $ThisFileInfo['flac']['STREAMINFO']['sample_rate'];
         $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['playtime_seconds'];
     } else {
         $ThisFileInfo['error'][] = 'Corrupt METAdata block: STREAMINFO';
         return false;
     }
     return true;
 }
開發者ID:artistafrustrado,項目名稱:debaser-diaadiaeducacao,代碼行數:32,代碼來源:module.audio.flac.php

示例11: ParseID3v2Frame


//.........這裏部分代碼省略.........
         $frame_offset = 0;
         $parsedFrame['datastart'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
         $frame_offset += 4;
         $parsedFrame['indexeddatalength'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
         $frame_offset += 4;
         $parsedFrame['indexpoints'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 2));
         $frame_offset += 2;
         $parsedFrame['bitsperpoint'] = ord(substr($parsedFrame['data'], $frame_offset++, 1));
         $frame_bytesperpoint = ceil($parsedFrame['bitsperpoint'] / 8);
         for ($i = 0; $i < $parsedFrame['indexpoints']; $i++) {
             $parsedFrame['indexes'][$i] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesperpoint));
             $frame_offset += $frame_bytesperpoint;
         }
         unset($parsedFrame['data']);
     } elseif ($id3v2_majorversion >= 3 && $parsedFrame['frame_name'] == 'RGAD') {
         // Replay Gain Adjustment
         // http://privatewww.essex.ac.uk/~djmrob/replaygain/file_format_id3v2.html
         //   There may only be one 'RGAD' frame in a tag
         // <Header for 'Replay Gain Adjustment', ID: 'RGAD'>
         // Peak Amplitude                      $xx $xx $xx $xx
         // Radio Replay Gain Adjustment        %aaabbbcd %dddddddd
         // Audiophile Replay Gain Adjustment   %aaabbbcd %dddddddd
         //   a - name code
         //   b - originator code
         //   c - sign bit
         //   d - replay gain adjustment
         $frame_offset = 0;
         $parsedFrame['peakamplitude'] = getid3_lib::BigEndian2Float(substr($parsedFrame['data'], $frame_offset, 4));
         $frame_offset += 4;
         $rg_track_adjustment = getid3_lib::Dec2Bin(substr($parsedFrame['data'], $frame_offset, 2));
         $frame_offset += 2;
         $rg_album_adjustment = getid3_lib::Dec2Bin(substr($parsedFrame['data'], $frame_offset, 2));
         $frame_offset += 2;
         $parsedFrame['raw']['track']['name'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 0, 3));
         $parsedFrame['raw']['track']['originator'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 3, 3));
         $parsedFrame['raw']['track']['signbit'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 6, 1));
         $parsedFrame['raw']['track']['adjustment'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 7, 9));
         $parsedFrame['raw']['album']['name'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 0, 3));
         $parsedFrame['raw']['album']['originator'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 3, 3));
         $parsedFrame['raw']['album']['signbit'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 6, 1));
         $parsedFrame['raw']['album']['adjustment'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 7, 9));
         $parsedFrame['track']['name'] = getid3_lib::RGADnameLookup($parsedFrame['raw']['track']['name']);
         $parsedFrame['track']['originator'] = getid3_lib::RGADoriginatorLookup($parsedFrame['raw']['track']['originator']);
         $parsedFrame['track']['adjustment'] = getid3_lib::RGADadjustmentLookup($parsedFrame['raw']['track']['adjustment'], $parsedFrame['raw']['track']['signbit']);
         $parsedFrame['album']['name'] = getid3_lib::RGADnameLookup($parsedFrame['raw']['album']['name']);
         $parsedFrame['album']['originator'] = getid3_lib::RGADoriginatorLookup($parsedFrame['raw']['album']['originator']);
         $parsedFrame['album']['adjustment'] = getid3_lib::RGADadjustmentLookup($parsedFrame['raw']['album']['adjustment'], $parsedFrame['raw']['album']['signbit']);
         $info['replay_gain']['track']['peak'] = $parsedFrame['peakamplitude'];
         $info['replay_gain']['track']['originator'] = $parsedFrame['track']['originator'];
         $info['replay_gain']['track']['adjustment'] = $parsedFrame['track']['adjustment'];
         $info['replay_gain']['album']['originator'] = $parsedFrame['album']['originator'];
         $info['replay_gain']['album']['adjustment'] = $parsedFrame['album']['adjustment'];
         unset($parsedFrame['data']);
     } elseif ($id3v2_majorversion >= 3 && $parsedFrame['frame_name'] == 'CHAP') {
         // CHAP Chapters frame (ID3v2.3+ only)
         // http://id3.org/id3v2-chapters-1.0
         // <ID3v2.3 or ID3v2.4 frame header, ID: "CHAP">           (10 bytes)
         // Element ID      <text string> $00
         // Start time      $xx xx xx xx
         // End time        $xx xx xx xx
         // Start offset    $xx xx xx xx
         // End offset      $xx xx xx xx
         // <Optional embedded sub-frames>
         $frame_offset = 0;
         @(list($parsedFrame['element_id']) = explode("", $parsedFrame['data'], 2));
         $frame_offset += strlen($parsedFrame['element_id'] . "");
開發者ID:kadrim1,項目名稱:metsayhistu,代碼行數:67,代碼來源:module.tag.id3v2.php

示例12: getid3_mpeg

 function getid3_mpeg(&$fd, &$ThisFileInfo)
 {
     if ($ThisFileInfo['avdataend'] <= $ThisFileInfo['avdataoffset']) {
         $ThisFileInfo['error'][] = '"avdataend" (' . $ThisFileInfo['avdataend'] . ') is unexpectedly less-than-or-equal-to "avdataoffset" (' . $ThisFileInfo['avdataoffset'] . ')';
         return false;
     }
     $ThisFileInfo['fileformat'] = 'mpeg';
     fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
     $MPEGstreamData = fread($fd, min(100000, $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']));
     $MPEGstreamDataLength = strlen($MPEGstreamData);
     $foundVideo = true;
     $VideoChunkOffset = 0;
     while (substr($MPEGstreamData, $VideoChunkOffset++, 4) !== GETID3_MPEG_VIDEO_SEQUENCE_HEADER) {
         if ($VideoChunkOffset >= $MPEGstreamDataLength) {
             $foundVideo = false;
             break;
         }
     }
     if ($foundVideo) {
         // Start code                       32 bits
         // horizontal frame size            12 bits
         // vertical frame size              12 bits
         // pixel aspect ratio                4 bits
         // frame rate                        4 bits
         // bitrate                          18 bits
         // marker bit                        1 bit
         // VBV buffer size                  10 bits
         // constrained parameter flag        1 bit
         // intra quant. matrix flag          1 bit
         // intra quant. matrix values      512 bits (present if matrix flag == 1)
         // non-intra quant. matrix flag      1 bit
         // non-intra quant. matrix values  512 bits (present if matrix flag == 1)
         $ThisFileInfo['video']['dataformat'] = 'mpeg';
         $VideoChunkOffset += strlen(GETID3_MPEG_VIDEO_SEQUENCE_HEADER) - 1;
         $FrameSizeDWORD = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $VideoChunkOffset, 3));
         $VideoChunkOffset += 3;
         $AspectRatioFrameRateDWORD = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $VideoChunkOffset, 1));
         $VideoChunkOffset += 1;
         $assortedinformation = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 4));
         $VideoChunkOffset += 4;
         $ThisFileInfo['mpeg']['video']['raw']['framesize_horizontal'] = ($FrameSizeDWORD & 0xfff000) >> 12;
         // 12 bits for horizontal frame size
         $ThisFileInfo['mpeg']['video']['raw']['framesize_vertical'] = $FrameSizeDWORD & 0xfff;
         // 12 bits for vertical frame size
         $ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio'] = ($AspectRatioFrameRateDWORD & 0xf0) >> 4;
         $ThisFileInfo['mpeg']['video']['raw']['frame_rate'] = $AspectRatioFrameRateDWORD & 0xf;
         $ThisFileInfo['mpeg']['video']['framesize_horizontal'] = $ThisFileInfo['mpeg']['video']['raw']['framesize_horizontal'];
         $ThisFileInfo['mpeg']['video']['framesize_vertical'] = $ThisFileInfo['mpeg']['video']['raw']['framesize_vertical'];
         $ThisFileInfo['mpeg']['video']['pixel_aspect_ratio'] = $this->MPEGvideoAspectRatioLookup($ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio']);
         $ThisFileInfo['mpeg']['video']['pixel_aspect_ratio_text'] = $this->MPEGvideoAspectRatioTextLookup($ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio']);
         $ThisFileInfo['mpeg']['video']['frame_rate'] = $this->MPEGvideoFramerateLookup($ThisFileInfo['mpeg']['video']['raw']['frame_rate']);
         $ThisFileInfo['mpeg']['video']['raw']['bitrate'] = getid3_lib::Bin2Dec(substr($assortedinformation, 0, 18));
         $ThisFileInfo['mpeg']['video']['raw']['marker_bit'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 18, 1));
         $ThisFileInfo['mpeg']['video']['raw']['vbv_buffer_size'] = getid3_lib::Bin2Dec(substr($assortedinformation, 19, 10));
         $ThisFileInfo['mpeg']['video']['raw']['constrained_param_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 29, 1));
         $ThisFileInfo['mpeg']['video']['raw']['intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 30, 1));
         if ($ThisFileInfo['mpeg']['video']['raw']['intra_quant_flag']) {
             // read 512 bits
             $ThisFileInfo['mpeg']['video']['raw']['intra_quant'] = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64));
             $VideoChunkOffset += 64;
             $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($ThisFileInfo['mpeg']['video']['raw']['intra_quant'], 511, 1));
             $ThisFileInfo['mpeg']['video']['raw']['intra_quant'] = getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1)) . substr(getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64)), 0, 511);
             if ($ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag']) {
                 $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
                 $VideoChunkOffset += 64;
             }
         } else {
             $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1));
             if ($ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag']) {
                 $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
                 $VideoChunkOffset += 64;
             }
         }
         if ($ThisFileInfo['mpeg']['video']['raw']['bitrate'] == 0x3ffff) {
             // 18 set bits
             $ThisFileInfo['warning'][] = 'This version of getID3() [' . GETID3_VERSION . '] cannot determine average bitrate of VBR MPEG video files';
             $ThisFileInfo['mpeg']['video']['bitrate_mode'] = 'vbr';
         } else {
             $ThisFileInfo['mpeg']['video']['bitrate'] = $ThisFileInfo['mpeg']['video']['raw']['bitrate'] * 400;
             $ThisFileInfo['mpeg']['video']['bitrate_mode'] = 'cbr';
             $ThisFileInfo['video']['bitrate'] = $ThisFileInfo['mpeg']['video']['bitrate'];
         }
         $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['mpeg']['video']['framesize_horizontal'];
         $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['mpeg']['video']['framesize_vertical'];
         $ThisFileInfo['video']['frame_rate'] = $ThisFileInfo['mpeg']['video']['frame_rate'];
         $ThisFileInfo['video']['bitrate_mode'] = $ThisFileInfo['mpeg']['video']['bitrate_mode'];
         $ThisFileInfo['video']['pixel_aspect_ratio'] = $ThisFileInfo['mpeg']['video']['pixel_aspect_ratio'];
         $ThisFileInfo['video']['lossless'] = false;
         $ThisFileInfo['video']['bits_per_sample'] = 24;
     } else {
         $ThisFileInfo['error'][] = 'Could not find start of video block in the first 100,000 bytes (or before end of file) - this might not be an MPEG-video file?';
     }
     //0x000001B3 begins the sequence_header of every MPEG video stream.
     //But in MPEG-2, this header must immediately be followed by an
     //extension_start_code (0x000001B5) with a sequence_extension ID (1).
     //(This extension contains all the additional MPEG-2 stuff.)
     //MPEG-1 doesn't have this extension, so that's a sure way to tell the
     //difference between MPEG-1 and MPEG-2 video streams.
     if (substr($MPEGstreamData, $VideoChunkOffset, 4) == GETID3_MPEG_VIDEO_EXTENSION_START) {
         $ThisFileInfo['video']['codec'] = 'MPEG-2';
//.........這裏部分代碼省略.........
開發者ID:BGCX261,項目名稱:zoom-gallery-svn-to-git,代碼行數:101,代碼來源:module.audio-video.mpeg.php


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