rlm@3
|
1 <?php
|
rlm@3
|
2 // +----------------------------------------------------------------------+
|
rlm@3
|
3 // | PHP version 5 |
|
rlm@3
|
4 // +----------------------------------------------------------------------+
|
rlm@3
|
5 // | Copyright (c) 2002-2006 James Heinrich, Allan Hansen |
|
rlm@3
|
6 // +----------------------------------------------------------------------+
|
rlm@3
|
7 // | This source file is subject to version 2 of the GPL license, |
|
rlm@3
|
8 // | that is bundled with this package in the file license.txt and is |
|
rlm@3
|
9 // | available through the world-wide-web at the following url: |
|
rlm@3
|
10 // | http://www.gnu.org/copyleft/gpl.html |
|
rlm@3
|
11 // +----------------------------------------------------------------------+
|
rlm@3
|
12 // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org |
|
rlm@3
|
13 // +----------------------------------------------------------------------+
|
rlm@3
|
14 // | Authors: James Heinrich <infoØgetid3*org> |
|
rlm@3
|
15 // | Allan Hansen <ahØartemis*dk> |
|
rlm@3
|
16 // +----------------------------------------------------------------------+
|
rlm@3
|
17 // | module.audio-video.quicktime.php |
|
rlm@3
|
18 // | Module for analyzing Quicktime, MP3-in-MP4 and Apple Lossless files. |
|
rlm@3
|
19 // | dependencies: module.audio.mp3.php |
|
rlm@3
|
20 // | zlib support in PHP (optional) |
|
rlm@3
|
21 // +----------------------------------------------------------------------+
|
rlm@3
|
22 //
|
rlm@3
|
23 // $Id: module.audio-video.quicktime.php,v 1.7 2006/11/02 16:03:28 ah Exp $
|
rlm@3
|
24
|
rlm@3
|
25
|
rlm@3
|
26
|
rlm@3
|
27 class getid3_quicktime extends getid3_handler
|
rlm@3
|
28 {
|
rlm@3
|
29
|
rlm@3
|
30 public function Analyze() {
|
rlm@3
|
31
|
rlm@3
|
32 $getid3 = $this->getid3;
|
rlm@3
|
33
|
rlm@3
|
34 $info = &$getid3->info;
|
rlm@3
|
35
|
rlm@3
|
36 $getid3->include_module('audio.mp3');
|
rlm@3
|
37
|
rlm@3
|
38 $info['quicktime'] = array ();
|
rlm@3
|
39 $info_quicktime = &$info['quicktime'];
|
rlm@3
|
40
|
rlm@3
|
41 $info['fileformat'] = 'quicktime';
|
rlm@3
|
42 $info_quicktime['hinting'] = false;
|
rlm@3
|
43
|
rlm@3
|
44 fseek($getid3->fp, $info['avdataoffset'], SEEK_SET);
|
rlm@3
|
45
|
rlm@3
|
46 $offset = $atom_counter = 0;
|
rlm@3
|
47
|
rlm@3
|
48 while ($offset < $info['avdataend']) {
|
rlm@3
|
49
|
rlm@3
|
50 fseek($getid3->fp, $offset, SEEK_SET);
|
rlm@3
|
51 $atom_header = fread($getid3->fp, 8);
|
rlm@3
|
52
|
rlm@3
|
53 $atom_size = getid3_lib::BigEndian2Int(substr($atom_header, 0, 4));
|
rlm@3
|
54 $atom_name = substr($atom_header, 4, 4);
|
rlm@3
|
55
|
rlm@3
|
56 $info_quicktime[$atom_name]['name'] = $atom_name;
|
rlm@3
|
57 $info_quicktime[$atom_name]['size'] = $atom_size;
|
rlm@3
|
58 $info_quicktime[$atom_name]['offset'] = $offset;
|
rlm@3
|
59
|
rlm@3
|
60 if (($offset + $atom_size) > $info['avdataend']) {
|
rlm@3
|
61 throw new getid3_exception('Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atom_size.' bytes)');
|
rlm@3
|
62 }
|
rlm@3
|
63
|
rlm@3
|
64 if ($atom_size == 0) {
|
rlm@3
|
65 // Furthermore, for historical reasons the list of atoms is optionally
|
rlm@3
|
66 // terminated by a 32-bit integer set to 0. If you are writing a program
|
rlm@3
|
67 // to read user data atoms, you should allow for the terminating 0.
|
rlm@3
|
68 break;
|
rlm@3
|
69 }
|
rlm@3
|
70
|
rlm@3
|
71 switch ($atom_name) {
|
rlm@3
|
72
|
rlm@3
|
73 case 'mdat': // Media DATa atom
|
rlm@3
|
74 // 'mdat' contains the actual data for the audio/video
|
rlm@3
|
75 if (($atom_size > 8) && (!isset($info['avdataend_tmp']) || ($info_quicktime[$atom_name]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) {
|
rlm@3
|
76
|
rlm@3
|
77 $info['avdataoffset'] = $info_quicktime[$atom_name]['offset'] + 8;
|
rlm@3
|
78 $old_av_data_end = $info['avdataend'];
|
rlm@3
|
79 $info['avdataend'] = $info_quicktime[$atom_name]['offset'] + $info_quicktime[$atom_name]['size'];
|
rlm@3
|
80
|
rlm@3
|
81
|
rlm@3
|
82 //// MP3
|
rlm@3
|
83
|
rlm@3
|
84 if (!$getid3->include_module_optional('audio.mp3')) {
|
rlm@3
|
85 $getid3->warning('MP3 skipped because mpeg module is missing.');
|
rlm@3
|
86 }
|
rlm@3
|
87
|
rlm@3
|
88 else {
|
rlm@3
|
89
|
rlm@3
|
90 // Clone getid3 - messing with offsets - better safe than sorry
|
rlm@3
|
91 $clone = clone $getid3;
|
rlm@3
|
92
|
rlm@3
|
93 if (getid3_mp3::MPEGaudioHeaderValid(getid3_mp3::MPEGaudioHeaderDecode(fread($clone->fp, 4)))) {
|
rlm@3
|
94
|
rlm@3
|
95 $mp3 = new getid3_mp3($clone);
|
rlm@3
|
96 $mp3->AnalyzeMPEGaudioInfo();
|
rlm@3
|
97
|
rlm@3
|
98 // Import from clone and destroy
|
rlm@3
|
99 if (isset($clone->info['mpeg']['audio'])) {
|
rlm@3
|
100
|
rlm@3
|
101 $info['mpeg']['audio'] = $clone->info['mpeg']['audio'];
|
rlm@3
|
102
|
rlm@3
|
103 $info['audio']['dataformat'] = 'mp3';
|
rlm@3
|
104 $info['audio']['codec'] = (!empty($info['mpeg']['audio']['encoder']) ? $info['mpeg']['audio']['encoder'] : (!empty($info['mpeg']['audio']['codec']) ? $info['mpeg']['audio']['codec'] : (!empty($info['mpeg']['audio']['LAME']) ? 'LAME' :'mp3')));
|
rlm@3
|
105 $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
|
rlm@3
|
106 $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
|
rlm@3
|
107 $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
|
rlm@3
|
108 $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
|
rlm@3
|
109 $info['bitrate'] = $info['audio']['bitrate'];
|
rlm@3
|
110
|
rlm@3
|
111 $getid3->warning($clone->warnings());
|
rlm@3
|
112 unset($clone);
|
rlm@3
|
113 }
|
rlm@3
|
114 }
|
rlm@3
|
115 }
|
rlm@3
|
116
|
rlm@3
|
117 $info['avdataend'] = $old_av_data_end;
|
rlm@3
|
118 unset($old_av_data_end);
|
rlm@3
|
119
|
rlm@3
|
120 }
|
rlm@3
|
121 break;
|
rlm@3
|
122
|
rlm@3
|
123
|
rlm@3
|
124 case 'free': // FREE space atom
|
rlm@3
|
125 case 'skip': // SKIP atom
|
rlm@3
|
126 case 'wide': // 64-bit expansion placeholder atom
|
rlm@3
|
127 // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
|
rlm@3
|
128 break;
|
rlm@3
|
129
|
rlm@3
|
130
|
rlm@3
|
131 default:
|
rlm@3
|
132 $atom_hierarchy = array ();
|
rlm@3
|
133 $info_quicktime[$atom_name] = $this->QuicktimeParseAtom($atom_name, $atom_size, fread($getid3->fp, $atom_size), $offset, $atom_hierarchy);
|
rlm@3
|
134 break;
|
rlm@3
|
135 }
|
rlm@3
|
136
|
rlm@3
|
137 $offset += $atom_size;
|
rlm@3
|
138 $atom_counter++;
|
rlm@3
|
139 }
|
rlm@3
|
140
|
rlm@3
|
141 if (!empty($info['avdataend_tmp'])) {
|
rlm@3
|
142 // this value is assigned to a temp value and then erased because
|
rlm@3
|
143 // otherwise any atoms beyond the 'mdat' atom would not get parsed
|
rlm@3
|
144 $info['avdataend'] = $info['avdataend_tmp'];
|
rlm@3
|
145 unset($info['avdataend_tmp']);
|
rlm@3
|
146 }
|
rlm@3
|
147
|
rlm@3
|
148 if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) {
|
rlm@3
|
149 $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
|
rlm@3
|
150 }
|
rlm@3
|
151
|
rlm@3
|
152 if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info_quicktime['video'])) {
|
rlm@3
|
153 $info['audio']['bitrate'] = $info['bitrate'];
|
rlm@3
|
154 }
|
rlm@3
|
155
|
rlm@3
|
156 if ((@$info['audio']['dataformat'] == 'mp4') && empty($info['video']['resolution_x'])) {
|
rlm@3
|
157 $info['fileformat'] = 'mp4';
|
rlm@3
|
158 $info['mime_type'] = 'audio/mp4';
|
rlm@3
|
159 unset($info['video']['dataformat']);
|
rlm@3
|
160 }
|
rlm@3
|
161
|
rlm@3
|
162 if (!$getid3->option_extra_info) {
|
rlm@3
|
163 unset($info_quicktime['moov']);
|
rlm@3
|
164 }
|
rlm@3
|
165
|
rlm@3
|
166 if (empty($info['audio']['dataformat']) && !empty($info_quicktime['audio'])) {
|
rlm@3
|
167 $info['audio']['dataformat'] = 'quicktime';
|
rlm@3
|
168 }
|
rlm@3
|
169
|
rlm@3
|
170 if (empty($info['video']['dataformat']) && !empty($info_quicktime['video'])) {
|
rlm@3
|
171 $info['video']['dataformat'] = 'quicktime';
|
rlm@3
|
172 }
|
rlm@3
|
173
|
rlm@3
|
174 return true;
|
rlm@3
|
175 }
|
rlm@3
|
176
|
rlm@3
|
177
|
rlm@3
|
178
|
rlm@3
|
179 private function QuicktimeParseAtom($atom_name, $atom_size, $atom_data, $base_offset, &$atom_hierarchy) {
|
rlm@3
|
180
|
rlm@3
|
181 // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm
|
rlm@3
|
182
|
rlm@3
|
183 $getid3 = $this->getid3;
|
rlm@3
|
184
|
rlm@3
|
185 $info = &$getid3->info;
|
rlm@3
|
186 $info_quicktime = &$info['quicktime'];
|
rlm@3
|
187
|
rlm@3
|
188 array_push($atom_hierarchy, $atom_name);
|
rlm@3
|
189 $atom_structure['hierarchy'] = implode(' ', $atom_hierarchy);
|
rlm@3
|
190 $atom_structure['name'] = $atom_name;
|
rlm@3
|
191 $atom_structure['size'] = $atom_size;
|
rlm@3
|
192 $atom_structure['offset'] = $base_offset;
|
rlm@3
|
193
|
rlm@3
|
194 switch ($atom_name) {
|
rlm@3
|
195 case 'moov': // MOVie container atom
|
rlm@3
|
196 case 'trak': // TRAcK container atom
|
rlm@3
|
197 case 'clip': // CLIPping container atom
|
rlm@3
|
198 case 'matt': // track MATTe container atom
|
rlm@3
|
199 case 'edts': // EDiTS container atom
|
rlm@3
|
200 case 'tref': // Track REFerence container atom
|
rlm@3
|
201 case 'mdia': // MeDIA container atom
|
rlm@3
|
202 case 'minf': // Media INFormation container atom
|
rlm@3
|
203 case 'dinf': // Data INFormation container atom
|
rlm@3
|
204 case 'udta': // User DaTA container atom
|
rlm@3
|
205 case 'stbl': // Sample TaBLe container atom
|
rlm@3
|
206 case 'cmov': // Compressed MOVie container atom
|
rlm@3
|
207 case 'rmra': // Reference Movie Record Atom
|
rlm@3
|
208 case 'rmda': // Reference Movie Descriptor Atom
|
rlm@3
|
209 case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR)
|
rlm@3
|
210 $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $base_offset + 8, $atom_hierarchy);
|
rlm@3
|
211 break;
|
rlm@3
|
212
|
rlm@3
|
213
|
rlm@3
|
214 case '©cpy':
|
rlm@3
|
215 case '©day':
|
rlm@3
|
216 case '©dir':
|
rlm@3
|
217 case '©ed1':
|
rlm@3
|
218 case '©ed2':
|
rlm@3
|
219 case '©ed3':
|
rlm@3
|
220 case '©ed4':
|
rlm@3
|
221 case '©ed5':
|
rlm@3
|
222 case '©ed6':
|
rlm@3
|
223 case '©ed7':
|
rlm@3
|
224 case '©ed8':
|
rlm@3
|
225 case '©ed9':
|
rlm@3
|
226 case '©fmt':
|
rlm@3
|
227 case '©inf':
|
rlm@3
|
228 case '©prd':
|
rlm@3
|
229 case '©prf':
|
rlm@3
|
230 case '©req':
|
rlm@3
|
231 case '©src':
|
rlm@3
|
232 case '©wrt':
|
rlm@3
|
233 case '©nam':
|
rlm@3
|
234 case '©cmt':
|
rlm@3
|
235 case '©wrn':
|
rlm@3
|
236 case '©hst':
|
rlm@3
|
237 case '©mak':
|
rlm@3
|
238 case '©mod':
|
rlm@3
|
239 case '©PRD':
|
rlm@3
|
240 case '©swr':
|
rlm@3
|
241 case '©aut':
|
rlm@3
|
242 case '©ART':
|
rlm@3
|
243 case '©trk':
|
rlm@3
|
244 case '©alb':
|
rlm@3
|
245 case '©com':
|
rlm@3
|
246 case '©gen':
|
rlm@3
|
247 case '©ope':
|
rlm@3
|
248 case '©url':
|
rlm@3
|
249 case '©enc':
|
rlm@3
|
250 $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
|
rlm@3
|
251 $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
|
rlm@3
|
252 $atom_structure['data'] = substr($atom_data, 4);
|
rlm@3
|
253
|
rlm@3
|
254 $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
|
rlm@3
|
255 if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
|
rlm@3
|
256 $info['comments']['language'][] = $atom_structure['language'];
|
rlm@3
|
257 }
|
rlm@3
|
258 $this->CopyToAppropriateCommentsSection($atom_name, $atom_structure['data']);
|
rlm@3
|
259 break;
|
rlm@3
|
260
|
rlm@3
|
261
|
rlm@3
|
262 case 'play': // auto-PLAY atom
|
rlm@3
|
263 $atom_structure['autoplay'] = (bool)getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
rlm@3
|
264
|
rlm@3
|
265 $info_quicktime['autoplay'] = $atom_structure['autoplay'];
|
rlm@3
|
266 break;
|
rlm@3
|
267
|
rlm@3
|
268
|
rlm@3
|
269 case 'WLOC': // Window LOCation atom
|
rlm@3
|
270 $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
|
rlm@3
|
271 $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
|
rlm@3
|
272 break;
|
rlm@3
|
273
|
rlm@3
|
274
|
rlm@3
|
275 case 'LOOP': // LOOPing atom
|
rlm@3
|
276 case 'SelO': // play SELection Only atom
|
rlm@3
|
277 case 'AllF': // play ALL Frames atom
|
rlm@3
|
278 $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data);
|
rlm@3
|
279 break;
|
rlm@3
|
280
|
rlm@3
|
281
|
rlm@3
|
282 case 'name': //
|
rlm@3
|
283 case 'MCPS': // Media Cleaner PRo
|
rlm@3
|
284 case '@PRM': // adobe PReMiere version
|
rlm@3
|
285 case '@PRQ': // adobe PRemiere Quicktime version
|
rlm@3
|
286 $atom_structure['data'] = $atom_data;
|
rlm@3
|
287 break;
|
rlm@3
|
288
|
rlm@3
|
289
|
rlm@3
|
290 case 'cmvd': // Compressed MooV Data atom
|
rlm@3
|
291 // Code by ubergeekØubergeek*tv based on information from
|
rlm@3
|
292 // http://developer.apple.com/quicktime/icefloe/dispatch012.html
|
rlm@3
|
293 $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
|
rlm@3
|
294
|
rlm@3
|
295 $compressed_file_data = substr($atom_data, 4);
|
rlm@3
|
296 if (!function_exists('gzuncompress')) {
|
rlm@3
|
297 $getid3->warning('PHP does not have zlib support - cannot decompress MOV atom at offset '.$atom_structure['offset']);
|
rlm@3
|
298 }
|
rlm@3
|
299 elseif ($uncompressed_header = @gzuncompress($compressed_file_data)) {
|
rlm@3
|
300 $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($uncompressed_header, 0, $atom_hierarchy);
|
rlm@3
|
301 } else {
|
rlm@3
|
302 $getid3->warning('Error decompressing compressed MOV atom at offset '.$atom_structure['offset']);
|
rlm@3
|
303 }
|
rlm@3
|
304 break;
|
rlm@3
|
305
|
rlm@3
|
306
|
rlm@3
|
307 case 'dcom': // Data COMpression atom
|
rlm@3
|
308 $atom_structure['compression_id'] = $atom_data;
|
rlm@3
|
309 $atom_structure['compression_text'] = getid3_quicktime::QuicktimeDCOMLookup($atom_data);
|
rlm@3
|
310 break;
|
rlm@3
|
311
|
rlm@3
|
312
|
rlm@3
|
313 case 'rdrf': // Reference movie Data ReFerence atom
|
rlm@3
|
314 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
315 array (
|
rlm@3
|
316 'version' => 1,
|
rlm@3
|
317 'flags_raw' => 3,
|
rlm@3
|
318 'reference_type_name' => -4,
|
rlm@3
|
319 'reference_length' => 4,
|
rlm@3
|
320 )
|
rlm@3
|
321 );
|
rlm@3
|
322
|
rlm@3
|
323 $atom_structure['flags']['internal_data'] = (bool)($atom_structure['flags_raw'] & 0x000001);
|
rlm@3
|
324
|
rlm@3
|
325 switch ($atom_structure['reference_type_name']) {
|
rlm@3
|
326 case 'url ':
|
rlm@3
|
327 $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12));
|
rlm@3
|
328 break;
|
rlm@3
|
329
|
rlm@3
|
330 case 'alis':
|
rlm@3
|
331 $atom_structure['file_alias'] = substr($atom_data, 12);
|
rlm@3
|
332 break;
|
rlm@3
|
333
|
rlm@3
|
334 case 'rsrc':
|
rlm@3
|
335 $atom_structure['resource_alias'] = substr($atom_data, 12);
|
rlm@3
|
336 break;
|
rlm@3
|
337
|
rlm@3
|
338 default:
|
rlm@3
|
339 $atom_structure['data'] = substr($atom_data, 12);
|
rlm@3
|
340 break;
|
rlm@3
|
341 }
|
rlm@3
|
342 break;
|
rlm@3
|
343
|
rlm@3
|
344
|
rlm@3
|
345 case 'rmqu': // Reference Movie QUality atom
|
rlm@3
|
346 $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data);
|
rlm@3
|
347 break;
|
rlm@3
|
348
|
rlm@3
|
349
|
rlm@3
|
350 case 'rmcs': // Reference Movie Cpu Speed atom
|
rlm@3
|
351 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
352 array (
|
rlm@3
|
353 'version' => 1,
|
rlm@3
|
354 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
355 'cpu_speed_rating' => 2
|
rlm@3
|
356 )
|
rlm@3
|
357 );
|
rlm@3
|
358 break;
|
rlm@3
|
359
|
rlm@3
|
360
|
rlm@3
|
361 case 'rmvc': // Reference Movie Version Check atom
|
rlm@3
|
362 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
363 array (
|
rlm@3
|
364 'version' => 1,
|
rlm@3
|
365 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
366 'gestalt_selector' => -4,
|
rlm@3
|
367 'gestalt_value_mask' => 4,
|
rlm@3
|
368 'gestalt_value' => 4,
|
rlm@3
|
369 'gestalt_check_type' => 2
|
rlm@3
|
370 )
|
rlm@3
|
371 );
|
rlm@3
|
372 break;
|
rlm@3
|
373
|
rlm@3
|
374
|
rlm@3
|
375 case 'rmcd': // Reference Movie Component check atom
|
rlm@3
|
376 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
377 array (
|
rlm@3
|
378 'version' => 1,
|
rlm@3
|
379 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
380 'component_type' => -4,
|
rlm@3
|
381 'component_subtype' => -4,
|
rlm@3
|
382 'component_manufacturer' => -4,
|
rlm@3
|
383 'component_flags_raw' => 4,
|
rlm@3
|
384 'component_flags_mask' => 4,
|
rlm@3
|
385 'component_min_version' => 4
|
rlm@3
|
386 )
|
rlm@3
|
387 );
|
rlm@3
|
388 break;
|
rlm@3
|
389
|
rlm@3
|
390
|
rlm@3
|
391 case 'rmdr': // Reference Movie Data Rate atom
|
rlm@3
|
392 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
393 array (
|
rlm@3
|
394 'version' => 1,
|
rlm@3
|
395 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
396 'data_rate' => 4
|
rlm@3
|
397 )
|
rlm@3
|
398 );
|
rlm@3
|
399
|
rlm@3
|
400 $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10;
|
rlm@3
|
401 break;
|
rlm@3
|
402
|
rlm@3
|
403
|
rlm@3
|
404 case 'rmla': // Reference Movie Language Atom
|
rlm@3
|
405 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
406 array (
|
rlm@3
|
407 'version' => 1,
|
rlm@3
|
408 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
409 'language_id' => 2
|
rlm@3
|
410 )
|
rlm@3
|
411 );
|
rlm@3
|
412
|
rlm@3
|
413 $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
|
rlm@3
|
414 if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
|
rlm@3
|
415 $info['comments']['language'][] = $atom_structure['language'];
|
rlm@3
|
416 }
|
rlm@3
|
417 break;
|
rlm@3
|
418
|
rlm@3
|
419
|
rlm@3
|
420 case 'rmla': // Reference Movie Language Atom
|
rlm@3
|
421 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
422 array (
|
rlm@3
|
423 'version' => 1,
|
rlm@3
|
424 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
425 'track_id' => 2
|
rlm@3
|
426 )
|
rlm@3
|
427 );
|
rlm@3
|
428 break;
|
rlm@3
|
429
|
rlm@3
|
430
|
rlm@3
|
431 case 'ptv ': // Print To Video - defines a movie's full screen mode
|
rlm@3
|
432 // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm
|
rlm@3
|
433 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
434 array (
|
rlm@3
|
435 'display_size_raw' => 2,
|
rlm@3
|
436 'reserved_1' => 2, // hardcoded: 0x0000
|
rlm@3
|
437 'reserved_2' => 2, // hardcoded: 0x0000
|
rlm@3
|
438 'slide_show_flag' => 1,
|
rlm@3
|
439 'play_on_open_flag' => 1
|
rlm@3
|
440 )
|
rlm@3
|
441 );
|
rlm@3
|
442
|
rlm@3
|
443 $atom_structure['flags']['play_on_open'] = (bool)$atom_structure['play_on_open_flag'];
|
rlm@3
|
444 $atom_structure['flags']['slide_show'] = (bool)$atom_structure['slide_show_flag'];
|
rlm@3
|
445
|
rlm@3
|
446 $ptv_lookup[0] = 'normal';
|
rlm@3
|
447 $ptv_lookup[1] = 'double';
|
rlm@3
|
448 $ptv_lookup[2] = 'half';
|
rlm@3
|
449 $ptv_lookup[3] = 'full';
|
rlm@3
|
450 $ptv_lookup[4] = 'current';
|
rlm@3
|
451 if (isset($ptv_lookup[$atom_structure['display_size_raw']])) {
|
rlm@3
|
452 $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']];
|
rlm@3
|
453 } else {
|
rlm@3
|
454 $getid3->warning('unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')');
|
rlm@3
|
455 }
|
rlm@3
|
456 break;
|
rlm@3
|
457
|
rlm@3
|
458
|
rlm@3
|
459 case 'stsd': // Sample Table Sample Description atom
|
rlm@3
|
460 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
461 array (
|
rlm@3
|
462 'version' => 1,
|
rlm@3
|
463 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
464 'number_entries' => 4
|
rlm@3
|
465 )
|
rlm@3
|
466 );
|
rlm@3
|
467 $stsd_entries_data_offset = 8;
|
rlm@3
|
468 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
rlm@3
|
469
|
rlm@3
|
470 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_data, $stsd_entries_data_offset,
|
rlm@3
|
471 array (
|
rlm@3
|
472 'size' => 4,
|
rlm@3
|
473 'data_format' => -4,
|
rlm@3
|
474 'reserved' => 6,
|
rlm@3
|
475 'reference_index' => 2
|
rlm@3
|
476 )
|
rlm@3
|
477 );
|
rlm@3
|
478
|
rlm@3
|
479 $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, 16+$stsd_entries_data_offset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));
|
rlm@3
|
480 $stsd_entries_data_offset += 16 + ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);
|
rlm@3
|
481
|
rlm@3
|
482 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 0,
|
rlm@3
|
483 array (
|
rlm@3
|
484 'encoder_version' => 2,
|
rlm@3
|
485 'encoder_revision' => 2,
|
rlm@3
|
486 'encoder_vendor' => -4
|
rlm@3
|
487 )
|
rlm@3
|
488 );
|
rlm@3
|
489
|
rlm@3
|
490 switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) {
|
rlm@3
|
491
|
rlm@3
|
492 case "\x00\x00\x00\x00":
|
rlm@3
|
493 // audio atom
|
rlm@3
|
494 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 8,
|
rlm@3
|
495 array (
|
rlm@3
|
496 'audio_channels' => 2,
|
rlm@3
|
497 'audio_bit_depth' => 2,
|
rlm@3
|
498 'audio_compression_id' => 2,
|
rlm@3
|
499 'audio_packet_size' => 2
|
rlm@3
|
500 )
|
rlm@3
|
501 );
|
rlm@3
|
502
|
rlm@3
|
503 $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_quicktime::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4));
|
rlm@3
|
504
|
rlm@3
|
505 switch ($atom_structure['sample_description_table'][$i]['data_format']) {
|
rlm@3
|
506
|
rlm@3
|
507 case 'mp4v':
|
rlm@3
|
508 $info['fileformat'] = 'mp4';
|
rlm@3
|
509 throw new getid3_exception('This version of getID3() does not fully support MPEG-4 audio/video streams');
|
rlm@3
|
510
|
rlm@3
|
511 case 'qtvr':
|
rlm@3
|
512 $info['video']['dataformat'] = 'quicktimevr';
|
rlm@3
|
513 break;
|
rlm@3
|
514
|
rlm@3
|
515 case 'mp4a':
|
rlm@3
|
516 default:
|
rlm@3
|
517 $info_quicktime['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
|
rlm@3
|
518 $info_quicktime['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate'];
|
rlm@3
|
519 $info_quicktime['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels'];
|
rlm@3
|
520 $info_quicktime['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth'];
|
rlm@3
|
521 $info['audio']['codec'] = $info_quicktime['audio']['codec'];
|
rlm@3
|
522 $info['audio']['sample_rate'] = $info_quicktime['audio']['sample_rate'];
|
rlm@3
|
523 $info['audio']['channels'] = $info_quicktime['audio']['channels'];
|
rlm@3
|
524 $info['audio']['bits_per_sample'] = $info_quicktime['audio']['bit_depth'];
|
rlm@3
|
525 switch ($atom_structure['sample_description_table'][$i]['data_format']) {
|
rlm@3
|
526 case 'raw ': // PCM
|
rlm@3
|
527 case 'alac': // Apple Lossless Audio Codec
|
rlm@3
|
528 $info['audio']['lossless'] = true;
|
rlm@3
|
529 break;
|
rlm@3
|
530 default:
|
rlm@3
|
531 $info['audio']['lossless'] = false;
|
rlm@3
|
532 break;
|
rlm@3
|
533 }
|
rlm@3
|
534 break;
|
rlm@3
|
535 }
|
rlm@3
|
536 break;
|
rlm@3
|
537
|
rlm@3
|
538 default:
|
rlm@3
|
539 switch ($atom_structure['sample_description_table'][$i]['data_format']) {
|
rlm@3
|
540 case 'mp4s':
|
rlm@3
|
541 $info['fileformat'] = 'mp4';
|
rlm@3
|
542 break;
|
rlm@3
|
543
|
rlm@3
|
544 default:
|
rlm@3
|
545 // video atom
|
rlm@3
|
546 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 8,
|
rlm@3
|
547 array (
|
rlm@3
|
548 'video_temporal_quality' => 4,
|
rlm@3
|
549 'video_spatial_quality' => 4,
|
rlm@3
|
550 'video_frame_width' => 2,
|
rlm@3
|
551 'video_frame_height' => 2
|
rlm@3
|
552 )
|
rlm@3
|
553 );
|
rlm@3
|
554 $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_quicktime::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4));
|
rlm@3
|
555 $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_quicktime::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));
|
rlm@3
|
556 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 28,
|
rlm@3
|
557 array (
|
rlm@3
|
558 'video_data_size' => 4,
|
rlm@3
|
559 'video_frame_count' => 2,
|
rlm@3
|
560 'video_encoder_name_len' => 1
|
rlm@3
|
561 )
|
rlm@3
|
562 );
|
rlm@3
|
563 $atom_structure['sample_description_table'][$i]['video_encoder_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 35, $atom_structure['sample_description_table'][$i]['video_encoder_name_len']);
|
rlm@3
|
564 $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2));
|
rlm@3
|
565 $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2));
|
rlm@3
|
566
|
rlm@3
|
567 $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color');
|
rlm@3
|
568 $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']);
|
rlm@3
|
569
|
rlm@3
|
570 if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') {
|
rlm@3
|
571 $info_quicktime['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
|
rlm@3
|
572 $info_quicktime['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
|
rlm@3
|
573 $info_quicktime['video']['codec'] = $atom_structure['sample_description_table'][$i]['video_encoder_name'];
|
rlm@3
|
574 $info_quicktime['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'];
|
rlm@3
|
575 $info_quicktime['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name'];
|
rlm@3
|
576
|
rlm@3
|
577 $info['video']['codec'] = $info_quicktime['video']['codec'];
|
rlm@3
|
578 $info['video']['bits_per_sample'] = $info_quicktime['video']['color_depth'];
|
rlm@3
|
579 }
|
rlm@3
|
580 $info['video']['lossless'] = false;
|
rlm@3
|
581 $info['video']['pixel_aspect_ratio'] = (float)1;
|
rlm@3
|
582 break;
|
rlm@3
|
583 }
|
rlm@3
|
584 break;
|
rlm@3
|
585 }
|
rlm@3
|
586 switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) {
|
rlm@3
|
587 case 'mp4a':
|
rlm@3
|
588 $info['audio']['dataformat'] = $info_quicktime['audio']['codec'] = 'mp4';
|
rlm@3
|
589 break;
|
rlm@3
|
590
|
rlm@3
|
591 case '3ivx':
|
rlm@3
|
592 case '3iv1':
|
rlm@3
|
593 case '3iv2':
|
rlm@3
|
594 $info['video']['dataformat'] = '3ivx';
|
rlm@3
|
595 break;
|
rlm@3
|
596
|
rlm@3
|
597 case 'xvid':
|
rlm@3
|
598 $info['video']['dataformat'] = 'xvid';
|
rlm@3
|
599 break;
|
rlm@3
|
600
|
rlm@3
|
601 case 'mp4v':
|
rlm@3
|
602 $info['video']['dataformat'] = 'mpeg4';
|
rlm@3
|
603 break;
|
rlm@3
|
604
|
rlm@3
|
605 case 'divx':
|
rlm@3
|
606 case 'div1':
|
rlm@3
|
607 case 'div2':
|
rlm@3
|
608 case 'div3':
|
rlm@3
|
609 case 'div4':
|
rlm@3
|
610 case 'div5':
|
rlm@3
|
611 case 'div6':
|
rlm@3
|
612 //$TDIVXileInfo['video']['dataformat'] = 'divx';
|
rlm@3
|
613 break;
|
rlm@3
|
614
|
rlm@3
|
615 default:
|
rlm@3
|
616 // do nothing
|
rlm@3
|
617 break;
|
rlm@3
|
618 }
|
rlm@3
|
619 unset($atom_structure['sample_description_table'][$i]['data']);
|
rlm@3
|
620 }
|
rlm@3
|
621 break;
|
rlm@3
|
622
|
rlm@3
|
623
|
rlm@3
|
624 case 'stts': // Sample Table Time-to-Sample atom
|
rlm@3
|
625 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
626 array (
|
rlm@3
|
627 'version' => 1,
|
rlm@3
|
628 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
629 'number_entries' => 4
|
rlm@3
|
630 )
|
rlm@3
|
631 );
|
rlm@3
|
632
|
rlm@3
|
633 $stts_entries_data_offset = 8;
|
rlm@3
|
634 $frame_rate_calculator_array = array ();
|
rlm@3
|
635 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
rlm@3
|
636
|
rlm@3
|
637 $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $stts_entries_data_offset, 4));
|
rlm@3
|
638 $stts_entries_data_offset += 4;
|
rlm@3
|
639
|
rlm@3
|
640 $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $stts_entries_data_offset, 4));
|
rlm@3
|
641 $stts_entries_data_offset += 4;
|
rlm@3
|
642
|
rlm@3
|
643 if (!empty($info_quicktime['time_scale']) && (@$atoms_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) {
|
rlm@3
|
644
|
rlm@3
|
645 $stts_new_framerate = $info_quicktime['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'];
|
rlm@3
|
646 if ($stts_new_framerate <= 60) {
|
rlm@3
|
647 // some atoms have durations of "1" giving a very large framerate, which probably is not right
|
rlm@3
|
648 $info['video']['frame_rate'] = max(@$info['video']['frame_rate'], $stts_new_framerate);
|
rlm@3
|
649 }
|
rlm@3
|
650 }
|
rlm@3
|
651 //@$frame_rate_calculator_array[($info_quicktime['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count'];
|
rlm@3
|
652 }
|
rlm@3
|
653 /*
|
rlm@3
|
654 $stts_frames_total = 0;
|
rlm@3
|
655 $stts_seconds_total = 0;
|
rlm@3
|
656 foreach ($frame_rate_calculator_array as $frames_per_second => $frame_count) {
|
rlm@3
|
657 if (($frames_per_second > 60) || ($frames_per_second < 1)) {
|
rlm@3
|
658 // not video FPS information, probably audio information
|
rlm@3
|
659 $stts_frames_total = 0;
|
rlm@3
|
660 $stts_seconds_total = 0;
|
rlm@3
|
661 break;
|
rlm@3
|
662 }
|
rlm@3
|
663 $stts_frames_total += $frame_count;
|
rlm@3
|
664 $stts_seconds_total += $frame_count / $frames_per_second;
|
rlm@3
|
665 }
|
rlm@3
|
666 if (($stts_frames_total > 0) && ($stts_seconds_total > 0)) {
|
rlm@3
|
667 if (($stts_frames_total / $stts_seconds_total) > @$info['video']['frame_rate']) {
|
rlm@3
|
668 $info['video']['frame_rate'] = $stts_frames_total / $stts_seconds_total;
|
rlm@3
|
669 }
|
rlm@3
|
670 }
|
rlm@3
|
671 */
|
rlm@3
|
672 break;
|
rlm@3
|
673
|
rlm@3
|
674
|
rlm@3
|
675 case 'stss': // Sample Table Sync Sample (key frames) atom
|
rlm@3
|
676 /*
|
rlm@3
|
677 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
rlm@3
|
678 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
rlm@3
|
679 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
rlm@3
|
680 $stss_entries_data_offset = 8;
|
rlm@3
|
681 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
rlm@3
|
682 $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stss_entries_data_offset, 4));
|
rlm@3
|
683 $stss_entries_data_offset += 4;
|
rlm@3
|
684 }
|
rlm@3
|
685 */
|
rlm@3
|
686 break;
|
rlm@3
|
687
|
rlm@3
|
688
|
rlm@3
|
689 case 'stsc': // Sample Table Sample-to-Chunk atom
|
rlm@3
|
690 /*
|
rlm@3
|
691 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
rlm@3
|
692 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
rlm@3
|
693 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
rlm@3
|
694 $stsc_entries_data_offset = 8;
|
rlm@3
|
695 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
rlm@3
|
696 $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsc_entries_data_offset, 4));
|
rlm@3
|
697 $stsc_entries_data_offset += 4;
|
rlm@3
|
698 $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsc_entries_data_offset, 4));
|
rlm@3
|
699 $stsc_entries_data_offset += 4;
|
rlm@3
|
700 $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsc_entries_data_offset, 4));
|
rlm@3
|
701 $stsc_entries_data_offset += 4;
|
rlm@3
|
702 }
|
rlm@3
|
703 */
|
rlm@3
|
704 break;
|
rlm@3
|
705
|
rlm@3
|
706
|
rlm@3
|
707 case 'stsz': // Sample Table SiZe atom
|
rlm@3
|
708 /*
|
rlm@3
|
709 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
rlm@3
|
710 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
rlm@3
|
711 $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
rlm@3
|
712 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
|
rlm@3
|
713 $stsz_entries_data_offset = 12;
|
rlm@3
|
714 if ($atom_structure['sample_size'] == 0) {
|
rlm@3
|
715 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
rlm@3
|
716 $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stsz_entries_data_offset, 4));
|
rlm@3
|
717 $stsz_entries_data_offset += 4;
|
rlm@3
|
718 }
|
rlm@3
|
719 }
|
rlm@3
|
720 */
|
rlm@3
|
721 break;
|
rlm@3
|
722
|
rlm@3
|
723
|
rlm@3
|
724 case 'stco': // Sample Table Chunk Offset atom
|
rlm@3
|
725 /*
|
rlm@3
|
726 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
rlm@3
|
727 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
rlm@3
|
728 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
rlm@3
|
729 $stco_entries_data_offset = 8;
|
rlm@3
|
730 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
rlm@3
|
731 $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stco_entries_data_offset, 4));
|
rlm@3
|
732 $stco_entries_data_offset += 4;
|
rlm@3
|
733 }
|
rlm@3
|
734 */
|
rlm@3
|
735 break;
|
rlm@3
|
736
|
rlm@3
|
737
|
rlm@3
|
738 case 'dref': // Data REFerence atom
|
rlm@3
|
739 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
740 array (
|
rlm@3
|
741 'version' => 1,
|
rlm@3
|
742 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
743 'number_entries' => 4
|
rlm@3
|
744 )
|
rlm@3
|
745 );
|
rlm@3
|
746
|
rlm@3
|
747 $dref_data_offset = 8;
|
rlm@3
|
748 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
rlm@3
|
749
|
rlm@3
|
750 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['data_references'][$i], $atom_data, $dref_data_offset,
|
rlm@3
|
751 array (
|
rlm@3
|
752 'size' => 4,
|
rlm@3
|
753 'type' => -4,
|
rlm@3
|
754 'version' => 1,
|
rlm@3
|
755 'flags_raw' => 3 // hardcoded: 0x0000
|
rlm@3
|
756 )
|
rlm@3
|
757 );
|
rlm@3
|
758 $dref_data_offset += 12;
|
rlm@3
|
759
|
rlm@3
|
760 $atom_structure['data_references'][$i]['data'] = substr($atom_data, $dref_data_offset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));
|
rlm@3
|
761 $dref_data_offset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);
|
rlm@3
|
762
|
rlm@3
|
763 $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool)($atom_structure['data_references'][$i]['flags_raw'] & 0x001);
|
rlm@3
|
764 }
|
rlm@3
|
765 break;
|
rlm@3
|
766
|
rlm@3
|
767
|
rlm@3
|
768 case 'gmin': // base Media INformation atom
|
rlm@3
|
769 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
770 array (
|
rlm@3
|
771 'version' => 1,
|
rlm@3
|
772 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
773 'graphics_mode' => 2,
|
rlm@3
|
774 'opcolor_red' => 2,
|
rlm@3
|
775 'opcolor_green' => 2,
|
rlm@3
|
776 'opcolor_blue' => 2,
|
rlm@3
|
777 'balance' => 2,
|
rlm@3
|
778 'reserved' => 2
|
rlm@3
|
779 )
|
rlm@3
|
780 );
|
rlm@3
|
781 break;
|
rlm@3
|
782
|
rlm@3
|
783
|
rlm@3
|
784 case 'smhd': // Sound Media information HeaDer atom
|
rlm@3
|
785 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
786 array (
|
rlm@3
|
787 'version' => 1,
|
rlm@3
|
788 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
789 'balance' => 2,
|
rlm@3
|
790 'reserved' => 2
|
rlm@3
|
791 )
|
rlm@3
|
792 );
|
rlm@3
|
793 break;
|
rlm@3
|
794
|
rlm@3
|
795
|
rlm@3
|
796 case 'vmhd': // Video Media information HeaDer atom
|
rlm@3
|
797 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
798 array (
|
rlm@3
|
799 'version' => 1,
|
rlm@3
|
800 'flags_raw' => 3,
|
rlm@3
|
801 'graphics_mode' => 2,
|
rlm@3
|
802 'opcolor_red' => 2,
|
rlm@3
|
803 'opcolor_green' => 2,
|
rlm@3
|
804 'opcolor_blue' => 2
|
rlm@3
|
805 )
|
rlm@3
|
806 );
|
rlm@3
|
807 $atom_structure['flags']['no_lean_ahead'] = (bool)($atom_structure['flags_raw'] & 0x001);
|
rlm@3
|
808 break;
|
rlm@3
|
809
|
rlm@3
|
810
|
rlm@3
|
811 case 'hdlr': // HanDLeR reference atom
|
rlm@3
|
812 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
813 array (
|
rlm@3
|
814 'version' => 1,
|
rlm@3
|
815 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
816 'component_type' => -4,
|
rlm@3
|
817 'component_subtype' => -4,
|
rlm@3
|
818 'component_manufacturer' => -4,
|
rlm@3
|
819 'component_flags_raw' => 4,
|
rlm@3
|
820 'component_flags_mask' => 4
|
rlm@3
|
821 )
|
rlm@3
|
822 );
|
rlm@3
|
823
|
rlm@3
|
824 $atom_structure['component_name'] = substr(substr($atom_data, 24), 1); /// Pascal2String
|
rlm@3
|
825
|
rlm@3
|
826 if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) {
|
rlm@3
|
827 $info['video']['dataformat'] = 'quicktimevr';
|
rlm@3
|
828 }
|
rlm@3
|
829 break;
|
rlm@3
|
830
|
rlm@3
|
831
|
rlm@3
|
832 case 'mdhd': // MeDia HeaDer atom
|
rlm@3
|
833 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
834 array (
|
rlm@3
|
835 'version' => 1,
|
rlm@3
|
836 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
837 'creation_time' => 4,
|
rlm@3
|
838 'modify_time' => 4,
|
rlm@3
|
839 'time_scale' => 4,
|
rlm@3
|
840 'duration' => 4,
|
rlm@3
|
841 'language_id' => 2,
|
rlm@3
|
842 'quality' => 2
|
rlm@3
|
843 )
|
rlm@3
|
844 );
|
rlm@3
|
845
|
rlm@3
|
846 if ($atom_structure['time_scale'] == 0) {
|
rlm@3
|
847 throw new getid3_exception('Corrupt Quicktime file: mdhd.time_scale == zero');
|
rlm@3
|
848 }
|
rlm@3
|
849 $info_quicktime['time_scale'] = max(@$info['quicktime']['time_scale'], $atom_structure['time_scale']);
|
rlm@3
|
850
|
rlm@3
|
851 $atom_structure['creation_time_unix'] = (int)($atom_structure['creation_time'] - 2082844800); // DateMac2Unix()
|
rlm@3
|
852 $atom_structure['modify_time_unix'] = (int)($atom_structure['modify_time'] - 2082844800); // DateMac2Unix()
|
rlm@3
|
853 $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
|
rlm@3
|
854 $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
|
rlm@3
|
855 if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
|
rlm@3
|
856 $info['comments']['language'][] = $atom_structure['language'];
|
rlm@3
|
857 }
|
rlm@3
|
858 break;
|
rlm@3
|
859
|
rlm@3
|
860
|
rlm@3
|
861 case 'pnot': // Preview atom
|
rlm@3
|
862 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
863 array (
|
rlm@3
|
864 'modification_date' => 4, // "standard Macintosh format"
|
rlm@3
|
865 'version_number' => 2, // hardcoded: 0x00
|
rlm@3
|
866 'atom_type' => -4, // usually: 'PICT'
|
rlm@3
|
867 'atom_index' => 2 // usually: 0x01
|
rlm@3
|
868 )
|
rlm@3
|
869 );
|
rlm@3
|
870 $atom_structure['modification_date_unix'] = (int)($atom_structure['modification_date'] - 2082844800); // DateMac2Unix()
|
rlm@3
|
871 break;
|
rlm@3
|
872
|
rlm@3
|
873
|
rlm@3
|
874 case 'crgn': // Clipping ReGioN atom
|
rlm@3
|
875 $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box,
|
rlm@3
|
876 $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields
|
rlm@3
|
877 $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region.
|
rlm@3
|
878 break;
|
rlm@3
|
879
|
rlm@3
|
880
|
rlm@3
|
881 case 'load': // track LOAD settings atom
|
rlm@3
|
882 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
883 array (
|
rlm@3
|
884 'preload_start_time' => 4,
|
rlm@3
|
885 'preload_duration' => 4,
|
rlm@3
|
886 'preload_flags_raw' => 4,
|
rlm@3
|
887 'default_hints_raw' => 4
|
rlm@3
|
888 )
|
rlm@3
|
889 );
|
rlm@3
|
890
|
rlm@3
|
891 $atom_structure['default_hints']['double_buffer'] = (bool)($atom_structure['default_hints_raw'] & 0x0020);
|
rlm@3
|
892 $atom_structure['default_hints']['high_quality'] = (bool)($atom_structure['default_hints_raw'] & 0x0100);
|
rlm@3
|
893 break;
|
rlm@3
|
894
|
rlm@3
|
895
|
rlm@3
|
896 case 'tmcd': // TiMe CoDe atom
|
rlm@3
|
897 case 'chap': // CHAPter list atom
|
rlm@3
|
898 case 'sync': // SYNChronization atom
|
rlm@3
|
899 case 'scpt': // tranSCriPT atom
|
rlm@3
|
900 case 'ssrc': // non-primary SouRCe atom
|
rlm@3
|
901 for ($i = 0; $i < (strlen($atom_data) % 4); $i++) {
|
rlm@3
|
902 $atom_structure['track_id'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $i * 4, 4));
|
rlm@3
|
903 }
|
rlm@3
|
904 break;
|
rlm@3
|
905
|
rlm@3
|
906
|
rlm@3
|
907 case 'elst': // Edit LiST atom
|
rlm@3
|
908 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
909 array (
|
rlm@3
|
910 'version' => 1,
|
rlm@3
|
911 'flags_raw' => 3, // hardcoded: 0x0000
|
rlm@3
|
912 'number_entries' => 4
|
rlm@3
|
913 )
|
rlm@3
|
914 );
|
rlm@3
|
915
|
rlm@3
|
916 for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) {
|
rlm@3
|
917 $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4));
|
rlm@3
|
918 $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4));
|
rlm@3
|
919 $atom_structure['edit_list'][$i]['media_rate'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4));
|
rlm@3
|
920 }
|
rlm@3
|
921 break;
|
rlm@3
|
922
|
rlm@3
|
923
|
rlm@3
|
924 case 'kmat': // compressed MATte atom
|
rlm@3
|
925 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
rlm@3
|
926 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
rlm@3
|
927 $atom_structure['matte_data_raw'] = substr($atom_data, 4);
|
rlm@3
|
928 break;
|
rlm@3
|
929
|
rlm@3
|
930
|
rlm@3
|
931 case 'ctab': // Color TABle atom
|
rlm@3
|
932 $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000
|
rlm@3
|
933 $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000
|
rlm@3
|
934 $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1;
|
rlm@3
|
935 for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) {
|
rlm@3
|
936 $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2));
|
rlm@3
|
937 $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2));
|
rlm@3
|
938 $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2));
|
rlm@3
|
939 $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2));
|
rlm@3
|
940 }
|
rlm@3
|
941 break;
|
rlm@3
|
942
|
rlm@3
|
943
|
rlm@3
|
944 case 'mvhd': // MoVie HeaDer atom
|
rlm@3
|
945 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
946 array (
|
rlm@3
|
947 'version' => 1,
|
rlm@3
|
948 'flags_raw' => 3,
|
rlm@3
|
949 'creation_time' => 4,
|
rlm@3
|
950 'modify_time' => 4,
|
rlm@3
|
951 'time_scale' => 4,
|
rlm@3
|
952 'duration' => 4
|
rlm@3
|
953 )
|
rlm@3
|
954 );
|
rlm@3
|
955
|
rlm@3
|
956 $atom_structure['preferred_rate'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 20, 4));
|
rlm@3
|
957 $atom_structure['preferred_volume'] = getid3_quicktime::FixedPoint8_8(substr($atom_data, 24, 2));
|
rlm@3
|
958 $atom_structure['reserved'] = substr($atom_data, 26, 10);
|
rlm@3
|
959 $atom_structure['matrix_a'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 36, 4));
|
rlm@3
|
960 $atom_structure['matrix_b'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 40, 4));
|
rlm@3
|
961 $atom_structure['matrix_u'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 44, 4));
|
rlm@3
|
962 $atom_structure['matrix_c'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 48, 4));
|
rlm@3
|
963 $atom_structure['matrix_d'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 52, 4));
|
rlm@3
|
964 $atom_structure['matrix_v'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 56, 4));
|
rlm@3
|
965 $atom_structure['matrix_x'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 60, 4));
|
rlm@3
|
966 $atom_structure['matrix_y'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 64, 4));
|
rlm@3
|
967 $atom_structure['matrix_w'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 68, 4));
|
rlm@3
|
968
|
rlm@3
|
969 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 72,
|
rlm@3
|
970 array (
|
rlm@3
|
971 'preview_time' => 4,
|
rlm@3
|
972 'preview_duration' => 4,
|
rlm@3
|
973 'poster_time' => 4,
|
rlm@3
|
974 'selection_time' => 4,
|
rlm@3
|
975 'selection_duration' => 4,
|
rlm@3
|
976 'current_time' => 4,
|
rlm@3
|
977 'next_track_id' => 4
|
rlm@3
|
978 )
|
rlm@3
|
979 );
|
rlm@3
|
980
|
rlm@3
|
981 if ($atom_structure['time_scale'] == 0) {
|
rlm@3
|
982 throw new getid3_exception('Corrupt Quicktime file: mvhd.time_scale == zero');
|
rlm@3
|
983 }
|
rlm@3
|
984
|
rlm@3
|
985 $atom_structure['creation_time_unix'] = (int)($atom_structure['creation_time'] - 2082844800); // DateMac2Unix()
|
rlm@3
|
986 $atom_structure['modify_time_unix'] = (int)($atom_structure['modify_time'] - 2082844800); // DateMac2Unix()
|
rlm@3
|
987 $info_quicktime['time_scale'] = max(@$info['quicktime']['time_scale'], $atom_structure['time_scale']);
|
rlm@3
|
988 $info_quicktime['display_scale'] = $atom_structure['matrix_a'];
|
rlm@3
|
989 $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
|
rlm@3
|
990 break;
|
rlm@3
|
991
|
rlm@3
|
992
|
rlm@3
|
993 case 'tkhd': // TracK HeaDer atom
|
rlm@3
|
994 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
995 array (
|
rlm@3
|
996 'version' => 1,
|
rlm@3
|
997 'flags_raw' => 3,
|
rlm@3
|
998 'creation_time' => 4,
|
rlm@3
|
999 'modify_time' => 4,
|
rlm@3
|
1000 'trackid' => 4,
|
rlm@3
|
1001 'reserved1' => 4,
|
rlm@3
|
1002 'duration' => 4,
|
rlm@3
|
1003 'reserved2' => 8,
|
rlm@3
|
1004 'layer' => 2,
|
rlm@3
|
1005 'alternate_group' => 2
|
rlm@3
|
1006 )
|
rlm@3
|
1007 );
|
rlm@3
|
1008
|
rlm@3
|
1009 $atom_structure['volume'] = getid3_quicktime::FixedPoint8_8(substr($atom_data, 36, 2));
|
rlm@3
|
1010 $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2));
|
rlm@3
|
1011 $atom_structure['matrix_a'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 40, 4));
|
rlm@3
|
1012 $atom_structure['matrix_b'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 44, 4));
|
rlm@3
|
1013 $atom_structure['matrix_u'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 48, 4));
|
rlm@3
|
1014 $atom_structure['matrix_c'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 52, 4));
|
rlm@3
|
1015 $atom_structure['matrix_v'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 56, 4));
|
rlm@3
|
1016 $atom_structure['matrix_d'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 60, 4));
|
rlm@3
|
1017 $atom_structure['matrix_x'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 64, 4));
|
rlm@3
|
1018 $atom_structure['matrix_y'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 68, 4));
|
rlm@3
|
1019 $atom_structure['matrix_w'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 72, 4));
|
rlm@3
|
1020 $atom_structure['width'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 76, 4));
|
rlm@3
|
1021 $atom_structure['height'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 80, 4));
|
rlm@3
|
1022
|
rlm@3
|
1023 $atom_structure['flags']['enabled'] = (bool)($atom_structure['flags_raw'] & 0x0001);
|
rlm@3
|
1024 $atom_structure['flags']['in_movie'] = (bool)($atom_structure['flags_raw'] & 0x0002);
|
rlm@3
|
1025 $atom_structure['flags']['in_preview'] = (bool)($atom_structure['flags_raw'] & 0x0004);
|
rlm@3
|
1026 $atom_structure['flags']['in_poster'] = (bool)($atom_structure['flags_raw'] & 0x0008);
|
rlm@3
|
1027 $atom_structure['creation_time_unix'] = (int)($atom_structure['creation_time'] - 2082844800); // DateMac2Unix()
|
rlm@3
|
1028 $atom_structure['modify_time_unix'] = (int)($atom_structure['modify_time'] - 2082844800); // DateMac2Unix()
|
rlm@3
|
1029
|
rlm@3
|
1030 if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) {
|
rlm@3
|
1031 $info['video']['resolution_x'] = $atom_structure['width'];
|
rlm@3
|
1032 $info['video']['resolution_y'] = $atom_structure['height'];
|
rlm@3
|
1033 }
|
rlm@3
|
1034
|
rlm@3
|
1035 if ($atom_structure['flags']['enabled'] == 1) {
|
rlm@3
|
1036 $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']);
|
rlm@3
|
1037 $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']);
|
rlm@3
|
1038 }
|
rlm@3
|
1039
|
rlm@3
|
1040 if (!empty($info['video']['resolution_x']) && !empty($info['video']['resolution_y'])) {
|
rlm@3
|
1041 $info_quicktime['video']['resolution_x'] = $info['video']['resolution_x'];
|
rlm@3
|
1042 $info_quicktime['video']['resolution_y'] = $info['video']['resolution_y'];
|
rlm@3
|
1043 } else {
|
rlm@3
|
1044 unset($info['video']['resolution_x']);
|
rlm@3
|
1045 unset($info['video']['resolution_y']);
|
rlm@3
|
1046 unset($info_quicktime['video']);
|
rlm@3
|
1047 }
|
rlm@3
|
1048 break;
|
rlm@3
|
1049
|
rlm@3
|
1050
|
rlm@3
|
1051 case 'meta': // METAdata atom
|
rlm@3
|
1052 // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
|
rlm@3
|
1053 $next_tag_position = strpos($atom_data, '©');
|
rlm@3
|
1054 while ($next_tag_position < strlen($atom_data)) {
|
rlm@3
|
1055 $meta_item_size = getid3_lib::BigEndian2Int(substr($atom_data, $next_tag_position - 4, 4)) - 4;
|
rlm@3
|
1056 if ($meta_item_size == -4) {
|
rlm@3
|
1057 break;
|
rlm@3
|
1058 }
|
rlm@3
|
1059 $meta_item_raw = substr($atom_data, $next_tag_position, $meta_item_size);
|
rlm@3
|
1060 $meta_item_key = substr($meta_item_raw, 0, 4);
|
rlm@3
|
1061 $meta_item_data = substr($meta_item_raw, 20);
|
rlm@3
|
1062 $next_tag_position += $meta_item_size + 4;
|
rlm@3
|
1063
|
rlm@3
|
1064 $this->CopyToAppropriateCommentsSection($meta_item_key, $meta_item_data);
|
rlm@3
|
1065 }
|
rlm@3
|
1066 break;
|
rlm@3
|
1067
|
rlm@3
|
1068 case 'ftyp': // FileTYPe (?) atom (for MP4 it seems)
|
rlm@3
|
1069 getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0,
|
rlm@3
|
1070 array (
|
rlm@3
|
1071 'signature' => -4,
|
rlm@3
|
1072 'unknown_1' => 4,
|
rlm@3
|
1073 'fourcc' => -4,
|
rlm@3
|
1074 )
|
rlm@3
|
1075 );
|
rlm@3
|
1076 break;
|
rlm@3
|
1077
|
rlm@3
|
1078 case 'mdat': // Media DATa atom
|
rlm@3
|
1079 case 'free': // FREE space atom
|
rlm@3
|
1080 case 'skip': // SKIP atom
|
rlm@3
|
1081 case 'wide': // 64-bit expansion placeholder atom
|
rlm@3
|
1082 // 'mdat' data is too big to deal with, contains no useful metadata
|
rlm@3
|
1083 // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
|
rlm@3
|
1084
|
rlm@3
|
1085 // When writing QuickTime files, it is sometimes necessary to update an atom's size.
|
rlm@3
|
1086 // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom
|
rlm@3
|
1087 // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime
|
rlm@3
|
1088 // puts an 8-byte placeholder atom before any atoms it may have to update the size of.
|
rlm@3
|
1089 // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the
|
rlm@3
|
1090 // placeholder atom can be overwritten to obtain the necessary 8 extra bytes.
|
rlm@3
|
1091 // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ).
|
rlm@3
|
1092 break;
|
rlm@3
|
1093
|
rlm@3
|
1094
|
rlm@3
|
1095 case 'nsav': // NoSAVe atom
|
rlm@3
|
1096 // http://developer.apple.com/technotes/tn/tn2038.html
|
rlm@3
|
1097 $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
|
rlm@3
|
1098 break;
|
rlm@3
|
1099
|
rlm@3
|
1100 case 'ctyp': // Controller TYPe atom (seen on QTVR)
|
rlm@3
|
1101 // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt
|
rlm@3
|
1102 // some controller names are:
|
rlm@3
|
1103 // 0x00 + 'std' for linear movie
|
rlm@3
|
1104 // 'none' for no controls
|
rlm@3
|
1105 $atom_structure['ctyp'] = substr($atom_data, 0, 4);
|
rlm@3
|
1106 switch ($atom_structure['ctyp']) {
|
rlm@3
|
1107 case 'qtvr':
|
rlm@3
|
1108 $info['video']['dataformat'] = 'quicktimevr';
|
rlm@3
|
1109 break;
|
rlm@3
|
1110 }
|
rlm@3
|
1111 break;
|
rlm@3
|
1112
|
rlm@3
|
1113 case 'pano': // PANOrama track (seen on QTVR)
|
rlm@3
|
1114 $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
|
rlm@3
|
1115 break;
|
rlm@3
|
1116
|
rlm@3
|
1117 case 'hint': // HINT track
|
rlm@3
|
1118 case 'hinf': //
|
rlm@3
|
1119 case 'hinv': //
|
rlm@3
|
1120 case 'hnti': //
|
rlm@3
|
1121 $info['quicktime']['hinting'] = true;
|
rlm@3
|
1122 break;
|
rlm@3
|
1123
|
rlm@3
|
1124 case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR)
|
rlm@3
|
1125 for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) {
|
rlm@3
|
1126 $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));
|
rlm@3
|
1127 }
|
rlm@3
|
1128 break;
|
rlm@3
|
1129
|
rlm@3
|
1130 case 'FXTC': // Something to do with Adobe After Effects (?)
|
rlm@3
|
1131 case 'PrmA':
|
rlm@3
|
1132 case 'code':
|
rlm@3
|
1133 case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
|
rlm@3
|
1134 // Observed-but-not-handled atom types are just listed here
|
rlm@3
|
1135 // to prevent warnings being generated
|
rlm@3
|
1136 $atom_structure['data'] = $atom_data;
|
rlm@3
|
1137 break;
|
rlm@3
|
1138
|
rlm@3
|
1139 default:
|
rlm@3
|
1140 $getid3->warning('Unknown QuickTime atom type: "'.$atom_name.'" at offset '.$base_offset);
|
rlm@3
|
1141 $atom_structure['data'] = $atom_data;
|
rlm@3
|
1142 break;
|
rlm@3
|
1143 }
|
rlm@3
|
1144 array_pop($atom_hierarchy);
|
rlm@3
|
1145 return $atom_structure;
|
rlm@3
|
1146 }
|
rlm@3
|
1147
|
rlm@3
|
1148
|
rlm@3
|
1149
|
rlm@3
|
1150 private function QuicktimeParseContainerAtom($atom_data, $base_offset, &$atom_hierarchy) {
|
rlm@3
|
1151
|
rlm@3
|
1152 if ((strlen($atom_data) == 4) && (getid3_lib::BigEndian2Int($atom_data) == 0x00000000)) {
|
rlm@3
|
1153 return false;
|
rlm@3
|
1154 }
|
rlm@3
|
1155
|
rlm@3
|
1156 $atom_structure = false;
|
rlm@3
|
1157 $subatom_offset = 0;
|
rlm@3
|
1158
|
rlm@3
|
1159 while ($subatom_offset < strlen($atom_data)) {
|
rlm@3
|
1160
|
rlm@3
|
1161 $subatom_size = getid3_lib::BigEndian2Int(substr($atom_data, $subatom_offset + 0, 4));
|
rlm@3
|
1162 $subatom_name = substr($atom_data, $subatom_offset + 4, 4);
|
rlm@3
|
1163 $subatom_data = substr($atom_data, $subatom_offset + 8, $subatom_size - 8);
|
rlm@3
|
1164
|
rlm@3
|
1165 if ($subatom_size == 0) {
|
rlm@3
|
1166 // Furthermore, for historical reasons the list of atoms is optionally
|
rlm@3
|
1167 // terminated by a 32-bit integer set to 0. If you are writing a program
|
rlm@3
|
1168 // to read user data atoms, you should allow for the terminating 0.
|
rlm@3
|
1169 return $atom_structure;
|
rlm@3
|
1170 }
|
rlm@3
|
1171
|
rlm@3
|
1172 $atom_structure[] = $this->QuicktimeParseAtom($subatom_name, $subatom_size, $subatom_data, $base_offset + $subatom_offset, $atom_hierarchy);
|
rlm@3
|
1173
|
rlm@3
|
1174 $subatom_offset += $subatom_size;
|
rlm@3
|
1175 }
|
rlm@3
|
1176 return $atom_structure;
|
rlm@3
|
1177 }
|
rlm@3
|
1178
|
rlm@3
|
1179
|
rlm@3
|
1180
|
rlm@3
|
1181 private function CopyToAppropriateCommentsSection($key_name, $data) {
|
rlm@3
|
1182
|
rlm@3
|
1183 // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt
|
rlm@3
|
1184
|
rlm@3
|
1185 static $translator = array (
|
rlm@3
|
1186 '©cpy' => 'copyright',
|
rlm@3
|
1187 '©day' => 'creation_date',
|
rlm@3
|
1188 '©dir' => 'director',
|
rlm@3
|
1189 '©ed1' => 'edit1',
|
rlm@3
|
1190 '©ed2' => 'edit2',
|
rlm@3
|
1191 '©ed3' => 'edit3',
|
rlm@3
|
1192 '©ed4' => 'edit4',
|
rlm@3
|
1193 '©ed5' => 'edit5',
|
rlm@3
|
1194 '©ed6' => 'edit6',
|
rlm@3
|
1195 '©ed7' => 'edit7',
|
rlm@3
|
1196 '©ed8' => 'edit8',
|
rlm@3
|
1197 '©ed9' => 'edit9',
|
rlm@3
|
1198 '©fmt' => 'format',
|
rlm@3
|
1199 '©inf' => 'information',
|
rlm@3
|
1200 '©prd' => 'producer',
|
rlm@3
|
1201 '©prf' => 'performers',
|
rlm@3
|
1202 '©req' => 'system_requirements',
|
rlm@3
|
1203 '©src' => 'source_credit',
|
rlm@3
|
1204 '©wrt' => 'writer',
|
rlm@3
|
1205 '©nam' => 'title',
|
rlm@3
|
1206 '©cmt' => 'comment',
|
rlm@3
|
1207 '©wrn' => 'warning',
|
rlm@3
|
1208 '©hst' => 'host_computer',
|
rlm@3
|
1209 '©mak' => 'make',
|
rlm@3
|
1210 '©mod' => 'model',
|
rlm@3
|
1211 '©PRD' => 'product',
|
rlm@3
|
1212 '©swr' => 'software',
|
rlm@3
|
1213 '©aut' => 'author',
|
rlm@3
|
1214 '©ART' => 'artist',
|
rlm@3
|
1215 '©trk' => 'track',
|
rlm@3
|
1216 '©alb' => 'album',
|
rlm@3
|
1217 '©com' => 'comment',
|
rlm@3
|
1218 '©gen' => 'genre',
|
rlm@3
|
1219 '©ope' => 'composer',
|
rlm@3
|
1220 '©url' => 'url',
|
rlm@3
|
1221 '©enc' => 'encoder'
|
rlm@3
|
1222 );
|
rlm@3
|
1223
|
rlm@3
|
1224 if (isset($translator[$key_name])) {
|
rlm@3
|
1225 $this->getid3->info['quicktime']['comments'][$translator[$key_name]][] = $data;
|
rlm@3
|
1226 }
|
rlm@3
|
1227
|
rlm@3
|
1228 return true;
|
rlm@3
|
1229 }
|
rlm@3
|
1230
|
rlm@3
|
1231
|
rlm@3
|
1232
|
rlm@3
|
1233 public static function QuicktimeLanguageLookup($language_id) {
|
rlm@3
|
1234
|
rlm@3
|
1235 static $lookup = array (
|
rlm@3
|
1236 0 => 'English',
|
rlm@3
|
1237 1 => 'French',
|
rlm@3
|
1238 2 => 'German',
|
rlm@3
|
1239 3 => 'Italian',
|
rlm@3
|
1240 4 => 'Dutch',
|
rlm@3
|
1241 5 => 'Swedish',
|
rlm@3
|
1242 6 => 'Spanish',
|
rlm@3
|
1243 7 => 'Danish',
|
rlm@3
|
1244 8 => 'Portuguese',
|
rlm@3
|
1245 9 => 'Norwegian',
|
rlm@3
|
1246 10 => 'Hebrew',
|
rlm@3
|
1247 11 => 'Japanese',
|
rlm@3
|
1248 12 => 'Arabic',
|
rlm@3
|
1249 13 => 'Finnish',
|
rlm@3
|
1250 14 => 'Greek',
|
rlm@3
|
1251 15 => 'Icelandic',
|
rlm@3
|
1252 16 => 'Maltese',
|
rlm@3
|
1253 17 => 'Turkish',
|
rlm@3
|
1254 18 => 'Croatian',
|
rlm@3
|
1255 19 => 'Chinese (Traditional)',
|
rlm@3
|
1256 20 => 'Urdu',
|
rlm@3
|
1257 21 => 'Hindi',
|
rlm@3
|
1258 22 => 'Thai',
|
rlm@3
|
1259 23 => 'Korean',
|
rlm@3
|
1260 24 => 'Lithuanian',
|
rlm@3
|
1261 25 => 'Polish',
|
rlm@3
|
1262 26 => 'Hungarian',
|
rlm@3
|
1263 27 => 'Estonian',
|
rlm@3
|
1264 28 => 'Lettish',
|
rlm@3
|
1265 28 => 'Latvian',
|
rlm@3
|
1266 29 => 'Saamisk',
|
rlm@3
|
1267 29 => 'Lappish',
|
rlm@3
|
1268 30 => 'Faeroese',
|
rlm@3
|
1269 31 => 'Farsi',
|
rlm@3
|
1270 31 => 'Persian',
|
rlm@3
|
1271 32 => 'Russian',
|
rlm@3
|
1272 33 => 'Chinese (Simplified)',
|
rlm@3
|
1273 34 => 'Flemish',
|
rlm@3
|
1274 35 => 'Irish',
|
rlm@3
|
1275 36 => 'Albanian',
|
rlm@3
|
1276 37 => 'Romanian',
|
rlm@3
|
1277 38 => 'Czech',
|
rlm@3
|
1278 39 => 'Slovak',
|
rlm@3
|
1279 40 => 'Slovenian',
|
rlm@3
|
1280 41 => 'Yiddish',
|
rlm@3
|
1281 42 => 'Serbian',
|
rlm@3
|
1282 43 => 'Macedonian',
|
rlm@3
|
1283 44 => 'Bulgarian',
|
rlm@3
|
1284 45 => 'Ukrainian',
|
rlm@3
|
1285 46 => 'Byelorussian',
|
rlm@3
|
1286 47 => 'Uzbek',
|
rlm@3
|
1287 48 => 'Kazakh',
|
rlm@3
|
1288 49 => 'Azerbaijani',
|
rlm@3
|
1289 50 => 'AzerbaijanAr',
|
rlm@3
|
1290 51 => 'Armenian',
|
rlm@3
|
1291 52 => 'Georgian',
|
rlm@3
|
1292 53 => 'Moldavian',
|
rlm@3
|
1293 54 => 'Kirghiz',
|
rlm@3
|
1294 55 => 'Tajiki',
|
rlm@3
|
1295 56 => 'Turkmen',
|
rlm@3
|
1296 57 => 'Mongolian',
|
rlm@3
|
1297 58 => 'MongolianCyr',
|
rlm@3
|
1298 59 => 'Pashto',
|
rlm@3
|
1299 60 => 'Kurdish',
|
rlm@3
|
1300 61 => 'Kashmiri',
|
rlm@3
|
1301 62 => 'Sindhi',
|
rlm@3
|
1302 63 => 'Tibetan',
|
rlm@3
|
1303 64 => 'Nepali',
|
rlm@3
|
1304 65 => 'Sanskrit',
|
rlm@3
|
1305 66 => 'Marathi',
|
rlm@3
|
1306 67 => 'Bengali',
|
rlm@3
|
1307 68 => 'Assamese',
|
rlm@3
|
1308 69 => 'Gujarati',
|
rlm@3
|
1309 70 => 'Punjabi',
|
rlm@3
|
1310 71 => 'Oriya',
|
rlm@3
|
1311 72 => 'Malayalam',
|
rlm@3
|
1312 73 => 'Kannada',
|
rlm@3
|
1313 74 => 'Tamil',
|
rlm@3
|
1314 75 => 'Telugu',
|
rlm@3
|
1315 76 => 'Sinhalese',
|
rlm@3
|
1316 77 => 'Burmese',
|
rlm@3
|
1317 78 => 'Khmer',
|
rlm@3
|
1318 79 => 'Lao',
|
rlm@3
|
1319 80 => 'Vietnamese',
|
rlm@3
|
1320 81 => 'Indonesian',
|
rlm@3
|
1321 82 => 'Tagalog',
|
rlm@3
|
1322 83 => 'MalayRoman',
|
rlm@3
|
1323 84 => 'MalayArabic',
|
rlm@3
|
1324 85 => 'Amharic',
|
rlm@3
|
1325 86 => 'Tigrinya',
|
rlm@3
|
1326 87 => 'Galla',
|
rlm@3
|
1327 87 => 'Oromo',
|
rlm@3
|
1328 88 => 'Somali',
|
rlm@3
|
1329 89 => 'Swahili',
|
rlm@3
|
1330 90 => 'Ruanda',
|
rlm@3
|
1331 91 => 'Rundi',
|
rlm@3
|
1332 92 => 'Chewa',
|
rlm@3
|
1333 93 => 'Malagasy',
|
rlm@3
|
1334 94 => 'Esperanto',
|
rlm@3
|
1335 128 => 'Welsh',
|
rlm@3
|
1336 129 => 'Basque',
|
rlm@3
|
1337 130 => 'Catalan',
|
rlm@3
|
1338 131 => 'Latin',
|
rlm@3
|
1339 132 => 'Quechua',
|
rlm@3
|
1340 133 => 'Guarani',
|
rlm@3
|
1341 134 => 'Aymara',
|
rlm@3
|
1342 135 => 'Tatar',
|
rlm@3
|
1343 136 => 'Uighur',
|
rlm@3
|
1344 137 => 'Dzongkha',
|
rlm@3
|
1345 138 => 'JavaneseRom'
|
rlm@3
|
1346 );
|
rlm@3
|
1347
|
rlm@3
|
1348 return (isset($lookup[$language_id]) ? $lookup[$language_id] : 'invalid');
|
rlm@3
|
1349 }
|
rlm@3
|
1350
|
rlm@3
|
1351
|
rlm@3
|
1352
|
rlm@3
|
1353 public static function QuicktimeVideoCodecLookup($codec_id) {
|
rlm@3
|
1354
|
rlm@3
|
1355 static $lookup = array (
|
rlm@3
|
1356 '3IVX' => '3ivx MPEG-4',
|
rlm@3
|
1357 '3IV1' => '3ivx MPEG-4 v1',
|
rlm@3
|
1358 '3IV2' => '3ivx MPEG-4 v2',
|
rlm@3
|
1359 'avr ' => 'AVR-JPEG',
|
rlm@3
|
1360 'base' => 'Base',
|
rlm@3
|
1361 'WRLE' => 'BMP',
|
rlm@3
|
1362 'cvid' => 'Cinepak',
|
rlm@3
|
1363 'clou' => 'Cloud',
|
rlm@3
|
1364 'cmyk' => 'CMYK',
|
rlm@3
|
1365 'yuv2' => 'ComponentVideo',
|
rlm@3
|
1366 'yuvu' => 'ComponentVideoSigned',
|
rlm@3
|
1367 'yuvs' => 'ComponentVideoUnsigned',
|
rlm@3
|
1368 'dvc ' => 'DVC-NTSC',
|
rlm@3
|
1369 'dvcp' => 'DVC-PAL',
|
rlm@3
|
1370 'dvpn' => 'DVCPro-NTSC',
|
rlm@3
|
1371 'dvpp' => 'DVCPro-PAL',
|
rlm@3
|
1372 'fire' => 'Fire',
|
rlm@3
|
1373 'flic' => 'FLC',
|
rlm@3
|
1374 'b48r' => '48RGB',
|
rlm@3
|
1375 'gif ' => 'GIF',
|
rlm@3
|
1376 'smc ' => 'Graphics',
|
rlm@3
|
1377 'h261' => 'H261',
|
rlm@3
|
1378 'h263' => 'H263',
|
rlm@3
|
1379 'IV41' => 'Indeo4',
|
rlm@3
|
1380 'jpeg' => 'JPEG',
|
rlm@3
|
1381 'PNTG' => 'MacPaint',
|
rlm@3
|
1382 'msvc' => 'Microsoft Video1',
|
rlm@3
|
1383 'mjpa' => 'Motion JPEG-A',
|
rlm@3
|
1384 'mjpb' => 'Motion JPEG-B',
|
rlm@3
|
1385 'myuv' => 'MPEG YUV420',
|
rlm@3
|
1386 'dmb1' => 'OpenDML JPEG',
|
rlm@3
|
1387 'kpcd' => 'PhotoCD',
|
rlm@3
|
1388 '8BPS' => 'Planar RGB',
|
rlm@3
|
1389 'png ' => 'PNG',
|
rlm@3
|
1390 'qdrw' => 'QuickDraw',
|
rlm@3
|
1391 'qdgx' => 'QuickDrawGX',
|
rlm@3
|
1392 'raw ' => 'RAW',
|
rlm@3
|
1393 '.SGI' => 'SGI',
|
rlm@3
|
1394 'b16g' => '16Gray',
|
rlm@3
|
1395 'b64a' => '64ARGB',
|
rlm@3
|
1396 'SVQ1' => 'Sorenson Video 1',
|
rlm@3
|
1397 'SVQ1' => 'Sorenson Video 3',
|
rlm@3
|
1398 'syv9' => 'Sorenson YUV9',
|
rlm@3
|
1399 'tga ' => 'Targa',
|
rlm@3
|
1400 'b32a' => '32AlphaGray',
|
rlm@3
|
1401 'tiff' => 'TIFF',
|
rlm@3
|
1402 'path' => 'Vector',
|
rlm@3
|
1403 'rpza' => 'Video',
|
rlm@3
|
1404 'ripl' => 'WaterRipple',
|
rlm@3
|
1405 'WRAW' => 'Windows RAW',
|
rlm@3
|
1406 'y420' => 'YUV420'
|
rlm@3
|
1407 );
|
rlm@3
|
1408
|
rlm@3
|
1409 return (isset($lookup[$codec_id]) ? $lookup[$codec_id] : '');
|
rlm@3
|
1410 }
|
rlm@3
|
1411
|
rlm@3
|
1412
|
rlm@3
|
1413
|
rlm@3
|
1414 public static function QuicktimeAudioCodecLookup($codec_id) {
|
rlm@3
|
1415
|
rlm@3
|
1416 static $lookup = array (
|
rlm@3
|
1417 '.mp3' => 'Fraunhofer MPEG Layer-III alias',
|
rlm@3
|
1418 'aac ' => 'ISO/IEC 14496-3 AAC',
|
rlm@3
|
1419 'agsm' => 'Apple GSM 10:1',
|
rlm@3
|
1420 'alac' => 'Apple Lossless Audio Codec',
|
rlm@3
|
1421 'alaw' => 'A-law 2:1',
|
rlm@3
|
1422 'conv' => 'Sample Format',
|
rlm@3
|
1423 'dvca' => 'DV',
|
rlm@3
|
1424 'dvi ' => 'DV 4:1',
|
rlm@3
|
1425 'eqal' => 'Frequency Equalizer',
|
rlm@3
|
1426 'fl32' => '32-bit Floating Point',
|
rlm@3
|
1427 'fl64' => '64-bit Floating Point',
|
rlm@3
|
1428 'ima4' => 'Interactive Multimedia Association 4:1',
|
rlm@3
|
1429 'in24' => '24-bit Integer',
|
rlm@3
|
1430 'in32' => '32-bit Integer',
|
rlm@3
|
1431 'lpc ' => 'LPC 23:1',
|
rlm@3
|
1432 'MAC3' => 'Macintosh Audio Compression/Expansion (MACE) 3:1',
|
rlm@3
|
1433 'MAC6' => 'Macintosh Audio Compression/Expansion (MACE) 6:1',
|
rlm@3
|
1434 'mixb' => '8-bit Mixer',
|
rlm@3
|
1435 'mixw' => '16-bit Mixer',
|
rlm@3
|
1436 'mp4a' => 'ISO/IEC 14496-3 AAC',
|
rlm@3
|
1437 "MS'\x00\x02" => 'Microsoft ADPCM',
|
rlm@3
|
1438 "MS'\x00\x11" => 'DV IMA',
|
rlm@3
|
1439 "MS\x00\x55" => 'Fraunhofer MPEG Layer III',
|
rlm@3
|
1440 'NONE' => 'No Encoding',
|
rlm@3
|
1441 'Qclp' => 'Qualcomm PureVoice',
|
rlm@3
|
1442 'QDM2' => 'QDesign Music 2',
|
rlm@3
|
1443 'QDMC' => 'QDesign Music 1',
|
rlm@3
|
1444 'ratb' => '8-bit Rate',
|
rlm@3
|
1445 'ratw' => '16-bit Rate',
|
rlm@3
|
1446 'raw ' => 'raw PCM',
|
rlm@3
|
1447 'sour' => 'Sound Source',
|
rlm@3
|
1448 'sowt' => 'signed/two\'s complement (Little Endian)',
|
rlm@3
|
1449 'str1' => 'Iomega MPEG layer II',
|
rlm@3
|
1450 'str2' => 'Iomega MPEG *layer II',
|
rlm@3
|
1451 'str3' => 'Iomega MPEG **layer II',
|
rlm@3
|
1452 'str4' => 'Iomega MPEG ***layer II',
|
rlm@3
|
1453 'twos' => 'signed/two\'s complement (Big Endian)',
|
rlm@3
|
1454 'ulaw' => 'mu-law 2:1',
|
rlm@3
|
1455 );
|
rlm@3
|
1456
|
rlm@3
|
1457 return (isset($lookup[$codec_id]) ? $lookup[$codec_id] : '');
|
rlm@3
|
1458 }
|
rlm@3
|
1459
|
rlm@3
|
1460
|
rlm@3
|
1461
|
rlm@3
|
1462 public static function QuicktimeDCOMLookup($compression_id) {
|
rlm@3
|
1463
|
rlm@3
|
1464 static $lookup = array (
|
rlm@3
|
1465 'zlib' => 'ZLib Deflate',
|
rlm@3
|
1466 'adec' => 'Apple Compression'
|
rlm@3
|
1467 );
|
rlm@3
|
1468
|
rlm@3
|
1469 return (isset($lookup[$compression_id]) ? $lookup[$compression_id] : '');
|
rlm@3
|
1470 }
|
rlm@3
|
1471
|
rlm@3
|
1472
|
rlm@3
|
1473
|
rlm@3
|
1474 public static function QuicktimeColorNameLookup($color_depth_id) {
|
rlm@3
|
1475
|
rlm@3
|
1476 static $lookup = array (
|
rlm@3
|
1477 1 => '2-color (monochrome)',
|
rlm@3
|
1478 2 => '4-color',
|
rlm@3
|
1479 4 => '16-color',
|
rlm@3
|
1480 8 => '256-color',
|
rlm@3
|
1481 16 => 'thousands (16-bit color)',
|
rlm@3
|
1482 24 => 'millions (24-bit color)',
|
rlm@3
|
1483 32 => 'millions+ (32-bit color)',
|
rlm@3
|
1484 33 => 'black & white',
|
rlm@3
|
1485 34 => '4-gray',
|
rlm@3
|
1486 36 => '16-gray',
|
rlm@3
|
1487 40 => '256-gray',
|
rlm@3
|
1488 );
|
rlm@3
|
1489
|
rlm@3
|
1490 return (isset($lookup[$color_depth_id]) ? $lookup[$color_depth_id] : 'invalid');
|
rlm@3
|
1491 }
|
rlm@3
|
1492
|
rlm@3
|
1493
|
rlm@3
|
1494
|
rlm@3
|
1495 public static function NoNullString($null_terminated_string) {
|
rlm@3
|
1496
|
rlm@3
|
1497 // remove the single null terminator on null terminated strings
|
rlm@3
|
1498 if (substr($null_terminated_string, strlen($null_terminated_string) - 1, 1) === "\x00") {
|
rlm@3
|
1499 return substr($null_terminated_string, 0, strlen($null_terminated_string) - 1);
|
rlm@3
|
1500 }
|
rlm@3
|
1501
|
rlm@3
|
1502 return $null_terminated_string;
|
rlm@3
|
1503 }
|
rlm@3
|
1504
|
rlm@3
|
1505
|
rlm@3
|
1506
|
rlm@3
|
1507 public static function FixedPoint8_8($raw_data) {
|
rlm@3
|
1508
|
rlm@3
|
1509 return getid3_lib::BigEndian2Int($raw_data{0}) + (float)(getid3_lib::BigEndian2Int($raw_data{1}) / 256);
|
rlm@3
|
1510 }
|
rlm@3
|
1511
|
rlm@3
|
1512
|
rlm@3
|
1513
|
rlm@3
|
1514 public static function FixedPoint16_16($raw_data) {
|
rlm@3
|
1515
|
rlm@3
|
1516 return getid3_lib::BigEndian2Int(substr($raw_data, 0, 2)) + (float)(getid3_lib::BigEndian2Int(substr($raw_data, 2, 2)) / 65536);
|
rlm@3
|
1517 }
|
rlm@3
|
1518
|
rlm@3
|
1519
|
rlm@3
|
1520
|
rlm@3
|
1521 public static function FixedPoint2_30($raw_data) {
|
rlm@3
|
1522
|
rlm@3
|
1523 $binary_string = getid3_lib::BigEndian2Bin($raw_data);
|
rlm@3
|
1524 return bindec(substr($binary_string, 0, 2)) + (float)(bindec(substr($binary_string, 2, 30)) / 1073741824);
|
rlm@3
|
1525 }
|
rlm@3
|
1526
|
rlm@3
|
1527 }
|
rlm@3
|
1528
|
rlm@3
|
1529 ?> |