| Conditions | 438 | 
| Paths | 793 | 
| Total Lines | 1802 | 
| Lines | 271 | 
| Ratio | 15.04 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 229 | 	public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) { | 
            ||
| 230 | // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm  | 
            ||
| 231 | // https://code.google.com/p/mp4v2/wiki/iTunesMetadata  | 
            ||
| 232 | |||
| 233 | $info = &$this->getid3->info;  | 
            ||
| 234 | |||
| 235 | $atom_parent = end($atomHierarchy); // not array_pop($atomHierarchy); see https://www.getid3.org/phpBB3/viewtopic.php?t=1717  | 
            ||
| 236 | array_push($atomHierarchy, $atomname);  | 
            ||
| 237 | $atom_structure = array();  | 
            ||
| 238 | 		$atom_structure['hierarchy'] = implode(' ', $atomHierarchy); | 
            ||
| 239 | $atom_structure['name'] = $atomname;  | 
            ||
| 240 | $atom_structure['size'] = $atomsize;  | 
            ||
| 241 | $atom_structure['offset'] = $baseoffset;  | 
            ||
| 242 | 		if (substr($atomname, 0, 3) == "\x00\x00\x00") { | 
            ||
| 243 | // https://github.com/JamesHeinrich/getID3/issues/139  | 
            ||
| 244 | $atomname = getid3_lib::BigEndian2Int($atomname);  | 
            ||
| 245 | $atom_structure['name'] = $atomname;  | 
            ||
| 246 | $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);  | 
            ||
| 247 | 		} else { | 
            ||
| 248 | 			switch ($atomname) { | 
            ||
| 249 | case 'moov': // MOVie container atom  | 
            ||
| 250 | case 'trak': // TRAcK container atom  | 
            ||
| 251 | case 'clip': // CLIPping container atom  | 
            ||
| 252 | case 'matt': // track MATTe container atom  | 
            ||
| 253 | case 'edts': // EDiTS container atom  | 
            ||
| 254 | case 'tref': // Track REFerence container atom  | 
            ||
| 255 | case 'mdia': // MeDIA container atom  | 
            ||
| 256 | case 'minf': // Media INFormation container atom  | 
            ||
| 257 | case 'dinf': // Data INFormation container atom  | 
            ||
| 258 | case 'nmhd': // Null Media HeaDer container atom  | 
            ||
| 259 | case 'udta': // User DaTA container atom  | 
            ||
| 260 | case 'cmov': // Compressed MOVie container atom  | 
            ||
| 261 | case 'rmra': // Reference Movie Record Atom  | 
            ||
| 262 | case 'rmda': // Reference Movie Descriptor Atom  | 
            ||
| 263 | case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR)  | 
            ||
| 264 | $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);  | 
            ||
| 265 | break;  | 
            ||
| 266 | |||
| 267 | case 'ilst': // Item LiST container atom  | 
            ||
| 268 | 					if ($atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms)) { | 
            ||
| 269 | // some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted  | 
            ||
| 270 | $allnumericnames = true;  | 
            ||
| 271 | 						foreach ($atom_structure['subatoms'] as $subatomarray) { | 
            ||
| 272 | 							if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) { | 
            ||
| 273 | $allnumericnames = false;  | 
            ||
| 274 | break;  | 
            ||
| 275 | }  | 
            ||
| 276 | }  | 
            ||
| 277 | 						if ($allnumericnames) { | 
            ||
| 278 | $newData = array();  | 
            ||
| 279 | 							foreach ($atom_structure['subatoms'] as $subatomarray) { | 
            ||
| 280 | 								foreach ($subatomarray['subatoms'] as $newData_subatomarray) { | 
            ||
| 281 | unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']);  | 
            ||
| 282 | $newData[$subatomarray['name']] = $newData_subatomarray;  | 
            ||
| 283 | break;  | 
            ||
| 284 | }  | 
            ||
| 285 | }  | 
            ||
| 286 | $atom_structure['data'] = $newData;  | 
            ||
| 287 | unset($atom_structure['subatoms']);  | 
            ||
| 288 | }  | 
            ||
| 289 | }  | 
            ||
| 290 | break;  | 
            ||
| 291 | |||
| 292 | case 'stbl': // Sample TaBLe container atom  | 
            ||
| 293 | $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);  | 
            ||
| 294 | $isVideo = false;  | 
            ||
| 295 | $framerate = 0;  | 
            ||
| 296 | $framecount = 0;  | 
            ||
| 297 | 					foreach ($atom_structure['subatoms'] as $key => $value_array) { | 
            ||
| 298 | 						if (isset($value_array['sample_description_table'])) { | 
            ||
| 299 | 							foreach ($value_array['sample_description_table'] as $key2 => $value_array2) { | 
            ||
| 300 | 								if (isset($value_array2['data_format'])) { | 
            ||
| 301 | 									switch ($value_array2['data_format']) { | 
            ||
| 302 | case 'avc1':  | 
            ||
| 303 | case 'mp4v':  | 
            ||
| 304 | // video data  | 
            ||
| 305 | $isVideo = true;  | 
            ||
| 306 | break;  | 
            ||
| 307 | case 'mp4a':  | 
            ||
| 308 | // audio data  | 
            ||
| 309 | break;  | 
            ||
| 310 | }  | 
            ||
| 311 | }  | 
            ||
| 312 | }  | 
            ||
| 313 | 						} elseif (isset($value_array['time_to_sample_table'])) { | 
            ||
| 314 | 							foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) { | 
            ||
| 315 | 								if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0)) { | 
            ||
| 316 | $framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3);  | 
            ||
| 317 | $framecount = $value_array2['sample_count'];  | 
            ||
| 318 | }  | 
            ||
| 319 | }  | 
            ||
| 320 | }  | 
            ||
| 321 | }  | 
            ||
| 322 | 					if ($isVideo && $framerate) { | 
            ||
| 323 | $info['quicktime']['video']['frame_rate'] = $framerate;  | 
            ||
| 324 | $info['video']['frame_rate'] = $info['quicktime']['video']['frame_rate'];  | 
            ||
| 325 | }  | 
            ||
| 326 | 					if ($isVideo && $framecount) { | 
            ||
| 327 | $info['quicktime']['video']['frame_count'] = $framecount;  | 
            ||
| 328 | }  | 
            ||
| 329 | break;  | 
            ||
| 330 | |||
| 331 | |||
| 332 | case "\xA9".'alb': // ALBum  | 
            ||
| 333 | case "\xA9".'ART': //  | 
            ||
| 334 | case "\xA9".'art': // ARTist  | 
            ||
| 335 | case "\xA9".'aut': //  | 
            ||
| 336 | case "\xA9".'cmt': // CoMmenT  | 
            ||
| 337 | case "\xA9".'com': // COMposer  | 
            ||
| 338 | case "\xA9".'cpy': //  | 
            ||
| 339 | case "\xA9".'day': // content created year  | 
            ||
| 340 | case "\xA9".'dir': //  | 
            ||
| 341 | case "\xA9".'ed1': //  | 
            ||
| 342 | case "\xA9".'ed2': //  | 
            ||
| 343 | case "\xA9".'ed3': //  | 
            ||
| 344 | case "\xA9".'ed4': //  | 
            ||
| 345 | case "\xA9".'ed5': //  | 
            ||
| 346 | case "\xA9".'ed6': //  | 
            ||
| 347 | case "\xA9".'ed7': //  | 
            ||
| 348 | case "\xA9".'ed8': //  | 
            ||
| 349 | case "\xA9".'ed9': //  | 
            ||
| 350 | case "\xA9".'enc': //  | 
            ||
| 351 | case "\xA9".'fmt': //  | 
            ||
| 352 | case "\xA9".'gen': // GENre  | 
            ||
| 353 | case "\xA9".'grp': // GRouPing  | 
            ||
| 354 | case "\xA9".'hst': //  | 
            ||
| 355 | case "\xA9".'inf': //  | 
            ||
| 356 | case "\xA9".'lyr': // LYRics  | 
            ||
| 357 | case "\xA9".'mak': //  | 
            ||
| 358 | case "\xA9".'mod': //  | 
            ||
| 359 | case "\xA9".'nam': // full NAMe  | 
            ||
| 360 | case "\xA9".'ope': //  | 
            ||
| 361 | case "\xA9".'PRD': //  | 
            ||
| 362 | case "\xA9".'prf': //  | 
            ||
| 363 | case "\xA9".'req': //  | 
            ||
| 364 | case "\xA9".'src': //  | 
            ||
| 365 | case "\xA9".'swr': //  | 
            ||
| 366 | case "\xA9".'too': // encoder  | 
            ||
| 367 | case "\xA9".'trk': // TRacK  | 
            ||
| 368 | case "\xA9".'url': //  | 
            ||
| 369 | case "\xA9".'wrn': //  | 
            ||
| 370 | case "\xA9".'wrt': // WRiTer  | 
            ||
| 371 | case '----': // itunes specific  | 
            ||
| 372 | case 'aART': // Album ARTist  | 
            ||
| 373 | case 'akID': // iTunes store account type  | 
            ||
| 374 | case 'apID': // Purchase Account  | 
            ||
| 375 | case 'atID': //  | 
            ||
| 376 | case 'catg': // CaTeGory  | 
            ||
| 377 | case 'cmID': //  | 
            ||
| 378 | case 'cnID': //  | 
            ||
| 379 | case 'covr': // COVeR artwork  | 
            ||
| 380 | case 'cpil': // ComPILation  | 
            ||
| 381 | case 'cprt': // CoPyRighT  | 
            ||
| 382 | case 'desc': // DESCription  | 
            ||
| 383 | case 'disk': // DISK number  | 
            ||
| 384 | case 'egid': // Episode Global ID  | 
            ||
| 385 | case 'geID': //  | 
            ||
| 386 | case 'gnre': // GeNRE  | 
            ||
| 387 | case 'hdvd': // HD ViDeo  | 
            ||
| 388 | case 'keyw': // KEYWord  | 
            ||
| 389 | case 'ldes': // Long DEScription  | 
            ||
| 390 | case 'pcst': // PodCaST  | 
            ||
| 391 | case 'pgap': // GAPless Playback  | 
            ||
| 392 | case 'plID': //  | 
            ||
| 393 | case 'purd': // PURchase Date  | 
            ||
| 394 | case 'purl': // Podcast URL  | 
            ||
| 395 | case 'rati': //  | 
            ||
| 396 | case 'rndu': //  | 
            ||
| 397 | case 'rpdu': //  | 
            ||
| 398 | case 'rtng': // RaTiNG  | 
            ||
| 399 | case 'sfID': // iTunes store country  | 
            ||
| 400 | case 'soaa': // SOrt Album Artist  | 
            ||
| 401 | case 'soal': // SOrt ALbum  | 
            ||
| 402 | case 'soar': // SOrt ARtist  | 
            ||
| 403 | case 'soco': // SOrt COmposer  | 
            ||
| 404 | case 'sonm': // SOrt NaMe  | 
            ||
| 405 | case 'sosn': // SOrt Show Name  | 
            ||
| 406 | case 'stik': //  | 
            ||
| 407 | case 'tmpo': // TeMPO (BPM)  | 
            ||
| 408 | case 'trkn': // TRacK Number  | 
            ||
| 409 | case 'tven': // tvEpisodeID  | 
            ||
| 410 | case 'tves': // TV EpiSode  | 
            ||
| 411 | case 'tvnn': // TV Network Name  | 
            ||
| 412 | case 'tvsh': // TV SHow Name  | 
            ||
| 413 | case 'tvsn': // TV SeasoN  | 
            ||
| 414 | 					if ($atom_parent == 'udta') { | 
            ||
| 415 | // User data atom handler  | 
            ||
| 416 | $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));  | 
            ||
| 417 | $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));  | 
            ||
| 418 | $atom_structure['data'] = substr($atom_data, 4);  | 
            ||
| 419 | |||
| 420 | $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);  | 
            ||
| 421 | View Code Duplication | 						if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { | 
            |
| 422 | $info['comments']['language'][] = $atom_structure['language'];  | 
            ||
| 423 | }  | 
            ||
| 424 | 					} else { | 
            ||
| 425 | // Apple item list box atom handler  | 
            ||
| 426 | $atomoffset = 0;  | 
            ||
| 427 | 						if (substr($atom_data, 2, 2) == "\x10\xB5") { | 
            ||
| 428 | // not sure what it means, but observed on iPhone4 data.  | 
            ||
| 429 | // Each $atom_data has 2 bytes of datasize, plus 0x10B5, then data  | 
            ||
| 430 | 							while ($atomoffset < strlen($atom_data)) { | 
            ||
| 431 | $boxsmallsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 2));  | 
            ||
| 432 | $boxsmalltype = substr($atom_data, $atomoffset + 2, 2);  | 
            ||
| 433 | $boxsmalldata = substr($atom_data, $atomoffset + 4, $boxsmallsize);  | 
            ||
| 434 | View Code Duplication | 								if ($boxsmallsize <= 1) { | 
            |
| 435 | 									$this->warning('Invalid QuickTime atom smallbox size "'.$boxsmallsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset)); | 
            ||
| 436 | $atom_structure['data'] = null;  | 
            ||
| 437 | $atomoffset = strlen($atom_data);  | 
            ||
| 438 | break;  | 
            ||
| 439 | }  | 
            ||
| 440 | 								switch ($boxsmalltype) { | 
            ||
| 441 | case "\x10\xB5":  | 
            ||
| 442 | $atom_structure['data'] = $boxsmalldata;  | 
            ||
| 443 | break;  | 
            ||
| 444 | View Code Duplication | default:  | 
            |
| 445 | 										$this->warning('Unknown QuickTime smallbox type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxsmalltype).'" ('.trim(getid3_lib::PrintHexBytes($boxsmalltype)).') at offset '.$baseoffset); | 
            ||
| 446 | $atom_structure['data'] = $atom_data;  | 
            ||
| 447 | break;  | 
            ||
| 448 | }  | 
            ||
| 449 | $atomoffset += (4 + $boxsmallsize);  | 
            ||
| 450 | }  | 
            ||
| 451 | 						} else { | 
            ||
| 452 | 							while ($atomoffset < strlen($atom_data)) { | 
            ||
| 453 | $boxsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 4));  | 
            ||
| 454 | $boxtype = substr($atom_data, $atomoffset + 4, 4);  | 
            ||
| 455 | $boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8);  | 
            ||
| 456 | View Code Duplication | 								if ($boxsize <= 1) { | 
            |
| 457 | 									$this->warning('Invalid QuickTime atom box size "'.$boxsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset)); | 
            ||
| 458 | $atom_structure['data'] = null;  | 
            ||
| 459 | $atomoffset = strlen($atom_data);  | 
            ||
| 460 | break;  | 
            ||
| 461 | }  | 
            ||
| 462 | $atomoffset += $boxsize;  | 
            ||
| 463 | |||
| 464 | 								switch ($boxtype) { | 
            ||
| 465 | case 'mean':  | 
            ||
| 466 | case 'name':  | 
            ||
| 467 | $atom_structure[$boxtype] = substr($boxdata, 4);  | 
            ||
| 468 | break;  | 
            ||
| 469 | |||
| 470 | case 'data':  | 
            ||
| 471 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1));  | 
            ||
| 472 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3));  | 
            ||
