Mercurial > judyates
comparison e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.tta.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 |
comparison
equal
deleted
inserted
replaced
2:670229c4eb4b | 3:3f6b44aa6b35 |
---|---|
1 <?php | |
2 // +----------------------------------------------------------------------+ | |
3 // | PHP version 5 | | |
4 // +----------------------------------------------------------------------+ | |
5 // | Copyright (c) 2002-2006 James Heinrich, Allan Hansen | | |
6 // +----------------------------------------------------------------------+ | |
7 // | This source file is subject to version 2 of the GPL license, | | |
8 // | that is bundled with this package in the file license.txt and is | | |
9 // | available through the world-wide-web at the following url: | | |
10 // | http://www.gnu.org/copyleft/gpl.html | | |
11 // +----------------------------------------------------------------------+ | |
12 // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org | | |
13 // +----------------------------------------------------------------------+ | |
14 // | Authors: James Heinrich <infoØgetid3*org> | | |
15 // | Allan Hansen <ahØartemis*dk> | | |
16 // +----------------------------------------------------------------------+ | |
17 // | module.audio.tta.php | | |
18 // | Module for analyzing TTA Audio files | | |
19 // | dependencies: NONE | | |
20 // +----------------------------------------------------------------------+ | |
21 // | |
22 // $Id: module.audio.tta.php,v 1.2 2006/11/02 10:48:01 ah Exp $ | |
23 | |
24 | |
25 | |
26 class getid3_tta extends getid3_handler | |
27 { | |
28 | |
29 public function Analyze() { | |
30 | |
31 $getid3 = $this->getid3; | |
32 | |
33 $getid3->info['fileformat'] = 'tta'; | |
34 $getid3->info['audio']['dataformat'] = 'tta'; | |
35 $getid3->info['audio']['lossless'] = true; | |
36 $getid3->info['audio']['bitrate_mode'] = 'vbr'; | |
37 | |
38 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET); | |
39 $tta_header = fread($getid3->fp, 26); | |
40 | |
41 $getid3->info['tta']['magic'] = 'TTA'; // Magic bytes | |
42 | |
43 switch ($tta_header{3}) { | |
44 | |
45 case "\x01": // TTA v1.x | |
46 case "\x02": // TTA v1.x | |
47 case "\x03": // TTA v1.x | |
48 | |
49 // "It was the demo-version of the TTA encoder. There is no released format with such header. TTA encoder v1 is not supported about a year." | |
50 $getid3->info['tta']['major_version'] = 1; | |
51 $getid3->info['avdataoffset'] += 16; | |
52 | |
53 getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4, | |
54 array ( | |
55 'channels' => 2, | |
56 'bits_per_sample' => 2, | |
57 'sample_rate' => 4, | |
58 'samples_per_channel' => 4 | |
59 ) | |
60 ); | |
61 $getid3->info['tta']['compression_level'] = ord($tta_header{3}); | |
62 | |
63 $getid3->info['audio']['encoder_options'] = '-e'.$getid3->info['tta']['compression_level']; | |
64 $getid3->info['playtime_seconds'] = $getid3->info['tta']['samples_per_channel'] / $getid3->info['tta']['sample_rate']; | |
65 break; | |
66 | |
67 case '2': // TTA v2.x | |
68 // "I have hurried to release the TTA 2.0 encoder. Format documentation is removed from our site. This format still in development. Please wait the TTA2 format, encoder v4." | |
69 $getid3->info['tta']['major_version'] = 2; | |
70 $getid3->info['avdataoffset'] += 20; | |
71 | |
72 getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4, | |
73 array ( | |
74 'compression_level' => 2, | |
75 'audio_format' => 2, | |
76 'channels' => 2, | |
77 'bits_per_sample' => 2, | |
78 'sample_rate' => 4, | |
79 'data_length' => 4 | |
80 ) | |
81 ); | |
82 | |
83 $getid3->info['audio']['encoder_options'] = '-e'.$getid3->info['tta']['compression_level']; | |
84 $getid3->info['playtime_seconds'] = $getid3->info['tta']['data_length'] / $getid3->info['tta']['sample_rate']; | |
85 break; | |
86 | |
87 case '1': // TTA v3.x | |
88 // "This is a first stable release of the TTA format. It will be supported by the encoders v3 or higher." | |
89 $getid3->info['tta']['major_version'] = 3; | |
90 $getid3->info['avdataoffset'] += 26; | |
91 | |
92 getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4, | |
93 array ( | |
94 'audio_format' => 2, | |
95 'channels' => 2, | |
96 'bits_per_sample'=> 2, | |
97 'sample_rate' => 4, | |
98 'data_length' => 4, | |
99 'crc32_footer' => -4, // string | |
100 'seek_point' => 4 | |
101 ) | |
102 ); | |
103 | |
104 $getid3->info['playtime_seconds'] = $getid3->info['tta']['data_length'] / $getid3->info['tta']['sample_rate']; | |
105 break; | |
106 | |
107 default: | |
108 throw new getid3_exception('This version of getID3() only knows how to handle TTA v1, v2 and v3 - it may not work correctly with this file which appears to be TTA v'.$tta_header{3}); | |
109 return false; | |
110 break; | |
111 } | |
112 | |
113 $getid3->info['audio']['encoder'] = 'TTA v'.$getid3->info['tta']['major_version']; | |
114 $getid3->info['audio']['bits_per_sample'] = $getid3->info['tta']['bits_per_sample']; | |
115 $getid3->info['audio']['sample_rate'] = $getid3->info['tta']['sample_rate']; | |
116 $getid3->info['audio']['channels'] = $getid3->info['tta']['channels']; | |
117 $getid3->info['audio']['bitrate'] = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['playtime_seconds']; | |
118 | |
119 return true; | |
120 } | |
121 | |
122 } | |
123 | |
124 | |
125 ?> |