ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
getid3_quicktime Class Reference
+ Inheritance diagram for getid3_quicktime:
+ Collaboration diagram for getid3_quicktime:

Public Member Functions

 getid3_quicktime (&$fd, &$ThisFileInfo, $ReturnAtomData=true, $ParseAllPossibleAtoms=false)
 
 QuicktimeParseAtom ($atomname, $atomsize, $atomdata, &$ThisFileInfo, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms)
 
 QuicktimeParseContainerAtom ($atomdata, &$ThisFileInfo, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms)
 
 QuicktimeLanguageLookup ($languageid)
 
 QuicktimeVideoCodecLookup ($codecid)
 
 QuicktimeAudioCodecLookup ($codecid)
 
 QuicktimeDCOMLookup ($compressionid)
 
 QuicktimeColorNameLookup ($colordepthid)
 
 CopyToAppropriateCommentsSection ($keyname, $data, &$ThisFileInfo)
 
 NoNullString ($nullterminatedstring)
 
 Pascal2String ($pascalstring)
 
 Analyze ()
 
 QuicktimeParseAtom ($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms)
 
 QuicktimeParseContainerAtom ($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms)
 
 quicktime_read_mp4_descr_length ($data, &$offset)
 
 QuicktimeLanguageLookup ($languageid)
 
 QuicktimeVideoCodecLookup ($codecid)
 
 QuicktimeAudioCodecLookup ($codecid)
 
 QuicktimeDCOMLookup ($compressionid)
 
 QuicktimeColorNameLookup ($colordepthid)
 
 QuicktimeSTIKLookup ($stik)
 
 QuicktimeIODSaudioProfileName ($audio_profile_id)
 
 QuicktimeIODSvideoProfileName ($video_profile_id)
 
 QuicktimeContentRatingLookup ($rtng)
 
 QuicktimeStoreAccountTypeLookup ($akid)
 
 QuicktimeStoreFrontCodeLookup ($sfid)
 
 QuicktimeParseNikonNCTG ($atom_data)
 
 CopyToAppropriateCommentsSection ($keyname, $data, $boxname='')
 
 NoNullString ($nullterminatedstring)
 
 Pascal2String ($pascalstring)
 
- Public Member Functions inherited from getid3_handler
 __construct (getID3 $getid3, $call_module=null)
 
 Analyze ()
 
 AnalyzeString ($string)
 
 setStringMode ($string)
 
 saveAttachment ($name, $offset, $length, $image_mime=null)
 

Data Fields

 $ReturnAtomData = true
 
 $ParseAllPossibleAtoms = false
 

Additional Inherited Members

- Protected Member Functions inherited from getid3_handler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
 notice ($text)
 
- Protected Attributes inherited from getid3_handler
 $getid3
 
 $data_string_flag = false
 
 $data_string = ''
 
 $data_string_position = 0
 
 $data_string_length = 0
 

Detailed Description

Definition at line 18 of file module.audio-video.quicktime.php.

Member Function Documentation

◆ Analyze()

getid3_quicktime::Analyze ( )

Definition at line 27 of file module.audio-video.quicktime.php.

References $info, getid3_lib\BigEndian2Int(), getid3_handler\fread(), getid3_handler\fseek(), getid3_lib\intValueSupported(), and QuicktimeParseAtom().

27  {
28  $info = &$this->getid3->info;
29 
30  $info['fileformat'] = 'quicktime';
31  $info['quicktime']['hinting'] = false;
32  $info['quicktime']['controller'] = 'standard'; // may be overridden if 'ctyp' atom is present
33 
34  $this->fseek($info['avdataoffset']);
35 
36  $offset = 0;
37  $atomcounter = 0;
38  $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
39  while ($offset < $info['avdataend']) {
40  if (!getid3_lib::intValueSupported($offset)) {
41  $info['error'][] = 'Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
42  break;
43  }
44  $this->fseek($offset);
45  $AtomHeader = $this->fread(8);
46 
47  $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
48  $atomname = substr($AtomHeader, 4, 4);
49 
50  // 64-bit MOV patch by jlegateØktnc*com
51  if ($atomsize == 1) {
52  $atomsize = getid3_lib::BigEndian2Int($this->fread(8));
53  }
54 
55  $info['quicktime'][$atomname]['name'] = $atomname;
56  $info['quicktime'][$atomname]['size'] = $atomsize;
57  $info['quicktime'][$atomname]['offset'] = $offset;
58 
59  if (($offset + $atomsize) > $info['avdataend']) {
60  $info['error'][] = 'Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)';
61  return false;
62  }
63 
64  if ($atomsize == 0) {
65  // Furthermore, for historical reasons the list of atoms is optionally
66  // terminated by a 32-bit integer set to 0. If you are writing a program
67  // to read user data atoms, you should allow for the terminating 0.
68  break;
69  }
70  $atomHierarchy = array();
71  $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread(min($atomsize, $atom_data_read_buffer_size)), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);
72 
73  $offset += $atomsize;
74  $atomcounter++;
75  }
76 
77  if (!empty($info['avdataend_tmp'])) {
78  // this value is assigned to a temp value and then erased because
79  // otherwise any atoms beyond the 'mdat' atom would not get parsed
80  $info['avdataend'] = $info['avdataend_tmp'];
81  unset($info['avdataend_tmp']);
82  }
83 
84  if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) {
85  $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
86  }
87  if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info['quicktime']['video'])) {
88  $info['audio']['bitrate'] = $info['bitrate'];
89  }
90  if (!empty($info['playtime_seconds']) && !isset($info['video']['frame_rate']) && !empty($info['quicktime']['stts_framecount'])) {
91  foreach ($info['quicktime']['stts_framecount'] as $key => $samples_count) {
92  $samples_per_second = $samples_count / $info['playtime_seconds'];
93  if ($samples_per_second > 240) {
94  // has to be audio samples
95  } else {
96  $info['video']['frame_rate'] = $samples_per_second;
97  break;
98  }
99  }
100  }
101  if (($info['audio']['dataformat'] == 'mp4') && empty($info['video']['resolution_x'])) {
102  $info['fileformat'] = 'mp4';
103  $info['mime_type'] = 'audio/mp4';
104  unset($info['video']['dataformat']);
105  }
106 
107  if (!$this->ReturnAtomData) {
108  unset($info['quicktime']['moov']);
109  }
110 
111  if (empty($info['audio']['dataformat']) && !empty($info['quicktime']['audio'])) {
112  $info['audio']['dataformat'] = 'quicktime';
113  }
114  if (empty($info['video']['dataformat']) && !empty($info['quicktime']['video'])) {
115  $info['video']['dataformat'] = 'quicktime';
116  }
117 
118  return true;
119  }
static intValueSupported($num)
Definition: getid3.lib.php:80
QuicktimeParseAtom($atomname, $atomsize, $atomdata, &$ThisFileInfo, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms)
$info
Definition: example_052.php:80
fread($bytes)
Definition: getid3.php:1685
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
+ Here is the call graph for this function:

◆ CopyToAppropriateCommentsSection() [1/2]

getid3_quicktime::CopyToAppropriateCommentsSection (   $keyname,
  $data,
$ThisFileInfo 
)

Definition at line 1238 of file module.audio-video.quicktime.php.

References $data.

Referenced by QuicktimeParseAtom().

1238  {
1239  static $handyatomtranslatorarray = array();
1240  if (empty($handyatomtranslatorarray)) {
1241  $handyatomtranslatorarray['©cpy'] = 'copyright';
1242  $handyatomtranslatorarray['©day'] = 'creation_date';
1243  $handyatomtranslatorarray['©dir'] = 'director';
1244  $handyatomtranslatorarray['©ed1'] = 'edit1';
1245  $handyatomtranslatorarray['©ed2'] = 'edit2';
1246  $handyatomtranslatorarray['©ed3'] = 'edit3';
1247  $handyatomtranslatorarray['©ed4'] = 'edit4';
1248  $handyatomtranslatorarray['©ed5'] = 'edit5';
1249  $handyatomtranslatorarray['©ed6'] = 'edit6';
1250  $handyatomtranslatorarray['©ed7'] = 'edit7';
1251  $handyatomtranslatorarray['©ed8'] = 'edit8';
1252  $handyatomtranslatorarray['©ed9'] = 'edit9';
1253  $handyatomtranslatorarray['©fmt'] = 'format';
1254  $handyatomtranslatorarray['©inf'] = 'information';
1255  $handyatomtranslatorarray['©prd'] = 'producer';
1256  $handyatomtranslatorarray['©prf'] = 'performers';
1257  $handyatomtranslatorarray['©req'] = 'system_requirements';
1258  $handyatomtranslatorarray['©src'] = 'source_credit';
1259  $handyatomtranslatorarray['©wrt'] = 'writer';
1260 
1261  // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt
1262  $handyatomtranslatorarray['©nam'] = 'title';
1263  $handyatomtranslatorarray['©cmt'] = 'comment';
1264  $handyatomtranslatorarray['©wrn'] = 'warning';
1265  $handyatomtranslatorarray['©hst'] = 'host_computer';
1266  $handyatomtranslatorarray['©mak'] = 'make';
1267  $handyatomtranslatorarray['©mod'] = 'model';
1268  $handyatomtranslatorarray['©PRD'] = 'product';
1269  $handyatomtranslatorarray['©swr'] = 'software';
1270  $handyatomtranslatorarray['©aut'] = 'author';
1271  $handyatomtranslatorarray['©ART'] = 'artist';
1272  $handyatomtranslatorarray['©trk'] = 'track';
1273  $handyatomtranslatorarray['©alb'] = 'album';
1274  $handyatomtranslatorarray['©com'] = 'comment';
1275  $handyatomtranslatorarray['©gen'] = 'genre';
1276  $handyatomtranslatorarray['©ope'] = 'composer';
1277  $handyatomtranslatorarray['©url'] = 'url';
1278  $handyatomtranslatorarray['©enc'] = 'encoder';
1279  }
1280  if (isset($handyatomtranslatorarray[$keyname])) {
1281  $ThisFileInfo['quicktime']['comments'][$handyatomtranslatorarray[$keyname]][] = $data;
1282  }
1283 
1284  return true;
1285  }
$data
+ Here is the caller graph for this function:

◆ CopyToAppropriateCommentsSection() [2/2]

getid3_quicktime::CopyToAppropriateCommentsSection (   $keyname,
  $data,
  $boxname = '' 
)

Definition at line 2137 of file module.audio-video.quicktime.php.

References $data, and $info.

2137  {
2138  static $handyatomtranslatorarray = array();
2139  if (empty($handyatomtranslatorarray)) {
2140  // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt
2141  // http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt
2142  // http://atomicparsley.sourceforge.net/mpeg-4files.html
2143  // https://code.google.com/p/mp4v2/wiki/iTunesMetadata
2144  $handyatomtranslatorarray["\xA9".'alb'] = 'album'; // iTunes 4.0
2145  $handyatomtranslatorarray["\xA9".'ART'] = 'artist';
2146  $handyatomtranslatorarray["\xA9".'art'] = 'artist'; // iTunes 4.0
2147  $handyatomtranslatorarray["\xA9".'aut'] = 'author';
2148  $handyatomtranslatorarray["\xA9".'cmt'] = 'comment'; // iTunes 4.0
2149  $handyatomtranslatorarray["\xA9".'com'] = 'comment';
2150  $handyatomtranslatorarray["\xA9".'cpy'] = 'copyright';
2151  $handyatomtranslatorarray["\xA9".'day'] = 'creation_date'; // iTunes 4.0
2152  $handyatomtranslatorarray["\xA9".'dir'] = 'director';
2153  $handyatomtranslatorarray["\xA9".'ed1'] = 'edit1';
2154  $handyatomtranslatorarray["\xA9".'ed2'] = 'edit2';
2155  $handyatomtranslatorarray["\xA9".'ed3'] = 'edit3';
2156  $handyatomtranslatorarray["\xA9".'ed4'] = 'edit4';
2157  $handyatomtranslatorarray["\xA9".'ed5'] = 'edit5';
2158  $handyatomtranslatorarray["\xA9".'ed6'] = 'edit6';
2159  $handyatomtranslatorarray["\xA9".'ed7'] = 'edit7';
2160  $handyatomtranslatorarray["\xA9".'ed8'] = 'edit8';
2161  $handyatomtranslatorarray["\xA9".'ed9'] = 'edit9';
2162  $handyatomtranslatorarray["\xA9".'enc'] = 'encoded_by';
2163  $handyatomtranslatorarray["\xA9".'fmt'] = 'format';
2164  $handyatomtranslatorarray["\xA9".'gen'] = 'genre'; // iTunes 4.0
2165  $handyatomtranslatorarray["\xA9".'grp'] = 'grouping'; // iTunes 4.2
2166  $handyatomtranslatorarray["\xA9".'hst'] = 'host_computer';
2167  $handyatomtranslatorarray["\xA9".'inf'] = 'information';
2168  $handyatomtranslatorarray["\xA9".'lyr'] = 'lyrics'; // iTunes 5.0
2169  $handyatomtranslatorarray["\xA9".'mak'] = 'make';
2170  $handyatomtranslatorarray["\xA9".'mod'] = 'model';
2171  $handyatomtranslatorarray["\xA9".'nam'] = 'title'; // iTunes 4.0
2172  $handyatomtranslatorarray["\xA9".'ope'] = 'composer';
2173  $handyatomtranslatorarray["\xA9".'prd'] = 'producer';
2174  $handyatomtranslatorarray["\xA9".'PRD'] = 'product';
2175  $handyatomtranslatorarray["\xA9".'prf'] = 'performers';
2176  $handyatomtranslatorarray["\xA9".'req'] = 'system_requirements';
2177  $handyatomtranslatorarray["\xA9".'src'] = 'source_credit';
2178  $handyatomtranslatorarray["\xA9".'swr'] = 'software';
2179  $handyatomtranslatorarray["\xA9".'too'] = 'encoding_tool'; // iTunes 4.0
2180  $handyatomtranslatorarray["\xA9".'trk'] = 'track';
2181  $handyatomtranslatorarray["\xA9".'url'] = 'url';
2182  $handyatomtranslatorarray["\xA9".'wrn'] = 'warning';
2183  $handyatomtranslatorarray["\xA9".'wrt'] = 'composer';
2184  $handyatomtranslatorarray['aART'] = 'album_artist';
2185  $handyatomtranslatorarray['apID'] = 'purchase_account';
2186  $handyatomtranslatorarray['catg'] = 'category'; // iTunes 4.9
2187  $handyatomtranslatorarray['covr'] = 'picture'; // iTunes 4.0
2188  $handyatomtranslatorarray['cpil'] = 'compilation'; // iTunes 4.0
2189  $handyatomtranslatorarray['cprt'] = 'copyright'; // iTunes 4.0?
2190  $handyatomtranslatorarray['desc'] = 'description'; // iTunes 5.0
2191  $handyatomtranslatorarray['disk'] = 'disc_number'; // iTunes 4.0
2192  $handyatomtranslatorarray['egid'] = 'episode_guid'; // iTunes 4.9
2193  $handyatomtranslatorarray['gnre'] = 'genre'; // iTunes 4.0
2194  $handyatomtranslatorarray['hdvd'] = 'hd_video'; // iTunes 4.0
2195  $handyatomtranslatorarray['ldes'] = 'description_long'; //
2196  $handyatomtranslatorarray['keyw'] = 'keyword'; // iTunes 4.9
2197  $handyatomtranslatorarray['pcst'] = 'podcast'; // iTunes 4.9
2198  $handyatomtranslatorarray['pgap'] = 'gapless_playback'; // iTunes 7.0
2199  $handyatomtranslatorarray['purd'] = 'purchase_date'; // iTunes 6.0.2
2200  $handyatomtranslatorarray['purl'] = 'podcast_url'; // iTunes 4.9
2201  $handyatomtranslatorarray['rtng'] = 'rating'; // iTunes 4.0
2202  $handyatomtranslatorarray['soaa'] = 'sort_album_artist'; //
2203  $handyatomtranslatorarray['soal'] = 'sort_album'; //
2204  $handyatomtranslatorarray['soar'] = 'sort_artist'; //
2205  $handyatomtranslatorarray['soco'] = 'sort_composer'; //
2206  $handyatomtranslatorarray['sonm'] = 'sort_title'; //
2207  $handyatomtranslatorarray['sosn'] = 'sort_show'; //
2208  $handyatomtranslatorarray['stik'] = 'stik'; // iTunes 4.9
2209  $handyatomtranslatorarray['tmpo'] = 'bpm'; // iTunes 4.0
2210  $handyatomtranslatorarray['trkn'] = 'track_number'; // iTunes 4.0
2211  $handyatomtranslatorarray['tven'] = 'tv_episode_id'; //
2212  $handyatomtranslatorarray['tves'] = 'tv_episode'; // iTunes 6.0
2213  $handyatomtranslatorarray['tvnn'] = 'tv_network_name'; // iTunes 6.0
2214  $handyatomtranslatorarray['tvsh'] = 'tv_show_name'; // iTunes 6.0
2215  $handyatomtranslatorarray['tvsn'] = 'tv_season'; // iTunes 6.0
2216 
2217  // boxnames:
2218  /*
2219  $handyatomtranslatorarray['iTunSMPB'] = 'iTunSMPB';
2220  $handyatomtranslatorarray['iTunNORM'] = 'iTunNORM';
2221  $handyatomtranslatorarray['Encoding Params'] = 'Encoding Params';
2222  $handyatomtranslatorarray['replaygain_track_gain'] = 'replaygain_track_gain';
2223  $handyatomtranslatorarray['replaygain_track_peak'] = 'replaygain_track_peak';
2224  $handyatomtranslatorarray['replaygain_track_minmax'] = 'replaygain_track_minmax';
2225  $handyatomtranslatorarray['MusicIP PUID'] = 'MusicIP PUID';
2226  $handyatomtranslatorarray['MusicBrainz Artist Id'] = 'MusicBrainz Artist Id';
2227  $handyatomtranslatorarray['MusicBrainz Album Id'] = 'MusicBrainz Album Id';
2228  $handyatomtranslatorarray['MusicBrainz Album Artist Id'] = 'MusicBrainz Album Artist Id';
2229  $handyatomtranslatorarray['MusicBrainz Track Id'] = 'MusicBrainz Track Id';
2230  $handyatomtranslatorarray['MusicBrainz Disc Id'] = 'MusicBrainz Disc Id';
2231 
2232  // http://age.hobba.nl/audio/tag_frame_reference.html
2233  $handyatomtranslatorarray['PLAY_COUNTER'] = 'play_counter'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355
2234  $handyatomtranslatorarray['MEDIATYPE'] = 'mediatype'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355
2235  */
2236  }
2237  $info = &$this->getid3->info;
2238  $comment_key = '';
2239  if ($boxname && ($boxname != $keyname)) {
2240  $comment_key = (isset($handyatomtranslatorarray[$boxname]) ? $handyatomtranslatorarray[$boxname] : $boxname);
2241  } elseif (isset($handyatomtranslatorarray[$keyname])) {
2242  $comment_key = $handyatomtranslatorarray[$keyname];
2243  }
2244  if ($comment_key) {
2245  if ($comment_key == 'picture') {
2246  if (!is_array($data)) {
2247  $image_mime = '';
2248  if (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $data)) {
2249  $image_mime = 'image/png';
2250  } elseif (preg_match('#^\xFF\xD8\xFF#', $data)) {
2251  $image_mime = 'image/jpeg';
2252  } elseif (preg_match('#^GIF#', $data)) {
2253  $image_mime = 'image/gif';
2254  } elseif (preg_match('#^BM#', $data)) {
2255  $image_mime = 'image/bmp';
2256  }
2257  $data = array('data'=>$data, 'image_mime'=>$image_mime);
2258  }
2259  }
2260  $info['quicktime']['comments'][$comment_key][] = $data;
2261  }
2262  return true;
2263  }
$info
Definition: example_052.php:80
$data

◆ getid3_quicktime()

getid3_quicktime::getid3_quicktime ( $fd,
$ThisFileInfo,
  $ReturnAtomData = true,
  $ParseAllPossibleAtoms = false 
)

Definition at line 21 of file module.audio-video.quicktime.php.

References $ParseAllPossibleAtoms, $ReturnAtomData, getid3_lib\BigEndian2Int(), getid3_handler\fread(), getid3_handler\fseek(), getid3_mp3\getOnlyMPEGaudioInfo(), getid3_mp3\MPEGaudioHeaderDecode(), getid3_mp3\MPEGaudioHeaderValid(), and QuicktimeParseAtom().