| 473 | 										switch ($atom_structure['flags_raw']) { | 
            ||
| 474 | case 0: // data flag  | 
            ||
| 475 | case 21: // tmpo/cpil flag  | 
            ||
| 476 | 												switch ($atomname) { | 
            ||
| 477 | case 'cpil':  | 
            ||
| 478 | case 'hdvd':  | 
            ||
| 479 | case 'pcst':  | 
            ||
| 480 | case 'pgap':  | 
            ||
| 481 | // 8-bit integer (boolean)  | 
            ||
| 482 | $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));  | 
            ||
| 483 | break;  | 
            ||
| 484 | |||
| 485 | case 'tmpo':  | 
            ||
| 486 | // 16-bit integer  | 
            ||
| 487 | $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2));  | 
            ||
| 488 | break;  | 
            ||
| 489 | |||
| 490 | case 'disk':  | 
            ||
| 491 | case 'trkn':  | 
            ||
| 492 | // binary  | 
            ||
| 493 | $num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2));  | 
            ||
| 494 | $num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2));  | 
            ||
| 495 | $atom_structure['data'] = empty($num) ? '' : $num;  | 
            ||
| 496 | $atom_structure['data'] .= empty($num_total) ? '' : '/'.$num_total;  | 
            ||
| 497 | break;  | 
            ||
| 498 | |||
| 499 | case 'gnre':  | 
            ||
| 500 | // enum  | 
            ||
| 501 | $GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));  | 
            ||
| 502 | $atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1);  | 
            ||
| 503 | break;  | 
            ||
| 504 | |||
| 505 | View Code Duplication | case 'rtng':  | 
            |
| 506 | // 8-bit integer  | 
            ||
| 507 | $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));  | 
            ||
| 508 | $atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]);  | 
            ||
| 509 | break;  | 
            ||
| 510 | |||
| 511 | View Code Duplication | case 'stik':  | 
            |
| 512 | // 8-bit integer (enum)  | 
            ||
| 513 | $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));  | 
            ||
| 514 | $atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]);  | 
            ||
| 515 | break;  | 
            ||
| 516 | |||
| 517 | View Code Duplication | case 'sfID':  | 
            |
| 518 | // 32-bit integer  | 
            ||
| 519 | $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));  | 
            ||
| 520 | $atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]);  | 
            ||
| 521 | break;  | 
            ||
| 522 | |||
| 523 | case 'egid':  | 
            ||
| 524 | case 'purl':  | 
            ||
| 525 | $atom_structure['data'] = substr($boxdata, 8);  | 
            ||
| 526 | break;  | 
            ||
| 527 | |||
| 528 | case 'plID':  | 
            ||
| 529 | // 64-bit integer  | 
            ||
| 530 | $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 8));  | 
            ||
| 531 | break;  | 
            ||
| 532 | |||
| 533 | View Code Duplication | case 'covr':  | 
            |
| 534 | $atom_structure['data'] = substr($boxdata, 8);  | 
            ||
| 535 | // not a foolproof check, but better than nothing  | 
            ||
| 536 | 														if (preg_match('#^\\xFF\\xD8\\xFF#', $atom_structure['data'])) { | 
            ||
| 537 | $atom_structure['image_mime'] = 'image/jpeg';  | 
            ||
| 538 | 														} elseif (preg_match('#^\\x89\\x50\\x4E\\x47\\x0D\\x0A\\x1A\\x0A#', $atom_structure['data'])) { | 
            ||
| 539 | $atom_structure['image_mime'] = 'image/png';  | 
            ||
| 540 | 														} elseif (preg_match('#^GIF#', $atom_structure['data'])) { | 
            ||
| 541 | $atom_structure['image_mime'] = 'image/gif';  | 
            ||
| 542 | }  | 
            ||
| 543 | 														$info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_structure['data'], 'description'=>'cover'); | 
            ||
| 544 | break;  | 
            ||
| 545 | |||
| 546 | case 'atID':  | 
            ||
| 547 | case 'cnID':  | 
            ||
| 548 | case 'geID':  | 
            ||
| 549 | case 'tves':  | 
            ||
| 550 | case 'tvsn':  | 
            ||
| 551 | default:  | 
            ||
| 552 | // 32-bit integer  | 
            ||
| 553 | $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));  | 
            ||
| 554 | }  | 
            ||
| 555 | break;  | 
            ||
| 556 | |||
| 557 | case 1: // text flag  | 
            ||
| 558 | case 13: // image flag  | 
            ||
| 559 | View Code Duplication | default:  | 
            |
| 560 | $atom_structure['data'] = substr($boxdata, 8);  | 
            ||
| 561 | 												if ($atomname == 'covr') { | 
            ||
| 562 | // not a foolproof check, but better than nothing  | 
            ||
| 563 | 													if (preg_match('#^\\xFF\\xD8\\xFF#', $atom_structure['data'])) { | 
            ||
| 564 | $atom_structure['image_mime'] = 'image/jpeg';  | 
            ||
| 565 | 													} elseif (preg_match('#^\\x89\\x50\\x4E\\x47\\x0D\\x0A\\x1A\\x0A#', $atom_structure['data'])) { | 
            ||
| 566 | $atom_structure['image_mime'] = 'image/png';  | 
            ||
| 567 | 													} elseif (preg_match('#^GIF#', $atom_structure['data'])) { | 
            ||
| 568 | $atom_structure['image_mime'] = 'image/gif';  | 
            ||
| 569 | }  | 
            ||
| 570 | 													$info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_structure['data'], 'description'=>'cover'); | 
            ||
| 571 | }  | 
            ||
| 572 | break;  | 
            ||
| 573 | |||
| 574 | }  | 
            ||
| 575 | break;  | 
            ||
| 576 | |||
| 577 | View Code Duplication | default:  | 
            |
| 578 | 										$this->warning('Unknown QuickTime box type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxtype).'" ('.trim(getid3_lib::PrintHexBytes($boxtype)).') at offset '.$baseoffset); | 
            ||
| 579 | $atom_structure['data'] = $atom_data;  | 
            ||
| 580 | |||
| 581 | }  | 
            ||
| 582 | }  | 
            ||
| 583 | }  | 
            ||
| 584 | }  | 
            ||
| 585 | $this->CopyToAppropriateCommentsSection($atomname, $atom_structure['data'], $atom_structure['name']);  | 
            ||
| 586 | break;  | 
            ||
| 587 | |||
| 588 | |||
| 589 | case 'play': // auto-PLAY atom  | 
            ||
| 590 | $atom_structure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 591 | |||
| 592 | $info['quicktime']['autoplay'] = $atom_structure['autoplay'];  | 
            ||
| 593 | break;  | 
            ||
| 594 | |||
| 595 | |||
| 596 | View Code Duplication | case 'WLOC': // Window LOCation atom  | 
            |
| 597 | $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));  | 
            ||
| 598 | $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));  | 
            ||
| 599 | break;  | 
            ||
| 600 | |||
| 601 | |||
| 602 | case 'LOOP': // LOOPing atom  | 
            ||
| 603 | case 'SelO': // play SELection Only atom  | 
            ||
| 604 | case 'AllF': // play ALL Frames atom  | 
            ||
| 605 | $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data);  | 
            ||
| 606 | break;  | 
            ||
| 607 | |||
| 608 | |||
| 609 | case 'name': //  | 
            ||
| 610 | case 'MCPS': // Media Cleaner PRo  | 
            ||
| 611 | case '@PRM': // adobe PReMiere version  | 
            ||
| 612 | case '@PRQ': // adobe PRemiere Quicktime version  | 
            ||
| 613 | $atom_structure['data'] = $atom_data;  | 
            ||
| 614 | break;  | 
            ||
| 615 | |||
| 616 | |||
| 617 | case 'cmvd': // Compressed MooV Data atom  | 
            ||
| 618 | // Code by ubergeekØubergeek*tv based on information from  | 
            ||
| 619 | // http://developer.apple.com/quicktime/icefloe/dispatch012.html  | 
            ||
| 620 | $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));  | 
            ||
| 621 | |||
| 622 | $CompressedFileData = substr($atom_data, 4);  | 
            ||
| 623 | 					if ($UncompressedHeader = @gzuncompress($CompressedFileData)) { | 
            ||
| 624 | $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, 0, $atomHierarchy, $ParseAllPossibleAtoms);  | 
            ||
| 625 | 					} else { | 
            ||
| 626 | 						$this->warning('Error decompressing compressed MOV atom at offset '.$atom_structure['offset']); | 
            ||
| 627 | }  | 
            ||
| 628 | break;  | 
            ||
| 629 | |||
| 630 | |||
| 631 | case 'dcom': // Data COMpression atom  | 
            ||
| 632 | $atom_structure['compression_id'] = $atom_data;  | 
            ||
| 633 | $atom_structure['compression_text'] = $this->QuicktimeDCOMLookup($atom_data);  | 
            ||
| 634 | break;  | 
            ||
| 635 | |||
| 636 | |||
| 637 | case 'rdrf': // Reference movie Data ReFerence atom  | 
            ||
| 638 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 639 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));  | 
            ||
| 640 | $atom_structure['flags']['internal_data'] = (bool) ($atom_structure['flags_raw'] & 0x000001);  | 
            ||
| 641 | |||
| 642 | $atom_structure['reference_type_name'] = substr($atom_data, 4, 4);  | 
            ||
| 643 | $atom_structure['reference_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));  | 
            ||
| 644 | 					switch ($atom_structure['reference_type_name']) { | 
            ||
| 645 | case 'url ':  | 
            ||
| 646 | $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12));  | 
            ||
| 647 | break;  | 
            ||
| 648 | |||
| 649 | case 'alis':  | 
            ||
| 650 | $atom_structure['file_alias'] = substr($atom_data, 12);  | 
            ||
| 651 | break;  | 
            ||
| 652 | |||
| 653 | case 'rsrc':  | 
            ||
| 654 | $atom_structure['resource_alias'] = substr($atom_data, 12);  | 
            ||
| 655 | break;  | 
            ||
| 656 | |||
| 657 | default:  | 
            ||
| 658 | $atom_structure['data'] = substr($atom_data, 12);  | 
            ||
| 659 | break;  | 
            ||
| 660 | }  | 
            ||
| 661 | break;  | 
            ||
| 662 | |||
| 663 | |||
| 664 | case 'rmqu': // Reference Movie QUality atom  | 
            ||
| 665 | $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data);  | 
            ||
| 666 | break;  | 
            ||
| 667 | |||
| 668 | |||
| 669 | View Code Duplication | case 'rmcs': // Reference Movie Cpu Speed atom  | 
            |
| 670 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 671 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 672 | $atom_structure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));  | 
            ||
| 673 | break;  | 
            ||
| 674 | |||
| 675 | |||
| 676 | case 'rmvc': // Reference Movie Version Check atom  | 
            ||
| 677 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 678 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 679 | $atom_structure['gestalt_selector'] = substr($atom_data, 4, 4);  | 
            ||
| 680 | $atom_structure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));  | 
            ||
| 681 | $atom_structure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));  | 
            ||
| 682 | $atom_structure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));  | 
            ||
| 683 | break;  | 
            ||
| 684 | |||
| 685 | |||
| 686 | case 'rmcd': // Reference Movie Component check atom  | 
            ||
| 687 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 688 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 689 | $atom_structure['component_type'] = substr($atom_data, 4, 4);  | 
            ||
| 690 | $atom_structure['component_subtype'] = substr($atom_data, 8, 4);  | 
            ||
| 691 | $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);  | 
            ||
| 692 | $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));  | 
            ||
| 693 | $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));  | 
            ||
| 694 | $atom_structure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 4));  | 
            ||
| 695 | break;  | 
            ||
| 696 | |||
| 697 | |||
| 698 | View Code Duplication | case 'rmdr': // Reference Movie Data Rate atom  | 
            |
| 699 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 700 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 701 | $atom_structure['data_rate'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 702 | |||
| 703 | $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10;  | 
            ||
| 704 | break;  | 
            ||
| 705 | |||
| 706 | |||
| 707 | case 'rmla': // Reference Movie Language Atom  | 
            ||
| 708 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 709 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 710 | $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));  | 
            ||
| 711 | |||
| 712 | $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);  | 
            ||
| 713 | View Code Duplication | 					if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { | 
            |
| 714 | $info['comments']['language'][] = $atom_structure['language'];  | 
            ||
| 715 | }  | 
            ||
| 716 | break;  | 
            ||
| 717 | |||
| 718 | |||
| 719 | case 'ptv ': // Print To Video - defines a movie's full screen mode  | 
            ||
| 720 | // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm  | 
            ||
| 721 | $atom_structure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));  | 
            ||
| 722 | $atom_structure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); // hardcoded: 0x0000  | 
            ||
| 723 | $atom_structure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x0000  | 
            ||
| 724 | $atom_structure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 1));  | 
            ||
| 725 | $atom_structure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 7, 1));  | 
            ||
| 726 | |||
| 727 | $atom_structure['flags']['play_on_open'] = (bool) $atom_structure['play_on_open_flag'];  | 
            ||
| 728 | $atom_structure['flags']['slide_show'] = (bool) $atom_structure['slide_show_flag'];  | 
            ||
| 729 | |||
| 730 | $ptv_lookup[0] = 'normal';  | 
            ||
| 731 | $ptv_lookup[1] = 'double';  | 
            ||
| 732 | $ptv_lookup[2] = 'half';  | 
            ||
| 733 | $ptv_lookup[3] = 'full';  | 
            ||
| 734 | $ptv_lookup[4] = 'current';  | 
            ||
| 735 | 					if (isset($ptv_lookup[$atom_structure['display_size_raw']])) { | 
            ||
| 736 | $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']];  | 
            ||
| 737 | 					} else { | 
            ||
| 738 | 						$this->warning('unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')'); | 
            ||
| 739 | }  | 
            ||
| 740 | break;  | 
            ||
| 741 | |||
| 742 | |||
| 743 | case 'stsd': // Sample Table Sample Description atom  | 
            ||
| 744 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 745 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 746 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 747 | |||
| 748 | // see: https://github.com/JamesHeinrich/getID3/issues/111  | 
            ||
| 749 | // Some corrupt files have been known to have high bits set in the number_entries field  | 
            ||
| 750 | // This field shouldn't really need to be 32-bits, values stores are likely in the range 1-100000  | 
            ||
| 751 | // Workaround: mask off the upper byte and throw a warning if it's nonzero  | 
            ||
| 752 | 					if ($atom_structure['number_entries'] > 0x000FFFFF) { | 
            ||
| 753 | 						if ($atom_structure['number_entries'] > 0x00FFFFFF) { | 
            ||
| 754 | 							$this->warning('"stsd" atom contains improbably large number_entries (0x'.getid3_lib::PrintHexBytes(substr($atom_data, 4, 4), true, false).' = '.$atom_structure['number_entries'].'), probably in error. Ignoring upper byte and interpreting this as 0x'.getid3_lib::PrintHexBytes(substr($atom_data, 5, 3), true, false).' = '.($atom_structure['number_entries'] & 0x00FFFFFF)); | 
            ||
| 755 | $atom_structure['number_entries'] = ($atom_structure['number_entries'] & 0x00FFFFFF);  | 
            ||
| 756 | 						} else { | 
            ||
| 757 | 							$this->warning('"stsd" atom contains improbably large number_entries (0x'.getid3_lib::PrintHexBytes(substr($atom_data, 4, 4), true, false).' = '.$atom_structure['number_entries'].'), probably in error. Please report this to [email protected] referencing bug report #111'); | 
            ||
| 758 | }  | 
            ||
| 759 | }  | 
            ||
