当前位置: 首页>>代码示例>>PHP>>正文


PHP getid3_riff::AnalyzeString方法代码示例

本文整理汇总了PHP中getid3_riff::AnalyzeString方法的典型用法代码示例。如果您正苦于以下问题:PHP getid3_riff::AnalyzeString方法的具体用法?PHP getid3_riff::AnalyzeString怎么用?PHP getid3_riff::AnalyzeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在getid3_riff的用法示例。


在下文中一共展示了getid3_riff::AnalyzeString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ParseOptimFROGheader45


//.........这里部分代码省略.........
                 $getid3->info['audio']['sample_rate'] = $info_ofr_this_block['sample_rate'];
                 $getid3->info['audio']['bits_per_sample'] = $this->OptimFROGbitsPerSampleTypeLookup($info_ofr_this_block['raw']['sample_type']);
                 break;
             case 'COMP':
                 // unlike other block types, there CAN be multiple COMP blocks
                 $comp_data['offset'] = $block_offset;
                 $comp_data['size'] = $block_size;
                 if ($getid3->info['avdataoffset'] == 0) {
                     $getid3->info['avdataoffset'] = $block_offset;
                 }
                 // Only interested in first 14 bytes (only first 12 needed for v4.50 alpha), not actual audio data
                 $block_data .= fread($getid3->fp, 14);
                 fseek($getid3->fp, $block_size - 14, SEEK_CUR);
                 $comp_data['crc_32'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 4));
                 $offset += 4;
                 $comp_data['sample_count'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 4));
                 $offset += 4;
                 $comp_data['raw']['sample_type'] = getid3_lib::LittleEndian2Int($block_data[$offset++]);
                 $comp_data['sample_type'] = $this->OptimFROGsampleTypeLookup($comp_data['raw']['sample_type']);
                 $comp_data['raw']['channel_configuration'] = getid3_lib::LittleEndian2Int($block_data[$offset++]);
                 $comp_data['channel_configuration'] = $this->OptimFROGchannelConfigurationLookup($comp_data['raw']['channel_configuration']);
                 $comp_data['raw']['algorithm_id'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 2));
                 $offset += 2;
                 if ($getid3->info['ofr']['OFR ']['size'] > 12) {
                     // OFR 4.504b or higher
                     $comp_data['raw']['encoder_id'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 2));
                     $comp_data['encoder'] = $this->OptimFROGencoderNameLookup($comp_data['raw']['encoder_id']);
                     $offset += 2;
                 }
                 if ($comp_data['crc_32'] == 0x454e4f4e) {
                     // ASCII value of 'NONE' - placeholder value in v4.50a
                     $comp_data['crc_32'] = false;
                 }
                 $info_ofr_this_block[] = $comp_data;
                 break;
             case 'HEAD':
                 $info_ofr_this_block['offset'] = $block_offset;
                 $info_ofr_this_block['size'] = $block_size;
                 $riff_data .= fread($getid3->fp, $block_size);
                 break;
             case 'TAIL':
                 $info_ofr_this_block['offset'] = $block_offset;
                 $info_ofr_this_block['size'] = $block_size;
                 if ($block_size > 0) {
                     $riff_data .= fread($getid3->fp, $block_size);
                 }
                 break;
             case 'RECV':
                 // block contains no useful meta data - simply note and skip
                 $info_ofr_this_block['offset'] = $block_offset;
                 $info_ofr_this_block['size'] = $block_size;
                 fseek($getid3->fp, $block_size, SEEK_CUR);
                 break;
             case 'APET':
                 // APEtag v2
                 $info_ofr_this_block['offset'] = $block_offset;
                 $info_ofr_this_block['size'] = $block_size;
                 $getid3->warning('APEtag processing inside OptimFROG not supported in this version (' . GETID3_VERSION . ') of getID3()');
                 fseek($getid3->fp, $block_size, SEEK_CUR);
                 break;
             case 'MD5 ':
                 // APEtag v2
                 $info_ofr_this_block['offset'] = $block_offset;
                 $info_ofr_this_block['size'] = $block_size;
                 if ($block_size == 16) {
                     $info_ofr_this_block['md5_binary'] = fread($getid3->fp, $block_size);
                     $info_ofr_this_block['md5_string'] = getid3_lib::PrintHexBytes($info_ofr_this_block['md5_binary'], true, false, false);
                     $getid3->info['md5_data_source'] = $info_ofr_this_block['md5_string'];
                 } else {
                     $getid3->warning('Expecting block size of 16 in "MD5 " chunk, found ' . $block_size . ' instead');
                     fseek($getid3->fp, $block_size, SEEK_CUR);
                 }
                 break;
             default:
                 $info_ofr_this_block['offset'] = $block_offset;
                 $info_ofr_this_block['size'] = $block_size;
                 $getid3->warning('Unhandled OptimFROG block type "' . $block_name . '" at offset ' . $info_ofr_this_block['offset']);
                 fseek($getid3->fp, $block_size, SEEK_CUR);
                 break;
         }
     }
     if (isset($getid3->info['ofr']['TAIL']['offset'])) {
         $getid3->info['avdataend'] = $getid3->info['ofr']['TAIL']['offset'];
     }
     $getid3->info['playtime_seconds'] = (double) $getid3->info['ofr']['OFR ']['total_samples'] / ($getid3->info['audio']['channels'] * $getid3->info['audio']['sample_rate']);
     $getid3->info['audio']['bitrate'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8 / $getid3->info['playtime_seconds'];
     // move the data chunk after all other chunks (if any)
     // so that the RIFF parser doesn't see EOF when trying
     // to skip over the data chunk
     $riff_data = substr($riff_data, 0, 36) . substr($riff_data, 44) . substr($riff_data, 36, 8);
     // Save audio info key
     $saved_info_audio = $getid3->info['audio'];
     // Instantiate riff module and analyze string
     $riff = new getid3_riff($getid3);
     $riff->AnalyzeString($riff_data);
     // Restore info key
     $getid3->info['audio'] = $saved_info_audio;
     $getid3->info['fileformat'] = 'ofr';
     return true;
 }
