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


PHP getid3_lib::safe_inc方法代碼示例

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


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

示例1: parseSEEKTABLE

 private function parseSEEKTABLE($BlockData)
 {
     $info =& $this->getid3->info;
     $offset = 0;
     $BlockLength = strlen($BlockData);
     $placeholderpattern = str_repeat("ÿ", 8);
     while ($offset < $BlockLength) {
         $SampleNumberString = substr($BlockData, $offset, 8);
         $offset += 8;
         if ($SampleNumberString == $placeholderpattern) {
             // placeholder point
             getid3_lib::safe_inc($info['flac']['SEEKTABLE']['placeholders'], 1);
             $offset += 10;
         } else {
             $SampleNumber = getid3_lib::BigEndian2Int($SampleNumberString);
             $info['flac']['SEEKTABLE'][$SampleNumber]['offset'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
             $offset += 8;
             $info['flac']['SEEKTABLE'][$SampleNumber]['samples'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 2));
             $offset += 2;
         }
     }
     return true;
 }
開發者ID:kadrim1,項目名稱:metsayhistu,代碼行數:23,代碼來源:module.audio.flac.php

示例2: getAACADTSheaderFilepointer


//.........這裏部分代碼省略.........
         }
         // this would be easier with 64-bit math, but split it up to allow for 32-bit:
         $header1 = getid3_lib::BigEndian2Int(substr($substring, 0, 2));
         $header2 = getid3_lib::BigEndian2Int(substr($substring, 2, 4));
         $header3 = getid3_lib::BigEndian2Int(substr($substring, 6, 1));
         $info['aac']['header']['raw']['syncword'] = ($header1 & 0xfff0) >> 4;
         if ($info['aac']['header']['raw']['syncword'] != 0xfff) {
             $info['error'][] = 'Synch pattern (0x0FFF) not found at offset ' . (ftell($this->getid3->fp) - $substringlength) . ' (found 0x0' . strtoupper(dechex($info['aac']['header']['raw']['syncword'])) . ' instead)';
             //if ($info['fileformat'] == 'aac') {
             //	return true;
             //}
             unset($info['aac']);
             return false;
         }
         // Gather info for first frame only - this takes time to do 1000 times!
         if ($framenumber == 0) {
             $info['aac']['header_type'] = 'ADTS';
             $info['fileformat'] = 'aac';
             $info['audio']['dataformat'] = 'aac';
             $info['aac']['header']['raw']['mpeg_version'] = ($header1 & 0x8) >> 3;
             $info['aac']['header']['raw']['mpeg_layer'] = ($header1 & 0x6) >> 1;
             $info['aac']['header']['raw']['protection_absent'] = ($header1 & 0x1) >> 0;
             $info['aac']['header']['raw']['profile_code'] = ($header2 & 0xc0000000) >> 30;
             $info['aac']['header']['raw']['sample_rate_code'] = ($header2 & 0x3c000000) >> 26;
             $info['aac']['header']['raw']['private_stream'] = ($header2 & 0x2000000) >> 25;
             $info['aac']['header']['raw']['channels_code'] = ($header2 & 0x1c00000) >> 22;
             $info['aac']['header']['raw']['original'] = ($header2 & 0x200000) >> 21;
             $info['aac']['header']['raw']['home'] = ($header2 & 0x100000) >> 20;
             $info['aac']['header']['raw']['copyright_stream'] = ($header2 & 0x80000) >> 19;
             $info['aac']['header']['raw']['copyright_start'] = ($header2 & 0x40000) >> 18;
             $info['aac']['header']['raw']['frame_length'] = ($header2 & 0x3ffe0) >> 5;
             $info['aac']['header']['mpeg_version'] = $info['aac']['header']['raw']['mpeg_version'] ? 2 : 4;
             $info['aac']['header']['crc_present'] = $info['aac']['header']['raw']['protection_absent'] ? false : true;
             $info['aac']['header']['profile'] = self::AACprofileLookup($info['aac']['header']['raw']['profile_code'], $info['aac']['header']['mpeg_version']);
             $info['aac']['header']['sample_frequency'] = self::AACsampleRateLookup($info['aac']['header']['raw']['sample_rate_code']);
             $info['aac']['header']['private'] = (bool) $info['aac']['header']['raw']['private_stream'];
             $info['aac']['header']['original'] = (bool) $info['aac']['header']['raw']['original'];
             $info['aac']['header']['home'] = (bool) $info['aac']['header']['raw']['home'];
             $info['aac']['header']['channels'] = $info['aac']['header']['raw']['channels_code'] == 7 ? 8 : $info['aac']['header']['raw']['channels_code'];
             if ($ReturnExtendedInfo) {
                 $info['aac'][$framenumber]['copyright_id_bit'] = (bool) $info['aac']['header']['raw']['copyright_stream'];
                 $info['aac'][$framenumber]['copyright_id_start'] = (bool) $info['aac']['header']['raw']['copyright_start'];
             }
             if ($info['aac']['header']['raw']['mpeg_layer'] != 0) {
                 $info['warning'][] = 'Layer error - expected "0", found "' . $info['aac']['header']['raw']['mpeg_layer'] . '" instead';
             }
             if ($info['aac']['header']['sample_frequency'] == 0) {
                 $info['error'][] = 'Corrupt AAC file: sample_frequency == zero';
                 return false;
             }
             $info['audio']['sample_rate'] = $info['aac']['header']['sample_frequency'];
             $info['audio']['channels'] = $info['aac']['header']['channels'];
         }
         $FrameLength = ($header2 & 0x3ffe0) >> 5;
         if (!isset($BitrateCache[$FrameLength])) {
             $BitrateCache[$FrameLength] = $info['aac']['header']['sample_frequency'] / 1024 * $FrameLength * 8;
         }
         getid3_lib::safe_inc($info['aac']['bitrate_distribution'][$BitrateCache[$FrameLength]], 1);
         $info['aac'][$framenumber]['aac_frame_length'] = $FrameLength;
         $info['aac'][$framenumber]['adts_buffer_fullness'] = ($header2 & 0x1f) << 6 & ($header3 & 0xfc) >> 2;
         if ($info['aac'][$framenumber]['adts_buffer_fullness'] == 0x7ff) {
             $info['audio']['bitrate_mode'] = 'vbr';
         } else {
             $info['audio']['bitrate_mode'] = 'cbr';
         }
         $info['aac'][$framenumber]['num_raw_data_blocks'] = ($header3 & 0x3) >> 0;
         if ($info['aac']['header']['crc_present']) {
             //$info['aac'][$framenumber]['crc'] = getid3_lib::BigEndian2Int(substr($substring, 7, 2);
         }
         if (!$ReturnExtendedInfo) {
             unset($info['aac'][$framenumber]);
         }
         /*
         $rounded_precision = 5000;
         $info['aac']['bitrate_distribution_rounded'] = array();
         foreach ($info['aac']['bitrate_distribution'] as $bitrate => $count) {
         	$rounded_bitrate = round($bitrate / $rounded_precision) * $rounded_precision;
         	getid3_lib::safe_inc($info['aac']['bitrate_distribution_rounded'][$rounded_bitrate], $count);
         }
         ksort($info['aac']['bitrate_distribution_rounded']);
         */
         $byteoffset += $FrameLength;
         if (++$framenumber < $MaxFramesToScan && $byteoffset + 10 < $info['avdataend']) {
             // keep scanning
         } else {
             $info['aac']['frames'] = $framenumber;
             $info['playtime_seconds'] = $info['avdataend'] / $byteoffset * ($framenumber * 1024 / $info['aac']['header']['sample_frequency']);
             // (1 / % of file scanned) * (samples / (samples/sec)) = seconds
             if ($info['playtime_seconds'] == 0) {
                 $info['error'][] = 'Corrupt AAC file: playtime_seconds == zero';
                 return false;
             }
             $info['audio']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
             ksort($info['aac']['bitrate_distribution']);
             $info['audio']['encoder_options'] = $info['aac']['header_type'] . ' ' . $info['aac']['header']['profile'];
             return true;
         }
     }
     // should never get here.
 }