| 760 | |||
| 761 | $stsdEntriesDataOffset = 8;  | 
            ||
| 762 | 					for ($i = 0; $i < $atom_structure['number_entries']; $i++) { | 
            ||
| 763 | $atom_structure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 4));  | 
            ||
| 764 | $stsdEntriesDataOffset += 4;  | 
            ||
| 765 | $atom_structure['sample_description_table'][$i]['data_format'] = substr($atom_data, $stsdEntriesDataOffset, 4);  | 
            ||
| 766 | $stsdEntriesDataOffset += 4;  | 
            ||
| 767 | $atom_structure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 6));  | 
            ||
| 768 | $stsdEntriesDataOffset += 6;  | 
            ||
| 769 | $atom_structure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 2));  | 
            ||
| 770 | $stsdEntriesDataOffset += 2;  | 
            ||
| 771 | $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));  | 
            ||
| 772 | $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);  | 
            ||
| 773 | |||
| 774 | 						if (substr($atom_structure['sample_description_table'][$i]['data'],  1, 54) == 'application/octet-stream;type=com.parrot.videometadata') { | 
            ||
| 775 | // special handling for apparently-malformed (TextMetaDataSampleEntry?) data for some version of Parrot drones  | 
            ||
| 776 | $atom_structure['sample_description_table'][$i]['parrot_frame_metadata']['mime_type'] = substr($atom_structure['sample_description_table'][$i]['data'], 1, 55);  | 
            ||
| 777 | $atom_structure['sample_description_table'][$i]['parrot_frame_metadata']['metadata_version'] = (int) substr($atom_structure['sample_description_table'][$i]['data'], 55, 1);  | 
            ||
| 778 | unset($atom_structure['sample_description_table'][$i]['data']);  | 
            ||
| 779 | $this->warning('incomplete/incorrect handling of "stsd" with Parrot metadata in this version of getID3() ['.$this->getid3->version().']'); | 
            ||
| 780 | continue;  | 
            ||
| 781 | }  | 
            ||
| 782 | |||
| 783 | $atom_structure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 0, 2));  | 
            ||
| 784 | $atom_structure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 2, 2));  | 
            ||
| 785 | $atom_structure['sample_description_table'][$i]['encoder_vendor'] = substr($atom_structure['sample_description_table'][$i]['data'], 4, 4);  | 
            ||
| 786 | |||
| 787 | 						switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) { | 
            ||
| 788 | |||
| 789 | case "\x00\x00\x00\x00":  | 
            ||
| 790 | // audio tracks  | 
            ||
| 791 | $atom_structure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 2));  | 
            ||
| 792 | $atom_structure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 10, 2));  | 
            ||
| 793 | $atom_structure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 2));  | 
            ||
| 794 | $atom_structure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 14, 2));  | 
            ||
| 795 | $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4));  | 
            ||
| 796 | |||
| 797 | // video tracks  | 
            ||
| 798 | // http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap3/qtff3.html  | 
            ||
| 799 | $atom_structure['sample_description_table'][$i]['temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));  | 
            ||
| 800 | $atom_structure['sample_description_table'][$i]['spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));  | 
            ||
| 801 | $atom_structure['sample_description_table'][$i]['width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));  | 
            ||
| 802 | $atom_structure['sample_description_table'][$i]['height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));  | 
            ||
| 803 | $atom_structure['sample_description_table'][$i]['resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));  | 
            ||
| 804 | $atom_structure['sample_description_table'][$i]['resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));  | 
            ||
| 805 | $atom_structure['sample_description_table'][$i]['data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 4));  | 
            ||
| 806 | $atom_structure['sample_description_table'][$i]['frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 36, 2));  | 
            ||
| 807 | $atom_structure['sample_description_table'][$i]['compressor_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 38, 4);  | 
            ||
| 808 | $atom_structure['sample_description_table'][$i]['pixel_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 42, 2));  | 
            ||
| 809 | $atom_structure['sample_description_table'][$i]['color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 44, 2));  | 
            ||
| 810 | |||
| 811 | 								switch ($atom_structure['sample_description_table'][$i]['data_format']) { | 
            ||
| 812 | case '2vuY':  | 
            ||
| 813 | case 'avc1':  | 
            ||
| 814 | case 'cvid':  | 
            ||
| 815 | case 'dvc ':  | 
            ||
| 816 | case 'dvcp':  | 
            ||
| 817 | case 'gif ':  | 
            ||
| 818 | case 'h263':  | 
            ||
| 819 | case 'jpeg':  | 
            ||
| 820 | case 'kpcd':  | 
            ||
| 821 | case 'mjpa':  | 
            ||
| 822 | case 'mjpb':  | 
            ||
| 823 | case 'mp4v':  | 
            ||
| 824 | case 'png ':  | 
            ||
| 825 | case 'raw ':  | 
            ||
| 826 | case 'rle ':  | 
            ||
| 827 | case 'rpza':  | 
            ||
| 828 | case 'smc ':  | 
            ||
| 829 | case 'SVQ1':  | 
            ||
| 830 | case 'SVQ3':  | 
            ||
| 831 | case 'tiff':  | 
            ||
| 832 | case 'v210':  | 
            ||
| 833 | case 'v216':  | 
            ||
| 834 | case 'v308':  | 
            ||
| 835 | case 'v408':  | 
            ||
| 836 | case 'v410':  | 
            ||
| 837 | case 'yuv2':  | 
            ||
| 838 | $info['fileformat'] = 'mp4';  | 
            ||
| 839 | $info['video']['fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];  | 
            ||
| 840 | 										if ($this->QuicktimeVideoCodecLookup($info['video']['fourcc'])) { | 
            ||
| 841 | $info['video']['fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($info['video']['fourcc']);  | 
            ||
| 842 | }  | 
            ||
| 843 | |||
| 844 | // https://www.getid3.org/phpBB3/viewtopic.php?t=1550  | 
            ||
| 845 | 										//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 | 
            ||
| 846 | 										if (!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($atom_structure['sample_description_table'][$i]['height'])) { | 
            ||
| 847 | // assume that values stored here are more important than values stored in [tkhd] atom  | 
            ||
| 848 | $info['video']['resolution_x'] = $atom_structure['sample_description_table'][$i]['width'];  | 
            ||
| 849 | $info['video']['resolution_y'] = $atom_structure['sample_description_table'][$i]['height'];  | 
            ||
| 850 | $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];  | 
            ||
| 851 | $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];  | 
            ||
| 852 | }  | 
            ||
| 853 | break;  | 
            ||
| 854 | |||
| 855 | case 'qtvr':  | 
            ||
| 856 | $info['video']['dataformat'] = 'quicktimevr';  | 
            ||
| 857 | break;  | 
            ||
| 858 | |||
| 859 | case 'mp4a':  | 
            ||
| 860 | default:  | 
            ||
| 861 | $info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);  | 
            ||
| 862 | $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate'];  | 
            ||
| 863 | $info['quicktime']['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels'];  | 
            ||
| 864 | $info['quicktime']['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth'];  | 
            ||
| 865 | $info['audio']['codec'] = $info['quicktime']['audio']['codec'];  | 
            ||
| 866 | $info['audio']['sample_rate'] = $info['quicktime']['audio']['sample_rate'];  | 
            ||
| 867 | $info['audio']['channels'] = $info['quicktime']['audio']['channels'];  | 
            ||
| 868 | $info['audio']['bits_per_sample'] = $info['quicktime']['audio']['bit_depth'];  | 
            ||
| 869 | 										switch ($atom_structure['sample_description_table'][$i]['data_format']) { | 
            ||
| 870 | case 'raw ': // PCM  | 
            ||
| 871 | case 'alac': // Apple Lossless Audio Codec  | 
            ||
| 872 | case 'sowt': // signed/two's complement (Little Endian)  | 
            ||
| 873 | case 'twos': // signed/two's complement (Big Endian)  | 
            ||
| 874 | case 'in24': // 24-bit Integer  | 
            ||
| 875 | case 'in32': // 32-bit Integer  | 
            ||
| 876 | case 'fl32': // 32-bit Floating Point  | 
            ||
| 877 | case 'fl64': // 64-bit Floating Point  | 
            ||
| 878 | $info['audio']['lossless'] = $info['quicktime']['audio']['lossless'] = true;  | 
            ||
| 879 | $info['audio']['bitrate'] = $info['quicktime']['audio']['bitrate'] = $info['audio']['channels'] * $info['audio']['bits_per_sample'] * $info['audio']['sample_rate'];  | 
            ||
| 880 | break;  | 
            ||
| 881 | default:  | 
            ||
| 882 | $info['audio']['lossless'] = false;  | 
            ||
| 883 | break;  | 
            ||
| 884 | }  | 
            ||
| 885 | break;  | 
            ||
| 886 | }  | 
            ||
| 887 | break;  | 
            ||
| 888 | |||
| 889 | default:  | 
            ||
| 890 | 								switch ($atom_structure['sample_description_table'][$i]['data_format']) { | 
            ||
| 891 | case 'mp4s':  | 
            ||
| 892 | $info['fileformat'] = 'mp4';  | 
            ||
| 893 | break;  | 
            ||
| 894 | |||
| 895 | default:  | 
            ||
| 896 | // video atom  | 
            ||
| 897 | $atom_structure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));  | 
            ||
| 898 | $atom_structure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));  | 
            ||
| 899 | $atom_structure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));  | 
            ||
| 900 | $atom_structure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));  | 
            ||
| 901 | $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4));  | 
            ||
| 902 | $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));  | 
            ||
| 903 | $atom_structure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));  | 
            ||
| 904 | $atom_structure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 2));  | 
            ||
| 905 | $atom_structure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 34, 1));  | 
            ||
| 906 | $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']);  | 
            ||
| 907 | $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2));  | 
            ||
| 908 | $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2));  | 
            ||
| 909 | |||
| 910 | $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color');  | 
            ||
| 911 | $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']);  | 
            ||
| 912 | |||
| 913 | 										if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') { | 
            ||
| 914 | $info['quicktime']['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];  | 
            ||
| 915 | $info['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);  | 
            ||
| 916 | $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']);  | 
            ||
| 917 | $info['quicktime']['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'];  | 
            ||
| 918 | $info['quicktime']['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name'];  | 
            ||
| 919 | |||
| 920 | $info['video']['codec'] = $info['quicktime']['video']['codec'];  | 
            ||
| 921 | $info['video']['bits_per_sample'] = $info['quicktime']['video']['color_depth'];  | 
            ||
| 922 | }  | 
            ||
| 923 | $info['video']['lossless'] = false;  | 
            ||
| 924 | $info['video']['pixel_aspect_ratio'] = (float) 1;  | 
            ||
| 925 | break;  | 
            ||
| 926 | }  | 
            ||
| 927 | break;  | 
            ||
| 928 | }  | 
            ||
| 929 | 						switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) { | 
            ||
| 930 | case 'mp4a':  | 
            ||
| 931 | $info['audio']['dataformat'] = 'mp4';  | 
            ||
| 932 | $info['quicktime']['audio']['codec'] = 'mp4';  | 
            ||
| 933 | break;  | 
            ||
| 934 | |||
| 935 | case '3ivx':  | 
            ||
| 936 | case '3iv1':  | 
            ||
| 937 | case '3iv2':  | 
            ||
| 938 | $info['video']['dataformat'] = '3ivx';  | 
            ||
| 939 | break;  | 
            ||
| 940 | |||
| 941 | case 'xvid':  | 
            ||
| 942 | $info['video']['dataformat'] = 'xvid';  | 
            ||
| 943 | break;  | 
            ||
| 944 | |||
| 945 | case 'mp4v':  | 
            ||
| 946 | $info['video']['dataformat'] = 'mpeg4';  | 
            ||
| 947 | break;  | 
            ||
| 948 | |||
| 949 | case 'divx':  | 
            ||
| 950 | case 'div1':  | 
            ||
| 951 | case 'div2':  | 
            ||
| 952 | case 'div3':  | 
            ||
| 953 | case 'div4':  | 
            ||
| 954 | case 'div5':  | 
            ||
| 955 | case 'div6':  | 
            ||
| 956 | $info['video']['dataformat'] = 'divx';  | 
            ||
| 957 | break;  | 
            ||
| 958 | |||
| 959 | default:  | 
            ||
| 960 | // do nothing  | 
            ||
| 961 | break;  | 
            ||
| 962 | }  | 
            ||
| 963 | unset($atom_structure['sample_description_table'][$i]['data']);  | 
            ||
| 964 | }  | 
            ||
| 965 | break;  | 
            ||
| 966 | |||
| 967 | |||
| 968 | case 'stts': // Sample Table Time-to-Sample atom  | 
            ||
| 969 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 970 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 971 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 972 | $sttsEntriesDataOffset = 8;  | 
            ||
| 973 | //$FrameRateCalculatorArray = array();  | 
            ||
| 974 | $frames_count = 0;  | 
            ||
| 975 | |||
| 976 | $max_stts_entries_to_scan = ($info['php_memory_limit'] ? min(floor($this->getid3->memory_limit / 10000), $atom_structure['number_entries']) : $atom_structure['number_entries']);  | 
            ||
| 977 | 					if ($max_stts_entries_to_scan < $atom_structure['number_entries']) { | 
            ||
| 978 | 						$this->warning('QuickTime atom "stts" has '.$atom_structure['number_entries'].' but only scanning the first '.$max_stts_entries_to_scan.' entries due to limited PHP memory available ('.floor($this->getid3->memory_limit / 1048576).'MB).'); | 
            ||
| 979 | }  | 
            ||
| 980 | View Code Duplication | 					for ($i = 0; $i < $max_stts_entries_to_scan; $i++) { | 
            |
| 981 | $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));  | 
            ||
| 982 | $sttsEntriesDataOffset += 4;  | 
            ||
| 983 | $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));  | 
            ||
| 984 | $sttsEntriesDataOffset += 4;  | 
            ||
| 985 | |||
| 986 | $frames_count += $atom_structure['time_to_sample_table'][$i]['sample_count'];  | 
            ||
| 987 | |||
| 988 | // THIS SECTION REPLACED WITH CODE IN "stbl" ATOM  | 
            ||
| 989 | 						//if (!empty($info['quicktime']['time_scale']) && ($atom_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) { | 
            ||
| 990 | // $stts_new_framerate = $info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'];  | 
            ||
| 991 | 						//	if ($stts_new_framerate <= 60) { | 
            ||
| 992 | // // some atoms have durations of "1" giving a very large framerate, which probably is not right  | 
            ||
| 993 | // $info['video']['frame_rate'] = max($info['video']['frame_rate'], $stts_new_framerate);  | 
            ||
| 994 | // }  | 
            ||
| 995 | //}  | 
            ||
| 996 | //  | 
            ||
| 997 | //$FrameRateCalculatorArray[($info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count'];  | 
            ||
| 998 | }  | 
            ||
| 999 | $info['quicktime']['stts_framecount'][] = $frames_count;  | 
            ||
| 1000 | //$sttsFramesTotal = 0;  | 
            ||
| 1001 | //$sttsSecondsTotal = 0;  | 
            ||
| 1002 | 					//foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) { | 
            ||
| 1003 | 					//	if (($frames_per_second > 60) || ($frames_per_second < 1)) { | 
            ||
| 1004 | // // not video FPS information, probably audio information  | 
            ||
| 1005 | // $sttsFramesTotal = 0;  | 
            ||
| 1006 | // $sttsSecondsTotal = 0;  | 
            ||
| 1007 | // break;  | 
            ||