21  {
22 
23  $ThisFileInfo['fileformat'] = 'quicktime';
24  $ThisFileInfo['quicktime']['hinting'] = false;
25 
26  fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
27 
28  $offset = 0;
29  $atomcounter = 0;
30 
31  while ($offset < $ThisFileInfo['avdataend']) {
32  fseek($fd, $offset, SEEK_SET);
33  $AtomHeader = fread($fd, 8);
34 
35  $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
36  $atomname = substr($AtomHeader, 4, 4);
37  $ThisFileInfo['quicktime'][$atomname]['name'] = $atomname;
38  $ThisFileInfo['quicktime'][$atomname]['size'] = $atomsize;
39  $ThisFileInfo['quicktime'][$atomname]['offset'] = $offset;
40 
41  if (($offset + $atomsize) > $ThisFileInfo['avdataend']) {
42  $ThisFileInfo['error'][] = 'Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)';
43  return false;
44  }
45 
46  if ($atomsize == 0) {
47  // Furthermore, for historical reasons the list of atoms is optionally
48  // terminated by a 32-bit integer set to 0. If you are writing a program
49  // to read user data atoms, you should allow for the terminating 0.
50  break;
51  }
52  switch ($atomname) {
53  case 'mdat': // Media DATa atom
54  // 'mdat' contains the actual data for the audio/video
55  if (($atomsize > 8) && (!isset($ThisFileInfo['avdataend_tmp']) || ($ThisFileInfo['quicktime'][$atomname]['size'] > ($ThisFileInfo['avdataend_tmp'] - $ThisFileInfo['avdataoffset'])))) {
56 
57  $ThisFileInfo['avdataoffset'] = $ThisFileInfo['quicktime'][$atomname]['offset'] + 8;
58  $OldAVDataEnd = $ThisFileInfo['avdataend'];
59  $ThisFileInfo['avdataend'] = $ThisFileInfo['quicktime'][$atomname]['offset'] + $ThisFileInfo['quicktime'][$atomname]['size'];
60 
62  getid3_mp3::getOnlyMPEGaudioInfo($fd, $ThisFileInfo, $ThisFileInfo['avdataoffset'], false);
63  if (isset($ThisFileInfo['mpeg']['audio'])) {
64  $ThisFileInfo['audio']['dataformat'] = 'mp3';
65  $ThisFileInfo['audio']['codec'] = (!empty($ThisFileInfo['mpeg']['audio']['encoder']) ? $ThisFileInfo['mpeg']['audio']['encoder'] : (!empty($ThisFileInfo['mpeg']['audio']['codec']) ? $ThisFileInfo['mpeg']['audio']['codec'] : (!empty($ThisFileInfo['mpeg']['audio']['LAME']) ? 'LAME' :'mp3')));
66  $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
67  $ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
68  $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
69  $ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
70  $ThisFileInfo['bitrate'] = $ThisFileInfo['audio']['bitrate'];
71  }
72  }
73  $ThisFileInfo['avdataend'] = $OldAVDataEnd;
74  unset($OldAVDataEnd);
75 
76  }
77  break;
78 
79  case 'free': // FREE space atom
80  case 'skip': // SKIP atom
81  case 'wide': // 64-bit expansion placeholder atom
82  // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
83  break;
84 
85  default:
86  $atomHierarchy = array();
87  $ThisFileInfo['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($fd, $atomsize), $ThisFileInfo, $offset, $atomHierarchy, $ParseAllPossibleAtoms);
88  break;
89  }
90 
91  $offset += $atomsize;
92  $atomcounter++;
93  }
94 
95  if (!empty($ThisFileInfo['avdataend_tmp'])) {
96  // this value is assigned to a temp value and then erased because
97  // otherwise any atoms beyond the 'mdat' atom would not get parsed
98  $ThisFileInfo['avdataend'] = $ThisFileInfo['avdataend_tmp'];
99  unset($ThisFileInfo['avdataend_tmp']);
100  }
101 
102  if (!isset($ThisFileInfo['bitrate']) && isset($ThisFileInfo['playtime_seconds'])) {
103  $ThisFileInfo['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
104  }
105  if (isset($ThisFileInfo['bitrate']) && !isset($ThisFileInfo['audio']['bitrate']) && !isset($ThisFileInfo['quicktime']['video'])) {
106  $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['bitrate'];
107  }
108 
109  if (($ThisFileInfo['audio']['dataformat'] == 'mp4') && empty($ThisFileInfo['video']['resolution_x'])) {
110  $ThisFileInfo['fileformat'] = 'mp4';
111  $ThisFileInfo['mime_type'] = 'audio/mp4';
112  unset($ThisFileInfo['video']['dataformat']);
113  }
114 
115  if (!$ReturnAtomData) {
116  unset($ThisFileInfo['quicktime']['moov']);
117  }
118 
119  if (empty($ThisFileInfo['audio']['dataformat']) && !empty($ThisFileInfo['quicktime']['audio'])) {
120  $ThisFileInfo['audio']['dataformat'] = 'quicktime';
121  }
122  if (empty($ThisFileInfo['video']['dataformat']) && !empty($ThisFileInfo['quicktime']['video'])) {
123  $ThisFileInfo['video']['dataformat'] = 'quicktime';
124  }
125 
126  return true;
127  }
QuicktimeParseAtom($atomname, $atomsize, $atomdata, &$ThisFileInfo, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms)
MPEGaudioHeaderDecode($Header4Bytes)
fread($bytes)
Definition: getid3.php:1685
MPEGaudioHeaderValid($rawarray, $echoerrors=false, $allowBitrate15=false)
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
getOnlyMPEGaudioInfo($fd, &$ThisFileInfo, $avdataoffset, $BitrateHistogram=false)
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
+ Here is the call graph for this function:

◆ NoNullString() [1/2]

getid3_quicktime::NoNullString (   $nullterminatedstring)

Definition at line 1287 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1287  {
1288  // remove the single null terminator on null terminated strings
1289  if (substr($nullterminatedstring, strlen($nullterminatedstring) - 1, 1) === "\x00") {
1290  return substr($nullterminatedstring, 0, strlen($nullterminatedstring) - 1);
1291  }
1292  return $nullterminatedstring;
1293  }
+ Here is the caller graph for this function:

◆ NoNullString() [2/2]

getid3_quicktime::NoNullString (   $nullterminatedstring)

Definition at line 2265 of file module.audio-video.quicktime.php.

2265  {
2266  // remove the single null terminator on null terminated strings
2267  if (substr($nullterminatedstring, strlen($nullterminatedstring) - 1, 1) === "\x00") {
2268  return substr($nullterminatedstring, 0, strlen($nullterminatedstring) - 1);
2269  }
2270  return $nullterminatedstring;
2271  }

◆ Pascal2String() [1/2]

getid3_quicktime::Pascal2String (   $pascalstring)

Definition at line 1295 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1295  {
1296  // Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string
1297  return substr($pascalstring, 1);
1298  }
+ Here is the caller graph for this function:

◆ Pascal2String() [2/2]

getid3_quicktime::Pascal2String (   $pascalstring)

Definition at line 2273 of file module.audio-video.quicktime.php.

2273  {
2274  // Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string
2275  return substr($pascalstring, 1);
2276  }

◆ quicktime_read_mp4_descr_length()

getid3_quicktime::quicktime_read_mp4_descr_length (   $data,
$offset 
)

Definition at line 1481 of file module.audio-video.quicktime.php.

References $data.

Referenced by QuicktimeParseAtom().

1481  {
1482  // http://libquicktime.sourcearchive.com/documentation/2:1.0.2plus-pdebian-2build1/esds_8c-source.html
1483  $num_bytes = 0;
1484  $length = 0;
1485  do {
1486  $b = ord(substr($data, $offset++, 1));
1487  $length = ($length << 7) | ($b & 0x7F);
1488  } while (($b & 0x80) && ($num_bytes++ < 4));
1489  return $length;
1490  }
$data
+ Here is the caller graph for this function:

◆ QuicktimeAudioCodecLookup() [1/2]

getid3_quicktime::QuicktimeAudioCodecLookup (   $codecid)

Definition at line 1166 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1166  {
1167  static $QuicktimeAudioCodecLookup = array();
1168  if (empty($QuicktimeAudioCodecLookup)) {
1169  $QuicktimeAudioCodecLookup['.mp3'] = 'Fraunhofer MPEG Layer-III alias';
1170  $QuicktimeAudioCodecLookup['aac '] = 'ISO/IEC 14496-3 AAC';
1171  $QuicktimeAudioCodecLookup['agsm'] = 'Apple GSM 10:1';
1172  $QuicktimeAudioCodecLookup['alac'] = 'Apple Lossless Audio Codec';
1173  $QuicktimeAudioCodecLookup['alaw'] = 'A-law 2:1';
1174  $QuicktimeAudioCodecLookup['conv'] = 'Sample Format';
1175  $QuicktimeAudioCodecLookup['dvca'] = 'DV';
1176  $QuicktimeAudioCodecLookup['dvi '] = 'DV 4:1';
1177  $QuicktimeAudioCodecLookup['eqal'] = 'Frequency Equalizer';
1178  $QuicktimeAudioCodecLookup['fl32'] = '32-bit Floating Point';
1179  $QuicktimeAudioCodecLookup['fl64'] = '64-bit Floating Point';
1180  $QuicktimeAudioCodecLookup['ima4'] = 'Interactive Multimedia Association 4:1';
1181  $QuicktimeAudioCodecLookup['in24'] = '24-bit Integer';
1182  $QuicktimeAudioCodecLookup['in32'] = '32-bit Integer';
1183  $QuicktimeAudioCodecLookup['lpc '] = 'LPC 23:1';
1184  $QuicktimeAudioCodecLookup['MAC3'] = 'Macintosh Audio Compression/Expansion (MACE) 3:1';
1185  $QuicktimeAudioCodecLookup['MAC6'] = 'Macintosh Audio Compression/Expansion (MACE) 6:1';
1186  $QuicktimeAudioCodecLookup['mixb'] = '8-bit Mixer';
1187  $QuicktimeAudioCodecLookup['mixw'] = '16-bit Mixer';
1188  $QuicktimeAudioCodecLookup['mp4a'] = 'ISO/IEC 14496-3 AAC';
1189  $QuicktimeAudioCodecLookup['MS'."\x00\x02"] = 'Microsoft ADPCM';
1190  $QuicktimeAudioCodecLookup['MS'."\x00\x11"] = 'DV IMA';
1191  $QuicktimeAudioCodecLookup['MS'."\x00\x55"] = 'Fraunhofer MPEG Layer III';
1192  $QuicktimeAudioCodecLookup['NONE'] = 'No Encoding';
1193  $QuicktimeAudioCodecLookup['Qclp'] = 'Qualcomm PureVoice';
1194  $QuicktimeAudioCodecLookup['QDM2'] = 'QDesign Music 2';
1195  $QuicktimeAudioCodecLookup['QDMC'] = 'QDesign Music 1';
1196  $QuicktimeAudioCodecLookup['ratb'] = '8-bit Rate';
1197  $QuicktimeAudioCodecLookup['ratw'] = '16-bit Rate';
1198  $QuicktimeAudioCodecLookup['raw '] = 'raw PCM';
1199  $QuicktimeAudioCodecLookup['sour'] = 'Sound Source';
1200  $QuicktimeAudioCodecLookup['sowt'] = 'signed/two\'s complement (Little Endian)';
1201  $QuicktimeAudioCodecLookup['str1'] = 'Iomega MPEG layer II';
1202  $QuicktimeAudioCodecLookup['str2'] = 'Iomega MPEG *layer II';
1203  $QuicktimeAudioCodecLookup['str3'] = 'Iomega MPEG **layer II';
1204  $QuicktimeAudioCodecLookup['str4'] = 'Iomega MPEG ***layer II';
1205  $QuicktimeAudioCodecLookup['twos'] = 'signed/two\'s complement (Big Endian)';
1206  $QuicktimeAudioCodecLookup['ulaw'] = 'mu-law 2:1';
1207  }
1208  return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : '');
1209  }
+ Here is the caller graph for this function:

◆ QuicktimeAudioCodecLookup() [2/2]

getid3_quicktime::QuicktimeAudioCodecLookup (   $codecid)

Definition at line 1689 of file module.audio-video.quicktime.php.

1689  {
1690  static $QuicktimeAudioCodecLookup = array();
1691  if (empty($QuicktimeAudioCodecLookup)) {
1692  $QuicktimeAudioCodecLookup['.mp3'] = 'Fraunhofer MPEG Layer-III alias';
1693  $QuicktimeAudioCodecLookup['aac '] = 'ISO/IEC 14496-3 AAC';
1694  $QuicktimeAudioCodecLookup['agsm'] = 'Apple GSM 10:1';
1695  $QuicktimeAudioCodecLookup['alac'] = 'Apple Lossless Audio Codec';
1696  $QuicktimeAudioCodecLookup['alaw'] = 'A-law 2:1';
1697  $QuicktimeAudioCodecLookup['conv'] = 'Sample Format';
1698  $QuicktimeAudioCodecLookup['dvca'] = 'DV';
1699  $QuicktimeAudioCodecLookup['dvi '] = 'DV 4:1';
1700  $QuicktimeAudioCodecLookup['eqal'] = 'Frequency Equalizer';
1701  $QuicktimeAudioCodecLookup['fl32'] = '32-bit Floating Point';
1702  $QuicktimeAudioCodecLookup['fl64'] = '64-bit Floating Point';
1703  $QuicktimeAudioCodecLookup['ima4'] = 'Interactive Multimedia Association 4:1';
1704  $QuicktimeAudioCodecLookup['in24'] = '24-bit Integer';
1705  $QuicktimeAudioCodecLookup['in32'] = '32-bit Integer';
1706  $QuicktimeAudioCodecLookup['lpc '] = 'LPC 23:1';
1707  $QuicktimeAudioCodecLookup['MAC3'] = 'Macintosh Audio Compression/Expansion (MACE) 3:1';
1708  $QuicktimeAudioCodecLookup['MAC6'] = 'Macintosh Audio Compression/Expansion (MACE) 6:1';
1709  $QuicktimeAudioCodecLookup['mixb'] = '8-bit Mixer';
1710  $QuicktimeAudioCodecLookup['mixw'] = '16-bit Mixer';
1711  $QuicktimeAudioCodecLookup['mp4a'] = 'ISO/IEC 14496-3 AAC';
1712  $QuicktimeAudioCodecLookup['MS'."\x00\x02"] = 'Microsoft ADPCM';
1713  $QuicktimeAudioCodecLookup['MS'."\x00\x11"] = 'DV IMA';
1714  $QuicktimeAudioCodecLookup['MS'."\x00\x55"] = 'Fraunhofer MPEG Layer III';
1715  $QuicktimeAudioCodecLookup['NONE'] = 'No Encoding';
1716  $QuicktimeAudioCodecLookup['Qclp'] = 'Qualcomm PureVoice';
1717  $QuicktimeAudioCodecLookup['QDM2'] = 'QDesign Music 2';
1718  $QuicktimeAudioCodecLookup['QDMC'] = 'QDesign Music 1';
1719  $QuicktimeAudioCodecLookup['ratb'] = '8-bit Rate';
1720  $QuicktimeAudioCodecLookup['ratw'] = '16-bit Rate';
1721  $QuicktimeAudioCodecLookup['raw '] = 'raw PCM';
1722  $QuicktimeAudioCodecLookup['sour'] = 'Sound Source';
1723  $QuicktimeAudioCodecLookup['sowt'] = 'signed/two\'s complement (Little Endian)';
1724  $QuicktimeAudioCodecLookup['str1'] = 'Iomega MPEG layer II';
1725  $QuicktimeAudioCodecLookup['str2'] = 'Iomega MPEG *layer II';
1726  $QuicktimeAudioCodecLookup['str3'] = 'Iomega MPEG **layer II';
1727  $QuicktimeAudioCodecLookup['str4'] = 'Iomega MPEG ***layer II';
1728  $QuicktimeAudioCodecLookup['twos'] = 'signed/two\'s complement (Big Endian)';
1729  $QuicktimeAudioCodecLookup['ulaw'] = 'mu-law 2:1';
1730  }
1731  return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : '');
1732  }

◆ QuicktimeColorNameLookup() [1/2]

getid3_quicktime::QuicktimeColorNameLookup (   $colordepthid)

Definition at line 1220 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1220  {
1221  static $QuicktimeColorNameLookup = array();
1222  if (empty($QuicktimeColorNameLookup)) {
1223  $QuicktimeColorNameLookup[1] = '2-color (monochrome)';
1224  $QuicktimeColorNameLookup[2] = '4-color';
1225  $QuicktimeColorNameLookup[4] = '16-color';
1226  $QuicktimeColorNameLookup[8] = '256-color';
1227  $QuicktimeColorNameLookup[16] = 'thousands (16-bit color)';
1228  $QuicktimeColorNameLookup[24] = 'millions (24-bit color)';
1229  $QuicktimeColorNameLookup[32] = 'millions+ (32-bit color)';
1230  $QuicktimeColorNameLookup[33] = 'black & white';
1231  $QuicktimeColorNameLookup[34] = '4-gray';
1232  $QuicktimeColorNameLookup[36] = '16-gray';
1233  $QuicktimeColorNameLookup[40] = '256-gray';
1234  }
1235  return (isset($QuicktimeColorNameLookup[$colordepthid]) ? $QuicktimeColorNameLookup[$colordepthid] : 'invalid');
1236  }
+ Here is the caller graph for this function:

◆ QuicktimeColorNameLookup() [2/2]

getid3_quicktime::QuicktimeColorNameLookup (   $colordepthid)

Definition at line 1743 of file module.audio-video.quicktime.php.

1743  {
1744  static $QuicktimeColorNameLookup = array();
1745  if (empty($QuicktimeColorNameLookup)) {
1746  $QuicktimeColorNameLookup[1] = '2-color (monochrome)';
1747  $QuicktimeColorNameLookup[2] = '4-color';
1748  $QuicktimeColorNameLookup[4] = '16-color';
1749  $QuicktimeColorNameLookup[8] = '256-color';
1750  $QuicktimeColorNameLookup[16] = 'thousands (16-bit color)';
1751  $QuicktimeColorNameLookup[24] = 'millions (24-bit color)';
1752  $QuicktimeColorNameLookup[32] = 'millions+ (32-bit color)';
1753  $QuicktimeColorNameLookup[33] = 'black & white';
1754  $QuicktimeColorNameLookup[34] = '4-gray';
1755  $QuicktimeColorNameLookup[36] = '16-gray';
1756  $QuicktimeColorNameLookup[40] = '256-gray';
1757  }
1758  return (isset($QuicktimeColorNameLookup[$colordepthid]) ? $QuicktimeColorNameLookup[$colordepthid] : 'invalid');
1759  }

◆ QuicktimeContentRatingLookup()

getid3_quicktime::QuicktimeContentRatingLookup (   $rtng)

Definition at line 1910 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1910  {
1911  static $QuicktimeContentRatingLookup = array();
1912  if (empty($QuicktimeContentRatingLookup)) {
1913  $QuicktimeContentRatingLookup[0] = 'None';
1914  $QuicktimeContentRatingLookup[2] = 'Clean';
1915  $QuicktimeContentRatingLookup[4] = 'Explicit';
1916  }
1917  return (isset($QuicktimeContentRatingLookup[$rtng]) ? $QuicktimeContentRatingLookup[$rtng] : 'invalid');
1918  }
+ Here is the caller graph for this function:

◆ QuicktimeDCOMLookup() [1/2]

getid3_quicktime::QuicktimeDCOMLookup (   $compressionid)

Definition at line 1211 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1211  {
1212  static $QuicktimeDCOMLookup = array();
1213  if (empty($QuicktimeDCOMLookup)) {
1214  $QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate';
1215  $QuicktimeDCOMLookup['adec'] = 'Apple Compression';
1216  }
1217  return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : '');
1218  }
+ Here is the caller graph for this function:

◆ QuicktimeDCOMLookup() [2/2]

getid3_quicktime::QuicktimeDCOMLookup (   $compressionid)

Definition at line 1734 of file module.audio-video.quicktime.php.

1734  {
1735  static $QuicktimeDCOMLookup = array();
1736  if (empty($QuicktimeDCOMLookup)) {
1737  $QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate';
1738  $QuicktimeDCOMLookup['adec'] = 'Apple Compression';
1739  }
1740  return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : '');
1741  }

◆ QuicktimeIODSaudioProfileName()

getid3_quicktime::QuicktimeIODSaudioProfileName (   $audio_profile_id)

Definition at line 1778 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1778  {
1779  static $QuicktimeIODSaudioProfileNameLookup = array();
1780  if (empty($QuicktimeIODSaudioProfileNameLookup)) {
1781  $QuicktimeIODSaudioProfileNameLookup = array(
1782  0x00 => 'ISO Reserved (0x00)',
1783  0x01 => 'Main Audio Profile @ Level 1',
1784  0x02 => 'Main Audio Profile @ Level 2',
1785  0x03 => 'Main Audio Profile @ Level 3',
1786  0x04 => 'Main Audio Profile @ Level 4',
1787  0x05 => 'Scalable Audio Profile @ Level 1',
1788  0x06 => 'Scalable Audio Profile @ Level 2',
1789  0x07 => 'Scalable Audio Profile @ Level 3',
1790  0x08 => 'Scalable Audio Profile @ Level 4',
1791  0x09 => 'Speech Audio Profile @ Level 1',
1792  0x0A => 'Speech Audio Profile @ Level 2',
1793  0x0B => 'Synthetic Audio Profile @ Level 1',
1794  0x0C => 'Synthetic Audio Profile @ Level 2',
1795  0x0D => 'Synthetic Audio Profile @ Level 3',
1796  0x0E => 'High Quality Audio Profile @ Level 1',
1797  0x0F => 'High Quality Audio Profile @ Level 2',
1798  0x10 => 'High Quality Audio Profile @ Level 3',
1799  0x11 => 'High Quality Audio Profile @ Level 4',
1800  0x12 => 'High Quality Audio Profile @ Level 5',
1801  0x13 => 'High Quality Audio Profile @ Level 6',
1802  0x14 => 'High Quality Audio Profile @ Level 7',
1803  0x15 => 'High Quality Audio Profile @ Level 8',
1804  0x16 => 'Low Delay Audio Profile @ Level 1',
1805  0x17 => 'Low Delay Audio Profile @ Level 2',
1806  0x18 => 'Low Delay Audio Profile @ Level 3',
1807  0x19 => 'Low Delay Audio Profile @ Level 4',
1808  0x1A => 'Low Delay Audio Profile @ Level 5',
1809  0x1B => 'Low Delay Audio Profile @ Level 6',
1810  0x1C => 'Low Delay Audio Profile @ Level 7',
1811  0x1D => 'Low Delay Audio Profile @ Level 8',
1812  0x1E => 'Natural Audio Profile @ Level 1',
1813  0x1F => 'Natural Audio Profile @ Level 2',
1814  0x20 => 'Natural Audio Profile @ Level 3',
1815  0x21 => 'Natural Audio Profile @ Level 4',
1816  0x22 => 'Mobile Audio Internetworking Profile @ Level 1',
1817  0x23 => 'Mobile Audio Internetworking Profile @ Level 2',
1818  0x24 => 'Mobile Audio Internetworking Profile @ Level 3',
1819  0x25 => 'Mobile Audio Internetworking Profile @ Level 4',
1820  0x26 => 'Mobile Audio Internetworking Profile @ Level 5',
1821  0x27 => 'Mobile Audio Internetworking Profile @ Level 6',
1822  0x28 => 'AAC Profile @ Level 1',
1823  0x29 => 'AAC Profile @ Level 2',
1824  0x2A => 'AAC Profile @ Level 4',
1825  0x2B => 'AAC Profile @ Level 5',
1826  0x2C => 'High Efficiency AAC Profile @ Level 2',
1827  0x2D => 'High Efficiency AAC Profile @ Level 3',
1828  0x2E => 'High Efficiency AAC Profile @ Level 4',
1829  0x2F => 'High Efficiency AAC Profile @ Level 5',
1830  0xFE => 'Not part of MPEG-4 audio profiles',
1831  0xFF => 'No audio capability required',
1832  );
1833  }
1834  return (isset($QuicktimeIODSaudioProfileNameLookup[$audio_profile_id]) ? $QuicktimeIODSaudioProfileNameLookup[$audio_profile_id] : 'ISO Reserved / User Private');
1835  }
+ Here is the caller graph for this function:

◆ QuicktimeIODSvideoProfileName()

getid3_quicktime::QuicktimeIODSvideoProfileName (   $video_profile_id)

Definition at line 1838 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1838  {
1839  static $QuicktimeIODSvideoProfileNameLookup = array();
1840  if (empty($QuicktimeIODSvideoProfileNameLookup)) {
1841  $QuicktimeIODSvideoProfileNameLookup = array(
1842  0x00 => 'Reserved (0x00) Profile',
1843  0x01 => 'Simple Profile @ Level 1',
1844  0x02 => 'Simple Profile @ Level 2',
1845  0x03 => 'Simple Profile @ Level 3',
1846  0x08 => 'Simple Profile @ Level 0',
1847  0x10 => 'Simple Scalable Profile @ Level 0',
1848  0x11 => 'Simple Scalable Profile @ Level 1',
1849  0x12 => 'Simple Scalable Profile @ Level 2',
1850  0x15 => 'AVC/H264 Profile',
1851  0x21 => 'Core Profile @ Level 1',
1852  0x22 => 'Core Profile @ Level 2',
1853  0x32 => 'Main Profile @ Level 2',
1854  0x33 => 'Main Profile @ Level 3',
1855  0x34 => 'Main Profile @ Level 4',
1856  0x42 => 'N-bit Profile @ Level 2',
1857  0x51 => 'Scalable Texture Profile @ Level 1',
1858  0x61 => 'Simple Face Animation Profile @ Level 1',
1859  0x62 => 'Simple Face Animation Profile @ Level 2',
1860  0x63 => 'Simple FBA Profile @ Level 1',
1861  0x64 => 'Simple FBA Profile @ Level 2',
1862  0x71 => 'Basic Animated Texture Profile @ Level 1',
1863  0x72 => 'Basic Animated Texture Profile @ Level 2',
1864  0x81 => 'Hybrid Profile @ Level 1',
1865  0x82 => 'Hybrid Profile @ Level 2',
1866  0x91 => 'Advanced Real Time Simple Profile @ Level 1',
1867  0x92 => 'Advanced Real Time Simple Profile @ Level 2',
1868  0x93 => 'Advanced Real Time Simple Profile @ Level 3',
1869  0x94 => 'Advanced Real Time Simple Profile @ Level 4',
1870  0xA1 => 'Core Scalable Profile @ Level1',
1871  0xA2 => 'Core Scalable Profile @ Level2',
1872  0xA3 => 'Core Scalable Profile @ Level3',
1873  0xB1 => 'Advanced Coding Efficiency Profile @ Level 1',
1874  0xB2 => 'Advanced Coding Efficiency Profile @ Level 2',
1875  0xB3 => 'Advanced Coding Efficiency Profile @ Level 3',
1876  0xB4 => 'Advanced Coding Efficiency Profile @ Level 4',
1877  0xC1 => 'Advanced Core Profile @ Level 1',
1878  0xC2 => 'Advanced Core Profile @ Level 2',
1879  0xD1 => 'Advanced Scalable Texture @ Level1',
1880  0xD2 => 'Advanced Scalable Texture @ Level2',
1881  0xE1 => 'Simple Studio Profile @ Level 1',
1882  0xE2 => 'Simple Studio Profile @ Level 2',
1883  0xE3 => 'Simple Studio Profile @ Level 3',
1884  0xE4 => 'Simple Studio Profile @ Level 4',
1885  0xE5 => 'Core Studio Profile @ Level 1',
1886  0xE6 => 'Core Studio Profile @ Level 2',
1887  0xE7 => 'Core Studio Profile @ Level 3',
1888  0xE8 => 'Core Studio Profile @ Level 4',
1889  0xF0 => 'Advanced Simple Profile @ Level 0',
1890  0xF1 => 'Advanced Simple Profile @ Level 1',
1891  0xF2 => 'Advanced Simple Profile @ Level 2',
1892  0xF3 => 'Advanced Simple Profile @ Level 3',
1893  0xF4 => 'Advanced Simple Profile @ Level 4',
1894  0xF5 => 'Advanced Simple Profile @ Level 5',
1895  0xF7 => 'Advanced Simple Profile @ Level 3b',
1896  0xF8 => 'Fine Granularity Scalable Profile @ Level 0',
1897  0xF9 => 'Fine Granularity Scalable Profile @ Level 1',
1898  0xFA => 'Fine Granularity Scalable Profile @ Level 2',
1899  0xFB => 'Fine Granularity Scalable Profile @ Level 3',
1900  0xFC => 'Fine Granularity Scalable Profile @ Level 4',
1901  0xFD => 'Fine Granularity Scalable Profile @ Level 5',
1902  0xFE => 'Not part of MPEG-4 Visual profiles',
1903  0xFF => 'No visual capability required',
1904  );
1905  }
1906  return (isset($QuicktimeIODSvideoProfileNameLookup[$video_profile_id]) ? $QuicktimeIODSvideoProfileNameLookup[$video_profile_id] : 'ISO Reserved Profile');
1907  }
+ Here is the caller graph for this function:

◆ QuicktimeLanguageLookup() [1/2]

getid3_quicktime::QuicktimeLanguageLookup (   $languageid)

Definition at line 991 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

991  {
992  static $QuicktimeLanguageLookup = array();
993  if (empty($QuicktimeLanguageLookup)) {
994  $QuicktimeLanguageLookup[0] = 'English';
995  $QuicktimeLanguageLookup[1] = 'French';
996  $QuicktimeLanguageLookup[2] = 'German';
997  $QuicktimeLanguageLookup[3] = 'Italian';
998  $QuicktimeLanguageLookup[4] = 'Dutch';
999  $QuicktimeLanguageLookup[5] = 'Swedish';
1000  $QuicktimeLanguageLookup[6] = 'Spanish';
1001  $QuicktimeLanguageLookup[7] = 'Danish';
1002  $QuicktimeLanguageLookup[8] = 'Portuguese';
1003  $QuicktimeLanguageLookup[9] = 'Norwegian';
1004  $QuicktimeLanguageLookup[10] = 'Hebrew';
1005  $QuicktimeLanguageLookup[11] = 'Japanese';
1006  $QuicktimeLanguageLookup[12] = 'Arabic';
1007  $QuicktimeLanguageLookup[13] = 'Finnish';
1008  $QuicktimeLanguageLookup[14] = 'Greek';
1009  $QuicktimeLanguageLookup[15] = 'Icelandic';
1010  $QuicktimeLanguageLookup[16] = 'Maltese';
1011  $QuicktimeLanguageLookup[17] = 'Turkish';
1012  $QuicktimeLanguageLookup[18] = 'Croatian';
1013  $QuicktimeLanguageLookup[19] = 'Chinese (Traditional)';
1014  $QuicktimeLanguageLookup[20] = 'Urdu';
1015  $QuicktimeLanguageLookup[21] = 'Hindi';
1016  $QuicktimeLanguageLookup[22] = 'Thai';
1017  $QuicktimeLanguageLookup[23] = 'Korean';
1018  $QuicktimeLanguageLookup[24] = 'Lithuanian';
1019  $QuicktimeLanguageLookup[25] = 'Polish';
1020  $QuicktimeLanguageLookup[26] = 'Hungarian';
1021  $QuicktimeLanguageLookup[27] = 'Estonian';
1022  $QuicktimeLanguageLookup[28] = 'Lettish';
1023  $QuicktimeLanguageLookup[28] = 'Latvian';
1024  $QuicktimeLanguageLookup[29] = 'Saamisk';
1025  $QuicktimeLanguageLookup[29] = 'Lappish';
1026  $QuicktimeLanguageLookup[30] = 'Faeroese';
1027  $QuicktimeLanguageLookup[31] = 'Farsi';
1028  $QuicktimeLanguageLookup[31] = 'Persian';
1029  $QuicktimeLanguageLookup[32] = 'Russian';
1030  $QuicktimeLanguageLookup[33] = 'Chinese (Simplified)';
1031  $QuicktimeLanguageLookup[34] = 'Flemish';
1032  $QuicktimeLanguageLookup[35] = 'Irish';
1033  $QuicktimeLanguageLookup[36] = 'Albanian';
1034  $QuicktimeLanguageLookup[37] = 'Romanian';
1035  $QuicktimeLanguageLookup[38] = 'Czech';
1036  $QuicktimeLanguageLookup[39] = 'Slovak';
1037  $QuicktimeLanguageLookup[40] = 'Slovenian';
1038  $QuicktimeLanguageLookup[41] = 'Yiddish';
1039  $QuicktimeLanguageLookup[42] = 'Serbian';
1040  $QuicktimeLanguageLookup[43] = 'Macedonian';
1041  $QuicktimeLanguageLookup[44] = 'Bulgarian';
1042  $QuicktimeLanguageLookup[45] = 'Ukrainian';
1043  $QuicktimeLanguageLookup[46] = 'Byelorussian';
1044  $QuicktimeLanguageLookup[47] = 'Uzbek';
1045  $QuicktimeLanguageLookup[48] = 'Kazakh';
1046  $QuicktimeLanguageLookup[49] = 'Azerbaijani';
1047  $QuicktimeLanguageLookup[50] = 'AzerbaijanAr';
1048  $QuicktimeLanguageLookup[51] = 'Armenian';
1049  $QuicktimeLanguageLookup[52] = 'Georgian';
1050  $QuicktimeLanguageLookup[53] = 'Moldavian';
1051  $QuicktimeLanguageLookup[54] = 'Kirghiz';
1052  $QuicktimeLanguageLookup[55] = 'Tajiki';
1053  $QuicktimeLanguageLookup[56] = 'Turkmen';
1054  $QuicktimeLanguageLookup[57] = 'Mongolian';
1055  $QuicktimeLanguageLookup[58] = 'MongolianCyr';
1056  $QuicktimeLanguageLookup[59] = 'Pashto';
1057  $QuicktimeLanguageLookup[60] = 'Kurdish';
1058  $QuicktimeLanguageLookup[61] = 'Kashmiri';
1059  $QuicktimeLanguageLookup[62] = 'Sindhi';
1060  $QuicktimeLanguageLookup[63] = 'Tibetan';
1061  $QuicktimeLanguageLookup[64] = 'Nepali';
1062  $QuicktimeLanguageLookup[65] = 'Sanskrit';
1063  $QuicktimeLanguageLookup[66] = 'Marathi';
1064  $QuicktimeLanguageLookup[67] = 'Bengali';
1065  $QuicktimeLanguageLookup[68] = 'Assamese';
1066  $QuicktimeLanguageLookup[69] = 'Gujarati';
1067  $QuicktimeLanguageLookup[70] = 'Punjabi';
1068  $QuicktimeLanguageLookup[71] = 'Oriya';
1069  $QuicktimeLanguageLookup[72] = 'Malayalam';
1070  $QuicktimeLanguageLookup[73] = 'Kannada';
1071  $QuicktimeLanguageLookup[74] = 'Tamil';
1072  $QuicktimeLanguageLookup[75] = 'Telugu';
1073  $QuicktimeLanguageLookup[76] = 'Sinhalese';
1074  $QuicktimeLanguageLookup[77] = 'Burmese';
1075  $QuicktimeLanguageLookup[78] = 'Khmer';
1076  $QuicktimeLanguageLookup[79] = 'Lao';
1077  $QuicktimeLanguageLookup[80] = 'Vietnamese';
1078  $QuicktimeLanguageLookup[81] = 'Indonesian';
1079  $QuicktimeLanguageLookup[82] = 'Tagalog';
1080  $QuicktimeLanguageLookup[83] = 'MalayRoman';
1081  $QuicktimeLanguageLookup[84] = 'MalayArabic';
1082  $QuicktimeLanguageLookup[85] = 'Amharic';
1083  $QuicktimeLanguageLookup[86] = 'Tigrinya';
1084  $QuicktimeLanguageLookup[87] = 'Galla';
1085  $QuicktimeLanguageLookup[87] = 'Oromo';
1086  $QuicktimeLanguageLookup[88] = 'Somali';
1087  $QuicktimeLanguageLookup[89] = 'Swahili';
1088  $QuicktimeLanguageLookup[90] = 'Ruanda';
1089  $QuicktimeLanguageLookup[91] = 'Rundi';
1090  $QuicktimeLanguageLookup[92] = 'Chewa';
1091  $QuicktimeLanguageLookup[93] = 'Malagasy';
1092  $QuicktimeLanguageLookup[94] = 'Esperanto';
1093  $QuicktimeLanguageLookup[128] = 'Welsh';
1094  $QuicktimeLanguageLookup[129] = 'Basque';
1095  $QuicktimeLanguageLookup[130] = 'Catalan';
1096  $QuicktimeLanguageLookup[131] = 'Latin';
1097  $QuicktimeLanguageLookup[132] = 'Quechua';
1098  $QuicktimeLanguageLookup[133] = 'Guarani';
1099  $QuicktimeLanguageLookup[134] = 'Aymara';
1100  $QuicktimeLanguageLookup[135] = 'Tatar';
1101  $QuicktimeLanguageLookup[136] = 'Uighur';
1102  $QuicktimeLanguageLookup[137] = 'Dzongkha';
1103  $QuicktimeLanguageLookup[138] = 'JavaneseRom';
1104  }
1105  return (isset($QuicktimeLanguageLookup[$languageid]) ? $QuicktimeLanguageLookup[$languageid] : 'invalid');
1106  }
+ Here is the caller graph for this function:

◆ QuicktimeLanguageLookup() [2/2]

getid3_quicktime::QuicktimeLanguageLookup (   $languageid)

Definition at line 1493 of file module.audio-video.quicktime.php.

References getid3_id3v2\LanguageLookup().

1493  {
1494  // http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-34353
1495  static $QuicktimeLanguageLookup = array();
1496  if (empty($QuicktimeLanguageLookup)) {
1497  $QuicktimeLanguageLookup[0] = 'English';
1498  $QuicktimeLanguageLookup[1] = 'French';
1499  $QuicktimeLanguageLookup[2] = 'German';
1500  $QuicktimeLanguageLookup[3] = 'Italian';
1501  $QuicktimeLanguageLookup[4] = 'Dutch';
1502  $QuicktimeLanguageLookup[5] = 'Swedish';
1503  $QuicktimeLanguageLookup[6] = 'Spanish';
1504  $QuicktimeLanguageLookup[7] = 'Danish';
1505  $QuicktimeLanguageLookup[8] = 'Portuguese';
1506  $QuicktimeLanguageLookup[9] = 'Norwegian';
1507  $QuicktimeLanguageLookup[10] = 'Hebrew';
1508  $QuicktimeLanguageLookup[11] = 'Japanese';
1509  $QuicktimeLanguageLookup[12] = 'Arabic';
1510  $QuicktimeLanguageLookup[13] = 'Finnish';
1511  $QuicktimeLanguageLookup[14] = 'Greek';
1512  $QuicktimeLanguageLookup[15] = 'Icelandic';
1513  $QuicktimeLanguageLookup[16] = 'Maltese';
1514  $QuicktimeLanguageLookup[17] = 'Turkish';
1515  $QuicktimeLanguageLookup[18] = 'Croatian';
1516  $QuicktimeLanguageLookup[19] = 'Chinese (Traditional)';
1517  $QuicktimeLanguageLookup[20] = 'Urdu';
1518  $QuicktimeLanguageLookup[21] = 'Hindi';
1519  $QuicktimeLanguageLookup[22] = 'Thai';
1520  $QuicktimeLanguageLookup[23] = 'Korean';
1521  $QuicktimeLanguageLookup[24] = 'Lithuanian';
1522  $QuicktimeLanguageLookup[25] = 'Polish';
1523  $QuicktimeLanguageLookup[26] = 'Hungarian';
1524  $QuicktimeLanguageLookup[27] = 'Estonian';
1525  $QuicktimeLanguageLookup[28] = 'Lettish';
1526  $QuicktimeLanguageLookup[28] = 'Latvian';
1527  $QuicktimeLanguageLookup[29] = 'Saamisk';
1528  $QuicktimeLanguageLookup[29] = 'Lappish';
1529  $QuicktimeLanguageLookup[30] = 'Faeroese';
1530  $QuicktimeLanguageLookup[31] = 'Farsi';
1531  $QuicktimeLanguageLookup[31] = 'Persian';
1532  $QuicktimeLanguageLookup[32] = 'Russian';
1533  $QuicktimeLanguageLookup[33] = 'Chinese (Simplified)';
1534  $QuicktimeLanguageLookup[34] = 'Flemish';
1535  $QuicktimeLanguageLookup[35] = 'Irish';
1536  $QuicktimeLanguageLookup[36] = 'Albanian';
1537  $QuicktimeLanguageLookup[37] = 'Romanian';
1538  $QuicktimeLanguageLookup[38] = 'Czech';
1539  $QuicktimeLanguageLookup[39] = 'Slovak';
1540  $QuicktimeLanguageLookup[40] = 'Slovenian';
1541  $QuicktimeLanguageLookup[41] = 'Yiddish';
1542  $QuicktimeLanguageLookup[42] = 'Serbian';
1543  $QuicktimeLanguageLookup[43] = 'Macedonian';
1544  $QuicktimeLanguageLookup[44] = 'Bulgarian';
1545  $QuicktimeLanguageLookup[45] = 'Ukrainian';
1546  $QuicktimeLanguageLookup[46] = 'Byelorussian';
1547  $QuicktimeLanguageLookup[47] = 'Uzbek';
1548  $QuicktimeLanguageLookup[48] = 'Kazakh';
1549  $QuicktimeLanguageLookup[49] = 'Azerbaijani';
1550  $QuicktimeLanguageLookup[50] = 'AzerbaijanAr';
1551  $QuicktimeLanguageLookup[51] = 'Armenian';
1552  $QuicktimeLanguageLookup[52] = 'Georgian';
1553  $QuicktimeLanguageLookup[53] = 'Moldavian';
1554  $QuicktimeLanguageLookup[54] = 'Kirghiz';
1555  $QuicktimeLanguageLookup[55] = 'Tajiki';
1556  $QuicktimeLanguageLookup[56] = 'Turkmen';
1557  $QuicktimeLanguageLookup[57] = 'Mongolian';
1558  $QuicktimeLanguageLookup[58] = 'MongolianCyr';
1559  $QuicktimeLanguageLookup[59] = 'Pashto';
1560  $QuicktimeLanguageLookup[60] = 'Kurdish';
1561  $QuicktimeLanguageLookup[61] = 'Kashmiri';
1562  $QuicktimeLanguageLookup[62] = 'Sindhi';
1563  $QuicktimeLanguageLookup[63] = 'Tibetan';
1564  $QuicktimeLanguageLookup[64] = 'Nepali';
1565  $QuicktimeLanguageLookup[65] = 'Sanskrit';
1566  $QuicktimeLanguageLookup[66] = 'Marathi';
1567  $QuicktimeLanguageLookup[67] = 'Bengali';
1568  $QuicktimeLanguageLookup[68] = 'Assamese';
1569  $QuicktimeLanguageLookup[69] = 'Gujarati';
1570  $QuicktimeLanguageLookup[70] = 'Punjabi';
1571  $QuicktimeLanguageLookup[71] = 'Oriya';
1572  $QuicktimeLanguageLookup[72] = 'Malayalam';
1573  $QuicktimeLanguageLookup[73] = 'Kannada';
1574  $QuicktimeLanguageLookup[74] = 'Tamil';
1575  $QuicktimeLanguageLookup[75] = 'Telugu';
1576  $QuicktimeLanguageLookup[76] = 'Sinhalese';
1577  $QuicktimeLanguageLookup[77] = 'Burmese';
1578  $QuicktimeLanguageLookup[78] = 'Khmer';
1579  $QuicktimeLanguageLookup[79] = 'Lao';
1580  $QuicktimeLanguageLookup[80] = 'Vietnamese';
1581  $QuicktimeLanguageLookup[81] = 'Indonesian';
1582  $QuicktimeLanguageLookup[82] = 'Tagalog';
1583  $QuicktimeLanguageLookup[83] = 'MalayRoman';
1584  $QuicktimeLanguageLookup[84] = 'MalayArabic';
1585  $QuicktimeLanguageLookup[85] = 'Amharic';
1586  $QuicktimeLanguageLookup[86] = 'Tigrinya';
1587  $QuicktimeLanguageLookup[87] = 'Galla';
1588  $QuicktimeLanguageLookup[87] = 'Oromo';
1589  $QuicktimeLanguageLookup[88] = 'Somali';
1590  $QuicktimeLanguageLookup[89] = 'Swahili';
1591  $QuicktimeLanguageLookup[90] = 'Ruanda';
1592  $QuicktimeLanguageLookup[91] = 'Rundi';
1593  $QuicktimeLanguageLookup[92] = 'Chewa';
1594  $QuicktimeLanguageLookup[93] = 'Malagasy';
1595  $QuicktimeLanguageLookup[94] = 'Esperanto';
1596  $QuicktimeLanguageLookup[128] = 'Welsh';
1597  $QuicktimeLanguageLookup[129] = 'Basque';
1598  $QuicktimeLanguageLookup[130] = 'Catalan';
1599  $QuicktimeLanguageLookup[131] = 'Latin';
1600  $QuicktimeLanguageLookup[132] = 'Quechua';
1601  $QuicktimeLanguageLookup[133] = 'Guarani';
1602  $QuicktimeLanguageLookup[134] = 'Aymara';
1603  $QuicktimeLanguageLookup[135] = 'Tatar';
1604  $QuicktimeLanguageLookup[136] = 'Uighur';
1605  $QuicktimeLanguageLookup[137] = 'Dzongkha';
1606  $QuicktimeLanguageLookup[138] = 'JavaneseRom';
1607  $QuicktimeLanguageLookup[32767] = 'Unspecified';
1608  }
1609  if (($languageid > 138) && ($languageid < 32767)) {
1610  /*
1611  ISO Language Codes - http://www.loc.gov/standards/iso639-2/php/code_list.php
1612  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.
1613  The packing algorithm must map each of the three characters, which are always lowercase, into a 5-bit integer and then concatenate
1614  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.
1615 
1616  One algorithm for performing this packing is to treat each ISO character as a 16-bit integer. Subtract 0x60 from the first character
1617  and multiply by 2^10 (0x400), subtract 0x60 from the second character and multiply by 2^5 (0x20), subtract 0x60 from the third character,
1618  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
1619  significant bits and the most significant bit set to zero.
1620  */
1621  $iso_language_id = '';
1622  $iso_language_id .= chr((($languageid & 0x7C00) >> 10) + 0x60);
1623  $iso_language_id .= chr((($languageid & 0x03E0) >> 5) + 0x60);
1624  $iso_language_id .= chr((($languageid & 0x001F) >> 0) + 0x60);
1625  $QuicktimeLanguageLookup[$languageid] = getid3_id3v2::LanguageLookup($iso_language_id);
1626  }
1627  return (isset($QuicktimeLanguageLookup[$languageid]) ? $QuicktimeLanguageLookup[$languageid] : 'invalid');
1628  }
LanguageLookup($languagecode, $casesensitive=false)
+ Here is the call graph for this function:

◆ QuicktimeParseAtom() [1/2]

getid3_quicktime::QuicktimeParseAtom (   $atomname,
  $atomsize,
  $atom_data,
  $baseoffset,
$atomHierarchy,
  $ParseAllPossibleAtoms 
)

Definition at line 121 of file module.audio-video.quicktime.php.

References $info, $ParseAllPossibleAtoms, getid3_lib\BigEndian2Int(), CopyToAppropriateCommentsSection(), getid3_lib\DateMac2Unix(), getid3_lib\FixedPoint16_16(), getid3_lib\FixedPoint2_30(), getid3_lib\FixedPoint8_8(), getid3_id3v1\LookupGenreName(), NoNullString(), Pascal2String(), getid3_lib\PrintHexBytes(), quicktime_read_mp4_descr_length(), QuicktimeAudioCodecLookup(), QuicktimeColorNameLookup(), QuicktimeContentRatingLookup(), QuicktimeDCOMLookup(), QuicktimeIODSaudioProfileName(), QuicktimeIODSvideoProfileName(), QuicktimeLanguageLookup(), QuicktimeParseContainerAtom(), QuicktimeParseNikonNCTG(), QuicktimeSTIKLookup(), QuicktimeStoreFrontCodeLookup(), and QuicktimeVideoCodecLookup().

