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