開發者ID:ricofreak,項目名稱:omekaArchiveProject,代碼行數:101,代碼來源:module.audio.aac.php

示例3: getOnlyMPEGaudioInfo


//.........這裏部分代碼省略.........
                     $this_scan_segment = 0;
                     $frames_scan_per_segment = ceil($max_frames_scan / $max_scan_segments);
                     $pct_data_scanned = 0;
                     for ($current_segment = 0; $current_segment < $max_scan_segments; $current_segment++) {
                         $frames_scanned_this_segment = 0;
                         if ($this->ftell() >= $info['avdataend']) {
                             break;
                         }
                         $scan_start_offset[$current_segment] = max($this->ftell(), $info['avdataoffset'] + round($current_segment * (($info['avdataend'] - $info['avdataoffset']) / $max_scan_segments)));
                         if ($current_segment > 0) {
                             $this->fseek($scan_start_offset[$current_segment]);
                             $buffer_4k = $this->fread(4096);
                             for ($j = 0; $j < strlen($buffer_4k) - 4; $j++) {
                                 if ($buffer_4k[$j] == "ÿ" && $buffer_4k[$j + 1] > "à") {
                                     // synch detected
                                     if ($this->decodeMPEGaudioHeader($scan_start_offset[$current_segment] + $j, $dummy, false, false, $FastMode)) {
                                         $calculated_next_offset = $scan_start_offset[$current_segment] + $j + $dummy['mpeg']['audio']['framelength'];
                                         if ($this->decodeMPEGaudioHeader($calculated_next_offset, $dummy, false, false, $FastMode)) {
                                             $scan_start_offset[$current_segment] += $j;
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                         $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;
開發者ID:rauldobrota,項目名稱:zenphoto,代碼行數:67,代碼來源:module.audio.mp3.php

示例4: 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

示例5: getAACADTSheaderFilepointer


//.........這裏部分代碼省略.........
         }
         // 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;
             }
             $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['aac']['header']['sample_frequency'];
             $ThisFileInfo['aac']['header']['private'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
             $bitoffset += 1;
             $ThisFileInfo['aac']['header']['channel_configuration'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 3));
             $bitoffset += 3;
             $ThisFileInfo['audio']['channels'] = $ThisFileInfo['aac']['header']['channel_configuration'];
             $ThisFileInfo['aac']['header']['original'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
             $bitoffset += 1;
             $ThisFileInfo['aac']['header']['home'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
             $bitoffset += 1;
             if ($ThisFileInfo['aac']['header']['mpeg_version'] == 4) {
                 $ThisFileInfo['aac']['header']['emphasis'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
                 $bitoffset += 2;
             }
             if ($ReturnExtendedInfo) {
                 $ThisFileInfo['aac'][$framenumber]['copyright_id_bit'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
                 $bitoffset += 1;
                 $ThisFileInfo['aac'][$framenumber]['copyright_id_start'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
                 $bitoffset += 1;
             } else {
                 $bitoffset += 2;
             }
         }
         $FrameLength = bindec(substr($AACheaderBitstream, $bitoffset, 13));
         if (!isset($BitrateCache[$FrameLength])) {
             $BitrateCache[$FrameLength] = $ThisFileInfo['aac']['header']['sample_frequency'] / 1024 * $FrameLength * 8;
         }
         getid3_lib::safe_inc($ThisFileInfo['aac']['bitrate_distribution'][$BitrateCache[$FrameLength]], 1);
         $ThisFileInfo['aac'][$framenumber]['aac_frame_length'] = $FrameLength;
         $bitoffset += 13;
         $ThisFileInfo['aac'][$framenumber]['adts_buffer_fullness'] = bindec(substr($AACheaderBitstream, $bitoffset, 11));
         $bitoffset += 11;
         if ($ThisFileInfo['aac'][$framenumber]['adts_buffer_fullness'] == 0x7ff) {
             $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
         } else {
             $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
         }
         $ThisFileInfo['aac'][$framenumber]['num_raw_data_blocks'] = bindec(substr($AACheaderBitstream, $bitoffset, 2));
         $bitoffset += 2;
         if ($ThisFileInfo['aac']['header']['crc_present']) {
             //$ThisFileInfo['aac'][$framenumber]['crc']              = bindec(substr($AACheaderBitstream, $bitoffset, 16));
             $bitoffset += 16;
         }
         if (!$ReturnExtendedInfo) {
             unset($ThisFileInfo['aac'][$framenumber]);
         }
         $byteoffset += $FrameLength;
         if (++$framenumber < $MaxFramesToScan && $byteoffset + 10 < $ThisFileInfo['avdataend']) {
             // keep scanning
         } else {
             $ThisFileInfo['aac']['frames'] = $framenumber;
             $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['avdataend'] / $byteoffset * ($framenumber * 1024 / $ThisFileInfo['aac']['header']['sample_frequency']);
             // (1 / % of file scanned) * (samples / (samples/sec)) = seconds
             if ($ThisFileInfo['playtime_seconds'] == 0) {
                 $ThisFileInfo['error'][] = 'Corrupt AAC file: playtime_seconds == zero';
                 return false;
             }
             $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['playtime_seconds'];
             ksort($ThisFileInfo['aac']['bitrate_distribution']);
             $ThisFileInfo['audio']['encoder_options'] = $ThisFileInfo['aac']['header_type'] . ' ' . $ThisFileInfo['aac']['header']['profile_text'];
             return true;
         }
     }
     // should never get here.
 }
開發者ID:par-orillonsoft,項目名稱:phpwebsite,代碼行數:101,代碼來源:module.audio.aac.php

示例6: getOnlyMPEGaudioInfoBruteForce

 public function getOnlyMPEGaudioInfoBruteForce()
 {
     $MPEGaudioHeaderDecodeCache = array();
     $MPEGaudioHeaderValidCache = array();
     $MPEGaudioHeaderLengthCache = array();
     $MPEGaudioVersionLookup = self::MPEGaudioVersionArray();
     $MPEGaudioLayerLookup = self::MPEGaudioLayerArray();
     $MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray();
     $MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray();
     $MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray();
     $MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray();
     $MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray();
     $LongMPEGversionLookup = array();
     $LongMPEGlayerLookup = array();
     $LongMPEGbitrateLookup = array();
     $LongMPEGpaddingLookup = array();
     $LongMPEGfrequencyLookup = array();
     $Distribution['bitrate'] = array();
     $Distribution['frequency'] = array();
     $Distribution['layer'] = array();
     $Distribution['version'] = array();
     $Distribution['padding'] = array();
     $info =& $this->getid3->info;
     $this->fseek($info['avdataoffset']);
     $max_frames_scan = 5000;
     $frames_scanned = 0;
     $previousvalidframe = $info['avdataoffset'];
     while ($this->ftell() < $info['avdataend']) {
         set_time_limit(30);
         $head4 = $this->fread(4);
         if (strlen($head4) < 4) {
             break;
         }
         if ($head4[0] != "ÿ") {
             for ($i = 1; $i < 4; $i++) {
                 if ($head4[$i] == "ÿ") {
                     $this->fseek($i - 4, SEEK_CUR);
                     continue 2;
                 }
             }
             continue;
         }
         if (!isset($MPEGaudioHeaderDecodeCache[$head4])) {
             $MPEGaudioHeaderDecodeCache[$head4] = self::MPEGaudioHeaderDecode($head4);
         }
         if (!isset($MPEGaudioHeaderValidCache[$head4])) {
             $MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$head4], false, false);
         }
         if ($MPEGaudioHeaderValidCache[$head4]) {
             if (!isset($MPEGaudioHeaderLengthCache[$head4])) {
                 $LongMPEGversionLookup[$head4] = $MPEGaudioVersionLookup[$MPEGaudioHeaderDecodeCache[$head4]['version']];
                 $LongMPEGlayerLookup[$head4] = $MPEGaudioLayerLookup[$MPEGaudioHeaderDecodeCache[$head4]['layer']];
                 $LongMPEGbitrateLookup[$head4] = $MPEGaudioBitrateLookup[$LongMPEGversionLookup[$head4]][$LongMPEGlayerLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['bitrate']];
                 $LongMPEGpaddingLookup[$head4] = (bool) $MPEGaudioHeaderDecodeCache[$head4]['padding'];
                 $LongMPEGfrequencyLookup[$head4] = $MPEGaudioFrequencyLookup[$LongMPEGversionLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['sample_rate']];
                 $MPEGaudioHeaderLengthCache[$head4] = self::MPEGaudioFrameLength($LongMPEGbitrateLookup[$head4], $LongMPEGversionLookup[$head4], $LongMPEGlayerLookup[$head4], $LongMPEGpaddingLookup[$head4], $LongMPEGfrequencyLookup[$head4]);
             }
             if ($MPEGaudioHeaderLengthCache[$head4] > 4) {
                 $WhereWeWere = $this->ftell();
                 $this->fseek($MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR);
                 $next4 = $this->fread(4);
                 if ($next4[0] == "ÿ") {
                     if (!isset($MPEGaudioHeaderDecodeCache[$next4])) {
                         $MPEGaudioHeaderDecodeCache[$next4] = self::MPEGaudioHeaderDecode($next4);
                     }
                     if (!isset($MPEGaudioHeaderValidCache[$next4])) {
                         $MPEGaudioHeaderValidCache[$next4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false);
                     }
                     if ($MPEGaudioHeaderValidCache[$next4]) {
                         $this->fseek(-4, SEEK_CUR);
                         getid3_lib::safe_inc($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]);
                         getid3_lib::safe_inc($Distribution['layer'][$LongMPEGlayerLookup[$head4]]);
                         getid3_lib::safe_inc($Distribution['version'][$LongMPEGversionLookup[$head4]]);
                         getid3_lib::safe_inc($Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]);
                         getid3_lib::safe_inc($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]);
                         if ($max_frames_scan && ++$frames_scanned >= $max_frames_scan) {
                             $pct_data_scanned = ($this->ftell() - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']);
                             $info['warning'][] = 'too many MPEG audio frames to scan, only scanned first ' . $max_frames_scan . ' frames (' . number_format($pct_data_scanned * 100, 1) . '% of file) and extrapolated distribution, playtime and bitrate may be incorrect.';
                             foreach ($Distribution as $key1 => $value1) {
                                 foreach ($value1 as $key2 => $value2) {
                                     $Distribution[$key1][$key2] = round($value2 / $pct_data_scanned);
                                 }
                             }
                             break;
                         }
                         continue;
                     }
                 }
                 unset($next4);
                 $this->fseek($WhereWeWere - 3);
             }
         }
     }
     foreach ($Distribution as $key => $value) {
         ksort($Distribution[$key], SORT_NUMERIC);
     }
     ksort($Distribution['version'], SORT_STRING);
     $info['mpeg']['audio']['bitrate_distribution'] = $Distribution['bitrate'];
     $info['mpeg']['audio']['frequency_distribution'] = $Distribution['frequency'];
     $info['mpeg']['audio']['layer_distribution'] = $Distribution['layer'];
//.........這裏部分代碼省略.........
開發者ID:kadrim1,項目名稱:metsayhistu,代碼行數:101,代碼來源:module.audio.mp3.php


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