getid3_quicktime

The WordPress Core getid3 quicktime class.

Defined (1)

The class is defined in the following location(s).

/wp-includes/ID3/module.audio-video.quicktime.php  
  1. class getid3_quicktime extends getid3_handler 
  2.  
  3. public $ReturnAtomData = true; 
  4. public $ParseAllPossibleAtoms = false; 
  5.  
  6. public function Analyze() { 
  7. $info = &$this->getid3->info; 
  8.  
  9. $info['fileformat'] = 'quicktime'; 
  10. $info['quicktime']['hinting'] = false; 
  11. $info['quicktime']['controller'] = 'standard'; // may be overridden if 'ctyp' atom is present 
  12.  
  13. $this->fseek($info['avdataoffset']); 
  14.  
  15. $offset = 0; 
  16. $atomcounter = 0; 
  17. $atom_data_read_buffer_size = ($info['php_memory_limit'] ? round($info['php_memory_limit'] / 2) : $this->getid3->option_fread_buffer_size * 1024); // allow [default: 32MB] if PHP configured with no memory_limit 
  18. while ($offset < $info['avdataend']) { 
  19. if (!getid3_lib::intValueSupported($offset)) { 
  20. $info['error'][] = 'Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions'; 
  21. break; 
  22. $this->fseek($offset); 
  23. $AtomHeader = $this->fread(8); 
  24.  
  25. $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4)); 
  26. $atomname = substr($AtomHeader, 4, 4); 
  27.  
  28. // 64-bit MOV patch by jlegatektnc*com 
  29. if ($atomsize == 1) { 
  30. $atomsize = getid3_lib::BigEndian2Int($this->fread(8)); 
  31.  
  32. $info['quicktime'][$atomname]['name'] = $atomname; 
  33. $info['quicktime'][$atomname]['size'] = $atomsize; 
  34. $info['quicktime'][$atomname]['offset'] = $offset; 
  35.  
  36. if (($offset + $atomsize) > $info['avdataend']) { 
  37. $info['error'][] = 'Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)'; 
  38. return false; 
  39.  
  40. if ($atomsize == 0) { 
  41. // Furthermore, for historical reasons the list of atoms is optionally 
  42. // terminated by a 32-bit integer set to 0. If you are writing a program 
  43. // to read user data atoms, you should allow for the terminating 0. 
  44. break; 
  45. $atomHierarchy = array(); 
  46. $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread(min($atomsize, $atom_data_read_buffer_size)), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms); 
  47.  
  48. $offset += $atomsize; 
  49. $atomcounter++; 
  50.  
  51. if (!empty($info['avdataend_tmp'])) { 
  52. // this value is assigned to a temp value and then erased because 
  53. // otherwise any atoms beyond the 'mdat' atom would not get parsed 
  54. $info['avdataend'] = $info['avdataend_tmp']; 
  55. unset($info['avdataend_tmp']); 
  56.  
  57. if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) { 
  58. $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds']; 
  59. if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info['quicktime']['video'])) { 
  60. $info['audio']['bitrate'] = $info['bitrate']; 
  61. if (!empty($info['playtime_seconds']) && !isset($info['video']['frame_rate']) && !empty($info['quicktime']['stts_framecount'])) { 
  62. foreach ($info['quicktime']['stts_framecount'] as $key => $samples_count) { 
  63. $samples_per_second = $samples_count / $info['playtime_seconds']; 
  64. if ($samples_per_second > 240) { 
  65. // has to be audio samples 
  66. } else { 
  67. $info['video']['frame_rate'] = $samples_per_second; 
  68. break; 
  69. if (($info['audio']['dataformat'] == 'mp4') && empty($info['video']['resolution_x'])) { 
  70. $info['fileformat'] = 'mp4'; 
  71. $info['mime_type'] = 'audio/mp4'; 
  72. unset($info['video']['dataformat']); 
  73.  
  74. if (!$this->ReturnAtomData) { 
  75. unset($info['quicktime']['moov']); 
  76.  
  77. if (empty($info['audio']['dataformat']) && !empty($info['quicktime']['audio'])) { 
  78. $info['audio']['dataformat'] = 'quicktime'; 
  79. if (empty($info['video']['dataformat']) && !empty($info['quicktime']['video'])) { 
  80. $info['video']['dataformat'] = 'quicktime'; 
  81.  
  82. return true; 
  83.  
  84. public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) { 
  85. // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm 
  86.  
  87. $info = &$this->getid3->info; 
  88.  
  89. $atom_parent = end($atomHierarchy); // not array_pop($atomHierarchy); see http://www.getid3.org/phpBB3/viewtopic.php?t=1717 
  90. array_push($atomHierarchy, $atomname); 
  91. $atom_structure['hierarchy'] = implode(' ', $atomHierarchy); 
  92. $atom_structure['name'] = $atomname; 
  93. $atom_structure['size'] = $atomsize; 
  94. $atom_structure['offset'] = $baseoffset; 
  95. switch ($atomname) { 
  96. case 'moov': // MOVie container atom 
  97. case 'trak': // TRAcK container atom 
  98. case 'clip': // CLIPping container atom 
  99. case 'matt': // track MATTe container atom 
  100. case 'edts': // EDiTS container atom 
  101. case 'tref': // Track REFerence container atom 
  102. case 'mdia': // MeDIA container atom 
  103. case 'minf': // Media INFormation container atom 
  104. case 'dinf': // Data INFormation container atom 
  105. case 'udta': // User DaTA container atom 
  106. case 'cmov': // Compressed MOVie container atom 
  107. case 'rmra': // Reference Movie Record Atom 
  108. case 'rmda': // Reference Movie Descriptor Atom 
  109. case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR) 
  110. $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); 
  111. break; 
  112.  
  113. case 'ilst': // Item LiST container atom 
  114. if ($atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms)) { 
  115. // some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted 
  116. $allnumericnames = true; 
  117. foreach ($atom_structure['subatoms'] as $subatomarray) { 
  118. if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) { 
  119. $allnumericnames = false; 
  120. break; 
  121. if ($allnumericnames) { 
  122. $newData = array(); 
  123. foreach ($atom_structure['subatoms'] as $subatomarray) { 
  124. foreach ($subatomarray['subatoms'] as $newData_subatomarray) { 
  125. unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']); 
  126. $newData[$subatomarray['name']] = $newData_subatomarray; 
  127. break; 
  128. $atom_structure['data'] = $newData; 
  129. unset($atom_structure['subatoms']); 
  130. break; 
  131.  
  132. case "\x00\x00\x00\x01": 
  133. case "\x00\x00\x00\x02": 
  134. case "\x00\x00\x00\x03": 
  135. case "\x00\x00\x00\x04": 
  136. case "\x00\x00\x00\x05": 
  137. $atomname = getid3_lib::BigEndian2Int($atomname); 
  138. $atom_structure['name'] = $atomname; 
  139. $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); 
  140. break; 
  141.  
  142. case 'stbl': // Sample TaBLe container atom 
  143. $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); 
  144. $isVideo = false; 
  145. $framerate = 0; 
  146. $framecount = 0; 
  147. foreach ($atom_structure['subatoms'] as $key => $value_array) { 
  148. if (isset($value_array['sample_description_table'])) { 
  149. foreach ($value_array['sample_description_table'] as $key2 => $value_array2) { 
  150. if (isset($value_array2['data_format'])) { 
  151. switch ($value_array2['data_format']) { 
  152. case 'avc1': 
  153. case 'mp4v': 
  154. // video data 
  155. $isVideo = true; 
  156. break; 
  157. case 'mp4a': 
  158. // audio data 
  159. break; 
  160. } elseif (isset($value_array['time_to_sample_table'])) { 
  161. foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) { 
  162. if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0)) { 
  163. $framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3); 
  164. $framecount = $value_array2['sample_count']; 
  165. if ($isVideo && $framerate) { 
  166. $info['quicktime']['video']['frame_rate'] = $framerate; 
  167. $info['video']['frame_rate'] = $info['quicktime']['video']['frame_rate']; 
  168. if ($isVideo && $framecount) { 
  169. $info['quicktime']['video']['frame_count'] = $framecount; 
  170. break; 
  171.  
  172.  
  173. case 'aART': // Album ARTist 
  174. case 'catg': // CaTeGory 
  175. case 'covr': // COVeR artwork 
  176. case 'cpil': // ComPILation 
  177. case 'cprt': // CoPyRighT 
  178. case 'desc': // DESCription 
  179. case 'disk': // DISK number 
  180. case 'egid': // Episode Global ID 
  181. case 'gnre': // GeNRE 
  182. case 'keyw': // KEYWord 
  183. case 'ldes': 
  184. case 'pcst': // PodCaST 
  185. case 'pgap': // GAPless Playback 
  186. case 'purd': // PURchase Date 
  187. case 'purl': // Podcast URL 
  188. case 'rati': 
  189. case 'rndu': 
  190. case 'rpdu': 
  191. case 'rtng': // RaTiNG 
  192. case 'stik': 
  193. case 'tmpo': // TeMPO (BPM) 
  194. case 'trkn': // TRacK Number 
  195. case 'tves': // TV EpiSode 
  196. case 'tvnn': // TV Network Name 
  197. case 'tvsh': // TV SHow Name 
  198. case 'tvsn': // TV SeasoN 
  199. case 'akID': // iTunes store account type 
  200. case 'apID': 
  201. case 'atID': 
  202. case 'cmID': 
  203. case 'cnID': 
  204. case 'geID': 
  205. case 'plID': 
  206. case 'sfID': // iTunes store country 
  207. case "\xA9".'alb': // ALBum 
  208. case "\xA9".'art': // ARTist 
  209. case "\xA9".'ART': 
  210. case "\xA9".'aut': 
  211. case "\xA9".'cmt': // CoMmenT 
  212. case "\xA9".'com': // COMposer 
  213. case "\xA9".'cpy': 
  214. case "\xA9".'day': // content created year 
  215. case "\xA9".'dir': 
  216. case "\xA9".'ed1': 
  217. case "\xA9".'ed2': 
  218. case "\xA9".'ed3': 
  219. case "\xA9".'ed4': 
  220. case "\xA9".'ed5': 
  221. case "\xA9".'ed6': 
  222. case "\xA9".'ed7': 
  223. case "\xA9".'ed8': 
  224. case "\xA9".'ed9': 
  225. case "\xA9".'enc': 
  226. case "\xA9".'fmt': 
  227. case "\xA9".'gen': // GENre 
  228. case "\xA9".'grp': // GRouPing 
  229. case "\xA9".'hst': 
  230. case "\xA9".'inf': 
  231. case "\xA9".'lyr': // LYRics 
  232. case "\xA9".'mak': 
  233. case "\xA9".'mod': 
  234. case "\xA9".'nam': // full NAMe 
  235. case "\xA9".'ope': 
  236. case "\xA9".'PRD': 
  237. case "\xA9".'prd': 
  238. case "\xA9".'prf': 
  239. case "\xA9".'req': 
  240. case "\xA9".'src': 
  241. case "\xA9".'swr': 
  242. case "\xA9".'too': // encoder 
  243. case "\xA9".'trk': // TRacK 
  244. case "\xA9".'url': 
  245. case "\xA9".'wrn': 
  246. case "\xA9".'wrt': // WRiTer 
  247. case '----': // itunes specific 
  248. if ($atom_parent == 'udta') { 
  249. // User data atom handler 
  250. $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); 
  251. $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); 
  252. $atom_structure['data'] = substr($atom_data, 4); 
  253.  
  254. $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); 
  255. if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { 
  256. $info['comments']['language'][] = $atom_structure['language']; 
  257. } else { 
  258. // Apple item list box atom handler 
  259. $atomoffset = 0; 
  260. if (substr($atom_data, 2, 2) == "\x10\xB5") { 
  261. // not sure what it means, but observed on iPhone4 data. 
  262. // Each $atom_data has 2 bytes of datasize, plus 0x10B5, then data 
  263. while ($atomoffset < strlen($atom_data)) { 
  264. $boxsmallsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 2)); 
  265. $boxsmalltype = substr($atom_data, $atomoffset + 2, 2); 
  266. $boxsmalldata = substr($atom_data, $atomoffset + 4, $boxsmallsize); 
  267. if ($boxsmallsize <= 1) { 
  268. $info['warning'][] = 'Invalid QuickTime atom smallbox size "'.$boxsmallsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset); 
  269. $atom_structure['data'] = null; 
  270. $atomoffset = strlen($atom_data); 
  271. break; 
  272. switch ($boxsmalltype) { 
  273. case "\x10\xB5": 
  274. $atom_structure['data'] = $boxsmalldata; 
  275. break; 
  276. default: 
  277. $info['warning'][] = 'Unknown QuickTime smallbox type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxsmalltype).'" ('.trim(getid3_lib::PrintHexBytes($boxsmalltype)).') at offset '.$baseoffset; 
  278. $atom_structure['data'] = $atom_data; 
  279. break; 
  280. $atomoffset += (4 + $boxsmallsize); 
  281. } else { 
  282. while ($atomoffset < strlen($atom_data)) { 
  283. $boxsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 4)); 
  284. $boxtype = substr($atom_data, $atomoffset + 4, 4); 
  285. $boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8); 
  286. if ($boxsize <= 1) { 
  287. $info['warning'][] = 'Invalid QuickTime atom box size "'.$boxsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset); 
  288. $atom_structure['data'] = null; 
  289. $atomoffset = strlen($atom_data); 
  290. break; 
  291. $atomoffset += $boxsize; 
  292.  
  293. switch ($boxtype) { 
  294. case 'mean': 
  295. case 'name': 
  296. $atom_structure[$boxtype] = substr($boxdata, 4); 
  297. break; 
  298.  
  299. case 'data': 
  300. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1)); 
  301. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3)); 
  302. switch ($atom_structure['flags_raw']) { 
  303. case 0: // data flag 
  304. case 21: // tmpo/cpil flag 
  305. switch ($atomname) { 
  306. case 'cpil': 
  307. case 'pcst': 
  308. case 'pgap': 
  309. $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1)); 
  310. break; 
  311.  
  312. case 'tmpo': 
  313. $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2)); 
  314. break; 
  315.  
  316. case 'disk': 
  317. case 'trkn': 
  318. $num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2)); 
  319. $num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2)); 
  320. $atom_structure['data'] = empty($num) ? '' : $num; 
  321. $atom_structure['data'] .= empty($num_total) ? '' : '/'.$num_total; 
  322. break; 
  323.  
  324. case 'gnre': 
  325. $GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4)); 
  326. $atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1); 
  327. break; 
  328.  
  329. case 'rtng': 
  330. $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1)); 
  331. $atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]); 
  332. break; 
  333.  
  334. case 'stik': 
  335. $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1)); 
  336. $atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]); 
  337. break; 
  338.  
  339. case 'sfID': 
  340. $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4)); 
  341. $atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]); 
  342. break; 
  343.  
  344. case 'egid': 
  345. case 'purl': 
  346. $atom_structure['data'] = substr($boxdata, 8); 
  347. break; 
  348.  
  349. default: 
  350. $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4)); 
  351. break; 
  352.  
  353. case 1: // text flag 
  354. case 13: // image flag 
  355. default: 
  356. $atom_structure['data'] = substr($boxdata, 8); 
  357. if ($atomname == 'covr') { 
  358. // not a foolproof check, but better than nothing 
  359. if (preg_match('#^\xFF\xD8\xFF#', $atom_structure['data'])) { 
  360. $atom_structure['image_mime'] = 'image/jpeg'; 
  361. } elseif (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $atom_structure['data'])) { 
  362. $atom_structure['image_mime'] = 'image/png'; 
  363. } elseif (preg_match('#^GIF#', $atom_structure['data'])) { 
  364. $atom_structure['image_mime'] = 'image/gif'; 
  365. break; 
  366.  
  367. break; 
  368.  
  369. default: 
  370. $info['warning'][] = 'Unknown QuickTime box type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxtype).'" ('.trim(getid3_lib::PrintHexBytes($boxtype)).') at offset '.$baseoffset; 
  371. $atom_structure['data'] = $atom_data; 
  372.  
  373. $this->CopyToAppropriateCommentsSection($atomname, $atom_structure['data'], $atom_structure['name']); 
  374. break; 
  375.  
  376.  
  377. case 'play': // auto-PLAY atom 
  378. $atom_structure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  379.  
  380. $info['quicktime']['autoplay'] = $atom_structure['autoplay']; 
  381. break; 
  382.  
  383.  
  384. case 'WLOC': // Window LOCation atom 
  385. $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); 
  386. $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); 
  387. break; 
  388.  
  389.  
  390. case 'LOOP': // LOOPing atom 
  391. case 'SelO': // play SELection Only atom 
  392. case 'AllF': // play ALL Frames atom 
  393. $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data); 
  394. break; 
  395.  
  396.  
  397. case 'name': // 
  398. case 'MCPS': // Media Cleaner PRo 
  399. case '@PRM': // adobe PReMiere version 
  400. case '@PRQ': // adobe PRemiere Quicktime version 
  401. $atom_structure['data'] = $atom_data; 
  402. break; 
  403.  
  404.  
  405. case 'cmvd': // Compressed MooV Data atom 
  406. // Code by ubergeekubergeek*tv based on information from 
  407. // http://developer.apple.com/quicktime/icefloe/dispatch012.html 
  408. $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); 
  409.  
  410. $CompressedFileData = substr($atom_data, 4); 
  411. if ($UncompressedHeader = @gzuncompress($CompressedFileData)) { 
  412. $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, 0, $atomHierarchy, $ParseAllPossibleAtoms); 
  413. } else { 
  414. $info['warning'][] = 'Error decompressing compressed MOV atom at offset '.$atom_structure['offset']; 
  415. break; 
  416.  
  417.  
  418. case 'dcom': // Data COMpression atom 
  419. $atom_structure['compression_id'] = $atom_data; 
  420. $atom_structure['compression_text'] = $this->QuicktimeDCOMLookup($atom_data); 
  421. break; 
  422.  
  423.  
  424. case 'rdrf': // Reference movie Data ReFerence atom 
  425. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  426. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); 
  427. $atom_structure['flags']['internal_data'] = (bool) ($atom_structure['flags_raw'] & 0x000001); 
  428.  
  429. $atom_structure['reference_type_name'] = substr($atom_data, 4, 4); 
  430. $atom_structure['reference_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); 
  431. switch ($atom_structure['reference_type_name']) { 
  432. case 'url ': 
  433. $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12)); 
  434. break; 
  435.  
  436. case 'alis': 
  437. $atom_structure['file_alias'] = substr($atom_data, 12); 
  438. break; 
  439.  
  440. case 'rsrc': 
  441. $atom_structure['resource_alias'] = substr($atom_data, 12); 
  442. break; 
  443.  
  444. default: 
  445. $atom_structure['data'] = substr($atom_data, 12); 
  446. break; 
  447. break; 
  448.  
  449.  
  450. case 'rmqu': // Reference Movie QUality atom 
  451. $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data); 
  452. break; 
  453.  
  454.  
  455. case 'rmcs': // Reference Movie Cpu Speed atom 
  456. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  457. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  458. $atom_structure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); 
  459. break; 
  460.  
  461.  
  462. case 'rmvc': // Reference Movie Version Check atom 
  463. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  464. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  465. $atom_structure['gestalt_selector'] = substr($atom_data, 4, 4); 
  466. $atom_structure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); 
  467. $atom_structure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4)); 
  468. $atom_structure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2)); 
  469. break; 
  470.  
  471.  
  472. case 'rmcd': // Reference Movie Component check atom 
  473. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  474. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  475. $atom_structure['component_type'] = substr($atom_data, 4, 4); 
  476. $atom_structure['component_subtype'] = substr($atom_data, 8, 4); 
  477. $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4); 
  478. $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); 
  479. $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4)); 
  480. $atom_structure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 4)); 
  481. break; 
  482.  
  483.  
  484. case 'rmdr': // Reference Movie Data Rate atom 
  485. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  486. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  487. $atom_structure['data_rate'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  488.  
  489. $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10; 
  490. break; 
  491.  
  492.  
  493. case 'rmla': // Reference Movie Language Atom 
  494. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  495. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  496. $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); 
  497.  
  498. $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); 
  499. if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { 
  500. $info['comments']['language'][] = $atom_structure['language']; 
  501. break; 
  502.  
  503.  
  504. case 'rmla': // Reference Movie Language Atom 
  505. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  506. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  507. $atom_structure['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); 
  508. break; 
  509.  
  510.  
  511. case 'ptv ': // Print To Video - defines a movie's full screen mode 
  512. // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm 
  513. $atom_structure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); 
  514. $atom_structure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); // hardcoded: 0x0000 
  515. $atom_structure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x0000 
  516. $atom_structure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 1)); 
  517. $atom_structure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 7, 1)); 
  518.  
  519. $atom_structure['flags']['play_on_open'] = (bool) $atom_structure['play_on_open_flag']; 
  520. $atom_structure['flags']['slide_show'] = (bool) $atom_structure['slide_show_flag']; 
  521.  
  522. $ptv_lookup[0] = 'normal'; 
  523. $ptv_lookup[1] = 'double'; 
  524. $ptv_lookup[2] = 'half'; 
  525. $ptv_lookup[3] = 'full'; 
  526. $ptv_lookup[4] = 'current'; 
  527. if (isset($ptv_lookup[$atom_structure['display_size_raw']])) { 
  528. $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']]; 
  529. } else { 
  530. $info['warning'][] = 'unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')'; 
  531. break; 
  532.  
  533.  
  534. case 'stsd': // Sample Table Sample Description atom 
  535. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  536. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  537. $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  538. $stsdEntriesDataOffset = 8; 
  539. for ($i = 0; $i < $atom_structure['number_entries']; $i++) { 
  540. $atom_structure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 4)); 
  541. $stsdEntriesDataOffset += 4; 
  542. $atom_structure['sample_description_table'][$i]['data_format'] = substr($atom_data, $stsdEntriesDataOffset, 4); 
  543. $stsdEntriesDataOffset += 4; 
  544. $atom_structure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 6)); 
  545. $stsdEntriesDataOffset += 6; 
  546. $atom_structure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 2)); 
  547. $stsdEntriesDataOffset += 2; 
  548. $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2)); 
  549. $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2); 
  550.  
  551. $atom_structure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 0, 2)); 
  552. $atom_structure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 2, 2)); 
  553. $atom_structure['sample_description_table'][$i]['encoder_vendor'] = substr($atom_structure['sample_description_table'][$i]['data'], 4, 4); 
  554.  
  555. switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) { 
  556.  
  557. case "\x00\x00\x00\x00": 
  558. // audio tracks 
  559. $atom_structure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 2)); 
  560. $atom_structure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 10, 2)); 
  561. $atom_structure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 2)); 
  562. $atom_structure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 14, 2)); 
  563. $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4)); 
  564.  
  565. // video tracks 
  566. // http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap3/qtff3.html 
  567. $atom_structure['sample_description_table'][$i]['temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4)); 
  568. $atom_structure['sample_description_table'][$i]['spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4)); 
  569. $atom_structure['sample_description_table'][$i]['width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2)); 
  570. $atom_structure['sample_description_table'][$i]['height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2)); 
  571. $atom_structure['sample_description_table'][$i]['resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4)); 
  572. $atom_structure['sample_description_table'][$i]['resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4)); 
  573. $atom_structure['sample_description_table'][$i]['data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 4)); 
  574. $atom_structure['sample_description_table'][$i]['frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 36, 2)); 
  575. $atom_structure['sample_description_table'][$i]['compressor_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 38, 4); 
  576. $atom_structure['sample_description_table'][$i]['pixel_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 42, 2)); 
  577. $atom_structure['sample_description_table'][$i]['color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 44, 2)); 
  578.  
  579. switch ($atom_structure['sample_description_table'][$i]['data_format']) { 
  580. case '2vuY': 
  581. case 'avc1': 
  582. case 'cvid': 
  583. case 'dvc ': 
  584. case 'dvcp': 
  585. case 'gif ': 
  586. case 'h263': 
  587. case 'jpeg': 
  588. case 'kpcd': 
  589. case 'mjpa': 
  590. case 'mjpb': 
  591. case 'mp4v': 
  592. case 'png ': 
  593. case 'raw ': 
  594. case 'rle ': 
  595. case 'rpza': 
  596. case 'smc ': 
  597. case 'SVQ1': 
  598. case 'SVQ3': 
  599. case 'tiff': 
  600. case 'v210': 
  601. case 'v216': 
  602. case 'v308': 
  603. case 'v408': 
  604. case 'v410': 
  605. case 'yuv2': 
  606. $info['fileformat'] = 'mp4'; 
  607. $info['video']['fourcc'] = $atom_structure['sample_description_table'][$i]['data_format']; 
  608. // http://www.getid3.org/phpBB3/viewtopic.php?t=1550 
  609. //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 
  610. if (!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($atom_structure['sample_description_table'][$i]['height'])) { 
  611. // assume that values stored here are more important than values stored in [tkhd] atom 
  612. $info['video']['resolution_x'] = $atom_structure['sample_description_table'][$i]['width']; 
  613. $info['video']['resolution_y'] = $atom_structure['sample_description_table'][$i]['height']; 
  614. $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x']; 
  615. $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y']; 
  616. break; 
  617.  
  618. case 'qtvr': 
  619. $info['video']['dataformat'] = 'quicktimevr'; 
  620. break; 
  621.  
  622. case 'mp4a': 
  623. default: 
  624. $info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']); 
  625. $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate']; 
  626. $info['quicktime']['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels']; 
  627. $info['quicktime']['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth']; 
  628. $info['audio']['codec'] = $info['quicktime']['audio']['codec']; 
  629. $info['audio']['sample_rate'] = $info['quicktime']['audio']['sample_rate']; 
  630. $info['audio']['channels'] = $info['quicktime']['audio']['channels']; 
  631. $info['audio']['bits_per_sample'] = $info['quicktime']['audio']['bit_depth']; 
  632. switch ($atom_structure['sample_description_table'][$i]['data_format']) { 
  633. case 'raw ': // PCM 
  634. case 'alac': // Apple Lossless Audio Codec 
  635. $info['audio']['lossless'] = true; 
  636. break; 
  637. default: 
  638. $info['audio']['lossless'] = false; 
  639. break; 
  640. break; 
  641. break; 
  642.  
  643. default: 
  644. switch ($atom_structure['sample_description_table'][$i]['data_format']) { 
  645. case 'mp4s': 
  646. $info['fileformat'] = 'mp4'; 
  647. break; 
  648.  
  649. default: 
  650. // video atom 
  651. $atom_structure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4)); 
  652. $atom_structure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4)); 
  653. $atom_structure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2)); 
  654. $atom_structure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2)); 
  655. $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4)); 
  656. $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4)); 
  657. $atom_structure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4)); 
  658. $atom_structure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 2)); 
  659. $atom_structure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 34, 1)); 
  660. $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']); 
  661. $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2)); 
  662. $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2)); 
  663.  
  664. $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color'); 
  665. $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']); 
  666.  
  667. if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') { 
  668. $info['quicktime']['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format']; 
  669. $info['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']); 
  670. $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']); 
  671. $info['quicktime']['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth']; 
  672. $info['quicktime']['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name']; 
  673.  
  674. $info['video']['codec'] = $info['quicktime']['video']['codec']; 
  675. $info['video']['bits_per_sample'] = $info['quicktime']['video']['color_depth']; 
  676. $info['video']['lossless'] = false; 
  677. $info['video']['pixel_aspect_ratio'] = (float) 1; 
  678. break; 
  679. break; 
  680. switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) { 
  681. case 'mp4a': 
  682. $info['audio']['dataformat'] = 'mp4'; 
  683. $info['quicktime']['audio']['codec'] = 'mp4'; 
  684. break; 
  685.  
  686. case '3ivx': 
  687. case '3iv1': 
  688. case '3iv2': 
  689. $info['video']['dataformat'] = '3ivx'; 
  690. break; 
  691.  
  692. case 'xvid': 
  693. $info['video']['dataformat'] = 'xvid'; 
  694. break; 
  695.  
  696. case 'mp4v': 
  697. $info['video']['dataformat'] = 'mpeg4'; 
  698. break; 
  699.  
  700. case 'divx': 
  701. case 'div1': 
  702. case 'div2': 
  703. case 'div3': 
  704. case 'div4': 
  705. case 'div5': 
  706. case 'div6': 
  707. $info['video']['dataformat'] = 'divx'; 
  708. break; 
  709.  
  710. default: 
  711. // do nothing 
  712. break; 
  713. unset($atom_structure['sample_description_table'][$i]['data']); 
  714. break; 
  715.  
  716.  
  717. case 'stts': // Sample Table Time-to-Sample atom 
  718. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  719. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  720. $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  721. $sttsEntriesDataOffset = 8; 
  722. //$FrameRateCalculatorArray = array(); 
  723. $frames_count = 0; 
  724.  
  725. $max_stts_entries_to_scan = ($info['php_memory_limit'] ? min(floor($this->getid3->memory_limit / 10000), $atom_structure['number_entries']) : $atom_structure['number_entries']); 
  726. if ($max_stts_entries_to_scan < $atom_structure['number_entries']) { 
  727. $info['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($atom_structure['number_entries'] / 1048576).'MB).'; 
  728. for ($i = 0; $i < $max_stts_entries_to_scan; $i++) { 
  729. $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4)); 
  730. $sttsEntriesDataOffset += 4; 
  731. $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4)); 
  732. $sttsEntriesDataOffset += 4; 
  733.  
  734. $frames_count += $atom_structure['time_to_sample_table'][$i]['sample_count']; 
  735.  
  736. // THIS SECTION REPLACED WITH CODE IN "stbl" ATOM 
  737. //if (!empty($info['quicktime']['time_scale']) && ($atom_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) { 
  738. // $stts_new_framerate = $info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration']; 
  739. // if ($stts_new_framerate <= 60) { 
  740. // // some atoms have durations of "1" giving a very large framerate, which probably is not right 
  741. // $info['video']['frame_rate'] = max($info['video']['frame_rate'], $stts_new_framerate); 
  742. // } 
  743. //} 
  744. // 
  745. //$FrameRateCalculatorArray[($info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count']; 
  746. $info['quicktime']['stts_framecount'][] = $frames_count; 
  747. //$sttsFramesTotal = 0; 
  748. //$sttsSecondsTotal = 0; 
  749. //foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) { 
  750. // if (($frames_per_second > 60) || ($frames_per_second < 1)) { 
  751. // // not video FPS information, probably audio information 
  752. // $sttsFramesTotal = 0; 
  753. // $sttsSecondsTotal = 0; 
  754. // break; 
  755. // } 
  756. // $sttsFramesTotal += $frame_count; 
  757. // $sttsSecondsTotal += $frame_count / $frames_per_second; 
  758. //} 
  759. //if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) { 
  760. // if (($sttsFramesTotal / $sttsSecondsTotal) > $info['video']['frame_rate']) { 
  761. // $info['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal; 
  762. // } 
  763. //} 
  764. break; 
  765.  
  766.  
  767. case 'stss': // Sample Table Sync Sample (key frames) atom 
  768. if ($ParseAllPossibleAtoms) { 
  769. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  770. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  771. $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  772. $stssEntriesDataOffset = 8; 
  773. for ($i = 0; $i < $atom_structure['number_entries']; $i++) { 
  774. $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stssEntriesDataOffset, 4)); 
  775. $stssEntriesDataOffset += 4; 
  776. break; 
  777.  
  778.  
  779. case 'stsc': // Sample Table Sample-to-Chunk atom 
  780. if ($ParseAllPossibleAtoms) { 
  781. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  782. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  783. $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  784. $stscEntriesDataOffset = 8; 
  785. for ($i = 0; $i < $atom_structure['number_entries']; $i++) { 
  786. $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4)); 
  787. $stscEntriesDataOffset += 4; 
  788. $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4)); 
  789. $stscEntriesDataOffset += 4; 
  790. $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4)); 
  791. $stscEntriesDataOffset += 4; 
  792. break; 
  793.  
  794.  
  795. case 'stsz': // Sample Table SiZe atom 
  796. if ($ParseAllPossibleAtoms) { 
  797. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  798. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  799. $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  800. $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); 
  801. $stszEntriesDataOffset = 12; 
  802. if ($atom_structure['sample_size'] == 0) { 
  803. for ($i = 0; $i < $atom_structure['number_entries']; $i++) { 
  804. $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stszEntriesDataOffset, 4)); 
  805. $stszEntriesDataOffset += 4; 
  806. break; 
  807.  
  808.  
  809. case 'stco': // Sample Table Chunk Offset atom 
  810. if ($ParseAllPossibleAtoms) { 
  811. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  812. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  813. $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  814. $stcoEntriesDataOffset = 8; 
  815. for ($i = 0; $i < $atom_structure['number_entries']; $i++) { 
  816. $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 4)); 
  817. $stcoEntriesDataOffset += 4; 
  818. break; 
  819.  
  820.  
  821. case 'co64': // Chunk Offset 64-bit (version of "stco" that supports > 2GB files) 
  822. if ($ParseAllPossibleAtoms) { 
  823. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  824. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  825. $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  826. $stcoEntriesDataOffset = 8; 
  827. for ($i = 0; $i < $atom_structure['number_entries']; $i++) { 
  828. $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 8)); 
  829. $stcoEntriesDataOffset += 8; 
  830. break; 
  831.  
  832.  
  833. case 'dref': // Data REFerence atom 
  834. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  835. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  836. $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  837. $drefDataOffset = 8; 
  838. for ($i = 0; $i < $atom_structure['number_entries']; $i++) { 
  839. $atom_structure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 4)); 
  840. $drefDataOffset += 4; 
  841. $atom_structure['data_references'][$i]['type'] = substr($atom_data, $drefDataOffset, 4); 
  842. $drefDataOffset += 4; 
  843. $atom_structure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 1)); 
  844. $drefDataOffset += 1; 
  845. $atom_structure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 3)); // hardcoded: 0x0000 
  846. $drefDataOffset += 3; 
  847. $atom_structure['data_references'][$i]['data'] = substr($atom_data, $drefDataOffset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3)); 
  848. $drefDataOffset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3); 
  849.  
  850. $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool) ($atom_structure['data_references'][$i]['flags_raw'] & 0x001); 
  851. break; 
  852.  
  853.  
  854. case 'gmin': // base Media INformation atom 
  855. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  856. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  857. $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); 
  858. $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)); 
  859. $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2)); 
  860. $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); 
  861. $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 2)); 
  862. $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2)); 
  863. break; 
  864.  
  865.  
  866. case 'smhd': // Sound Media information HeaDer atom 
  867. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  868. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  869. $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); 
  870. $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)); 
  871. break; 
  872.  
  873.  
  874. case 'vmhd': // Video Media information HeaDer atom 
  875. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  876. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); 
  877. $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); 
  878. $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)); 
  879. $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2)); 
  880. $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); 
  881.  
  882. $atom_structure['flags']['no_lean_ahead'] = (bool) ($atom_structure['flags_raw'] & 0x001); 
  883. break; 
  884.  
  885.  
  886. case 'hdlr': // HanDLeR reference atom 
  887. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  888. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  889. $atom_structure['component_type'] = substr($atom_data, 4, 4); 
  890. $atom_structure['component_subtype'] = substr($atom_data, 8, 4); 
  891. $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4); 
  892. $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); 
  893. $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4)); 
  894. $atom_structure['component_name'] = $this->Pascal2String(substr($atom_data, 24)); 
  895.  
  896. if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) { 
  897. $info['video']['dataformat'] = 'quicktimevr'; 
  898. break; 
  899.  
  900.  
  901. case 'mdhd': // MeDia HeaDer atom 
  902. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  903. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  904. $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  905. $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); 
  906. $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4)); 
  907. $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); 
  908. $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 2)); 
  909. $atom_structure['quality'] = getid3_lib::BigEndian2Int(substr($atom_data, 22, 2)); 
  910.  
  911. if ($atom_structure['time_scale'] == 0) { 
  912. $info['error'][] = 'Corrupt Quicktime file: mdhd.time_scale == zero'; 
  913. return false; 
  914. $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']); 
  915.  
  916. $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']); 
  917. $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']); 
  918. $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale']; 
  919. $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); 
  920. if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { 
  921. $info['comments']['language'][] = $atom_structure['language']; 
  922. break; 
  923.  
  924.  
  925. case 'pnot': // Preview atom 
  926. $atom_structure['modification_date'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // "standard Macintosh format" 
  927. $atom_structure['version_number'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x00 
  928. $atom_structure['atom_type'] = substr($atom_data, 6, 4); // usually: 'PICT' 
  929. $atom_structure['atom_index'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); // usually: 0x01 
  930.  
  931. $atom_structure['modification_date_unix'] = getid3_lib::DateMac2Unix($atom_structure['modification_date']); 
  932. break; 
  933.  
  934.  
  935. case 'crgn': // Clipping ReGioN atom 
  936. $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box,  
  937. $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields 
  938. $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region. 
  939. break; 
  940.  
  941.  
  942. case 'load': // track LOAD settings atom 
  943. $atom_structure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); 
  944. $atom_structure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  945. $atom_structure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); 
  946. $atom_structure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4)); 
  947.  
  948. $atom_structure['default_hints']['double_buffer'] = (bool) ($atom_structure['default_hints_raw'] & 0x0020); 
  949. $atom_structure['default_hints']['high_quality'] = (bool) ($atom_structure['default_hints_raw'] & 0x0100); 
  950. break; 
  951.  
  952.  
  953. case 'tmcd': // TiMe CoDe atom 
  954. case 'chap': // CHAPter list atom 
  955. case 'sync': // SYNChronization atom 
  956. case 'scpt': // tranSCriPT atom 
  957. case 'ssrc': // non-primary SouRCe atom 
  958. for ($i = 0; $i < strlen($atom_data); $i += 4) { 
  959. @$atom_structure['track_id'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4)); 
  960. break; 
  961.  
  962.  
  963. case 'elst': // Edit LiST atom 
  964. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  965. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  966. $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  967. for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) { 
  968. $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4)); 
  969. $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4)); 
  970. $atom_structure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4)); 
  971. break; 
  972.  
  973.  
  974. case 'kmat': // compressed MATte atom 
  975. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  976. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 
  977. $atom_structure['matte_data_raw'] = substr($atom_data, 4); 
  978. break; 
  979.  
  980.  
  981. case 'ctab': // Color TABle atom 
  982. $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000 
  983. $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000 
  984. $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1; 
  985. for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) { 
  986. $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2)); 
  987. $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2)); 
  988. $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2)); 
  989. $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2)); 
  990. break; 
  991.  
  992.  
  993. case 'mvhd': // MoVie HeaDer atom 
  994. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  995. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); 
  996. $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  997. $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); 
  998. $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4)); 
  999. $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); 
  1000. $atom_structure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 20, 4)); 
  1001. $atom_structure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 24, 2)); 
  1002. $atom_structure['reserved'] = substr($atom_data, 26, 10); 
  1003. $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 36, 4)); 
  1004. $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4)); 
  1005. $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 44, 4)); 
  1006. $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4)); 
  1007. $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4)); 
  1008. $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 56, 4)); 
  1009. $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4)); 
  1010. $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4)); 
  1011. $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4)); 
  1012. $atom_structure['preview_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 72, 4)); 
  1013. $atom_structure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 76, 4)); 
  1014. $atom_structure['poster_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 80, 4)); 
  1015. $atom_structure['selection_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 84, 4)); 
  1016. $atom_structure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 88, 4)); 
  1017. $atom_structure['current_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 92, 4)); 
  1018. $atom_structure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 96, 4)); 
  1019.  
  1020. if ($atom_structure['time_scale'] == 0) { 
  1021. $info['error'][] = 'Corrupt Quicktime file: mvhd.time_scale == zero'; 
  1022. return false; 
  1023. $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']); 
  1024. $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']); 
  1025. $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']); 
  1026. $info['quicktime']['display_scale'] = $atom_structure['matrix_a']; 
  1027. $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale']; 
  1028. break; 
  1029.  
  1030.  
  1031. case 'tkhd': // TracK HeaDer atom 
  1032. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  1033. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); 
  1034. $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  1035. $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); 
  1036. $atom_structure['trackid'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4)); 
  1037. $atom_structure['reserved1'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); 
  1038. $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4)); 
  1039. $atom_structure['reserved2'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 8)); 
  1040. $atom_structure['layer'] = getid3_lib::BigEndian2Int(substr($atom_data, 32, 2)); 
  1041. $atom_structure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atom_data, 34, 2)); 
  1042. $atom_structure['volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 36, 2)); 
  1043. $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2)); 
  1044. // http://developer.apple.com/library/mac/#documentation/QuickTime/RM/MovieBasics/MTEditing/K-Chapter/11MatrixFunctions.html 
  1045. // http://developer.apple.com/library/mac/#documentation/QuickTime/qtff/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-18737 
  1046. $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4)); 
  1047. $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 44, 4)); 
  1048. $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 48, 4)); 
  1049. $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4)); 
  1050. $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 56, 4)); 
  1051. $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 60, 4)); 
  1052. $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4)); 
  1053. $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 68, 4)); 
  1054. $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 72, 4)); 
  1055. $atom_structure['width'] = getid3_lib::FixedPoint16_16(substr($atom_data, 76, 4)); 
  1056. $atom_structure['height'] = getid3_lib::FixedPoint16_16(substr($atom_data, 80, 4)); 
  1057. $atom_structure['flags']['enabled'] = (bool) ($atom_structure['flags_raw'] & 0x0001); 
  1058. $atom_structure['flags']['in_movie'] = (bool) ($atom_structure['flags_raw'] & 0x0002); 
  1059. $atom_structure['flags']['in_preview'] = (bool) ($atom_structure['flags_raw'] & 0x0004); 
  1060. $atom_structure['flags']['in_poster'] = (bool) ($atom_structure['flags_raw'] & 0x0008); 
  1061. $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']); 
  1062. $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']); 
  1063.  
  1064. if ($atom_structure['flags']['enabled'] == 1) { 
  1065. if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) { 
  1066. $info['video']['resolution_x'] = $atom_structure['width']; 
  1067. $info['video']['resolution_y'] = $atom_structure['height']; 
  1068. $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']); 
  1069. $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']); 
  1070. $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x']; 
  1071. $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y']; 
  1072. } else { 
  1073. // see: http://www.getid3.org/phpBB3/viewtopic.php?t=1295 
  1074. //if (isset($info['video']['resolution_x'])) { unset($info['video']['resolution_x']); } 
  1075. //if (isset($info['video']['resolution_y'])) { unset($info['video']['resolution_y']); } 
  1076. //if (isset($info['quicktime']['video'])) { unset($info['quicktime']['video']); } 
  1077. break; 
  1078.  
  1079.  
  1080. case 'iods': // Initial Object DeScriptor atom 
  1081. // http://www.koders.com/c/fid1FAB3E762903DC482D8A246D4A4BF9F28E049594.aspx?s=windows.h 
  1082. // http://libquicktime.sourcearchive.com/documentation/1.0.2plus-pdebian/iods_8c-source.html 
  1083. $offset = 0; 
  1084. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); 
  1085. $offset += 1; 
  1086. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 3)); 
  1087. $offset += 3; 
  1088. $atom_structure['mp4_iod_tag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); 
  1089. $offset += 1; 
  1090. $atom_structure['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset); 
  1091. //$offset already adjusted by quicktime_read_mp4_descr_length() 
  1092. $atom_structure['object_descriptor_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); 
  1093. $offset += 2; 
  1094. $atom_structure['od_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); 
  1095. $offset += 1; 
  1096. $atom_structure['scene_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); 
  1097. $offset += 1; 
  1098. $atom_structure['audio_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); 
  1099. $offset += 1; 
  1100. $atom_structure['video_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); 
  1101. $offset += 1; 
  1102. $atom_structure['graphics_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); 
  1103. $offset += 1; 
  1104.  
  1105. $atom_structure['num_iods_tracks'] = ($atom_structure['length'] - 7) / 6; // 6 bytes would only be right if all tracks use 1-byte length fields 
  1106. for ($i = 0; $i < $atom_structure['num_iods_tracks']; $i++) { 
  1107. $atom_structure['track'][$i]['ES_ID_IncTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); 
  1108. $offset += 1; 
  1109. $atom_structure['track'][$i]['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset); 
  1110. //$offset already adjusted by quicktime_read_mp4_descr_length() 
  1111. $atom_structure['track'][$i]['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4)); 
  1112. $offset += 4; 
  1113.  
  1114. $atom_structure['audio_profile_name'] = $this->QuicktimeIODSaudioProfileName($atom_structure['audio_profile_id']); 
  1115. $atom_structure['video_profile_name'] = $this->QuicktimeIODSvideoProfileName($atom_structure['video_profile_id']); 
  1116. break; 
  1117.  
  1118. case 'ftyp': // FileTYPe (?) atom (for MP4 it seems) 
  1119. $atom_structure['signature'] = substr($atom_data, 0, 4); 
  1120. $atom_structure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 
  1121. $atom_structure['fourcc'] = substr($atom_data, 8, 4); 
  1122. break; 
  1123.  
  1124. case 'mdat': // Media DATa atom 
  1125. // 'mdat' contains the actual data for the audio/video, possibly also subtitles 
  1126.  
  1127. /** 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 info@getid3.org */ 
  1128.  
  1129. // first, skip any 'wide' padding, and second 'mdat' header (with specified size of zero?) 
  1130. $mdat_offset = 0; 
  1131. while (true) { 
  1132. if (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x08".'wide') { 
  1133. $mdat_offset += 8; 
  1134. } elseif (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x00".'mdat') { 
  1135. $mdat_offset += 8; 
  1136. } else { 
  1137. break; 
  1138.  
  1139. // check to see if it looks like chapter titles, in the form of unterminated strings with a leading 16-bit size field 
  1140. while (($chapter_string_length = getid3_lib::BigEndian2Int(substr($atom_data, $mdat_offset, 2))) 
  1141. && ($chapter_string_length < 1000) 
  1142. && ($chapter_string_length <= (strlen($atom_data) - $mdat_offset - 2)) 
  1143. && preg_match('#^[\x20-\xFF]+$#', substr($atom_data, $mdat_offset + 2, $chapter_string_length), $chapter_matches)) { 
  1144. $mdat_offset += (2 + $chapter_string_length); 
  1145. @$info['quicktime']['comments']['chapters'][] = $chapter_matches[0]; 
  1146.  
  1147.  
  1148.  
  1149. if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) { 
  1150.  
  1151. $info['avdataoffset'] = $atom_structure['offset'] + 8; // $info['quicktime'][$atomname]['offset'] + 8; 
  1152. $OldAVDataEnd = $info['avdataend']; 
  1153. $info['avdataend'] = $atom_structure['offset'] + $atom_structure['size']; // $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size']; 
  1154.  
  1155. $getid3_temp = new getID3(); 
  1156. $getid3_temp->openfile($this->getid3->filename); 
  1157. $getid3_temp->info['avdataoffset'] = $info['avdataoffset']; 
  1158. $getid3_temp->info['avdataend'] = $info['avdataend']; 
  1159. $getid3_mp3 = new getid3_mp3($getid3_temp); 
  1160. if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode($this->fread(4)))) { 
  1161. $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false); 
  1162. if (!empty($getid3_temp->info['warning'])) { 
  1163. foreach ($getid3_temp->info['warning'] as $value) { 
  1164. $info['warning'][] = $value; 
  1165. if (!empty($getid3_temp->info['mpeg'])) { 
  1166. $info['mpeg'] = $getid3_temp->info['mpeg']; 
  1167. if (isset($info['mpeg']['audio'])) { 
  1168. $info['audio']['dataformat'] = 'mp3'; 
  1169. $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'))); 
  1170. $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate']; 
  1171. $info['audio']['channels'] = $info['mpeg']['audio']['channels']; 
  1172. $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate']; 
  1173. $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']); 
  1174. $info['bitrate'] = $info['audio']['bitrate']; 
  1175. unset($getid3_mp3, $getid3_temp); 
  1176. $info['avdataend'] = $OldAVDataEnd; 
  1177. unset($OldAVDataEnd); 
  1178.  
  1179.  
  1180. unset($mdat_offset, $chapter_string_length, $chapter_matches); 
  1181. break; 
  1182.  
  1183. case 'free': // FREE space atom 
  1184. case 'skip': // SKIP atom 
  1185. case 'wide': // 64-bit expansion placeholder atom 
  1186. // 'free', 'skip' and 'wide' are just padding, contains no useful data at all 
  1187.  
  1188. // When writing QuickTime files, it is sometimes necessary to update an atom's size. 
  1189. // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom 
  1190. // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime 
  1191. // puts an 8-byte placeholder atom before any atoms it may have to update the size of. 
  1192. // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the 
  1193. // placeholder atom can be overwritten to obtain the necessary 8 extra bytes. 
  1194. // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ). 
  1195. break; 
  1196.  
  1197.  
  1198. case 'nsav': // NoSAVe atom 
  1199. // http://developer.apple.com/technotes/tn/tn2038.html 
  1200. $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); 
  1201. break; 
  1202.  
  1203. case 'ctyp': // Controller TYPe atom (seen on QTVR) 
  1204. // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt 
  1205. // some controller names are: 
  1206. // 0x00 + 'std' for linear movie 
  1207. // 'none' for no controls 
  1208. $atom_structure['ctyp'] = substr($atom_data, 0, 4); 
  1209. $info['quicktime']['controller'] = $atom_structure['ctyp']; 
  1210. switch ($atom_structure['ctyp']) { 
  1211. case 'qtvr': 
  1212. $info['video']['dataformat'] = 'quicktimevr'; 
  1213. break; 
  1214. break; 
  1215.  
  1216. case 'pano': // PANOrama track (seen on QTVR) 
  1217. $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); 
  1218. break; 
  1219.  
  1220. case 'hint': // HINT track 
  1221. case 'hinf': // 
  1222. case 'hinv': // 
  1223. case 'hnti': // 
  1224. $info['quicktime']['hinting'] = true; 
  1225. break; 
  1226.  
  1227. case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR) 
  1228. for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) { 
  1229. $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4)); 
  1230. break; 
  1231.  
  1232.  
  1233. // Observed-but-not-handled atom types are just listed here to prevent warnings being generated 
  1234. case 'FXTC': // Something to do with Adobe After Effects (?) 
  1235. case 'PrmA': 
  1236. case 'code': 
  1237. case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html 
  1238. case 'tapt': // TrackApertureModeDimensionsAID - http://developer.apple.com/documentation/QuickTime/Reference/QT7-1_Update_Reference/Constants/Constants.html 
  1239. // tapt seems to be used to compute the video size [http://www.getid3.org/phpBB3/viewtopic.php?t=838] 
  1240. // * http://lists.apple.com/archives/quicktime-api/2006/Aug/msg00014.html 
  1241. // * http://handbrake.fr/irclogs/handbrake-dev/handbrake-dev20080128_pg2.html 
  1242. case 'ctts':// STCompositionOffsetAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html 
  1243. case 'cslg':// STCompositionShiftLeastGreatestAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html 
  1244. case 'sdtp':// STSampleDependencyAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html 
  1245. case 'stps':// STPartialSyncSampleAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html 
  1246. //$atom_structure['data'] = $atom_data; 
  1247. break; 
  1248.  
  1249. case "\xA9".'xyz': // GPS latitude+longitude+altitude 
  1250. $atom_structure['data'] = $atom_data; 
  1251. if (preg_match('#([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)?/$#i', $atom_data, $matches)) { 
  1252. @list($all, $latitude, $longitude, $altitude) = $matches; 
  1253. $info['quicktime']['comments']['gps_latitude'][] = floatval($latitude); 
  1254. $info['quicktime']['comments']['gps_longitude'][] = floatval($longitude); 
  1255. if (!empty($altitude)) { 
  1256. $info['quicktime']['comments']['gps_altitude'][] = floatval($altitude); 
  1257. } else { 
  1258. $info['warning'][] = 'QuickTime atom "xyz" data does not match expected data pattern at offset '.$baseoffset.'. Please report as getID3() bug.'; 
  1259. break; 
  1260.  
  1261. case 'NCDT': 
  1262. // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html 
  1263. // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100 
  1264. $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 4, $atomHierarchy, $ParseAllPossibleAtoms); 
  1265. break; 
  1266. case 'NCTH': // Nikon Camera THumbnail image 
  1267. case 'NCVW': // Nikon Camera preVieW image 
  1268. // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html 
  1269. if (preg_match('/^\xFF\xD8\xFF/', $atom_data)) { 
  1270. $atom_structure['data'] = $atom_data; 
  1271. $atom_structure['image_mime'] = 'image/jpeg'; 
  1272. $atom_structure['description'] = (($atomname == 'NCTH') ? 'Nikon Camera Thumbnail Image' : (($atomname == 'NCVW') ? 'Nikon Camera Preview Image' : 'Nikon preview image')); 
  1273. $info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_data, 'description'=>$atom_structure['description']); 
  1274. break; 
  1275. case 'NCTG': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG 
  1276. $atom_structure['data'] = $this->QuicktimeParseNikonNCTG($atom_data); 
  1277. break; 
  1278. case 'NCHD': // Nikon:MakerNoteVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html 
  1279. case 'NCDB': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html 
  1280. case 'CNCV': // Canon:CompressorVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html 
  1281. $atom_structure['data'] = $atom_data; 
  1282. break; 
  1283.  
  1284. case "\x00\x00\x00\x00": 
  1285. case 'meta': // METAdata atom 
  1286. // some kind of metacontainer, may contain a big data dump such as: 
  1287. // 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 
  1288. // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt 
  1289.  
  1290. $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 
  1291. $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); 
  1292. $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_data, 4), $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); 
  1293. //$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); 
  1294. break; 
  1295.  
  1296. case 'data': // metaDATA atom 
  1297. // seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in sample I have), remainder is useful data 
  1298. $atom_structure['language'] = substr($atom_data, 4 + 0, 2); 
  1299. $atom_structure['unknown'] = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2)); 
  1300. $atom_structure['data'] = substr($atom_data, 4 + 4); 
  1301. break; 
  1302.  
  1303. default: 
  1304. $info['warning'][] = 'Unknown QuickTime atom type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" ('.trim(getid3_lib::PrintHexBytes($atomname)).') at offset '.$baseoffset; 
  1305. $atom_structure['data'] = $atom_data; 
  1306. break; 
  1307. array_pop($atomHierarchy); 
  1308. return $atom_structure; 
  1309.  
  1310. public function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) { 
  1311. //echo 'QuicktimeParseContainerAtom('.substr($atom_data, 4, 4).') @ '.$baseoffset.'<br><br>'; 
  1312. $atom_structure = false; 
  1313. $subatomoffset = 0; 
  1314. $subatomcounter = 0; 
  1315. if ((strlen($atom_data) == 4) && (getid3_lib::BigEndian2Int($atom_data) == 0x00000000)) { 
  1316. return false; 
  1317. while ($subatomoffset < strlen($atom_data)) { 
  1318. $subatomsize = getid3_lib::BigEndian2Int(substr($atom_data, $subatomoffset + 0, 4)); 
  1319. $subatomname = substr($atom_data, $subatomoffset + 4, 4); 
  1320. $subatomdata = substr($atom_data, $subatomoffset + 8, $subatomsize - 8); 
  1321. if ($subatomsize == 0) { 
  1322. // Furthermore, for historical reasons the list of atoms is optionally 
  1323. // terminated by a 32-bit integer set to 0. If you are writing a program 
  1324. // to read user data atoms, you should allow for the terminating 0. 
  1325. return $atom_structure; 
  1326.  
  1327. $atom_structure[$subatomcounter] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms); 
  1328.  
  1329. $subatomoffset += $subatomsize; 
  1330. $subatomcounter++; 
  1331. return $atom_structure; 
  1332.  
  1333.  
  1334. public function quicktime_read_mp4_descr_length($data, &$offset) { 
  1335. // http://libquicktime.sourcearchive.com/documentation/2:1.0.2plus-pdebian-2build1/esds_8c-source.html 
  1336. $num_bytes = 0; 
  1337. $length = 0; 
  1338. do { 
  1339. $b = ord(substr($data, $offset++, 1)); 
  1340. $length = ($length << 7) | ($b & 0x7F); 
  1341. } while (($b & 0x80) && ($num_bytes++ < 4)); 
  1342. return $length; 
  1343.  
  1344.  
  1345. public function QuicktimeLanguageLookup($languageid) { 
  1346. // http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-34353 
  1347. static $QuicktimeLanguageLookup = array(); 
  1348. if (empty($QuicktimeLanguageLookup)) { 
  1349. $QuicktimeLanguageLookup[0] = 'English'; 
  1350. $QuicktimeLanguageLookup[1] = 'French'; 
  1351. $QuicktimeLanguageLookup[2] = 'German'; 
  1352. $QuicktimeLanguageLookup[3] = 'Italian'; 
  1353. $QuicktimeLanguageLookup[4] = 'Dutch'; 
  1354. $QuicktimeLanguageLookup[5] = 'Swedish'; 
  1355. $QuicktimeLanguageLookup[6] = 'Spanish'; 
  1356. $QuicktimeLanguageLookup[7] = 'Danish'; 
  1357. $QuicktimeLanguageLookup[8] = 'Portuguese'; 
  1358. $QuicktimeLanguageLookup[9] = 'Norwegian'; 
  1359. $QuicktimeLanguageLookup[10] = 'Hebrew'; 
  1360. $QuicktimeLanguageLookup[11] = 'Japanese'; 
  1361. $QuicktimeLanguageLookup[12] = 'Arabic'; 
  1362. $QuicktimeLanguageLookup[13] = 'Finnish'; 
  1363. $QuicktimeLanguageLookup[14] = 'Greek'; 
  1364. $QuicktimeLanguageLookup[15] = 'Icelandic'; 
  1365. $QuicktimeLanguageLookup[16] = 'Maltese'; 
  1366. $QuicktimeLanguageLookup[17] = 'Turkish'; 
  1367. $QuicktimeLanguageLookup[18] = 'Croatian'; 
  1368. $QuicktimeLanguageLookup[19] = 'Chinese (Traditional)'; 
  1369. $QuicktimeLanguageLookup[20] = 'Urdu'; 
  1370. $QuicktimeLanguageLookup[21] = 'Hindi'; 
  1371. $QuicktimeLanguageLookup[22] = 'Thai'; 
  1372. $QuicktimeLanguageLookup[23] = 'Korean'; 
  1373. $QuicktimeLanguageLookup[24] = 'Lithuanian'; 
  1374. $QuicktimeLanguageLookup[25] = 'Polish'; 
  1375. $QuicktimeLanguageLookup[26] = 'Hungarian'; 
  1376. $QuicktimeLanguageLookup[27] = 'Estonian'; 
  1377. $QuicktimeLanguageLookup[28] = 'Lettish'; 
  1378. $QuicktimeLanguageLookup[28] = 'Latvian'; 
  1379. $QuicktimeLanguageLookup[29] = 'Saamisk'; 
  1380. $QuicktimeLanguageLookup[29] = 'Lappish'; 
  1381. $QuicktimeLanguageLookup[30] = 'Faeroese'; 
  1382. $QuicktimeLanguageLookup[31] = 'Farsi'; 
  1383. $QuicktimeLanguageLookup[31] = 'Persian'; 
  1384. $QuicktimeLanguageLookup[32] = 'Russian'; 
  1385. $QuicktimeLanguageLookup[33] = 'Chinese (Simplified)'; 
  1386. $QuicktimeLanguageLookup[34] = 'Flemish'; 
  1387. $QuicktimeLanguageLookup[35] = 'Irish'; 
  1388. $QuicktimeLanguageLookup[36] = 'Albanian'; 
  1389. $QuicktimeLanguageLookup[37] = 'Romanian'; 
  1390. $QuicktimeLanguageLookup[38] = 'Czech'; 
  1391. $QuicktimeLanguageLookup[39] = 'Slovak'; 
  1392. $QuicktimeLanguageLookup[40] = 'Slovenian'; 
  1393. $QuicktimeLanguageLookup[41] = 'Yiddish'; 
  1394. $QuicktimeLanguageLookup[42] = 'Serbian'; 
  1395. $QuicktimeLanguageLookup[43] = 'Macedonian'; 
  1396. $QuicktimeLanguageLookup[44] = 'Bulgarian'; 
  1397. $QuicktimeLanguageLookup[45] = 'Ukrainian'; 
  1398. $QuicktimeLanguageLookup[46] = 'Byelorussian'; 
  1399. $QuicktimeLanguageLookup[47] = 'Uzbek'; 
  1400. $QuicktimeLanguageLookup[48] = 'Kazakh'; 
  1401. $QuicktimeLanguageLookup[49] = 'Azerbaijani'; 
  1402. $QuicktimeLanguageLookup[50] = 'AzerbaijanAr'; 
  1403. $QuicktimeLanguageLookup[51] = 'Armenian'; 
  1404. $QuicktimeLanguageLookup[52] = 'Georgian'; 
  1405. $QuicktimeLanguageLookup[53] = 'Moldavian'; 
  1406. $QuicktimeLanguageLookup[54] = 'Kirghiz'; 
  1407. $QuicktimeLanguageLookup[55] = 'Tajiki'; 
  1408. $QuicktimeLanguageLookup[56] = 'Turkmen'; 
  1409. $QuicktimeLanguageLookup[57] = 'Mongolian'; 
  1410. $QuicktimeLanguageLookup[58] = 'MongolianCyr'; 
  1411. $QuicktimeLanguageLookup[59] = 'Pashto'; 
  1412. $QuicktimeLanguageLookup[60] = 'Kurdish'; 
  1413. $QuicktimeLanguageLookup[61] = 'Kashmiri'; 
  1414. $QuicktimeLanguageLookup[62] = 'Sindhi'; 
  1415. $QuicktimeLanguageLookup[63] = 'Tibetan'; 
  1416. $QuicktimeLanguageLookup[64] = 'Nepali'; 
  1417. $QuicktimeLanguageLookup[65] = 'Sanskrit'; 
  1418. $QuicktimeLanguageLookup[66] = 'Marathi'; 
  1419. $QuicktimeLanguageLookup[67] = 'Bengali'; 
  1420. $QuicktimeLanguageLookup[68] = 'Assamese'; 
  1421. $QuicktimeLanguageLookup[69] = 'Gujarati'; 
  1422. $QuicktimeLanguageLookup[70] = 'Punjabi'; 
  1423. $QuicktimeLanguageLookup[71] = 'Oriya'; 
  1424. $QuicktimeLanguageLookup[72] = 'Malayalam'; 
  1425. $QuicktimeLanguageLookup[73] = 'Kannada'; 
  1426. $QuicktimeLanguageLookup[74] = 'Tamil'; 
  1427. $QuicktimeLanguageLookup[75] = 'Telugu'; 
  1428. $QuicktimeLanguageLookup[76] = 'Sinhalese'; 
  1429. $QuicktimeLanguageLookup[77] = 'Burmese'; 
  1430. $QuicktimeLanguageLookup[78] = 'Khmer'; 
  1431. $QuicktimeLanguageLookup[79] = 'Lao'; 
  1432. $QuicktimeLanguageLookup[80] = 'Vietnamese'; 
  1433. $QuicktimeLanguageLookup[81] = 'Indonesian'; 
  1434. $QuicktimeLanguageLookup[82] = 'Tagalog'; 
  1435. $QuicktimeLanguageLookup[83] = 'MalayRoman'; 
  1436. $QuicktimeLanguageLookup[84] = 'MalayArabic'; 
  1437. $QuicktimeLanguageLookup[85] = 'Amharic'; 
  1438. $QuicktimeLanguageLookup[86] = 'Tigrinya'; 
  1439. $QuicktimeLanguageLookup[87] = 'Galla'; 
  1440. $QuicktimeLanguageLookup[87] = 'Oromo'; 
  1441. $QuicktimeLanguageLookup[88] = 'Somali'; 
  1442. $QuicktimeLanguageLookup[89] = 'Swahili'; 
  1443. $QuicktimeLanguageLookup[90] = 'Ruanda'; 
  1444. $QuicktimeLanguageLookup[91] = 'Rundi'; 
  1445. $QuicktimeLanguageLookup[92] = 'Chewa'; 
  1446. $QuicktimeLanguageLookup[93] = 'Malagasy'; 
  1447. $QuicktimeLanguageLookup[94] = 'Esperanto'; 
  1448. $QuicktimeLanguageLookup[128] = 'Welsh'; 
  1449. $QuicktimeLanguageLookup[129] = 'Basque'; 
  1450. $QuicktimeLanguageLookup[130] = 'Catalan'; 
  1451. $QuicktimeLanguageLookup[131] = 'Latin'; 
  1452. $QuicktimeLanguageLookup[132] = 'Quechua'; 
  1453. $QuicktimeLanguageLookup[133] = 'Guarani'; 
  1454. $QuicktimeLanguageLookup[134] = 'Aymara'; 
  1455. $QuicktimeLanguageLookup[135] = 'Tatar'; 
  1456. $QuicktimeLanguageLookup[136] = 'Uighur'; 
  1457. $QuicktimeLanguageLookup[137] = 'Dzongkha'; 
  1458. $QuicktimeLanguageLookup[138] = 'JavaneseRom'; 
  1459. $QuicktimeLanguageLookup[32767] = 'Unspecified'; 
  1460. if (($languageid > 138) && ($languageid < 32767)) { 
  1461. /** 
  1462. ISO Language Codes - http://www.loc.gov/standards/iso639-2/php/code_list.php 
  1463. Because the language codes specified by ISO 639-2/T are three characters long, they must be packed to fit into a 16-bit field. 
  1464. The packing algorithm must map each of the three characters, which are always lowercase, into a 5-bit integer and then concatenate 
  1465. these integers into the least significant 15 bits of a 16-bit integer, leaving the 16-bit integer's most significant bit set to zero. 
  1466.   
  1467. One algorithm for performing this packing is to treat each ISO character as a 16-bit integer. Subtract 0x60 from the first character 
  1468. and multiply by 2^10 (0x400), subtract 0x60 from the second character and multiply by 2^5 (0x20), subtract 0x60 from the third character,  
  1469. and add the three 16-bit values. This will result in a single 16-bit value with the three codes correctly packed into the 15 least 
  1470. significant bits and the most significant bit set to zero. 
  1471. */ 
  1472. $iso_language_id = ''; 
  1473. $iso_language_id .= chr((($languageid & 0x7C00) >> 10) + 0x60); 
  1474. $iso_language_id .= chr((($languageid & 0x03E0) >> 5) + 0x60); 
  1475. $iso_language_id .= chr((($languageid & 0x001F) >> 0) + 0x60); 
  1476. $QuicktimeLanguageLookup[$languageid] = getid3_id3v2::LanguageLookup($iso_language_id); 
  1477. return (isset($QuicktimeLanguageLookup[$languageid]) ? $QuicktimeLanguageLookup[$languageid] : 'invalid'); 
  1478.  
  1479. public function QuicktimeVideoCodecLookup($codecid) { 
  1480. static $QuicktimeVideoCodecLookup = array(); 
  1481. if (empty($QuicktimeVideoCodecLookup)) { 
  1482. $QuicktimeVideoCodecLookup['.SGI'] = 'SGI'; 
  1483. $QuicktimeVideoCodecLookup['3IV1'] = '3ivx MPEG-4 v1'; 
  1484. $QuicktimeVideoCodecLookup['3IV2'] = '3ivx MPEG-4 v2'; 
  1485. $QuicktimeVideoCodecLookup['3IVX'] = '3ivx MPEG-4'; 
  1486. $QuicktimeVideoCodecLookup['8BPS'] = 'Planar RGB'; 
  1487. $QuicktimeVideoCodecLookup['avc1'] = 'H.264/MPEG-4 AVC'; 
  1488. $QuicktimeVideoCodecLookup['avr '] = 'AVR-JPEG'; 
  1489. $QuicktimeVideoCodecLookup['b16g'] = '16Gray'; 
  1490. $QuicktimeVideoCodecLookup['b32a'] = '32AlphaGray'; 
  1491. $QuicktimeVideoCodecLookup['b48r'] = '48RGB'; 
  1492. $QuicktimeVideoCodecLookup['b64a'] = '64ARGB'; 
  1493. $QuicktimeVideoCodecLookup['base'] = 'Base'; 
  1494. $QuicktimeVideoCodecLookup['clou'] = 'Cloud'; 
  1495. $QuicktimeVideoCodecLookup['cmyk'] = 'CMYK'; 
  1496. $QuicktimeVideoCodecLookup['cvid'] = 'Cinepak'; 
  1497. $QuicktimeVideoCodecLookup['dmb1'] = 'OpenDML JPEG'; 
  1498. $QuicktimeVideoCodecLookup['dvc '] = 'DVC-NTSC'; 
  1499. $QuicktimeVideoCodecLookup['dvcp'] = 'DVC-PAL'; 
  1500. $QuicktimeVideoCodecLookup['dvpn'] = 'DVCPro-NTSC'; 
  1501. $QuicktimeVideoCodecLookup['dvpp'] = 'DVCPro-PAL'; 
  1502. $QuicktimeVideoCodecLookup['fire'] = 'Fire'; 
  1503. $QuicktimeVideoCodecLookup['flic'] = 'FLC'; 
  1504. $QuicktimeVideoCodecLookup['gif '] = 'GIF'; 
  1505. $QuicktimeVideoCodecLookup['h261'] = 'H261'; 
  1506. $QuicktimeVideoCodecLookup['h263'] = 'H263'; 
  1507. $QuicktimeVideoCodecLookup['IV41'] = 'Indeo4'; 
  1508. $QuicktimeVideoCodecLookup['jpeg'] = 'JPEG'; 
  1509. $QuicktimeVideoCodecLookup['kpcd'] = 'PhotoCD'; 
  1510. $QuicktimeVideoCodecLookup['mjpa'] = 'Motion JPEG-A'; 
  1511. $QuicktimeVideoCodecLookup['mjpb'] = 'Motion JPEG-B'; 
  1512. $QuicktimeVideoCodecLookup['msvc'] = 'Microsoft Video1'; 
  1513. $QuicktimeVideoCodecLookup['myuv'] = 'MPEG YUV420'; 
  1514. $QuicktimeVideoCodecLookup['path'] = 'Vector'; 
  1515. $QuicktimeVideoCodecLookup['png '] = 'PNG'; 
  1516. $QuicktimeVideoCodecLookup['PNTG'] = 'MacPaint'; 
  1517. $QuicktimeVideoCodecLookup['qdgx'] = 'QuickDrawGX'; 
  1518. $QuicktimeVideoCodecLookup['qdrw'] = 'QuickDraw'; 
  1519. $QuicktimeVideoCodecLookup['raw '] = 'RAW'; 
  1520. $QuicktimeVideoCodecLookup['ripl'] = 'WaterRipple'; 
  1521. $QuicktimeVideoCodecLookup['rpza'] = 'Video'; 
  1522. $QuicktimeVideoCodecLookup['smc '] = 'Graphics'; 
  1523. $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 1'; 
  1524. $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 3'; 
  1525. $QuicktimeVideoCodecLookup['syv9'] = 'Sorenson YUV9'; 
  1526. $QuicktimeVideoCodecLookup['tga '] = 'Targa'; 
  1527. $QuicktimeVideoCodecLookup['tiff'] = 'TIFF'; 
  1528. $QuicktimeVideoCodecLookup['WRAW'] = 'Windows RAW'; 
  1529. $QuicktimeVideoCodecLookup['WRLE'] = 'BMP'; 
  1530. $QuicktimeVideoCodecLookup['y420'] = 'YUV420'; 
  1531. $QuicktimeVideoCodecLookup['yuv2'] = 'ComponentVideo'; 
  1532. $QuicktimeVideoCodecLookup['yuvs'] = 'ComponentVideoUnsigned'; 
  1533. $QuicktimeVideoCodecLookup['yuvu'] = 'ComponentVideoSigned'; 
  1534. return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : ''); 
  1535.  
  1536. public function QuicktimeAudioCodecLookup($codecid) { 
  1537. static $QuicktimeAudioCodecLookup = array(); 
  1538. if (empty($QuicktimeAudioCodecLookup)) { 
  1539. $QuicktimeAudioCodecLookup['.mp3'] = 'Fraunhofer MPEG Layer-III alias'; 
  1540. $QuicktimeAudioCodecLookup['aac '] = 'ISO/IEC 14496-3 AAC'; 
  1541. $QuicktimeAudioCodecLookup['agsm'] = 'Apple GSM 10:1'; 
  1542. $QuicktimeAudioCodecLookup['alac'] = 'Apple Lossless Audio Codec'; 
  1543. $QuicktimeAudioCodecLookup['alaw'] = 'A-law 2:1'; 
  1544. $QuicktimeAudioCodecLookup['conv'] = 'Sample Format'; 
  1545. $QuicktimeAudioCodecLookup['dvca'] = 'DV'; 
  1546. $QuicktimeAudioCodecLookup['dvi '] = 'DV 4:1'; 
  1547. $QuicktimeAudioCodecLookup['eqal'] = 'Frequency Equalizer'; 
  1548. $QuicktimeAudioCodecLookup['fl32'] = '32-bit Floating Point'; 
  1549. $QuicktimeAudioCodecLookup['fl64'] = '64-bit Floating Point'; 
  1550. $QuicktimeAudioCodecLookup['ima4'] = 'Interactive Multimedia Association 4:1'; 
  1551. $QuicktimeAudioCodecLookup['in24'] = '24-bit Integer'; 
  1552. $QuicktimeAudioCodecLookup['in32'] = '32-bit Integer'; 
  1553. $QuicktimeAudioCodecLookup['lpc '] = 'LPC 23:1'; 
  1554. $QuicktimeAudioCodecLookup['MAC3'] = 'Macintosh Audio Compression/Expansion (MACE) 3:1'; 
  1555. $QuicktimeAudioCodecLookup['MAC6'] = 'Macintosh Audio Compression/Expansion (MACE) 6:1'; 
  1556. $QuicktimeAudioCodecLookup['mixb'] = '8-bit Mixer'; 
  1557. $QuicktimeAudioCodecLookup['mixw'] = '16-bit Mixer'; 
  1558. $QuicktimeAudioCodecLookup['mp4a'] = 'ISO/IEC 14496-3 AAC'; 
  1559. $QuicktimeAudioCodecLookup['MS'."\x00\x02"] = 'Microsoft ADPCM'; 
  1560. $QuicktimeAudioCodecLookup['MS'."\x00\x11"] = 'DV IMA'; 
  1561. $QuicktimeAudioCodecLookup['MS'."\x00\x55"] = 'Fraunhofer MPEG Layer III'; 
  1562. $QuicktimeAudioCodecLookup['NONE'] = 'No Encoding'; 
  1563. $QuicktimeAudioCodecLookup['Qclp'] = 'Qualcomm PureVoice'; 
  1564. $QuicktimeAudioCodecLookup['QDM2'] = 'QDesign Music 2'; 
  1565. $QuicktimeAudioCodecLookup['QDMC'] = 'QDesign Music 1'; 
  1566. $QuicktimeAudioCodecLookup['ratb'] = '8-bit Rate'; 
  1567. $QuicktimeAudioCodecLookup['ratw'] = '16-bit Rate'; 
  1568. $QuicktimeAudioCodecLookup['raw '] = 'raw PCM'; 
  1569. $QuicktimeAudioCodecLookup['sour'] = 'Sound Source'; 
  1570. $QuicktimeAudioCodecLookup['sowt'] = 'signed/two\'s complement (Little Endian)'; 
  1571. $QuicktimeAudioCodecLookup['str1'] = 'Iomega MPEG layer II'; 
  1572. $QuicktimeAudioCodecLookup['str2'] = 'Iomega MPEG *layer II'; 
  1573. $QuicktimeAudioCodecLookup['str3'] = 'Iomega MPEG **layer II'; 
  1574. $QuicktimeAudioCodecLookup['str4'] = 'Iomega MPEG ***layer II'; 
  1575. $QuicktimeAudioCodecLookup['twos'] = 'signed/two\'s complement (Big Endian)'; 
  1576. $QuicktimeAudioCodecLookup['ulaw'] = 'mu-law 2:1'; 
  1577. return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : ''); 
  1578.  
  1579. public function QuicktimeDCOMLookup($compressionid) { 
  1580. static $QuicktimeDCOMLookup = array(); 
  1581. if (empty($QuicktimeDCOMLookup)) { 
  1582. $QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate'; 
  1583. $QuicktimeDCOMLookup['adec'] = 'Apple Compression'; 
  1584. return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : ''); 
  1585.  
  1586. public function QuicktimeColorNameLookup($colordepthid) { 
  1587. static $QuicktimeColorNameLookup = array(); 
  1588. if (empty($QuicktimeColorNameLookup)) { 
  1589. $QuicktimeColorNameLookup[1] = '2-color (monochrome)'; 
  1590. $QuicktimeColorNameLookup[2] = '4-color'; 
  1591. $QuicktimeColorNameLookup[4] = '16-color'; 
  1592. $QuicktimeColorNameLookup[8] = '256-color'; 
  1593. $QuicktimeColorNameLookup[16] = 'thousands (16-bit color)'; 
  1594. $QuicktimeColorNameLookup[24] = 'millions (24-bit color)'; 
  1595. $QuicktimeColorNameLookup[32] = 'millions+ (32-bit color)'; 
  1596. $QuicktimeColorNameLookup[33] = 'black & white'; 
  1597. $QuicktimeColorNameLookup[34] = '4-gray'; 
  1598. $QuicktimeColorNameLookup[36] = '16-gray'; 
  1599. $QuicktimeColorNameLookup[40] = '256-gray'; 
  1600. return (isset($QuicktimeColorNameLookup[$colordepthid]) ? $QuicktimeColorNameLookup[$colordepthid] : 'invalid'); 
  1601.  
  1602. public function QuicktimeSTIKLookup($stik) { 
  1603. static $QuicktimeSTIKLookup = array(); 
  1604. if (empty($QuicktimeSTIKLookup)) { 
  1605. $QuicktimeSTIKLookup[0] = 'Movie'; 
  1606. $QuicktimeSTIKLookup[1] = 'Normal'; 
  1607. $QuicktimeSTIKLookup[2] = 'Audiobook'; 
  1608. $QuicktimeSTIKLookup[5] = 'Whacked Bookmark'; 
  1609. $QuicktimeSTIKLookup[6] = 'Music Video'; 
  1610. $QuicktimeSTIKLookup[9] = 'Short Film'; 
  1611. $QuicktimeSTIKLookup[10] = 'TV Show'; 
  1612. $QuicktimeSTIKLookup[11] = 'Booklet'; 
  1613. $QuicktimeSTIKLookup[14] = 'Ringtone'; 
  1614. $QuicktimeSTIKLookup[21] = 'Podcast'; 
  1615. return (isset($QuicktimeSTIKLookup[$stik]) ? $QuicktimeSTIKLookup[$stik] : 'invalid'); 
  1616.  
  1617. public function QuicktimeIODSaudioProfileName($audio_profile_id) { 
  1618. static $QuicktimeIODSaudioProfileNameLookup = array(); 
  1619. if (empty($QuicktimeIODSaudioProfileNameLookup)) { 
  1620. $QuicktimeIODSaudioProfileNameLookup = array( 
  1621. 0x00 => 'ISO Reserved (0x00)',  
  1622. 0x01 => 'Main Audio Profile @ Level 1',  
  1623. 0x02 => 'Main Audio Profile @ Level 2',  
  1624. 0x03 => 'Main Audio Profile @ Level 3',  
  1625. 0x04 => 'Main Audio Profile @ Level 4',  
  1626. 0x05 => 'Scalable Audio Profile @ Level 1',  
  1627. 0x06 => 'Scalable Audio Profile @ Level 2',  
  1628. 0x07 => 'Scalable Audio Profile @ Level 3',  
  1629. 0x08 => 'Scalable Audio Profile @ Level 4',  
  1630. 0x09 => 'Speech Audio Profile @ Level 1',  
  1631. 0x0A => 'Speech Audio Profile @ Level 2',  
  1632. 0x0B => 'Synthetic Audio Profile @ Level 1',  
  1633. 0x0C => 'Synthetic Audio Profile @ Level 2',  
  1634. 0x0D => 'Synthetic Audio Profile @ Level 3',  
  1635. 0x0E => 'High Quality Audio Profile @ Level 1',  
  1636. 0x0F => 'High Quality Audio Profile @ Level 2',  
  1637. 0x10 => 'High Quality Audio Profile @ Level 3',  
  1638. 0x11 => 'High Quality Audio Profile @ Level 4',  
  1639. 0x12 => 'High Quality Audio Profile @ Level 5',  
  1640. 0x13 => 'High Quality Audio Profile @ Level 6',  
  1641. 0x14 => 'High Quality Audio Profile @ Level 7',  
  1642. 0x15 => 'High Quality Audio Profile @ Level 8',  
  1643. 0x16 => 'Low Delay Audio Profile @ Level 1',  
  1644. 0x17 => 'Low Delay Audio Profile @ Level 2',  
  1645. 0x18 => 'Low Delay Audio Profile @ Level 3',  
  1646. 0x19 => 'Low Delay Audio Profile @ Level 4',  
  1647. 0x1A => 'Low Delay Audio Profile @ Level 5',  
  1648. 0x1B => 'Low Delay Audio Profile @ Level 6',  
  1649. 0x1C => 'Low Delay Audio Profile @ Level 7',  
  1650. 0x1D => 'Low Delay Audio Profile @ Level 8',  
  1651. 0x1E => 'Natural Audio Profile @ Level 1',  
  1652. 0x1F => 'Natural Audio Profile @ Level 2',  
  1653. 0x20 => 'Natural Audio Profile @ Level 3',  
  1654. 0x21 => 'Natural Audio Profile @ Level 4',  
  1655. 0x22 => 'Mobile Audio Internetworking Profile @ Level 1',  
  1656. 0x23 => 'Mobile Audio Internetworking Profile @ Level 2',  
  1657. 0x24 => 'Mobile Audio Internetworking Profile @ Level 3',  
  1658. 0x25 => 'Mobile Audio Internetworking Profile @ Level 4',  
  1659. 0x26 => 'Mobile Audio Internetworking Profile @ Level 5',  
  1660. 0x27 => 'Mobile Audio Internetworking Profile @ Level 6',  
  1661. 0x28 => 'AAC Profile @ Level 1',  
  1662. 0x29 => 'AAC Profile @ Level 2',  
  1663. 0x2A => 'AAC Profile @ Level 4',  
  1664. 0x2B => 'AAC Profile @ Level 5',  
  1665. 0x2C => 'High Efficiency AAC Profile @ Level 2',  
  1666. 0x2D => 'High Efficiency AAC Profile @ Level 3',  
  1667. 0x2E => 'High Efficiency AAC Profile @ Level 4',  
  1668. 0x2F => 'High Efficiency AAC Profile @ Level 5',  
  1669. 0xFE => 'Not part of MPEG-4 audio profiles',  
  1670. 0xFF => 'No audio capability required',  
  1671. ); 
  1672. return (isset($QuicktimeIODSaudioProfileNameLookup[$audio_profile_id]) ? $QuicktimeIODSaudioProfileNameLookup[$audio_profile_id] : 'ISO Reserved / User Private'); 
  1673.  
  1674.  
  1675. public function QuicktimeIODSvideoProfileName($video_profile_id) { 
  1676. static $QuicktimeIODSvideoProfileNameLookup = array(); 
  1677. if (empty($QuicktimeIODSvideoProfileNameLookup)) { 
  1678. $QuicktimeIODSvideoProfileNameLookup = array( 
  1679. 0x00 => 'Reserved (0x00) Profile',  
  1680. 0x01 => 'Simple Profile @ Level 1',  
  1681. 0x02 => 'Simple Profile @ Level 2',  
  1682. 0x03 => 'Simple Profile @ Level 3',  
  1683. 0x08 => 'Simple Profile @ Level 0',  
  1684. 0x10 => 'Simple Scalable Profile @ Level 0',  
  1685. 0x11 => 'Simple Scalable Profile @ Level 1',  
  1686. 0x12 => 'Simple Scalable Profile @ Level 2',  
  1687. 0x15 => 'AVC/H264 Profile',  
  1688. 0x21 => 'Core Profile @ Level 1',  
  1689. 0x22 => 'Core Profile @ Level 2',  
  1690. 0x32 => 'Main Profile @ Level 2',  
  1691. 0x33 => 'Main Profile @ Level 3',  
  1692. 0x34 => 'Main Profile @ Level 4',  
  1693. 0x42 => 'N-bit Profile @ Level 2',  
  1694. 0x51 => 'Scalable Texture Profile @ Level 1',  
  1695. 0x61 => 'Simple Face Animation Profile @ Level 1',  
  1696. 0x62 => 'Simple Face Animation Profile @ Level 2',  
  1697. 0x63 => 'Simple FBA Profile @ Level 1',  
  1698. 0x64 => 'Simple FBA Profile @ Level 2',  
  1699. 0x71 => 'Basic Animated Texture Profile @ Level 1',  
  1700. 0x72 => 'Basic Animated Texture Profile @ Level 2',  
  1701. 0x81 => 'Hybrid Profile @ Level 1',  
  1702. 0x82 => 'Hybrid Profile @ Level 2',  
  1703. 0x91 => 'Advanced Real Time Simple Profile @ Level 1',  
  1704. 0x92 => 'Advanced Real Time Simple Profile @ Level 2',  
  1705. 0x93 => 'Advanced Real Time Simple Profile @ Level 3',  
  1706. 0x94 => 'Advanced Real Time Simple Profile @ Level 4',  
  1707. 0xA1 => 'Core Scalable Profile @ Level1',  
  1708. 0xA2 => 'Core Scalable Profile @ Level2',  
  1709. 0xA3 => 'Core Scalable Profile @ Level3',  
  1710. 0xB1 => 'Advanced Coding Efficiency Profile @ Level 1',  
  1711. 0xB2 => 'Advanced Coding Efficiency Profile @ Level 2',  
  1712. 0xB3 => 'Advanced Coding Efficiency Profile @ Level 3',  
  1713. 0xB4 => 'Advanced Coding Efficiency Profile @ Level 4',  
  1714. 0xC1 => 'Advanced Core Profile @ Level 1',  
  1715. 0xC2 => 'Advanced Core Profile @ Level 2',  
  1716. 0xD1 => 'Advanced Scalable Texture @ Level1',  
  1717. 0xD2 => 'Advanced Scalable Texture @ Level2',  
  1718. 0xE1 => 'Simple Studio Profile @ Level 1',  
  1719. 0xE2 => 'Simple Studio Profile @ Level 2',  
  1720. 0xE3 => 'Simple Studio Profile @ Level 3',  
  1721. 0xE4 => 'Simple Studio Profile @ Level 4',  
  1722. 0xE5 => 'Core Studio Profile @ Level 1',  
  1723. 0xE6 => 'Core Studio Profile @ Level 2',  
  1724. 0xE7 => 'Core Studio Profile @ Level 3',  
  1725. 0xE8 => 'Core Studio Profile @ Level 4',  
  1726. 0xF0 => 'Advanced Simple Profile @ Level 0',  
  1727. 0xF1 => 'Advanced Simple Profile @ Level 1',  
  1728. 0xF2 => 'Advanced Simple Profile @ Level 2',  
  1729. 0xF3 => 'Advanced Simple Profile @ Level 3',  
  1730. 0xF4 => 'Advanced Simple Profile @ Level 4',  
  1731. 0xF5 => 'Advanced Simple Profile @ Level 5',  
  1732. 0xF7 => 'Advanced Simple Profile @ Level 3b',  
  1733. 0xF8 => 'Fine Granularity Scalable Profile @ Level 0',  
  1734. 0xF9 => 'Fine Granularity Scalable Profile @ Level 1',  
  1735. 0xFA => 'Fine Granularity Scalable Profile @ Level 2',  
  1736. 0xFB => 'Fine Granularity Scalable Profile @ Level 3',  
  1737. 0xFC => 'Fine Granularity Scalable Profile @ Level 4',  
  1738. 0xFD => 'Fine Granularity Scalable Profile @ Level 5',  
  1739. 0xFE => 'Not part of MPEG-4 Visual profiles',  
  1740. 0xFF => 'No visual capability required',  
  1741. ); 
  1742. return (isset($QuicktimeIODSvideoProfileNameLookup[$video_profile_id]) ? $QuicktimeIODSvideoProfileNameLookup[$video_profile_id] : 'ISO Reserved Profile'); 
  1743.  
  1744.  
  1745. public function QuicktimeContentRatingLookup($rtng) { 
  1746. static $QuicktimeContentRatingLookup = array(); 
  1747. if (empty($QuicktimeContentRatingLookup)) { 
  1748. $QuicktimeContentRatingLookup[0] = 'None'; 
  1749. $QuicktimeContentRatingLookup[2] = 'Clean'; 
  1750. $QuicktimeContentRatingLookup[4] = 'Explicit'; 
  1751. return (isset($QuicktimeContentRatingLookup[$rtng]) ? $QuicktimeContentRatingLookup[$rtng] : 'invalid'); 
  1752.  
  1753. public function QuicktimeStoreAccountTypeLookup($akid) { 
  1754. static $QuicktimeStoreAccountTypeLookup = array(); 
  1755. if (empty($QuicktimeStoreAccountTypeLookup)) { 
  1756. $QuicktimeStoreAccountTypeLookup[0] = 'iTunes'; 
  1757. $QuicktimeStoreAccountTypeLookup[1] = 'AOL'; 
  1758. return (isset($QuicktimeStoreAccountTypeLookup[$akid]) ? $QuicktimeStoreAccountTypeLookup[$akid] : 'invalid'); 
  1759.  
  1760. public function QuicktimeStoreFrontCodeLookup($sfid) { 
  1761. static $QuicktimeStoreFrontCodeLookup = array(); 
  1762. if (empty($QuicktimeStoreFrontCodeLookup)) { 
  1763. $QuicktimeStoreFrontCodeLookup[143460] = 'Australia'; 
  1764. $QuicktimeStoreFrontCodeLookup[143445] = 'Austria'; 
  1765. $QuicktimeStoreFrontCodeLookup[143446] = 'Belgium'; 
  1766. $QuicktimeStoreFrontCodeLookup[143455] = 'Canada'; 
  1767. $QuicktimeStoreFrontCodeLookup[143458] = 'Denmark'; 
  1768. $QuicktimeStoreFrontCodeLookup[143447] = 'Finland'; 
  1769. $QuicktimeStoreFrontCodeLookup[143442] = 'France'; 
  1770. $QuicktimeStoreFrontCodeLookup[143443] = 'Germany'; 
  1771. $QuicktimeStoreFrontCodeLookup[143448] = 'Greece'; 
  1772. $QuicktimeStoreFrontCodeLookup[143449] = 'Ireland'; 
  1773. $QuicktimeStoreFrontCodeLookup[143450] = 'Italy'; 
  1774. $QuicktimeStoreFrontCodeLookup[143462] = 'Japan'; 
  1775. $QuicktimeStoreFrontCodeLookup[143451] = 'Luxembourg'; 
  1776. $QuicktimeStoreFrontCodeLookup[143452] = 'Netherlands'; 
  1777. $QuicktimeStoreFrontCodeLookup[143461] = 'New Zealand'; 
  1778. $QuicktimeStoreFrontCodeLookup[143457] = 'Norway'; 
  1779. $QuicktimeStoreFrontCodeLookup[143453] = 'Portugal'; 
  1780. $QuicktimeStoreFrontCodeLookup[143454] = 'Spain'; 
  1781. $QuicktimeStoreFrontCodeLookup[143456] = 'Sweden'; 
  1782. $QuicktimeStoreFrontCodeLookup[143459] = 'Switzerland'; 
  1783. $QuicktimeStoreFrontCodeLookup[143444] = 'United Kingdom'; 
  1784. $QuicktimeStoreFrontCodeLookup[143441] = 'United States'; 
  1785. return (isset($QuicktimeStoreFrontCodeLookup[$sfid]) ? $QuicktimeStoreFrontCodeLookup[$sfid] : 'invalid'); 
  1786.  
  1787. public function QuicktimeParseNikonNCTG($atom_data) { 
  1788. // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG 
  1789. // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100 
  1790. // Data is stored as records of: 
  1791. // * 4 bytes record type 
  1792. // * 2 bytes size of data field type: 
  1793. // 0x0001 = flag (size field *= 1-byte) 
  1794. // 0x0002 = char (size field *= 1-byte) 
  1795. // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB 
  1796. // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD 
  1797. // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together 
  1798. // 0x0007 = bytes (size field *= 1-byte), values are stored as ?????? 
  1799. // 0x0008 = ????? (size field *= 2-byte), values are stored as ?????? 
  1800. // * 2 bytes data size field 
  1801. // * ? bytes data (string data may be null-padded; datestamp fields are in the format "2011:05:25 20:24:15") 
  1802. // all integers are stored BigEndian 
  1803.  
  1804. $NCTGtagName = array( 
  1805. 0x00000001 => 'Make',  
  1806. 0x00000002 => 'Model',  
  1807. 0x00000003 => 'Software',  
  1808. 0x00000011 => 'CreateDate',  
  1809. 0x00000012 => 'DateTimeOriginal',  
  1810. 0x00000013 => 'FrameCount',  
  1811. 0x00000016 => 'FrameRate',  
  1812. 0x00000022 => 'FrameWidth',  
  1813. 0x00000023 => 'FrameHeight',  
  1814. 0x00000032 => 'AudioChannels',  
  1815. 0x00000033 => 'AudioBitsPerSample',  
  1816. 0x00000034 => 'AudioSampleRate',  
  1817. 0x02000001 => 'MakerNoteVersion',  
  1818. 0x02000005 => 'WhiteBalance',  
  1819. 0x0200000b => 'WhiteBalanceFineTune',  
  1820. 0x0200001e => 'ColorSpace',  
  1821. 0x02000023 => 'PictureControlData',  
  1822. 0x02000024 => 'WorldTime',  
  1823. 0x02000032 => 'UnknownInfo',  
  1824. 0x02000083 => 'LensType',  
  1825. 0x02000084 => 'Lens',  
  1826. ); 
  1827.  
  1828. $offset = 0; 
  1829. $datalength = strlen($atom_data); 
  1830. $parsed = array(); 
  1831. while ($offset < $datalength) { 
  1832. //echo getid3_lib::PrintHexBytes(substr($atom_data, $offset, 4)).'<br>'; 
  1833. $record_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4)); $offset += 4; 
  1834. $data_size_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2; 
  1835. $data_size = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2; 
  1836. switch ($data_size_type) { 
  1837. case 0x0001: // 0x0001 = flag (size field *= 1-byte) 
  1838. $data = getid3_lib::BigEndian2Int(substr($atom_data, $offset, $data_size * 1)); 
  1839. $offset += ($data_size * 1); 
  1840. break; 
  1841. case 0x0002: // 0x0002 = char (size field *= 1-byte) 
  1842. $data = substr($atom_data, $offset, $data_size * 1); 
  1843. $offset += ($data_size * 1); 
  1844. $data = rtrim($data, "\x00"); 
  1845. break; 
  1846. case 0x0003: // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB 
  1847. $data = ''; 
  1848. for ($i = $data_size - 1; $i >= 0; $i--) { 
  1849. $data .= substr($atom_data, $offset + ($i * 2), 2); 
  1850. $data = getid3_lib::BigEndian2Int($data); 
  1851. $offset += ($data_size * 2); 
  1852. break; 
  1853. case 0x0004: // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD 
  1854. $data = ''; 
  1855. for ($i = $data_size - 1; $i >= 0; $i--) { 
  1856. $data .= substr($atom_data, $offset + ($i * 4), 4); 
  1857. $data = getid3_lib::BigEndian2Int($data); 
  1858. $offset += ($data_size * 4); 
  1859. break; 
  1860. case 0x0005: // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together 
  1861. $data = array(); 
  1862. for ($i = 0; $i < $data_size; $i++) { 
  1863. $numerator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 0, 4)); 
  1864. $denomninator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 4, 4)); 
  1865. if ($denomninator == 0) { 
  1866. $data[$i] = false; 
  1867. } else { 
  1868. $data[$i] = (double) $numerator / $denomninator; 
  1869. $offset += (8 * $data_size); 
  1870. if (count($data) == 1) { 
  1871. $data = $data[0]; 
  1872. break; 
  1873. case 0x0007: // 0x0007 = bytes (size field *= 1-byte), values are stored as ?????? 
  1874. $data = substr($atom_data, $offset, $data_size * 1); 
  1875. $offset += ($data_size * 1); 
  1876. break; 
  1877. case 0x0008: // 0x0008 = ????? (size field *= 2-byte), values are stored as ?????? 
  1878. $data = substr($atom_data, $offset, $data_size * 2); 
  1879. $offset += ($data_size * 2); 
  1880. break; 
  1881. default: 
  1882. echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br>'; 
  1883. break 2; 
  1884.  
  1885. switch ($record_type) { 
  1886. case 0x00000011: // CreateDate 
  1887. case 0x00000012: // DateTimeOriginal 
  1888. $data = strtotime($data); 
  1889. break; 
  1890. case 0x0200001e: // ColorSpace 
  1891. switch ($data) { 
  1892. case 1: 
  1893. $data = 'sRGB'; 
  1894. break; 
  1895. case 2: 
  1896. $data = 'Adobe RGB'; 
  1897. break; 
  1898. break; 
  1899. case 0x02000023: // PictureControlData 
  1900. $PictureControlAdjust = array(0=>'default', 1=>'quick', 2=>'full'); 
  1901. $FilterEffect = array(0x80=>'off', 0x81=>'yellow', 0x82=>'orange', 0x83=>'red', 0x84=>'green', 0xff=>'n/a'); 
  1902. $ToningEffect = array(0x80=>'b&w', 0x81=>'sepia', 0x82=>'cyanotype', 0x83=>'red', 0x84=>'yellow', 0x85=>'green', 0x86=>'blue-green', 0x87=>'blue', 0x88=>'purple-blue', 0x89=>'red-purple', 0xff=>'n/a'); 
  1903. $data = array( 
  1904. 'PictureControlVersion' => substr($data, 0, 4),  
  1905. 'PictureControlName' => rtrim(substr($data, 4, 20), "\x00"),  
  1906. 'PictureControlBase' => rtrim(substr($data, 24, 20), "\x00"),  
  1907. //'?' => substr($data, 44, 4),  
  1908. 'PictureControlAdjust' => $PictureControlAdjust[ord(substr($data, 48, 1))],  
  1909. 'PictureControlQuickAdjust' => ord(substr($data, 49, 1)),  
  1910. 'Sharpness' => ord(substr($data, 50, 1)),  
  1911. 'Contrast' => ord(substr($data, 51, 1)),  
  1912. 'Brightness' => ord(substr($data, 52, 1)),  
  1913. 'Saturation' => ord(substr($data, 53, 1)),  
  1914. 'HueAdjustment' => ord(substr($data, 54, 1)),  
  1915. 'FilterEffect' => $FilterEffect[ord(substr($data, 55, 1))],  
  1916. 'ToningEffect' => $ToningEffect[ord(substr($data, 56, 1))],  
  1917. 'ToningSaturation' => ord(substr($data, 57, 1)),  
  1918. ); 
  1919. break; 
  1920. case 0x02000024: // WorldTime 
  1921. // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#WorldTime 
  1922. // timezone is stored as offset from GMT in minutes 
  1923. $timezone = getid3_lib::BigEndian2Int(substr($data, 0, 2)); 
  1924. if ($timezone & 0x8000) { 
  1925. $timezone = 0 - (0x10000 - $timezone); 
  1926. $timezone /= 60; 
  1927.  
  1928. $dst = (bool) getid3_lib::BigEndian2Int(substr($data, 2, 1)); 
  1929. switch (getid3_lib::BigEndian2Int(substr($data, 3, 1))) { 
  1930. case 2: 
  1931. $datedisplayformat = 'D/M/Y'; break; 
  1932. case 1: 
  1933. $datedisplayformat = 'M/D/Y'; break; 
  1934. case 0: 
  1935. default: 
  1936. $datedisplayformat = 'Y/M/D'; break; 
  1937.  
  1938. $data = array('timezone'=>floatval($timezone), 'dst'=>$dst, 'display'=>$datedisplayformat); 
  1939. break; 
  1940. case 0x02000083: // LensType 
  1941. $data = array( 
  1942. //'_' => $data,  
  1943. 'mf' => (bool) ($data & 0x01),  
  1944. 'd' => (bool) ($data & 0x02),  
  1945. 'g' => (bool) ($data & 0x04),  
  1946. 'vr' => (bool) ($data & 0x08),  
  1947. ); 
  1948. break; 
  1949. $tag_name = (isset($NCTGtagName[$record_type]) ? $NCTGtagName[$record_type] : '0x'.str_pad(dechex($record_type), 8, '0', STR_PAD_LEFT)); 
  1950. $parsed[$tag_name] = $data; 
  1951. return $parsed; 
  1952.  
  1953.  
  1954. public function CopyToAppropriateCommentsSection($keyname, $data, $boxname='') { 
  1955. static $handyatomtranslatorarray = array(); 
  1956. if (empty($handyatomtranslatorarray)) { 
  1957. $handyatomtranslatorarray["\xA9".'cpy'] = 'copyright'; 
  1958. $handyatomtranslatorarray["\xA9".'day'] = 'creation_date'; // iTunes 4.0 
  1959. $handyatomtranslatorarray["\xA9".'dir'] = 'director'; 
  1960. $handyatomtranslatorarray["\xA9".'ed1'] = 'edit1'; 
  1961. $handyatomtranslatorarray["\xA9".'ed2'] = 'edit2'; 
  1962. $handyatomtranslatorarray["\xA9".'ed3'] = 'edit3'; 
  1963. $handyatomtranslatorarray["\xA9".'ed4'] = 'edit4'; 
  1964. $handyatomtranslatorarray["\xA9".'ed5'] = 'edit5'; 
  1965. $handyatomtranslatorarray["\xA9".'ed6'] = 'edit6'; 
  1966. $handyatomtranslatorarray["\xA9".'ed7'] = 'edit7'; 
  1967. $handyatomtranslatorarray["\xA9".'ed8'] = 'edit8'; 
  1968. $handyatomtranslatorarray["\xA9".'ed9'] = 'edit9'; 
  1969. $handyatomtranslatorarray["\xA9".'fmt'] = 'format'; 
  1970. $handyatomtranslatorarray["\xA9".'inf'] = 'information'; 
  1971. $handyatomtranslatorarray["\xA9".'prd'] = 'producer'; 
  1972. $handyatomtranslatorarray["\xA9".'prf'] = 'performers'; 
  1973. $handyatomtranslatorarray["\xA9".'req'] = 'system_requirements'; 
  1974. $handyatomtranslatorarray["\xA9".'src'] = 'source_credit'; 
  1975. $handyatomtranslatorarray["\xA9".'wrt'] = 'writer'; 
  1976.  
  1977. // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt 
  1978. $handyatomtranslatorarray["\xA9".'nam'] = 'title'; // iTunes 4.0 
  1979. $handyatomtranslatorarray["\xA9".'cmt'] = 'comment'; // iTunes 4.0 
  1980. $handyatomtranslatorarray["\xA9".'wrn'] = 'warning'; 
  1981. $handyatomtranslatorarray["\xA9".'hst'] = 'host_computer'; 
  1982. $handyatomtranslatorarray["\xA9".'mak'] = 'make'; 
  1983. $handyatomtranslatorarray["\xA9".'mod'] = 'model'; 
  1984. $handyatomtranslatorarray["\xA9".'PRD'] = 'product'; 
  1985. $handyatomtranslatorarray["\xA9".'swr'] = 'software'; 
  1986. $handyatomtranslatorarray["\xA9".'aut'] = 'author'; 
  1987. $handyatomtranslatorarray["\xA9".'ART'] = 'artist'; 
  1988. $handyatomtranslatorarray["\xA9".'trk'] = 'track'; 
  1989. $handyatomtranslatorarray["\xA9".'alb'] = 'album'; // iTunes 4.0 
  1990. $handyatomtranslatorarray["\xA9".'com'] = 'comment'; 
  1991. $handyatomtranslatorarray["\xA9".'gen'] = 'genre'; // iTunes 4.0 
  1992. $handyatomtranslatorarray["\xA9".'ope'] = 'composer'; 
  1993. $handyatomtranslatorarray["\xA9".'url'] = 'url'; 
  1994. $handyatomtranslatorarray["\xA9".'enc'] = 'encoder'; 
  1995.  
  1996. // http://atomicparsley.sourceforge.net/mpeg-4files.html 
  1997. $handyatomtranslatorarray["\xA9".'art'] = 'artist'; // iTunes 4.0 
  1998. $handyatomtranslatorarray['aART'] = 'album_artist'; 
  1999. $handyatomtranslatorarray['trkn'] = 'track_number'; // iTunes 4.0 
  2000. $handyatomtranslatorarray['disk'] = 'disc_number'; // iTunes 4.0 
  2001. $handyatomtranslatorarray['gnre'] = 'genre'; // iTunes 4.0 
  2002. $handyatomtranslatorarray["\xA9".'too'] = 'encoder'; // iTunes 4.0 
  2003. $handyatomtranslatorarray['tmpo'] = 'bpm'; // iTunes 4.0 
  2004. $handyatomtranslatorarray['cprt'] = 'copyright'; // iTunes 4.0? 
  2005. $handyatomtranslatorarray['cpil'] = 'compilation'; // iTunes 4.0 
  2006. $handyatomtranslatorarray['covr'] = 'picture'; // iTunes 4.0 
  2007. $handyatomtranslatorarray['rtng'] = 'rating'; // iTunes 4.0 
  2008. $handyatomtranslatorarray["\xA9".'grp'] = 'grouping'; // iTunes 4.2 
  2009. $handyatomtranslatorarray['stik'] = 'stik'; // iTunes 4.9 
  2010. $handyatomtranslatorarray['pcst'] = 'podcast'; // iTunes 4.9 
  2011. $handyatomtranslatorarray['catg'] = 'category'; // iTunes 4.9 
  2012. $handyatomtranslatorarray['keyw'] = 'keyword'; // iTunes 4.9 
  2013. $handyatomtranslatorarray['purl'] = 'podcast_url'; // iTunes 4.9 
  2014. $handyatomtranslatorarray['egid'] = 'episode_guid'; // iTunes 4.9 
  2015. $handyatomtranslatorarray['desc'] = 'description'; // iTunes 5.0 
  2016. $handyatomtranslatorarray["\xA9".'lyr'] = 'lyrics'; // iTunes 5.0 
  2017. $handyatomtranslatorarray['tvnn'] = 'tv_network_name'; // iTunes 6.0 
  2018. $handyatomtranslatorarray['tvsh'] = 'tv_show_name'; // iTunes 6.0 
  2019. $handyatomtranslatorarray['tvsn'] = 'tv_season'; // iTunes 6.0 
  2020. $handyatomtranslatorarray['tves'] = 'tv_episode'; // iTunes 6.0 
  2021. $handyatomtranslatorarray['purd'] = 'purchase_date'; // iTunes 6.0.2 
  2022. $handyatomtranslatorarray['pgap'] = 'gapless_playback'; // iTunes 7.0 
  2023.  
  2024. // http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt 
  2025.  
  2026.  
  2027.  
  2028. // boxnames: 
  2029. /** 
  2030. $handyatomtranslatorarray['iTunSMPB'] = 'iTunSMPB'; 
  2031. $handyatomtranslatorarray['iTunNORM'] = 'iTunNORM'; 
  2032. $handyatomtranslatorarray['Encoding Params'] = 'Encoding Params'; 
  2033. $handyatomtranslatorarray['replaygain_track_gain'] = 'replaygain_track_gain'; 
  2034. $handyatomtranslatorarray['replaygain_track_peak'] = 'replaygain_track_peak'; 
  2035. $handyatomtranslatorarray['replaygain_track_minmax'] = 'replaygain_track_minmax'; 
  2036. $handyatomtranslatorarray['MusicIP PUID'] = 'MusicIP PUID'; 
  2037. $handyatomtranslatorarray['MusicBrainz Artist Id'] = 'MusicBrainz Artist Id'; 
  2038. $handyatomtranslatorarray['MusicBrainz Album Id'] = 'MusicBrainz Album Id'; 
  2039. $handyatomtranslatorarray['MusicBrainz Album Artist Id'] = 'MusicBrainz Album Artist Id'; 
  2040. $handyatomtranslatorarray['MusicBrainz Track Id'] = 'MusicBrainz Track Id'; 
  2041. $handyatomtranslatorarray['MusicBrainz Disc Id'] = 'MusicBrainz Disc Id'; 
  2042.   
  2043. // http://age.hobba.nl/audio/tag_frame_reference.html 
  2044. $handyatomtranslatorarray['PLAY_COUNTER'] = 'play_counter'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355 
  2045. $handyatomtranslatorarray['MEDIATYPE'] = 'mediatype'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355 
  2046. */ 
  2047. $info = &$this->getid3->info; 
  2048. $comment_key = ''; 
  2049. if ($boxname && ($boxname != $keyname)) { 
  2050. $comment_key = (isset($handyatomtranslatorarray[$boxname]) ? $handyatomtranslatorarray[$boxname] : $boxname); 
  2051. } elseif (isset($handyatomtranslatorarray[$keyname])) { 
  2052. $comment_key = $handyatomtranslatorarray[$keyname]; 
  2053. if ($comment_key) { 
  2054. if ($comment_key == 'picture') { 
  2055. if (!is_array($data)) { 
  2056. $image_mime = ''; 
  2057. if (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $data)) { 
  2058. $image_mime = 'image/png'; 
  2059. } elseif (preg_match('#^\xFF\xD8\xFF#', $data)) { 
  2060. $image_mime = 'image/jpeg'; 
  2061. } elseif (preg_match('#^GIF#', $data)) { 
  2062. $image_mime = 'image/gif'; 
  2063. } elseif (preg_match('#^BM#', $data)) { 
  2064. $image_mime = 'image/bmp'; 
  2065. $data = array('data'=>$data, 'image_mime'=>$image_mime); 
  2066. $info['quicktime']['comments'][$comment_key][] = $data; 
  2067. return true; 
  2068.  
  2069. public function NoNullString($nullterminatedstring) { 
  2070. // remove the single null terminator on null terminated strings 
  2071. if (substr($nullterminatedstring, strlen($nullterminatedstring) - 1, 1) === "\x00") { 
  2072. return substr($nullterminatedstring, 0, strlen($nullterminatedstring) - 1); 
  2073. return $nullterminatedstring; 
  2074.  
  2075. public function Pascal2String($pascalstring) { 
  2076. // Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string 
  2077. return substr($pascalstring, 1); 
  2078.