2 /////////////////////////////////////////////////////////////////
3 /// getID3() by James Heinrich <info@getid3.org> //
4 // available at http://getid3.sourceforge.net //
5 // or http://www.getid3.org //
6 /////////////////////////////////////////////////////////////////
7 // See readme.txt for more details //
8 /////////////////////////////////////////////////////////////////
10 // module.audio-video.quicktime.php //
11 // module for analyzing Quicktime and MP3-in-MP4 files //
12 // dependencies: module.audio.mp3.php //
13 // dependencies: module.tag.id3v2.php //
15 /////////////////////////////////////////////////////////////////
17 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
18 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true); // needed for ISO 639-2 language code lookup
20 class getid3_quicktime extends getid3_handler
23 public $ReturnAtomData = true;
24 public $ParseAllPossibleAtoms = false;
26 public function Analyze() {
27 $info = &$this->getid3->info;
29 $info['fileformat'] = 'quicktime';
30 $info['quicktime']['hinting'] = false;
31 $info['quicktime']['controller'] = 'standard'; // may be overridden if 'ctyp' atom is present
33 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
38 while ($offset < $info['avdataend']) {
39 if (!getid3_lib::intValueSupported($offset)) {
40 $info['error'][] = 'Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
43 fseek($this->getid3->fp, $offset, SEEK_SET);
44 $AtomHeader = fread($this->getid3->fp, 8);
46 $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
47 $atomname = substr($AtomHeader, 4, 4);
49 // 64-bit MOV patch by jlegateØktnc*com
51 $atomsize = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 8));
54 $info['quicktime'][$atomname]['name'] = $atomname;
55 $info['quicktime'][$atomname]['size'] = $atomsize;
56 $info['quicktime'][$atomname]['offset'] = $offset;
58 if (($offset + $atomsize) > $info['avdataend']) {
59 $info['error'][] = 'Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)';
64 // Furthermore, for historical reasons the list of atoms is optionally
65 // terminated by a 32-bit integer set to 0. If you are writing a program
66 // to read user data atoms, you should allow for the terminating 0.
70 case 'mdat': // Media DATa atom
71 // 'mdat' contains the actual data for the audio/video
72 if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) {
74 $info['avdataoffset'] = $info['quicktime'][$atomname]['offset'] + 8;
75 $OldAVDataEnd = $info['avdataend'];
76 $info['avdataend'] = $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];
78 $getid3_temp = new getID3();
79 $getid3_temp->openfile($this->getid3->filename);
80 $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
81 $getid3_temp->info['avdataend'] = $info['avdataend'];
82 $getid3_mp3 = new getid3_mp3($getid3_temp);
83 if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode(fread($this->getid3->fp, 4)))) {
84 $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
85 if (!empty($getid3_temp->info['warning'])) {
86 foreach ($getid3_temp->info['warning'] as $value) {
87 $info['warning'][] = $value;
90 if (!empty($getid3_temp->info['mpeg'])) {
91 $info['mpeg'] = $getid3_temp->info['mpeg'];
92 if (isset($info['mpeg']['audio'])) {
93 $info['audio']['dataformat'] = 'mp3';
94 $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')));
95 $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
96 $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
97 $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
98 $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
99 $info['bitrate'] = $info['audio']['bitrate'];
103 unset($getid3_mp3, $getid3_temp);
104 $info['avdataend'] = $OldAVDataEnd;
105 unset($OldAVDataEnd);
110 case 'free': // FREE space atom
111 case 'skip': // SKIP atom
112 case 'wide': // 64-bit expansion placeholder atom
113 // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
117 $atomHierarchy = array();
118 $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($this->getid3->fp, $atomsize), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);
122 $offset += $atomsize;
126 if (!empty($info['avdataend_tmp'])) {
127 // this value is assigned to a temp value and then erased because
128 // otherwise any atoms beyond the 'mdat' atom would not get parsed
129 $info['avdataend'] = $info['avdataend_tmp'];
130 unset($info['avdataend_tmp']);
133 if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) {
134 $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
136 if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info['quicktime']['video'])) {
137 $info['audio']['bitrate'] = $info['bitrate'];
139 if (!empty($info['playtime_seconds']) && !isset($info['video']['frame_rate']) && !empty($info['quicktime']['stts_framecount'])) {
140 foreach ($info['quicktime']['stts_framecount'] as $key => $samples_count) {
141 $samples_per_second = $samples_count / $info['playtime_seconds'];
142 if ($samples_per_second > 240) {
143 // has to be audio samples
145 $info['video']['frame_rate'] = $samples_per_second;
150 if (($info['audio']['dataformat'] == 'mp4') && empty($info['video']['resolution_x'])) {
151 $info['fileformat'] = 'mp4';
152 $info['mime_type'] = 'audio/mp4';
153 unset($info['video']['dataformat']);
156 if (!$this->ReturnAtomData) {
157 unset($info['quicktime']['moov']);
160 if (empty($info['audio']['dataformat']) && !empty($info['quicktime']['audio'])) {
161 $info['audio']['dataformat'] = 'quicktime';
163 if (empty($info['video']['dataformat']) && !empty($info['quicktime']['video'])) {
164 $info['video']['dataformat'] = 'quicktime';
170 public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
171 // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm
173 $info = &$this->getid3->info;
175 //$atom_parent = array_pop($atomHierarchy);
176 $atom_parent = end($atomHierarchy); // http://www.getid3.org/phpBB3/viewtopic.php?t=1717
177 array_push($atomHierarchy, $atomname);
178 $atom_structure['hierarchy'] = implode(' ', $atomHierarchy);
179 $atom_structure['name'] = $atomname;
180 $atom_structure['size'] = $atomsize;
181 $atom_structure['offset'] = $baseoffset;
182 //echo getid3_lib::PrintHexBytes(substr($atom_data, 0, 8)).'<br>';
183 //echo getid3_lib::PrintHexBytes(substr($atom_data, 0, 8), false).'<br><br>';
185 case 'moov': // MOVie container atom
186 case 'trak': // TRAcK container atom
187 case 'clip': // CLIPping container atom
188 case 'matt': // track MATTe container atom
189 case 'edts': // EDiTS container atom
190 case 'tref': // Track REFerence container atom
191 case 'mdia': // MeDIA container atom
192 case 'minf': // Media INFormation container atom
193 case 'dinf': // Data INFormation container atom
194 case 'udta': // User DaTA container atom
195 case 'cmov': // Compressed MOVie container atom
196 case 'rmra': // Reference Movie Record Atom
197 case 'rmda': // Reference Movie Descriptor Atom
198 case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR)
199 $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
202 case 'ilst': // Item LiST container atom
203 $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
205 // some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted
206 $allnumericnames = true;
207 foreach ($atom_structure['subatoms'] as $subatomarray) {
208 if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) {
209 $allnumericnames = false;
213 if ($allnumericnames) {
215 foreach ($atom_structure['subatoms'] as $subatomarray) {
216 foreach ($subatomarray['subatoms'] as $newData_subatomarray) {
217 unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']);
218 $newData[$subatomarray['name']] = $newData_subatomarray;
222 $atom_structure['data'] = $newData;
223 unset($atom_structure['subatoms']);
227 case "\x00\x00\x00\x01":
228 case "\x00\x00\x00\x02":
229 case "\x00\x00\x00\x03":
230 case "\x00\x00\x00\x04":
231 case "\x00\x00\x00\x05":
232 $atomname = getid3_lib::BigEndian2Int($atomname);
233 $atom_structure['name'] = $atomname;
234 $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
237 case 'stbl': // Sample TaBLe container atom
238 $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
242 foreach ($atom_structure['subatoms'] as $key => $value_array) {
243 if (isset($value_array['sample_description_table'])) {
244 foreach ($value_array['sample_description_table'] as $key2 => $value_array2) {
245 if (isset($value_array2['data_format'])) {
246 switch ($value_array2['data_format']) {
258 } elseif (isset($value_array['time_to_sample_table'])) {
259 foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) {
260 if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0)) {
261 $framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3);
262 $framecount = $value_array2['sample_count'];
267 if ($isVideo && $framerate) {
268 $info['quicktime']['video']['frame_rate'] = $framerate;
269 $info['video']['frame_rate'] = $info['quicktime']['video']['frame_rate'];
271 if ($isVideo && $framecount) {
272 $info['quicktime']['video']['frame_count'] = $framecount;
277 case 'aART': // Album ARTist
278 case 'catg': // CaTeGory
279 case 'covr': // COVeR artwork
280 case 'cpil': // ComPILation
281 case 'cprt': // CoPyRighT
282 case 'desc': // DESCription
283 case 'disk': // DISK number
284 case 'egid': // Episode Global ID
285 case 'gnre': // GeNRE
286 case 'keyw': // KEYWord
288 case 'pcst': // PodCaST
289 case 'pgap': // GAPless Playback
290 case 'purd': // PURchase Date
291 case 'purl': // Podcast URL
295 case 'rtng': // RaTiNG
297 case 'tmpo': // TeMPO (BPM)
298 case 'trkn': // TRacK Number
299 case 'tves': // TV EpiSode
300 case 'tvnn': // TV Network Name
301 case 'tvsh': // TV SHow Name
302 case 'tvsn': // TV SeasoN
303 case 'akID': // iTunes store account type
310 case 'sfID': // iTunes store country
311 case '©alb': // ALBum
312 case '©art': // ARTist
315 case '©cmt': // CoMmenT
316 case '©com': // COMposer
318 case '©day': // content created year
331 case '©gen': // GENre
332 case '©grp': // GRouPing
335 case '©lyr': // LYRics
338 case '©nam': // full NAMe
346 case '©too': // encoder
347 case '©trk': // TRacK
350 case '©wrt': // WRiTer
351 case '----': // itunes specific
352 if ($atom_parent == 'udta') {
353 // User data atom handler
354 $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
355 $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
356 $atom_structure['data'] = substr($atom_data, 4);
358 $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
359 if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
360 $info['comments']['language'][] = $atom_structure['language'];
363 // Apple item list box atom handler
365 if (substr($atom_data, 2, 2) == "\x10\xB5") {
366 // not sure what it means, but observed on iPhone4 data.
367 // Each $atom_data has 2 bytes of datasize, plus 0x10B5, then data
368 while ($atomoffset < strlen($atom_data)) {
369 $boxsmallsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 2));
370 $boxsmalltype = substr($atom_data, $atomoffset + 2, 2);
371 $boxsmalldata = substr($atom_data, $atomoffset + 4, $boxsmallsize);
372 if ($boxsmallsize <= 1) {
373 $info['warning'][] = 'Invalid QuickTime atom smallbox size "'.$boxsmallsize.'" in atom "'.$atomname.'" at offset: '.($atom_structure['offset'] + $atomoffset);
374 $atom_structure['data'] = null;
375 $atomoffset = strlen($atom_data);
378 switch ($boxsmalltype) {
380 $atom_structure['data'] = $boxsmalldata;
383 $info['warning'][] = 'Unknown QuickTime smallbox type: "'.getid3_lib::PrintHexBytes($boxsmalltype).'" at offset '.$baseoffset;
384 $atom_structure['data'] = $atom_data;
387 $atomoffset += (4 + $boxsmallsize);
390 while ($atomoffset < strlen($atom_data)) {
391 $boxsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 4));
392 $boxtype = substr($atom_data, $atomoffset + 4, 4);
393 $boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8);
395 $info['warning'][] = 'Invalid QuickTime atom box size "'.$boxsize.'" in atom "'.$atomname.'" at offset: '.($atom_structure['offset'] + $atomoffset);
396 $atom_structure['data'] = null;
397 $atomoffset = strlen($atom_data);
400 $atomoffset += $boxsize;
405 $atom_structure[$boxtype] = substr($boxdata, 4);
409 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1));
410 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3));
411 switch ($atom_structure['flags_raw']) {
413 case 21: // tmpo/cpil flag
418 $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
422 $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2));
427 $num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2));
428 $num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2));
429 $atom_structure['data'] = empty($num) ? '' : $num;
430 $atom_structure['data'] .= empty($num_total) ? '' : '/'.$num_total;
434 $GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
435 $atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1);
439 $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
440 $atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]);
444 $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
445 $atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]);
449 $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
450 $atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]);
455 $atom_structure['data'] = substr($boxdata, 8);
459 $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
464 case 13: // image flag
466 $atom_structure['data'] = substr($boxdata, 8);
473 $info['warning'][] = 'Unknown QuickTime box type: "'.getid3_lib::PrintHexBytes($boxtype).'" at offset '.$baseoffset;
474 $atom_structure['data'] = $atom_data;
480 $this->CopyToAppropriateCommentsSection($atomname, $atom_structure['data'], $atom_structure['name']);
484 case 'play': // auto-PLAY atom
485 $atom_structure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
487 $info['quicktime']['autoplay'] = $atom_structure['autoplay'];
491 case 'WLOC': // Window LOCation atom
492 $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
493 $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
497 case 'LOOP': // LOOPing atom
498 case 'SelO': // play SELection Only atom
499 case 'AllF': // play ALL Frames atom
500 $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data);
505 case 'MCPS': // Media Cleaner PRo
506 case '@PRM': // adobe PReMiere version
507 case '@PRQ': // adobe PRemiere Quicktime version
508 $atom_structure['data'] = $atom_data;
512 case 'cmvd': // Compressed MooV Data atom
513 // Code by ubergeekØubergeek*tv based on information from
514 // http://developer.apple.com/quicktime/icefloe/dispatch012.html
515 $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
517 $CompressedFileData = substr($atom_data, 4);
518 if ($UncompressedHeader = @gzuncompress($CompressedFileData)) {
519 $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, 0, $atomHierarchy, $ParseAllPossibleAtoms);
521 $info['warning'][] = 'Error decompressing compressed MOV atom at offset '.$atom_structure['offset'];
526 case 'dcom': // Data COMpression atom
527 $atom_structure['compression_id'] = $atom_data;
528 $atom_structure['compression_text'] = $this->QuicktimeDCOMLookup($atom_data);
532 case 'rdrf': // Reference movie Data ReFerence atom
533 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
534 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
535 $atom_structure['flags']['internal_data'] = (bool) ($atom_structure['flags_raw'] & 0x000001);
537 $atom_structure['reference_type_name'] = substr($atom_data, 4, 4);
538 $atom_structure['reference_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
539 switch ($atom_structure['reference_type_name']) {
541 $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12));
545 $atom_structure['file_alias'] = substr($atom_data, 12);
549 $atom_structure['resource_alias'] = substr($atom_data, 12);
553 $atom_structure['data'] = substr($atom_data, 12);
559 case 'rmqu': // Reference Movie QUality atom
560 $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data);
564 case 'rmcs': // Reference Movie Cpu Speed atom
565 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
566 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
567 $atom_structure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
571 case 'rmvc': // Reference Movie Version Check atom
572 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
573 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
574 $atom_structure['gestalt_selector'] = substr($atom_data, 4, 4);
575 $atom_structure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
576 $atom_structure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
577 $atom_structure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
581 case 'rmcd': // Reference Movie Component check atom
582 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
583 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
584 $atom_structure['component_type'] = substr($atom_data, 4, 4);
585 $atom_structure['component_subtype'] = substr($atom_data, 8, 4);
586 $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
587 $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
588 $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
589 $atom_structure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 4));
593 case 'rmdr': // Reference Movie Data Rate atom
594 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
595 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
596 $atom_structure['data_rate'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
598 $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10;
602 case 'rmla': // Reference Movie Language Atom
603 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
604 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
605 $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
607 $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
608 if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
609 $info['comments']['language'][] = $atom_structure['language'];
614 case 'rmla': // Reference Movie Language Atom
615 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
616 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
617 $atom_structure['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
621 case 'ptv ': // Print To Video - defines a movie's full screen mode
622 // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm
623 $atom_structure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
624 $atom_structure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); // hardcoded: 0x0000
625 $atom_structure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x0000
626 $atom_structure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 1));
627 $atom_structure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 7, 1));
629 $atom_structure['flags']['play_on_open'] = (bool) $atom_structure['play_on_open_flag'];
630 $atom_structure['flags']['slide_show'] = (bool) $atom_structure['slide_show_flag'];
632 $ptv_lookup[0] = 'normal';
633 $ptv_lookup[1] = 'double';
634 $ptv_lookup[2] = 'half';
635 $ptv_lookup[3] = 'full';
636 $ptv_lookup[4] = 'current';
637 if (isset($ptv_lookup[$atom_structure['display_size_raw']])) {
638 $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']];
640 $info['warning'][] = 'unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')';
645 case 'stsd': // Sample Table Sample Description atom
646 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
647 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
648 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
649 $stsdEntriesDataOffset = 8;
650 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
651 $atom_structure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 4));
652 $stsdEntriesDataOffset += 4;
653 $atom_structure['sample_description_table'][$i]['data_format'] = substr($atom_data, $stsdEntriesDataOffset, 4);
654 $stsdEntriesDataOffset += 4;
655 $atom_structure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 6));
656 $stsdEntriesDataOffset += 6;
657 $atom_structure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 2));
658 $stsdEntriesDataOffset += 2;
659 $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));
660 $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);
662 $atom_structure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 0, 2));
663 $atom_structure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 2, 2));
664 $atom_structure['sample_description_table'][$i]['encoder_vendor'] = substr($atom_structure['sample_description_table'][$i]['data'], 4, 4);
666 switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) {
668 case "\x00\x00\x00\x00":
670 $atom_structure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 2));
671 $atom_structure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 10, 2));
672 $atom_structure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 2));
673 $atom_structure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 14, 2));
674 $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4));
677 // http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
678 $atom_structure['sample_description_table'][$i]['temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));
679 $atom_structure['sample_description_table'][$i]['spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));
680 $atom_structure['sample_description_table'][$i]['width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));
681 $atom_structure['sample_description_table'][$i]['height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));
682 $atom_structure['sample_description_table'][$i]['resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));
683 $atom_structure['sample_description_table'][$i]['resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));
684 $atom_structure['sample_description_table'][$i]['data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 4));
685 $atom_structure['sample_description_table'][$i]['frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 36, 2));
686 $atom_structure['sample_description_table'][$i]['compressor_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 38, 4);
687 $atom_structure['sample_description_table'][$i]['pixel_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 42, 2));
688 $atom_structure['sample_description_table'][$i]['color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 44, 2));
690 switch ($atom_structure['sample_description_table'][$i]['data_format']) {
717 $info['fileformat'] = 'mp4';
718 $info['video']['fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
719 // http://www.getid3.org/phpBB3/viewtopic.php?t=1550
720 //if ((!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($atom_structure['sample_description_table'][$i]['width'])) && (empty($info['video']['resolution_x']) || empty($info['video']['resolution_y']) || (number_format($info['video']['resolution_x'], 6) != number_format(round($info['video']['resolution_x']), 6)) || (number_format($info['video']['resolution_y'], 6) != number_format(round($info['video']['resolution_y']), 6)))) { // ugly check for floating point numbers
721 if (!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($atom_structure['sample_description_table'][$i]['height'])) {
722 // assume that values stored here are more important than values stored in [tkhd] atom
723 $info['video']['resolution_x'] = $atom_structure['sample_description_table'][$i]['width'];
724 $info['video']['resolution_y'] = $atom_structure['sample_description_table'][$i]['height'];
725 $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];
726 $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];
731 $info['video']['dataformat'] = 'quicktimevr';
736 $info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
737 $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate'];
738 $info['quicktime']['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels'];
739 $info['quicktime']['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth'];
740 $info['audio']['codec'] = $info['quicktime']['audio']['codec'];
741 $info['audio']['sample_rate'] = $info['quicktime']['audio']['sample_rate'];
742 $info['audio']['channels'] = $info['quicktime']['audio']['channels'];
743 $info['audio']['bits_per_sample'] = $info['quicktime']['audio']['bit_depth'];
744 switch ($atom_structure['sample_description_table'][$i]['data_format']) {
746 case 'alac': // Apple Lossless Audio Codec
747 $info['audio']['lossless'] = true;
750 $info['audio']['lossless'] = false;
758 switch ($atom_structure['sample_description_table'][$i]['data_format']) {
760 $info['fileformat'] = 'mp4';
765 $atom_structure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));
766 $atom_structure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));
767 $atom_structure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));
768 $atom_structure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));
769 $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4));
770 $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));
771 $atom_structure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));
772 $atom_structure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 2));
773 $atom_structure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 34, 1));
774 $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']);
775 $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2));
776 $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2));
778 $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color');
779 $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']);
781 if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') {
782 $info['quicktime']['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
783 $info['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
784 $info['quicktime']['video']['codec'] = (($atom_structure['sample_description_table'][$i]['video_encoder_name_len'] > 0) ? $atom_structure['sample_description_table'][$i]['video_encoder_name'] : $atom_structure['sample_description_table'][$i]['data_format']);
785 $info['quicktime']['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'];
786 $info['quicktime']['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name'];
788 $info['video']['codec'] = $info['quicktime']['video']['codec'];
789 $info['video']['bits_per_sample'] = $info['quicktime']['video']['color_depth'];
791 $info['video']['lossless'] = false;
792 $info['video']['pixel_aspect_ratio'] = (float) 1;
797 switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) {
799 $info['audio']['dataformat'] = 'mp4';
800 $info['quicktime']['audio']['codec'] = 'mp4';
806 $info['video']['dataformat'] = '3ivx';
810 $info['video']['dataformat'] = 'xvid';
814 $info['video']['dataformat'] = 'mpeg4';
824 $info['video']['dataformat'] = 'divx';
831 unset($atom_structure['sample_description_table'][$i]['data']);
836 case 'stts': // Sample Table Time-to-Sample atom
837 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
838 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
839 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
840 $sttsEntriesDataOffset = 8;
841 //$FrameRateCalculatorArray = array();
843 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
844 $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
845 $sttsEntriesDataOffset += 4;
846 $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
847 $sttsEntriesDataOffset += 4;
849 $frames_count += $atom_structure['time_to_sample_table'][$i]['sample_count'];
851 // THIS SECTION REPLACED WITH CODE IN "stbl" ATOM
852 //if (!empty($info['quicktime']['time_scale']) && ($atom_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) {
853 // $stts_new_framerate = $info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'];
854 // if ($stts_new_framerate <= 60) {
855 // // some atoms have durations of "1" giving a very large framerate, which probably is not right
856 // $info['video']['frame_rate'] = max($info['video']['frame_rate'], $stts_new_framerate);
860 //$FrameRateCalculatorArray[($info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count'];
862 $info['quicktime']['stts_framecount'][] = $frames_count;
863 //$sttsFramesTotal = 0;
864 //$sttsSecondsTotal = 0;
865 //foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) {
866 // if (($frames_per_second > 60) || ($frames_per_second < 1)) {
867 // // not video FPS information, probably audio information
868 // $sttsFramesTotal = 0;
869 // $sttsSecondsTotal = 0;
872 // $sttsFramesTotal += $frame_count;
873 // $sttsSecondsTotal += $frame_count / $frames_per_second;
875 //if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) {
876 // if (($sttsFramesTotal / $sttsSecondsTotal) > $info['video']['frame_rate']) {
877 // $info['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal;
883 case 'stss': // Sample Table Sync Sample (key frames) atom
884 if ($ParseAllPossibleAtoms) {
885 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
886 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
887 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
888 $stssEntriesDataOffset = 8;
889 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
890 $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stssEntriesDataOffset, 4));
891 $stssEntriesDataOffset += 4;
897 case 'stsc': // Sample Table Sample-to-Chunk atom
898 if ($ParseAllPossibleAtoms) {
899 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
900 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
901 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
902 $stscEntriesDataOffset = 8;
903 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
904 $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
905 $stscEntriesDataOffset += 4;
906 $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
907 $stscEntriesDataOffset += 4;
908 $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
909 $stscEntriesDataOffset += 4;
915 case 'stsz': // Sample Table SiZe atom
916 if ($ParseAllPossibleAtoms) {
917 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
918 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
919 $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
920 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
921 $stszEntriesDataOffset = 12;
922 if ($atom_structure['sample_size'] == 0) {
923 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
924 $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stszEntriesDataOffset, 4));
925 $stszEntriesDataOffset += 4;
932 case 'stco': // Sample Table Chunk Offset atom
933 if ($ParseAllPossibleAtoms) {
934 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
935 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
936 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
937 $stcoEntriesDataOffset = 8;
938 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
939 $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 4));
940 $stcoEntriesDataOffset += 4;
946 case 'co64': // Chunk Offset 64-bit (version of "stco" that supports > 2GB files)
947 if ($ParseAllPossibleAtoms) {
948 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
949 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
950 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
951 $stcoEntriesDataOffset = 8;
952 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
953 $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 8));
954 $stcoEntriesDataOffset += 8;
960 case 'dref': // Data REFerence atom
961 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
962 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
963 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
965 for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
966 $atom_structure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 4));
967 $drefDataOffset += 4;
968 $atom_structure['data_references'][$i]['type'] = substr($atom_data, $drefDataOffset, 4);
969 $drefDataOffset += 4;
970 $atom_structure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 1));
971 $drefDataOffset += 1;
972 $atom_structure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 3)); // hardcoded: 0x0000
973 $drefDataOffset += 3;
974 $atom_structure['data_references'][$i]['data'] = substr($atom_data, $drefDataOffset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));
975 $drefDataOffset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);
977 $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool) ($atom_structure['data_references'][$i]['flags_raw'] & 0x001);
982 case 'gmin': // base Media INformation atom
983 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
984 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
985 $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
986 $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
987 $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
988 $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
989 $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 2));
990 $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
994 case 'smhd': // Sound Media information HeaDer atom
995 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
996 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
997 $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
998 $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
1002 case 'vmhd': // Video Media information HeaDer atom
1003 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1004 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
1005 $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
1006 $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
1007 $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
1008 $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
1010 $atom_structure['flags']['no_lean_ahead'] = (bool) ($atom_structure['flags_raw'] & 0x001);
1014 case 'hdlr': // HanDLeR reference atom
1015 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1016 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
1017 $atom_structure['component_type'] = substr($atom_data, 4, 4);
1018 $atom_structure['component_subtype'] = substr($atom_data, 8, 4);
1019 $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
1020 $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
1021 $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
1022 $atom_structure['component_name'] = $this->Pascal2String(substr($atom_data, 24));
1024 if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) {
1025 $info['video']['dataformat'] = 'quicktimevr';
1030 case 'mdhd': // MeDia HeaDer atom
1031 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1032 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
1033 $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1034 $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1035 $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1036 $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
1037 $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 2));
1038 $atom_structure['quality'] = getid3_lib::BigEndian2Int(substr($atom_data, 22, 2));
1040 if ($atom_structure['time_scale'] == 0) {
1041 $info['error'][] = 'Corrupt Quicktime file: mdhd.time_scale == zero';
1044 $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
1046 $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
1047 $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
1048 $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
1049 $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
1050 if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
1051 $info['comments']['language'][] = $atom_structure['language'];
1056 case 'pnot': // Preview atom
1057 $atom_structure['modification_date'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // "standard Macintosh format"
1058 $atom_structure['version_number'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x00
1059 $atom_structure['atom_type'] = substr($atom_data, 6, 4); // usually: 'PICT'
1060 $atom_structure['atom_index'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); // usually: 0x01
1062 $atom_structure['modification_date_unix'] = getid3_lib::DateMac2Unix($atom_structure['modification_date']);
1066 case 'crgn': // Clipping ReGioN atom
1067 $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box,
1068 $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields
1069 $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region.
1073 case 'load': // track LOAD settings atom
1074 $atom_structure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1075 $atom_structure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1076 $atom_structure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1077 $atom_structure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1079 $atom_structure['default_hints']['double_buffer'] = (bool) ($atom_structure['default_hints_raw'] & 0x0020);
1080 $atom_structure['default_hints']['high_quality'] = (bool) ($atom_structure['default_hints_raw'] & 0x0100);
1084 case 'tmcd': // TiMe CoDe atom
1085 case 'chap': // CHAPter list atom
1086 case 'sync': // SYNChronization atom
1087 case 'scpt': // tranSCriPT atom
1088 case 'ssrc': // non-primary SouRCe atom
1089 for ($i = 0; $i < (strlen($atom_data) % 4); $i++) {
1090 $atom_structure['track_id'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $i * 4, 4));
1095 case 'elst': // Edit LiST atom
1096 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1097 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
1098 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1099 for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) {
1100 $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4));
1101 $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4));
1102 $atom_structure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4));
1107 case 'kmat': // compressed MATte atom
1108 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1109 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
1110 $atom_structure['matte_data_raw'] = substr($atom_data, 4);
1114 case 'ctab': // Color TABle atom
1115 $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000
1116 $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000
1117 $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1;
1118 for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) {
1119 $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2));
1120 $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2));
1121 $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2));
1122 $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2));
1127 case 'mvhd': // MoVie HeaDer atom
1128 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1129 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
1130 $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1131 $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1132 $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1133 $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
1134 $atom_structure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 20, 4));
1135 $atom_structure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 24, 2));
1136 $atom_structure['reserved'] = substr($atom_data, 26, 10);
1137 $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 36, 4));
1138 $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
1139 $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 44, 4));
1140 $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4));
1141 $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
1142 $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 56, 4));
1143 $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4));
1144 $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));
1145 $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4));
1146 $atom_structure['preview_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 72, 4));
1147 $atom_structure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 76, 4));
1148 $atom_structure['poster_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 80, 4));
1149 $atom_structure['selection_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 84, 4));
1150 $atom_structure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 88, 4));
1151 $atom_structure['current_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 92, 4));
1152 $atom_structure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 96, 4));
1154 if ($atom_structure['time_scale'] == 0) {
1155 $info['error'][] = 'Corrupt Quicktime file: mvhd.time_scale == zero';
1158 $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
1159 $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
1160 $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
1161 $info['quicktime']['display_scale'] = $atom_structure['matrix_a'];
1162 $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
1166 case 'tkhd': // TracK HeaDer atom
1167 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1168 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
1169 $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1170 $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1171 $atom_structure['trackid'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1172 $atom_structure['reserved1'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
1173 $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
1174 $atom_structure['reserved2'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 8));
1175 $atom_structure['layer'] = getid3_lib::BigEndian2Int(substr($atom_data, 32, 2));
1176 $atom_structure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atom_data, 34, 2));
1177 $atom_structure['volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 36, 2));
1178 $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2));
1179 // http://developer.apple.com/library/mac/#documentation/QuickTime/RM/MovieBasics/MTEditing/K-Chapter/11MatrixFunctions.html
1180 // http://developer.apple.com/library/mac/#documentation/QuickTime/qtff/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-18737
1181 $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
1182 $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 44, 4));
1183 $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 48, 4));
1184 $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
1185 $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 56, 4));
1186 $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 60, 4));
1187 $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));
1188 $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 68, 4));
1189 $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 72, 4));
1190 $atom_structure['width'] = getid3_lib::FixedPoint16_16(substr($atom_data, 76, 4));
1191 $atom_structure['height'] = getid3_lib::FixedPoint16_16(substr($atom_data, 80, 4));
1192 $atom_structure['flags']['enabled'] = (bool) ($atom_structure['flags_raw'] & 0x0001);
1193 $atom_structure['flags']['in_movie'] = (bool) ($atom_structure['flags_raw'] & 0x0002);
1194 $atom_structure['flags']['in_preview'] = (bool) ($atom_structure['flags_raw'] & 0x0004);
1195 $atom_structure['flags']['in_poster'] = (bool) ($atom_structure['flags_raw'] & 0x0008);
1196 $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
1197 $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
1199 if ($atom_structure['flags']['enabled'] == 1) {
1200 if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) {
1201 $info['video']['resolution_x'] = $atom_structure['width'];
1202 $info['video']['resolution_y'] = $atom_structure['height'];
1204 $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']);
1205 $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']);
1206 $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];
1207 $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];
1209 // see: http://www.getid3.org/phpBB3/viewtopic.php?t=1295
1210 //if (isset($info['video']['resolution_x'])) { unset($info['video']['resolution_x']); }
1211 //if (isset($info['video']['resolution_y'])) { unset($info['video']['resolution_y']); }
1212 //if (isset($info['quicktime']['video'])) { unset($info['quicktime']['video']); }
1217 case 'iods': // Initial Object DeScriptor atom
1218 // http://www.koders.com/c/fid1FAB3E762903DC482D8A246D4A4BF9F28E049594.aspx?s=windows.h
1219 // http://libquicktime.sourcearchive.com/documentation/1.0.2plus-pdebian/iods_8c-source.html
1221 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1223 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 3));
1225 $atom_structure['mp4_iod_tag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1227 $atom_structure['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
1228 //$offset already adjusted by quicktime_read_mp4_descr_length()
1229 $atom_structure['object_descriptor_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2));
1231 $atom_structure['od_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1233 $atom_structure['scene_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1235 $atom_structure['audio_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1237 $atom_structure['video_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1239 $atom_structure['graphics_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1242 $atom_structure['num_iods_tracks'] = ($atom_structure['length'] - 7) / 6; // 6 bytes would only be right if all tracks use 1-byte length fields
1243 for ($i = 0; $i < $atom_structure['num_iods_tracks']; $i++) {
1244 $atom_structure['track'][$i]['ES_ID_IncTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1246 $atom_structure['track'][$i]['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
1247 //$offset already adjusted by quicktime_read_mp4_descr_length()
1248 $atom_structure['track'][$i]['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4));
1252 $atom_structure['audio_profile_name'] = $this->QuicktimeIODSaudioProfileName($atom_structure['audio_profile_id']);
1253 $atom_structure['video_profile_name'] = $this->QuicktimeIODSvideoProfileName($atom_structure['video_profile_id']);
1256 case 'ftyp': // FileTYPe (?) atom (for MP4 it seems)
1257 $atom_structure['signature'] = substr($atom_data, 0, 4);
1258 $atom_structure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1259 $atom_structure['fourcc'] = substr($atom_data, 8, 4);
1262 case 'mdat': // Media DATa atom
1263 case 'free': // FREE space atom
1264 case 'skip': // SKIP atom
1265 case 'wide': // 64-bit expansion placeholder atom
1266 // 'mdat' data is too big to deal with, contains no useful metadata
1267 // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
1269 // When writing QuickTime files, it is sometimes necessary to update an atom's size.
1270 // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom
1271 // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime
1272 // puts an 8-byte placeholder atom before any atoms it may have to update the size of.
1273 // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the
1274 // placeholder atom can be overwritten to obtain the necessary 8 extra bytes.
1275 // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ).
1279 case 'nsav': // NoSAVe atom
1280 // http://developer.apple.com/technotes/tn/tn2038.html
1281 $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1284 case 'ctyp': // Controller TYPe atom (seen on QTVR)
1285 // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt
1286 // some controller names are:
1287 // 0x00 + 'std' for linear movie
1288 // 'none' for no controls
1289 $atom_structure['ctyp'] = substr($atom_data, 0, 4);
1290 $info['quicktime']['controller'] = $atom_structure['ctyp'];
1291 switch ($atom_structure['ctyp']) {
1293 $info['video']['dataformat'] = 'quicktimevr';
1298 case 'pano': // PANOrama track (seen on QTVR)
1299 $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1302 case 'hint': // HINT track
1306 $info['quicktime']['hinting'] = true;
1309 case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR)
1310 for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) {
1311 $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));
1316 // Observed-but-not-handled atom types are just listed here to prevent warnings being generated
1317 case 'FXTC': // Something to do with Adobe After Effects (?)
1320 case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
1321 case 'tapt': // TrackApertureModeDimensionsAID - http://developer.apple.com/documentation/QuickTime/Reference/QT7-1_Update_Reference/Constants/Constants.html
1322 // tapt seems to be used to compute the video size [http://www.getid3.org/phpBB3/viewtopic.php?t=838]
1323 // * http://lists.apple.com/archives/quicktime-api/2006/Aug/msg00014.html
1324 // * http://handbrake.fr/irclogs/handbrake-dev/handbrake-dev20080128_pg2.html
1325 case 'ctts':// STCompositionOffsetAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1326 case 'cslg':// STCompositionShiftLeastGreatestAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1327 case 'sdtp':// STSampleDependencyAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1328 case 'stps':// STPartialSyncSampleAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1329 //$atom_structure['data'] = $atom_data;
1332 case '©xyz': // GPS latitude+longitude+altitude
1333 $atom_structure['data'] = $atom_data;
1334 if (preg_match('#([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)?/$#i', $atom_data, $matches)) {
1335 @list($all, $latitude, $longitude, $altitude) = $matches;
1336 $info['quicktime']['comments']['gps_latitude'][] = floatval($latitude);
1337 $info['quicktime']['comments']['gps_longitude'][] = floatval($longitude);
1338 if (!empty($altitude)) {
1339 $info['quicktime']['comments']['gps_altitude'][] = floatval($altitude);
1342 $info['warning'][] = 'QuickTime atom "©xyz" data does not match expected data pattern at offset '.$baseoffset.'. Please report as getID3() bug.';
1347 // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1348 // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
1349 $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 4, $atomHierarchy, $ParseAllPossibleAtoms);
1351 case 'NCTH': // Nikon Camera THumbnail image
1352 case 'NCVW': // Nikon Camera preVieW image
1353 // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1354 if (preg_match('/^\xFF\xD8\xFF/', $atom_data)) {
1355 $atom_structure['data'] = $atom_data;
1356 $atom_structure['image_mime'] = 'image/jpeg';
1357 $atom_structure['description'] = (($atomname == 'NCTH') ? 'Nikon Camera Thumbnail Image' : (($atomname == 'NCVW') ? 'Nikon Camera Preview Image' : 'Nikon preview image'));
1358 $info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_data, 'description'=>$atom_structure['description']);
1361 case 'NCHD': // MakerNoteVersion
1362 // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1363 $atom_structure['data'] = $atom_data;
1365 case 'NCTG': // NikonTags
1366 // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
1367 $atom_structure['data'] = $this->QuicktimeParseNikonNCTG($atom_data);
1369 case 'NCDB': // NikonTags
1370 // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1371 $atom_structure['data'] = $atom_data;
1374 case "\x00\x00\x00\x00":
1375 case 'meta': // METAdata atom
1376 // some kind of metacontainer, may contain a big data dump such as:
1377 // mdta keys
\ 5 mdtacom.apple.quicktime.make (mdtacom.apple.quicktime.creationdate ,mdtacom.apple.quicktime.location.ISO6709 $mdtacom.apple.quicktime.software !mdtacom.apple.quicktime.model ilst
\1d \ 1 \15data
\ 1DE
\10Apple 0
\ 2 (data
\ 1DE
\102011-05-11T17:54:04+0200 2
\ 3 *data
\ 1DE
\10+52.4936+013.3897+040.247/
\1d \ 4 \15data
\ 1DE
\104.3.1
\ 5 \18data
\ 1DE
\10iPhone 4
1378 // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
1380 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1381 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
1382 $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_data, 4), $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
1383 //$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
1386 case 'data': // metaDATA atom
1387 // seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in sample I have), remainder is useful data
1388 $atom_structure['language'] = substr($atom_data, 4 + 0, 2);
1389 $atom_structure['unknown'] = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2));
1390 $atom_structure['data'] = substr($atom_data, 4 + 4);
1394 $info['warning'][] = 'Unknown QuickTime atom type: "'.$atomname.'" ('.trim(getid3_lib::PrintHexBytes($atomname)).') at offset '.$baseoffset;
1395 $atom_structure['data'] = $atom_data;
1398 array_pop($atomHierarchy);
1399 return $atom_structure;
1402 public function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
1403 //echo 'QuicktimeParseContainerAtom('.substr($atom_data, 4, 4).') @ '.$baseoffset.'<br><br>';
1404 $atom_structure = false;
1406 $subatomcounter = 0;
1407 if ((strlen($atom_data) == 4) && (getid3_lib::BigEndian2Int($atom_data) == 0x00000000)) {
1410 while ($subatomoffset < strlen($atom_data)) {
1411 $subatomsize = getid3_lib::BigEndian2Int(substr($atom_data, $subatomoffset + 0, 4));
1412 $subatomname = substr($atom_data, $subatomoffset + 4, 4);
1413 $subatomdata = substr($atom_data, $subatomoffset + 8, $subatomsize - 8);
1414 if ($subatomsize == 0) {
1415 // Furthermore, for historical reasons the list of atoms is optionally
1416 // terminated by a 32-bit integer set to 0. If you are writing a program
1417 // to read user data atoms, you should allow for the terminating 0.
1418 return $atom_structure;
1421 $atom_structure[$subatomcounter] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms);
1423 $subatomoffset += $subatomsize;
1426 return $atom_structure;
1430 public function quicktime_read_mp4_descr_length($data, &$offset) {
1431 // http://libquicktime.sourcearchive.com/documentation/2:1.0.2plus-pdebian-2build1/esds_8c-source.html
1435 $b = ord(substr($data, $offset++, 1));
1436 $length = ($length << 7) | ($b & 0x7F);
1437 } while (($b & 0x80) && ($num_bytes++ < 4));
1442 public function QuicktimeLanguageLookup($languageid) {
1443 // http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-34353
1444 static $QuicktimeLanguageLookup = array();
1445 if (empty($QuicktimeLanguageLookup)) {
1446 $QuicktimeLanguageLookup[0] = 'English';
1447 $QuicktimeLanguageLookup[1] = 'French';
1448 $QuicktimeLanguageLookup[2] = 'German';
1449 $QuicktimeLanguageLookup[3] = 'Italian';
1450 $QuicktimeLanguageLookup[4] = 'Dutch';
1451 $QuicktimeLanguageLookup[5] = 'Swedish';
1452 $QuicktimeLanguageLookup[6] = 'Spanish';
1453 $QuicktimeLanguageLookup[7] = 'Danish';
1454 $QuicktimeLanguageLookup[8] = 'Portuguese';
1455 $QuicktimeLanguageLookup[9] = 'Norwegian';
1456 $QuicktimeLanguageLookup[10] = 'Hebrew';
1457 $QuicktimeLanguageLookup[11] = 'Japanese';
1458 $QuicktimeLanguageLookup[12] = 'Arabic';
1459 $QuicktimeLanguageLookup[13] = 'Finnish';
1460 $QuicktimeLanguageLookup[14] = 'Greek';
1461 $QuicktimeLanguageLookup[15] = 'Icelandic';
1462 $QuicktimeLanguageLookup[16] = 'Maltese';
1463 $QuicktimeLanguageLookup[17] = 'Turkish';
1464 $QuicktimeLanguageLookup[18] = 'Croatian';
1465 $QuicktimeLanguageLookup[19] = 'Chinese (Traditional)';
1466 $QuicktimeLanguageLookup[20] = 'Urdu';
1467 $QuicktimeLanguageLookup[21] = 'Hindi';
1468 $QuicktimeLanguageLookup[22] = 'Thai';
1469 $QuicktimeLanguageLookup[23] = 'Korean';
1470 $QuicktimeLanguageLookup[24] = 'Lithuanian';
1471 $QuicktimeLanguageLookup[25] = 'Polish';
1472 $QuicktimeLanguageLookup[26] = 'Hungarian';
1473 $QuicktimeLanguageLookup[27] = 'Estonian';
1474 $QuicktimeLanguageLookup[28] = 'Lettish';
1475 $QuicktimeLanguageLookup[28] = 'Latvian';
1476 $QuicktimeLanguageLookup[29] = 'Saamisk';
1477 $QuicktimeLanguageLookup[29] = 'Lappish';
1478 $QuicktimeLanguageLookup[30] = 'Faeroese';
1479 $QuicktimeLanguageLookup[31] = 'Farsi';
1480 $QuicktimeLanguageLookup[31] = 'Persian';
1481 $QuicktimeLanguageLookup[32] = 'Russian';
1482 $QuicktimeLanguageLookup[33] = 'Chinese (Simplified)';
1483 $QuicktimeLanguageLookup[34] = 'Flemish';
1484 $QuicktimeLanguageLookup[35] = 'Irish';
1485 $QuicktimeLanguageLookup[36] = 'Albanian';
1486 $QuicktimeLanguageLookup[37] = 'Romanian';
1487 $QuicktimeLanguageLookup[38] = 'Czech';
1488 $QuicktimeLanguageLookup[39] = 'Slovak';
1489 $QuicktimeLanguageLookup[40] = 'Slovenian';
1490 $QuicktimeLanguageLookup[41] = 'Yiddish';
1491 $QuicktimeLanguageLookup[42] = 'Serbian';
1492 $QuicktimeLanguageLookup[43] = 'Macedonian';
1493 $QuicktimeLanguageLookup[44] = 'Bulgarian';
1494 $QuicktimeLanguageLookup[45] = 'Ukrainian';
1495 $QuicktimeLanguageLookup[46] = 'Byelorussian';
1496 $QuicktimeLanguageLookup[47] = 'Uzbek';
1497 $QuicktimeLanguageLookup[48] = 'Kazakh';
1498 $QuicktimeLanguageLookup[49] = 'Azerbaijani';
1499 $QuicktimeLanguageLookup[50] = 'AzerbaijanAr';
1500 $QuicktimeLanguageLookup[51] = 'Armenian';
1501 $QuicktimeLanguageLookup[52] = 'Georgian';
1502 $QuicktimeLanguageLookup[53] = 'Moldavian';
1503 $QuicktimeLanguageLookup[54] = 'Kirghiz';
1504 $QuicktimeLanguageLookup[55] = 'Tajiki';
1505 $QuicktimeLanguageLookup[56] = 'Turkmen';
1506 $QuicktimeLanguageLookup[57] = 'Mongolian';
1507 $QuicktimeLanguageLookup[58] = 'MongolianCyr';
1508 $QuicktimeLanguageLookup[59] = 'Pashto';
1509 $QuicktimeLanguageLookup[60] = 'Kurdish';
1510 $QuicktimeLanguageLookup[61] = 'Kashmiri';
1511 $QuicktimeLanguageLookup[62] = 'Sindhi';
1512 $QuicktimeLanguageLookup[63] = 'Tibetan';
1513 $QuicktimeLanguageLookup[64] = 'Nepali';
1514 $QuicktimeLanguageLookup[65] = 'Sanskrit';
1515 $QuicktimeLanguageLookup[66] = 'Marathi';
1516 $QuicktimeLanguageLookup[67] = 'Bengali';
1517 $QuicktimeLanguageLookup[68] = 'Assamese';
1518 $QuicktimeLanguageLookup[69] = 'Gujarati';
1519 $QuicktimeLanguageLookup[70] = 'Punjabi';
1520 $QuicktimeLanguageLookup[71] = 'Oriya';
1521 $QuicktimeLanguageLookup[72] = 'Malayalam';
1522 $QuicktimeLanguageLookup[73] = 'Kannada';
1523 $QuicktimeLanguageLookup[74] = 'Tamil';
1524 $QuicktimeLanguageLookup[75] = 'Telugu';
1525 $QuicktimeLanguageLookup[76] = 'Sinhalese';
1526 $QuicktimeLanguageLookup[77] = 'Burmese';
1527 $QuicktimeLanguageLookup[78] = 'Khmer';
1528 $QuicktimeLanguageLookup[79] = 'Lao';
1529 $QuicktimeLanguageLookup[80] = 'Vietnamese';
1530 $QuicktimeLanguageLookup[81] = 'Indonesian';
1531 $QuicktimeLanguageLookup[82] = 'Tagalog';
1532 $QuicktimeLanguageLookup[83] = 'MalayRoman';
1533 $QuicktimeLanguageLookup[84] = 'MalayArabic';
1534 $QuicktimeLanguageLookup[85] = 'Amharic';
1535 $QuicktimeLanguageLookup[86] = 'Tigrinya';
1536 $QuicktimeLanguageLookup[87] = 'Galla';
1537 $QuicktimeLanguageLookup[87] = 'Oromo';
1538 $QuicktimeLanguageLookup[88] = 'Somali';
1539 $QuicktimeLanguageLookup[89] = 'Swahili';
1540 $QuicktimeLanguageLookup[90] = 'Ruanda';
1541 $QuicktimeLanguageLookup[91] = 'Rundi';
1542 $QuicktimeLanguageLookup[92] = 'Chewa';
1543 $QuicktimeLanguageLookup[93] = 'Malagasy';
1544 $QuicktimeLanguageLookup[94] = 'Esperanto';
1545 $QuicktimeLanguageLookup[128] = 'Welsh';
1546 $QuicktimeLanguageLookup[129] = 'Basque';
1547 $QuicktimeLanguageLookup[130] = 'Catalan';
1548 $QuicktimeLanguageLookup[131] = 'Latin';
1549 $QuicktimeLanguageLookup[132] = 'Quechua';
1550 $QuicktimeLanguageLookup[133] = 'Guarani';
1551 $QuicktimeLanguageLookup[134] = 'Aymara';
1552 $QuicktimeLanguageLookup[135] = 'Tatar';
1553 $QuicktimeLanguageLookup[136] = 'Uighur';
1554 $QuicktimeLanguageLookup[137] = 'Dzongkha';
1555 $QuicktimeLanguageLookup[138] = 'JavaneseRom';
1556 $QuicktimeLanguageLookup[32767] = 'Unspecified';
1558 if (($languageid > 138) && ($languageid < 32767)) {
1560 ISO Language Codes - http://www.loc.gov/standards/iso639-2/php/code_list.php
1561 Because the language codes specified by ISO 639-2/T are three characters long, they must be packed to fit into a 16-bit field.
1562 The packing algorithm must map each of the three characters, which are always lowercase, into a 5-bit integer and then concatenate
1563 these integers into the least significant 15 bits of a 16-bit integer, leaving the 16-bit integer's most significant bit set to zero.
1565 One algorithm for performing this packing is to treat each ISO character as a 16-bit integer. Subtract 0x60 from the first character
1566 and multiply by 2^10 (0x400), subtract 0x60 from the second character and multiply by 2^5 (0x20), subtract 0x60 from the third character,
1567 and add the three 16-bit values. This will result in a single 16-bit value with the three codes correctly packed into the 15 least
1568 significant bits and the most significant bit set to zero.
1570 $iso_language_id = '';
1571 $iso_language_id .= chr((($languageid & 0x7C00) >> 10) + 0x60);
1572 $iso_language_id .= chr((($languageid & 0x03E0) >> 5) + 0x60);
1573 $iso_language_id .= chr((($languageid & 0x001F) >> 0) + 0x60);
1574 $QuicktimeLanguageLookup[$languageid] = getid3_id3v2::LanguageLookup($iso_language_id);
1576 return (isset($QuicktimeLanguageLookup[$languageid]) ? $QuicktimeLanguageLookup[$languageid] : 'invalid');
1579 public function QuicktimeVideoCodecLookup($codecid) {
1580 static $QuicktimeVideoCodecLookup = array();
1581 if (empty($QuicktimeVideoCodecLookup)) {
1582 $QuicktimeVideoCodecLookup['.SGI'] = 'SGI';
1583 $QuicktimeVideoCodecLookup['3IV1'] = '3ivx MPEG-4 v1';
1584 $QuicktimeVideoCodecLookup['3IV2'] = '3ivx MPEG-4 v2';
1585 $QuicktimeVideoCodecLookup['3IVX'] = '3ivx MPEG-4';
1586 $QuicktimeVideoCodecLookup['8BPS'] = 'Planar RGB';
1587 $QuicktimeVideoCodecLookup['avc1'] = 'H.264/MPEG-4 AVC';
1588 $QuicktimeVideoCodecLookup['avr '] = 'AVR-JPEG';
1589 $QuicktimeVideoCodecLookup['b16g'] = '16Gray';
1590 $QuicktimeVideoCodecLookup['b32a'] = '32AlphaGray';
1591 $QuicktimeVideoCodecLookup['b48r'] = '48RGB';
1592 $QuicktimeVideoCodecLookup['b64a'] = '64ARGB';
1593 $QuicktimeVideoCodecLookup['base'] = 'Base';
1594 $QuicktimeVideoCodecLookup['clou'] = 'Cloud';
1595 $QuicktimeVideoCodecLookup['cmyk'] = 'CMYK';
1596 $QuicktimeVideoCodecLookup['cvid'] = 'Cinepak';
1597 $QuicktimeVideoCodecLookup['dmb1'] = 'OpenDML JPEG';
1598 $QuicktimeVideoCodecLookup['dvc '] = 'DVC-NTSC';
1599 $QuicktimeVideoCodecLookup['dvcp'] = 'DVC-PAL';
1600 $QuicktimeVideoCodecLookup['dvpn'] = 'DVCPro-NTSC';
1601 $QuicktimeVideoCodecLookup['dvpp'] = 'DVCPro-PAL';
1602 $QuicktimeVideoCodecLookup['fire'] = 'Fire';
1603 $QuicktimeVideoCodecLookup['flic'] = 'FLC';
1604 $QuicktimeVideoCodecLookup['gif '] = 'GIF';
1605 $QuicktimeVideoCodecLookup['h261'] = 'H261';
1606 $QuicktimeVideoCodecLookup['h263'] = 'H263';
1607 $QuicktimeVideoCodecLookup['IV41'] = 'Indeo4';
1608 $QuicktimeVideoCodecLookup['jpeg'] = 'JPEG';
1609 $QuicktimeVideoCodecLookup['kpcd'] = 'PhotoCD';
1610 $QuicktimeVideoCodecLookup['mjpa'] = 'Motion JPEG-A';
1611 $QuicktimeVideoCodecLookup['mjpb'] = 'Motion JPEG-B';
1612 $QuicktimeVideoCodecLookup['msvc'] = 'Microsoft Video1';
1613 $QuicktimeVideoCodecLookup['myuv'] = 'MPEG YUV420';
1614 $QuicktimeVideoCodecLookup['path'] = 'Vector';
1615 $QuicktimeVideoCodecLookup['png '] = 'PNG';
1616 $QuicktimeVideoCodecLookup['PNTG'] = 'MacPaint';
1617 $QuicktimeVideoCodecLookup['qdgx'] = 'QuickDrawGX';
1618 $QuicktimeVideoCodecLookup['qdrw'] = 'QuickDraw';
1619 $QuicktimeVideoCodecLookup['raw '] = 'RAW';
1620 $QuicktimeVideoCodecLookup['ripl'] = 'WaterRipple';
1621 $QuicktimeVideoCodecLookup['rpza'] = 'Video';
1622 $QuicktimeVideoCodecLookup['smc '] = 'Graphics';
1623 $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 1';
1624 $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 3';
1625 $QuicktimeVideoCodecLookup['syv9'] = 'Sorenson YUV9';
1626 $QuicktimeVideoCodecLookup['tga '] = 'Targa';
1627 $QuicktimeVideoCodecLookup['tiff'] = 'TIFF';
1628 $QuicktimeVideoCodecLookup['WRAW'] = 'Windows RAW';
1629 $QuicktimeVideoCodecLookup['WRLE'] = 'BMP';
1630 $QuicktimeVideoCodecLookup['y420'] = 'YUV420';
1631 $QuicktimeVideoCodecLookup['yuv2'] = 'ComponentVideo';
1632 $QuicktimeVideoCodecLookup['yuvs'] = 'ComponentVideoUnsigned';
1633 $QuicktimeVideoCodecLookup['yuvu'] = 'ComponentVideoSigned';
1635 return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : '');
1638 public function QuicktimeAudioCodecLookup($codecid) {
1639 static $QuicktimeAudioCodecLookup = array();
1640 if (empty($QuicktimeAudioCodecLookup)) {
1641 $QuicktimeAudioCodecLookup['.mp3'] = 'Fraunhofer MPEG Layer-III alias';
1642 $QuicktimeAudioCodecLookup['aac '] = 'ISO/IEC 14496-3 AAC';
1643 $QuicktimeAudioCodecLookup['agsm'] = 'Apple GSM 10:1';
1644 $QuicktimeAudioCodecLookup['alac'] = 'Apple Lossless Audio Codec';
1645 $QuicktimeAudioCodecLookup['alaw'] = 'A-law 2:1';
1646 $QuicktimeAudioCodecLookup['conv'] = 'Sample Format';
1647 $QuicktimeAudioCodecLookup['dvca'] = 'DV';
1648 $QuicktimeAudioCodecLookup['dvi '] = 'DV 4:1';
1649 $QuicktimeAudioCodecLookup['eqal'] = 'Frequency Equalizer';
1650 $QuicktimeAudioCodecLookup['fl32'] = '32-bit Floating Point';
1651 $QuicktimeAudioCodecLookup['fl64'] = '64-bit Floating Point';
1652 $QuicktimeAudioCodecLookup['ima4'] = 'Interactive Multimedia Association 4:1';
1653 $QuicktimeAudioCodecLookup['in24'] = '24-bit Integer';
1654 $QuicktimeAudioCodecLookup['in32'] = '32-bit Integer';
1655 $QuicktimeAudioCodecLookup['lpc '] = 'LPC 23:1';
1656 $QuicktimeAudioCodecLookup['MAC3'] = 'Macintosh Audio Compression/Expansion (MACE) 3:1';
1657 $QuicktimeAudioCodecLookup['MAC6'] = 'Macintosh Audio Compression/Expansion (MACE) 6:1';
1658 $QuicktimeAudioCodecLookup['mixb'] = '8-bit Mixer';
1659 $QuicktimeAudioCodecLookup['mixw'] = '16-bit Mixer';
1660 $QuicktimeAudioCodecLookup['mp4a'] = 'ISO/IEC 14496-3 AAC';
1661 $QuicktimeAudioCodecLookup['MS'."\x00\x02"] = 'Microsoft ADPCM';
1662 $QuicktimeAudioCodecLookup['MS'."\x00\x11"] = 'DV IMA';
1663 $QuicktimeAudioCodecLookup['MS'."\x00\x55"] = 'Fraunhofer MPEG Layer III';
1664 $QuicktimeAudioCodecLookup['NONE'] = 'No Encoding';
1665 $QuicktimeAudioCodecLookup['Qclp'] = 'Qualcomm PureVoice';
1666 $QuicktimeAudioCodecLookup['QDM2'] = 'QDesign Music 2';
1667 $QuicktimeAudioCodecLookup['QDMC'] = 'QDesign Music 1';
1668 $QuicktimeAudioCodecLookup['ratb'] = '8-bit Rate';
1669 $QuicktimeAudioCodecLookup['ratw'] = '16-bit Rate';
1670 $QuicktimeAudioCodecLookup['raw '] = 'raw PCM';
1671 $QuicktimeAudioCodecLookup['sour'] = 'Sound Source';
1672 $QuicktimeAudioCodecLookup['sowt'] = 'signed/two\'s complement (Little Endian)';
1673 $QuicktimeAudioCodecLookup['str1'] = 'Iomega MPEG layer II';
1674 $QuicktimeAudioCodecLookup['str2'] = 'Iomega MPEG *layer II';
1675 $QuicktimeAudioCodecLookup['str3'] = 'Iomega MPEG **layer II';
1676 $QuicktimeAudioCodecLookup['str4'] = 'Iomega MPEG ***layer II';
1677 $QuicktimeAudioCodecLookup['twos'] = 'signed/two\'s complement (Big Endian)';
1678 $QuicktimeAudioCodecLookup['ulaw'] = 'mu-law 2:1';
1680 return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : '');
1683 public function QuicktimeDCOMLookup($compressionid) {
1684 static $QuicktimeDCOMLookup = array();
1685 if (empty($QuicktimeDCOMLookup)) {
1686 $QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate';
1687 $QuicktimeDCOMLookup['adec'] = 'Apple Compression';
1689 return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : '');
1692 public function QuicktimeColorNameLookup($colordepthid) {
1693 static $QuicktimeColorNameLookup = array();
1694 if (empty($QuicktimeColorNameLookup)) {
1695 $QuicktimeColorNameLookup[1] = '2-color (monochrome)';
1696 $QuicktimeColorNameLookup[2] = '4-color';
1697 $QuicktimeColorNameLookup[4] = '16-color';
1698 $QuicktimeColorNameLookup[8] = '256-color';
1699 $QuicktimeColorNameLookup[16] = 'thousands (16-bit color)';
1700 $QuicktimeColorNameLookup[24] = 'millions (24-bit color)';
1701 $QuicktimeColorNameLookup[32] = 'millions+ (32-bit color)';
1702 $QuicktimeColorNameLookup[33] = 'black & white';
1703 $QuicktimeColorNameLookup[34] = '4-gray';
1704 $QuicktimeColorNameLookup[36] = '16-gray';
1705 $QuicktimeColorNameLookup[40] = '256-gray';
1707 return (isset($QuicktimeColorNameLookup[$colordepthid]) ? $QuicktimeColorNameLookup[$colordepthid] : 'invalid');
1710 public function QuicktimeSTIKLookup($stik) {
1711 static $QuicktimeSTIKLookup = array();
1712 if (empty($QuicktimeSTIKLookup)) {
1713 $QuicktimeSTIKLookup[0] = 'Movie';
1714 $QuicktimeSTIKLookup[1] = 'Normal';
1715 $QuicktimeSTIKLookup[2] = 'Audiobook';
1716 $QuicktimeSTIKLookup[5] = 'Whacked Bookmark';
1717 $QuicktimeSTIKLookup[6] = 'Music Video';
1718 $QuicktimeSTIKLookup[9] = 'Short Film';
1719 $QuicktimeSTIKLookup[10] = 'TV Show';
1720 $QuicktimeSTIKLookup[11] = 'Booklet';
1721 $QuicktimeSTIKLookup[14] = 'Ringtone';
1722 $QuicktimeSTIKLookup[21] = 'Podcast';
1724 return (isset($QuicktimeSTIKLookup[$stik]) ? $QuicktimeSTIKLookup[$stik] : 'invalid');
1727 public function QuicktimeIODSaudioProfileName($audio_profile_id) {
1728 static $QuicktimeIODSaudioProfileNameLookup = array();
1729 if (empty($QuicktimeIODSaudioProfileNameLookup)) {
1730 $QuicktimeIODSaudioProfileNameLookup = array(
1731 0x00 => 'ISO Reserved (0x00)',
1732 0x01 => 'Main Audio Profile @ Level 1',
1733 0x02 => 'Main Audio Profile @ Level 2',
1734 0x03 => 'Main Audio Profile @ Level 3',
1735 0x04 => 'Main Audio Profile @ Level 4',
1736 0x05 => 'Scalable Audio Profile @ Level 1',
1737 0x06 => 'Scalable Audio Profile @ Level 2',
1738 0x07 => 'Scalable Audio Profile @ Level 3',
1739 0x08 => 'Scalable Audio Profile @ Level 4',
1740 0x09 => 'Speech Audio Profile @ Level 1',
1741 0x0A => 'Speech Audio Profile @ Level 2',
1742 0x0B => 'Synthetic Audio Profile @ Level 1',
1743 0x0C => 'Synthetic Audio Profile @ Level 2',
1744 0x0D => 'Synthetic Audio Profile @ Level 3',
1745 0x0E => 'High Quality Audio Profile @ Level 1',
1746 0x0F => 'High Quality Audio Profile @ Level 2',
1747 0x10 => 'High Quality Audio Profile @ Level 3',
1748 0x11 => 'High Quality Audio Profile @ Level 4',
1749 0x12 => 'High Quality Audio Profile @ Level 5',
1750 0x13 => 'High Quality Audio Profile @ Level 6',
1751 0x14 => 'High Quality Audio Profile @ Level 7',
1752 0x15 => 'High Quality Audio Profile @ Level 8',
1753 0x16 => 'Low Delay Audio Profile @ Level 1',
1754 0x17 => 'Low Delay Audio Profile @ Level 2',
1755 0x18 => 'Low Delay Audio Profile @ Level 3',
1756 0x19 => 'Low Delay Audio Profile @ Level 4',
1757 0x1A => 'Low Delay Audio Profile @ Level 5',
1758 0x1B => 'Low Delay Audio Profile @ Level 6',
1759 0x1C => 'Low Delay Audio Profile @ Level 7',
1760 0x1D => 'Low Delay Audio Profile @ Level 8',
1761 0x1E => 'Natural Audio Profile @ Level 1',
1762 0x1F => 'Natural Audio Profile @ Level 2',
1763 0x20 => 'Natural Audio Profile @ Level 3',
1764 0x21 => 'Natural Audio Profile @ Level 4',
1765 0x22 => 'Mobile Audio Internetworking Profile @ Level 1',
1766 0x23 => 'Mobile Audio Internetworking Profile @ Level 2',
1767 0x24 => 'Mobile Audio Internetworking Profile @ Level 3',
1768 0x25 => 'Mobile Audio Internetworking Profile @ Level 4',
1769 0x26 => 'Mobile Audio Internetworking Profile @ Level 5',
1770 0x27 => 'Mobile Audio Internetworking Profile @ Level 6',
1771 0x28 => 'AAC Profile @ Level 1',
1772 0x29 => 'AAC Profile @ Level 2',
1773 0x2A => 'AAC Profile @ Level 4',
1774 0x2B => 'AAC Profile @ Level 5',
1775 0x2C => 'High Efficiency AAC Profile @ Level 2',
1776 0x2D => 'High Efficiency AAC Profile @ Level 3',
1777 0x2E => 'High Efficiency AAC Profile @ Level 4',
1778 0x2F => 'High Efficiency AAC Profile @ Level 5',
1779 0xFE => 'Not part of MPEG-4 audio profiles',
1780 0xFF => 'No audio capability required',
1783 return (isset($QuicktimeIODSaudioProfileNameLookup[$audio_profile_id]) ? $QuicktimeIODSaudioProfileNameLookup[$audio_profile_id] : 'ISO Reserved / User Private');
1787 public function QuicktimeIODSvideoProfileName($video_profile_id) {
1788 static $QuicktimeIODSvideoProfileNameLookup = array();
1789 if (empty($QuicktimeIODSvideoProfileNameLookup)) {
1790 $QuicktimeIODSvideoProfileNameLookup = array(
1791 0x00 => 'Reserved (0x00) Profile',
1792 0x01 => 'Simple Profile @ Level 1',
1793 0x02 => 'Simple Profile @ Level 2',
1794 0x03 => 'Simple Profile @ Level 3',
1795 0x08 => 'Simple Profile @ Level 0',
1796 0x10 => 'Simple Scalable Profile @ Level 0',
1797 0x11 => 'Simple Scalable Profile @ Level 1',
1798 0x12 => 'Simple Scalable Profile @ Level 2',
1799 0x15 => 'AVC/H264 Profile',
1800 0x21 => 'Core Profile @ Level 1',
1801 0x22 => 'Core Profile @ Level 2',
1802 0x32 => 'Main Profile @ Level 2',
1803 0x33 => 'Main Profile @ Level 3',
1804 0x34 => 'Main Profile @ Level 4',
1805 0x42 => 'N-bit Profile @ Level 2',
1806 0x51 => 'Scalable Texture Profile @ Level 1',
1807 0x61 => 'Simple Face Animation Profile @ Level 1',
1808 0x62 => 'Simple Face Animation Profile @ Level 2',
1809 0x63 => 'Simple FBA Profile @ Level 1',
1810 0x64 => 'Simple FBA Profile @ Level 2',
1811 0x71 => 'Basic Animated Texture Profile @ Level 1',
1812 0x72 => 'Basic Animated Texture Profile @ Level 2',
1813 0x81 => 'Hybrid Profile @ Level 1',
1814 0x82 => 'Hybrid Profile @ Level 2',
1815 0x91 => 'Advanced Real Time Simple Profile @ Level 1',
1816 0x92 => 'Advanced Real Time Simple Profile @ Level 2',
1817 0x93 => 'Advanced Real Time Simple Profile @ Level 3',
1818 0x94 => 'Advanced Real Time Simple Profile @ Level 4',
1819 0xA1 => 'Core Scalable Profile @ Level1',
1820 0xA2 => 'Core Scalable Profile @ Level2',
1821 0xA3 => 'Core Scalable Profile @ Level3',
1822 0xB1 => 'Advanced Coding Efficiency Profile @ Level 1',
1823 0xB2 => 'Advanced Coding Efficiency Profile @ Level 2',
1824 0xB3 => 'Advanced Coding Efficiency Profile @ Level 3',
1825 0xB4 => 'Advanced Coding Efficiency Profile @ Level 4',
1826 0xC1 => 'Advanced Core Profile @ Level 1',
1827 0xC2 => 'Advanced Core Profile @ Level 2',
1828 0xD1 => 'Advanced Scalable Texture @ Level1',
1829 0xD2 => 'Advanced Scalable Texture @ Level2',
1830 0xE1 => 'Simple Studio Profile @ Level 1',
1831 0xE2 => 'Simple Studio Profile @ Level 2',
1832 0xE3 => 'Simple Studio Profile @ Level 3',
1833 0xE4 => 'Simple Studio Profile @ Level 4',
1834 0xE5 => 'Core Studio Profile @ Level 1',
1835 0xE6 => 'Core Studio Profile @ Level 2',
1836 0xE7 => 'Core Studio Profile @ Level 3',
1837 0xE8 => 'Core Studio Profile @ Level 4',
1838 0xF0 => 'Advanced Simple Profile @ Level 0',
1839 0xF1 => 'Advanced Simple Profile @ Level 1',
1840 0xF2 => 'Advanced Simple Profile @ Level 2',
1841 0xF3 => 'Advanced Simple Profile @ Level 3',
1842 0xF4 => 'Advanced Simple Profile @ Level 4',
1843 0xF5 => 'Advanced Simple Profile @ Level 5',
1844 0xF7 => 'Advanced Simple Profile @ Level 3b',
1845 0xF8 => 'Fine Granularity Scalable Profile @ Level 0',
1846 0xF9 => 'Fine Granularity Scalable Profile @ Level 1',
1847 0xFA => 'Fine Granularity Scalable Profile @ Level 2',
1848 0xFB => 'Fine Granularity Scalable Profile @ Level 3',
1849 0xFC => 'Fine Granularity Scalable Profile @ Level 4',
1850 0xFD => 'Fine Granularity Scalable Profile @ Level 5',
1851 0xFE => 'Not part of MPEG-4 Visual profiles',
1852 0xFF => 'No visual capability required',
1855 return (isset($QuicktimeIODSvideoProfileNameLookup[$video_profile_id]) ? $QuicktimeIODSvideoProfileNameLookup[$video_profile_id] : 'ISO Reserved Profile');
1859 public function QuicktimeContentRatingLookup($rtng) {
1860 static $QuicktimeContentRatingLookup = array();
1861 if (empty($QuicktimeContentRatingLookup)) {
1862 $QuicktimeContentRatingLookup[0] = 'None';
1863 $QuicktimeContentRatingLookup[2] = 'Clean';
1864 $QuicktimeContentRatingLookup[4] = 'Explicit';
1866 return (isset($QuicktimeContentRatingLookup[$rtng]) ? $QuicktimeContentRatingLookup[$rtng] : 'invalid');
1869 public function QuicktimeStoreAccountTypeLookup($akid) {
1870 static $QuicktimeStoreAccountTypeLookup = array();
1871 if (empty($QuicktimeStoreAccountTypeLookup)) {
1872 $QuicktimeStoreAccountTypeLookup[0] = 'iTunes';
1873 $QuicktimeStoreAccountTypeLookup[1] = 'AOL';
1875 return (isset($QuicktimeStoreAccountTypeLookup[$akid]) ? $QuicktimeStoreAccountTypeLookup[$akid] : 'invalid');
1878 public function QuicktimeStoreFrontCodeLookup($sfid) {
1879 static $QuicktimeStoreFrontCodeLookup = array();
1880 if (empty($QuicktimeStoreFrontCodeLookup)) {
1881 $QuicktimeStoreFrontCodeLookup[143460] = 'Australia';
1882 $QuicktimeStoreFrontCodeLookup[143445] = 'Austria';
1883 $QuicktimeStoreFrontCodeLookup[143446] = 'Belgium';
1884 $QuicktimeStoreFrontCodeLookup[143455] = 'Canada';
1885 $QuicktimeStoreFrontCodeLookup[143458] = 'Denmark';
1886 $QuicktimeStoreFrontCodeLookup[143447] = 'Finland';
1887 $QuicktimeStoreFrontCodeLookup[143442] = 'France';
1888 $QuicktimeStoreFrontCodeLookup[143443] = 'Germany';
1889 $QuicktimeStoreFrontCodeLookup[143448] = 'Greece';
1890 $QuicktimeStoreFrontCodeLookup[143449] = 'Ireland';
1891 $QuicktimeStoreFrontCodeLookup[143450] = 'Italy';
1892 $QuicktimeStoreFrontCodeLookup[143462] = 'Japan';
1893 $QuicktimeStoreFrontCodeLookup[143451] = 'Luxembourg';
1894 $QuicktimeStoreFrontCodeLookup[143452] = 'Netherlands';
1895 $QuicktimeStoreFrontCodeLookup[143461] = 'New Zealand';
1896 $QuicktimeStoreFrontCodeLookup[143457] = 'Norway';
1897 $QuicktimeStoreFrontCodeLookup[143453] = 'Portugal';
1898 $QuicktimeStoreFrontCodeLookup[143454] = 'Spain';
1899 $QuicktimeStoreFrontCodeLookup[143456] = 'Sweden';
1900 $QuicktimeStoreFrontCodeLookup[143459] = 'Switzerland';
1901 $QuicktimeStoreFrontCodeLookup[143444] = 'United Kingdom';
1902 $QuicktimeStoreFrontCodeLookup[143441] = 'United States';
1904 return (isset($QuicktimeStoreFrontCodeLookup[$sfid]) ? $QuicktimeStoreFrontCodeLookup[$sfid] : 'invalid');
1907 public function QuicktimeParseNikonNCTG($atom_data) {
1908 // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
1909 // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
1910 // Data is stored as records of:
1911 // * 4 bytes record type
1912 // * 2 bytes size of data field type:
1913 // 0x0001 = flag (size field *= 1-byte)
1914 // 0x0002 = char (size field *= 1-byte)
1915 // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB
1916 // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD
1917 // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together
1918 // 0x0007 = bytes (size field *= 1-byte), values are stored as ??????
1919 // 0x0008 = ????? (size field *= 2-byte), values are stored as ??????
1920 // * 2 bytes data size field
1921 // * ? bytes data (string data may be null-padded; datestamp fields are in the format "2011:05:25 20:24:15")
1922 // all integers are stored BigEndian
1924 $NCTGtagName = array(
1925 0x00000001 => 'Make',
1926 0x00000002 => 'Model',
1927 0x00000003 => 'Software',
1928 0x00000011 => 'CreateDate',
1929 0x00000012 => 'DateTimeOriginal',
1930 0x00000013 => 'FrameCount',
1931 0x00000016 => 'FrameRate',
1932 0x00000022 => 'FrameWidth',
1933 0x00000023 => 'FrameHeight',
1934 0x00000032 => 'AudioChannels',
1935 0x00000033 => 'AudioBitsPerSample',
1936 0x00000034 => 'AudioSampleRate',
1937 0x02000001 => 'MakerNoteVersion',
1938 0x02000005 => 'WhiteBalance',
1939 0x0200000b => 'WhiteBalanceFineTune',
1940 0x0200001e => 'ColorSpace',
1941 0x02000023 => 'PictureControlData',
1942 0x02000024 => 'WorldTime',
1943 0x02000032 => 'UnknownInfo',
1944 0x02000083 => 'LensType',
1945 0x02000084 => 'Lens',
1949 $datalength = strlen($atom_data);
1951 while ($offset < $datalength) {
1952 //echo getid3_lib::PrintHexBytes(substr($atom_data, $offset, 4)).'<br>';
1953 $record_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4)); $offset += 4;
1954 $data_size_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2;
1955 $data_size = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2;
1956 switch ($data_size_type) {
1957 case 0x0001: // 0x0001 = flag (size field *= 1-byte)
1958 $data = getid3_lib::BigEndian2Int(substr($atom_data, $offset, $data_size * 1));
1959 $offset += ($data_size * 1);
1961 case 0x0002: // 0x0002 = char (size field *= 1-byte)
1962 $data = substr($atom_data, $offset, $data_size * 1);
1963 $offset += ($data_size * 1);
1964 $data = rtrim($data, "\x00");
1966 case 0x0003: // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB
1968 for ($i = $data_size - 1; $i >= 0; $i--) {
1969 $data .= substr($atom_data, $offset + ($i * 2), 2);
1971 $data = getid3_lib::BigEndian2Int($data);
1972 $offset += ($data_size * 2);
1974 case 0x0004: // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD
1976 for ($i = $data_size - 1; $i >= 0; $i--) {
1977 $data .= substr($atom_data, $offset + ($i * 4), 4);
1979 $data = getid3_lib::BigEndian2Int($data);
1980 $offset += ($data_size * 4);
1982 case 0x0005: // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together
1984 for ($i = 0; $i < $data_size; $i++) {
1985 $numerator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 0, 4));
1986 $denomninator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 4, 4));
1987 if ($denomninator == 0) {
1990 $data[$i] = (double) $numerator / $denomninator;
1993 $offset += (8 * $data_size);
1994 if (count($data) == 1) {
1998 case 0x0007: // 0x0007 = bytes (size field *= 1-byte), values are stored as ??????
1999 $data = substr($atom_data, $offset, $data_size * 1);
2000 $offset += ($data_size * 1);
2002 case 0x0008: // 0x0008 = ????? (size field *= 2-byte), values are stored as ??????
2003 $data = substr($atom_data, $offset, $data_size * 2);
2004 $offset += ($data_size * 2);
2007 echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br>';
2011 switch ($record_type) {
2012 case 0x00000011: // CreateDate
2013 case 0x00000012: // DateTimeOriginal
2014 $data = strtotime($data);
2016 case 0x0200001e: // ColorSpace
2022 $data = 'Adobe RGB';
2026 case 0x02000023: // PictureControlData
2027 $PictureControlAdjust = array(0=>'default', 1=>'quick', 2=>'full');
2028 $FilterEffect = array(0x80=>'off', 0x81=>'yellow', 0x82=>'orange', 0x83=>'red', 0x84=>'green', 0xff=>'n/a');
2029 $ToningEffect = array(0x80=>'b&w', 0x81=>'sepia', 0x82=>'cyanotype', 0x83=>'red', 0x84=>'yellow', 0x85=>'green', 0x86=>'blue-green', 0x87=>'blue', 0x88=>'purple-blue', 0x89=>'red-purple', 0xff=>'n/a');
2031 'PictureControlVersion' => substr($data, 0, 4),
2032 'PictureControlName' => rtrim(substr($data, 4, 20), "\x00"),
2033 'PictureControlBase' => rtrim(substr($data, 24, 20), "\x00"),
2034 //'?' => substr($data, 44, 4),
2035 'PictureControlAdjust' => $PictureControlAdjust[ord(substr($data, 48, 1))],
2036 'PictureControlQuickAdjust' => ord(substr($data, 49, 1)),
2037 'Sharpness' => ord(substr($data, 50, 1)),
2038 'Contrast' => ord(substr($data, 51, 1)),
2039 'Brightness' => ord(substr($data, 52, 1)),
2040 'Saturation' => ord(substr($data, 53, 1)),
2041 'HueAdjustment' => ord(substr($data, 54, 1)),
2042 'FilterEffect' => $FilterEffect[ord(substr($data, 55, 1))],
2043 'ToningEffect' => $ToningEffect[ord(substr($data, 56, 1))],
2044 'ToningSaturation' => ord(substr($data, 57, 1)),
2047 case 0x02000024: // WorldTime
2048 // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#WorldTime
2049 // timezone is stored as offset from GMT in minutes
2050 $timezone = getid3_lib::BigEndian2Int(substr($data, 0, 2));
2051 if ($timezone & 0x8000) {
2052 $timezone = 0 - (0x10000 - $timezone);
2056 $dst = (bool) getid3_lib::BigEndian2Int(substr($data, 2, 1));
2057 switch (getid3_lib::BigEndian2Int(substr($data, 3, 1))) {
2059 $datedisplayformat = 'D/M/Y'; break;
2061 $datedisplayformat = 'M/D/Y'; break;
2064 $datedisplayformat = 'Y/M/D'; break;
2067 $data = array('timezone'=>floatval($timezone), 'dst'=>$dst, 'display'=>$datedisplayformat);
2069 case 0x02000083: // LensType
2072 'mf' => (bool) ($data & 0x01),
2073 'd' => (bool) ($data & 0x02),
2074 'g' => (bool) ($data & 0x04),
2075 'vr' => (bool) ($data & 0x08),
2079 $tag_name = (isset($NCTGtagName[$record_type]) ? $NCTGtagName[$record_type] : '0x'.str_pad(dechex($record_type), 8, '0', STR_PAD_LEFT));
2080 $parsed[$tag_name] = $data;
2086 public function CopyToAppropriateCommentsSection($keyname, $data, $boxname='') {
2087 static $handyatomtranslatorarray = array();
2088 if (empty($handyatomtranslatorarray)) {
2089 $handyatomtranslatorarray['©cpy'] = 'copyright';
2090 $handyatomtranslatorarray['©day'] = 'creation_date'; // iTunes 4.0
2091 $handyatomtranslatorarray['©dir'] = 'director';
2092 $handyatomtranslatorarray['©ed1'] = 'edit1';
2093 $handyatomtranslatorarray['©ed2'] = 'edit2';
2094 $handyatomtranslatorarray['©ed3'] = 'edit3';
2095 $handyatomtranslatorarray['©ed4'] = 'edit4';
2096 $handyatomtranslatorarray['©ed5'] = 'edit5';
2097 $handyatomtranslatorarray['©ed6'] = 'edit6';
2098 $handyatomtranslatorarray['©ed7'] = 'edit7';
2099 $handyatomtranslatorarray['©ed8'] = 'edit8';
2100 $handyatomtranslatorarray['©ed9'] = 'edit9';
2101 $handyatomtranslatorarray['©fmt'] = 'format';
2102 $handyatomtranslatorarray['©inf'] = 'information';
2103 $handyatomtranslatorarray['©prd'] = 'producer';
2104 $handyatomtranslatorarray['©prf'] = 'performers';
2105 $handyatomtranslatorarray['©req'] = 'system_requirements';
2106 $handyatomtranslatorarray['©src'] = 'source_credit';
2107 $handyatomtranslatorarray['©wrt'] = 'writer';
2109 // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt
2110 $handyatomtranslatorarray['©nam'] = 'title'; // iTunes 4.0
2111 $handyatomtranslatorarray['©cmt'] = 'comment'; // iTunes 4.0
2112 $handyatomtranslatorarray['©wrn'] = 'warning';
2113 $handyatomtranslatorarray['©hst'] = 'host_computer';
2114 $handyatomtranslatorarray['©mak'] = 'make';
2115 $handyatomtranslatorarray['©mod'] = 'model';
2116 $handyatomtranslatorarray['©PRD'] = 'product';
2117 $handyatomtranslatorarray['©swr'] = 'software';
2118 $handyatomtranslatorarray['©aut'] = 'author';
2119 $handyatomtranslatorarray['©ART'] = 'artist';
2120 $handyatomtranslatorarray['©trk'] = 'track';
2121 $handyatomtranslatorarray['©alb'] = 'album'; // iTunes 4.0
2122 $handyatomtranslatorarray['©com'] = 'comment';
2123 $handyatomtranslatorarray['©gen'] = 'genre'; // iTunes 4.0
2124 $handyatomtranslatorarray['©ope'] = 'composer';
2125 $handyatomtranslatorarray['©url'] = 'url';
2126 $handyatomtranslatorarray['©enc'] = 'encoder';
2128 // http://atomicparsley.sourceforge.net/mpeg-4files.html
2129 $handyatomtranslatorarray['©art'] = 'artist'; // iTunes 4.0
2130 $handyatomtranslatorarray['aART'] = 'album_artist';
2131 $handyatomtranslatorarray['trkn'] = 'track_number'; // iTunes 4.0
2132 $handyatomtranslatorarray['disk'] = 'disc_number'; // iTunes 4.0
2133 $handyatomtranslatorarray['gnre'] = 'genre'; // iTunes 4.0
2134 $handyatomtranslatorarray['©too'] = 'encoder'; // iTunes 4.0
2135 $handyatomtranslatorarray['tmpo'] = 'bpm'; // iTunes 4.0
2136 $handyatomtranslatorarray['cprt'] = 'copyright'; // iTunes 4.0?
2137 $handyatomtranslatorarray['cpil'] = 'compilation'; // iTunes 4.0
2138 $handyatomtranslatorarray['covr'] = 'picture'; // iTunes 4.0
2139 $handyatomtranslatorarray['rtng'] = 'rating'; // iTunes 4.0
2140 $handyatomtranslatorarray['©grp'] = 'grouping'; // iTunes 4.2
2141 $handyatomtranslatorarray['stik'] = 'stik'; // iTunes 4.9
2142 $handyatomtranslatorarray['pcst'] = 'podcast'; // iTunes 4.9
2143 $handyatomtranslatorarray['catg'] = 'category'; // iTunes 4.9
2144 $handyatomtranslatorarray['keyw'] = 'keyword'; // iTunes 4.9
2145 $handyatomtranslatorarray['purl'] = 'podcast_url'; // iTunes 4.9
2146 $handyatomtranslatorarray['egid'] = 'episode_guid'; // iTunes 4.9
2147 $handyatomtranslatorarray['desc'] = 'description'; // iTunes 5.0
2148 $handyatomtranslatorarray['©lyr'] = 'lyrics'; // iTunes 5.0
2149 $handyatomtranslatorarray['tvnn'] = 'tv_network_name'; // iTunes 6.0
2150 $handyatomtranslatorarray['tvsh'] = 'tv_show_name'; // iTunes 6.0
2151 $handyatomtranslatorarray['tvsn'] = 'tv_season'; // iTunes 6.0
2152 $handyatomtranslatorarray['tves'] = 'tv_episode'; // iTunes 6.0
2153 $handyatomtranslatorarray['purd'] = 'purchase_date'; // iTunes 6.0.2
2154 $handyatomtranslatorarray['pgap'] = 'gapless_playback'; // iTunes 7.0
2156 // http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt
2162 $handyatomtranslatorarray['iTunSMPB'] = 'iTunSMPB';
2163 $handyatomtranslatorarray['iTunNORM'] = 'iTunNORM';
2164 $handyatomtranslatorarray['Encoding Params'] = 'Encoding Params';
2165 $handyatomtranslatorarray['replaygain_track_gain'] = 'replaygain_track_gain';
2166 $handyatomtranslatorarray['replaygain_track_peak'] = 'replaygain_track_peak';
2167 $handyatomtranslatorarray['replaygain_track_minmax'] = 'replaygain_track_minmax';
2168 $handyatomtranslatorarray['MusicIP PUID'] = 'MusicIP PUID';
2169 $handyatomtranslatorarray['MusicBrainz Artist Id'] = 'MusicBrainz Artist Id';
2170 $handyatomtranslatorarray['MusicBrainz Album Id'] = 'MusicBrainz Album Id';
2171 $handyatomtranslatorarray['MusicBrainz Album Artist Id'] = 'MusicBrainz Album Artist Id';
2172 $handyatomtranslatorarray['MusicBrainz Track Id'] = 'MusicBrainz Track Id';
2173 $handyatomtranslatorarray['MusicBrainz Disc Id'] = 'MusicBrainz Disc Id';
2175 // http://age.hobba.nl/audio/tag_frame_reference.html
2176 $handyatomtranslatorarray['PLAY_COUNTER'] = 'play_counter'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355
2177 $handyatomtranslatorarray['MEDIATYPE'] = 'mediatype'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355
2180 $info = &$this->getid3->info;
2182 if ($boxname && ($boxname != $keyname)) {
2183 $comment_key = (isset($handyatomtranslatorarray[$boxname]) ? $handyatomtranslatorarray[$boxname] : $boxname);
2184 } elseif (isset($handyatomtranslatorarray[$keyname])) {
2185 $comment_key = $handyatomtranslatorarray[$keyname];
2188 if ($comment_key == 'picture') {
2189 if (!is_array($data)) {
2191 if (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $data)) {
2192 $image_mime = 'image/png';
2193 } elseif (preg_match('#^\xFF\xD8\xFF#', $data)) {
2194 $image_mime = 'image/jpeg';
2195 } elseif (preg_match('#^GIF#', $data)) {
2196 $image_mime = 'image/gif';
2197 } elseif (preg_match('#^BM#', $data)) {
2198 $image_mime = 'image/bmp';
2200 $data = array('data'=>$data, 'image_mime'=>$image_mime);
2203 $info['quicktime']['comments'][$comment_key][] = $data;
2208 public function NoNullString($nullterminatedstring) {
2209 // remove the single null terminator on null terminated strings
2210 if (substr($nullterminatedstring, strlen($nullterminatedstring) - 1, 1) === "\x00") {
2211 return substr($nullterminatedstring, 0, strlen($nullterminatedstring) - 1);
2213 return $nullterminatedstring;
2216 public function Pascal2String($pascalstring) {
2217 // Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string
2218 return substr($pascalstring, 1);