开发者ID:ryumaru,项目名称:ryuzinewriter,代码行数:101,代码来源:module.audio.optimfrog.php

示例2: Analyze

 public function Analyze()
 {
     $getid3 = $this->getid3;
     $getid3->include_module('audio-video.riff');
     fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
     $raw_data = fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
     $getid3->info['fileformat'] = 'la';
     $getid3->info['audio']['dataformat'] = 'la';
     $getid3->info['audio']['lossless'] = true;
     $getid3->info['la']['version_major'] = (int) $raw_data[2];
     $getid3->info['la']['version_minor'] = (int) $raw_data[3];
     $getid3->info['la']['version'] = (double) $getid3->info['la']['version_major'] + $getid3->info['la']['version_minor'] / 10;
     $getid3->info['la']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($raw_data, 4, 4));
     $wave_chunk = substr($raw_data, 8, 4);
     if ($wave_chunk !== 'WAVE') {
         throw new getid3_exception('Expected "WAVE" (' . getid3_lib::PrintHexBytes('WAVE') . ') at offset 8, found "' . $wave_chunk . '" (' . getid3_lib::PrintHexBytes($wave_chunk) . ') instead.');
     }
     $offset = 12;
     $getid3->info['la']['fmt_size'] = 24;
     if ($getid3->info['la']['version'] >= 0.3) {
         $getid3->info['la']['fmt_size'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
         $getid3->info['la']['header_size'] = 49 + $getid3->info['la']['fmt_size'] - 24;
         $offset += 4;
     } else {
         // version 0.2 didn't support additional data blocks
         $getid3->info['la']['header_size'] = 41;
     }
     $fmt_chunk = substr($raw_data, $offset, 4);
     if ($fmt_chunk !== 'fmt ') {
         throw new getid3_exception('Expected "fmt " (' . getid3_lib::PrintHexBytes('fmt ') . ') at offset ' . $offset . ', found "' . $fmt_chunk . '" (' . getid3_lib::PrintHexBytes($fmt_chunk) . ') instead.');
     }
     $offset += 4;
     $fmt_size = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
     $offset += 4;
     $getid3->info['la']['raw']['format'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 2));
     $offset += 2;
     getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['la'], $raw_data, $offset, array('channels' => 2, 'sample_rate' => 4, 'bytes_per_second' => 4, 'bytes_per_sample' => 2, 'bits_per_sample' => 2, 'samples' => 4));
     $offset += 18;
     $getid3->info['la']['raw']['flags'] = getid3_lib::LittleEndian2Int($raw_data[$offset++]);
     $getid3->info['la']['flags']['seekable'] = (bool) ($getid3->info['la']['raw']['flags'] & 0x1);
     if ($getid3->info['la']['version'] >= 0.4) {
         $getid3->info['la']['flags']['high_compression'] = (bool) ($getid3->info['la']['raw']['flags'] & 0x2);
     }
     $getid3->info['la']['original_crc'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
     $offset += 4;
     // mikeØbevin*de
     // Basically, the blocksize/seekevery are 61440/19 in La0.4 and 73728/16
     // in earlier versions. A seekpoint is added every blocksize * seekevery
     // samples, so 4 * int(totalSamples / (blockSize * seekEvery)) should
     // give the number of bytes used for the seekpoints. Of course, if seeking
     // is disabled, there are no seekpoints stored.
     if ($getid3->info['la']['version'] >= 0.4) {
         $getid3->info['la']['blocksize'] = 61440;
         $getid3->info['la']['seekevery'] = 19;
     } else {
         $getid3->info['la']['blocksize'] = 73728;
         $getid3->info['la']['seekevery'] = 16;
     }
     $getid3->info['la']['seekpoint_count'] = 0;
     if ($getid3->info['la']['flags']['seekable']) {
         $getid3->info['la']['seekpoint_count'] = floor($getid3->info['la']['samples'] / ($getid3->info['la']['blocksize'] * $getid3->info['la']['seekevery']));
         for ($i = 0; $i < $getid3->info['la']['seekpoint_count']; $i++) {
             $getid3->info['la']['seekpoints'][] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
             $offset += 4;
         }
     }
     if ($getid3->info['la']['version'] >= 0.3) {
         // Following the main header information, the program outputs all of the
         // seekpoints. Following these is what I called the 'footer start',
         // i.e. the position immediately after the La audio data is finished.
         $getid3->info['la']['footerstart'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
         $offset += 4;
         if ($getid3->info['la']['footerstart'] > $getid3->info['filesize']) {
             $getid3->warning('FooterStart value points to offset ' . $getid3->info['la']['footerstart'] . ' which is beyond end-of-file (' . $getid3->info['filesize'] . ')');
             $getid3->info['la']['footerstart'] = $getid3->info['filesize'];
         }
     } else {
         // La v0.2 didn't have FooterStart value
         $getid3->info['la']['footerstart'] = $getid3->info['avdataend'];
     }
     if ($getid3->info['la']['footerstart'] < $getid3->info['avdataend']) {
         // Create riff header
         $riff_data = 'WAVE';
         if ($getid3->info['la']['version'] == 0.2) {
             $riff_data .= substr($raw_data, 12, 24);
         } else {
             $riff_data .= substr($raw_data, 16, 24);
         }
         if ($getid3->info['la']['footerstart'] < $getid3->info['avdataend']) {
             fseek($getid3->fp, $getid3->info['la']['footerstart'], SEEK_SET);
             $riff_data .= fread($getid3->fp, $getid3->info['avdataend'] - $getid3->info['la']['footerstart']);
         }
         $riff_data = 'RIFF' . getid3_lib::LittleEndian2String(strlen($riff_data), 4, false) . $riff_data;
         // Clone getid3 - messing with offsets - better safe than sorry
         $clone = clone $getid3;
         // Analyze clone by string
         $riff = new getid3_riff($clone);
         $riff->AnalyzeString($riff_data);
         // Import from clone and destroy
         $getid3->info['riff'] = $clone->info['riff'];
//.........这里部分代码省略.........
开发者ID:ryumaru,项目名称:ryuzinewriter,代码行数:101,代码来源:module.audio.la.php

示例3: Analyze


//.........这里部分代码省略.........
                     // ID_SHAPING_WEIGHTS
                     case 0x8:
                         // ID_FLOAT_INFO
                     // ID_FLOAT_INFO
                     case 0x9:
                         // ID_INT32_INFO
                     // ID_INT32_INFO
                     case 0xa:
                         // ID_WV_BITSTREAM
                     // ID_WV_BITSTREAM
                     case 0xb:
                         // ID_WVC_BITSTREAM
                     // ID_WVC_BITSTREAM
                     case 0xc:
                         // ID_WVX_BITSTREAM
                     // ID_WVX_BITSTREAM
                     case 0xd:
                         // ID_CHANNEL_INFO
                         fseek($getid3->fp, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
                         break;
                     default:
                         $getid3->warning('Unexpected metablock type "0x' . str_pad(dechex($metablock['function_id']), 2, '0', STR_PAD_LEFT) . '" at offset ' . $metablock['offset']);
                         fseek($getid3->fp, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
                         break;
                 }
                 switch ($metablock['function_id']) {
                     case 0x21:
                         // ID_RIFF_HEADER
                         $original_wav_filesize = getid3_lib::LittleEndian2Int(substr($metablock['data'], 4, 4));
                         // Clone getid3
                         $clone = clone $getid3;
                         // Analyze clone by string
                         $riff = new getid3_riff($clone);
                         $riff->AnalyzeString($metablock['data']);
                         // Import from clone and destroy
                         $metablock['riff'] = $clone->info['riff'];
                         $getid3->warnings($clone->warnings());
                         unset($clone);
                         // Save RIFF header - we may need it later for RIFF footer parsing
                         $this->riff_header = $metablock['data'];
                         $metablock['riff']['original_filesize'] = $original_wav_filesize;
                         $info_wavpack['riff_trailer_size'] = $original_wav_filesize - $metablock['riff']['WAVE']['data'][0]['size'] - $metablock['riff']['header_size'];
                         $getid3->info['audio']['sample_rate'] = $metablock['riff']['raw']['fmt ']['nSamplesPerSec'];
                         $getid3->info['playtime_seconds'] = $info_wavpack_blockheader['total_samples'] / $getid3->info['audio']['sample_rate'];
                         // Safe RIFF header in case there's a RIFF footer later
                         $metablock_riff_header = $metablock['data'];
                         break;
                     case 0x22:
                         // ID_RIFF_TRAILER
                         $metablock_riff_footer = $metablock_riff_header . $metablock['data'];
                         $start_offset = $metablock['offset'] + ($metablock['large_block'] ? 4 : 2);
                         $ftell_old = ftell($getid3->fp);
                         // Clone getid3
                         $clone = clone $getid3;
                         // Call public method that really should be private
                         $riff = new getid3_riff($clone);
                         $metablock['riff'] = $riff->ParseRIFF($start_offset, $start_offset + $metablock['size']);
                         unset($clone);
                         fseek($getid3->fp, $ftell_old, SEEK_SET);
                         if (!empty($metablock['riff']['INFO'])) {
                             getid3_riff::RIFFCommentsParse($metablock['riff']['INFO'], $metablock['comments']);
                             $getid3->info['tags']['riff'] = $metablock['comments'];
                         }
                         break;
                     case 0x23:
                         // ID_REPLAY_GAIN
开发者ID:peterlindkvist,项目名称:apache-player,代码行数:67,代码来源:module.audio.wavpack.php


注:本文中的getid3_riff::AnalyzeString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。