| 1008 | // }  | 
            ||
| 1009 | // $sttsFramesTotal += $frame_count;  | 
            ||
| 1010 | // $sttsSecondsTotal += $frame_count / $frames_per_second;  | 
            ||
| 1011 | //}  | 
            ||
| 1012 | 					//if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) { | 
            ||
| 1013 | 					//	if (($sttsFramesTotal / $sttsSecondsTotal) > $info['video']['frame_rate']) { | 
            ||
| 1014 | // $info['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal;  | 
            ||
| 1015 | // }  | 
            ||
| 1016 | //}  | 
            ||
| 1017 | break;  | 
            ||
| 1018 | |||
| 1019 | |||
| 1020 | View Code Duplication | case 'stss': // Sample Table Sync Sample (key frames) atom  | 
            |
| 1021 | 					if ($ParseAllPossibleAtoms) { | 
            ||
| 1022 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1023 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1024 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1025 | $stssEntriesDataOffset = 8;  | 
            ||
| 1026 | 						for ($i = 0; $i < $atom_structure['number_entries']; $i++) { | 
            ||
| 1027 | $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stssEntriesDataOffset, 4));  | 
            ||
| 1028 | $stssEntriesDataOffset += 4;  | 
            ||
| 1029 | }  | 
            ||
| 1030 | }  | 
            ||
| 1031 | break;  | 
            ||
| 1032 | |||
| 1033 | |||
| 1034 | case 'stsc': // Sample Table Sample-to-Chunk atom  | 
            ||
| 1035 | 					if ($ParseAllPossibleAtoms) { | 
            ||
| 1036 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1037 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1038 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1039 | $stscEntriesDataOffset = 8;  | 
            ||
| 1040 | View Code Duplication | 						for ($i = 0; $i < $atom_structure['number_entries']; $i++) { | 
            |
| 1041 | $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));  | 
            ||
| 1042 | $stscEntriesDataOffset += 4;  | 
            ||
| 1043 | $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));  | 
            ||
| 1044 | $stscEntriesDataOffset += 4;  | 
            ||
| 1045 | $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));  | 
            ||
| 1046 | $stscEntriesDataOffset += 4;  | 
            ||
| 1047 | }  | 
            ||
| 1048 | }  | 
            ||
| 1049 | break;  | 
            ||
| 1050 | |||
| 1051 | |||
| 1052 | case 'stsz': // Sample Table SiZe atom  | 
            ||
| 1053 | 					if ($ParseAllPossibleAtoms) { | 
            ||
| 1054 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1055 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1056 | $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1057 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));  | 
            ||
| 1058 | $stszEntriesDataOffset = 12;  | 
            ||
| 1059 | 						if ($atom_structure['sample_size'] == 0) { | 
            ||
| 1060 | 							for ($i = 0; $i < $atom_structure['number_entries']; $i++) { | 
            ||
| 1061 | $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stszEntriesDataOffset, 4));  | 
            ||
| 1062 | $stszEntriesDataOffset += 4;  | 
            ||
| 1063 | }  | 
            ||
| 1064 | }  | 
            ||
| 1065 | }  | 
            ||
| 1066 | break;  | 
            ||
| 1067 | |||
| 1068 | |||
| 1069 | View Code Duplication | case 'stco': // Sample Table Chunk Offset atom  | 
            |
| 1070 | //					if (true) { | 
            ||
| 1071 | 					if ($ParseAllPossibleAtoms) { | 
            ||
| 1072 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1073 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1074 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1075 | $stcoEntriesDataOffset = 8;  | 
            ||
| 1076 | 						for ($i = 0; $i < $atom_structure['number_entries']; $i++) { | 
            ||
| 1077 | $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 4));  | 
            ||
| 1078 | $stcoEntriesDataOffset += 4;  | 
            ||
| 1079 | }  | 
            ||
| 1080 | }  | 
            ||
| 1081 | break;  | 
            ||
| 1082 | |||
| 1083 | |||
| 1084 | View Code Duplication | case 'co64': // Chunk Offset 64-bit (version of "stco" that supports > 2GB files)  | 
            |
| 1085 | 					if ($ParseAllPossibleAtoms) { | 
            ||
| 1086 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1087 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1088 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1089 | $stcoEntriesDataOffset = 8;  | 
            ||
| 1090 | 						for ($i = 0; $i < $atom_structure['number_entries']; $i++) { | 
            ||
| 1091 | $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 8));  | 
            ||
| 1092 | $stcoEntriesDataOffset += 8;  | 
            ||
| 1093 | }  | 
            ||
| 1094 | }  | 
            ||
| 1095 | break;  | 
            ||
| 1096 | |||
| 1097 | |||
| 1098 | case 'dref': // Data REFerence atom  | 
            ||
| 1099 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1100 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1101 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1102 | $drefDataOffset = 8;  | 
            ||
| 1103 | 					for ($i = 0; $i < $atom_structure['number_entries']; $i++) { | 
            ||
| 1104 | $atom_structure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 4));  | 
            ||
| 1105 | $drefDataOffset += 4;  | 
            ||
| 1106 | $atom_structure['data_references'][$i]['type'] = substr($atom_data, $drefDataOffset, 4);  | 
            ||
| 1107 | $drefDataOffset += 4;  | 
            ||
| 1108 | $atom_structure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 1));  | 
            ||
| 1109 | $drefDataOffset += 1;  | 
            ||
| 1110 | $atom_structure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 3)); // hardcoded: 0x0000  | 
            ||
| 1111 | $drefDataOffset += 3;  | 
            ||
| 1112 | $atom_structure['data_references'][$i]['data'] = substr($atom_data, $drefDataOffset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));  | 
            ||
| 1113 | $drefDataOffset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);  | 
            ||
| 1114 | |||
| 1115 | $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool) ($atom_structure['data_references'][$i]['flags_raw'] & 0x001);  | 
            ||
| 1116 | }  | 
            ||
| 1117 | break;  | 
            ||
| 1118 | |||
| 1119 | |||
| 1120 | case 'gmin': // base Media INformation atom  | 
            ||
| 1121 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1122 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1123 | $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));  | 
            ||
| 1124 | $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));  | 
            ||
| 1125 | $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));  | 
            ||
| 1126 | $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));  | 
            ||
| 1127 | $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 2));  | 
            ||
| 1128 | $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));  | 
            ||
| 1129 | break;  | 
            ||
| 1130 | |||
| 1131 | |||
| 1132 | View Code Duplication | case 'smhd': // Sound Media information HeaDer atom  | 
            |
| 1133 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1134 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1135 | $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));  | 
            ||
| 1136 | $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));  | 
            ||
| 1137 | break;  | 
            ||
| 1138 | |||
| 1139 | |||
| 1140 | case 'vmhd': // Video Media information HeaDer atom  | 
            ||
| 1141 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1142 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));  | 
            ||
| 1143 | $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));  | 
            ||
| 1144 | $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));  | 
            ||
| 1145 | $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));  | 
            ||
| 1146 | $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));  | 
            ||
| 1147 | |||
| 1148 | $atom_structure['flags']['no_lean_ahead'] = (bool) ($atom_structure['flags_raw'] & 0x001);  | 
            ||
| 1149 | break;  | 
            ||
| 1150 | |||
| 1151 | |||
| 1152 | case 'hdlr': // HanDLeR reference atom  | 
            ||
| 1153 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1154 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1155 | $atom_structure['component_type'] = substr($atom_data, 4, 4);  | 
            ||
| 1156 | $atom_structure['component_subtype'] = substr($atom_data, 8, 4);  | 
            ||
| 1157 | $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);  | 
            ||
| 1158 | $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));  | 
            ||
| 1159 | $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));  | 
            ||
| 1160 | $atom_structure['component_name'] = $this->MaybePascal2String(substr($atom_data, 24));  | 
            ||
| 1161 | |||
| 1162 | 					if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) { | 
            ||
| 1163 | $info['video']['dataformat'] = 'quicktimevr';  | 
            ||
| 1164 | }  | 
            ||
| 1165 | break;  | 
            ||
| 1166 | |||
| 1167 | |||
| 1168 | case 'mdhd': // MeDia HeaDer atom  | 
            ||
| 1169 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1170 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1171 | $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1172 | $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));  | 
            ||
| 1173 | $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));  | 
            ||
| 1174 | $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));  | 
            ||
| 1175 | $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 2));  | 
            ||
| 1176 | $atom_structure['quality'] = getid3_lib::BigEndian2Int(substr($atom_data, 22, 2));  | 
            ||
| 1177 | |||
| 1178 | 					if ($atom_structure['time_scale'] == 0) { | 
            ||
| 1179 | 						$this->error('Corrupt Quicktime file: mdhd.time_scale == zero'); | 
            ||
| 1180 | return false;  | 
            ||
| 1181 | }  | 
            ||
| 1182 | $info['quicktime']['time_scale'] = ((isset($info['quicktime']['time_scale']) && ($info['quicktime']['time_scale'] < 1000)) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);  | 
            ||
| 1183 | |||
| 1184 | $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);  | 
            ||
| 1185 | $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);  | 
            ||
| 1186 | $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];  | 
            ||
| 1187 | $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);  | 
            ||
| 1188 | View Code Duplication | 					if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { | 
            |
| 1189 | $info['comments']['language'][] = $atom_structure['language'];  | 
            ||
| 1190 | }  | 
            ||
| 1191 | $info['quicktime']['timestamps_unix']['create'][$atom_structure['hierarchy']] = $atom_structure['creation_time_unix'];  | 
            ||
| 1192 | $info['quicktime']['timestamps_unix']['modify'][$atom_structure['hierarchy']] = $atom_structure['modify_time_unix'];  | 
            ||
| 1193 | break;  | 
            ||
| 1194 | |||
| 1195 | |||
| 1196 | case 'pnot': // Preview atom  | 
            ||
| 1197 | $atom_structure['modification_date'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // "standard Macintosh format"  | 
            ||
| 1198 | $atom_structure['version_number'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x00  | 
            ||
| 1199 | $atom_structure['atom_type'] = substr($atom_data, 6, 4); // usually: 'PICT'  | 
            ||
| 1200 | $atom_structure['atom_index'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); // usually: 0x01  | 
            ||
| 1201 | |||
| 1202 | $atom_structure['modification_date_unix'] = getid3_lib::DateMac2Unix($atom_structure['modification_date']);  | 
            ||
| 1203 | $info['quicktime']['timestamps_unix']['modify'][$atom_structure['hierarchy']] = $atom_structure['modification_date_unix'];  | 
            ||
| 1204 | break;  | 
            ||
| 1205 | |||
| 1206 | |||
| 1207 | View Code Duplication | case 'crgn': // Clipping ReGioN atom  | 
            |
| 1208 | $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box,  | 
            ||
| 1209 | $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields  | 
            ||
| 1210 | $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region.  | 
            ||
| 1211 | break;  | 
            ||
| 1212 | |||
| 1213 | |||
| 1214 | case 'load': // track LOAD settings atom  | 
            ||
| 1215 | $atom_structure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));  | 
            ||
| 1216 | $atom_structure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1217 | $atom_structure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));  | 
            ||
| 1218 | $atom_structure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));  | 
            ||
| 1219 | |||
| 1220 | $atom_structure['default_hints']['double_buffer'] = (bool) ($atom_structure['default_hints_raw'] & 0x0020);  | 
            ||
| 1221 | $atom_structure['default_hints']['high_quality'] = (bool) ($atom_structure['default_hints_raw'] & 0x0100);  | 
            ||
| 1222 | break;  | 
            ||
| 1223 | |||
| 1224 | |||
| 1225 | case 'tmcd': // TiMe CoDe atom  | 
            ||
| 1226 | case 'chap': // CHAPter list atom  | 
            ||
| 1227 | case 'sync': // SYNChronization atom  | 
            ||
| 1228 | case 'scpt': // tranSCriPT atom  | 
            ||
| 1229 | View Code Duplication | case 'ssrc': // non-primary SouRCe atom  | 
            |
| 1230 | 					for ($i = 0; $i < strlen($atom_data); $i += 4) { | 
            ||
| 1231 | @$atom_structure['track_id'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));  | 
            ||
| 1232 | }  | 
            ||
| 1233 | break;  | 
            ||
| 1234 | |||
| 1235 | |||
| 1236 | case 'elst': // Edit LiST atom  | 
            ||
| 1237 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1238 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1239 | $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1240 | 					for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) { | 
            ||
| 1241 | $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4));  | 
            ||
| 1242 | $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4));  | 
            ||
| 1243 | $atom_structure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4));  | 
            ||
| 1244 | }  | 
            ||
| 1245 | break;  | 
            ||
| 1246 | |||
| 1247 | |||
| 1248 | View Code Duplication | case 'kmat': // compressed MATte atom  | 
            |
| 1249 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1250 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000  | 
            ||
| 1251 | $atom_structure['matte_data_raw'] = substr($atom_data, 4);  | 
            ||
| 1252 | break;  | 
            ||
| 1253 | |||
| 1254 | |||
| 1255 | case 'ctab': // Color TABle atom  | 
            ||
| 1256 | $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000  | 
            ||
| 1257 | $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000  | 
            ||
| 1258 | $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1;  | 
            ||
| 1259 | 					for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) { | 
            ||
| 1260 | $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2));  | 
            ||
| 1261 | $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2));  | 
            ||
| 1262 | $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2));  | 
            ||
| 1263 | $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2));  | 
            ||
| 1264 | }  | 
            ||
| 1265 | break;  | 
            ||
| 1266 | |||
| 1267 | |||
| 1268 | case 'mvhd': // MoVie HeaDer atom  | 
            ||
| 1269 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1270 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));  | 
            ||
| 1271 | $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1272 | $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));  | 
            ||
| 1273 | $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));  | 
            ||
| 1274 | $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));  | 
            ||
| 1275 | $atom_structure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 20, 4));  | 
            ||
| 1276 | $atom_structure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 24, 2));  | 
            ||
| 1277 | $atom_structure['reserved'] = substr($atom_data, 26, 10);  | 
            ||
| 1278 | $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 36, 4));  | 
            ||
| 1279 | $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));  | 
            ||
| 1280 | $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 44, 4));  | 
            ||
| 1281 | $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4));  | 
            ||
| 1282 | $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));  | 
            ||
| 1283 | $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 56, 4));  | 
            ||
| 1284 | $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4));  | 
            ||
| 1285 | $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));  | 
            ||
| 1286 | $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4));  | 
            ||
| 1287 | $atom_structure['preview_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 72, 4));  | 
            ||
| 1288 | $atom_structure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 76, 4));  | 
            ||
| 1289 | $atom_structure['poster_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 80, 4));  | 
            ||
| 1290 | $atom_structure['selection_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 84, 4));  | 
            ||
| 1291 | $atom_structure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 88, 4));  | 
            ||
| 1292 | $atom_structure['current_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 92, 4));  | 
            ||
| 1293 | $atom_structure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 96, 4));  | 
            ||
| 1294 | |||
| 1295 | 					if ($atom_structure['time_scale'] == 0) { | 
            ||
| 1296 | 						$this->error('Corrupt Quicktime file: mvhd.time_scale == zero'); | 
            ||
| 1297 | return false;  | 
            ||
| 1298 | }  | 
            ||
| 1299 | $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);  | 
            ||
| 1300 | $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);  | 
            ||
| 1301 | $info['quicktime']['timestamps_unix']['create'][$atom_structure['hierarchy']] = $atom_structure['creation_time_unix'];  | 
            ||
