Mercurial > judyates
diff e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.vqf.php @ 3:3f6b44aa6b35 judyates
[svn r4] added ability to buy stuff, from a Prints page, but it doesn't work well with the css, and it also has not been fitted into the perl make system.
author | rlm |
---|---|
date | Mon, 22 Feb 2010 08:02:39 -0500 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.vqf.php Mon Feb 22 08:02:39 2010 -0500 1.3 @@ -0,0 +1,164 @@ 1.4 +<?php 1.5 +// +----------------------------------------------------------------------+ 1.6 +// | PHP version 5 | 1.7 +// +----------------------------------------------------------------------+ 1.8 +// | Copyright (c) 2002-2006 James Heinrich, Allan Hansen | 1.9 +// +----------------------------------------------------------------------+ 1.10 +// | This source file is subject to version 2 of the GPL license, | 1.11 +// | that is bundled with this package in the file license.txt and is | 1.12 +// | available through the world-wide-web at the following url: | 1.13 +// | http://www.gnu.org/copyleft/gpl.html | 1.14 +// +----------------------------------------------------------------------+ 1.15 +// | getID3() - http://getid3.sourceforge.net or http://www.getid3.org | 1.16 +// +----------------------------------------------------------------------+ 1.17 +// | Authors: James Heinrich <infoØgetid3*org> | 1.18 +// | Allan Hansen <ahØartemis*dk> | 1.19 +// +----------------------------------------------------------------------+ 1.20 +// | module.audio.vqf.php | 1.21 +// | Module for analyzing VQF Audio files | 1.22 +// | dependencies: NONE | 1.23 +// +----------------------------------------------------------------------+ 1.24 +// 1.25 +// $Id: module.audio.vqf.php,v 1.3 2006/11/16 23:16:31 ah Exp $ 1.26 + 1.27 + 1.28 + 1.29 +class getid3_vqf extends getid3_handler 1.30 +{ 1.31 + 1.32 + public function Analyze() { 1.33 + 1.34 + $getid3 = $this->getid3; 1.35 + 1.36 + // based loosely on code from TTwinVQ by Jurgen Faul <jfaulØgmx*de> 1.37 + // http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html 1.38 + 1.39 + $getid3->info['fileformat'] = 'vqf'; 1.40 + $getid3->info['audio']['dataformat'] = 'vqf'; 1.41 + $getid3->info['audio']['bitrate_mode'] = 'cbr'; 1.42 + $getid3->info['audio']['lossless'] = false; 1.43 + 1.44 + // Shortcuts 1.45 + $getid3->info['vqf']['raw'] = array (); 1.46 + $info_vqf = &$getid3->info['vqf']; 1.47 + $info_vqf_raw = &$info_vqf['raw']; 1.48 + 1.49 + // Get header 1.50 + fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET); 1.51 + $vqf_header_data = fread($getid3->fp, 16); 1.52 + 1.53 + $info_vqf_raw['header_tag'] = 'TWIN'; // Magic bytes 1.54 + $info_vqf_raw['version'] = substr($vqf_header_data, 4, 8); 1.55 + $info_vqf_raw['size'] = getid3_lib::BigEndian2Int(substr($vqf_header_data, 12, 4)); 1.56 + 1.57 + while (ftell($getid3->fp) < $getid3->info['avdataend']) { 1.58 + 1.59 + $chunk_base_offset = ftell($getid3->fp); 1.60 + $chunk_data = fread($getid3->fp, 8); 1.61 + $chunk_name = substr($chunk_data, 0, 4); 1.62 + 1.63 + if ($chunk_name == 'DATA') { 1.64 + $getid3->info['avdataoffset'] = $chunk_base_offset; 1.65 + break; 1.66 + } 1.67 + 1.68 + $chunk_size = getid3_lib::BigEndian2Int(substr($chunk_data, 4, 4)); 1.69 + if ($chunk_size > ($getid3->info['avdataend'] - ftell($getid3->fp))) { 1.70 + throw new getid3_exception('Invalid chunk size ('.$chunk_size.') for chunk "'.$chunk_name.'" at offset 8.'); 1.71 + } 1.72 + if ($chunk_size > 0) { 1.73 + $chunk_data .= fread($getid3->fp, $chunk_size); 1.74 + } 1.75 + 1.76 + switch ($chunk_name) { 1.77 + 1.78 + case 'COMM': 1.79 + $info_vqf['COMM'] = array (); 1.80 + getid3_lib::ReadSequence('BigEndian2Int', $info_vqf['COMM'], $chunk_data, 8, 1.81 + array ( 1.82 + 'channel_mode' => 4, 1.83 + 'bitrate' => 4, 1.84 + 'sample_rate' => 4, 1.85 + 'security_level' => 4 1.86 + ) 1.87 + ); 1.88 + 1.89 + $getid3->info['audio']['channels'] = $info_vqf['COMM']['channel_mode'] + 1; 1.90 + $getid3->info['audio']['sample_rate'] = getid3_vqf::VQFchannelFrequencyLookup($info_vqf['COMM']['sample_rate']); 1.91 + $getid3->info['audio']['bitrate'] = $info_vqf['COMM']['bitrate'] * 1000; 1.92 + $getid3->info['audio']['encoder_options'] = 'CBR' . ceil($getid3->info['audio']['bitrate']/1000); 1.93 + 1.94 + if ($getid3->info['audio']['bitrate'] == 0) { 1.95 + throw new getid3_exception('Corrupt VQF file: bitrate_audio == zero'); 1.96 + } 1.97 + break; 1.98 + 1.99 + case 'NAME': 1.100 + case 'AUTH': 1.101 + case '(c) ': 1.102 + case 'FILE': 1.103 + case 'COMT': 1.104 + case 'ALBM': 1.105 + $info_vqf['comments'][getid3_vqf::VQFcommentNiceNameLookup($chunk_name)][] = trim(substr($chunk_data, 8)); 1.106 + break; 1.107 + 1.108 + case 'DSIZ': 1.109 + $info_vqf['DSIZ'] = getid3_lib::BigEndian2Int(substr($chunk_data, 8, 4)); 1.110 + break; 1.111 + 1.112 + default: 1.113 + $getid3->warning('Unhandled chunk type "'.$chunk_name.'" at offset 8'); 1.114 + break; 1.115 + } 1.116 + } 1.117 + 1.118 + $getid3->info['playtime_seconds'] = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['audio']['bitrate']; 1.119 + 1.120 + if (isset($info_vqf['DSIZ']) && (($info_vqf['DSIZ'] != ($getid3->info['avdataend'] - $getid3->info['avdataoffset'] - strlen('DATA'))))) { 1.121 + switch ($info_vqf['DSIZ']) { 1.122 + case 0: 1.123 + case 1: 1.124 + $getid3->warning('Invalid DSIZ value "'.$info_vqf['DSIZ'].'". This is known to happen with VQF files encoded by Ahead Nero, and seems to be its way of saying this is TwinVQF v'.($info_vqf['DSIZ'] + 1).'.0'); 1.125 + $getid3->info['audio']['encoder'] = 'Ahead Nero'; 1.126 + break; 1.127 + 1.128 + default: 1.129 + $getid3->warning('Probable corrupted file - should be '.$info_vqf['DSIZ'].' bytes, actually '.($getid3->info['avdataend'] - $getid3->info['avdataoffset'] - strlen('DATA'))); 1.130 + break; 1.131 + } 1.132 + } 1.133 + 1.134 + return true; 1.135 + } 1.136 + 1.137 + 1.138 + 1.139 + public static function VQFchannelFrequencyLookup($frequencyid) { 1.140 + 1.141 + static $lookup = array ( 1.142 + 11 => 11025, 1.143 + 22 => 22050, 1.144 + 44 => 44100 1.145 + ); 1.146 + return (isset($lookup[$frequencyid]) ? $lookup[$frequencyid] : $frequencyid * 1000); 1.147 + } 1.148 + 1.149 + 1.150 + 1.151 + public static function VQFcommentNiceNameLookup($shortname) { 1.152 + 1.153 + static $lookup = array ( 1.154 + 'NAME' => 'title', 1.155 + 'AUTH' => 'artist', 1.156 + '(c) ' => 'copyright', 1.157 + 'FILE' => 'filename', 1.158 + 'COMT' => 'comment', 1.159 + 'ALBM' => 'album' 1.160 + ); 1.161 + return (isset($lookup[$shortname]) ? $lookup[$shortname] : $shortname); 1.162 + } 1.163 + 1.164 +} 1.165 + 1.166 + 1.167 +?> 1.168 \ No newline at end of file