rlm@3: | rlm@3: // | Allan Hansen | rlm@3: // +----------------------------------------------------------------------+ rlm@3: // | module.audio-video.quicktime.php | rlm@3: // | Module for analyzing Quicktime, MP3-in-MP4 and Apple Lossless files. | rlm@3: // | dependencies: module.audio.mp3.php | rlm@3: // | zlib support in PHP (optional) | rlm@3: // +----------------------------------------------------------------------+ rlm@3: // rlm@3: // $Id: module.audio-video.quicktime.php,v 1.7 2006/11/02 16:03:28 ah Exp $ rlm@3: rlm@3: rlm@3: rlm@3: class getid3_quicktime extends getid3_handler rlm@3: { rlm@3: rlm@3: public function Analyze() { rlm@3: rlm@3: $getid3 = $this->getid3; rlm@3: rlm@3: $info = &$getid3->info; rlm@3: rlm@3: $getid3->include_module('audio.mp3'); rlm@3: rlm@3: $info['quicktime'] = array (); rlm@3: $info_quicktime = &$info['quicktime']; rlm@3: rlm@3: $info['fileformat'] = 'quicktime'; rlm@3: $info_quicktime['hinting'] = false; rlm@3: rlm@3: fseek($getid3->fp, $info['avdataoffset'], SEEK_SET); rlm@3: rlm@3: $offset = $atom_counter = 0; rlm@3: rlm@3: while ($offset < $info['avdataend']) { rlm@3: rlm@3: fseek($getid3->fp, $offset, SEEK_SET); rlm@3: $atom_header = fread($getid3->fp, 8); rlm@3: rlm@3: $atom_size = getid3_lib::BigEndian2Int(substr($atom_header, 0, 4)); rlm@3: $atom_name = substr($atom_header, 4, 4); rlm@3: rlm@3: $info_quicktime[$atom_name]['name'] = $atom_name; rlm@3: $info_quicktime[$atom_name]['size'] = $atom_size; rlm@3: $info_quicktime[$atom_name]['offset'] = $offset; rlm@3: rlm@3: if (($offset + $atom_size) > $info['avdataend']) { rlm@3: throw new getid3_exception('Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atom_size.' bytes)'); rlm@3: } rlm@3: rlm@3: if ($atom_size == 0) { rlm@3: // Furthermore, for historical reasons the list of atoms is optionally rlm@3: // terminated by a 32-bit integer set to 0. If you are writing a program rlm@3: // to read user data atoms, you should allow for the terminating 0. rlm@3: break; rlm@3: } rlm@3: rlm@3: switch ($atom_name) { rlm@3: rlm@3: case 'mdat': // Media DATa atom rlm@3: // 'mdat' contains the actual data for the audio/video rlm@3: if (($atom_size > 8) && (!isset($info['avdataend_tmp']) || ($info_quicktime[$atom_name]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) { rlm@3: rlm@3: $info['avdataoffset'] = $info_quicktime[$atom_name]['offset'] + 8; rlm@3: $old_av_data_end = $info['avdataend']; rlm@3: $info['avdataend'] = $info_quicktime[$atom_name]['offset'] + $info_quicktime[$atom_name]['size']; rlm@3: rlm@3: rlm@3: //// MP3 rlm@3: rlm@3: if (!$getid3->include_module_optional('audio.mp3')) { rlm@3: $getid3->warning('MP3 skipped because mpeg module is missing.'); rlm@3: } rlm@3: rlm@3: else { rlm@3: rlm@3: // Clone getid3 - messing with offsets - better safe than sorry rlm@3: $clone = clone $getid3; rlm@3: rlm@3: if (getid3_mp3::MPEGaudioHeaderValid(getid3_mp3::MPEGaudioHeaderDecode(fread($clone->fp, 4)))) { rlm@3: rlm@3: $mp3 = new getid3_mp3($clone); rlm@3: $mp3->AnalyzeMPEGaudioInfo(); rlm@3: rlm@3: // Import from clone and destroy rlm@3: if (isset($clone->info['mpeg']['audio'])) { rlm@3: rlm@3: $info['mpeg']['audio'] = $clone->info['mpeg']['audio']; rlm@3: rlm@3: $info['audio']['dataformat'] = 'mp3'; rlm@3: $info['audio']['codec'] = (!empty($info['mpeg']['audio']['encoder']) ? $info['mpeg']['audio']['encoder'] : (!empty($info['mpeg']['audio']['codec']) ? $info['mpeg']['audio']['codec'] : (!empty($info['mpeg']['audio']['LAME']) ? 'LAME' :'mp3'))); rlm@3: $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate']; rlm@3: $info['audio']['channels'] = $info['mpeg']['audio']['channels']; rlm@3: $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate']; rlm@3: $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']); rlm@3: $info['bitrate'] = $info['audio']['bitrate']; rlm@3: rlm@3: $getid3->warning($clone->warnings()); rlm@3: unset($clone); rlm@3: } rlm@3: } rlm@3: } rlm@3: rlm@3: $info['avdataend'] = $old_av_data_end; rlm@3: unset($old_av_data_end); rlm@3: rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'free': // FREE space atom rlm@3: case 'skip': // SKIP atom rlm@3: case 'wide': // 64-bit expansion placeholder atom rlm@3: // 'free', 'skip' and 'wide' are just padding, contains no useful data at all rlm@3: break; rlm@3: rlm@3: rlm@3: default: rlm@3: $atom_hierarchy = array (); rlm@3: $info_quicktime[$atom_name] = $this->QuicktimeParseAtom($atom_name, $atom_size, fread($getid3->fp, $atom_size), $offset, $atom_hierarchy); rlm@3: break; rlm@3: } rlm@3: rlm@3: $offset += $atom_size; rlm@3: $atom_counter++; rlm@3: } rlm@3: rlm@3: if (!empty($info['avdataend_tmp'])) { rlm@3: // this value is assigned to a temp value and then erased because rlm@3: // otherwise any atoms beyond the 'mdat' atom would not get parsed rlm@3: $info['avdataend'] = $info['avdataend_tmp']; rlm@3: unset($info['avdataend_tmp']); rlm@3: } rlm@3: rlm@3: if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) { rlm@3: $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds']; rlm@3: } rlm@3: rlm@3: if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info_quicktime['video'])) { rlm@3: $info['audio']['bitrate'] = $info['bitrate']; rlm@3: } rlm@3: rlm@3: if ((@$info['audio']['dataformat'] == 'mp4') && empty($info['video']['resolution_x'])) { rlm@3: $info['fileformat'] = 'mp4'; rlm@3: $info['mime_type'] = 'audio/mp4'; rlm@3: unset($info['video']['dataformat']); rlm@3: } rlm@3: rlm@3: if (!$getid3->option_extra_info) { rlm@3: unset($info_quicktime['moov']); rlm@3: } rlm@3: rlm@3: if (empty($info['audio']['dataformat']) && !empty($info_quicktime['audio'])) { rlm@3: $info['audio']['dataformat'] = 'quicktime'; rlm@3: } rlm@3: rlm@3: if (empty($info['video']['dataformat']) && !empty($info_quicktime['video'])) { rlm@3: $info['video']['dataformat'] = 'quicktime'; rlm@3: } rlm@3: rlm@3: return true; rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: private function QuicktimeParseAtom($atom_name, $atom_size, $atom_data, $base_offset, &$atom_hierarchy) { rlm@3: rlm@3: // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm rlm@3: rlm@3: $getid3 = $this->getid3; rlm@3: rlm@3: $info = &$getid3->info; rlm@3: $info_quicktime = &$info['quicktime']; rlm@3: rlm@3: array_push($atom_hierarchy, $atom_name); rlm@3: $atom_structure['hierarchy'] = implode(' ', $atom_hierarchy); rlm@3: $atom_structure['name'] = $atom_name; rlm@3: $atom_structure['size'] = $atom_size; rlm@3: $atom_structure['offset'] = $base_offset; rlm@3: rlm@3: switch ($atom_name) { rlm@3: case 'moov': // MOVie container atom rlm@3: case 'trak': // TRAcK container atom rlm@3: case 'clip': // CLIPping container atom rlm@3: case 'matt': // track MATTe container atom rlm@3: case 'edts': // EDiTS container atom rlm@3: case 'tref': // Track REFerence container atom rlm@3: case 'mdia': // MeDIA container atom rlm@3: case 'minf': // Media INFormation container atom rlm@3: case 'dinf': // Data INFormation container atom rlm@3: case 'udta': // User DaTA container atom rlm@3: case 'stbl': // Sample TaBLe container atom rlm@3: case 'cmov': // Compressed MOVie container atom rlm@3: case 'rmra': // Reference Movie Record Atom rlm@3: case 'rmda': // Reference Movie Descriptor Atom rlm@3: case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR) rlm@3: $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $base_offset + 8, $atom_hierarchy); rlm@3: break; rlm@3: rlm@3: rlm@3: case '©cpy': rlm@3: case '©day': rlm@3: case '©dir': rlm@3: case '©ed1': rlm@3: case '©ed2': rlm@3: case '©ed3': rlm@3: case '©ed4': rlm@3: case '©ed5': rlm@3: case '©ed6': rlm@3: case '©ed7': rlm@3: case '©ed8': rlm@3: case '©ed9': rlm@3: case '©fmt': rlm@3: case '©inf': rlm@3: case '©prd': rlm@3: case '©prf': rlm@3: case '©req': rlm@3: case '©src': rlm@3: case '©wrt': rlm@3: case '©nam': rlm@3: case '©cmt': rlm@3: case '©wrn': rlm@3: case '©hst': rlm@3: case '©mak': rlm@3: case '©mod': rlm@3: case '©PRD': rlm@3: case '©swr': rlm@3: case '©aut': rlm@3: case '©ART': rlm@3: case '©trk': rlm@3: case '©alb': rlm@3: case '©com': rlm@3: case '©gen': rlm@3: case '©ope': rlm@3: case '©url': rlm@3: case '©enc': rlm@3: $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); rlm@3: $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); rlm@3: $atom_structure['data'] = substr($atom_data, 4); rlm@3: rlm@3: $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); rlm@3: if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { rlm@3: $info['comments']['language'][] = $atom_structure['language']; rlm@3: } rlm@3: $this->CopyToAppropriateCommentsSection($atom_name, $atom_structure['data']); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'play': // auto-PLAY atom rlm@3: $atom_structure['autoplay'] = (bool)getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); rlm@3: rlm@3: $info_quicktime['autoplay'] = $atom_structure['autoplay']; rlm@3: break; rlm@3: rlm@3: rlm@3: case 'WLOC': // Window LOCation atom rlm@3: $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); rlm@3: $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'LOOP': // LOOPing atom rlm@3: case 'SelO': // play SELection Only atom rlm@3: case 'AllF': // play ALL Frames atom rlm@3: $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'name': // rlm@3: case 'MCPS': // Media Cleaner PRo rlm@3: case '@PRM': // adobe PReMiere version rlm@3: case '@PRQ': // adobe PRemiere Quicktime version rlm@3: $atom_structure['data'] = $atom_data; rlm@3: break; rlm@3: rlm@3: rlm@3: case 'cmvd': // Compressed MooV Data atom rlm@3: // Code by ubergeekØubergeek*tv based on information from rlm@3: // http://developer.apple.com/quicktime/icefloe/dispatch012.html rlm@3: $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); rlm@3: rlm@3: $compressed_file_data = substr($atom_data, 4); rlm@3: if (!function_exists('gzuncompress')) { rlm@3: $getid3->warning('PHP does not have zlib support - cannot decompress MOV atom at offset '.$atom_structure['offset']); rlm@3: } rlm@3: elseif ($uncompressed_header = @gzuncompress($compressed_file_data)) { rlm@3: $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($uncompressed_header, 0, $atom_hierarchy); rlm@3: } else { rlm@3: $getid3->warning('Error decompressing compressed MOV atom at offset '.$atom_structure['offset']); rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'dcom': // Data COMpression atom rlm@3: $atom_structure['compression_id'] = $atom_data; rlm@3: $atom_structure['compression_text'] = getid3_quicktime::QuicktimeDCOMLookup($atom_data); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'rdrf': // Reference movie Data ReFerence atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, rlm@3: 'reference_type_name' => -4, rlm@3: 'reference_length' => 4, rlm@3: ) rlm@3: ); rlm@3: rlm@3: $atom_structure['flags']['internal_data'] = (bool)($atom_structure['flags_raw'] & 0x000001); rlm@3: rlm@3: switch ($atom_structure['reference_type_name']) { rlm@3: case 'url ': rlm@3: $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12)); rlm@3: break; rlm@3: rlm@3: case 'alis': rlm@3: $atom_structure['file_alias'] = substr($atom_data, 12); rlm@3: break; rlm@3: rlm@3: case 'rsrc': rlm@3: $atom_structure['resource_alias'] = substr($atom_data, 12); rlm@3: break; rlm@3: rlm@3: default: rlm@3: $atom_structure['data'] = substr($atom_data, 12); rlm@3: break; rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'rmqu': // Reference Movie QUality atom rlm@3: $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'rmcs': // Reference Movie Cpu Speed atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'cpu_speed_rating' => 2 rlm@3: ) rlm@3: ); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'rmvc': // Reference Movie Version Check atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'gestalt_selector' => -4, rlm@3: 'gestalt_value_mask' => 4, rlm@3: 'gestalt_value' => 4, rlm@3: 'gestalt_check_type' => 2 rlm@3: ) rlm@3: ); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'rmcd': // Reference Movie Component check atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'component_type' => -4, rlm@3: 'component_subtype' => -4, rlm@3: 'component_manufacturer' => -4, rlm@3: 'component_flags_raw' => 4, rlm@3: 'component_flags_mask' => 4, rlm@3: 'component_min_version' => 4 rlm@3: ) rlm@3: ); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'rmdr': // Reference Movie Data Rate atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'data_rate' => 4 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10; rlm@3: break; rlm@3: rlm@3: rlm@3: case 'rmla': // Reference Movie Language Atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'language_id' => 2 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); rlm@3: if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { rlm@3: $info['comments']['language'][] = $atom_structure['language']; rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'rmla': // Reference Movie Language Atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'track_id' => 2 rlm@3: ) rlm@3: ); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'ptv ': // Print To Video - defines a movie's full screen mode rlm@3: // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'display_size_raw' => 2, rlm@3: 'reserved_1' => 2, // hardcoded: 0x0000 rlm@3: 'reserved_2' => 2, // hardcoded: 0x0000 rlm@3: 'slide_show_flag' => 1, rlm@3: 'play_on_open_flag' => 1 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $atom_structure['flags']['play_on_open'] = (bool)$atom_structure['play_on_open_flag']; rlm@3: $atom_structure['flags']['slide_show'] = (bool)$atom_structure['slide_show_flag']; rlm@3: rlm@3: $ptv_lookup[0] = 'normal'; rlm@3: $ptv_lookup[1] = 'double'; rlm@3: $ptv_lookup[2] = 'half'; rlm@3: $ptv_lookup[3] = 'full'; rlm@3: $ptv_lookup[4] = 'current'; rlm@3: if (isset($ptv_lookup[$atom_structure['display_size_raw']])) { rlm@3: $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']]; rlm@3: } else { rlm@3: $getid3->warning('unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')'); rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'stsd': // Sample Table Sample Description atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'number_entries' => 4 rlm@3: ) rlm@3: ); rlm@3: $stsd_entries_data_offset = 8; rlm@3: for ($i = 0; $i < $atom_structure['number_entries']; $i++) { rlm@3: rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_data, $stsd_entries_data_offset, rlm@3: array ( rlm@3: 'size' => 4, rlm@3: 'data_format' => -4, rlm@3: 'reserved' => 6, rlm@3: 'reference_index' => 2 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, 16+$stsd_entries_data_offset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2)); rlm@3: $stsd_entries_data_offset += 16 + ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2); rlm@3: rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 0, rlm@3: array ( rlm@3: 'encoder_version' => 2, rlm@3: 'encoder_revision' => 2, rlm@3: 'encoder_vendor' => -4 rlm@3: ) rlm@3: ); rlm@3: rlm@3: switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) { rlm@3: rlm@3: case "\x00\x00\x00\x00": rlm@3: // audio atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 8, rlm@3: array ( rlm@3: 'audio_channels' => 2, rlm@3: 'audio_bit_depth' => 2, rlm@3: 'audio_compression_id' => 2, rlm@3: 'audio_packet_size' => 2 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_quicktime::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4)); rlm@3: rlm@3: switch ($atom_structure['sample_description_table'][$i]['data_format']) { rlm@3: rlm@3: case 'mp4v': rlm@3: $info['fileformat'] = 'mp4'; rlm@3: throw new getid3_exception('This version of getID3() does not fully support MPEG-4 audio/video streams'); rlm@3: rlm@3: case 'qtvr': rlm@3: $info['video']['dataformat'] = 'quicktimevr'; rlm@3: break; rlm@3: rlm@3: case 'mp4a': rlm@3: default: rlm@3: $info_quicktime['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']); rlm@3: $info_quicktime['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate']; rlm@3: $info_quicktime['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels']; rlm@3: $info_quicktime['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth']; rlm@3: $info['audio']['codec'] = $info_quicktime['audio']['codec']; rlm@3: $info['audio']['sample_rate'] = $info_quicktime['audio']['sample_rate']; rlm@3: $info['audio']['channels'] = $info_quicktime['audio']['channels']; rlm@3: $info['audio']['bits_per_sample'] = $info_quicktime['audio']['bit_depth']; rlm@3: switch ($atom_structure['sample_description_table'][$i]['data_format']) { rlm@3: case 'raw ': // PCM rlm@3: case 'alac': // Apple Lossless Audio Codec rlm@3: $info['audio']['lossless'] = true; rlm@3: break; rlm@3: default: rlm@3: $info['audio']['lossless'] = false; rlm@3: break; rlm@3: } rlm@3: break; rlm@3: } rlm@3: break; rlm@3: rlm@3: default: rlm@3: switch ($atom_structure['sample_description_table'][$i]['data_format']) { rlm@3: case 'mp4s': rlm@3: $info['fileformat'] = 'mp4'; rlm@3: break; rlm@3: rlm@3: default: rlm@3: // video atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 8, rlm@3: array ( rlm@3: 'video_temporal_quality' => 4, rlm@3: 'video_spatial_quality' => 4, rlm@3: 'video_frame_width' => 2, rlm@3: 'video_frame_height' => 2 rlm@3: ) rlm@3: ); rlm@3: $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_quicktime::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4)); rlm@3: $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_quicktime::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4)); rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['sample_description_table'][$i], $atom_structure['sample_description_table'][$i]['data'], 28, rlm@3: array ( rlm@3: 'video_data_size' => 4, rlm@3: 'video_frame_count' => 2, rlm@3: 'video_encoder_name_len' => 1 rlm@3: ) rlm@3: ); rlm@3: $atom_structure['sample_description_table'][$i]['video_encoder_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 35, $atom_structure['sample_description_table'][$i]['video_encoder_name_len']); rlm@3: $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2)); rlm@3: $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2)); rlm@3: rlm@3: $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color'); rlm@3: $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']); rlm@3: rlm@3: if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') { rlm@3: $info_quicktime['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format']; rlm@3: $info_quicktime['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']); rlm@3: $info_quicktime['video']['codec'] = $atom_structure['sample_description_table'][$i]['video_encoder_name']; rlm@3: $info_quicktime['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth']; rlm@3: $info_quicktime['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name']; rlm@3: rlm@3: $info['video']['codec'] = $info_quicktime['video']['codec']; rlm@3: $info['video']['bits_per_sample'] = $info_quicktime['video']['color_depth']; rlm@3: } rlm@3: $info['video']['lossless'] = false; rlm@3: $info['video']['pixel_aspect_ratio'] = (float)1; rlm@3: break; rlm@3: } rlm@3: break; rlm@3: } rlm@3: switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) { rlm@3: case 'mp4a': rlm@3: $info['audio']['dataformat'] = $info_quicktime['audio']['codec'] = 'mp4'; rlm@3: break; rlm@3: rlm@3: case '3ivx': rlm@3: case '3iv1': rlm@3: case '3iv2': rlm@3: $info['video']['dataformat'] = '3ivx'; rlm@3: break; rlm@3: rlm@3: case 'xvid': rlm@3: $info['video']['dataformat'] = 'xvid'; rlm@3: break; rlm@3: rlm@3: case 'mp4v': rlm@3: $info['video']['dataformat'] = 'mpeg4'; rlm@3: break; rlm@3: rlm@3: case 'divx': rlm@3: case 'div1': rlm@3: case 'div2': rlm@3: case 'div3': rlm@3: case 'div4': rlm@3: case 'div5': rlm@3: case 'div6': rlm@3: //$TDIVXileInfo['video']['dataformat'] = 'divx'; rlm@3: break; rlm@3: rlm@3: default: rlm@3: // do nothing rlm@3: break; rlm@3: } rlm@3: unset($atom_structure['sample_description_table'][$i]['data']); rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'stts': // Sample Table Time-to-Sample atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'number_entries' => 4 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $stts_entries_data_offset = 8; rlm@3: $frame_rate_calculator_array = array (); rlm@3: for ($i = 0; $i < $atom_structure['number_entries']; $i++) { rlm@3: rlm@3: $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $stts_entries_data_offset, 4)); rlm@3: $stts_entries_data_offset += 4; rlm@3: rlm@3: $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $stts_entries_data_offset, 4)); rlm@3: $stts_entries_data_offset += 4; rlm@3: rlm@3: if (!empty($info_quicktime['time_scale']) && (@$atoms_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) { rlm@3: rlm@3: $stts_new_framerate = $info_quicktime['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration']; rlm@3: if ($stts_new_framerate <= 60) { rlm@3: // some atoms have durations of "1" giving a very large framerate, which probably is not right rlm@3: $info['video']['frame_rate'] = max(@$info['video']['frame_rate'], $stts_new_framerate); rlm@3: } rlm@3: } rlm@3: //@$frame_rate_calculator_array[($info_quicktime['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count']; rlm@3: } rlm@3: /* rlm@3: $stts_frames_total = 0; rlm@3: $stts_seconds_total = 0; rlm@3: foreach ($frame_rate_calculator_array as $frames_per_second => $frame_count) { rlm@3: if (($frames_per_second > 60) || ($frames_per_second < 1)) { rlm@3: // not video FPS information, probably audio information rlm@3: $stts_frames_total = 0; rlm@3: $stts_seconds_total = 0; rlm@3: break; rlm@3: } rlm@3: $stts_frames_total += $frame_count; rlm@3: $stts_seconds_total += $frame_count / $frames_per_second; rlm@3: } rlm@3: if (($stts_frames_total > 0) && ($stts_seconds_total > 0)) { rlm@3: if (($stts_frames_total / $stts_seconds_total) > @$info['video']['frame_rate']) { rlm@3: $info['video']['frame_rate'] = $stts_frames_total / $stts_seconds_total; rlm@3: } rlm@3: } rlm@3: */ rlm@3: break; rlm@3: rlm@3: rlm@3: case 'stss': // Sample Table Sync Sample (key frames) atom rlm@3: /* rlm@3: $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); rlm@3: $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 rlm@3: $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); rlm@3: $stss_entries_data_offset = 8; rlm@3: for ($i = 0; $i < $atom_structure['number_entries']; $i++) { rlm@3: $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stss_entries_data_offset, 4)); rlm@3: $stss_entries_data_offset += 4; rlm@3: } rlm@3: */ rlm@3: break; rlm@3: rlm@3: rlm@3: case 'stsc': // Sample Table Sample-to-Chunk atom rlm@3: /* rlm@3: $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); rlm@3: $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 rlm@3: $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); rlm@3: $stsc_entries_data_offset = 8; rlm@3: for ($i = 0; $i < $atom_structure['number_entries']; $i++) { rlm@3: $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsc_entries_data_offset, 4)); rlm@3: $stsc_entries_data_offset += 4; rlm@3: $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsc_entries_data_offset, 4)); rlm@3: $stsc_entries_data_offset += 4; rlm@3: $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsc_entries_data_offset, 4)); rlm@3: $stsc_entries_data_offset += 4; rlm@3: } rlm@3: */ rlm@3: break; rlm@3: rlm@3: rlm@3: case 'stsz': // Sample Table SiZe atom rlm@3: /* rlm@3: $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); rlm@3: $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 rlm@3: $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); rlm@3: $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); rlm@3: $stsz_entries_data_offset = 12; rlm@3: if ($atom_structure['sample_size'] == 0) { rlm@3: for ($i = 0; $i < $atom_structure['number_entries']; $i++) { rlm@3: $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stsz_entries_data_offset, 4)); rlm@3: $stsz_entries_data_offset += 4; rlm@3: } rlm@3: } rlm@3: */ rlm@3: break; rlm@3: rlm@3: rlm@3: case 'stco': // Sample Table Chunk Offset atom rlm@3: /* rlm@3: $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); rlm@3: $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 rlm@3: $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); rlm@3: $stco_entries_data_offset = 8; rlm@3: for ($i = 0; $i < $atom_structure['number_entries']; $i++) { rlm@3: $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stco_entries_data_offset, 4)); rlm@3: $stco_entries_data_offset += 4; rlm@3: } rlm@3: */ rlm@3: break; rlm@3: rlm@3: rlm@3: case 'dref': // Data REFerence atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'number_entries' => 4 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $dref_data_offset = 8; rlm@3: for ($i = 0; $i < $atom_structure['number_entries']; $i++) { rlm@3: rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure['data_references'][$i], $atom_data, $dref_data_offset, rlm@3: array ( rlm@3: 'size' => 4, rlm@3: 'type' => -4, rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3 // hardcoded: 0x0000 rlm@3: ) rlm@3: ); rlm@3: $dref_data_offset += 12; rlm@3: rlm@3: $atom_structure['data_references'][$i]['data'] = substr($atom_data, $dref_data_offset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3)); rlm@3: $dref_data_offset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3); rlm@3: rlm@3: $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool)($atom_structure['data_references'][$i]['flags_raw'] & 0x001); rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'gmin': // base Media INformation atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'graphics_mode' => 2, rlm@3: 'opcolor_red' => 2, rlm@3: 'opcolor_green' => 2, rlm@3: 'opcolor_blue' => 2, rlm@3: 'balance' => 2, rlm@3: 'reserved' => 2 rlm@3: ) rlm@3: ); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'smhd': // Sound Media information HeaDer atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'balance' => 2, rlm@3: 'reserved' => 2 rlm@3: ) rlm@3: ); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'vmhd': // Video Media information HeaDer atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, rlm@3: 'graphics_mode' => 2, rlm@3: 'opcolor_red' => 2, rlm@3: 'opcolor_green' => 2, rlm@3: 'opcolor_blue' => 2 rlm@3: ) rlm@3: ); rlm@3: $atom_structure['flags']['no_lean_ahead'] = (bool)($atom_structure['flags_raw'] & 0x001); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'hdlr': // HanDLeR reference atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'component_type' => -4, rlm@3: 'component_subtype' => -4, rlm@3: 'component_manufacturer' => -4, rlm@3: 'component_flags_raw' => 4, rlm@3: 'component_flags_mask' => 4 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $atom_structure['component_name'] = substr(substr($atom_data, 24), 1); /// Pascal2String rlm@3: rlm@3: if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) { rlm@3: $info['video']['dataformat'] = 'quicktimevr'; rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'mdhd': // MeDia HeaDer atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'creation_time' => 4, rlm@3: 'modify_time' => 4, rlm@3: 'time_scale' => 4, rlm@3: 'duration' => 4, rlm@3: 'language_id' => 2, rlm@3: 'quality' => 2 rlm@3: ) rlm@3: ); rlm@3: rlm@3: if ($atom_structure['time_scale'] == 0) { rlm@3: throw new getid3_exception('Corrupt Quicktime file: mdhd.time_scale == zero'); rlm@3: } rlm@3: $info_quicktime['time_scale'] = max(@$info['quicktime']['time_scale'], $atom_structure['time_scale']); rlm@3: rlm@3: $atom_structure['creation_time_unix'] = (int)($atom_structure['creation_time'] - 2082844800); // DateMac2Unix() rlm@3: $atom_structure['modify_time_unix'] = (int)($atom_structure['modify_time'] - 2082844800); // DateMac2Unix() rlm@3: $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale']; rlm@3: $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); rlm@3: if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { rlm@3: $info['comments']['language'][] = $atom_structure['language']; rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'pnot': // Preview atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'modification_date' => 4, // "standard Macintosh format" rlm@3: 'version_number' => 2, // hardcoded: 0x00 rlm@3: 'atom_type' => -4, // usually: 'PICT' rlm@3: 'atom_index' => 2 // usually: 0x01 rlm@3: ) rlm@3: ); rlm@3: $atom_structure['modification_date_unix'] = (int)($atom_structure['modification_date'] - 2082844800); // DateMac2Unix() rlm@3: break; rlm@3: rlm@3: rlm@3: case 'crgn': // Clipping ReGioN atom rlm@3: $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box, rlm@3: $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields rlm@3: $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region. rlm@3: break; rlm@3: rlm@3: rlm@3: case 'load': // track LOAD settings atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'preload_start_time' => 4, rlm@3: 'preload_duration' => 4, rlm@3: 'preload_flags_raw' => 4, rlm@3: 'default_hints_raw' => 4 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $atom_structure['default_hints']['double_buffer'] = (bool)($atom_structure['default_hints_raw'] & 0x0020); rlm@3: $atom_structure['default_hints']['high_quality'] = (bool)($atom_structure['default_hints_raw'] & 0x0100); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'tmcd': // TiMe CoDe atom rlm@3: case 'chap': // CHAPter list atom rlm@3: case 'sync': // SYNChronization atom rlm@3: case 'scpt': // tranSCriPT atom rlm@3: case 'ssrc': // non-primary SouRCe atom rlm@3: for ($i = 0; $i < (strlen($atom_data) % 4); $i++) { rlm@3: $atom_structure['track_id'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $i * 4, 4)); rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'elst': // Edit LiST atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, // hardcoded: 0x0000 rlm@3: 'number_entries' => 4 rlm@3: ) rlm@3: ); rlm@3: rlm@3: for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) { rlm@3: $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4)); rlm@3: $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4)); rlm@3: $atom_structure['edit_list'][$i]['media_rate'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4)); rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'kmat': // compressed MATte atom rlm@3: $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); rlm@3: $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 rlm@3: $atom_structure['matte_data_raw'] = substr($atom_data, 4); rlm@3: break; rlm@3: rlm@3: rlm@3: case 'ctab': // Color TABle atom rlm@3: $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000 rlm@3: $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000 rlm@3: $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1; rlm@3: for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) { rlm@3: $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2)); rlm@3: $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2)); rlm@3: $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2)); rlm@3: $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2)); rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'mvhd': // MoVie HeaDer atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, rlm@3: 'creation_time' => 4, rlm@3: 'modify_time' => 4, rlm@3: 'time_scale' => 4, rlm@3: 'duration' => 4 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $atom_structure['preferred_rate'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 20, 4)); rlm@3: $atom_structure['preferred_volume'] = getid3_quicktime::FixedPoint8_8(substr($atom_data, 24, 2)); rlm@3: $atom_structure['reserved'] = substr($atom_data, 26, 10); rlm@3: $atom_structure['matrix_a'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 36, 4)); rlm@3: $atom_structure['matrix_b'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 40, 4)); rlm@3: $atom_structure['matrix_u'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 44, 4)); rlm@3: $atom_structure['matrix_c'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 48, 4)); rlm@3: $atom_structure['matrix_d'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 52, 4)); rlm@3: $atom_structure['matrix_v'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 56, 4)); rlm@3: $atom_structure['matrix_x'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 60, 4)); rlm@3: $atom_structure['matrix_y'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 64, 4)); rlm@3: $atom_structure['matrix_w'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 68, 4)); rlm@3: rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 72, rlm@3: array ( rlm@3: 'preview_time' => 4, rlm@3: 'preview_duration' => 4, rlm@3: 'poster_time' => 4, rlm@3: 'selection_time' => 4, rlm@3: 'selection_duration' => 4, rlm@3: 'current_time' => 4, rlm@3: 'next_track_id' => 4 rlm@3: ) rlm@3: ); rlm@3: rlm@3: if ($atom_structure['time_scale'] == 0) { rlm@3: throw new getid3_exception('Corrupt Quicktime file: mvhd.time_scale == zero'); rlm@3: } rlm@3: rlm@3: $atom_structure['creation_time_unix'] = (int)($atom_structure['creation_time'] - 2082844800); // DateMac2Unix() rlm@3: $atom_structure['modify_time_unix'] = (int)($atom_structure['modify_time'] - 2082844800); // DateMac2Unix() rlm@3: $info_quicktime['time_scale'] = max(@$info['quicktime']['time_scale'], $atom_structure['time_scale']); rlm@3: $info_quicktime['display_scale'] = $atom_structure['matrix_a']; rlm@3: $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale']; rlm@3: break; rlm@3: rlm@3: rlm@3: case 'tkhd': // TracK HeaDer atom rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'version' => 1, rlm@3: 'flags_raw' => 3, rlm@3: 'creation_time' => 4, rlm@3: 'modify_time' => 4, rlm@3: 'trackid' => 4, rlm@3: 'reserved1' => 4, rlm@3: 'duration' => 4, rlm@3: 'reserved2' => 8, rlm@3: 'layer' => 2, rlm@3: 'alternate_group' => 2 rlm@3: ) rlm@3: ); rlm@3: rlm@3: $atom_structure['volume'] = getid3_quicktime::FixedPoint8_8(substr($atom_data, 36, 2)); rlm@3: $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2)); rlm@3: $atom_structure['matrix_a'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 40, 4)); rlm@3: $atom_structure['matrix_b'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 44, 4)); rlm@3: $atom_structure['matrix_u'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 48, 4)); rlm@3: $atom_structure['matrix_c'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 52, 4)); rlm@3: $atom_structure['matrix_v'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 56, 4)); rlm@3: $atom_structure['matrix_d'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 60, 4)); rlm@3: $atom_structure['matrix_x'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 64, 4)); rlm@3: $atom_structure['matrix_y'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 68, 4)); rlm@3: $atom_structure['matrix_w'] = getid3_quicktime::FixedPoint2_30(substr($atom_data, 72, 4)); rlm@3: $atom_structure['width'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 76, 4)); rlm@3: $atom_structure['height'] = getid3_quicktime::FixedPoint16_16(substr($atom_data, 80, 4)); rlm@3: rlm@3: $atom_structure['flags']['enabled'] = (bool)($atom_structure['flags_raw'] & 0x0001); rlm@3: $atom_structure['flags']['in_movie'] = (bool)($atom_structure['flags_raw'] & 0x0002); rlm@3: $atom_structure['flags']['in_preview'] = (bool)($atom_structure['flags_raw'] & 0x0004); rlm@3: $atom_structure['flags']['in_poster'] = (bool)($atom_structure['flags_raw'] & 0x0008); rlm@3: $atom_structure['creation_time_unix'] = (int)($atom_structure['creation_time'] - 2082844800); // DateMac2Unix() rlm@3: $atom_structure['modify_time_unix'] = (int)($atom_structure['modify_time'] - 2082844800); // DateMac2Unix() rlm@3: rlm@3: if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) { rlm@3: $info['video']['resolution_x'] = $atom_structure['width']; rlm@3: $info['video']['resolution_y'] = $atom_structure['height']; rlm@3: } rlm@3: rlm@3: if ($atom_structure['flags']['enabled'] == 1) { rlm@3: $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']); rlm@3: $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']); rlm@3: } rlm@3: rlm@3: if (!empty($info['video']['resolution_x']) && !empty($info['video']['resolution_y'])) { rlm@3: $info_quicktime['video']['resolution_x'] = $info['video']['resolution_x']; rlm@3: $info_quicktime['video']['resolution_y'] = $info['video']['resolution_y']; rlm@3: } else { rlm@3: unset($info['video']['resolution_x']); rlm@3: unset($info['video']['resolution_y']); rlm@3: unset($info_quicktime['video']); rlm@3: } rlm@3: break; rlm@3: rlm@3: rlm@3: case 'meta': // METAdata atom rlm@3: // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt rlm@3: $next_tag_position = strpos($atom_data, '©'); rlm@3: while ($next_tag_position < strlen($atom_data)) { rlm@3: $meta_item_size = getid3_lib::BigEndian2Int(substr($atom_data, $next_tag_position - 4, 4)) - 4; rlm@3: if ($meta_item_size == -4) { rlm@3: break; rlm@3: } rlm@3: $meta_item_raw = substr($atom_data, $next_tag_position, $meta_item_size); rlm@3: $meta_item_key = substr($meta_item_raw, 0, 4); rlm@3: $meta_item_data = substr($meta_item_raw, 20); rlm@3: $next_tag_position += $meta_item_size + 4; rlm@3: rlm@3: $this->CopyToAppropriateCommentsSection($meta_item_key, $meta_item_data); rlm@3: } rlm@3: break; rlm@3: rlm@3: case 'ftyp': // FileTYPe (?) atom (for MP4 it seems) rlm@3: getid3_lib::ReadSequence('BigEndian2Int', $atom_structure, $atom_data, 0, rlm@3: array ( rlm@3: 'signature' => -4, rlm@3: 'unknown_1' => 4, rlm@3: 'fourcc' => -4, rlm@3: ) rlm@3: ); rlm@3: break; rlm@3: rlm@3: case 'mdat': // Media DATa atom rlm@3: case 'free': // FREE space atom rlm@3: case 'skip': // SKIP atom rlm@3: case 'wide': // 64-bit expansion placeholder atom rlm@3: // 'mdat' data is too big to deal with, contains no useful metadata rlm@3: // 'free', 'skip' and 'wide' are just padding, contains no useful data at all rlm@3: rlm@3: // When writing QuickTime files, it is sometimes necessary to update an atom's size. rlm@3: // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom rlm@3: // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime rlm@3: // puts an 8-byte placeholder atom before any atoms it may have to update the size of. rlm@3: // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the rlm@3: // placeholder atom can be overwritten to obtain the necessary 8 extra bytes. rlm@3: // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ). rlm@3: break; rlm@3: rlm@3: rlm@3: case 'nsav': // NoSAVe atom rlm@3: // http://developer.apple.com/technotes/tn/tn2038.html rlm@3: $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); rlm@3: break; rlm@3: rlm@3: case 'ctyp': // Controller TYPe atom (seen on QTVR) rlm@3: // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt rlm@3: // some controller names are: rlm@3: // 0x00 + 'std' for linear movie rlm@3: // 'none' for no controls rlm@3: $atom_structure['ctyp'] = substr($atom_data, 0, 4); rlm@3: switch ($atom_structure['ctyp']) { rlm@3: case 'qtvr': rlm@3: $info['video']['dataformat'] = 'quicktimevr'; rlm@3: break; rlm@3: } rlm@3: break; rlm@3: rlm@3: case 'pano': // PANOrama track (seen on QTVR) rlm@3: $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); rlm@3: break; rlm@3: rlm@3: case 'hint': // HINT track rlm@3: case 'hinf': // rlm@3: case 'hinv': // rlm@3: case 'hnti': // rlm@3: $info['quicktime']['hinting'] = true; rlm@3: break; rlm@3: rlm@3: case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR) rlm@3: for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) { rlm@3: $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4)); rlm@3: } rlm@3: break; rlm@3: rlm@3: case 'FXTC': // Something to do with Adobe After Effects (?) rlm@3: case 'PrmA': rlm@3: case 'code': rlm@3: case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html rlm@3: // Observed-but-not-handled atom types are just listed here rlm@3: // to prevent warnings being generated rlm@3: $atom_structure['data'] = $atom_data; rlm@3: break; rlm@3: rlm@3: default: rlm@3: $getid3->warning('Unknown QuickTime atom type: "'.$atom_name.'" at offset '.$base_offset); rlm@3: $atom_structure['data'] = $atom_data; rlm@3: break; rlm@3: } rlm@3: array_pop($atom_hierarchy); rlm@3: return $atom_structure; rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: private function QuicktimeParseContainerAtom($atom_data, $base_offset, &$atom_hierarchy) { rlm@3: rlm@3: if ((strlen($atom_data) == 4) && (getid3_lib::BigEndian2Int($atom_data) == 0x00000000)) { rlm@3: return false; rlm@3: } rlm@3: rlm@3: $atom_structure = false; rlm@3: $subatom_offset = 0; rlm@3: rlm@3: while ($subatom_offset < strlen($atom_data)) { rlm@3: rlm@3: $subatom_size = getid3_lib::BigEndian2Int(substr($atom_data, $subatom_offset + 0, 4)); rlm@3: $subatom_name = substr($atom_data, $subatom_offset + 4, 4); rlm@3: $subatom_data = substr($atom_data, $subatom_offset + 8, $subatom_size - 8); rlm@3: rlm@3: if ($subatom_size == 0) { rlm@3: // Furthermore, for historical reasons the list of atoms is optionally rlm@3: // terminated by a 32-bit integer set to 0. If you are writing a program rlm@3: // to read user data atoms, you should allow for the terminating 0. rlm@3: return $atom_structure; rlm@3: } rlm@3: rlm@3: $atom_structure[] = $this->QuicktimeParseAtom($subatom_name, $subatom_size, $subatom_data, $base_offset + $subatom_offset, $atom_hierarchy); rlm@3: rlm@3: $subatom_offset += $subatom_size; rlm@3: } rlm@3: return $atom_structure; rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: private function CopyToAppropriateCommentsSection($key_name, $data) { rlm@3: rlm@3: // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt rlm@3: rlm@3: static $translator = array ( rlm@3: '©cpy' => 'copyright', rlm@3: '©day' => 'creation_date', rlm@3: '©dir' => 'director', rlm@3: '©ed1' => 'edit1', rlm@3: '©ed2' => 'edit2', rlm@3: '©ed3' => 'edit3', rlm@3: '©ed4' => 'edit4', rlm@3: '©ed5' => 'edit5', rlm@3: '©ed6' => 'edit6', rlm@3: '©ed7' => 'edit7', rlm@3: '©ed8' => 'edit8', rlm@3: '©ed9' => 'edit9', rlm@3: '©fmt' => 'format', rlm@3: '©inf' => 'information', rlm@3: '©prd' => 'producer', rlm@3: '©prf' => 'performers', rlm@3: '©req' => 'system_requirements', rlm@3: '©src' => 'source_credit', rlm@3: '©wrt' => 'writer', rlm@3: '©nam' => 'title', rlm@3: '©cmt' => 'comment', rlm@3: '©wrn' => 'warning', rlm@3: '©hst' => 'host_computer', rlm@3: '©mak' => 'make', rlm@3: '©mod' => 'model', rlm@3: '©PRD' => 'product', rlm@3: '©swr' => 'software', rlm@3: '©aut' => 'author', rlm@3: '©ART' => 'artist', rlm@3: '©trk' => 'track', rlm@3: '©alb' => 'album', rlm@3: '©com' => 'comment', rlm@3: '©gen' => 'genre', rlm@3: '©ope' => 'composer', rlm@3: '©url' => 'url', rlm@3: '©enc' => 'encoder' rlm@3: ); rlm@3: rlm@3: if (isset($translator[$key_name])) { rlm@3: $this->getid3->info['quicktime']['comments'][$translator[$key_name]][] = $data; rlm@3: } rlm@3: rlm@3: return true; rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: public static function QuicktimeLanguageLookup($language_id) { rlm@3: rlm@3: static $lookup = array ( rlm@3: 0 => 'English', rlm@3: 1 => 'French', rlm@3: 2 => 'German', rlm@3: 3 => 'Italian', rlm@3: 4 => 'Dutch', rlm@3: 5 => 'Swedish', rlm@3: 6 => 'Spanish', rlm@3: 7 => 'Danish', rlm@3: 8 => 'Portuguese', rlm@3: 9 => 'Norwegian', rlm@3: 10 => 'Hebrew', rlm@3: 11 => 'Japanese', rlm@3: 12 => 'Arabic', rlm@3: 13 => 'Finnish', rlm@3: 14 => 'Greek', rlm@3: 15 => 'Icelandic', rlm@3: 16 => 'Maltese', rlm@3: 17 => 'Turkish', rlm@3: 18 => 'Croatian', rlm@3: 19 => 'Chinese (Traditional)', rlm@3: 20 => 'Urdu', rlm@3: 21 => 'Hindi', rlm@3: 22 => 'Thai', rlm@3: 23 => 'Korean', rlm@3: 24 => 'Lithuanian', rlm@3: 25 => 'Polish', rlm@3: 26 => 'Hungarian', rlm@3: 27 => 'Estonian', rlm@3: 28 => 'Lettish', rlm@3: 28 => 'Latvian', rlm@3: 29 => 'Saamisk', rlm@3: 29 => 'Lappish', rlm@3: 30 => 'Faeroese', rlm@3: 31 => 'Farsi', rlm@3: 31 => 'Persian', rlm@3: 32 => 'Russian', rlm@3: 33 => 'Chinese (Simplified)', rlm@3: 34 => 'Flemish', rlm@3: 35 => 'Irish', rlm@3: 36 => 'Albanian', rlm@3: 37 => 'Romanian', rlm@3: 38 => 'Czech', rlm@3: 39 => 'Slovak', rlm@3: 40 => 'Slovenian', rlm@3: 41 => 'Yiddish', rlm@3: 42 => 'Serbian', rlm@3: 43 => 'Macedonian', rlm@3: 44 => 'Bulgarian', rlm@3: 45 => 'Ukrainian', rlm@3: 46 => 'Byelorussian', rlm@3: 47 => 'Uzbek', rlm@3: 48 => 'Kazakh', rlm@3: 49 => 'Azerbaijani', rlm@3: 50 => 'AzerbaijanAr', rlm@3: 51 => 'Armenian', rlm@3: 52 => 'Georgian', rlm@3: 53 => 'Moldavian', rlm@3: 54 => 'Kirghiz', rlm@3: 55 => 'Tajiki', rlm@3: 56 => 'Turkmen', rlm@3: 57 => 'Mongolian', rlm@3: 58 => 'MongolianCyr', rlm@3: 59 => 'Pashto', rlm@3: 60 => 'Kurdish', rlm@3: 61 => 'Kashmiri', rlm@3: 62 => 'Sindhi', rlm@3: 63 => 'Tibetan', rlm@3: 64 => 'Nepali', rlm@3: 65 => 'Sanskrit', rlm@3: 66 => 'Marathi', rlm@3: 67 => 'Bengali', rlm@3: 68 => 'Assamese', rlm@3: 69 => 'Gujarati', rlm@3: 70 => 'Punjabi', rlm@3: 71 => 'Oriya', rlm@3: 72 => 'Malayalam', rlm@3: 73 => 'Kannada', rlm@3: 74 => 'Tamil', rlm@3: 75 => 'Telugu', rlm@3: 76 => 'Sinhalese', rlm@3: 77 => 'Burmese', rlm@3: 78 => 'Khmer', rlm@3: 79 => 'Lao', rlm@3: 80 => 'Vietnamese', rlm@3: 81 => 'Indonesian', rlm@3: 82 => 'Tagalog', rlm@3: 83 => 'MalayRoman', rlm@3: 84 => 'MalayArabic', rlm@3: 85 => 'Amharic', rlm@3: 86 => 'Tigrinya', rlm@3: 87 => 'Galla', rlm@3: 87 => 'Oromo', rlm@3: 88 => 'Somali', rlm@3: 89 => 'Swahili', rlm@3: 90 => 'Ruanda', rlm@3: 91 => 'Rundi', rlm@3: 92 => 'Chewa', rlm@3: 93 => 'Malagasy', rlm@3: 94 => 'Esperanto', rlm@3: 128 => 'Welsh', rlm@3: 129 => 'Basque', rlm@3: 130 => 'Catalan', rlm@3: 131 => 'Latin', rlm@3: 132 => 'Quechua', rlm@3: 133 => 'Guarani', rlm@3: 134 => 'Aymara', rlm@3: 135 => 'Tatar', rlm@3: 136 => 'Uighur', rlm@3: 137 => 'Dzongkha', rlm@3: 138 => 'JavaneseRom' rlm@3: ); rlm@3: rlm@3: return (isset($lookup[$language_id]) ? $lookup[$language_id] : 'invalid'); rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: public static function QuicktimeVideoCodecLookup($codec_id) { rlm@3: rlm@3: static $lookup = array ( rlm@3: '3IVX' => '3ivx MPEG-4', rlm@3: '3IV1' => '3ivx MPEG-4 v1', rlm@3: '3IV2' => '3ivx MPEG-4 v2', rlm@3: 'avr ' => 'AVR-JPEG', rlm@3: 'base' => 'Base', rlm@3: 'WRLE' => 'BMP', rlm@3: 'cvid' => 'Cinepak', rlm@3: 'clou' => 'Cloud', rlm@3: 'cmyk' => 'CMYK', rlm@3: 'yuv2' => 'ComponentVideo', rlm@3: 'yuvu' => 'ComponentVideoSigned', rlm@3: 'yuvs' => 'ComponentVideoUnsigned', rlm@3: 'dvc ' => 'DVC-NTSC', rlm@3: 'dvcp' => 'DVC-PAL', rlm@3: 'dvpn' => 'DVCPro-NTSC', rlm@3: 'dvpp' => 'DVCPro-PAL', rlm@3: 'fire' => 'Fire', rlm@3: 'flic' => 'FLC', rlm@3: 'b48r' => '48RGB', rlm@3: 'gif ' => 'GIF', rlm@3: 'smc ' => 'Graphics', rlm@3: 'h261' => 'H261', rlm@3: 'h263' => 'H263', rlm@3: 'IV41' => 'Indeo4', rlm@3: 'jpeg' => 'JPEG', rlm@3: 'PNTG' => 'MacPaint', rlm@3: 'msvc' => 'Microsoft Video1', rlm@3: 'mjpa' => 'Motion JPEG-A', rlm@3: 'mjpb' => 'Motion JPEG-B', rlm@3: 'myuv' => 'MPEG YUV420', rlm@3: 'dmb1' => 'OpenDML JPEG', rlm@3: 'kpcd' => 'PhotoCD', rlm@3: '8BPS' => 'Planar RGB', rlm@3: 'png ' => 'PNG', rlm@3: 'qdrw' => 'QuickDraw', rlm@3: 'qdgx' => 'QuickDrawGX', rlm@3: 'raw ' => 'RAW', rlm@3: '.SGI' => 'SGI', rlm@3: 'b16g' => '16Gray', rlm@3: 'b64a' => '64ARGB', rlm@3: 'SVQ1' => 'Sorenson Video 1', rlm@3: 'SVQ1' => 'Sorenson Video 3', rlm@3: 'syv9' => 'Sorenson YUV9', rlm@3: 'tga ' => 'Targa', rlm@3: 'b32a' => '32AlphaGray', rlm@3: 'tiff' => 'TIFF', rlm@3: 'path' => 'Vector', rlm@3: 'rpza' => 'Video', rlm@3: 'ripl' => 'WaterRipple', rlm@3: 'WRAW' => 'Windows RAW', rlm@3: 'y420' => 'YUV420' rlm@3: ); rlm@3: rlm@3: return (isset($lookup[$codec_id]) ? $lookup[$codec_id] : ''); rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: public static function QuicktimeAudioCodecLookup($codec_id) { rlm@3: rlm@3: static $lookup = array ( rlm@3: '.mp3' => 'Fraunhofer MPEG Layer-III alias', rlm@3: 'aac ' => 'ISO/IEC 14496-3 AAC', rlm@3: 'agsm' => 'Apple GSM 10:1', rlm@3: 'alac' => 'Apple Lossless Audio Codec', rlm@3: 'alaw' => 'A-law 2:1', rlm@3: 'conv' => 'Sample Format', rlm@3: 'dvca' => 'DV', rlm@3: 'dvi ' => 'DV 4:1', rlm@3: 'eqal' => 'Frequency Equalizer', rlm@3: 'fl32' => '32-bit Floating Point', rlm@3: 'fl64' => '64-bit Floating Point', rlm@3: 'ima4' => 'Interactive Multimedia Association 4:1', rlm@3: 'in24' => '24-bit Integer', rlm@3: 'in32' => '32-bit Integer', rlm@3: 'lpc ' => 'LPC 23:1', rlm@3: 'MAC3' => 'Macintosh Audio Compression/Expansion (MACE) 3:1', rlm@3: 'MAC6' => 'Macintosh Audio Compression/Expansion (MACE) 6:1', rlm@3: 'mixb' => '8-bit Mixer', rlm@3: 'mixw' => '16-bit Mixer', rlm@3: 'mp4a' => 'ISO/IEC 14496-3 AAC', rlm@3: "MS'\x00\x02" => 'Microsoft ADPCM', rlm@3: "MS'\x00\x11" => 'DV IMA', rlm@3: "MS\x00\x55" => 'Fraunhofer MPEG Layer III', rlm@3: 'NONE' => 'No Encoding', rlm@3: 'Qclp' => 'Qualcomm PureVoice', rlm@3: 'QDM2' => 'QDesign Music 2', rlm@3: 'QDMC' => 'QDesign Music 1', rlm@3: 'ratb' => '8-bit Rate', rlm@3: 'ratw' => '16-bit Rate', rlm@3: 'raw ' => 'raw PCM', rlm@3: 'sour' => 'Sound Source', rlm@3: 'sowt' => 'signed/two\'s complement (Little Endian)', rlm@3: 'str1' => 'Iomega MPEG layer II', rlm@3: 'str2' => 'Iomega MPEG *layer II', rlm@3: 'str3' => 'Iomega MPEG **layer II', rlm@3: 'str4' => 'Iomega MPEG ***layer II', rlm@3: 'twos' => 'signed/two\'s complement (Big Endian)', rlm@3: 'ulaw' => 'mu-law 2:1', rlm@3: ); rlm@3: rlm@3: return (isset($lookup[$codec_id]) ? $lookup[$codec_id] : ''); rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: public static function QuicktimeDCOMLookup($compression_id) { rlm@3: rlm@3: static $lookup = array ( rlm@3: 'zlib' => 'ZLib Deflate', rlm@3: 'adec' => 'Apple Compression' rlm@3: ); rlm@3: rlm@3: return (isset($lookup[$compression_id]) ? $lookup[$compression_id] : ''); rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: public static function QuicktimeColorNameLookup($color_depth_id) { rlm@3: rlm@3: static $lookup = array ( rlm@3: 1 => '2-color (monochrome)', rlm@3: 2 => '4-color', rlm@3: 4 => '16-color', rlm@3: 8 => '256-color', rlm@3: 16 => 'thousands (16-bit color)', rlm@3: 24 => 'millions (24-bit color)', rlm@3: 32 => 'millions+ (32-bit color)', rlm@3: 33 => 'black & white', rlm@3: 34 => '4-gray', rlm@3: 36 => '16-gray', rlm@3: 40 => '256-gray', rlm@3: ); rlm@3: rlm@3: return (isset($lookup[$color_depth_id]) ? $lookup[$color_depth_id] : 'invalid'); rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: public static function NoNullString($null_terminated_string) { rlm@3: rlm@3: // remove the single null terminator on null terminated strings rlm@3: if (substr($null_terminated_string, strlen($null_terminated_string) - 1, 1) === "\x00") { rlm@3: return substr($null_terminated_string, 0, strlen($null_terminated_string) - 1); rlm@3: } rlm@3: rlm@3: return $null_terminated_string; rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: public static function FixedPoint8_8($raw_data) { rlm@3: rlm@3: return getid3_lib::BigEndian2Int($raw_data{0}) + (float)(getid3_lib::BigEndian2Int($raw_data{1}) / 256); rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: public static function FixedPoint16_16($raw_data) { rlm@3: rlm@3: return getid3_lib::BigEndian2Int(substr($raw_data, 0, 2)) + (float)(getid3_lib::BigEndian2Int(substr($raw_data, 2, 2)) / 65536); rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: public static function FixedPoint2_30($raw_data) { rlm@3: rlm@3: $binary_string = getid3_lib::BigEndian2Bin($raw_data); rlm@3: return bindec(substr($binary_string, 0, 2)) + (float)(bindec(substr($binary_string, 2, 30)) / 1073741824); rlm@3: } rlm@3: rlm@3: } rlm@3: rlm@3: ?>