121  {
122  // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm
123  // https://code.google.com/p/mp4v2/wiki/iTunesMetadata
124 
125  $info = &$this->getid3->info;
126 
127  $atom_parent = end($atomHierarchy); // not array_pop($atomHierarchy); see http://www.getid3.org/phpBB3/viewtopic.php?t=1717
128  array_push($atomHierarchy, $atomname);
129  $atom_structure['hierarchy'] = implode(' ', $atomHierarchy);
130  $atom_structure['name'] = $atomname;
131  $atom_structure['size'] = $atomsize;
132  $atom_structure['offset'] = $baseoffset;
133  switch ($atomname) {
134  case 'moov': // MOVie container atom
135  case 'trak': // TRAcK container atom
136  case 'clip': // CLIPping container atom
137  case 'matt': // track MATTe container atom
138  case 'edts': // EDiTS container atom
139  case 'tref': // Track REFerence container atom
140  case 'mdia': // MeDIA container atom
141  case 'minf': // Media INFormation container atom
142  case 'dinf': // Data INFormation container atom
143  case 'udta': // User DaTA container atom
144  case 'cmov': // Compressed MOVie container atom
145  case 'rmra': // Reference Movie Record Atom
146  case 'rmda': // Reference Movie Descriptor Atom
147  case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR)
148  $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
149  break;
150 
151  case 'ilst': // Item LiST container atom
152  if ($atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms)) {
153  // some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted
154  $allnumericnames = true;
155  foreach ($atom_structure['subatoms'] as $subatomarray) {
156  if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) {
157  $allnumericnames = false;
158  break;
159  }
160  }
161  if ($allnumericnames) {
162  $newData = array();
163  foreach ($atom_structure['subatoms'] as $subatomarray) {
164  foreach ($subatomarray['subatoms'] as $newData_subatomarray) {
165  unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']);
166  $newData[$subatomarray['name']] = $newData_subatomarray;
167  break;
168  }
169  }
170  $atom_structure['data'] = $newData;
171  unset($atom_structure['subatoms']);
172  }
173  }
174  break;
175 
176  case "\x00\x00\x00\x01":
177  case "\x00\x00\x00\x02":
178  case "\x00\x00\x00\x03":
179  case "\x00\x00\x00\x04":
180  case "\x00\x00\x00\x05":
181  $atomname = getid3_lib::BigEndian2Int($atomname);
182  $atom_structure['name'] = $atomname;
183  $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
184  break;
185 
186  case 'stbl': // Sample TaBLe container atom
187  $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
188  $isVideo = false;
189  $framerate = 0;
190  $framecount = 0;
191  foreach ($atom_structure['subatoms'] as $key => $value_array) {
192  if (isset($value_array['sample_description_table'])) {
193  foreach ($value_array['sample_description_table'] as $key2 => $value_array2) {
194  if (isset($value_array2['data_format'])) {
195  switch ($value_array2['data_format']) {
196  case 'avc1':
197  case 'mp4v':
198  // video data
199  $isVideo = true;
200  break;
201  case 'mp4a':
202  // audio data
203  break;
204  }
205  }
206  }
207  } elseif (isset($value_array['time_to_sample_table'])) {
208  foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) {
209  if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0)) {
210  $framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3);
211  $framecount = $value_array2['sample_count'];
212  }
213  }
214  }
215  }
216  if ($isVideo && $framerate) {
217  $info['quicktime']['video']['frame_rate'] = $framerate;
218  $info['video']['frame_rate'] = $info['quicktime']['video']['frame_rate'];
219  }
220  if ($isVideo && $framecount) {
221  $info['quicktime']['video']['frame_count'] = $framecount;
222  }
223  break;
224 
225 
226  case "\xA9".'alb': // ALBum
227  case "\xA9".'ART': //
228  case "\xA9".'art': // ARTist
229  case "\xA9".'aut': //
230  case "\xA9".'cmt': // CoMmenT
231  case "\xA9".'com': // COMposer
232  case "\xA9".'cpy': //
233  case "\xA9".'day': // content created year
234  case "\xA9".'dir': //
235  case "\xA9".'ed1': //
236  case "\xA9".'ed2': //
237  case "\xA9".'ed3': //
238  case "\xA9".'ed4': //
239  case "\xA9".'ed5': //
240  case "\xA9".'ed6': //
241  case "\xA9".'ed7': //
242  case "\xA9".'ed8': //
243  case "\xA9".'ed9': //
244  case "\xA9".'enc': //
245  case "\xA9".'fmt': //
246  case "\xA9".'gen': // GENre
247  case "\xA9".'grp': // GRouPing
248  case "\xA9".'hst': //
249  case "\xA9".'inf': //
250  case "\xA9".'lyr': // LYRics
251  case "\xA9".'mak': //
252  case "\xA9".'mod': //
253  case "\xA9".'nam': // full NAMe
254  case "\xA9".'ope': //
255  case "\xA9".'PRD': //
256  case "\xA9".'prf': //
257  case "\xA9".'req': //
258  case "\xA9".'src': //
259  case "\xA9".'swr': //
260  case "\xA9".'too': // encoder
261  case "\xA9".'trk': // TRacK
262  case "\xA9".'url': //
263  case "\xA9".'wrn': //
264  case "\xA9".'wrt': // WRiTer
265  case '----': // itunes specific
266  case 'aART': // Album ARTist
267  case 'akID': // iTunes store account type
268  case 'apID': // Purchase Account
269  case 'atID': //
270  case 'catg': // CaTeGory
271  case 'cmID': //
272  case 'cnID': //
273  case 'covr': // COVeR artwork
274  case 'cpil': // ComPILation
275  case 'cprt': // CoPyRighT
276  case 'desc': // DESCription
277  case 'disk': // DISK number
278  case 'egid': // Episode Global ID
279  case 'geID': //
280  case 'gnre': // GeNRE
281  case 'hdvd': // HD ViDeo
282  case 'keyw': // KEYWord
283  case 'ldes': // Long DEScription
284  case 'pcst': // PodCaST
285  case 'pgap': // GAPless Playback
286  case 'plID': //
287  case 'purd': // PURchase Date
288  case 'purl': // Podcast URL
289  case 'rati': //
290  case 'rndu': //
291  case 'rpdu': //
292  case 'rtng': // RaTiNG
293  case 'sfID': // iTunes store country
294  case 'soaa': // SOrt Album Artist
295  case 'soal': // SOrt ALbum
296  case 'soar': // SOrt ARtist
297  case 'soco': // SOrt COmposer
298  case 'sonm': // SOrt NaMe
299  case 'sosn': // SOrt Show Name
300  case 'stik': //
301  case 'tmpo': // TeMPO (BPM)
302  case 'trkn': // TRacK Number
303  case 'tven': // tvEpisodeID
304  case 'tves': // TV EpiSode
305  case 'tvnn': // TV Network Name
306  case 'tvsh': // TV SHow Name
307  case 'tvsn': // TV SeasoN
308  if ($atom_parent == 'udta') {
309  // User data atom handler
310  $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
311  $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
312  $atom_structure['data'] = substr($atom_data, 4);
313 
314  $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
315  if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
316  $info['comments']['language'][] = $atom_structure['language'];
317  }
318  } else {
319  // Apple item list box atom handler
320  $atomoffset = 0;
321  if (substr($atom_data, 2, 2) == "\x10\xB5") {
322  // not sure what it means, but observed on iPhone4 data.
323  // Each $atom_data has 2 bytes of datasize, plus 0x10B5, then data
324  while ($atomoffset < strlen($atom_data)) {
325  $boxsmallsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 2));
326  $boxsmalltype = substr($atom_data, $atomoffset + 2, 2);
327  $boxsmalldata = substr($atom_data, $atomoffset + 4, $boxsmallsize);
328  if ($boxsmallsize <= 1) {
329  $info['warning'][] = 'Invalid QuickTime atom smallbox size "'.$boxsmallsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset);
330  $atom_structure['data'] = null;
331  $atomoffset = strlen($atom_data);
332  break;
333  }
334  switch ($boxsmalltype) {
335  case "\x10\xB5":
336  $atom_structure['data'] = $boxsmalldata;
337  break;
338  default:
339  $info['warning'][] = 'Unknown QuickTime smallbox type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxsmalltype).'" ('.trim(getid3_lib::PrintHexBytes($boxsmalltype)).') at offset '.$baseoffset;
340  $atom_structure['data'] = $atom_data;
341  break;
342  }
343  $atomoffset += (4 + $boxsmallsize);
344  }
345  } else {
346  while ($atomoffset < strlen($atom_data)) {
347  $boxsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 4));
348  $boxtype = substr($atom_data, $atomoffset + 4, 4);
349  $boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8);
350  if ($boxsize <= 1) {
351  $info['warning'][] = 'Invalid QuickTime atom box size "'.$boxsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset);
352  $atom_structure['data'] = null;
353  $atomoffset = strlen($atom_data);
354  break;
355  }
356  $atomoffset += $boxsize;
357 
358  switch ($boxtype) {
359  case 'mean':
360  case 'name':
361  $atom_structure[$boxtype] = substr($boxdata, 4);
362  break;
363 
364  case 'data':
365  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1));
366  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3));
367  switch ($atom_structure['flags_raw']) {
368  case 0: // data flag
369  case 21: // tmpo/cpil flag
370  switch ($atomname) {
371  case 'cpil':
372  case 'hdvd':
373  case 'pcst':
374  case 'pgap':
375  // 8-bit integer (boolean)
376  $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
377  break;
378 
379  case 'tmpo':
380  // 16-bit integer
381  $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2));
382  break;
383 
384  case 'disk':
385  case 'trkn':
386  // binary
387  $num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2));
388  $num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2));
389  $atom_structure['data'] = empty($num) ? '' : $num;
390  $atom_structure['data'] .= empty($num_total) ? '' : '/'.$num_total;
391  break;
392 
393  case 'gnre':
394  // enum
395  $GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
396  $atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1);
397  break;
398 
399  case 'rtng':
400  // 8-bit integer
401  $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
402  $atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]);
403  break;
404 
405  case 'stik':
406  // 8-bit integer (enum)
407  $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
408  $atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]);
409  break;
410 
411  case 'sfID':
412  // 32-bit integer
413  $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
414  $atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]);
415  break;
416 
417  case 'egid':
418  case 'purl':
419  $atom_structure['data'] = substr($boxdata, 8);
420  break;
421 
422  case 'plID':
423  // 64-bit integer
424  $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 8));
425 
426  case 'atID':
427  case 'cnID':
428  case 'geID':
429  case 'tves':
430  case 'tvsn':
431  default:
432  // 32-bit integer
433  $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
434  }
435  break;
436 
437  case 1: // text flag
438  case 13: // image flag
439  default:
440  $atom_structure['data'] = substr($boxdata, 8);
441  if ($atomname == 'covr') {
442  // not a foolproof check, but better than nothing
443  if (preg_match('#^\xFF\xD8\xFF#', $atom_structure['data'])) {
444  $atom_structure['image_mime'] = 'image/jpeg';
445  } elseif (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $atom_structure['data'])) {
446  $atom_structure['image_mime'] = 'image/png';
447  } elseif (preg_match('#^GIF#', $atom_structure['data'])) {
448  $atom_structure['image_mime'] = 'image/gif';
449  }
450  }
451  break;
452 
453  }
454  break;
455 
456  default:
457  $info['warning'][] = 'Unknown QuickTime box type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxtype).'" ('.trim(getid3_lib::PrintHexBytes($boxtype)).') at offset '.$baseoffset;
458  $atom_structure['data'] = $atom_data;
459 
460  }
461  }
462  }
463  }
464  $this->CopyToAppropriateCommentsSection($atomname, $atom_structure['data'], $atom_structure['name']);
465  break;
466 
467 
468  case 'play': // auto-PLAY atom
469  $atom_structure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
470 
471  $info['quicktime']['autoplay'] = $atom_structure['autoplay'];
472  break;
473 
474 
475  case 'WLOC': // Window LOCation atom
476  $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
477  $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
478  break;
479 
480 
481  case 'LOOP': // LOOPing atom
482  case 'SelO': // play SELection Only atom
483  case 'AllF': // play ALL Frames atom
484  $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data);
485  break;
486 
487 
488  case 'name': //
489  case 'MCPS': // Media Cleaner PRo
490  case '@PRM': // adobe PReMiere version
491  case '@PRQ': // adobe PRemiere Quicktime version
492  $atom_structure['data'] = $atom_data;
493  break;
494 
495 
496  case 'cmvd': // Compressed MooV Data atom
497  // Code by ubergeekØubergeek*tv based on information from
498  // http://developer.apple.com/quicktime/icefloe/dispatch012.html
499  $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
500 
501  $CompressedFileData = substr($atom_data, 4);
502  if ($UncompressedHeader = @gzuncompress($CompressedFileData)) {
503  $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, 0, $atomHierarchy, $ParseAllPossibleAtoms);
504  } else {
505  $info['warning'][] = 'Error decompressing compressed MOV atom at offset '.$atom_structure['offset'];
506  }
507  break;
508 
509 
510  case 'dcom': // Data COMpression atom
511  $atom_structure['compression_id'] = $atom_data;
512  $atom_structure['compression_text'] = $this->QuicktimeDCOMLookup($atom_data);
513  break;
514 
515 
516  case 'rdrf': // Reference movie Data ReFerence atom
517  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
518  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
519  $atom_structure['flags']['internal_data'] = (bool) ($atom_structure['flags_raw'] & 0x000001);
520 
521  $atom_structure['reference_type_name'] = substr($atom_data, 4, 4);
522  $atom_structure['reference_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
523  switch ($atom_structure['reference_type_name']) {
524  case 'url ':
525  $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12));
526  break;
527 
528  case 'alis':
529  $atom_structure['file_alias'] = substr($atom_data, 12);
530  break;
531 
532  case 'rsrc':
533  $atom_structure['resource_alias'] = substr($atom_data, 12);
534  break;
535 
536  default:
537  $atom_structure['data'] = substr($atom_data, 12);
538  break;
539  }
540  break;
541 
542 
543  case 'rmqu': // Reference Movie QUality atom
544  $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data);
545  break;
546 
547 
548  case 'rmcs': // Reference Movie Cpu Speed atom
549  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
550  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
551  $atom_structure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
552  break;
553 
554 
555  case 'rmvc': // Reference Movie Version Check atom
556  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
557  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
558  $atom_structure['gestalt_selector'] = substr($atom_data, 4, 4);
559  $atom_structure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
560  $atom_structure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
561  $atom_structure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
562  break;
563 
564 
565  case 'rmcd': // Reference Movie Component check atom
566  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
567  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
568  $atom_structure['component_type'] = substr($atom_data, 4, 4);
569  $atom_structure['component_subtype'] = substr($atom_data, 8, 4);
570  $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
571  $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
572  $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
573  $atom_structure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 4));
574  break;
575 
576 
577  case 'rmdr': // Reference Movie Data Rate atom
578  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
579  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
580  $atom_structure['data_rate'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
581 
582  $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10;
583  break;
584 
585 
586  case 'rmla': // Reference Movie Language Atom
587  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
588  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
589  $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
590 
591  $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
592  if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
593  $info['comments']['language'][] = $atom_structure['language'];
594  }
595  break;
596 
597 
598  case 'rmla': // Reference Movie Language Atom
599  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
600  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
601  $atom_structure['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
602  break;
603 
604 
605  case 'ptv ': // Print To Video - defines a movie's full screen mode
606  // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm
607  $atom_structure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
608  $atom_structure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); // hardcoded: 0x0000
609  $atom_structure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x0000
610  $atom_structure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 1));
611  $atom_structure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 7, 1));
612 
613  $atom_structure['flags']['play_on_open'] = (bool) $atom_structure['play_on_open_flag'];
614  $atom_structure['flags']['slide_show'] = (bool) $atom_structure['slide_show_flag'];
615 
616  $ptv_lookup[0] = 'normal';
617  $ptv_lookup[1] = 'double';
618  $ptv_lookup[2] = 'half';
619  $ptv_lookup[3] = 'full';
620  $ptv_lookup[4] = 'current';
621  if (isset($ptv_lookup[$atom_structure['display_size_raw']])) {
622  $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']];
623  } else {
624  $info['warning'][] = 'unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')';
625  }
626  break;
627 
628 
629  case 'stsd': // Sample Table Sample Description atom
630  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
631  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
632  $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
633  $stsdEntriesDataOffset = 8;
634  for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
635  $atom_structure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 4));
636  $stsdEntriesDataOffset += 4;
637  $atom_structure['sample_description_table'][$i]['data_format'] = substr($atom_data, $stsdEntriesDataOffset, 4);
638  $stsdEntriesDataOffset += 4;
639  $atom_structure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 6));
640  $stsdEntriesDataOffset += 6;
641  $atom_structure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 2));
642  $stsdEntriesDataOffset += 2;
643  $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));
644  $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);
645 
646  $atom_structure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 0, 2));
647  $atom_structure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 2, 2));
648  $atom_structure['sample_description_table'][$i]['encoder_vendor'] = substr($atom_structure['sample_description_table'][$i]['data'], 4, 4);
649 
650  switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) {
651 
652  case "\x00\x00\x00\x00":
653  // audio tracks
654  $atom_structure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 2));
655  $atom_structure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 10, 2));
656  $atom_structure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 2));
657  $atom_structure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 14, 2));
658  $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4));
659 
660  // video tracks
661  // http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
662  $atom_structure['sample_description_table'][$i]['temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));
663  $atom_structure['sample_description_table'][$i]['spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));
664  $atom_structure['sample_description_table'][$i]['width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));
665  $atom_structure['sample_description_table'][$i]['height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));
666  $atom_structure['sample_description_table'][$i]['resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));
667  $atom_structure['sample_description_table'][$i]['resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));
668  $atom_structure['sample_description_table'][$i]['data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 4));
669  $atom_structure['sample_description_table'][$i]['frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 36, 2));
670  $atom_structure['sample_description_table'][$i]['compressor_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 38, 4);
671  $atom_structure['sample_description_table'][$i]['pixel_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 42, 2));
672  $atom_structure['sample_description_table'][$i]['color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 44, 2));
673 
674  switch ($atom_structure['sample_description_table'][$i]['data_format']) {
675  case '2vuY':
676  case 'avc1':
677  case 'cvid':
678  case 'dvc ':
679  case 'dvcp':
680  case 'gif ':
681  case 'h263':
682  case 'jpeg':
683  case 'kpcd':
684  case 'mjpa':
685  case 'mjpb':
686  case 'mp4v':
687  case 'png ':
688  case 'raw ':
689  case 'rle ':
690  case 'rpza':
691  case 'smc ':
692  case 'SVQ1':
693  case 'SVQ3':
694  case 'tiff':
695  case 'v210':
696  case 'v216':
697  case 'v308':
698  case 'v408':
699  case 'v410':
700  case 'yuv2':
701  $info['fileformat'] = 'mp4';
702  $info['video']['fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
703 // http://www.getid3.org/phpBB3/viewtopic.php?t=1550
704 //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
705 if (!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($atom_structure['sample_description_table'][$i]['height'])) {
706  // assume that values stored here are more important than values stored in [tkhd] atom
707  $info['video']['resolution_x'] = $atom_structure['sample_description_table'][$i]['width'];
708  $info['video']['resolution_y'] = $atom_structure['sample_description_table'][$i]['height'];
709  $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];
710  $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];
711 }
712  break;
713 
714  case 'qtvr':
715  $info['video']['dataformat'] = 'quicktimevr';
716  break;
717 
718  case 'mp4a':
719  default:
720  $info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
721  $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate'];
722  $info['quicktime']['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels'];
723  $info['quicktime']['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth'];
724  $info['audio']['codec'] = $info['quicktime']['audio']['codec'];
725  $info['audio']['sample_rate'] = $info['quicktime']['audio']['sample_rate'];
726  $info['audio']['channels'] = $info['quicktime']['audio']['channels'];
727  $info['audio']['bits_per_sample'] = $info['quicktime']['audio']['bit_depth'];
728  switch ($atom_structure['sample_description_table'][$i]['data_format']) {
729  case 'raw ': // PCM
730  case 'alac': // Apple Lossless Audio Codec
731  $info['audio']['lossless'] = true;
732  break;
733  default:
734  $info['audio']['lossless'] = false;
735  break;
736  }
737  break;
738  }
739  break;
740 
741  default:
742  switch ($atom_structure['sample_description_table'][$i]['data_format']) {
743  case 'mp4s':
744  $info['fileformat'] = 'mp4';
745  break;
746 
747  default:
748  // video atom
749  $atom_structure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));
750  $atom_structure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));
751  $atom_structure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));
752  $atom_structure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));
753  $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4));
754  $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));
755  $atom_structure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));
756  $atom_structure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 2));
757  $atom_structure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 34, 1));
758  $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']);
759  $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2));
760  $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2));
761 
762  $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color');
763  $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']);
764 
765  if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') {
766  $info['quicktime']['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
767  $info['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
768  $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']);
769  $info['quicktime']['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'];
770  $info['quicktime']['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name'];
771 
772  $info['video']['codec'] = $info['quicktime']['video']['codec'];
773  $info['video']['bits_per_sample'] = $info['quicktime']['video']['color_depth'];
774  }
775  $info['video']['lossless'] = false;
776  $info['video']['pixel_aspect_ratio'] = (float) 1;
777  break;
778  }
779  break;
780  }
781  switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) {
782  case 'mp4a':
783  $info['audio']['dataformat'] = 'mp4';
784  $info['quicktime']['audio']['codec'] = 'mp4';
785  break;
786 
787  case '3ivx':
788  case '3iv1':
789  case '3iv2':
790  $info['video']['dataformat'] = '3ivx';
791  break;
792 
793  case 'xvid':
794  $info['video']['dataformat'] = 'xvid';
795  break;
796 
797  case 'mp4v':
798  $info['video']['dataformat'] = 'mpeg4';
799  break;
800 
801  case 'divx':
802  case 'div1':
803  case 'div2':
804  case 'div3':
805  case 'div4':
806  case 'div5':
807  case 'div6':
808  $info['video']['dataformat'] = 'divx';
809  break;
810 
811  default:
812  // do nothing
813  break;
814  }
815  unset($atom_structure['sample_description_table'][$i]['data']);
816  }
817  break;
818 
819 
820  case 'stts': // Sample Table Time-to-Sample atom
821  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
822  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
823  $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
824  $sttsEntriesDataOffset = 8;
825  //$FrameRateCalculatorArray = array();
826  $frames_count = 0;
827 
828  $max_stts_entries_to_scan = ($info['php_memory_limit'] ? min(floor($this->getid3->memory_limit / 10000), $atom_structure['number_entries']) : $atom_structure['number_entries']);
829  if ($max_stts_entries_to_scan < $atom_structure['number_entries']) {
830  $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).';
831  }
832  for ($i = 0; $i < $max_stts_entries_to_scan; $i++) {
833  $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
834  $sttsEntriesDataOffset += 4;
835  $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
836  $sttsEntriesDataOffset += 4;
837 
838  $frames_count += $atom_structure['time_to_sample_table'][$i]['sample_count'];
839 
840  // THIS SECTION REPLACED WITH CODE IN "stbl" ATOM
841  //if (!empty($info['quicktime']['time_scale']) && ($atom_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) {
842  // $stts_new_framerate = $info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'];
843  // if ($stts_new_framerate <= 60) {
844  // // some atoms have durations of "1" giving a very large framerate, which probably is not right
845  // $info['video']['frame_rate'] = max($info['video']['frame_rate'], $stts_new_framerate);
846  // }
847  //}
848  //
849  //$FrameRateCalculatorArray[($info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count'];
850  }
851  $info['quicktime']['stts_framecount'][] = $frames_count;
852  //$sttsFramesTotal = 0;
853  //$sttsSecondsTotal = 0;
854  //foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) {
855  // if (($frames_per_second > 60) || ($frames_per_second < 1)) {
856  // // not video FPS information, probably audio information
857  // $sttsFramesTotal = 0;
858  // $sttsSecondsTotal = 0;
859  // break;
860  // }
861  // $sttsFramesTotal += $frame_count;
862  // $sttsSecondsTotal += $frame_count / $frames_per_second;
863  //}
864  //if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) {
865  // if (($sttsFramesTotal / $sttsSecondsTotal) > $info['video']['frame_rate']) {
866  // $info['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal;
867  // }
868  //}
869  break;
870 
871 
872  case 'stss': // Sample Table Sync Sample (key frames) atom
874  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
875  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
876  $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
877  $stssEntriesDataOffset = 8;
878  for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
879  $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stssEntriesDataOffset, 4));
880  $stssEntriesDataOffset += 4;
881  }
882  }
883  break;
884 
885 
886  case 'stsc': // Sample Table Sample-to-Chunk atom
888  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
889  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
890  $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
891  $stscEntriesDataOffset = 8;
892  for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
893  $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
894  $stscEntriesDataOffset += 4;
895  $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
896  $stscEntriesDataOffset += 4;
897  $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
898  $stscEntriesDataOffset += 4;
899  }
900  }
901  break;
902 
903 
904  case 'stsz': // Sample Table SiZe atom
906  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
907  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
908  $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
909  $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
910  $stszEntriesDataOffset = 12;
911  if ($atom_structure['sample_size'] == 0) {
912  for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
913  $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stszEntriesDataOffset, 4));
914  $stszEntriesDataOffset += 4;
915  }
916  }
917  }
918  break;
919 
920 
921  case 'stco': // Sample Table Chunk Offset atom
923  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
924  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
925  $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
926  $stcoEntriesDataOffset = 8;
927  for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
928  $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 4));
929  $stcoEntriesDataOffset += 4;
930  }
931  }
932  break;
933 
934 
935  case 'co64': // Chunk Offset 64-bit (version of "stco" that supports > 2GB files)
937  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
938  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
939  $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
940  $stcoEntriesDataOffset = 8;
941  for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
942  $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 8));
943  $stcoEntriesDataOffset += 8;
944  }
945  }
946  break;
947 
948 
949  case 'dref': // Data REFerence atom
950  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
951  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
952  $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
953  $drefDataOffset = 8;
954  for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
955  $atom_structure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 4));
956  $drefDataOffset += 4;
957  $atom_structure['data_references'][$i]['type'] = substr($atom_data, $drefDataOffset, 4);
958  $drefDataOffset += 4;
959  $atom_structure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 1));
960  $drefDataOffset += 1;
961  $atom_structure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 3)); // hardcoded: 0x0000
962  $drefDataOffset += 3;
963  $atom_structure['data_references'][$i]['data'] = substr($atom_data, $drefDataOffset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));
964  $drefDataOffset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);
965 
966  $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool) ($atom_structure['data_references'][$i]['flags_raw'] & 0x001);
967  }
968  break;
969 
970 
971  case 'gmin': // base Media INformation atom
972  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
973  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
974  $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
975  $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
976  $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
977  $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
978  $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 2));
979  $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
980  break;
981 
982 
983  case 'smhd': // Sound Media information HeaDer atom
984  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
985  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
986  $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
987  $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
988  break;
989 
990 
991  case 'vmhd': // Video Media information HeaDer atom
992  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
993  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
994  $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
995  $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
996  $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
997  $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
998 
999  $atom_structure['flags']['no_lean_ahead'] = (bool) ($atom_structure['flags_raw'] & 0x001);
1000  break;
1001 
1002 
1003  case 'hdlr': // HanDLeR reference atom
1004  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1005  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
1006  $atom_structure['component_type'] = substr($atom_data, 4, 4);
1007  $atom_structure['component_subtype'] = substr($atom_data, 8, 4);
1008  $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
1009  $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
1010  $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
1011  $atom_structure['component_name'] = $this->Pascal2String(substr($atom_data, 24));
1012 
1013  if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) {
1014  $info['video']['dataformat'] = 'quicktimevr';
1015  }
1016  break;
1017 
1018 
1019  case 'mdhd': // MeDia HeaDer atom
1020  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1021  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
1022  $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1023  $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1024  $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1025  $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
1026  $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 2));
1027  $atom_structure['quality'] = getid3_lib::BigEndian2Int(substr($atom_data, 22, 2));
1028 
1029  if ($atom_structure['time_scale'] == 0) {
1030  $info['error'][] = 'Corrupt Quicktime file: mdhd.time_scale == zero';
1031  return false;
1032  }
1033  $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
1034 
1035  $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
1036  $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
1037  $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
1038  $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
1039  if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
1040  $info['comments']['language'][] = $atom_structure['language'];
1041  }
1042  break;
1043 
1044 
1045  case 'pnot': // Preview atom
1046  $atom_structure['modification_date'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // "standard Macintosh format"
1047  $atom_structure['version_number'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x00
1048  $atom_structure['atom_type'] = substr($atom_data, 6, 4); // usually: 'PICT'
1049  $atom_structure['atom_index'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); // usually: 0x01
1050 
1051  $atom_structure['modification_date_unix'] = getid3_lib::DateMac2Unix($atom_structure['modification_date']);
1052  break;
1053 
1054 
1055  case 'crgn': // Clipping ReGioN atom
1056  $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box,
1057  $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields
1058  $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region.
1059  break;
1060 
1061 
1062  case 'load': // track LOAD settings atom
1063  $atom_structure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1064  $atom_structure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1065  $atom_structure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1066  $atom_structure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1067 
1068  $atom_structure['default_hints']['double_buffer'] = (bool) ($atom_structure['default_hints_raw'] & 0x0020);
1069  $atom_structure['default_hints']['high_quality'] = (bool) ($atom_structure['default_hints_raw'] & 0x0100);
1070  break;
1071 
1072 
1073  case 'tmcd': // TiMe CoDe atom
1074  case 'chap': // CHAPter list atom
1075  case 'sync': // SYNChronization atom
1076  case 'scpt': // tranSCriPT atom
1077  case 'ssrc': // non-primary SouRCe atom
1078  for ($i = 0; $i < strlen($atom_data); $i += 4) {
1079  @$atom_structure['track_id'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));
1080  }
1081  break;
1082 
1083 
1084  case 'elst': // Edit LiST atom
1085  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1086  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
1087  $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1088  for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) {
1089  $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4));
1090  $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4));
1091  $atom_structure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4));
1092  }
1093  break;
1094 
1095 
1096  case 'kmat': // compressed MATte atom
1097  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1098  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
1099  $atom_structure['matte_data_raw'] = substr($atom_data, 4);
1100  break;
1101 
1102 
1103  case 'ctab': // Color TABle atom
1104  $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000
1105  $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000
1106  $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1;
1107  for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) {
1108  $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2));
1109  $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2));
1110  $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2));
1111  $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2));
1112  }
1113  break;
1114 
1115 
1116  case 'mvhd': // MoVie HeaDer atom
1117  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1118  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
1119  $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1120  $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1121  $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1122  $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
1123  $atom_structure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 20, 4));
1124  $atom_structure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 24, 2));
1125  $atom_structure['reserved'] = substr($atom_data, 26, 10);
1126  $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 36, 4));
1127  $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
1128  $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 44, 4));
1129  $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4));
1130  $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
1131  $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 56, 4));
1132  $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4));
1133  $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));
1134  $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4));
1135  $atom_structure['preview_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 72, 4));
1136  $atom_structure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 76, 4));
1137  $atom_structure['poster_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 80, 4));
1138  $atom_structure['selection_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 84, 4));
1139  $atom_structure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 88, 4));
1140  $atom_structure['current_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 92, 4));
1141  $atom_structure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 96, 4));
1142 
1143  if ($atom_structure['time_scale'] == 0) {
1144  $info['error'][] = 'Corrupt Quicktime file: mvhd.time_scale == zero';
1145  return false;
1146  }
1147  $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
1148  $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
1149  $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
1150  $info['quicktime']['display_scale'] = $atom_structure['matrix_a'];
1151  $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
1152  break;
1153 
1154 
1155  case 'tkhd': // TracK HeaDer atom
1156  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1157  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
1158  $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1159  $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1160  $atom_structure['trackid'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1161  $atom_structure['reserved1'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
1162  $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
1163  $atom_structure['reserved2'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 8));
1164  $atom_structure['layer'] = getid3_lib::BigEndian2Int(substr($atom_data, 32, 2));
1165  $atom_structure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atom_data, 34, 2));
1166  $atom_structure['volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 36, 2));
1167  $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2));
1168 // http://developer.apple.com/library/mac/#documentation/QuickTime/RM/MovieBasics/MTEditing/K-Chapter/11MatrixFunctions.html
1169 // http://developer.apple.com/library/mac/#documentation/QuickTime/qtff/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-18737
1170  $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
1171  $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 44, 4));
1172  $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 48, 4));
1173  $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
1174  $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 56, 4));
1175  $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 60, 4));
1176  $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));
1177  $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 68, 4));
1178  $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 72, 4));
1179  $atom_structure['width'] = getid3_lib::FixedPoint16_16(substr($atom_data, 76, 4));
1180  $atom_structure['height'] = getid3_lib::FixedPoint16_16(substr($atom_data, 80, 4));
1181  $atom_structure['flags']['enabled'] = (bool) ($atom_structure['flags_raw'] & 0x0001);
1182  $atom_structure['flags']['in_movie'] = (bool) ($atom_structure['flags_raw'] & 0x0002);
1183  $atom_structure['flags']['in_preview'] = (bool) ($atom_structure['flags_raw'] & 0x0004);
1184  $atom_structure['flags']['in_poster'] = (bool) ($atom_structure['flags_raw'] & 0x0008);
1185  $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
1186  $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
1187 
1188  if ($atom_structure['flags']['enabled'] == 1) {
1189  if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) {
1190  $info['video']['resolution_x'] = $atom_structure['width'];
1191  $info['video']['resolution_y'] = $atom_structure['height'];
1192  }
1193  $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']);
1194  $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']);
1195  $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];
1196  $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];
1197  } else {
1198  // see: http://www.getid3.org/phpBB3/viewtopic.php?t=1295
1199  //if (isset($info['video']['resolution_x'])) { unset($info['video']['resolution_x']); }
1200  //if (isset($info['video']['resolution_y'])) { unset($info['video']['resolution_y']); }
1201  //if (isset($info['quicktime']['video'])) { unset($info['quicktime']['video']); }
1202  }
1203  break;
1204 
1205 
1206  case 'iods': // Initial Object DeScriptor atom
1207  // http://www.koders.com/c/fid1FAB3E762903DC482D8A246D4A4BF9F28E049594.aspx?s=windows.h
1208  // http://libquicktime.sourcearchive.com/documentation/1.0.2plus-pdebian/iods_8c-source.html
1209  $offset = 0;
1210  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1211  $offset += 1;
1212  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 3));
1213  $offset += 3;
1214  $atom_structure['mp4_iod_tag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1215  $offset += 1;
1216  $atom_structure['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
1217  //$offset already adjusted by quicktime_read_mp4_descr_length()
1218  $atom_structure['object_descriptor_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2));
1219  $offset += 2;
1220  $atom_structure['od_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1221  $offset += 1;
1222  $atom_structure['scene_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1223  $offset += 1;
1224  $atom_structure['audio_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1225  $offset += 1;
1226  $atom_structure['video_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1227  $offset += 1;
1228  $atom_structure['graphics_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1229  $offset += 1;
1230 
1231  $atom_structure['num_iods_tracks'] = ($atom_structure['length'] - 7) / 6; // 6 bytes would only be right if all tracks use 1-byte length fields
1232  for ($i = 0; $i < $atom_structure['num_iods_tracks']; $i++) {
1233  $atom_structure['track'][$i]['ES_ID_IncTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1234  $offset += 1;
1235  $atom_structure['track'][$i]['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
1236  //$offset already adjusted by quicktime_read_mp4_descr_length()
1237  $atom_structure['track'][$i]['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4));
1238  $offset += 4;
1239  }
1240 
1241  $atom_structure['audio_profile_name'] = $this->QuicktimeIODSaudioProfileName($atom_structure['audio_profile_id']);
1242  $atom_structure['video_profile_name'] = $this->QuicktimeIODSvideoProfileName($atom_structure['video_profile_id']);
1243  break;
1244 
1245  case 'ftyp': // FileTYPe (?) atom (for MP4 it seems)
1246  $atom_structure['signature'] = substr($atom_data, 0, 4);
1247  $atom_structure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1248  $atom_structure['fourcc'] = substr($atom_data, 8, 4);
1249  break;
1250 
1251  case 'mdat': // Media DATa atom
1252  // 'mdat' contains the actual data for the audio/video, possibly also subtitles
1253 
1254 /* 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 */
1255 
1256  // first, skip any 'wide' padding, and second 'mdat' header (with specified size of zero?)
1257  $mdat_offset = 0;
1258  while (true) {
1259  if (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x08".'wide') {
1260  $mdat_offset += 8;
1261  } elseif (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x00".'mdat') {
1262  $mdat_offset += 8;
1263  } else {
1264  break;
1265  }
1266  }
1267 
1268  // check to see if it looks like chapter titles, in the form of unterminated strings with a leading 16-bit size field
1269  while (($chapter_string_length = getid3_lib::BigEndian2Int(substr($atom_data, $mdat_offset, 2)))
1270  && ($chapter_string_length < 1000)
1271  && ($chapter_string_length <= (strlen($atom_data) - $mdat_offset - 2))
1272  && preg_match('#^[\x20-\xFF]+$#', substr($atom_data, $mdat_offset + 2, $chapter_string_length), $chapter_matches)) {
1273  $mdat_offset += (2 + $chapter_string_length);
1274  @$info['quicktime']['comments']['chapters'][] = $chapter_matches[0];
1275  }
1276 
1277 
1278 
1279  if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) {
1280 
1281  $info['avdataoffset'] = $atom_structure['offset'] + 8; // $info['quicktime'][$atomname]['offset'] + 8;
1282  $OldAVDataEnd = $info['avdataend'];
1283  $info['avdataend'] = $atom_structure['offset'] + $atom_structure['size']; // $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];
1284 
1285  $getid3_temp = new getID3();
1286  $getid3_temp->openfile($this->getid3->filename);
1287  $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
1288  $getid3_temp->info['avdataend'] = $info['avdataend'];
1289  $getid3_mp3 = new getid3_mp3($getid3_temp);
1290  if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode($this->fread(4)))) {
1291  $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
1292  if (!empty($getid3_temp->info['warning'])) {
1293  foreach ($getid3_temp->info['warning'] as $value) {
1294  $info['warning'][] = $value;
1295  }
1296  }
1297  if (!empty($getid3_temp->info['mpeg'])) {
1298  $info['mpeg'] = $getid3_temp->info['mpeg'];
1299  if (isset($info['mpeg']['audio'])) {
1300  $info['audio']['dataformat'] = 'mp3';
1301  $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')));
1302  $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
1303  $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
1304  $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
1305  $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
1306  $info['bitrate'] = $info['audio']['bitrate'];
1307  }
1308  }
1309  }
1310  unset($getid3_mp3, $getid3_temp);
1311  $info['avdataend'] = $OldAVDataEnd;
1312  unset($OldAVDataEnd);
1313 
1314  }
1315 
1316  unset($mdat_offset, $chapter_string_length, $chapter_matches);
1317  break;
1318 
1319  case 'free': // FREE space atom
1320  case 'skip': // SKIP atom
1321  case 'wide': // 64-bit expansion placeholder atom
1322  // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
1323 
1324  // When writing QuickTime files, it is sometimes necessary to update an atom's size.
1325  // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom
1326  // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime
1327  // puts an 8-byte placeholder atom before any atoms it may have to update the size of.
1328  // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the
1329  // placeholder atom can be overwritten to obtain the necessary 8 extra bytes.
1330  // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ).
1331  break;
1332 
1333 
1334  case 'nsav': // NoSAVe atom
1335  // http://developer.apple.com/technotes/tn/tn2038.html
1336  $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1337  break;
1338 
1339  case 'ctyp': // Controller TYPe atom (seen on QTVR)
1340  // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt
1341  // some controller names are:
1342  // 0x00 + 'std' for linear movie
1343  // 'none' for no controls
1344  $atom_structure['ctyp'] = substr($atom_data, 0, 4);
1345  $info['quicktime']['controller'] = $atom_structure['ctyp'];
1346  switch ($atom_structure['ctyp']) {
1347  case 'qtvr':
1348  $info['video']['dataformat'] = 'quicktimevr';
1349  break;
1350  }
1351  break;
1352 
1353  case 'pano': // PANOrama track (seen on QTVR)
1354  $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1355  break;
1356 
1357  case 'hint': // HINT track
1358  case 'hinf': //
1359  case 'hinv': //
1360  case 'hnti': //
1361  $info['quicktime']['hinting'] = true;
1362  break;
1363 
1364  case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR)
1365  for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) {
1366  $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));
1367  }
1368  break;
1369 
1370 
1371  // Observed-but-not-handled atom types are just listed here to prevent warnings being generated
1372  case 'FXTC': // Something to do with Adobe After Effects (?)
1373  case 'PrmA':
1374  case 'code':
1375  case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
1376  case 'tapt': // TrackApertureModeDimensionsAID - http://developer.apple.com/documentation/QuickTime/Reference/QT7-1_Update_Reference/Constants/Constants.html
1377  // tapt seems to be used to compute the video size [http://www.getid3.org/phpBB3/viewtopic.php?t=838]
1378  // * http://lists.apple.com/archives/quicktime-api/2006/Aug/msg00014.html
1379  // * http://handbrake.fr/irclogs/handbrake-dev/handbrake-dev20080128_pg2.html
1380  case 'ctts':// STCompositionOffsetAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1381  case 'cslg':// STCompositionShiftLeastGreatestAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1382  case 'sdtp':// STSampleDependencyAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1383  case 'stps':// STPartialSyncSampleAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1384  //$atom_structure['data'] = $atom_data;
1385  break;
1386 
1387  case "\xA9".'xyz': // GPS latitude+longitude+altitude
1388  $atom_structure['data'] = $atom_data;
1389  if (preg_match('#([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)?/$#i', $atom_data, $matches)) {
1390  @list($all, $latitude, $longitude, $altitude) = $matches;
1391  $info['quicktime']['comments']['gps_latitude'][] = floatval($latitude);
1392  $info['quicktime']['comments']['gps_longitude'][] = floatval($longitude);
1393  if (!empty($altitude)) {
1394  $info['quicktime']['comments']['gps_altitude'][] = floatval($altitude);
1395  }
1396  } else {
1397  $info['warning'][] = 'QuickTime atom "©xyz" data does not match expected data pattern at offset '.$baseoffset.'. Please report as getID3() bug.';
1398  }
1399  break;
1400 
1401  case 'NCDT':
1402  // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1403  // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
1404  $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 4, $atomHierarchy, $ParseAllPossibleAtoms);
1405  break;
1406  case 'NCTH': // Nikon Camera THumbnail image
1407  case 'NCVW': // Nikon Camera preVieW image
1408  // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1409  if (preg_match('/^\xFF\xD8\xFF/', $atom_data)) {
1410  $atom_structure['data'] = $atom_data;
1411  $atom_structure['image_mime'] = 'image/jpeg';
1412  $atom_structure['description'] = (($atomname == 'NCTH') ? 'Nikon Camera Thumbnail Image' : (($atomname == 'NCVW') ? 'Nikon Camera Preview Image' : 'Nikon preview image'));
1413  $info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_data, 'description'=>$atom_structure['description']);
1414  }
1415  break;
1416  case 'NCTG': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
1417  $atom_structure['data'] = $this->QuicktimeParseNikonNCTG($atom_data);
1418  break;
1419  case 'NCHD': // Nikon:MakerNoteVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1420  case 'NCDB': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1421  case 'CNCV': // Canon:CompressorVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html
1422  $atom_structure['data'] = $atom_data;
1423  break;
1424 
1425  case "\x00\x00\x00\x00":
1426  case 'meta': // METAdata atom
1427  // some kind of metacontainer, may contain a big data dump such as:
1428  // 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
1429  // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
1430 
1431  $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1432  $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
1433  $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_data, 4), $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
1434  //$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
1435  break;
1436 
1437  case 'data': // metaDATA atom
1438  // seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in sample I have), remainder is useful data
1439  $atom_structure['language'] = substr($atom_data, 4 + 0, 2);
1440  $atom_structure['unknown'] = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2));
1441  $atom_structure['data'] = substr($atom_data, 4 + 4);
1442  break;
1443 
1444  default:
1445  $info['warning'][] = 'Unknown QuickTime atom type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" ('.trim(getid3_lib::PrintHexBytes($atomname)).') at offset '.$baseoffset;
1446  $atom_structure['data'] = $atom_data;
1447  break;
1448  }
1449  array_pop($atomHierarchy);
1450  return $atom_structure;
1451  }
QuicktimeIODSaudioProfileName($audio_profile_id)
CopyToAppropriateCommentsSection($keyname, $data, &$ThisFileInfo)
DateMac2Unix($macdate)
Definition: getid3.lib.php:442
QuicktimeIODSvideoProfileName($video_profile_id)
quicktime_read_mp4_descr_length($data, &$offset)
FixedPoint16_16($rawdata)
Definition: getid3.lib.php:454
NoNullString($nullterminatedstring)
FixedPoint2_30($rawdata)
Definition: getid3.lib.php:459
FixedPoint8_8($rawdata)
Definition: getid3.lib.php:449
$info
Definition: example_052.php:80
QuicktimeParseContainerAtom($atomdata, &$ThisFileInfo, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms)
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
PrintHexBytes($string, $hex=true, $spaces=true, $htmlsafe=true)
Definition: getid3.lib.php:17
LookupGenreName($genreid, $allowSCMPXextended=true)
+ Here is the call graph for this function:

