Conditions | 171 |
Paths | 172 |
Total Lines | 967 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
179 | private function QuicktimeParseAtom($atom_name, $atom_size, $atom_data, $base_offset, &$atom_hierarchy) { |
||
180 | |||
181 | // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm |
||
182 | |||
183 | $getid3 = $this->getid3; |
||
184 | |||
185 | $info = &$getid3->info; |
||
186 | $info_quicktime = &$info['quicktime']; |
||
187 | |||
188 | array_push($atom_hierarchy, $atom_name); |
||
189 | $atom_structure['hierarchy'] = implode(' ', $atom_hierarchy); |
||
190 | $atom_structure['name'] = $atom_name; |
||
191 | $atom_structure['size'] = $atom_size; |
||
192 | $atom_structure['offset'] = $base_offset; |
||
193 | |||
194 | switch ($atom_name) { |
||
195 | case 'moov': // MOVie container atom |
||
196 | case 'trak': // TRAcK container atom |
||
197 | case 'clip': // CLIPping container atom |
||
198 | case 'matt': // track MATTe container atom |
||
199 | case 'edts': // EDiTS container atom |
||
200 | case 'tref': // Track REFerence container atom |
||
201 | case 'mdia': // MeDIA container atom |
||
202 | case 'minf': // Media INFormation container atom |
||
203 | case 'dinf': // Data INFormation container atom |
||
204 | case 'udta': // User DaTA container atom |
||
205 | case 'stbl': // Sample TaBLe container atom |
||
206 | case 'cmov': // Compressed MOVie container atom |
||
207 | case 'rmra': // Reference Movie Record Atom |
||
208 | case 'rmda': // Reference Movie Descriptor Atom |
||
209 | case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR) |
||
210 | $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $base_offset + 8, $atom_hierarchy); |
||
211 | break; |
||
212 | |||
213 | |||
214 | case '�cpy': |
||
215 | case '�day': |
||
216 | case '�dir': |
||
217 | case '�ed1': |
||
218 | case '�ed2': |
||
219 | case '�ed3': |
||
220 | case '�ed4': |
||
221 | case '�ed5': |
||
222 | case '�ed6': |
||
223 | case '�ed7': |
||
224 | case '�ed8': |
||
225 | case '�ed9': |
||
226 | case '�fmt': |
||
227 | case '�inf': |
||
228 | case '�prd': |
||
229 | case '�prf': |
||
230 | case '�req': |
||
231 | case '�src': |
||
232 | case '�wrt': |
||
233 | case '�nam': |
||
234 | case '�cmt': |
||
235 | case '�wrn': |
||
236 | case '�hst': |
||
237 | case '�mak': |
||
238 | case '�mod': |
||
239 | case '�PRD': |
||
240 | case '�swr': |
||
241 | case '�aut': |
||
242 | case '�ART': |
||
243 | case '�trk': |
||
244 | case '�alb': |
||
245 | case '�com': |
||
246 | case '�gen': |
||
247 | case '�ope': |
||
248 | case '�url': |
||
249 | case '�enc': |
||
250 | $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); |
||
251 | $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); |
||
252 | $atom_structure['data'] = substr($atom_data, 4); |
||
253 | |||
254 | $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); |
||
255 | if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { |
||
256 | $info['comments']['language'][] = $atom_structure['language']; |
||
257 | } |
||
258 | $this->CopyToAppropriateCommentsSection($atom_name, $atom_structure['data']); |
||
259 | break; |
||
260 | |||
261 | |||
262 | case 'play': // auto-PLAY atom |
||
263 | $atom_structure['autoplay'] = (bool)getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); |
||
264 | |||
265 | $info_quicktime['autoplay'] = $atom_structure['autoplay']; |
||
266 | break; |
||
267 | |||
268 | |||
269 | case 'WLOC': // Window LOCation atom |
||
270 | $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); |
||
271 | $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); |
||
272 | break; |
||
273 | |||
274 | |||
275 | case 'LOOP': // LOOPing atom |
||
276 | case 'SelO': // play SELection Only atom |
||
277 | case 'AllF': // play ALL Frames atom |
||
278 | $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data); |
||
279 | break; |
||
280 | |||
281 | |||
282 | case 'name': // |
||
283 | case 'MCPS': // Media Cleaner PRo |
||
284 | case '@PRM': // adobe PReMiere version |
||
285 | case '@PRQ': // adobe PRemiere Quicktime version |
||
286 | $atom_structure['data'] = $atom_data; |
||
287 | break; |
||
288 | |||
289 | |||
290 | case 'cmvd': // Compressed MooV Data atom |
||
291 | // Code by ubergeek�ubergeek*tv based on information from |
||
292 | // http://developer.apple.com/quicktime/icefloe/dispatch012.html |
||
293 | $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); |
||
294 | |||
295 | $compressed_file_data = substr($atom_data, 4); |
||
296 | if (!function_exists('gzuncompress')) { |
||
297 | $getid3->warning('PHP does not have zlib support - cannot decompress MOV atom at offset '.$atom_structure['offset']); |
||
298 | } |
||
299 | elseif ($uncompressed_header = @gzuncompress($compressed_file_data)) { |
||
300 | $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($uncompressed_header, 0, $atom_hierarchy); |
||
301 | } else { |
||
302 | $getid3->warning('Error decompressing compressed MOV atom at offset '.$atom_structure['offset']); |
||
303 | } |
||
304 | break; |
||
305 | |||
306 | |||
307 | case 'dcom': // Data COMpression atom |
||
308 | $atom_structure['compression_id'] = $atom_data; |
||
309 | $atom_structure['compression_text'] = getid3_quicktime::QuicktimeDCOMLookup($atom_data); |
||
310 | break; |
||
311 | |||
312 | |||
313 | case 'rdrf': // Reference movie Data ReFerence atom |
||
314 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
315 | array ( |
||
316 | 'version' => 1, |
||
317 | 'flags_raw' => 3, |
||
318 | 'reference_type_name' => -4, |
||
319 | 'reference_length' => 4, |
||
320 | ) |
||
321 | ); |
||
322 | |||
323 | $atom_structure['flags']['internal_data'] = (bool)($atom_structure['flags_raw'] & 0x000001); |
||
324 | |||
325 | switch ($atom_structure['reference_type_name']) { |
||
326 | case 'url ': |
||
327 | $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12)); |
||
328 | break; |
||
329 | |||
330 | case 'alis': |
||
331 | $atom_structure['file_alias'] = substr($atom_data, 12); |
||
332 | break; |
||
333 | |||
334 | case 'rsrc': |
||
335 | $atom_structure['resource_alias'] = substr($atom_data, 12); |
||
336 | break; |
||
337 | |||
338 | default: |
||
339 | $atom_structure['data'] = substr($atom_data, 12); |
||
340 | break; |
||
341 | } |
||
342 | break; |
||
343 | |||
344 | |||
345 | case 'rmqu': // Reference Movie QUality atom |
||
346 | $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data); |
||
347 | break; |
||
348 | |||
349 | |||
350 | case 'rmcs': // Reference Movie Cpu Speed atom |
||
351 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
352 | array ( |
||
353 | 'version' => 1, |
||
354 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
355 | 'cpu_speed_rating' => 2 |
||
356 | ) |
||
357 | ); |
||
358 | break; |
||
359 | |||
360 | |||
361 | case 'rmvc': // Reference Movie Version Check atom |
||
362 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
363 | array ( |
||
364 | 'version' => 1, |
||
365 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
366 | 'gestalt_selector' => -4, |
||
367 | 'gestalt_value_mask' => 4, |
||
368 | 'gestalt_value' => 4, |
||
369 | 'gestalt_check_type' => 2 |
||
370 | ) |
||
371 | ); |
||
372 | break; |
||
373 | |||
374 | |||
375 | case 'rmcd': // Reference Movie Component check atom |
||
376 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
377 | array ( |
||
378 | 'version' => 1, |
||
379 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
380 | 'component_type' => -4, |
||
381 | 'component_subtype' => -4, |
||
382 | 'component_manufacturer' => -4, |
||
383 | 'component_flags_raw' => 4, |
||
384 | 'component_flags_mask' => 4, |
||
385 | 'component_min_version' => 4 |
||
386 | ) |
||
387 | ); |
||
388 | break; |
||
389 | |||
390 | |||
391 | case 'rmdr': // Reference Movie Data Rate atom |
||
392 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
393 | array ( |
||
394 | 'version' => 1, |
||
395 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
396 | 'data_rate' => 4 |
||
397 | ) |
||
398 | ); |
||
399 | |||
400 | $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10; |
||
401 | break; |
||
402 | |||
403 | |||
404 | case 'rmla': // Reference Movie Language Atom |
||
405 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
406 | array ( |
||
407 | 'version' => 1, |
||
408 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
409 | 'language_id' => 2 |
||
410 | ) |
||
411 | ); |
||
412 | |||
413 | $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); |
||
414 | if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { |
||
415 | $info['comments']['language'][] = $atom_structure['language']; |
||
416 | } |
||
417 | break; |
||
418 | |||
419 | |||
420 | case 'rmla': // Reference Movie Language Atom |
||
421 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
422 | array ( |
||
423 | 'version' => 1, |
||
424 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
425 | 'track_id' => 2 |
||
426 | ) |
||
427 | ); |
||
428 | break; |
||
429 | |||
430 | |||
431 | case 'ptv ': // Print To Video - defines a movie's full screen mode |
||
432 | // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm |
||
433 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
434 | array ( |
||
435 | 'display_size_raw' => 2, |
||
436 | 'reserved_1' => 2, // hardcoded: 0x0000 |
||
437 | 'reserved_2' => 2, // hardcoded: 0x0000 |
||
438 | 'slide_show_flag' => 1, |
||
439 | 'play_on_open_flag' => 1 |
||
440 | ) |
||
441 | ); |
||
442 | |||
443 | $atom_structure['flags']['play_on_open'] = (bool)$atom_structure['play_on_open_flag']; |
||
444 | $atom_structure['flags']['slide_show'] = (bool)$atom_structure['slide_show_flag']; |
||
445 | |||
446 | $ptv_lookup[0] = 'normal'; |
||
447 | $ptv_lookup[1] = 'double'; |
||
448 | $ptv_lookup[2] = 'half'; |
||
449 | $ptv_lookup[3] = 'full'; |
||
450 | $ptv_lookup[4] = 'current'; |
||
451 | if (isset($ptv_lookup[$atom_structure['display_size_raw']])) { |
||
452 | $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']]; |
||
453 | } else { |
||
454 | $getid3->warning('unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')'); |
||
455 | } |
||
456 | break; |
||
457 | |||
458 | |||
459 | case 'stsd': // Sample Table Sample Description atom |
||
460 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
461 | array ( |
||
462 | 'version' => 1, |
||
463 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
464 | 'number_entries' => 4 |
||
465 | ) |
||
466 | ); |
||
467 | $stsd_entries_data_offset = 8; |
||
468 | for ($i = 0; $i < $atom_structure['number_entries']; $i++) { |
||
469 | |||
470 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_data, $stsd_entries_data_offset, |
||
471 | array ( |
||
472 | 'size' => 4, |
||
473 | 'data_format' => -4, |
||
474 | 'reserved' => 6, |
||
475 | 'reference_index' => 2 |
||
476 | ) |
||
477 | ); |
||
478 | |||
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)); |
||
480 | $stsd_entries_data_offset += 16 + ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2); |
||
481 | |||
482 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 0, |
||
483 | array ( |
||
484 | 'encoder_version' => 2, |
||
485 | 'encoder_revision' => 2, |
||
486 | 'encoder_vendor' => -4 |
||
487 | ) |
||
488 | ); |
||
489 | |||
490 | switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) { |
||
491 | |||
492 | case "\x00\x00\x00\x00": |
||
493 | // audio atom |
||
494 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 8, |
||
495 | array ( |
||
496 | 'audio_channels' => 2, |
||
497 | 'audio_bit_depth' => 2, |
||
498 | 'audio_compression_id' => 2, |
||
499 | 'audio_packet_size' => 2 |
||
500 | ) |
||
501 | ); |
||
502 | |||
503 | $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_quicktime::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4)); |
||
504 | |||
505 | switch ($atom_structure['sample_description_table'][$i]['data_format']) { |
||
506 | |||
507 | case 'mp4v': |
||
508 | $info['fileformat'] = 'mp4'; |
||
509 | throw new getid3_exception('This version of getID3() does not fully support MPEG-4 audio/video streams'); |
||
510 | |||
511 | case 'qtvr': |
||
512 | $info['video']['dataformat'] = 'quicktimevr'; |
||
513 | break; |
||
514 | |||
515 | case 'mp4a': |
||
516 | default: |
||
517 | $info_quicktime['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']); |
||
518 | $info_quicktime['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate']; |
||
519 | $info_quicktime['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels']; |
||
520 | $info_quicktime['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth']; |
||
521 | $info['audio']['codec'] = $info_quicktime['audio']['codec']; |
||
522 | $info['audio']['sample_rate'] = $info_quicktime['audio']['sample_rate']; |
||
523 | $info['audio']['channels'] = $info_quicktime['audio']['channels']; |
||
524 | $info['audio']['bits_per_sample'] = $info_quicktime['audio']['bit_depth']; |
||
525 | switch ($atom_structure['sample_description_table'][$i]['data_format']) { |
||
526 | case 'raw ': // PCM |
||
527 | case 'alac': // Apple Lossless Audio Codec |
||
528 | $info['audio']['lossless'] = true; |
||
529 | break; |
||
530 | default: |
||
531 | $info['audio']['lossless'] = false; |
||
532 | break; |
||
533 | } |
||
534 | break; |
||
535 | } |
||
536 | break; |
||
537 | |||
538 | default: |
||
539 | switch ($atom_structure['sample_description_table'][$i]['data_format']) { |
||
540 | case 'mp4s': |
||
541 | $info['fileformat'] = 'mp4'; |
||
542 | break; |
||
543 | |||
544 | default: |
||
545 | // video atom |
||
546 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 8, |
||
547 | array ( |
||
548 | 'video_temporal_quality' => 4, |
||
549 | 'video_spatial_quality' => 4, |
||
550 | 'video_frame_width' => 2, |
||
551 | 'video_frame_height' => 2 |
||
552 | ) |
||
553 | ); |
||
554 | $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_quicktime::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4)); |
||
555 | $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_quicktime::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4)); |
||
556 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 28, |
||
557 | array ( |
||
558 | 'video_data_size' => 4, |
||
559 | 'video_frame_count' => 2, |
||
560 | 'video_encoder_name_len' => 1 |
||
561 | ) |
||
562 | ); |
||
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']); |
||
564 | $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2)); |
||
565 | $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2)); |
||
566 | |||
567 | $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color'); |
||
568 | $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']); |
||
569 | |||
570 | if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') { |
||
571 | $info_quicktime['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format']; |
||
572 | $info_quicktime['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']); |
||
573 | $info_quicktime['video']['codec'] = $atom_structure['sample_description_table'][$i]['video_encoder_name']; |
||
574 | $info_quicktime['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth']; |
||
575 | $info_quicktime['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name']; |
||
576 | |||
577 | $info['video']['codec'] = $info_quicktime['video']['codec']; |
||
578 | $info['video']['bits_per_sample'] = $info_quicktime['video']['color_depth']; |
||
579 | } |
||
580 | $info['video']['lossless'] = false; |
||
581 | $info['video']['pixel_aspect_ratio'] = (float)1; |
||
582 | break; |
||
583 | } |
||
584 | break; |
||
585 | } |
||
586 | switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) { |
||
587 | case 'mp4a': |
||
588 | $info['audio']['dataformat'] = $info_quicktime['audio']['codec'] = 'mp4'; |
||
589 | break; |
||
590 | |||
591 | case '3ivx': |
||
592 | case '3iv1': |
||
593 | case '3iv2': |
||
594 | $info['video']['dataformat'] = '3ivx'; |
||
595 | break; |
||
596 | |||
597 | case 'xvid': |
||
598 | $info['video']['dataformat'] = 'xvid'; |
||
599 | break; |
||
600 | |||
601 | case 'mp4v': |
||
602 | $info['video']['dataformat'] = 'mpeg4'; |
||
603 | break; |
||
604 | |||
605 | case 'divx': |
||
606 | case 'div1': |
||
607 | case 'div2': |
||
608 | case 'div3': |
||
609 | case 'div4': |
||
610 | case 'div5': |
||
611 | case 'div6': |
||
612 | //$TDIVXileInfo['video']['dataformat'] = 'divx'; |
||
613 | break; |
||
614 | |||
615 | default: |
||
616 | // do nothing |
||
617 | break; |
||
618 | } |
||
619 | unset($atom_structure['sample_description_table'][$i]['data']); |
||
620 | } |
||
621 | break; |
||
622 | |||
623 | |||
624 | case 'stts': // Sample Table Time-to-Sample atom |
||
625 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
626 | array ( |
||
627 | 'version' => 1, |
||
628 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
629 | 'number_entries' => 4 |
||
630 | ) |
||
631 | ); |
||
632 | |||
633 | $stts_entries_data_offset = 8; |
||
634 | $frame_rate_calculator_array = array (); |
||
635 | for ($i = 0; $i < $atom_structure['number_entries']; $i++) { |
||
636 | |||
637 | $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $stts_entries_data_offset, 4)); |
||
638 | $stts_entries_data_offset += 4; |
||
639 | |||
640 | $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $stts_entries_data_offset, 4)); |
||
641 | $stts_entries_data_offset += 4; |
||
642 | |||
643 | if (!empty($info_quicktime['time_scale']) && (@$atoms_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) { |
||
644 | |||
645 | $stts_new_framerate = $info_quicktime['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration']; |
||
646 | if ($stts_new_framerate <= 60) { |
||
647 | // some atoms have durations of "1" giving a very large framerate, which probably is not right |
||
648 | $info['video']['frame_rate'] = max(@$info['video']['frame_rate'], $stts_new_framerate); |
||
649 | } |
||
650 | } |
||
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']; |
||
652 | } |
||
653 | /* |
||
654 | $stts_frames_total = 0; |
||
655 | $stts_seconds_total = 0; |
||
656 | foreach ($frame_rate_calculator_array as $frames_per_second => $frame_count) { |
||
657 | if (($frames_per_second > 60) || ($frames_per_second < 1)) { |
||
658 | // not video FPS information, probably audio information |
||
659 | $stts_frames_total = 0; |
||
660 | $stts_seconds_total = 0; |
||
661 | break; |
||
662 | } |
||
663 | $stts_frames_total += $frame_count; |
||
664 | $stts_seconds_total += $frame_count / $frames_per_second; |
||
665 | } |
||
666 | if (($stts_frames_total > 0) && ($stts_seconds_total > 0)) { |
||
667 | if (($stts_frames_total / $stts_seconds_total) > @$info['video']['frame_rate']) { |
||
668 | $info['video']['frame_rate'] = $stts_frames_total / $stts_seconds_total; |
||
669 | } |
||
670 | } |
||
671 | */ |
||
672 | break; |
||
673 | |||
674 | |||
675 | case 'stss': // Sample Table Sync Sample (key frames) atom |
||
676 | /* |
||
677 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); |
||
678 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 |
||
679 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); |
||
680 | $stss_entries_data_offset = 8; |
||
681 | for ($i = 0; $i < $atom_structure['number_entries']; $i++) { |
||
682 | $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stss_entries_data_offset, 4)); |
||
683 | $stss_entries_data_offset += 4; |
||
684 | } |
||
685 | */ |
||
686 | break; |
||
687 | |||
688 | |||
689 | case 'stsc': // Sample Table Sample-to-Chunk atom |
||
690 | /* |
||
691 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); |
||
692 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 |
||
693 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); |
||
694 | $stsc_entries_data_offset = 8; |
||
695 | for ($i = 0; $i < $atom_structure['number_entries']; $i++) { |
||
696 | $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsc_entries_data_offset, 4)); |
||
697 | $stsc_entries_data_offset += 4; |
||
698 | $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsc_entries_data_offset, 4)); |
||
699 | $stsc_entries_data_offset += 4; |
||
700 | $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsc_entries_data_offset, 4)); |
||
701 | $stsc_entries_data_offset += 4; |
||
702 | } |
||
703 | */ |
||
704 | break; |
||
705 | |||
706 | |||
707 | case 'stsz': // Sample Table SiZe atom |
||
708 | /* |
||
709 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); |
||
710 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 |
||
711 | $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); |
||
712 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); |
||
713 | $stsz_entries_data_offset = 12; |
||
714 | if ($atom_structure['sample_size'] == 0) { |
||
715 | for ($i = 0; $i < $atom_structure['number_entries']; $i++) { |
||
716 | $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stsz_entries_data_offset, 4)); |
||
717 | $stsz_entries_data_offset += 4; |
||
718 | } |
||
719 | } |
||
720 | */ |
||
721 | break; |
||
722 | |||
723 | |||
724 | case 'stco': // Sample Table Chunk Offset atom |
||
725 | /* |
||
726 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); |
||
727 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 |
||
728 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); |
||
729 | $stco_entries_data_offset = 8; |
||
730 | for ($i = 0; $i < $atom_structure['number_entries']; $i++) { |
||
731 | $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stco_entries_data_offset, 4)); |
||
732 | $stco_entries_data_offset += 4; |
||
733 | } |
||
734 | */ |
||
735 | break; |
||
736 | |||
737 | |||
738 | case 'dref': // Data REFerence atom |
||
739 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
740 | array ( |
||
741 | 'version' => 1, |
||
742 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
743 | 'number_entries' => 4 |
||
744 | ) |
||
745 | ); |
||
746 | |||
747 | $dref_data_offset = 8; |
||
748 | for ($i = 0; $i < $atom_structure['number_entries']; $i++) { |
||
749 | |||
750 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['data_references'][$i], $atom_data, $dref_data_offset, |
||
751 | array ( |
||
752 | 'size' => 4, |
||
753 | 'type' => -4, |
||
754 | 'version' => 1, |
||
755 | 'flags_raw' => 3 // hardcoded: 0x0000 |
||
756 | ) |
||
757 | ); |
||
758 | $dref_data_offset += 12; |
||
759 | |||
760 | $atom_structure['data_references'][$i]['data'] = substr($atom_data, $dref_data_offset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3)); |
||
761 | $dref_data_offset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3); |
||
762 | |||
763 | $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool)($atom_structure['data_references'][$i]['flags_raw'] & 0x001); |
||
764 | } |
||
765 | break; |
||
766 | |||
767 | |||
768 | case 'gmin': // base Media INformation atom |
||
769 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
770 | array ( |
||
771 | 'version' => 1, |
||
772 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
773 | 'graphics_mode' => 2, |
||
774 | 'opcolor_red' => 2, |
||
775 | 'opcolor_green' => 2, |
||
776 | 'opcolor_blue' => 2, |
||
777 | 'balance' => 2, |
||
778 | 'reserved' => 2 |
||
779 | ) |
||
780 | ); |
||
781 | break; |
||
782 | |||
783 | |||
784 | case 'smhd': // Sound Media information HeaDer atom |
||
785 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
786 | array ( |
||
787 | 'version' => 1, |
||
788 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
789 | 'balance' => 2, |
||
790 | 'reserved' => 2 |
||
791 | ) |
||
792 | ); |
||
793 | break; |
||
794 | |||
795 | |||
796 | case 'vmhd': // Video Media information HeaDer atom |
||
797 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
798 | array ( |
||
799 | 'version' => 1, |
||
800 | 'flags_raw' => 3, |
||
801 | 'graphics_mode' => 2, |
||
802 | 'opcolor_red' => 2, |
||
803 | 'opcolor_green' => 2, |
||
804 | 'opcolor_blue' => 2 |
||
805 | ) |
||
806 | ); |
||
807 | $atom_structure['flags']['no_lean_ahead'] = (bool)($atom_structure['flags_raw'] & 0x001); |
||
808 | break; |
||
809 | |||
810 | |||
811 | case 'hdlr': // HanDLeR reference atom |
||
812 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
813 | array ( |
||
814 | 'version' => 1, |
||
815 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
816 | 'component_type' => -4, |
||
817 | 'component_subtype' => -4, |
||
818 | 'component_manufacturer' => -4, |
||
819 | 'component_flags_raw' => 4, |
||
820 | 'component_flags_mask' => 4 |
||
821 | ) |
||
822 | ); |
||
823 | |||
824 | $atom_structure['component_name'] = substr(substr($atom_data, 24), 1); /// Pascal2String |
||
825 | |||
826 | if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) { |
||
827 | $info['video']['dataformat'] = 'quicktimevr'; |
||
828 | } |
||
829 | break; |
||
830 | |||
831 | |||
832 | case 'mdhd': // MeDia HeaDer atom |
||
833 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
834 | array ( |
||
835 | 'version' => 1, |
||
836 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
837 | 'creation_time' => 4, |
||
838 | 'modify_time' => 4, |
||
839 | 'time_scale' => 4, |
||
840 | 'duration' => 4, |
||
841 | 'language_id' => 2, |
||
842 | 'quality' => 2 |
||
843 | ) |
||
844 | ); |
||
845 | |||
846 | if ($atom_structure['time_scale'] == 0) { |
||
847 | throw new getid3_exception('Corrupt Quicktime file: mdhd.time_scale == zero'); |
||
848 | } |
||
849 | $info_quicktime['time_scale'] = max(@$info['quicktime']['time_scale'], $atom_structure['time_scale']); |
||
850 | |||
851 | $atom_structure['creation_time_unix'] = (int)($atom_structure['creation_time'] - 2082844800); // DateMac2Unix() |
||
852 | $atom_structure['modify_time_unix'] = (int)($atom_structure['modify_time'] - 2082844800); // DateMac2Unix() |
||
853 | $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale']; |
||
854 | $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); |
||
855 | if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { |
||
856 | $info['comments']['language'][] = $atom_structure['language']; |
||
857 | } |
||
858 | break; |
||
859 | |||
860 | |||
861 | case 'pnot': // Preview atom |
||
862 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
863 | array ( |
||
864 | 'modification_date' => 4, // "standard Macintosh format" |
||
865 | 'version_number' => 2, // hardcoded: 0x00 |
||
866 | 'atom_type' => -4, // usually: 'PICT' |
||
867 | 'atom_index' => 2 // usually: 0x01 |
||
868 | ) |
||
869 | ); |
||
870 | $atom_structure['modification_date_unix'] = (int)($atom_structure['modification_date'] - 2082844800); // DateMac2Unix() |
||
871 | break; |
||
872 | |||
873 | |||
874 | case 'crgn': // Clipping ReGioN atom |
||
875 | $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box, |
||
876 | $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields |
||
877 | $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region. |
||
878 | break; |
||
879 | |||
880 | |||
881 | case 'load': // track LOAD settings atom |
||
882 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
883 | array ( |
||
884 | 'preload_start_time' => 4, |
||
885 | 'preload_duration' => 4, |
||
886 | 'preload_flags_raw' => 4, |
||
887 | 'default_hints_raw' => 4 |
||
888 | ) |
||
889 | ); |
||
890 | |||
891 | $atom_structure['default_hints']['double_buffer'] = (bool)($atom_structure['default_hints_raw'] & 0x0020); |
||
892 | $atom_structure['default_hints']['high_quality'] = (bool)($atom_structure['default_hints_raw'] & 0x0100); |
||
893 | break; |
||
894 | |||
895 | |||
896 | case 'tmcd': // TiMe CoDe atom |
||
897 | case 'chap': // CHAPter list atom |
||
898 | case 'sync': // SYNChronization atom |
||
899 | case 'scpt': // tranSCriPT atom |
||
900 | case 'ssrc': // non-primary SouRCe atom |
||
901 | for ($i = 0; $i < (strlen($atom_data) % 4); $i++) { |
||
902 | $atom_structure['track_id'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $i * 4, 4)); |
||
903 | } |
||
904 | break; |
||
905 | |||
906 | |||
907 | case 'elst': // Edit LiST atom |
||
908 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
909 | array ( |
||
910 | 'version' => 1, |
||
911 | 'flags_raw' => 3, // hardcoded: 0x0000 |
||
912 | 'number_entries' => 4 |
||
913 | ) |
||
914 | ); |
||
915 | |||
916 | for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) { |
||
917 | $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4)); |
||
918 | $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4)); |
||
919 | $atom_structure['edit_list'][$i]['media_rate'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4)); |
||
920 | } |
||
921 | break; |
||
922 | |||
923 | |||
924 | case 'kmat': // compressed MATte atom |
||
925 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); |
||
926 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 |
||
927 | $atom_structure['matte_data_raw'] = substr($atom_data, 4); |
||
928 | break; |
||
929 | |||
930 | |||
931 | case 'ctab': // Color TABle atom |
||
932 | $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000 |
||
933 | $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000 |
||
934 | $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1; |
||
935 | for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) { |
||
936 | $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2)); |
||
937 | $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2)); |
||
938 | $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2)); |
||
939 | $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2)); |
||
940 | } |
||
941 | break; |
||
942 | |||
943 | |||
944 | case 'mvhd': // MoVie HeaDer atom |
||
945 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
946 | array ( |
||
947 | 'version' => 1, |
||
948 | 'flags_raw' => 3, |
||
949 | 'creation_time' => 4, |
||
950 | 'modify_time' => 4, |
||
951 | 'time_scale' => 4, |
||
952 | 'duration' => 4 |
||
953 | ) |
||
954 | ); |
||
955 | |||
956 | $atom_structure['preferred_rate'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 20, 4)); |
||
957 | $atom_structure['preferred_volume'] = getid3_quicktime::FixedPoint8_8(substr($atom_data, 24, 2)); |
||
958 | $atom_structure['reserved'] = substr($atom_data, 26, 10); |
||
959 | $atom_structure['matrix_a'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 36, 4)); |
||
960 | $atom_structure['matrix_b'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 40, 4)); |
||
961 | $atom_structure['matrix_u'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 44, 4)); |
||
962 | $atom_structure['matrix_c'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 48, 4)); |
||
963 | $atom_structure['matrix_d'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 52, 4)); |
||
964 | $atom_structure['matrix_v'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 56, 4)); |
||
965 | $atom_structure['matrix_x'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 60, 4)); |
||
966 | $atom_structure['matrix_y'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 64, 4)); |
||
967 | $atom_structure['matrix_w'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 68, 4)); |
||
968 | |||
969 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 72, |
||
970 | array ( |
||
971 | 'preview_time' => 4, |
||
972 | 'preview_duration' => 4, |
||
973 | 'poster_time' => 4, |
||
974 | 'selection_time' => 4, |
||
975 | 'selection_duration' => 4, |
||
976 | 'current_time' => 4, |
||
977 | 'next_track_id' => 4 |
||
978 | ) |
||
979 | ); |
||
980 | |||
981 | if ($atom_structure['time_scale'] == 0) { |
||
982 | throw new getid3_exception('Corrupt Quicktime file: mvhd.time_scale == zero'); |
||
983 | } |
||
984 | |||
985 | $atom_structure['creation_time_unix'] = (int)($atom_structure['creation_time'] - 2082844800); // DateMac2Unix() |
||
986 | $atom_structure['modify_time_unix'] = (int)($atom_structure['modify_time'] - 2082844800); // DateMac2Unix() |
||
987 | $info_quicktime['time_scale'] = max(@$info['quicktime']['time_scale'], $atom_structure['time_scale']); |
||
988 | $info_quicktime['display_scale'] = $atom_structure['matrix_a']; |
||
989 | $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale']; |
||
990 | break; |
||
991 | |||
992 | |||
993 | case 'tkhd': // TracK HeaDer atom |
||
994 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
995 | array ( |
||
996 | 'version' => 1, |
||
997 | 'flags_raw' => 3, |
||
998 | 'creation_time' => 4, |
||
999 | 'modify_time' => 4, |
||
1000 | 'trackid' => 4, |
||
1001 | 'reserved1' => 4, |
||
1002 | 'duration' => 4, |
||
1003 | 'reserved2' => 8, |
||
1004 | 'layer' => 2, |
||
1005 | 'alternate_group' => 2 |
||
1006 | ) |
||
1007 | ); |
||
1008 | |||
1009 | $atom_structure['volume'] = getid3_quicktime::FixedPoint8_8(substr($atom_data, 36, 2)); |
||
1010 | $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2)); |
||
1011 | $atom_structure['matrix_a'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 40, 4)); |
||
1012 | $atom_structure['matrix_b'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 44, 4)); |
||
1013 | $atom_structure['matrix_u'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 48, 4)); |
||
1014 | $atom_structure['matrix_c'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 52, 4)); |
||
1015 | $atom_structure['matrix_v'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 56, 4)); |
||
1016 | $atom_structure['matrix_d'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 60, 4)); |
||
1017 | $atom_structure['matrix_x'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 64, 4)); |
||
1018 | $atom_structure['matrix_y'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 68, 4)); |
||
1019 | $atom_structure['matrix_w'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 72, 4)); |
||
1020 | $atom_structure['width'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 76, 4)); |
||
1021 | $atom_structure['height'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 80, 4)); |
||
1022 | |||
1023 | $atom_structure['flags']['enabled'] = (bool)($atom_structure['flags_raw'] & 0x0001); |
||
1024 | $atom_structure['flags']['in_movie'] = (bool)($atom_structure['flags_raw'] & 0x0002); |
||
1025 | $atom_structure['flags']['in_preview'] = (bool)($atom_structure['flags_raw'] & 0x0004); |
||
1026 | $atom_structure['flags']['in_poster'] = (bool)($atom_structure['flags_raw'] & 0x0008); |
||
1027 | $atom_structure['creation_time_unix'] = (int)($atom_structure['creation_time'] - 2082844800); // DateMac2Unix() |
||
1028 | $atom_structure['modify_time_unix'] = (int)($atom_structure['modify_time'] - 2082844800); // DateMac2Unix() |
||
1029 | |||
1030 | if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) { |
||
1031 | $info['video']['resolution_x'] = $atom_structure['width']; |
||
1032 | $info['video']['resolution_y'] = $atom_structure['height']; |
||
1033 | } |
||
1034 | |||
1035 | if ($atom_structure['flags']['enabled'] == 1) { |
||
1036 | $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']); |
||
1037 | $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']); |
||
1038 | } |
||
1039 | |||
1040 | if (!empty($info['video']['resolution_x']) && !empty($info['video']['resolution_y'])) { |
||
1041 | $info_quicktime['video']['resolution_x'] = $info['video']['resolution_x']; |
||
1042 | $info_quicktime['video']['resolution_y'] = $info['video']['resolution_y']; |
||
1043 | } else { |
||
1044 | unset($info['video']['resolution_x']); |
||
1045 | unset($info['video']['resolution_y']); |
||
1046 | unset($info_quicktime['video']); |
||
1047 | } |
||
1048 | break; |
||
1049 | |||
1050 | |||
1051 | case 'meta': // METAdata atom |
||
1052 | // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt |
||
1053 | $next_tag_position = strpos($atom_data, '�'); |
||
1054 | while ($next_tag_position < strlen($atom_data)) { |
||
1055 | $meta_item_size = getid3_lib::BigEndian2Int(substr($atom_data, $next_tag_position - 4, 4)) - 4; |
||
1056 | if ($meta_item_size == -4) { |
||
1057 | break; |
||
1058 | } |
||
1059 | $meta_item_raw = substr($atom_data, $next_tag_position, $meta_item_size); |
||
1060 | $meta_item_key = substr($meta_item_raw, 0, 4); |
||
1061 | $meta_item_data = substr($meta_item_raw, 20); |
||
1062 | $next_tag_position += $meta_item_size + 4; |
||
1063 | |||
1064 | $this->CopyToAppropriateCommentsSection($meta_item_key, $meta_item_data); |
||
1065 | } |
||
1066 | break; |
||
1067 | |||
1068 | case 'ftyp': // FileTYPe (?) atom (for MP4 it seems) |
||
1069 | getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, |
||
1070 | array ( |
||
1071 | 'signature' => -4, |
||
1072 | 'unknown_1' => 4, |
||
1073 | 'fourcc' => -4, |
||
1074 | ) |
||
1075 | ); |
||
1076 | break; |
||
1077 | |||
1078 | case 'mdat': // Media DATa atom |
||
1079 | case 'free': // FREE space atom |
||
1080 | case 'skip': // SKIP atom |
||
1081 | case 'wide': // 64-bit expansion placeholder atom |
||
1082 | // 'mdat' data is too big to deal with, contains no useful metadata |
||
1083 | // 'free', 'skip' and 'wide' are just padding, contains no useful data at all |
||
1084 | |||
1085 | // When writing QuickTime files, it is sometimes necessary to update an atom's size. |
||
1086 | // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom |
||
1087 | // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime |
||
1088 | // puts an 8-byte placeholder atom before any atoms it may have to update the size of. |
||
1089 | // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the |
||
1090 | // placeholder atom can be overwritten to obtain the necessary 8 extra bytes. |
||
1091 | // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ). |
||
1092 | break; |
||
1093 | |||
1094 | |||
1095 | case 'nsav': // NoSAVe atom |
||
1096 | // http://developer.apple.com/technotes/tn/tn2038.html |
||
1097 | $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); |
||
1098 | break; |
||
1099 | |||
1100 | case 'ctyp': // Controller TYPe atom (seen on QTVR) |
||
1101 | // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt |
||
1102 | // some controller names are: |
||
1103 | // 0x00 + 'std' for linear movie |
||
1104 | // 'none' for no controls |
||
1105 | $atom_structure['ctyp'] = substr($atom_data, 0, 4); |
||
1106 | switch ($atom_structure['ctyp']) { |
||
1107 | case 'qtvr': |
||
1108 | $info['video']['dataformat'] = 'quicktimevr'; |
||
1109 | break; |
||
1110 | } |
||
1111 | break; |
||
1112 | |||
1113 | case 'pano': // PANOrama track (seen on QTVR) |
||
1114 | $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); |
||
1115 | break; |
||
1116 | |||
1117 | case 'hint': // HINT track |
||
1118 | case 'hinf': // |
||
1119 | case 'hinv': // |
||
1120 | case 'hnti': // |
||
1121 | $info['quicktime']['hinting'] = true; |
||
1122 | break; |
||
1123 | |||
1124 | case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR) |
||
1125 | for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) { |
||
1126 | $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4)); |
||
1127 | } |
||
1128 | break; |
||
1129 | |||
1130 | case 'FXTC': // Something to do with Adobe After Effects (?) |
||
1131 | case 'PrmA': |
||
1132 | case 'code': |
||
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 |
||
1134 | // Observed-but-not-handled atom types are just listed here |
||
1135 | // to prevent warnings being generated |
||
1136 | $atom_structure['data'] = $atom_data; |
||
1137 | break; |
||
1138 | |||
1139 | default: |
||
1140 | $getid3->warning('Unknown QuickTime atom type: "'.$atom_name.'" at offset '.$base_offset); |
||
1141 | $atom_structure['data'] = $atom_data; |
||
1142 | break; |
||
1143 | } |
||
1144 | array_pop($atom_hierarchy); |
||
1145 | return $atom_structure; |
||
1146 | } |
||
1529 | ?> |
||
If an expression can have both
false
, andnull
as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.