Mercurial > judyates
diff e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.la.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.la.php Mon Feb 22 08:02:39 2010 -0500 1.3 @@ -0,0 +1,196 @@ 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.la.php | 1.21 +// | Module for analyzing LA udio files | 1.22 +// | dependencies: module.audio-video.riff.php | 1.23 +// +----------------------------------------------------------------------+ 1.24 +// 1.25 +// $Id: module.audio.la.php,v 1.2 2006/11/02 10:48:01 ah Exp $ 1.26 + 1.27 + 1.28 + 1.29 +class getid3_la extends getid3_handler 1.30 +{ 1.31 + 1.32 + public function Analyze() { 1.33 + 1.34 + $getid3 = $this->getid3; 1.35 + 1.36 + $getid3->include_module('audio-video.riff'); 1.37 + 1.38 + fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET); 1.39 + $raw_data = fread($getid3->fp, getid3::FREAD_BUFFER_SIZE); 1.40 + 1.41 + $getid3->info['fileformat'] = 'la'; 1.42 + $getid3->info['audio']['dataformat'] = 'la'; 1.43 + $getid3->info['audio']['lossless'] = true; 1.44 + 1.45 + $getid3->info['la']['version_major'] = (int)$raw_data{2}; 1.46 + $getid3->info['la']['version_minor'] = (int)$raw_data{3}; 1.47 + $getid3->info['la']['version'] = (float)$getid3->info['la']['version_major'] + ($getid3->info['la']['version_minor'] / 10); 1.48 + 1.49 + $getid3->info['la']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($raw_data, 4, 4)); 1.50 + 1.51 + $wave_chunk = substr($raw_data, 8, 4); 1.52 + if ($wave_chunk !== 'WAVE') { 1.53 + throw new getid3_exception('Expected "WAVE" ('.getid3_lib::PrintHexBytes('WAVE').') at offset 8, found "'.$wave_chunk.'" ('.getid3_lib::PrintHexBytes($wave_chunk).') instead.'); 1.54 + } 1.55 + 1.56 + $offset = 12; 1.57 + 1.58 + $getid3->info['la']['fmt_size'] = 24; 1.59 + if ($getid3->info['la']['version'] >= 0.3) { 1.60 + 1.61 + $getid3->info['la']['fmt_size'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4)); 1.62 + $getid3->info['la']['header_size'] = 49 + $getid3->info['la']['fmt_size'] - 24; 1.63 + $offset += 4; 1.64 + 1.65 + } else { 1.66 + 1.67 + // version 0.2 didn't support additional data blocks 1.68 + $getid3->info['la']['header_size'] = 41; 1.69 + } 1.70 + 1.71 + $fmt_chunk = substr($raw_data, $offset, 4); 1.72 + if ($fmt_chunk !== 'fmt ') { 1.73 + throw new getid3_exception('Expected "fmt " ('.getid3_lib::PrintHexBytes('fmt ').') at offset '.$offset.', found "'.$fmt_chunk.'" ('.getid3_lib::PrintHexBytes($fmt_chunk).') instead.'); 1.74 + } 1.75 + $offset += 4; 1.76 + 1.77 + $fmt_size = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4)); 1.78 + $offset += 4; 1.79 + 1.80 + $getid3->info['la']['raw']['format'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 2)); 1.81 + $offset += 2; 1.82 + 1.83 + getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['la'], $raw_data, $offset, 1.84 + array ( 1.85 + 'channels' => 2, 1.86 + 'sample_rate' => 4, 1.87 + 'bytes_per_second' => 4, 1.88 + 'bytes_per_sample' => 2, 1.89 + 'bits_per_sample' => 2, 1.90 + 'samples' => 4 1.91 + ) 1.92 + ); 1.93 + $offset += 18; 1.94 + 1.95 + $getid3->info['la']['raw']['flags'] = getid3_lib::LittleEndian2Int($raw_data{$offset++}); 1.96 + 1.97 + $getid3->info['la']['flags']['seekable'] = (bool)($getid3->info['la']['raw']['flags'] & 0x01); 1.98 + if ($getid3->info['la']['version'] >= 0.4) { 1.99 + $getid3->info['la']['flags']['high_compression'] = (bool)($getid3->info['la']['raw']['flags'] & 0x02); 1.100 + } 1.101 + 1.102 + $getid3->info['la']['original_crc'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4)); 1.103 + $offset += 4; 1.104 + 1.105 + // mikeØbevin*de 1.106 + // Basically, the blocksize/seekevery are 61440/19 in La0.4 and 73728/16 1.107 + // in earlier versions. A seekpoint is added every blocksize * seekevery 1.108 + // samples, so 4 * int(totalSamples / (blockSize * seekEvery)) should 1.109 + // give the number of bytes used for the seekpoints. Of course, if seeking 1.110 + // is disabled, there are no seekpoints stored. 1.111 + 1.112 + if ($getid3->info['la']['version'] >= 0.4) { 1.113 + $getid3->info['la']['blocksize'] = 61440; 1.114 + $getid3->info['la']['seekevery'] = 19; 1.115 + } else { 1.116 + $getid3->info['la']['blocksize'] = 73728; 1.117 + $getid3->info['la']['seekevery'] = 16; 1.118 + } 1.119 + 1.120 + $getid3->info['la']['seekpoint_count'] = 0; 1.121 + if ($getid3->info['la']['flags']['seekable']) { 1.122 + $getid3->info['la']['seekpoint_count'] = floor($getid3->info['la']['samples'] / ($getid3->info['la']['blocksize'] * $getid3->info['la']['seekevery'])); 1.123 + 1.124 + for ($i = 0; $i < $getid3->info['la']['seekpoint_count']; $i++) { 1.125 + $getid3->info['la']['seekpoints'][] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4)); 1.126 + $offset += 4; 1.127 + } 1.128 + } 1.129 + 1.130 + if ($getid3->info['la']['version'] >= 0.3) { 1.131 + 1.132 + // Following the main header information, the program outputs all of the 1.133 + // seekpoints. Following these is what I called the 'footer start', 1.134 + // i.e. the position immediately after the La audio data is finished. 1.135 + 1.136 + $getid3->info['la']['footerstart'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4)); 1.137 + $offset += 4; 1.138 + 1.139 + if ($getid3->info['la']['footerstart'] > $getid3->info['filesize']) { 1.140 + $getid3->warning('FooterStart value points to offset '.$getid3->info['la']['footerstart'].' which is beyond end-of-file ('.$getid3->info['filesize'].')'); 1.141 + $getid3->info['la']['footerstart'] = $getid3->info['filesize']; 1.142 + } 1.143 + 1.144 + } else { 1.145 + 1.146 + // La v0.2 didn't have FooterStart value 1.147 + $getid3->info['la']['footerstart'] = $getid3->info['avdataend']; 1.148 + 1.149 + } 1.150 + 1.151 + if ($getid3->info['la']['footerstart'] < $getid3->info['avdataend']) { 1.152 + 1.153 + // Create riff header 1.154 + $riff_data = 'WAVE'; 1.155 + if ($getid3->info['la']['version'] == 0.2) { 1.156 + $riff_data .= substr($raw_data, 12, 24); 1.157 + } else { 1.158 + $riff_data .= substr($raw_data, 16, 24); 1.159 + } 1.160 + if ($getid3->info['la']['footerstart'] < $getid3->info['avdataend']) { 1.161 + fseek($getid3->fp, $getid3->info['la']['footerstart'], SEEK_SET); 1.162 + $riff_data .= fread($getid3->fp, $getid3->info['avdataend'] - $getid3->info['la']['footerstart']); 1.163 + } 1.164 + $riff_data = 'RIFF'.getid3_lib::LittleEndian2String(strlen($riff_data), 4, false).$riff_data; 1.165 + 1.166 + // Clone getid3 - messing with offsets - better safe than sorry 1.167 + $clone = clone $getid3; 1.168 + 1.169 + // Analyze clone by string 1.170 + $riff = new getid3_riff($clone); 1.171 + $riff->AnalyzeString($riff_data); 1.172 + 1.173 + // Import from clone and destroy 1.174 + $getid3->info['riff'] = $clone->info['riff']; 1.175 + $getid3->warnings($clone->warnings()); 1.176 + unset($clone); 1.177 + } 1.178 + 1.179 + // $getid3->info['avdataoffset'] should be zero to begin with, but just in case it's not, include the addition anyway 1.180 + $getid3->info['avdataend'] = $getid3->info['avdataoffset'] + $getid3->info['la']['footerstart']; 1.181 + $getid3->info['avdataoffset'] = $getid3->info['avdataoffset'] + $offset; 1.182 + 1.183 + $getid3->info['la']['compression_ratio'] = (float)(($getid3->info['avdataend'] - $getid3->info['avdataoffset']) / $getid3->info['la']['uncompressed_size']); 1.184 + $getid3->info['playtime_seconds'] = (float)($getid3->info['la']['samples'] / $getid3->info['la']['sample_rate']) / $getid3->info['la']['channels']; 1.185 + 1.186 + $getid3->info['audio']['bitrate'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8 / $getid3->info['playtime_seconds']; 1.187 + $getid3->info['audio']['bits_per_sample'] = $getid3->info['la']['bits_per_sample']; 1.188 + 1.189 + $getid3->info['audio']['channels'] = $getid3->info['la']['channels']; 1.190 + $getid3->info['audio']['sample_rate'] = (int)$getid3->info['la']['sample_rate']; 1.191 + $getid3->info['audio']['encoder'] = 'LA v'.$getid3->info['la']['version']; 1.192 + 1.193 + return true; 1.194 + } 1.195 + 1.196 +} 1.197 + 1.198 + 1.199 +?> 1.200 \ No newline at end of file