◆ QuicktimeParseAtom() [2/2]

getid3_quicktime::QuicktimeParseAtom (   $atomname,
  $atomsize,
  $atomdata,
$ThisFileInfo,
  $baseoffset,
$atomHierarchy,
  $ParseAllPossibleAtoms 
)

Definition at line 129 of file module.audio-video.quicktime.php.

References $ParseAllPossibleAtoms, getid3_lib\BigEndian2Int(), CopyToAppropriateCommentsSection(), getid3_lib\DateMac2Unix(), getid3_lib\FixedPoint16_16(), getid3_lib\FixedPoint2_30(), getid3_lib\FixedPoint8_8(), NoNullString(), Pascal2String(), QuicktimeAudioCodecLookup(), QuicktimeColorNameLookup(), QuicktimeDCOMLookup(), QuicktimeLanguageLookup(), QuicktimeParseContainerAtom(), and QuicktimeVideoCodecLookup().

Referenced by Analyze(), getid3_quicktime(), and QuicktimeParseContainerAtom().

129  {
130  // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm
131 
132  array_push($atomHierarchy, $atomname);
133  $atomstructure['hierarchy'] = implode(' ', $atomHierarchy);
134  $atomstructure['name'] = $atomname;
135  $atomstructure['size'] = $atomsize;
136  $atomstructure['offset'] = $baseoffset;
137 
138  switch ($atomname) {
139  case 'moov': // MOVie container atom
140  case 'trak': // TRAcK container atom
141  case 'clip': // CLIPping container atom
142  case 'matt': // track MATTe container atom
143  case 'edts': // EDiTS container atom
144  case 'tref': // Track REFerence container atom
145  case 'mdia': // MeDIA container atom
146  case 'minf': // Media INFormation container atom
147  case 'dinf': // Data INFormation container atom
148  case 'udta': // User DaTA container atom
149  case 'stbl': // Sample TaBLe container atom
150  case 'cmov': // Compressed MOVie container atom
151  case 'rmra': // Reference Movie Record Atom
152  case 'rmda': // Reference Movie Descriptor Atom
153  case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR)
154  $atomstructure['subatoms'] = $this->QuicktimeParseContainerAtom($atomdata, $ThisFileInfo, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
155  break;
156 
157 
158  case '©cpy':
159  case '©day':
160  case '©dir':
161  case '©ed1':
162  case '©ed2':
163  case '©ed3':
164  case '©ed4':
165  case '©ed5':
166  case '©ed6':
167  case '©ed7':
168  case '©ed8':
169  case '©ed9':
170  case '©fmt':
171  case '©inf':
172  case '©prd':
173  case '©prf':
174  case '©req':
175  case '©src':
176  case '©wrt':
177  case '©nam':
178  case '©cmt':
179  case '©wrn':
180  case '©hst':
181  case '©mak':
182  case '©mod':
183  case '©PRD':
184  case '©swr':
185  case '©aut':
186  case '©ART':
187  case '©trk':
188  case '©alb':
189  case '©com':
190  case '©gen':
191  case '©ope':
192  case '©url':
193  case '©enc':
194  $atomstructure['data_length'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 2));
195  $atomstructure['language_id'] = getid3_lib::BigEndian2Int(substr($atomdata, 2, 2));
196  $atomstructure['data'] = substr($atomdata, 4);
197 
198  $atomstructure['language'] = $this->QuicktimeLanguageLookup($atomstructure['language_id']);
199  if (empty($ThisFileInfo['comments']['language']) || (!in_array($atomstructure['language'], $ThisFileInfo['comments']['language']))) {
200  $ThisFileInfo['comments']['language'][] = $atomstructure['language'];
201  }
202  $this->CopyToAppropriateCommentsSection($atomname, $atomstructure['data'], $ThisFileInfo);
203  break;
204 
205 
206  case 'play': // auto-PLAY atom
207  $atomstructure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
208 
209  $ThisFileInfo['quicktime']['autoplay'] = $atomstructure['autoplay'];
210  break;
211 
212 
213  case 'WLOC': // Window LOCation atom
214  $atomstructure['location_x'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 2));
215  $atomstructure['location_y'] = getid3_lib::BigEndian2Int(substr($atomdata, 2, 2));
216  break;
217 
218 
219  case 'LOOP': // LOOPing atom
220  case 'SelO': // play SELection Only atom
221  case 'AllF': // play ALL Frames atom
222  $atomstructure['data'] = getid3_lib::BigEndian2Int($atomdata);
223  break;
224 
225 
226  case 'name': //
227  case 'MCPS': // Media Cleaner PRo
228  case '@PRM': // adobe PReMiere version
229  case '@PRQ': // adobe PRemiere Quicktime version
230  $atomstructure['data'] = $atomdata;
231  break;
232 
233 
234  case 'cmvd': // Compressed MooV Data atom
235  // Code by ubergeekØubergeek*tv based on information from
236  // http://developer.apple.com/quicktime/icefloe/dispatch012.html
237  $atomstructure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4));
238 
239  $CompressedFileData = substr($atomdata, 4);
240  if ($UncompressedHeader = @gzuncompress($CompressedFileData)) {
241  $atomstructure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, $ThisFileInfo, 0, $atomHierarchy, $ParseAllPossibleAtoms);
242  } else {
243  $ThisFileInfo['warning'][] = 'Error decompressing compressed MOV atom at offset '.$atomstructure['offset'];
244  }
245  break;
246 
247 
248  case 'dcom': // Data COMpression atom
249  $atomstructure['compression_id'] = $atomdata;
250  $atomstructure['compression_text'] = $this->QuicktimeDCOMLookup($atomdata);
251  break;
252 
253 
254  case 'rdrf': // Reference movie Data ReFerence atom
255  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
256  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3));
257  $atomstructure['flags']['internal_data'] = (bool) ($atomstructure['flags_raw'] & 0x000001);
258 
259  $atomstructure['reference_type_name'] = substr($atomdata, 4, 4);
260  $atomstructure['reference_length'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
261  switch ($atomstructure['reference_type_name']) {
262  case 'url ':
263  $atomstructure['url'] = $this->NoNullString(substr($atomdata, 12));
264  break;
265 
266  case 'alis':
267  $atomstructure['file_alias'] = substr($atomdata, 12);
268  break;
269 
270  case 'rsrc':
271  $atomstructure['resource_alias'] = substr($atomdata, 12);
272  break;
273 
274  default:
275  $atomstructure['data'] = substr($atomdata, 12);
276  break;
277  }
278  break;
279 
280 
281  case 'rmqu': // Reference Movie QUality atom
282  $atomstructure['movie_quality'] = getid3_lib::BigEndian2Int($atomdata);
283  break;
284 
285 
286  case 'rmcs': // Reference Movie Cpu Speed atom
287  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
288  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
289  $atomstructure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
290  break;
291 
292 
293  case 'rmvc': // Reference Movie Version Check atom
294  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
295  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
296  $atomstructure['gestalt_selector'] = substr($atomdata, 4, 4);
297  $atomstructure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
298  $atomstructure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
299  $atomstructure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atomdata, 14, 2));
300  break;
301 
302 
303  case 'rmcd': // Reference Movie Component check atom
304  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
305  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
306  $atomstructure['component_type'] = substr($atomdata, 4, 4);
307  $atomstructure['component_subtype'] = substr($atomdata, 8, 4);
308  $atomstructure['component_manufacturer'] = substr($atomdata, 12, 4);
309  $atomstructure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 16, 4));
310  $atomstructure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atomdata, 20, 4));
311  $atomstructure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atomdata, 24, 4));
312  break;
313 
314 
315  case 'rmdr': // Reference Movie Data Rate atom
316  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
317  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
318  $atomstructure['data_rate'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
319 
320  $atomstructure['data_rate_bps'] = $atomstructure['data_rate'] * 10;
321  break;
322 
323 
324  case 'rmla': // Reference Movie Language Atom
325  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
326  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
327  $atomstructure['language_id'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
328 
329  $atomstructure['language'] = $this->QuicktimeLanguageLookup($atomstructure['language_id']);
330  if (empty($ThisFileInfo['comments']['language']) || (!in_array($atomstructure['language'], $ThisFileInfo['comments']['language']))) {
331  $ThisFileInfo['comments']['language'][] = $atomstructure['language'];
332  }
333  break;
334 
335 
336  case 'rmla': // Reference Movie Language Atom
337  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
338  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
339  $atomstructure['track_id'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
340  break;
341 
342 
343  case 'ptv ': // Print To Video - defines a movie's full screen mode
344  // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm
345  $atomstructure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 2));
346  $atomstructure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atomdata, 2, 2)); // hardcoded: 0x0000
347  $atomstructure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2)); // hardcoded: 0x0000
348  $atomstructure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atomdata, 6, 1));
349  $atomstructure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atomdata, 7, 1));
350 
351  $atomstructure['flags']['play_on_open'] = (bool) $atomstructure['play_on_open_flag'];
352  $atomstructure['flags']['slide_show'] = (bool) $atomstructure['slide_show_flag'];
353 
354  $ptv_lookup[0] = 'normal';
355  $ptv_lookup[1] = 'double';
356  $ptv_lookup[2] = 'half';
357  $ptv_lookup[3] = 'full';
358  $ptv_lookup[4] = 'current';
359  if (isset($ptv_lookup[$atomstructure['display_size_raw']])) {
360  $atomstructure['display_size'] = $ptv_lookup[$atomstructure['display_size_raw']];
361  } else {
362  $ThisFileInfo['warning'][] = 'unknown "ptv " display constant ('.$atomstructure['display_size_raw'].')';
363  }
364  break;
365 
366 
367  case 'stsd': // Sample Table Sample Description atom
368  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
369  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
370  $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
371  $stsdEntriesDataOffset = 8;
372  for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
373  $atomstructure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atomdata, $stsdEntriesDataOffset, 4));
374  $stsdEntriesDataOffset += 4;
375  $atomstructure['sample_description_table'][$i]['data_format'] = substr($atomdata, $stsdEntriesDataOffset, 4);
376  $stsdEntriesDataOffset += 4;
377  $atomstructure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atomdata, $stsdEntriesDataOffset, 6));
378  $stsdEntriesDataOffset += 6;
379  $atomstructure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atomdata, $stsdEntriesDataOffset, 2));
380  $stsdEntriesDataOffset += 2;
381  $atomstructure['sample_description_table'][$i]['data'] = substr($atomdata, $stsdEntriesDataOffset, ($atomstructure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));
382  $stsdEntriesDataOffset += ($atomstructure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);
383 
384  $atomstructure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 0, 2));
385  $atomstructure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 2, 2));
386  $atomstructure['sample_description_table'][$i]['encoder_vendor'] = substr($atomstructure['sample_description_table'][$i]['data'], 4, 4);
387 
388  switch ($atomstructure['sample_description_table'][$i]['encoder_vendor']) {
389 
390  case "\x00\x00\x00\x00":
391  // audio atom
392  $atomstructure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 8, 2));
393  $atomstructure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 10, 2));
394  $atomstructure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 12, 2));
395  $atomstructure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 14, 2));
396  $atomstructure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atomstructure['sample_description_table'][$i]['data'], 16, 4));
397 
398  switch ($atomstructure['sample_description_table'][$i]['data_format']) {
399  case 'mp4v':
400  $ThisFileInfo['fileformat'] = 'mp4';
401  $ThisFileInfo['error'][] = 'This version ('.GETID3_VERSION.') of getID3() does not fully support MPEG-4 audio/video streams';
402  break;
403 
404  case 'qtvr':
405  $ThisFileInfo['video']['dataformat'] = 'quicktimevr';
406  break;
407 
408  case 'mp4a':
409  default:
410  $ThisFileInfo['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atomstructure['sample_description_table'][$i]['data_format']);
411  $ThisFileInfo['quicktime']['audio']['sample_rate'] = $atomstructure['sample_description_table'][$i]['audio_sample_rate'];
412  $ThisFileInfo['quicktime']['audio']['channels'] = $atomstructure['sample_description_table'][$i]['audio_channels'];
413  $ThisFileInfo['quicktime']['audio']['bit_depth'] = $atomstructure['sample_description_table'][$i]['audio_bit_depth'];
414  $ThisFileInfo['audio']['codec'] = $ThisFileInfo['quicktime']['audio']['codec'];
415  $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['quicktime']['audio']['sample_rate'];
416  $ThisFileInfo['audio']['channels'] = $ThisFileInfo['quicktime']['audio']['channels'];
417  $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['quicktime']['audio']['bit_depth'];
418  switch ($atomstructure['sample_description_table'][$i]['data_format']) {
419  case 'raw ': // PCM
420  case 'alac': // Apple Lossless Audio Codec
421  $ThisFileInfo['audio']['lossless'] = true;
422  break;
423  default:
424  $ThisFileInfo['audio']['lossless'] = false;
425  break;
426  }
427  break;
428  }
429  break;
430 
431  default:
432  switch ($atomstructure['sample_description_table'][$i]['data_format']) {
433  case 'mp4s':
434  $ThisFileInfo['fileformat'] = 'mp4';
435  break;
436 
437  default:
438  // video atom
439  $atomstructure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 8, 4));
440  $atomstructure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 12, 4));
441  $atomstructure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 16, 2));
442  $atomstructure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 18, 2));
443  $atomstructure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atomstructure['sample_description_table'][$i]['data'], 20, 4));
444  $atomstructure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atomstructure['sample_description_table'][$i]['data'], 24, 4));
445  $atomstructure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 28, 4));
446  $atomstructure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 32, 2));
447  $atomstructure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 34, 1));
448  $atomstructure['sample_description_table'][$i]['video_encoder_name'] = substr($atomstructure['sample_description_table'][$i]['data'], 35, $atomstructure['sample_description_table'][$i]['video_encoder_name_len']);
449  $atomstructure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 66, 2));
450  $atomstructure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 68, 2));
451 
452  $atomstructure['sample_description_table'][$i]['video_pixel_color_type'] = (($atomstructure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color');
453  $atomstructure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atomstructure['sample_description_table'][$i]['video_pixel_color_depth']);
454 
455  if ($atomstructure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') {
456  $ThisFileInfo['quicktime']['video']['codec_fourcc'] = $atomstructure['sample_description_table'][$i]['data_format'];
457  $ThisFileInfo['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atomstructure['sample_description_table'][$i]['data_format']);
458  $ThisFileInfo['quicktime']['video']['codec'] = $atomstructure['sample_description_table'][$i]['video_encoder_name'];
459  $ThisFileInfo['quicktime']['video']['color_depth'] = $atomstructure['sample_description_table'][$i]['video_pixel_color_depth'];
460  $ThisFileInfo['quicktime']['video']['color_depth_name'] = $atomstructure['sample_description_table'][$i]['video_pixel_color_name'];
461 
462  $ThisFileInfo['video']['codec'] = $ThisFileInfo['quicktime']['video']['codec'];
463  $ThisFileInfo['video']['bits_per_sample'] = $ThisFileInfo['quicktime']['video']['color_depth'];
464  }
465  $ThisFileInfo['video']['lossless'] = false;
466  $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
467  break;
468  }
469  break;
470  }
471  switch (strtolower($atomstructure['sample_description_table'][$i]['data_format'])) {
472  case 'mp4a':
473  $ThisFileInfo['audio']['dataformat'] = 'mp4';
474  $ThisFileInfo['quicktime']['audio']['codec'] = 'mp4';
475  break;
476 
477  case '3ivx':
478  case '3iv1':
479  case '3iv2':
480  $ThisFileInfo['video']['dataformat'] = '3ivx';
481  break;
482 
483  case 'xvid':
484  $ThisFileInfo['video']['dataformat'] = 'xvid';
485  break;
486 
487  case 'mp4v':
488  $ThisFileInfo['video']['dataformat'] = 'mpeg4';
489  break;
490 
491  case 'divx':
492  case 'div1':
493  case 'div2':
494  case 'div3':
495  case 'div4':
496  case 'div5':
497  case 'div6':
498  $TDIVXileInfo['video']['dataformat'] = 'divx';
499  break;
500 
501  default:
502  // do nothing
503  break;
504  }
505  unset($atomstructure['sample_description_table'][$i]['data']);
506  }
507  break;
508 
509 
510  case 'stts': // Sample Table Time-to-Sample atom
511  //if ($ParseAllPossibleAtoms) {
512  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
513  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
514  $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
515  $sttsEntriesDataOffset = 8;
516  $FrameRateCalculatorArray = array();
517  for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
518  $atomstructure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atomdata, $sttsEntriesDataOffset, 4));
519  $sttsEntriesDataOffset += 4;
520  $atomstructure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, $sttsEntriesDataOffset, 4));
521  $sttsEntriesDataOffset += 4;
522 
523  if (!empty($ThisFileInfo['quicktime']['time_scale']) && (@$atomstructure['time_to_sample_table'][$i]['sample_duration'] > 0)) {
524  $stts_new_framerate = $ThisFileInfo['quicktime']['time_scale'] / $atomstructure['time_to_sample_table'][$i]['sample_duration'];
525  if ($stts_new_framerate <= 60) {
526  // some atoms have durations of "1" giving a very large framerate, which probably is not right
527  $ThisFileInfo['video']['frame_rate'] = max(@$ThisFileInfo['video']['frame_rate'], $stts_new_framerate);
528  }
529  }
530  //@$FrameRateCalculatorArray[($ThisFileInfo['quicktime']['time_scale'] / $atomstructure['time_to_sample_table'][$i]['sample_duration'])] += $atomstructure['time_to_sample_table'][$i]['sample_count'];
531  }
532  //$sttsFramesTotal = 0;
533  //$sttsSecondsTotal = 0;
534  //foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) {
535  // if (($frames_per_second > 60) || ($frames_per_second < 1)) {
536  // // not video FPS information, probably audio information
537  // $sttsFramesTotal = 0;
538  // $sttsSecondsTotal = 0;
539  // break;
540  // }
541  // $sttsFramesTotal += $frame_count;
542  // $sttsSecondsTotal += $frame_count / $frames_per_second;
543  //}
544  //if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) {
545  // if (($sttsFramesTotal / $sttsSecondsTotal) > @$ThisFileInfo['video']['frame_rate']) {
546  // $ThisFileInfo['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal;
547  // }
548  //}
549  //}
550  break;
551 
552 
553  case 'stss': // Sample Table Sync Sample (key frames) atom
555  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
556  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
557  $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
558  $stssEntriesDataOffset = 8;
559  for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
560  $atomstructure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atomdata, $stssEntriesDataOffset, 4));
561  $stssEntriesDataOffset += 4;
562  }
563  }
564  break;
565 
566 
567  case 'stsc': // Sample Table Sample-to-Chunk atom
569  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
570  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
571  $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
572  $stscEntriesDataOffset = 8;
573  for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
574  $atomstructure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atomdata, $stscEntriesDataOffset, 4));
575  $stscEntriesDataOffset += 4;
576  $atomstructure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atomdata, $stscEntriesDataOffset, 4));
577  $stscEntriesDataOffset += 4;
578  $atomstructure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atomdata, $stscEntriesDataOffset, 4));
579  $stscEntriesDataOffset += 4;
580  }
581  }
582  break;
583 
584 
585  case 'stsz': // Sample Table SiZe atom
587  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
588  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
589  $atomstructure['sample_size'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
590  $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
591  $stszEntriesDataOffset = 12;
592  if ($atomstructure['sample_size'] == 0) {
593  for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
594  $atomstructure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atomdata, $stszEntriesDataOffset, 4));
595  $stszEntriesDataOffset += 4;
596  }
597  }
598  }
599  break;
600 
601 
602  case 'stco': // Sample Table Chunk Offset atom
604  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
605  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
606  $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
607  $stcoEntriesDataOffset = 8;
608  for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
609  $atomstructure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atomdata, $stcoEntriesDataOffset, 4));
610  $stcoEntriesDataOffset += 4;
611  }
612  }
613  break;
614 
615 
616  case 'dref': // Data REFerence atom
617  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
618  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
619  $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
620  $drefDataOffset = 8;
621  for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
622  $atomstructure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atomdata, $drefDataOffset, 4));
623  $drefDataOffset += 4;
624  $atomstructure['data_references'][$i]['type'] = substr($atomdata, $drefDataOffset, 4);
625  $drefDataOffset += 4;
626  $atomstructure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atomdata, $drefDataOffset, 1));
627  $drefDataOffset += 1;
628  $atomstructure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, $drefDataOffset, 3)); // hardcoded: 0x0000
629  $drefDataOffset += 3;
630  $atomstructure['data_references'][$i]['data'] = substr($atomdata, $drefDataOffset, ($atomstructure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));
631  $drefDataOffset += ($atomstructure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);
632 
633  $atomstructure['data_references'][$i]['flags']['self_reference'] = (bool) ($atomstructure['data_references'][$i]['flags_raw'] & 0x001);
634  }
635  break;
636 
637 
638  case 'gmin': // base Media INformation atom
639  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
640  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
641  $atomstructure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
642  $atomstructure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atomdata, 6, 2));
643  $atomstructure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 2));
644  $atomstructure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atomdata, 10, 2));
645  $atomstructure['balance'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 2));
646  $atomstructure['reserved'] = getid3_lib::BigEndian2Int(substr($atomdata, 14, 2));
647  break;
648 
649 
650  case 'smhd': // Sound Media information HeaDer atom
651  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
652  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
653  $atomstructure['balance'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
654  $atomstructure['reserved'] = getid3_lib::BigEndian2Int(substr($atomdata, 6, 2));
655  break;
656 
657 
658  case 'vmhd': // Video Media information HeaDer atom
659  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
660  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3));
661  $atomstructure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
662  $atomstructure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atomdata, 6, 2));
663  $atomstructure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 2));
664  $atomstructure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atomdata, 10, 2));
665 
666  $atomstructure['flags']['no_lean_ahead'] = (bool) ($atomstructure['flags_raw'] & 0x001);
667  break;
668 
669 
670  case 'hdlr': // HanDLeR reference atom
671  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
672  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
673  $atomstructure['component_type'] = substr($atomdata, 4, 4);
674  $atomstructure['component_subtype'] = substr($atomdata, 8, 4);
675  $atomstructure['component_manufacturer'] = substr($atomdata, 12, 4);
676  $atomstructure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 16, 4));
677  $atomstructure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atomdata, 20, 4));
678  $atomstructure['component_name'] = $this->Pascal2String(substr($atomdata, 24));
679 
680  if (($atomstructure['component_subtype'] == 'STpn') && ($atomstructure['component_manufacturer'] == 'zzzz')) {
681  $ThisFileInfo['video']['dataformat'] = 'quicktimevr';
682  }
683  break;
684 
685 
686  case 'mdhd': // MeDia HeaDer atom
687  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
688  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
689  $atomstructure['creation_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
690  $atomstructure['modify_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
691  $atomstructure['time_scale'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
692  $atomstructure['duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 16, 4));
693  $atomstructure['language_id'] = getid3_lib::BigEndian2Int(substr($atomdata, 20, 2));
694  $atomstructure['quality'] = getid3_lib::BigEndian2Int(substr($atomdata, 22, 2));
695 
696  if ($atomstructure['time_scale'] == 0) {
697  $ThisFileInfo['error'][] = 'Corrupt Quicktime file: mdhd.time_scale == zero';
698  return false;
699  }
700  $atomstructure['creation_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['creation_time']);
701  $atomstructure['modify_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['modify_time']);
702  $atomstructure['playtime_seconds'] = $atomstructure['duration'] / $atomstructure['time_scale'];
703  $atomstructure['language'] = $this->QuicktimeLanguageLookup($atomstructure['language_id']);
704  if (empty($ThisFileInfo['comments']['language']) || (!in_array($atomstructure['language'], $ThisFileInfo['comments']['language']))) {
705  $ThisFileInfo['comments']['language'][] = $atomstructure['language'];
706  }
707  break;
708 
709 
710  case 'pnot': // Preview atom
711  $atomstructure['modification_date'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4)); // "standard Macintosh format"
712  $atomstructure['version_number'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2)); // hardcoded: 0x00
713  $atomstructure['atom_type'] = substr($atomdata, 6, 4); // usually: 'PICT'
714  $atomstructure['atom_index'] = getid3_lib::BigEndian2Int(substr($atomdata, 10, 2)); // usually: 0x01
715 
716  $atomstructure['modification_date_unix'] = getid3_lib::DateMac2Unix($atomstructure['modification_date']);
717  break;
718 
719 
720  case 'crgn': // Clipping ReGioN atom
721  $atomstructure['region_size'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 2)); // The Region size, Region boundary box,
722  $atomstructure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atomdata, 2, 8)); // and Clipping region data fields
723  $atomstructure['clipping_data'] = substr($atomdata, 10); // constitute a QuickDraw region.
724  break;
725 
726 
727  case 'load': // track LOAD settings atom
728  $atomstructure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4));
729  $atomstructure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
730  $atomstructure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
731  $atomstructure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
732 
733  $atomstructure['default_hints']['double_buffer'] = (bool) ($atomstructure['default_hints_raw'] & 0x0020);
734  $atomstructure['default_hints']['high_quality'] = (bool) ($atomstructure['default_hints_raw'] & 0x0100);
735  break;
736 
737 
738  case 'tmcd': // TiMe CoDe atom
739  case 'chap': // CHAPter list atom
740  case 'sync': // SYNChronization atom
741  case 'scpt': // tranSCriPT atom
742  case 'ssrc': // non-primary SouRCe atom
743  for ($i = 0; $i < (strlen($atomdata) % 4); $i++) {
744  $atomstructure['track_id'][$i] = getid3_lib::BigEndian2Int(substr($atomdata, $i * 4, 4));
745  }
746  break;
747 
748 
749  case 'elst': // Edit LiST atom
750  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
751  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
752  $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
753  for ($i = 0; $i < $atomstructure['number_entries']; $i++ ) {
754  $atomstructure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($i * 12) + 0, 4));
755  $atomstructure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($i * 12) + 4, 4));
756  $atomstructure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atomdata, 8 + ($i * 12) + 8, 4));
757  }
758  break;
759 
760 
761  case 'kmat': // compressed MATte atom
762  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
763  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
764  $atomstructure['matte_data_raw'] = substr($atomdata, 4);
765  break;
766 
767 
768  case 'ctab': // Color TABle atom
769  $atomstructure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4)); // hardcoded: 0x00000000
770  $atomstructure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2)); // hardcoded: 0x8000
771  $atomstructure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atomdata, 6, 2)) + 1;
772  for ($colortableentry = 0; $colortableentry < $atomstructure['color_table_size']; $colortableentry++) {
773  $atomstructure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($colortableentry * 8) + 0, 2));
774  $atomstructure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($colortableentry * 8) + 2, 2));
775  $atomstructure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($colortableentry * 8) + 4, 2));
776  $atomstructure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($colortableentry * 8) + 6, 2));
777  }
778  break;
779 
780 
781  case 'mvhd': // MoVie HeaDer atom
782  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
783  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3));
784  $atomstructure['creation_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
785  $atomstructure['modify_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
786  $atomstructure['time_scale'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
787  $atomstructure['duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 16, 4));
788  $atomstructure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atomdata, 20, 4));
789  $atomstructure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atomdata, 24, 2));
790  $atomstructure['reserved'] = substr($atomdata, 26, 10);
791  $atomstructure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atomdata, 36, 4));
792  $atomstructure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atomdata, 40, 4));
793  $atomstructure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atomdata, 44, 4));
794  $atomstructure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atomdata, 48, 4));
795  $atomstructure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atomdata, 52, 4));
796  $atomstructure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atomdata, 56, 4));
797  $atomstructure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atomdata, 60, 4));
798  $atomstructure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atomdata, 64, 4));
799  $atomstructure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atomdata, 68, 4));
800  $atomstructure['preview_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 72, 4));
801  $atomstructure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 76, 4));
802  $atomstructure['poster_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 80, 4));
803  $atomstructure['selection_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 84, 4));
804  $atomstructure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 88, 4));
805  $atomstructure['current_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 92, 4));
806  $atomstructure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atomdata, 96, 4));
807 
808  if ($atomstructure['time_scale'] == 0) {
809  $ThisFileInfo['error'][] = 'Corrupt Quicktime file: mvhd.time_scale == zero';
810  return false;
811  }
812  $atomstructure['creation_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['creation_time']);
813  $atomstructure['modify_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['modify_time']);
814  $ThisFileInfo['quicktime']['time_scale'] = $atomstructure['time_scale'];
815  $ThisFileInfo['quicktime']['display_scale'] = $atomstructure['matrix_a'];
816  $ThisFileInfo['playtime_seconds'] = $atomstructure['duration'] / $atomstructure['time_scale'];
817  break;
818 
819 
820  case 'tkhd': // TracK HeaDer atom
821  $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
822  $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3));
823  $atomstructure['creation_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
824  $atomstructure['modify_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
825  $atomstructure['trackid'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
826  $atomstructure['reserved1'] = getid3_lib::BigEndian2Int(substr($atomdata, 16, 4));
827  $atomstructure['duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 20, 4));
828  $atomstructure['reserved2'] = getid3_lib::BigEndian2Int(substr($atomdata, 24, 8));
829  $atomstructure['layer'] = getid3_lib::BigEndian2Int(substr($atomdata, 32, 2));
830  $atomstructure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atomdata, 34, 2));
831  $atomstructure['volume'] = getid3_lib::FixedPoint8_8(substr($atomdata, 36, 2));
832  $atomstructure['reserved3'] = getid3_lib::BigEndian2Int(substr($atomdata, 38, 2));
833  $atomstructure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atomdata, 40, 4));
834  $atomstructure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atomdata, 44, 4));
835  $atomstructure['matrix_u'] = getid3_lib::FixedPoint16_16(substr($atomdata, 48, 4));
836  $atomstructure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atomdata, 52, 4));
837  $atomstructure['matrix_v'] = getid3_lib::FixedPoint16_16(substr($atomdata, 56, 4));
838  $atomstructure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atomdata, 60, 4));
839  $atomstructure['matrix_x'] = getid3_lib::FixedPoint2_30(substr($atomdata, 64, 4));
840  $atomstructure['matrix_y'] = getid3_lib::FixedPoint2_30(substr($atomdata, 68, 4));
841  $atomstructure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atomdata, 72, 4));
842  $atomstructure['width'] = getid3_lib::FixedPoint16_16(substr($atomdata, 76, 4));
843  $atomstructure['height'] = getid3_lib::FixedPoint16_16(substr($atomdata, 80, 4));
844 
845  $atomstructure['flags']['enabled'] = (bool) ($atomstructure['flags_raw'] & 0x0001);
846  $atomstructure['flags']['in_movie'] = (bool) ($atomstructure['flags_raw'] & 0x0002);
847  $atomstructure['flags']['in_preview'] = (bool) ($atomstructure['flags_raw'] & 0x0004);
848  $atomstructure['flags']['in_poster'] = (bool) ($atomstructure['flags_raw'] & 0x0008);
849  $atomstructure['creation_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['creation_time']);
850  $atomstructure['modify_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['modify_time']);
851 
852  if (!isset($ThisFileInfo['video']['resolution_x']) || !isset($ThisFileInfo['video']['resolution_y'])) {
853  $ThisFileInfo['video']['resolution_x'] = $atomstructure['width'];
854  $ThisFileInfo['video']['resolution_y'] = $atomstructure['height'];
855  }
856  if ($atomstructure['flags']['enabled'] == 1) {
857  $ThisFileInfo['video']['resolution_x'] = max($ThisFileInfo['video']['resolution_x'], $atomstructure['width']);
858  $ThisFileInfo['video']['resolution_y'] = max($ThisFileInfo['video']['resolution_y'], $atomstructure['height']);
859  }
860  if (!empty($ThisFileInfo['video']['resolution_x']) && !empty($ThisFileInfo['video']['resolution_y'])) {
861  $ThisFileInfo['quicktime']['video']['resolution_x'] = $ThisFileInfo['video']['resolution_x'];
862  $ThisFileInfo['quicktime']['video']['resolution_y'] = $ThisFileInfo['video']['resolution_y'];
863  } else {
864  unset($ThisFileInfo['video']['resolution_x']);
865  unset($ThisFileInfo['video']['resolution_y']);
866  unset($ThisFileInfo['quicktime']['video']);
867  }
868  break;
869 
870 
871  case 'meta': // METAdata atom
872  // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
873  $NextTagPosition = strpos($atomdata, '©');
874  while ($NextTagPosition < strlen($atomdata)) {
875  $metaItemSize = getid3_lib::BigEndian2Int(substr($atomdata, $NextTagPosition - 4, 4)) - 4;
876  if ($metaItemSize == -4) {
877  break;
878  }
879  $metaItemRaw = substr($atomdata, $NextTagPosition, $metaItemSize);
880  $metaItemKey = substr($metaItemRaw, 0, 4);
881  $metaItemData = substr($metaItemRaw, 20);
882  $NextTagPosition += $metaItemSize + 4;
883 
884  $this->CopyToAppropriateCommentsSection($metaItemKey, $metaItemData, $ThisFileInfo);
885  }
886  break;
887 
888  case 'ftyp': // FileTYPe (?) atom (for MP4 it seems)
889  $atomstructure['signature'] = substr($atomdata, 0, 4);
890  $atomstructure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
891  $atomstructure['fourcc'] = substr($atomdata, 8, 4);
892  break;
893 
894  case 'mdat': // Media DATa atom
895  case 'free': // FREE space atom
896  case 'skip': // SKIP atom
897  case 'wide': // 64-bit expansion placeholder atom
898  // 'mdat' data is too big to deal with, contains no useful metadata
899  // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
900 
901  // When writing QuickTime files, it is sometimes necessary to update an atom's size.
902  // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom
903  // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime
904  // puts an 8-byte placeholder atom before any atoms it may have to update the size of.
905  // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the
906  // placeholder atom can be overwritten to obtain the necessary 8 extra bytes.
907  // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ).
908  break;
909 
910 
911  case 'nsav': // NoSAVe atom
912  // http://developer.apple.com/technotes/tn/tn2038.html
913  $atomstructure['data'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4));
914  break;
915 
916  case 'ctyp': // Controller TYPe atom (seen on QTVR)
917  // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt
918  // some controller names are:
919  // 0x00 + 'std' for linear movie
920  // 'none' for no controls
921  $atomstructure['ctyp'] = substr($atomdata, 0, 4);
922  switch ($atomstructure['ctyp']) {
923  case 'qtvr':
924  $ThisFileInfo['video']['dataformat'] = 'quicktimevr';
925  break;
926  }
927  break;
928 
929  case 'pano': // PANOrama track (seen on QTVR)
930  $atomstructure['pano'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4));
931  break;
932 
933  case 'hint': // HINT track
934  case 'hinf': //
935  case 'hinv': //
936  case 'hnti': //
937  $ThisFileInfo['quicktime']['hinting'] = true;
938  break;
939 
940  case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR)
941  for ($i = 0; $i < ($atomstructure['size'] - 8); $i += 4) {
942  $atomstructure['imgt'][] = getid3_lib::BigEndian2Int(substr($atomdata, $i, 4));
943  }
944  break;
945 
946  case 'FXTC': // Something to do with Adobe After Effects (?)
947  case 'PrmA':
948  case 'code':
949  case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
950  // Observed-but-not-handled atom types are just listed here
951  // to prevent warnings being generated
952  $atomstructure['data'] = $atomdata;
953  break;
954 
955  default:
956  $ThisFileInfo['warning'][] = 'Unknown QuickTime atom type: "'.$atomname.'" at offset '.$baseoffset;
957  $atomstructure['data'] = $atomdata;
958  break;
959  }
960  array_pop($atomHierarchy);
961  return $atomstructure;
962  }
CopyToAppropriateCommentsSection($keyname, $data, &$ThisFileInfo)
DateMac2Unix($macdate)
Definition: getid3.lib.php:442
FixedPoint16_16($rawdata)
Definition: getid3.lib.php:454
NoNullString($nullterminatedstring)
FixedPoint2_30($rawdata)
Definition: getid3.lib.php:459
FixedPoint8_8($rawdata)
Definition: getid3.lib.php:449
QuicktimeParseContainerAtom($atomdata, &$ThisFileInfo, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms)
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ QuicktimeParseContainerAtom() [1/2]

getid3_quicktime::QuicktimeParseContainerAtom (   $atomdata,
$ThisFileInfo,
  $baseoffset,
$atomHierarchy,
  $ParseAllPossibleAtoms 
)

Definition at line 964 of file module.audio-video.quicktime.php.

References $ParseAllPossibleAtoms, getid3_lib\BigEndian2Int(), and QuicktimeParseAtom().

Referenced by QuicktimeParseAtom().

964  {
965  $atomstructure = false;
966  $subatomoffset = 0;
967  $subatomcounter = 0;
968  if ((strlen($atomdata) == 4) && (getid3_lib::BigEndian2Int($atomdata) == 0x00000000)) {
969  return false;
970  }
971  while ($subatomoffset < strlen($atomdata)) {
972  $subatomsize = getid3_lib::BigEndian2Int(substr($atomdata, $subatomoffset + 0, 4));
973  $subatomname = substr($atomdata, $subatomoffset + 4, 4);
974  $subatomdata = substr($atomdata, $subatomoffset + 8, $subatomsize - 8);
975  if ($subatomsize == 0) {
976  // Furthermore, for historical reasons the list of atoms is optionally
977  // terminated by a 32-bit integer set to 0. If you are writing a program
978  // to read user data atoms, you should allow for the terminating 0.
979  return $atomstructure;
980  }
981 
982  $atomstructure[$subatomcounter] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $ThisFileInfo, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms);
983 
984  $subatomoffset += $subatomsize;
985  $subatomcounter++;
986  }
987  return $atomstructure;
988  }
QuicktimeParseAtom($atomname, $atomsize, $atomdata, &$ThisFileInfo, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms)
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ QuicktimeParseContainerAtom() [2/2]

getid3_quicktime::QuicktimeParseContainerAtom (   $atom_data,
  $baseoffset,
$atomHierarchy,
  $ParseAllPossibleAtoms 
)

Definition at line 1453 of file module.audio-video.quicktime.php.

References $ParseAllPossibleAtoms, getid3_lib\BigEndian2Int(), and QuicktimeParseAtom().

1453  {
1454 //echo 'QuicktimeParseContainerAtom('.substr($atom_data, 4, 4).') @ '.$baseoffset.'<br><br>';
1455  $atom_structure = false;
1456  $subatomoffset = 0;
1457  $subatomcounter = 0;
1458  if ((strlen($atom_data) == 4) && (getid3_lib::BigEndian2Int($atom_data) == 0x00000000)) {
1459  return false;
1460  }
1461  while ($subatomoffset < strlen($atom_data)) {
1462  $subatomsize = getid3_lib::BigEndian2Int(substr($atom_data, $subatomoffset + 0, 4));
1463  $subatomname = substr($atom_data, $subatomoffset + 4, 4);
1464  $subatomdata = substr($atom_data, $subatomoffset + 8, $subatomsize - 8);
1465  if ($subatomsize == 0) {
1466  // Furthermore, for historical reasons the list of atoms is optionally
1467  // terminated by a 32-bit integer set to 0. If you are writing a program
1468  // to read user data atoms, you should allow for the terminating 0.
1469  return $atom_structure;
1470  }
1471 
1472  $atom_structure[$subatomcounter] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms);
1473 
1474  $subatomoffset += $subatomsize;
1475  $subatomcounter++;
1476  }
1477  return $atom_structure;
1478  }
QuicktimeParseAtom($atomname, $atomsize, $atomdata, &$ThisFileInfo, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms)
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:

◆ QuicktimeParseNikonNCTG()