| 1302 | $info['quicktime']['timestamps_unix']['modify'][$atom_structure['hierarchy']] = $atom_structure['modify_time_unix'];  | 
            ||
| 1303 | $info['quicktime']['time_scale'] = ((isset($info['quicktime']['time_scale']) && ($info['quicktime']['time_scale'] < 1000)) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);  | 
            ||
| 1304 | $info['quicktime']['display_scale'] = $atom_structure['matrix_a'];  | 
            ||
| 1305 | $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];  | 
            ||
| 1306 | break;  | 
            ||
| 1307 | |||
| 1308 | |||
| 1309 | case 'tkhd': // TracK HeaDer atom  | 
            ||
| 1310 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1311 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));  | 
            ||
| 1312 | $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1313 | $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));  | 
            ||
| 1314 | $atom_structure['trackid'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));  | 
            ||
| 1315 | $atom_structure['reserved1'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));  | 
            ||
| 1316 | $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));  | 
            ||
| 1317 | $atom_structure['reserved2'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 8));  | 
            ||
| 1318 | $atom_structure['layer'] = getid3_lib::BigEndian2Int(substr($atom_data, 32, 2));  | 
            ||
| 1319 | $atom_structure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atom_data, 34, 2));  | 
            ||
| 1320 | $atom_structure['volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 36, 2));  | 
            ||
| 1321 | $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2));  | 
            ||
| 1322 | // http://developer.apple.com/library/mac/#documentation/QuickTime/RM/MovieBasics/MTEditing/K-Chapter/11MatrixFunctions.html  | 
            ||
| 1323 | // http://developer.apple.com/library/mac/#documentation/QuickTime/qtff/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-18737  | 
            ||
| 1324 | $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));  | 
            ||
| 1325 | $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 44, 4));  | 
            ||
| 1326 | $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 48, 4));  | 
            ||
| 1327 | $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));  | 
            ||
| 1328 | $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 56, 4));  | 
            ||
| 1329 | $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 60, 4));  | 
            ||
| 1330 | $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));  | 
            ||
| 1331 | $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 68, 4));  | 
            ||
| 1332 | $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 72, 4));  | 
            ||
| 1333 | $atom_structure['width'] = getid3_lib::FixedPoint16_16(substr($atom_data, 76, 4));  | 
            ||
| 1334 | $atom_structure['height'] = getid3_lib::FixedPoint16_16(substr($atom_data, 80, 4));  | 
            ||
| 1335 | $atom_structure['flags']['enabled'] = (bool) ($atom_structure['flags_raw'] & 0x0001);  | 
            ||
| 1336 | $atom_structure['flags']['in_movie'] = (bool) ($atom_structure['flags_raw'] & 0x0002);  | 
            ||
| 1337 | $atom_structure['flags']['in_preview'] = (bool) ($atom_structure['flags_raw'] & 0x0004);  | 
            ||
| 1338 | $atom_structure['flags']['in_poster'] = (bool) ($atom_structure['flags_raw'] & 0x0008);  | 
            ||
| 1339 | $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);  | 
            ||
| 1340 | $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);  | 
            ||
| 1341 | $info['quicktime']['timestamps_unix']['create'][$atom_structure['hierarchy']] = $atom_structure['creation_time_unix'];  | 
            ||
| 1342 | $info['quicktime']['timestamps_unix']['modify'][$atom_structure['hierarchy']] = $atom_structure['modify_time_unix'];  | 
            ||
| 1343 | |||
| 1344 | // https://www.getid3.org/phpBB3/viewtopic.php?t=1908  | 
            ||
| 1345 | // attempt to compute rotation from matrix values  | 
            ||
| 1346 | // 2017-Dec-28: uncertain if 90/270 are correctly oriented; values returned by FixedPoint16_16 should perhaps be -1 instead of 65535(?)  | 
            ||
| 1347 | $matrixRotation = 0;  | 
            ||
| 1348 | 					switch ($atom_structure['matrix_a'].':'.$atom_structure['matrix_b'].':'.$atom_structure['matrix_c'].':'.$atom_structure['matrix_d']) { | 
            ||
| 1349 | case '1:0:0:1': $matrixRotation = 0; break;  | 
            ||
| 1350 | case '0:1:65535:0': $matrixRotation = 90; break;  | 
            ||
| 1351 | case '65535:0:0:65535': $matrixRotation = 180; break;  | 
            ||
| 1352 | case '0:65535:1:0': $matrixRotation = 270; break;  | 
            ||
| 1353 | default: break;  | 
            ||
| 1354 | }  | 
            ||
| 1355 | |||
| 1356 | // https://www.getid3.org/phpBB3/viewtopic.php?t=2468  | 
            ||
| 1357 | // The rotation matrix can appear in the Quicktime file multiple times, at least once for each track,  | 
            ||
| 1358 | // and it's possible that only the video track (or, in theory, one of the video tracks) is flagged as  | 
            ||
| 1359 | // rotated while the other tracks (e.g. audio) is tagged as rotation=0 (behavior noted on iPhone 8 Plus)  | 
            ||
| 1360 | // The correct solution would be to check if the TrackID associated with the rotation matrix is indeed  | 
            ||
| 1361 | // a video track (or the main video track) and only set the rotation then, but since information about  | 
            ||
| 1362 | // what track is what is not trivially there to be examined, the lazy solution is to set the rotation  | 
            ||
| 1363 | // if it is found to be nonzero, on the assumption that tracks that don't need it will have rotation set  | 
            ||
| 1364 | // to zero (and be effectively ignored) and the video track will have rotation set correctly, which will  | 
            ||
| 1365 | // either be zero and automatically correct, or nonzero and be set correctly.  | 
            ||
| 1366 | 					if (!isset($info['video']['rotate']) || (($info['video']['rotate'] == 0) && ($matrixRotation > 0))) { | 
            ||
| 1367 | $info['quicktime']['video']['rotate'] = $info['video']['rotate'] = $matrixRotation;  | 
            ||
| 1368 | }  | 
            ||
| 1369 | |||
| 1370 | 					if ($atom_structure['flags']['enabled'] == 1) { | 
            ||
| 1371 | 						if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) { | 
            ||
| 1372 | $info['video']['resolution_x'] = $atom_structure['width'];  | 
            ||
| 1373 | $info['video']['resolution_y'] = $atom_structure['height'];  | 
            ||
| 1374 | }  | 
            ||
| 1375 | $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']);  | 
            ||
| 1376 | $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']);  | 
            ||
| 1377 | $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];  | 
            ||
| 1378 | $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];  | 
            ||
| 1379 | 					} else { | 
            ||
| 1380 | // see: https://www.getid3.org/phpBB3/viewtopic.php?t=1295  | 
            ||
| 1381 | 						//if (isset($info['video']['resolution_x'])) { unset($info['video']['resolution_x']); } | 
            ||
| 1382 | 						//if (isset($info['video']['resolution_y'])) { unset($info['video']['resolution_y']); } | 
            ||
| 1383 | 						//if (isset($info['quicktime']['video']))    { unset($info['quicktime']['video']);    } | 
            ||
| 1384 | }  | 
            ||
| 1385 | break;  | 
            ||
| 1386 | |||
| 1387 | |||
| 1388 | case 'iods': // Initial Object DeScriptor atom  | 
            ||
| 1389 | // http://www.koders.com/c/fid1FAB3E762903DC482D8A246D4A4BF9F28E049594.aspx?s=windows.h  | 
            ||
| 1390 | // http://libquicktime.sourcearchive.com/documentation/1.0.2plus-pdebian/iods_8c-source.html  | 
            ||
| 1391 | $offset = 0;  | 
            ||
| 1392 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));  | 
            ||
| 1393 | $offset += 1;  | 
            ||
| 1394 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 3));  | 
            ||
| 1395 | $offset += 3;  | 
            ||
| 1396 | $atom_structure['mp4_iod_tag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));  | 
            ||
| 1397 | $offset += 1;  | 
            ||
| 1398 | $atom_structure['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);  | 
            ||
| 1399 | //$offset already adjusted by quicktime_read_mp4_descr_length()  | 
            ||
| 1400 | $atom_structure['object_descriptor_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2));  | 
            ||
| 1401 | $offset += 2;  | 
            ||
| 1402 | $atom_structure['od_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));  | 
            ||
| 1403 | $offset += 1;  | 
            ||
| 1404 | $atom_structure['scene_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));  | 
            ||
| 1405 | $offset += 1;  | 
            ||
| 1406 | $atom_structure['audio_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));  | 
            ||
| 1407 | $offset += 1;  | 
            ||
| 1408 | $atom_structure['video_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));  | 
            ||
| 1409 | $offset += 1;  | 
            ||
| 1410 | $atom_structure['graphics_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));  | 
            ||
| 1411 | $offset += 1;  | 
            ||
| 1412 | |||
| 1413 | $atom_structure['num_iods_tracks'] = ($atom_structure['length'] - 7) / 6; // 6 bytes would only be right if all tracks use 1-byte length fields  | 
            ||
| 1414 | View Code Duplication | 					for ($i = 0; $i < $atom_structure['num_iods_tracks']; $i++) { | 
            |
| 1415 | $atom_structure['track'][$i]['ES_ID_IncTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));  | 
            ||
| 1416 | $offset += 1;  | 
            ||
| 1417 | $atom_structure['track'][$i]['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);  | 
            ||
| 1418 | //$offset already adjusted by quicktime_read_mp4_descr_length()  | 
            ||
| 1419 | $atom_structure['track'][$i]['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4));  | 
            ||
| 1420 | $offset += 4;  | 
            ||
| 1421 | }  | 
            ||
| 1422 | |||
| 1423 | $atom_structure['audio_profile_name'] = $this->QuicktimeIODSaudioProfileName($atom_structure['audio_profile_id']);  | 
            ||
| 1424 | $atom_structure['video_profile_name'] = $this->QuicktimeIODSvideoProfileName($atom_structure['video_profile_id']);  | 
            ||
| 1425 | break;  | 
            ||
| 1426 | |||
| 1427 | View Code Duplication | case 'ftyp': // FileTYPe (?) atom (for MP4 it seems)  | 
            |
| 1428 | $atom_structure['signature'] = substr($atom_data, 0, 4);  | 
            ||
| 1429 | $atom_structure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1430 | $atom_structure['fourcc'] = substr($atom_data, 8, 4);  | 
            ||
| 1431 | break;  | 
            ||
| 1432 | |||
| 1433 | case 'mdat': // Media DATa atom  | 
            ||
| 1434 | // 'mdat' contains the actual data for the audio/video, possibly also subtitles  | 
            ||
| 1435 | |||
| 1436 | /* due to lack of known documentation, this is a kludge implementation. If you know of documentation on how mdat is properly structed, please send it to [email protected] */  | 
            ||
| 1437 | |||
| 1438 | // first, skip any 'wide' padding, and second 'mdat' header (with specified size of zero?)  | 
            ||
| 1439 | $mdat_offset = 0;  | 
            ||
| 1440 | 					while (true) { | 
            ||
| 1441 | 						if (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x08".'wide') { | 
            ||
| 1442 | $mdat_offset += 8;  | 
            ||
| 1443 | 						} elseif (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x00".'mdat') { | 
            ||
| 1444 | $mdat_offset += 8;  | 
            ||
| 1445 | 						} else { | 
            ||
| 1446 | break;  | 
            ||
| 1447 | }  | 
            ||
| 1448 | }  | 
            ||
| 1449 | 					if (substr($atom_data, $mdat_offset, 4) == 'GPRO') { | 
            ||
| 1450 | $GOPRO_chunk_length = getid3_lib::LittleEndian2Int(substr($atom_data, $mdat_offset + 4, 4));  | 
            ||
| 1451 | $GOPRO_offset = 8;  | 
            ||
| 1452 | $atom_structure['GPRO']['raw'] = substr($atom_data, $mdat_offset + 8, $GOPRO_chunk_length - 8);  | 
            ||
| 1453 | $atom_structure['GPRO']['firmware'] = substr($atom_structure['GPRO']['raw'], 0, 15);  | 
            ||
| 1454 | $atom_structure['GPRO']['unknown1'] = substr($atom_structure['GPRO']['raw'], 15, 16);  | 
            ||
| 1455 | $atom_structure['GPRO']['unknown2'] = substr($atom_structure['GPRO']['raw'], 31, 32);  | 
            ||
| 1456 | $atom_structure['GPRO']['unknown3'] = substr($atom_structure['GPRO']['raw'], 63, 16);  | 
            ||
| 1457 | $atom_structure['GPRO']['camera'] = substr($atom_structure['GPRO']['raw'], 79, 32);  | 
            ||
| 1458 | $info['quicktime']['camera']['model'] = rtrim($atom_structure['GPRO']['camera'], "\x00");  | 
            ||
| 1459 | }  | 
            ||
| 1460 | |||
| 1461 | // check to see if it looks like chapter titles, in the form of unterminated strings with a leading 16-bit size field  | 
            ||
| 1462 | while (($mdat_offset < (strlen($atom_data) - 8))  | 
            ||
| 1463 | && ($chapter_string_length = getid3_lib::BigEndian2Int(substr($atom_data, $mdat_offset, 2)))  | 
            ||
| 1464 | && ($chapter_string_length < 1000)  | 
            ||
| 1465 | && ($chapter_string_length <= (strlen($atom_data) - $mdat_offset - 2))  | 
            ||
| 1466 | 						&& preg_match('#^([\x00-\xFF]{2})([\x20-\xFF]+)$#', substr($atom_data, $mdat_offset, $chapter_string_length + 2), $chapter_matches)) { | 
            ||
| 1467 | list($dummy, $chapter_string_length_hex, $chapter_string) = $chapter_matches;  | 
            ||
| 1468 | $mdat_offset += (2 + $chapter_string_length);  | 
            ||
| 1469 | @$info['quicktime']['comments']['chapters'][] = $chapter_string;  | 
            ||
| 1470 | |||
| 1471 | // "encd" atom specifies encoding. In theory could be anything, almost always UTF-8, but may be UTF-16 with BOM (not currently handled)  | 
            ||
| 1472 | 							if (substr($atom_data, $mdat_offset, 12) == "\x00\x00\x00\x0C\x65\x6E\x63\x64\x00\x00\x01\x00") { // UTF-8 | 
            ||
| 1473 | $mdat_offset += 12;  | 
            ||
| 1474 | }  | 
            ||
| 1475 | }  | 
            ||
| 1476 | |||
| 1477 | 					if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) { | 
            ||
| 1478 | |||
| 1479 | $info['avdataoffset'] = $atom_structure['offset'] + 8; // $info['quicktime'][$atomname]['offset'] + 8;  | 
            ||
| 1480 | $OldAVDataEnd = $info['avdataend'];  | 
            ||
| 1481 | $info['avdataend'] = $atom_structure['offset'] + $atom_structure['size']; // $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];  | 
            ||
| 1482 | |||
| 1483 | $getid3_temp = new getID3();  | 
            ||
| 1484 | $getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize'], $this->getid3->fp);  | 
            ||
| 1485 | $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];  | 
            ||
| 1486 | $getid3_temp->info['avdataend'] = $info['avdataend'];  | 
            ||
| 1487 | $getid3_mp3 = new getid3_mp3($getid3_temp);  | 
            ||
| 1488 | 						if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode($this->fread(4)))) { | 
            ||
| 1489 | $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);  | 
            ||
| 1490 | 							if (!empty($getid3_temp->info['warning'])) { | 
            ||
| 1491 | 								foreach ($getid3_temp->info['warning'] as $value) { | 
            ||
| 1492 | $this->warning($value);  | 
            ||
| 1493 | }  | 
            ||
| 1494 | }  | 
            ||
| 1495 | 							if (!empty($getid3_temp->info['mpeg'])) { | 
            ||
| 1496 | $info['mpeg'] = $getid3_temp->info['mpeg'];  | 
            ||
| 1497 | 								if (isset($info['mpeg']['audio'])) { | 
            ||
| 1498 | $info['audio']['dataformat'] = 'mp3';  | 
            ||
| 1499 | $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')));  | 
            ||
| 1500 | $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];  | 
            ||
| 1501 | $info['audio']['channels'] = $info['mpeg']['audio']['channels'];  | 
            ||
| 1502 | $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];  | 
            ||
| 1503 | $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);  | 
            ||
| 1504 | $info['bitrate'] = $info['audio']['bitrate'];  | 
            ||
| 1505 | }  | 
            ||
| 1506 | }  | 
            ||
| 1507 | }  | 
            ||
| 1508 | unset($getid3_mp3, $getid3_temp);  | 
            ||
| 1509 | $info['avdataend'] = $OldAVDataEnd;  | 
            ||
| 1510 | unset($OldAVDataEnd);  | 
            ||
| 1511 | |||
| 1512 | }  | 
            ||
| 1513 | |||
| 1514 | unset($mdat_offset, $chapter_string_length, $chapter_matches);  | 
            ||
| 1515 | break;  | 
            ||
| 1516 | |||
| 1517 | case 'free': // FREE space atom  | 
            ||
| 1518 | case 'skip': // SKIP atom  | 
            ||
| 1519 | case 'wide': // 64-bit expansion placeholder atom  | 
            ||
| 1520 | // 'free', 'skip' and 'wide' are just padding, contains no useful data at all  | 
            ||
| 1521 | |||
| 1522 | // When writing QuickTime files, it is sometimes necessary to update an atom's size.  | 
            ||
| 1523 | // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom  | 
            ||
| 1524 | // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime  | 
            ||
| 1525 | // puts an 8-byte placeholder atom before any atoms it may have to update the size of.  | 
            ||
| 1526 | // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the  | 
            ||
| 1527 | // placeholder atom can be overwritten to obtain the necessary 8 extra bytes.  | 
            ||
| 1528 | // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ).  | 
            ||
| 1529 | break;  | 
            ||
| 1530 | |||
| 1531 | |||
| 1532 | case 'nsav': // NoSAVe atom  | 
            ||
| 1533 | // http://developer.apple.com/technotes/tn/tn2038.html  | 
            ||
| 1534 | $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));  | 
            ||
| 1535 | break;  | 
            ||
| 1536 | |||
| 1537 | case 'ctyp': // Controller TYPe atom (seen on QTVR)  | 
            ||
| 1538 | // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt  | 
            ||
| 1539 | // some controller names are:  | 
            ||
| 1540 | // 0x00 + 'std' for linear movie  | 
            ||
| 1541 | // 'none' for no controls  | 
            ||
| 1542 | $atom_structure['ctyp'] = substr($atom_data, 0, 4);  | 
            ||
| 1543 | $info['quicktime']['controller'] = $atom_structure['ctyp'];  | 
            ||
| 1544 | 					switch ($atom_structure['ctyp']) { | 
            ||
| 1545 | case 'qtvr':  | 
            ||
| 1546 | $info['video']['dataformat'] = 'quicktimevr';  | 
            ||
| 1547 | break;  | 
            ||
| 1548 | }  | 
            ||
| 1549 | break;  | 
            ||
| 1550 | |||
| 1551 | case 'pano': // PANOrama track (seen on QTVR)  | 
            ||
| 1552 | $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));  | 
            ||
| 1553 | break;  | 
            ||
| 1554 | |||
| 1555 | case 'hint': // HINT track  | 
            ||
| 1556 | case 'hinf': //  | 
            ||
| 1557 | case 'hinv': //  | 
            ||
| 1558 | case 'hnti': //  | 
            ||
| 1559 | $info['quicktime']['hinting'] = true;  | 
            ||
| 1560 | break;  | 
            ||
| 1561 | |||
| 1562 | case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR)  | 
            ||
| 1563 | 					for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) { | 
            ||
| 1564 | $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));  | 
            ||
| 1565 | }  | 
            ||
| 1566 | break;  | 
            ||
| 1567 | |||
| 1568 | |||
| 1569 | // Observed-but-not-handled atom types are just listed here to prevent warnings being generated  | 
            ||
| 1570 | case 'FXTC': // Something to do with Adobe After Effects (?)  | 
            ||
| 1571 | case 'PrmA':  | 
            ||
| 1572 | case 'code':  | 
            ||
| 1573 | case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html  | 
            ||
| 1574 | case 'tapt': // TrackApertureModeDimensionsAID - http://developer.apple.com/documentation/QuickTime/Reference/QT7-1_Update_Reference/Constants/Constants.html  | 
            ||
| 1575 | // tapt seems to be used to compute the video size [https://www.getid3.org/phpBB3/viewtopic.php?t=838]  | 
            ||
| 1576 | // * http://lists.apple.com/archives/quicktime-api/2006/Aug/msg00014.html  | 
            ||
| 1577 | // * http://handbrake.fr/irclogs/handbrake-dev/handbrake-dev20080128_pg2.html  | 
            ||
| 1578 | case 'ctts':// STCompositionOffsetAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html  | 
            ||
| 1579 | case 'cslg':// STCompositionShiftLeastGreatestAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html  | 
            ||
| 1580 | case 'sdtp':// STSampleDependencyAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html  | 
            ||
| 1581 | case 'stps':// STPartialSyncSampleAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html  | 
            ||
| 1582 | //$atom_structure['data'] = $atom_data;  | 
            ||
| 1583 | break;  | 
            ||
| 1584 | |||
| 1585 | case "\xA9".'xyz': // GPS latitude+longitude+altitude  | 
            ||
| 1586 | $atom_structure['data'] = $atom_data;  | 
            ||
| 1587 | 					if (preg_match('#([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)?/$#i', $atom_data, $matches)) { | 
            ||
| 1588 | @list($all, $latitude, $longitude, $altitude) = $matches;  | 
            ||
| 1589 | $info['quicktime']['comments']['gps_latitude'][] = floatval($latitude);  | 
            ||
| 1590 | $info['quicktime']['comments']['gps_longitude'][] = floatval($longitude);  | 
            ||
| 1591 | 						if (!empty($altitude)) { | 
            ||
| 1592 | $info['quicktime']['comments']['gps_altitude'][] = floatval($altitude);  | 
            ||
| 1593 | }  | 
            ||
| 1594 | 					} else { | 
            ||
| 1595 | 						$this->warning('QuickTime atom "©xyz" data does not match expected data pattern at offset '.$baseoffset.'. Please report as getID3() bug.'); | 
            ||
| 1596 | }  | 
            ||
| 1597 | break;  | 
            ||
| 1598 | |||
| 1599 | case 'NCDT':  | 
            ||
| 1600 | // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html  | 
            ||
| 1601 | // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100  | 
            ||
| 1602 | $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 4, $atomHierarchy, $ParseAllPossibleAtoms);  | 
            ||
| 1603 | break;  | 
            ||
| 1604 | case 'NCTH': // Nikon Camera THumbnail image  | 
            ||
| 1605 | case 'NCVW': // Nikon Camera preVieW image  | 
            ||
| 1606 | // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html  | 
            ||
| 1607 | 					if (preg_match('/^\xFF\xD8\xFF/', $atom_data)) { | 
            ||
| 1608 | $atom_structure['data'] = $atom_data;  | 
            ||
| 1609 | $atom_structure['image_mime'] = 'image/jpeg';  | 
            ||
| 1610 | $atom_structure['description'] = (($atomname == 'NCTH') ? 'Nikon Camera Thumbnail Image' : (($atomname == 'NCVW') ? 'Nikon Camera Preview Image' : 'Nikon preview image'));  | 
            ||
| 1611 | 						$info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_data, 'description'=>$atom_structure['description']); | 
            ||
| 1612 | }  | 
            ||
| 1613 | break;  | 
            ||
| 1614 | case 'NCTG': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG  | 
            ||
| 1615 | $atom_structure['data'] = $this->QuicktimeParseNikonNCTG($atom_data);  | 
            ||
| 1616 | break;  | 
            ||
| 1617 | case 'NCHD': // Nikon:MakerNoteVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html  | 
            ||
| 1618 | case 'NCDB': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html  | 
            ||
| 1619 | case 'CNCV': // Canon:CompressorVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html  | 
            ||
| 1620 | $atom_structure['data'] = $atom_data;  | 
            ||
| 1621 | break;  | 
            ||
| 1622 | |||
| 1623 | View Code Duplication | case "\x00\x00\x00\x00":  | 
            |
| 1624 | // some kind of metacontainer, may contain a big data dump such as:  | 
            ||
| 1625 | // mdta keys \005 mdtacom.apple.quicktime.make (mdtacom.apple.quicktime.creationdate ,mdtacom.apple.quicktime.location.ISO6709 $mdtacom.apple.quicktime.software !mdtacom.apple.quicktime.model ilst \01D \001 \015data \001DE\010Apple 0 \002 (data \001DE\0102011-05-11T17:54:04+0200 2 \003 *data \001DE\010+52.4936+013.3897+040.247/ \01D \004 \015data \001DE\0104.3.1 \005 \018data \001DE\010iPhone 4  | 
            ||
| 1626 | // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt  | 
            ||
| 1627 | |||
| 1628 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1629 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));  | 
            ||
| 1630 | $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_data, 4), $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);  | 
            ||
| 1631 | //$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);  | 
            ||
| 1632 | break;  | 
            ||
| 1633 | |||
| 1634 | View Code Duplication | case 'meta': // METAdata atom  | 
            |
| 1635 | // https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/Metadata/Metadata.html  | 
            ||
| 1636 | |||
| 1637 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1638 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));  | 
            ||
| 1639 | $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);  | 
            ||
| 1640 | break;  | 
            ||
| 1641 | |||
| 1642 | case 'data': // metaDATA atom  | 
            ||
| 1643 | static $metaDATAkey = 1; // real ugly, but so is the QuickTime structure that stores keys and values in different multinested locations that are hard to relate to each other  | 
            ||
| 1644 | // seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in sample I have), remainder is useful data  | 
            ||
| 1645 | $atom_structure['language'] = substr($atom_data, 4 + 0, 2);  | 
            ||
| 1646 | $atom_structure['unknown'] = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2));  | 
            ||
| 1647 | $atom_structure['data'] = substr($atom_data, 4 + 4);  | 
            ||
| 1648 | $atom_structure['key_name'] = @$info['quicktime']['temp_meta_key_names'][$metaDATAkey++];  | 
            ||
| 1649 | |||
| 1650 | 					if ($atom_structure['key_name'] && $atom_structure['data']) { | 
            ||
| 1651 | 						@$info['quicktime']['comments'][str_replace('com.apple.quicktime.', '', $atom_structure['key_name'])][] = $atom_structure['data']; | 
            ||
| 1652 | }  | 
            ||
| 1653 | break;  | 
            ||
| 1654 | |||
| 1655 | case 'keys': // KEYS that may be present in the metadata atom.  | 
            ||
| 1656 | // https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW21  | 
            ||
| 1657 | // The metadata item keys atom holds a list of the metadata keys that may be present in the metadata atom.  | 
            ||
| 1658 | // This list is indexed starting with 1; 0 is a reserved index value. The metadata item keys atom is a full atom with an atom type of "keys".  | 
            ||
| 1659 | $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));  | 
            ||
| 1660 | $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));  | 
            ||
| 1661 | $atom_structure['entry_count'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));  | 
            ||
| 1662 | $keys_atom_offset = 8;  | 
            ||
| 1663 | 					for ($i = 1; $i <= $atom_structure['entry_count']; $i++) { | 
            ||
| 1664 | $atom_structure['keys'][$i]['key_size'] = getid3_lib::BigEndian2Int(substr($atom_data, $keys_atom_offset + 0, 4));  | 
            ||
| 1665 | $atom_structure['keys'][$i]['key_namespace'] = substr($atom_data, $keys_atom_offset + 4, 4);  | 
            ||
| 1666 | $atom_structure['keys'][$i]['key_value'] = substr($atom_data, $keys_atom_offset + 8, $atom_structure['keys'][$i]['key_size'] - 8);  | 
            ||
| 1667 | $keys_atom_offset += $atom_structure['keys'][$i]['key_size']; // key_size includes the 4+4 bytes for key_size and key_namespace  | 
            ||
| 1668 | |||
| 1669 | $info['quicktime']['temp_meta_key_names'][$i] = $atom_structure['keys'][$i]['key_value'];  | 
            ||
| 1670 | }  | 
            ||
| 1671 | break;  | 
            ||
| 1672 | |||
| 1673 | case 'uuid': // user-defined atom often seen containing XML data, also used for potentially many other purposes, only a few specifically handled by getID3 (e.g. 360fly spatial data)  | 
            ||
| 1674 | //Get the UUID ID in first 16 bytes  | 
            ||
| 1675 | 					$uuid_bytes_read = unpack('H8time_low/H4time_mid/H4time_hi/H4clock_seq_hi/H12clock_seq_low', substr($atom_data, 0, 16)); | 
            ||
| 1676 | 					$atom_structure['uuid_field_id'] = implode('-', $uuid_bytes_read); | 
            ||
| 1677 | |||
| 1678 | 					switch ($atom_structure['uuid_field_id']) {   // http://fileformats.archiveteam.org/wiki/Boxes/atoms_format#UUID_boxes | 
            ||
| 1679 | |||
| 1680 | case '0537cdab-9d0c-4431-a72a-fa561f2a113e': // Exif - http://fileformats.archiveteam.org/wiki/Exif  | 
            ||
| 1681 | case '2c4c0100-8504-40b9-a03e-562148d6dfeb': // Photoshop Image Resources - http://fileformats.archiveteam.org/wiki/Photoshop_Image_Resources  | 
            ||
| 1682 | case '33c7a4d2-b81d-4723-a0ba-f1a3e097ad38': // IPTC-IIM - http://fileformats.archiveteam.org/wiki/IPTC-IIM  | 
            ||
| 1683 | case '8974dbce-7be7-4c51-84f9-7148f9882554': // PIFF Track Encryption Box - http://fileformats.archiveteam.org/wiki/Protected_Interoperable_File_Format  | 
            ||
| 1684 | case '96a9f1f1-dc98-402d-a7ae-d68e34451809': // GeoJP2 World File Box - http://fileformats.archiveteam.org/wiki/GeoJP2  | 
            ||
| 1685 | case 'a2394f52-5a9b-4f14-a244-6c427c648df4': // PIFF Sample Encryption Box - http://fileformats.archiveteam.org/wiki/Protected_Interoperable_File_Format  | 
            ||
| 1686 | case 'b14bf8bd-083d-4b43-a5ae-8cd7d5a6ce03': // GeoJP2 GeoTIFF Box - http://fileformats.archiveteam.org/wiki/GeoJP2  | 
            ||
| 1687 | View Code Duplication | case 'd08a4f18-10f3-4a82-b6c8-32d8aba183d3': // PIFF Protection System Specific Header Box - http://fileformats.archiveteam.org/wiki/Protected_Interoperable_File_Format  | 
            |
| 1688 | 							$this->warning('Unhandled (but recognized) "uuid" atom identified by "'.$atom_structure['uuid_field_id'].'" at offset '.$atom_structure['offset'].' ('.strlen($atom_data).' bytes)'); | 
            ||
| 1689 | break;  | 
            ||
| 1690 | |||
| 1691 | case 'be7acfcb-97a9-42e8-9c71-999491e3afac': // XMP data (in XML format)  | 
            ||
| 1692 | $atom_structure['xml'] = substr($atom_data, 16, strlen($atom_data) - 16 - 8); // 16 bytes for UUID, 8 bytes header(?)  | 
            ||
| 1693 | break;  | 
            ||
| 1694 | |||
| 1695 | case 'efe1589a-bb77-49ef-8095-27759eb1dc6f': // 360fly data  | 
            ||
| 1696 | /* 360fly code in this block by Paul Lewis 2019-Oct-31 */  | 
            ||
| 1697 | /* Sensor Timestamps need to be calculated using the recordings base time at ['quicktime']['moov']['subatoms'][0]['creation_time_unix']. */  | 
            ||
| 1698 | $atom_structure['title'] = '360Fly Sensor Data';  | 
            ||
| 1699 | |||
| 1700 | //Get the UUID HEADER data  | 
            ||
| 1701 | 							$uuid_bytes_read = unpack('vheader_size/vheader_version/vtimescale/vhardware_version/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/', substr($atom_data, 16, 32)); | 
            ||
| 1702 | $atom_structure['uuid_header'] = $uuid_bytes_read;  | 
            ||
| 1703 | |||
| 1704 | $start_byte = 48;  | 
            ||
| 1705 | $atom_SENSOR_data = substr($atom_data, $start_byte);  | 
            ||
| 1706 | $atom_structure['sensor_data']['data_type'] = array(  | 
            ||
| 1707 | 'fusion_count' => 0, // ID 250  | 
            ||
| 1708 | 'fusion_data' => array(),  | 
            ||
| 1709 | 'accel_count' => 0, // ID 1  | 
            ||
| 1710 | 'accel_data' => array(),  | 
            ||
| 1711 | 'gyro_count' => 0, // ID 2  | 
            ||
| 1712 | 'gyro_data' => array(),  | 
            ||
| 1713 | 'magno_count' => 0, // ID 3  | 
            ||
| 1714 | 'magno_data' => array(),  | 
            ||
| 1715 | 'gps_count' => 0, // ID 5  | 
            ||
| 1716 | 'gps_data' => array(),  | 
            ||
| 1717 | 'rotation_count' => 0, // ID 6  | 
            ||
| 1718 | 'rotation_data' => array(),  | 
            ||
| 1719 | 'unknown_count' => 0, // ID ??  | 
            ||
| 1720 | 'unknown_data' => array(),  | 
            ||
| 1721 | 'debug_list' => '', // Used to debug variables stored as comma delimited strings  | 
            ||
| 1722 | );  | 
            ||
| 1723 | $debug_structure['debug_items'] = array();  | 
            ||
| 1724 | // Can start loop here to decode all sensor data in 32 Byte chunks:  | 
            ||
| 1725 | 							foreach (str_split($atom_SENSOR_data, 32) as $sensor_key => $sensor_data) { | 
            ||
| 1726 | // This gets me a data_type code to work out what data is in the next 31 bytes.  | 
            ||
| 1727 | $sensor_data_type = substr($sensor_data, 0, 1);  | 
            ||
| 1728 | $sensor_data_content = substr($sensor_data, 1);  | 
            ||
| 1729 | 								$uuid_bytes_read = unpack('C*', $sensor_data_type); | 
            ||
| 1730 | $sensor_data_array = array();  | 
            ||
| 1731 | 								switch ($uuid_bytes_read[1]) { | 
            ||
| 1732 | View Code Duplication | case 250:  | 
            |
| 1733 | $atom_structure['sensor_data']['data_type']['fusion_count']++;  | 
            ||
| 1734 | 										$uuid_bytes_read = unpack('cmode/Jtimestamp/Gyaw/Gpitch/Groll/x*', $sensor_data_content); | 
            ||
| 1735 | $sensor_data_array['mode'] = $uuid_bytes_read['mode'];  | 
            ||
| 1736 | $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp'];  | 
            ||
| 1737 | $sensor_data_array['yaw'] = $uuid_bytes_read['yaw'];  | 
            ||
| 1738 | $sensor_data_array['pitch'] = $uuid_bytes_read['pitch'];  | 
            ||
| 1739 | $sensor_data_array['roll'] = $uuid_bytes_read['roll'];  | 
            ||
| 1740 | array_push($atom_structure['sensor_data']['data_type']['fusion_data'], $sensor_data_array);  | 
            ||
| 1741 | break;  | 
            ||
| 1742 | View Code Duplication | case 1:  | 
            |
| 1743 | $atom_structure['sensor_data']['data_type']['accel_count']++;  | 
            ||
| 1744 | 										$uuid_bytes_read = unpack('cmode/Jtimestamp/Gyaw/Gpitch/Groll/x*', $sensor_data_content); | 
            ||
| 1745 | $sensor_data_array['mode'] = $uuid_bytes_read['mode'];  | 
            ||
| 1746 | $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp'];  | 
            ||
| 1747 | $sensor_data_array['yaw'] = $uuid_bytes_read['yaw'];  | 
            ||
| 1748 | $sensor_data_array['pitch'] = $uuid_bytes_read['pitch'];  | 
            ||
| 1749 | $sensor_data_array['roll'] = $uuid_bytes_read['roll'];  | 
            ||
| 1750 | array_push($atom_structure['sensor_data']['data_type']['accel_data'], $sensor_data_array);  | 
            ||
| 1751 | break;  | 
            ||
| 1752 | View Code Duplication | case 2:  | 
            |
| 1753 | $atom_structure['sensor_data']['data_type']['gyro_count']++;  | 
            ||
| 1754 | 										$uuid_bytes_read = unpack('cmode/Jtimestamp/Gyaw/Gpitch/Groll/x*', $sensor_data_content); | 
            ||
| 1755 | $sensor_data_array['mode'] = $uuid_bytes_read['mode'];  | 
            ||
| 1756 | $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp'];  | 
            ||
| 1757 | $sensor_data_array['yaw'] = $uuid_bytes_read['yaw'];  | 
            ||
| 1758 | $sensor_data_array['pitch'] = $uuid_bytes_read['pitch'];  | 
            ||
| 1759 | $sensor_data_array['roll'] = $uuid_bytes_read['roll'];  | 
            ||
| 1760 | array_push($atom_structure['sensor_data']['data_type']['gyro_data'], $sensor_data_array);  | 
            ||
| 1761 | break;  | 
            ||
| 1762 | View Code Duplication | case 3:  | 
            |
| 1763 | $atom_structure['sensor_data']['data_type']['magno_count']++;  | 
            ||
| 1764 | 										$uuid_bytes_read = unpack('cmode/Jtimestamp/Gmagx/Gmagy/Gmagz/x*', $sensor_data_content); | 
            ||
| 1765 | $sensor_data_array['mode'] = $uuid_bytes_read['mode'];  | 
            ||
| 1766 | $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp'];  | 
            ||
| 1767 | $sensor_data_array['magx'] = $uuid_bytes_read['magx'];  | 
            ||
| 1768 | $sensor_data_array['magy'] = $uuid_bytes_read['magy'];  | 
            ||
| 1769 | $sensor_data_array['magz'] = $uuid_bytes_read['magz'];  | 
            ||
| 1770 | array_push($atom_structure['sensor_data']['data_type']['magno_data'], $sensor_data_array);  | 
            ||
| 1771 | break;  | 
            ||
| 1772 | case 5:  | 
            ||
| 1773 | $atom_structure['sensor_data']['data_type']['gps_count']++;  | 
            ||
| 1774 | 										$uuid_bytes_read = unpack('cmode/Jtimestamp/Glat/Glon/Galt/Gspeed/nbearing/nacc/x*', $sensor_data_content); | 
            ||
| 1775 | $sensor_data_array['mode'] = $uuid_bytes_read['mode'];  | 
            ||
| 1776 | $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp'];  | 
            ||
| 1777 | $sensor_data_array['lat'] = $uuid_bytes_read['lat'];  | 
            ||
| 1778 | $sensor_data_array['lon'] = $uuid_bytes_read['lon'];  | 
            ||
| 1779 | $sensor_data_array['alt'] = $uuid_bytes_read['alt'];  | 
            ||
| 1780 | $sensor_data_array['speed'] = $uuid_bytes_read['speed'];  | 
            ||
| 1781 | $sensor_data_array['bearing'] = $uuid_bytes_read['bearing'];  | 
            ||
| 1782 | $sensor_data_array['acc'] = $uuid_bytes_read['acc'];  | 
            ||
| 1783 | array_push($atom_structure['sensor_data']['data_type']['gps_data'], $sensor_data_array);  | 
            ||
| 1784 | //array_push($debug_structure['debug_items'], $uuid_bytes_read['timestamp']);  | 
            ||
| 1785 | break;  | 
            ||
| 1786 | View Code Duplication | case 6:  | 
            |
| 1787 | $atom_structure['sensor_data']['data_type']['rotation_count']++;  | 
            ||
| 1788 | 										$uuid_bytes_read = unpack('cmode/Jtimestamp/Grotx/Groty/Grotz/x*', $sensor_data_content); | 
            ||
| 1789 | $sensor_data_array['mode'] = $uuid_bytes_read['mode'];  | 
            ||
| 1790 | $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp'];  | 
            ||
| 1791 | $sensor_data_array['rotx'] = $uuid_bytes_read['rotx'];  | 
            ||
| 1792 | $sensor_data_array['roty'] = $uuid_bytes_read['roty'];  | 
            ||
| 1793 | $sensor_data_array['rotz'] = $uuid_bytes_read['rotz'];  | 
            ||
| 1794 | array_push($atom_structure['sensor_data']['data_type']['rotation_data'], $sensor_data_array);  | 
            ||
| 1795 | break;  | 
            ||
| 1796 | default:  | 
            ||
| 1797 | $atom_structure['sensor_data']['data_type']['unknown_count']++;  | 
            ||
| 1798 | break;  | 
            ||
| 1799 | }  | 
            ||
| 1800 | }  | 
            ||
| 1801 | 							//if (isset($debug_structure['debug_items']) && count($debug_structure['debug_items']) > 0) { | 
            ||
| 1802 | 							//	$atom_structure['sensor_data']['data_type']['debug_list'] = implode(',', $debug_structure['debug_items']); | 
            ||
| 1803 | 							//} else { | 
            ||
| 1804 | $atom_structure['sensor_data']['data_type']['debug_list'] = 'No debug items in list!';  | 
            ||
| 1805 | //}  | 
            ||
| 1806 | break;  | 
            ||
| 1807 | |||
| 1808 | View Code Duplication | default:  | 
            |
| 1809 | 							$this->warning('Unhandled "uuid" atom identified by "'.$atom_structure['uuid_field_id'].'" at offset '.$atom_structure['offset'].' ('.strlen($atom_data).' bytes)'); | 
            ||
| 1810 | }  | 
            ||
| 1811 | break;  | 
            ||
| 1812 | |||
| 1813 | case 'gps ':  | 
            ||
| 1814 | // https://dashcamtalk.com/forum/threads/script-to-extract-gps-data-from-novatek-mp4.20808/page-2#post-291730  | 
            ||
| 1815 | // The 'gps ' contains simple look up table made up of 8byte rows, that point to the 'free' atoms that contains the actual GPS data.  | 
            ||
| 1816 | // The first row is version/metadata/notsure, I skip that.  | 
            ||
| 1817 | // The following rows consist of 4byte address (absolute) and 4byte size (0x1000), these point to the GPS data in the file.  | 
            ||
| 1818 | |||
| 1819 | $GPS_rowsize = 8; // 4 bytes for offset, 4 bytes for size  | 
            ||
| 1820 | 					if (strlen($atom_data) > 0) { | 
            ||
| 1821 | 						if ((strlen($atom_data) % $GPS_rowsize) == 0) { | 
            ||
| 1822 | $atom_structure['gps_toc'] = array();  | 
            ||
| 1823 | 							foreach (str_split($atom_data, $GPS_rowsize) as $counter => $datapair) { | 
            ||
| 1824 | 								$atom_structure['gps_toc'][] = unpack('Noffset/Nsize', substr($atom_data, $counter * $GPS_rowsize, $GPS_rowsize)); | 
            ||
| 1825 | }  | 
            ||
| 1826 | |||
| 1827 | $atom_structure['gps_entries'] = array();  | 
            ||
| 1828 | $previous_offset = $this->ftell();  | 
            ||
| 1829 | 							foreach ($atom_structure['gps_toc'] as $key => $gps_pointer) { | 
            ||
| 1830 | 								if ($key == 0) { | 
            ||
| 1831 | // "The first row is version/metadata/notsure, I skip that."  | 
            ||
| 1832 | continue;  | 
            ||
| 1833 | }  | 
            ||
| 1834 | $this->fseek($gps_pointer['offset']);  | 
            ||
| 1835 | $GPS_free_data = $this->fread($gps_pointer['size']);  | 
            ||
| 1836 | |||
| 1837 | /*  | 
            ||
| 1838 | // 2017-05-10: I see some of the data, notably the Hour-Minute-Second, but cannot reconcile the rest of the data. However, the NMEA "GPRMC" line is there and relatively easy to parse, so I'm using that instead  | 
            ||
| 1839 | |||
| 1840 | // https://dashcamtalk.com/forum/threads/script-to-extract-gps-data-from-novatek-mp4.20808/page-2#post-291730  | 
            ||
| 1841 | // The structure of the GPS data atom (the 'free' atoms mentioned above) is following:  | 
            ||
| 1842 | 								// hour,minute,second,year,month,day,active,latitude_b,longitude_b,unknown2,latitude,longitude,speed = struct.unpack_from('<IIIIIIssssfff',data, 48) | 
            ||
| 1843 | // For those unfamiliar with python struct:  | 
            ||
| 1844 | // I = int  | 
            ||
| 1845 | // s = is string (size 1, in this case)  | 
            ||
| 1846 | // f = float  | 
            ||
| 1847 | |||
| 1848 | 								//$atom_structure['gps_entries'][$key] = unpack('Vhour/Vminute/Vsecond/Vyear/Vmonth/Vday/Vactive/Vlatitude_b/Vlongitude_b/Vunknown2/flatitude/flongitude/fspeed', substr($GPS_free_data, 48)); | 
            ||
| 1849 | */  | 
            ||
| 1850 | |||
| 1851 | // $GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62  | 
            ||
| 1852 | // $GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67  | 
            ||
| 1853 | // $GPRMC,002454,A,3553.5295,N,13938.6570,E,0.0,43.1,180700,7.1,W,A*3F  | 
            ||
| 1854 | // $GPRMC,094347.000,A,5342.0061,N,00737.9908,W,0.01,156.75,140217,,,A*7D  | 
            ||
| 1855 | 								if (preg_match('#\\$GPRMC,([0-9\\.]*),([AV]),([0-9\\.]*),([NS]),([0-9\\.]*),([EW]),([0-9\\.]*),([0-9\\.]*),([0-9]*),([0-9\\.]*),([EW]?)(,[A])?(\\*[0-9A-F]{2})#', $GPS_free_data, $matches)) { | 
            ||
| 1856 | $GPS_this_GPRMC = array();  | 
            ||
| 1857 | $GPS_this_GPRMC_raw = array();  | 
            ||
| 1858 | list(  | 
            ||
| 1859 | $GPS_this_GPRMC_raw['gprmc'],  | 
            ||
| 1860 | $GPS_this_GPRMC_raw['timestamp'],  | 
            ||
| 1861 | $GPS_this_GPRMC_raw['status'],  | 
            ||
| 1862 | $GPS_this_GPRMC_raw['latitude'],  | 
            ||
| 1863 | $GPS_this_GPRMC_raw['latitude_direction'],  | 
            ||
| 1864 | $GPS_this_GPRMC_raw['longitude'],  | 
            ||
| 1865 | $GPS_this_GPRMC_raw['longitude_direction'],  | 
            ||
| 1866 | $GPS_this_GPRMC_raw['knots'],  | 
            ||
| 1867 | $GPS_this_GPRMC_raw['angle'],  | 
            ||
| 1868 | $GPS_this_GPRMC_raw['datestamp'],  | 
            ||
| 1869 | $GPS_this_GPRMC_raw['variation'],  | 
            ||
| 1870 | $GPS_this_GPRMC_raw['variation_direction'],  | 
            ||
| 1871 | $dummy,  | 
            ||
| 1872 | $GPS_this_GPRMC_raw['checksum'],  | 
            ||
| 1873 | ) = $matches;  | 
            ||
| 1874 | $GPS_this_GPRMC['raw'] = $GPS_this_GPRMC_raw;  | 
            ||
| 1875 | |||
| 1876 | $hour = substr($GPS_this_GPRMC['raw']['timestamp'], 0, 2);  | 
            ||
| 1877 | $minute = substr($GPS_this_GPRMC['raw']['timestamp'], 2, 2);  | 
            ||
| 1878 | $second = substr($GPS_this_GPRMC['raw']['timestamp'], 4, 2);  | 
            ||
| 1879 | $ms = substr($GPS_this_GPRMC['raw']['timestamp'], 6); // may contain decimal seconds  | 
            ||
| 1880 | $day = substr($GPS_this_GPRMC['raw']['datestamp'], 0, 2);  | 
            ||
| 1881 | $month = substr($GPS_this_GPRMC['raw']['datestamp'], 2, 2);  | 
            ||
| 1882 | $year = (int) substr($GPS_this_GPRMC['raw']['datestamp'], 4, 2);  | 
            ||
| 1883 | $year += (($year > 90) ? 1900 : 2000); // complete lack of foresight: datestamps are stored with 2-digit years, take best guess  | 
            ||
| 1884 | $GPS_this_GPRMC['timestamp'] = $year.'-'.$month.'-'.$day.' '.$hour.':'.$minute.':'.$second.$ms;  | 
            ||
| 1885 | |||
| 1886 | $GPS_this_GPRMC['active'] = ($GPS_this_GPRMC['raw']['status'] == 'A'); // A=Active,V=Void  | 
            ||
| 1887 | |||
| 1888 | 									foreach (array('latitude','longitude') as $latlon) { | 
            ||
| 1889 | 										preg_match('#^([0-9]{1,3})([0-9]{2}\\.[0-9]+)$#', $GPS_this_GPRMC['raw'][$latlon], $matches); | 
            ||
| 1890 | list($dummy, $deg, $min) = $matches;  | 
            ||
| 1891 | $GPS_this_GPRMC[$latlon] = $deg + ($min / 60);  | 
            ||
| 1892 | }  | 
            ||
| 1893 | $GPS_this_GPRMC['latitude'] *= (($GPS_this_GPRMC['raw']['latitude_direction'] == 'S') ? -1 : 1);  | 
            ||
| 1894 | $GPS_this_GPRMC['longitude'] *= (($GPS_this_GPRMC['raw']['longitude_direction'] == 'W') ? -1 : 1);  | 
            ||
| 1895 | |||
| 1896 | $GPS_this_GPRMC['heading'] = $GPS_this_GPRMC['raw']['angle'];  | 
            ||
| 1897 | $GPS_this_GPRMC['speed_knot'] = $GPS_this_GPRMC['raw']['knots'];  | 
            ||
| 1898 | $GPS_this_GPRMC['speed_kmh'] = $GPS_this_GPRMC['raw']['knots'] * 1.852;  | 
            ||
| 1899 | 									if ($GPS_this_GPRMC['raw']['variation']) { | 
            ||
| 1900 | $GPS_this_GPRMC['variation'] = $GPS_this_GPRMC['raw']['variation'];  | 
            ||
| 1901 | $GPS_this_GPRMC['variation'] *= (($GPS_this_GPRMC['raw']['variation_direction'] == 'W') ? -1 : 1);  | 
            ||
| 1902 | }  | 
            ||
| 1903 | |||
| 1904 | $atom_structure['gps_entries'][$key] = $GPS_this_GPRMC;  | 
            ||
| 1905 | |||
| 1906 | @$info['quicktime']['gps_track'][$GPS_this_GPRMC['timestamp']] = array(  | 
            ||
| 1907 | 'latitude' => (float) $GPS_this_GPRMC['latitude'],  | 
            ||
| 1908 | 'longitude' => (float) $GPS_this_GPRMC['longitude'],  | 
            ||
| 1909 | 'speed_kmh' => (float) $GPS_this_GPRMC['speed_kmh'],  | 
            ||
| 1910 | 'heading' => (float) $GPS_this_GPRMC['heading'],  | 
            ||
| 1911 | );  | 
            ||
| 1912 | |||
| 1913 | 								} else { | 
            ||
| 1914 | 									$this->warning('Unhandled GPS format in "free" atom at offset '.$gps_pointer['offset']); | 
            ||
| 1915 | }  | 
            ||
| 1916 | }  | 
            ||
| 1917 | $this->fseek($previous_offset);  | 
            ||
| 1918 | |||
| 1919 | 						} else { | 
            ||
| 1920 | 							$this->warning('QuickTime atom "'.$atomname.'" is not mod-8 bytes long ('.$atomsize.' bytes) at offset '.$baseoffset); | 
            ||
| 1921 | }  | 
            ||
| 1922 | 					} else { | 
            ||
| 1923 | 						$this->warning('QuickTime atom "'.$atomname.'" is zero bytes long at offset '.$baseoffset); | 
            ||
| 1924 | }  | 
            ||
| 1925 | break;  | 
            ||
| 1926 | |||
| 1927 | case 'loci':// 3GP location (El Loco)  | 
            ||
| 1928 | $loffset = 0;  | 
            ||
| 1929 | $info['quicktime']['comments']['gps_flags'] = array( getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)));  | 
            ||
| 1930 | $info['quicktime']['comments']['gps_lang'] = array( getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)));  | 
            ||
| 1931 | $info['quicktime']['comments']['gps_location'] = array( $this->LociString(substr($atom_data, 6), $loffset));  | 
            ||
| 1932 | $loci_data = substr($atom_data, 6 + $loffset);  | 
            ||
| 1933 | $info['quicktime']['comments']['gps_role'] = array( getid3_lib::BigEndian2Int(substr($loci_data, 0, 1)));  | 
            ||
| 1934 | $info['quicktime']['comments']['gps_longitude'] = array(getid3_lib::FixedPoint16_16(substr($loci_data, 1, 4)));  | 
            ||
| 1935 | $info['quicktime']['comments']['gps_latitude'] = array(getid3_lib::FixedPoint16_16(substr($loci_data, 5, 4)));  | 
            ||
| 1936 | $info['quicktime']['comments']['gps_altitude'] = array(getid3_lib::FixedPoint16_16(substr($loci_data, 9, 4)));  | 
            ||
| 1937 | $info['quicktime']['comments']['gps_body'] = array( $this->LociString(substr($loci_data, 13 ), $loffset));  | 
            ||
| 1938 | $info['quicktime']['comments']['gps_notes'] = array( $this->LociString(substr($loci_data, 13 + $loffset), $loffset));  | 
            ||
| 1939 | break;  | 
            ||
| 1940 | |||
| 1941 | case 'chpl': // CHaPter List  | 
            ||
| 1942 | // https://www.adobe.com/content/dam/Adobe/en/devnet/flv/pdfs/video_file_format_spec_v10.pdf  | 
            ||
| 1943 | $chpl_version = getid3_lib::BigEndian2Int(substr($atom_data, 4, 1)); // Expected to be 0  | 
            ||
| 1944 | $chpl_flags = getid3_lib::BigEndian2Int(substr($atom_data, 5, 3)); // Reserved, set to 0  | 
            ||
| 1945 | $chpl_count = getid3_lib::BigEndian2Int(substr($atom_data, 8, 1));  | 
            ||
| 1946 | $chpl_offset = 9;  | 
            ||
| 1947 | 					for ($i = 0; $i < $chpl_count; $i++) { | 
            ||
| 1948 | 						if (($chpl_offset + 9) >= strlen($atom_data)) { | 
            ||
| 1949 | 							$this->warning('QuickTime chapter '.$i.' extends beyond end of "chpl" atom'); | 
            ||
| 1950 | break;  | 
            ||
| 1951 | }  | 
            ||
| 1952 | $info['quicktime']['chapters'][$i]['timestamp'] = getid3_lib::BigEndian2Int(substr($atom_data, $chpl_offset, 8)) / 10000000; // timestamps are stored as 100-nanosecond units  | 
            ||
| 1953 | $chpl_offset += 8;  | 
            ||
| 1954 | $chpl_title_size = getid3_lib::BigEndian2Int(substr($atom_data, $chpl_offset, 1));  | 
            ||
| 1955 | $chpl_offset += 1;  | 
            ||
| 1956 | $info['quicktime']['chapters'][$i]['title'] = substr($atom_data, $chpl_offset, $chpl_title_size);  | 
            ||
| 1957 | $chpl_offset += $chpl_title_size;  | 
            ||
| 1958 | }  | 
            ||
| 1959 | break;  | 
            ||
| 1960 | |||
| 1961 | case 'FIRM': // FIRMware version(?), seen on GoPro Hero4  | 
            ||
| 1962 | $info['quicktime']['camera']['firmware'] = $atom_data;  | 
            ||
| 1963 | break;  | 
            ||
| 1964 | |||
| 1965 | case 'CAME': // FIRMware version(?), seen on GoPro Hero4  | 
            ||
| 1966 | 					$info['quicktime']['camera']['serial_hash'] = unpack('H*', $atom_data); | 
            ||
| 1967 | break;  | 
            ||
| 1968 | |||
| 1969 | case 'dscp':  | 
            ||
| 1970 | case 'rcif':  | 
            ||
| 1971 | // https://www.getid3.org/phpBB3/viewtopic.php?t=1908  | 
            ||
| 1972 | 					if (substr($atom_data, 0, 7) == "\x00\x00\x00\x00\x55\xC4".'{') { | 
            ||
| 1973 | 						if ($json_decoded = @json_decode(rtrim(substr($atom_data, 6), "\x00"), true)) { | 
            ||
| 1974 | $info['quicktime']['camera'][$atomname] = $json_decoded;  | 
            ||
| 1975 | 							if (($atomname == 'rcif') && isset($info['quicktime']['camera']['rcif']['wxcamera']['rotate'])) { | 
            ||
| 1976 | $info['video']['rotate'] = $info['quicktime']['video']['rotate'] = $info['quicktime']['camera']['rcif']['wxcamera']['rotate'];  | 
            ||
| 1977 | }  | 
            ||
| 1978 | 						} else { | 
            ||
| 1979 | 							$this->warning('Failed to JSON decode atom "'.$atomname.'"'); | 
            ||
| 1980 | $atom_structure['data'] = $atom_data;  | 
            ||
| 1981 | }  | 
            ||
| 1982 | unset($json_decoded);  | 
            ||
| 1983 | 					} else { | 
            ||
| 1984 | 						$this->warning('Expecting 55 C4 7B at start of atom "'.$atomname.'", found '.getid3_lib::PrintHexBytes(substr($atom_data, 4, 3)).' instead'); | 
            ||
| 1985 | $atom_structure['data'] = $atom_data;  | 
            ||
| 1986 | }  | 
            ||
| 1987 | break;  | 
            ||
| 1988 | |||
| 1989 | case 'frea':  | 
            ||
| 1990 | // https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Kodak.html#frea  | 
            ||
| 1991 | // may contain "scra" (PreviewImage) and/or "thma" (ThumbnailImage)  | 
            ||
| 1992 | $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 4, $atomHierarchy, $ParseAllPossibleAtoms);  | 
            ||
| 1993 | break;  | 
            ||
| 1994 | case 'tima': // subatom to "frea"  | 
            ||
| 1995 | // no idea what this does, the one sample file I've seen has a value of 0x00000027  | 
            ||
| 1996 | $atom_structure['data'] = $atom_data;  | 
            ||
| 1997 | break;  | 
            ||
| 1998 | case 'ver ': // subatom to "frea"  | 
            ||
| 1999 | // some kind of version number, the one sample file I've seen has a value of "3.00.073"  | 
            ||
| 2000 | $atom_structure['data'] = $atom_data;  | 
            ||
| 2001 | break;  | 
            ||
| 2002 | View Code Duplication | case 'thma': // subatom to "frea" -- "ThumbnailImage"  | 
            |
| 2003 | // https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Kodak.html#frea  | 
            ||
| 2004 | 					if (strlen($atom_data) > 0) { | 
            ||
| 2005 | 						$info['quicktime']['comments']['picture'][] = array('data'=>$atom_data, 'image_mime'=>'image/jpeg', 'description'=>'ThumbnailImage'); | 
            ||
| 2006 | }  | 
            ||
| 2007 | break;  | 
            ||
| 2008 | View Code Duplication | case 'scra': // subatom to "frea" -- "PreviewImage"  | 
            |
| 2009 | // https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Kodak.html#frea  | 
            ||
| 2010 | // but the only sample file I've seen has no useful data here  | 
            ||
| 2011 | 					if (strlen($atom_data) > 0) { | 
            ||
| 2012 | 						$info['quicktime']['comments']['picture'][] = array('data'=>$atom_data, 'image_mime'=>'image/jpeg', 'description'=>'PreviewImage'); | 
            ||
| 2013 | }  | 
            ||
| 2014 | break;  | 
            ||
| 2015 | |||
| 2016 | case 'cdsc': // timed metadata reference  | 
            ||
| 2017 | // A QuickTime movie can contain none, one, or several timed metadata tracks. Timed metadata tracks can refer to multiple tracks.  | 
            ||
| 2018 | // Metadata tracks are linked to the tracks they describe using a track-reference of type 'cdsc'. The metadata track holds the 'cdsc' track reference.  | 
            ||
| 2019 | $atom_structure['track_number'] = getid3_lib::BigEndian2Int($atom_data);  | 
            ||
| 2020 | break;  | 
            ||
| 2021 | |||
| 2022 | View Code Duplication | default:  | 
            |
| 2023 | 					$this->warning('Unknown QuickTime atom type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" ('.trim(getid3_lib::PrintHexBytes($atomname)).'), '.$atomsize.' bytes at offset '.$baseoffset); | 
            ||
| 2024 | $atom_structure['data'] = $atom_data;  | 
            ||
| 2025 | break;  | 
            ||
| 2026 | }  | 
            ||
| 2027 | }  | 
            ||
| 2028 | array_pop($atomHierarchy);  | 
            ||
| 2029 | return $atom_structure;  | 
            ||
| 2030 | }  | 
            ||
| 2031 | |||
| 3100 |