getid3_quicktime::QuicktimeParseNikonNCTG (   $atom_data)

Definition at line 1958 of file module.audio-video.quicktime.php.

References $data, and getid3_lib\BigEndian2Int().

Referenced by QuicktimeParseAtom().

1958  {
1959  // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
1960  // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
1961  // Data is stored as records of:
1962  // * 4 bytes record type
1963  // * 2 bytes size of data field type:
1964  // 0x0001 = flag (size field *= 1-byte)
1965  // 0x0002 = char (size field *= 1-byte)
1966  // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB
1967  // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD
1968  // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together
1969  // 0x0007 = bytes (size field *= 1-byte), values are stored as ??????
1970  // 0x0008 = ????? (size field *= 2-byte), values are stored as ??????
1971  // * 2 bytes data size field
1972  // * ? bytes data (string data may be null-padded; datestamp fields are in the format "2011:05:25 20:24:15")
1973  // all integers are stored BigEndian
1974 
1975  $NCTGtagName = array(
1976  0x00000001 => 'Make',
1977  0x00000002 => 'Model',
1978  0x00000003 => 'Software',
1979  0x00000011 => 'CreateDate',
1980  0x00000012 => 'DateTimeOriginal',
1981  0x00000013 => 'FrameCount',
1982  0x00000016 => 'FrameRate',
1983  0x00000022 => 'FrameWidth',
1984  0x00000023 => 'FrameHeight',
1985  0x00000032 => 'AudioChannels',
1986  0x00000033 => 'AudioBitsPerSample',
1987  0x00000034 => 'AudioSampleRate',
1988  0x02000001 => 'MakerNoteVersion',
1989  0x02000005 => 'WhiteBalance',
1990  0x0200000b => 'WhiteBalanceFineTune',
1991  0x0200001e => 'ColorSpace',
1992  0x02000023 => 'PictureControlData',
1993  0x02000024 => 'WorldTime',
1994  0x02000032 => 'UnknownInfo',
1995  0x02000083 => 'LensType',
1996  0x02000084 => 'Lens',
1997  );
1998 
1999  $offset = 0;
2000  $datalength = strlen($atom_data);
2001  $parsed = array();
2002  while ($offset < $datalength) {
2003 //echo getid3_lib::PrintHexBytes(substr($atom_data, $offset, 4)).'<br>';
2004  $record_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4)); $offset += 4;
2005  $data_size_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2;
2006  $data_size = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2;
2007  switch ($data_size_type) {
2008  case 0x0001: // 0x0001 = flag (size field *= 1-byte)
2009  $data = getid3_lib::BigEndian2Int(substr($atom_data, $offset, $data_size * 1));
2010  $offset += ($data_size * 1);
2011  break;
2012  case 0x0002: // 0x0002 = char (size field *= 1-byte)
2013  $data = substr($atom_data, $offset, $data_size * 1);
2014  $offset += ($data_size * 1);
2015  $data = rtrim($data, "\x00");
2016  break;
2017  case 0x0003: // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB
2018  $data = '';
2019  for ($i = $data_size - 1; $i >= 0; $i--) {
2020  $data .= substr($atom_data, $offset + ($i * 2), 2);
2021  }
2023  $offset += ($data_size * 2);
2024  break;
2025  case 0x0004: // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD
2026  $data = '';
2027  for ($i = $data_size - 1; $i >= 0; $i--) {
2028  $data .= substr($atom_data, $offset + ($i * 4), 4);
2029  }
2031  $offset += ($data_size * 4);
2032  break;
2033  case 0x0005: // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together
2034  $data = array();
2035  for ($i = 0; $i < $data_size; $i++) {
2036  $numerator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 0, 4));
2037  $denomninator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 4, 4));
2038  if ($denomninator == 0) {
2039  $data[$i] = false;
2040  } else {
2041  $data[$i] = (double) $numerator / $denomninator;
2042  }
2043  }
2044  $offset += (8 * $data_size);
2045  if (count($data) == 1) {
2046  $data = $data[0];
2047  }
2048  break;
2049  case 0x0007: // 0x0007 = bytes (size field *= 1-byte), values are stored as ??????
2050  $data = substr($atom_data, $offset, $data_size * 1);
2051  $offset += ($data_size * 1);
2052  break;
2053  case 0x0008: // 0x0008 = ????? (size field *= 2-byte), values are stored as ??????
2054  $data = substr($atom_data, $offset, $data_size * 2);
2055  $offset += ($data_size * 2);
2056  break;
2057  default:
2058 echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br>';
2059  break 2;
2060  }
2061 
2062  switch ($record_type) {
2063  case 0x00000011: // CreateDate
2064  case 0x00000012: // DateTimeOriginal
2065  $data = strtotime($data);
2066  break;
2067  case 0x0200001e: // ColorSpace
2068  switch ($data) {
2069  case 1:
2070  $data = 'sRGB';
2071  break;
2072  case 2:
2073  $data = 'Adobe RGB';
2074  break;
2075  }
2076  break;
2077  case 0x02000023: // PictureControlData
2078  $PictureControlAdjust = array(0=>'default', 1=>'quick', 2=>'full');
2079  $FilterEffect = array(0x80=>'off', 0x81=>'yellow', 0x82=>'orange', 0x83=>'red', 0x84=>'green', 0xff=>'n/a');
2080  $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');
2081  $data = array(
2082  'PictureControlVersion' => substr($data, 0, 4),
2083  'PictureControlName' => rtrim(substr($data, 4, 20), "\x00"),
2084  'PictureControlBase' => rtrim(substr($data, 24, 20), "\x00"),
2085  //'?' => substr($data, 44, 4),
2086  'PictureControlAdjust' => $PictureControlAdjust[ord(substr($data, 48, 1))],
2087  'PictureControlQuickAdjust' => ord(substr($data, 49, 1)),
2088  'Sharpness' => ord(substr($data, 50, 1)),
2089  'Contrast' => ord(substr($data, 51, 1)),
2090  'Brightness' => ord(substr($data, 52, 1)),
2091  'Saturation' => ord(substr($data, 53, 1)),
2092  'HueAdjustment' => ord(substr($data, 54, 1)),
2093  'FilterEffect' => $FilterEffect[ord(substr($data, 55, 1))],
2094  'ToningEffect' => $ToningEffect[ord(substr($data, 56, 1))],
2095  'ToningSaturation' => ord(substr($data, 57, 1)),
2096  );
2097  break;
2098  case 0x02000024: // WorldTime
2099  // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#WorldTime
2100  // timezone is stored as offset from GMT in minutes
2101  $timezone = getid3_lib::BigEndian2Int(substr($data, 0, 2));
2102  if ($timezone & 0x8000) {
2103  $timezone = 0 - (0x10000 - $timezone);
2104  }
2105  $timezone /= 60;
2106 
2107  $dst = (bool) getid3_lib::BigEndian2Int(substr($data, 2, 1));
2108  switch (getid3_lib::BigEndian2Int(substr($data, 3, 1))) {
2109  case 2:
2110  $datedisplayformat = 'D/M/Y'; break;
2111  case 1:
2112  $datedisplayformat = 'M/D/Y'; break;
2113  case 0:
2114  default:
2115  $datedisplayformat = 'Y/M/D'; break;
2116  }
2117 
2118  $data = array('timezone'=>floatval($timezone), 'dst'=>$dst, 'display'=>$datedisplayformat);
2119  break;
2120  case 0x02000083: // LensType
2121  $data = array(
2122  //'_' => $data,
2123  'mf' => (bool) ($data & 0x01),
2124  'd' => (bool) ($data & 0x02),
2125  'g' => (bool) ($data & 0x04),
2126  'vr' => (bool) ($data & 0x08),
2127  );
2128  break;
2129  }
2130  $tag_name = (isset($NCTGtagName[$record_type]) ? $NCTGtagName[$record_type] : '0x'.str_pad(dechex($record_type), 8, '0', STR_PAD_LEFT));
2131  $parsed[$tag_name] = $data;
2132  }
2133  return $parsed;
2134  }
$data
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ QuicktimeSTIKLookup()

getid3_quicktime::QuicktimeSTIKLookup (   $stik)

Definition at line 1761 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1761  {
1762  static $QuicktimeSTIKLookup = array();
1763  if (empty($QuicktimeSTIKLookup)) {
1764  $QuicktimeSTIKLookup[0] = 'Movie';
1765  $QuicktimeSTIKLookup[1] = 'Normal';
1766  $QuicktimeSTIKLookup[2] = 'Audiobook';
1767  $QuicktimeSTIKLookup[5] = 'Whacked Bookmark';
1768  $QuicktimeSTIKLookup[6] = 'Music Video';
1769  $QuicktimeSTIKLookup[9] = 'Short Film';
1770  $QuicktimeSTIKLookup[10] = 'TV Show';
1771  $QuicktimeSTIKLookup[11] = 'Booklet';
1772  $QuicktimeSTIKLookup[14] = 'Ringtone';
1773  $QuicktimeSTIKLookup[21] = 'Podcast';
1774  }
1775  return (isset($QuicktimeSTIKLookup[$stik]) ? $QuicktimeSTIKLookup[$stik] : 'invalid');
1776  }
+ Here is the caller graph for this function:

◆ QuicktimeStoreAccountTypeLookup()

getid3_quicktime::QuicktimeStoreAccountTypeLookup (   $akid)

Definition at line 1920 of file module.audio-video.quicktime.php.

1920  {
1921  static $QuicktimeStoreAccountTypeLookup = array();
1922  if (empty($QuicktimeStoreAccountTypeLookup)) {
1923  $QuicktimeStoreAccountTypeLookup[0] = 'iTunes';
1924  $QuicktimeStoreAccountTypeLookup[1] = 'AOL';
1925  }
1926  return (isset($QuicktimeStoreAccountTypeLookup[$akid]) ? $QuicktimeStoreAccountTypeLookup[$akid] : 'invalid');
1927  }

◆ QuicktimeStoreFrontCodeLookup()

getid3_quicktime::QuicktimeStoreFrontCodeLookup (   $sfid)

Definition at line 1929 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1929  {
1930  static $QuicktimeStoreFrontCodeLookup = array();
1931  if (empty($QuicktimeStoreFrontCodeLookup)) {
1932  $QuicktimeStoreFrontCodeLookup[143460] = 'Australia';
1933  $QuicktimeStoreFrontCodeLookup[143445] = 'Austria';
1934  $QuicktimeStoreFrontCodeLookup[143446] = 'Belgium';
1935  $QuicktimeStoreFrontCodeLookup[143455] = 'Canada';
1936  $QuicktimeStoreFrontCodeLookup[143458] = 'Denmark';
1937  $QuicktimeStoreFrontCodeLookup[143447] = 'Finland';
1938  $QuicktimeStoreFrontCodeLookup[143442] = 'France';
1939  $QuicktimeStoreFrontCodeLookup[143443] = 'Germany';
1940  $QuicktimeStoreFrontCodeLookup[143448] = 'Greece';
1941  $QuicktimeStoreFrontCodeLookup[143449] = 'Ireland';
1942  $QuicktimeStoreFrontCodeLookup[143450] = 'Italy';
1943  $QuicktimeStoreFrontCodeLookup[143462] = 'Japan';
1944  $QuicktimeStoreFrontCodeLookup[143451] = 'Luxembourg';
1945  $QuicktimeStoreFrontCodeLookup[143452] = 'Netherlands';
1946  $QuicktimeStoreFrontCodeLookup[143461] = 'New Zealand';
1947  $QuicktimeStoreFrontCodeLookup[143457] = 'Norway';
1948  $QuicktimeStoreFrontCodeLookup[143453] = 'Portugal';
1949  $QuicktimeStoreFrontCodeLookup[143454] = 'Spain';
1950  $QuicktimeStoreFrontCodeLookup[143456] = 'Sweden';
1951  $QuicktimeStoreFrontCodeLookup[143459] = 'Switzerland';
1952  $QuicktimeStoreFrontCodeLookup[143444] = 'United Kingdom';
1953  $QuicktimeStoreFrontCodeLookup[143441] = 'United States';
1954  }
1955  return (isset($QuicktimeStoreFrontCodeLookup[$sfid]) ? $QuicktimeStoreFrontCodeLookup[$sfid] : 'invalid');
1956  }
+ Here is the caller graph for this function:

◆ QuicktimeVideoCodecLookup() [1/2]

getid3_quicktime::QuicktimeVideoCodecLookup (   $codecid)

Definition at line 1108 of file module.audio-video.quicktime.php.

Referenced by QuicktimeParseAtom().

1108  {
1109  static $QuicktimeVideoCodecLookup = array();
1110  if (empty($QuicktimeVideoCodecLookup)) {
1111  $QuicktimeVideoCodecLookup['3IVX'] = '3ivx MPEG-4';
1112  $QuicktimeVideoCodecLookup['3IV1'] = '3ivx MPEG-4 v1';
1113  $QuicktimeVideoCodecLookup['3IV2'] = '3ivx MPEG-4 v2';
1114  $QuicktimeVideoCodecLookup['avr '] = 'AVR-JPEG';
1115  $QuicktimeVideoCodecLookup['base'] = 'Base';
1116  $QuicktimeVideoCodecLookup['WRLE'] = 'BMP';
1117  $QuicktimeVideoCodecLookup['cvid'] = 'Cinepak';
1118  $QuicktimeVideoCodecLookup['clou'] = 'Cloud';
1119  $QuicktimeVideoCodecLookup['cmyk'] = 'CMYK';
1120  $QuicktimeVideoCodecLookup['yuv2'] = 'ComponentVideo';
1121  $QuicktimeVideoCodecLookup['yuvu'] = 'ComponentVideoSigned';
1122  $QuicktimeVideoCodecLookup['yuvs'] = 'ComponentVideoUnsigned';
1123  $QuicktimeVideoCodecLookup['dvc '] = 'DVC-NTSC';
1124  $QuicktimeVideoCodecLookup['dvcp'] = 'DVC-PAL';
1125  $QuicktimeVideoCodecLookup['dvpn'] = 'DVCPro-NTSC';
1126  $QuicktimeVideoCodecLookup['dvpp'] = 'DVCPro-PAL';
1127  $QuicktimeVideoCodecLookup['fire'] = 'Fire';
1128  $QuicktimeVideoCodecLookup['flic'] = 'FLC';
1129  $QuicktimeVideoCodecLookup['b48r'] = '48RGB';
1130  $QuicktimeVideoCodecLookup['gif '] = 'GIF';
1131  $QuicktimeVideoCodecLookup['smc '] = 'Graphics';
1132  $QuicktimeVideoCodecLookup['h261'] = 'H261';
1133  $QuicktimeVideoCodecLookup['h263'] = 'H263';
1134  $QuicktimeVideoCodecLookup['IV41'] = 'Indeo4';
1135  $QuicktimeVideoCodecLookup['jpeg'] = 'JPEG';
1136  $QuicktimeVideoCodecLookup['PNTG'] = 'MacPaint';
1137  $QuicktimeVideoCodecLookup['msvc'] = 'Microsoft Video1';
1138  $QuicktimeVideoCodecLookup['mjpa'] = 'Motion JPEG-A';
1139  $QuicktimeVideoCodecLookup['mjpb'] = 'Motion JPEG-B';
1140  $QuicktimeVideoCodecLookup['myuv'] = 'MPEG YUV420';
1141  $QuicktimeVideoCodecLookup['dmb1'] = 'OpenDML JPEG';
1142  $QuicktimeVideoCodecLookup['kpcd'] = 'PhotoCD';
1143  $QuicktimeVideoCodecLookup['8BPS'] = 'Planar RGB';
1144  $QuicktimeVideoCodecLookup['png '] = 'PNG';
1145  $QuicktimeVideoCodecLookup['qdrw'] = 'QuickDraw';
1146  $QuicktimeVideoCodecLookup['qdgx'] = 'QuickDrawGX';
1147  $QuicktimeVideoCodecLookup['raw '] = 'RAW';
1148  $QuicktimeVideoCodecLookup['.SGI'] = 'SGI';
1149  $QuicktimeVideoCodecLookup['b16g'] = '16Gray';
1150  $QuicktimeVideoCodecLookup['b64a'] = '64ARGB';
1151  $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 1';
1152  $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 3';
1153  $QuicktimeVideoCodecLookup['syv9'] = 'Sorenson YUV9';
1154  $QuicktimeVideoCodecLookup['tga '] = 'Targa';
1155  $QuicktimeVideoCodecLookup['b32a'] = '32AlphaGray';
1156  $QuicktimeVideoCodecLookup['tiff'] = 'TIFF';
1157  $QuicktimeVideoCodecLookup['path'] = 'Vector';
1158  $QuicktimeVideoCodecLookup['rpza'] = 'Video';
1159  $QuicktimeVideoCodecLookup['ripl'] = 'WaterRipple';
1160  $QuicktimeVideoCodecLookup['WRAW'] = 'Windows RAW';
1161  $QuicktimeVideoCodecLookup['y420'] = 'YUV420';
1162  }
1163  return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : '');
1164  }
+ Here is the caller graph for this function:

◆ QuicktimeVideoCodecLookup() [2/2]

getid3_quicktime::QuicktimeVideoCodecLookup (   $codecid)

Definition at line 1630 of file module.audio-video.quicktime.php.

1630  {
1631  static $QuicktimeVideoCodecLookup = array();
1632  if (empty($QuicktimeVideoCodecLookup)) {
1633  $QuicktimeVideoCodecLookup['.SGI'] = 'SGI';
1634  $QuicktimeVideoCodecLookup['3IV1'] = '3ivx MPEG-4 v1';
1635  $QuicktimeVideoCodecLookup['3IV2'] = '3ivx MPEG-4 v2';
1636  $QuicktimeVideoCodecLookup['3IVX'] = '3ivx MPEG-4';
1637  $QuicktimeVideoCodecLookup['8BPS'] = 'Planar RGB';
1638  $QuicktimeVideoCodecLookup['avc1'] = 'H.264/MPEG-4 AVC';
1639  $QuicktimeVideoCodecLookup['avr '] = 'AVR-JPEG';
1640  $QuicktimeVideoCodecLookup['b16g'] = '16Gray';
1641  $QuicktimeVideoCodecLookup['b32a'] = '32AlphaGray';
1642  $QuicktimeVideoCodecLookup['b48r'] = '48RGB';
1643  $QuicktimeVideoCodecLookup['b64a'] = '64ARGB';
1644  $QuicktimeVideoCodecLookup['base'] = 'Base';
1645  $QuicktimeVideoCodecLookup['clou'] = 'Cloud';
1646  $QuicktimeVideoCodecLookup['cmyk'] = 'CMYK';
1647  $QuicktimeVideoCodecLookup['cvid'] = 'Cinepak';
1648  $QuicktimeVideoCodecLookup['dmb1'] = 'OpenDML JPEG';
1649  $QuicktimeVideoCodecLookup['dvc '] = 'DVC-NTSC';
1650  $QuicktimeVideoCodecLookup['dvcp'] = 'DVC-PAL';
1651  $QuicktimeVideoCodecLookup['dvpn'] = 'DVCPro-NTSC';
1652  $QuicktimeVideoCodecLookup['dvpp'] = 'DVCPro-PAL';
1653  $QuicktimeVideoCodecLookup['fire'] = 'Fire';
1654  $QuicktimeVideoCodecLookup['flic'] = 'FLC';
1655  $QuicktimeVideoCodecLookup['gif '] = 'GIF';
1656  $QuicktimeVideoCodecLookup['h261'] = 'H261';
1657  $QuicktimeVideoCodecLookup['h263'] = 'H263';
1658  $QuicktimeVideoCodecLookup['IV41'] = 'Indeo4';
1659  $QuicktimeVideoCodecLookup['jpeg'] = 'JPEG';
1660  $QuicktimeVideoCodecLookup['kpcd'] = 'PhotoCD';
1661  $QuicktimeVideoCodecLookup['mjpa'] = 'Motion JPEG-A';
1662  $QuicktimeVideoCodecLookup['mjpb'] = 'Motion JPEG-B';
1663  $QuicktimeVideoCodecLookup['msvc'] = 'Microsoft Video1';
1664  $QuicktimeVideoCodecLookup['myuv'] = 'MPEG YUV420';
1665  $QuicktimeVideoCodecLookup['path'] = 'Vector';
1666  $QuicktimeVideoCodecLookup['png '] = 'PNG';
1667  $QuicktimeVideoCodecLookup['PNTG'] = 'MacPaint';
1668  $QuicktimeVideoCodecLookup['qdgx'] = 'QuickDrawGX';
1669  $QuicktimeVideoCodecLookup['qdrw'] = 'QuickDraw';
1670  $QuicktimeVideoCodecLookup['raw '] = 'RAW';
1671  $QuicktimeVideoCodecLookup['ripl'] = 'WaterRipple';
1672  $QuicktimeVideoCodecLookup['rpza'] = 'Video';
1673  $QuicktimeVideoCodecLookup['smc '] = 'Graphics';
1674  $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 1';
1675  $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 3';
1676  $QuicktimeVideoCodecLookup['syv9'] = 'Sorenson YUV9';
1677  $QuicktimeVideoCodecLookup['tga '] = 'Targa';
1678  $QuicktimeVideoCodecLookup['tiff'] = 'TIFF';
1679  $QuicktimeVideoCodecLookup['WRAW'] = 'Windows RAW';
1680  $QuicktimeVideoCodecLookup['WRLE'] = 'BMP';
1681  $QuicktimeVideoCodecLookup['y420'] = 'YUV420';
1682  $QuicktimeVideoCodecLookup['yuv2'] = 'ComponentVideo';
1683  $QuicktimeVideoCodecLookup['yuvs'] = 'ComponentVideoUnsigned';
1684  $QuicktimeVideoCodecLookup['yuvu'] = 'ComponentVideoSigned';
1685  }
1686  return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : '');
1687  }

Field Documentation

◆ $ParseAllPossibleAtoms

getid3_quicktime::$ParseAllPossibleAtoms = false

◆ $ReturnAtomData

getid3_quicktime::$ReturnAtomData = true

Definition at line 24 of file module.audio-video.quicktime.php.

Referenced by getid3_quicktime().


The documentation for this class was generated from the following file: