Ticket #29627: 29627.diff
| File 29627.diff, 142.4 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/ID3/getid3.lib.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // // 8 9 // getid3.lib.php - part of getID3() // … … 282 283 } 283 284 } else { 284 285 throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in self::BigEndian2Int()'); 285 break;286 286 } 287 287 } 288 288 return self::CastAsInt($intvalue); … … 635 635 } 636 636 if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) { 637 637 if (($fp_dest = fopen($filename_dest, 'wb'))) { 638 if (fseek($fp_src, $offset , SEEK_SET) == 0) {638 if (fseek($fp_src, $offset) == 0) { 639 639 $byteslefttowrite = $length; 640 640 while (($byteslefttowrite > 0) && ($buffer = fread($fp_src, min($byteslefttowrite, getID3::FREAD_BUFFER_SIZE)))) { 641 641 $byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite); … … 986 986 throw new Exception('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset); 987 987 } 988 988 989 public static function recursiveMultiByteCharString2HTML($data, $charset='ISO-8859-1') { 990 if (is_string($data)) { 991 return self::MultiByteCharString2HTML($data, $charset); 992 } elseif (is_array($data)) { 993 $return_data = array(); 994 foreach ($data as $key => $value) { 995 $return_data[$key] = self::recursiveMultiByteCharString2HTML($value, $charset); 996 } 997 return $return_data; 998 } 999 // integer, float, objects, resources, etc 1000 return $data; 1001 } 989 1002 990 1003 public static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') { 991 1004 $string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string … … 1210 1223 $newvaluelength = strlen(trim($value)); 1211 1224 foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) { 1212 1225 $oldvaluelength = strlen(trim($existingvalue)); 1213 if (( $newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {1226 if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) { 1214 1227 $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value); 1215 break 2; 1228 //break 2; 1229 break; 1216 1230 } 1217 1231 } 1218 1232 … … 1219 1233 } 1220 1234 if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) { 1221 1235 $value = (is_string($value) ? trim($value) : $value); 1222 $ThisFileInfo['comments'][$tagname][] = $value; 1236 if (!is_numeric($key)) { 1237 $ThisFileInfo['comments'][$tagname][$key] = $value; 1238 } else { 1239 $ThisFileInfo['comments'][$tagname][] = $value; 1240 } 1223 1241 } 1224 1242 } 1225 1243 } … … 1227 1245 } 1228 1246 1229 1247 // Copy to ['comments_html'] 1230 foreach ($ThisFileInfo['comments'] as $field => $values) { 1231 if ($field == 'picture') { 1232 // pictures can take up a lot of space, and we don't need multiple copies of them 1233 // let there be a single copy in [comments][picture], and not elsewhere 1234 continue; 1235 } 1236 foreach ($values as $index => $value) { 1237 if (is_array($value)) { 1238 $ThisFileInfo['comments_html'][$field][$index] = $value; 1239 } else { 1240 $ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding'])); 1248 if (!empty($ThisFileInfo['comments'])) { 1249 foreach ($ThisFileInfo['comments'] as $field => $values) { 1250 if ($field == 'picture') { 1251 // pictures can take up a lot of space, and we don't need multiple copies of them 1252 // let there be a single copy in [comments][picture], and not elsewhere 1253 continue; 1241 1254 } 1255 foreach ($values as $index => $value) { 1256 if (is_array($value)) { 1257 $ThisFileInfo['comments_html'][$field][$index] = $value; 1258 } else { 1259 $ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding'])); 1260 } 1261 } 1242 1262 } 1243 1263 } 1264 1244 1265 } 1245 1266 return true; 1246 1267 } … … 1339 1360 } 1340 1361 return $filesize; 1341 1362 } 1363 1364 1365 /** 1366 * Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268) 1367 * @param string $path A path. 1368 * @param string $suffix If the name component ends in suffix this will also be cut off. 1369 * @return string 1370 */ 1371 public static function mb_basename($path, $suffix = null) { 1372 $splited = preg_split('#/#', rtrim($path, '/ ')); 1373 return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1); 1374 } 1375 1342 1376 } 1377 No newline at end of file -
src/wp-includes/ID3/getid3.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // // 8 9 // Please see readme.txt for more information // … … 17 18 if (!defined('GETID3_INCLUDEPATH')) { 18 19 define('GETID3_INCLUDEPATH', dirname(__FILE__).DIRECTORY_SEPARATOR); 19 20 } 21 // Workaround Bug #39923 (https://bugs.php.net/bug.php?id=39923) 22 if (!defined('IMG_JPG') && defined('IMAGETYPE_JPEG')) { 23 define('IMG_JPG', IMAGETYPE_JPEG); 24 } 20 25 21 26 // attempt to define temp dir as something flexible but reliable 22 27 $temp_dir = ini_get('upload_tmp_dir'); … … 23 28 if ($temp_dir && (!is_dir($temp_dir) || !is_readable($temp_dir))) { 24 29 $temp_dir = ''; 25 30 } 26 if (!$temp_dir && function_exists('sys_get_temp_dir')) { 27 // PHP v5.2.1+ 31 if (!$temp_dir) { 28 32 // sys_get_temp_dir() may give inaccessible temp dir, e.g. with open_basedir on virtual hosts 29 33 $temp_dir = sys_get_temp_dir(); 30 34 } 31 $temp_dir = realpath($temp_dir);35 $temp_dir = @realpath($temp_dir); // see https://github.com/JamesHeinrich/getID3/pull/10 32 36 $open_basedir = ini_get('open_basedir'); 33 37 if ($open_basedir) { 34 38 // e.g. "/var/www/vhosts/getid3.org/httpdocs/:/tmp/" … … 57 61 $temp_dir = '*'; // invalid directory name should force tempnam() to use system default temp dir 58 62 } 59 63 // $temp_dir = '/something/else/'; // feel free to override temp dir here if it works better for your system 60 define('GETID3_TEMP_DIR', $temp_dir); 64 if (!defined('GETID3_TEMP_DIR')) { 65 define('GETID3_TEMP_DIR', $temp_dir); 66 } 61 67 unset($open_basedir, $temp_dir); 62 68 63 69 // End: Defines … … 97 103 public $fp; // Filepointer to file being analysed. 98 104 public $info; // Result array. 99 105 public $tempdir = GETID3_TEMP_DIR; 106 public $memory_limit = 0; 100 107 101 108 // Protected variables 102 109 protected $startup_error = ''; 103 110 protected $startup_warning = ''; 104 protected $memory_limit = 0;105 111 106 const VERSION = '1.9. 7-20130705';112 const VERSION = '1.9.8-20140511'; 107 113 const FREAD_BUFFER_SIZE = 32768; 108 114 109 115 const ATTACHMENTS_NONE = false; … … 112 118 // public: constructor 113 119 public function __construct() { 114 120 115 // Check for PHP version116 $required_php_version = '5.0.5';117 if (version_compare(PHP_VERSION, $required_php_version, '<')) {118 $this->startup_error .= 'getID3() requires PHP v'.$required_php_version.' or higher - you are running v'.PHP_VERSION;119 return false;120 }121 122 121 // Check memory 123 122 $this->memory_limit = ini_get('memory_limit'); 124 123 if (preg_match('#([0-9]+)M#i', $this->memory_limit, $matches)) { … … 261 260 $filename = preg_replace('#(.+)'.preg_quote(DIRECTORY_SEPARATOR).'{2,}#U', '\1'.DIRECTORY_SEPARATOR, $filename); 262 261 263 262 // open local file 264 if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { 263 //if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { // see http://www.getid3.org/phpBB3/viewtopic.php?t=1720 264 if ((is_readable($filename) || file_exists($filename)) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { 265 265 // great 266 266 } else { 267 throw new getid3_exception('Could not open "'.$filename.'" (does not exist, or is not a file)'); 267 $errormessagelist = array(); 268 if (!is_readable($filename)) { 269 $errormessagelist[] = '!is_readable'; 270 } 271 if (!is_file($filename)) { 272 $errormessagelist[] = '!is_file'; 273 } 274 if (!file_exists($filename)) { 275 $errormessagelist[] = '!file_exists'; 276 } 277 if (empty($errormessagelist)) { 278 $errormessagelist[] = 'fopen failed'; 279 } 280 throw new getid3_exception('Could not open "'.$filename.'" ('.implode('; ', $errormessagelist).')'); 268 281 } 269 282 270 283 $this->info['filesize'] = filesize($filename); 271 284 // set redundant parameters - might be needed in some include file 272 $this->info['filename'] = basename($filename); 285 // filenames / filepaths in getID3 are always expressed with forward slashes (unix-style) for both Windows and other to try and minimize confusion 286 $filename = str_replace('\\', '/', $filename); 273 287 $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename))); 288 $this->info['filename'] = getid3_lib::mb_basename($filename); 274 289 $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename']; 275 290 276 291 … … 352 367 353 368 // ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier 354 369 if (!$this->option_tag_id3v2) { 355 fseek($this->fp, 0 , SEEK_SET);370 fseek($this->fp, 0); 356 371 $header = fread($this->fp, 10); 357 372 if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) { 358 373 $this->info['id3v2']['header'] = true; … … 363 378 } 364 379 365 380 // read 32 kb file data 366 fseek($this->fp, $this->info['avdataoffset'] , SEEK_SET);381 fseek($this->fp, $this->info['avdataoffset']); 367 382 $formattest = fread($this->fp, 32774); 368 383 369 384 // determine format … … 588 603 'mime_type' => 'audio/basic', 589 604 ), 590 605 606 // AMR - audio - Adaptive Multi Rate 607 'amr' => array( 608 'pattern' => '^\x23\x21AMR\x0A', // #!AMR[0A] 609 'group' => 'audio', 610 'module' => 'amr', 611 'mime_type' => 'audio/amr', 612 ), 613 591 614 // AVR - audio - Audio Visual Research 592 615 'avr' => array( 593 616 'pattern' => '^2BIT', … … 1161 1184 'matroska' => array('matroska' , 'UTF-8'), 1162 1185 'flac' => array('vorbiscomment' , 'UTF-8'), 1163 1186 'divxtag' => array('divx' , 'ISO-8859-1'), 1187 'iptc' => array('iptc' , 'ISO-8859-1'), 1164 1188 ); 1165 1189 } 1166 1190 … … 1181 1205 $value = trim($value, " \r\n\t"); // do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed! 1182 1206 } 1183 1207 if ($value) { 1184 $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value; 1208 if (!is_numeric($key)) { 1209 $this->info['tags'][trim($tag_name)][trim($tag_key)][$key] = $value; 1210 } else { 1211 $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value; 1212 } 1185 1213 } 1186 1214 } 1187 1215 if ($tag_key == 'picture') { … … 1196 1224 1197 1225 if ($this->option_tags_html) { 1198 1226 foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) { 1199 foreach ($valuearray as $key => $value) { 1200 if (is_string($value)) { 1201 //$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding); 1202 $this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('�', '', trim(getid3_lib::MultiByteCharString2HTML($value, $encoding))); 1203 } else { 1204 $this->info['tags_html'][$tag_name][$tag_key][$key] = $value; 1205 } 1206 } 1227 $this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $encoding); 1207 1228 } 1208 1229 } 1209 1230 … … 1259 1280 return true; 1260 1281 } 1261 1282 1262 1263 1283 public function getHashdata($algorithm) { 1264 1284 switch ($algorithm) { 1265 1285 case 'md5': … … 1565 1585 } 1566 1586 1567 1587 1568 abstract class getid3_handler 1569 { 1588 abstract class getid3_handler { 1589 1590 /** 1591 * @var getID3 1592 */ 1570 1593 protected $getid3; // pointer 1571 1594 1572 1595 protected $data_string_flag = false; // analyzing filepointer or string … … 1593 1616 // Analyze from string instead 1594 1617 public function AnalyzeString($string) { 1595 1618 // Enter string mode 1596 $this->setStringMode($string);1619 $this->setStringMode($string); 1597 1620 1598 1621 // Save info 1599 1622 $saved_avdataoffset = $this->getid3->info['avdataoffset']; … … 1634 1657 $this->data_string_position += $bytes; 1635 1658 return substr($this->data_string, $this->data_string_position - $bytes, $bytes); 1636 1659 } 1637 $pos = $this->ftell() + $bytes;1638 if (!getid3_lib::intValueSupported($pos)) {1660 $pos = $this->ftell() + $bytes; 1661 if (!getid3_lib::intValueSupported($pos)) { 1639 1662 throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10); 1640 }1663 } 1641 1664 return fread($this->getid3->fp, $bytes); 1642 1665 } 1643 1666 … … 1657 1680 break; 1658 1681 } 1659 1682 return 0; 1660 } else {1661 $pos = $bytes;1662 if ($whence == SEEK_CUR) {1683 } else { 1684 $pos = $bytes; 1685 if ($whence == SEEK_CUR) { 1663 1686 $pos = $this->ftell() + $bytes; 1664 } elseif ($whence == SEEK_END) {1665 $pos = $this-> info['filesize'] + $bytes;1666 }1667 if (!getid3_lib::intValueSupported($pos)) {1687 } elseif ($whence == SEEK_END) { 1688 $pos = $this->getid3->info['filesize'] + $bytes; 1689 } 1690 if (!getid3_lib::intValueSupported($pos)) { 1668 1691 throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10); 1669 1692 } 1670 1693 } … … 1682 1705 return $this->dependency_to == $module; 1683 1706 } 1684 1707 1685 protected function error($text) 1686 { 1708 protected function error($text) { 1687 1709 $this->getid3->info['error'][] = $text; 1688 1710 1689 1711 return false; 1690 1712 } 1691 1713 1692 protected function warning($text) 1693 { 1714 protected function warning($text) { 1694 1715 return $this->getid3->warning($text); 1695 1716 } 1696 1717 1697 protected function notice($text) 1698 { 1718 protected function notice($text) { 1699 1719 // does nothing for now 1700 1720 } 1701 1721 -
src/wp-includes/ID3/license.commercial.txt
24 24 The licensee may not sub-license getID3() itself, meaning that any 25 25 commercially released product containing all or parts of getID3() must 26 26 have added functionality beyond what is available in getID3(); 27 getID3() itself may not be re-licensed by the licensee. 27 getID3() itself may not be re-licensed by the licensee. 28 No newline at end of file -
src/wp-includes/ID3/license.txt
2 2 /// getID3() by James Heinrich <info@getid3.org> // 3 3 // available at http://getid3.sourceforge.net // 4 4 // or http://www.getid3.org // 5 // also https://github.com/JamesHeinrich/getID3 // 5 6 ///////////////////////////////////////////////////////////////// 6 7 7 8 ***************************************************************** … … 25 26 ***************************************************************** 26 27 27 28 Copies of each of the above licenses are included in the 'licenses' 28 directory of the getID3 distribution. 29 directory of the getID3 distribution. 30 No newline at end of file -
src/wp-includes/ID3/module.audio-video.asf.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 15 16 16 17 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true); 17 18 18 class getid3_asf extends getid3_handler 19 { 19 class getid3_asf extends getid3_handler { 20 20 21 21 public function __construct(getID3 $getid3) { 22 22 parent::__construct($getid3); // extends getid3_handler::__construct() … … 66 66 67 67 $info['fileformat'] = 'asf'; 68 68 69 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);70 $HeaderObjectData = fread($this->getid3->fp,30);69 $this->fseek($info['avdataoffset']); 70 $HeaderObjectData = $this->fread(30); 71 71 72 72 $thisfile_asf_headerobject['objectid'] = substr($HeaderObjectData, 0, 16); 73 73 $thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']); 74 74 if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) { 75 $info['warning'][] = 'ASF header GUID {'.$this->BytestringToGUID($thisfile_asf_headerobject['objectid']).'} does not match expected "GETID3_ASF_Header_Object" GUID {'.$this->BytestringToGUID(GETID3_ASF_Header_Object).'}'; 76 unset($info['fileformat']); 77 unset($info['asf']); 78 return false; 79 break; 75 unset($info['fileformat'], $info['asf']); 76 return $this->error('ASF header GUID {'.$this->BytestringToGUID($thisfile_asf_headerobject['objectid']).'} does not match expected "GETID3_ASF_Header_Object" GUID {'.$this->BytestringToGUID(GETID3_ASF_Header_Object).'}'); 80 77 } 81 78 $thisfile_asf_headerobject['objectsize'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 16, 8)); 82 79 $thisfile_asf_headerobject['headerobjects'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 24, 4)); … … 83 80 $thisfile_asf_headerobject['reserved1'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1)); 84 81 $thisfile_asf_headerobject['reserved2'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1)); 85 82 86 $NextObjectOffset = ftell($this->getid3->fp);87 $ASFHeaderData = fread($this->getid3->fp,$thisfile_asf_headerobject['objectsize'] - 30);83 $NextObjectOffset = $this->ftell(); 84 $ASFHeaderData = $this->fread($thisfile_asf_headerobject['objectsize'] - 30); 88 85 $offset = 0; 89 86 90 87 for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) { … … 284 281 $offset += 4; 285 282 $thisfile_asf_headerextensionobject['extension_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_headerextensionobject['extension_data_size']); 286 283 $unhandled_sections = 0; 287 $thisfile_asf_headerextensionobject['extension_data_parsed'] = $this-> ASF_HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections);284 $thisfile_asf_headerextensionobject['extension_data_parsed'] = $this->HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections); 288 285 if ($unhandled_sections === 0) { 289 286 unset($thisfile_asf_headerextensionobject['extension_data']); 290 287 } … … 332 329 333 330 $thisfile_asf_codeclistobject_codecentries_current['type_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); 334 331 $offset += 2; 335 $thisfile_asf_codeclistobject_codecentries_current['type'] = $this->ASFCodecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current['type_raw']);332 $thisfile_asf_codeclistobject_codecentries_current['type'] = self::codecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current['type_raw']); 336 333 337 334 $CodecNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character 338 335 $offset += 2; … … 826 823 break; 827 824 828 825 case 'id3': 829 // id3v2 module might not be loaded 830 if (class_exists('getid3_id3v2')) { 831 $tempfile = tempnam(GETID3_TEMP_DIR, 'getID3'); 832 $tempfilehandle = fopen($tempfile, 'wb'); 833 $tempThisfileInfo = array('encoding'=>$info['encoding']); 834 fwrite($tempfilehandle, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); 835 fclose($tempfilehandle); 826 $this->getid3->include_module('tag.id3v2'); 836 827 837 $getid3_temp = new getID3(); 838 $getid3_temp->openfile($tempfile); 839 $getid3_id3v2 = new getid3_id3v2($getid3_temp); 840 $getid3_id3v2->Analyze(); 841 $info['id3v2'] = $getid3_temp->info['id3v2']; 842 unset($getid3_temp, $getid3_id3v2); 828 $getid3_id3v2 = new getid3_id3v2($this->getid3); 829 $getid3_id3v2->AnalyzeString($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); 830 unset($getid3_id3v2); 843 831 844 unlink($tempfile); 832 if ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'] > 1024) { 833 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = '<value too large to display>'; 845 834 } 846 835 break; 847 836 … … 860 849 $wm_picture_offset = 0; 861 850 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 1)); 862 851 $wm_picture_offset += 1; 863 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type'] = $this->WMpictureTypeLookup($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id']);852 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type'] = self::WMpictureTypeLookup($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id']); 864 853 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_size'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 4)); 865 854 $wm_picture_offset += 4; 866 855 … … 1156 1145 } 1157 1146 } 1158 1147 1159 while ( ftell($this->getid3->fp) < $info['avdataend']) {1160 $NextObjectDataHeader = fread($this->getid3->fp,24);1148 while ($this->ftell() < $info['avdataend']) { 1149 $NextObjectDataHeader = $this->fread(24); 1161 1150 $offset = 0; 1162 1151 $NextObjectGUID = substr($NextObjectDataHeader, 0, 16); 1163 1152 $offset += 16; … … 1179 1168 $thisfile_asf['data_object'] = array(); 1180 1169 $thisfile_asf_dataobject = &$thisfile_asf['data_object']; 1181 1170 1182 $DataObjectData = $NextObjectDataHeader. fread($this->getid3->fp,50 - 24);1171 $DataObjectData = $NextObjectDataHeader.$this->fread(50 - 24); 1183 1172 $offset = 24; 1184 1173 1185 1174 $thisfile_asf_dataobject['objectid'] = $NextObjectGUID; … … 1207 1196 // * * Error Correction Present bits 1 // If set, use Opaque Data Packet structure, else use Payload structure 1208 1197 // * Error Correction Data 1209 1198 1210 $info['avdataoffset'] = ftell($this->getid3->fp);1211 fseek($this->getid3->fp,($thisfile_asf_dataobject['objectsize'] - 50), SEEK_CUR); // skip actual audio/video data1212 $info['avdataend'] = ftell($this->getid3->fp);1199 $info['avdataoffset'] = $this->ftell(); 1200 $this->fseek(($thisfile_asf_dataobject['objectsize'] - 50), SEEK_CUR); // skip actual audio/video data 1201 $info['avdataend'] = $this->ftell(); 1213 1202 break; 1214 1203 1215 1204 case GETID3_ASF_Simple_Index_Object: … … 1229 1218 $thisfile_asf['simple_index_object'] = array(); 1230 1219 $thisfile_asf_simpleindexobject = &$thisfile_asf['simple_index_object']; 1231 1220 1232 $SimpleIndexObjectData = $NextObjectDataHeader. fread($this->getid3->fp,56 - 24);1221 $SimpleIndexObjectData = $NextObjectDataHeader.$this->fread(56 - 24); 1233 1222 $offset = 24; 1234 1223 1235 1224 $thisfile_asf_simpleindexobject['objectid'] = $NextObjectGUID; … … 1246 1235 $thisfile_asf_simpleindexobject['index_entries_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4)); 1247 1236 $offset += 4; 1248 1237 1249 $IndexEntriesData = $SimpleIndexObjectData. fread($this->getid3->fp,6 * $thisfile_asf_simpleindexobject['index_entries_count']);1238 $IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $thisfile_asf_simpleindexobject['index_entries_count']); 1250 1239 for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; $IndexEntriesCounter++) { 1251 1240 $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4)); 1252 1241 $offset += 4; … … 1283 1272 $thisfile_asf['asf_index_object'] = array(); 1284 1273 $thisfile_asf_asfindexobject = &$thisfile_asf['asf_index_object']; 1285 1274 1286 $ASFIndexObjectData = $NextObjectDataHeader. fread($this->getid3->fp,34 - 24);1275 $ASFIndexObjectData = $NextObjectDataHeader.$this->fread(34 - 24); 1287 1276 $offset = 24; 1288 1277 1289 1278 $thisfile_asf_asfindexobject['objectid'] = $NextObjectGUID; … … 1297 1286 $thisfile_asf_asfindexobject['index_blocks_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); 1298 1287 $offset += 4; 1299 1288 1300 $ASFIndexObjectData .= fread($this->getid3->fp,4 * $thisfile_asf_asfindexobject['index_specifiers_count']);1289 $ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count']); 1301 1290 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { 1302 1291 $IndexSpecifierStreamNumber = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); 1303 1292 $offset += 2; … … 1307 1296 $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type_text'] = $this->ASFIndexObjectIndexTypeLookup($thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type']); 1308 1297 } 1309 1298 1310 $ASFIndexObjectData .= fread($this->getid3->fp,4);1299 $ASFIndexObjectData .= $this->fread(4); 1311 1300 $thisfile_asf_asfindexobject['index_entry_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); 1312 1301 $offset += 4; 1313 1302 1314 $ASFIndexObjectData .= fread($this->getid3->fp,8 * $thisfile_asf_asfindexobject['index_specifiers_count']);1303 $ASFIndexObjectData .= $this->fread(8 * $thisfile_asf_asfindexobject['index_specifiers_count']); 1315 1304 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { 1316 1305 $thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8)); 1317 1306 $offset += 8; 1318 1307 } 1319 1308 1320 $ASFIndexObjectData .= fread($this->getid3->fp,4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']);1309 $ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']); 1321 1310 for ($IndexEntryCounter = 0; $IndexEntryCounter < $thisfile_asf_asfindexobject['index_entry_count']; $IndexEntryCounter++) { 1322 1311 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { 1323 1312 $thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); … … 1332 1321 if ($this->GUIDname($NextObjectGUIDtext)) { 1333 1322 $info['warning'][] = 'unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF body at offset '.($offset - 16 - 8); 1334 1323 } else { 1335 $info['warning'][] = 'unknown GUID {'.$NextObjectGUIDtext.'} in ASF body at offset '.( ftell($this->getid3->fp) - 16 - 8);1324 $info['warning'][] = 'unknown GUID {'.$NextObjectGUIDtext.'} in ASF body at offset '.($this->ftell() - 16 - 8); 1336 1325 } 1337 fseek($this->getid3->fp,($NextObjectSize - 16 - 8), SEEK_CUR);1326 $this->fseek(($NextObjectSize - 16 - 8), SEEK_CUR); 1338 1327 break; 1339 1328 } 1340 1329 } … … 1433 1422 $thisfile_video['dataformat'] = (!empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf'); 1434 1423 } 1435 1424 if (!empty($thisfile_video['streams'])) { 1436 $thisfile_video[' streams']['resolution_x'] = 0;1437 $thisfile_video[' streams']['resolution_y'] = 0;1425 $thisfile_video['resolution_x'] = 0; 1426 $thisfile_video['resolution_y'] = 0; 1438 1427 foreach ($thisfile_video['streams'] as $key => $valuearray) { 1439 if (($valuearray['resolution_x'] > $thisfile_video[' streams']['resolution_x']) || ($valuearray['resolution_y'] > $thisfile_video['streams']['resolution_y'])) {1428 if (($valuearray['resolution_x'] > $thisfile_video['resolution_x']) || ($valuearray['resolution_y'] > $thisfile_video['resolution_y'])) { 1440 1429 $thisfile_video['resolution_x'] = $valuearray['resolution_x']; 1441 1430 $thisfile_video['resolution_y'] = $valuearray['resolution_y']; 1442 1431 } … … 1451 1440 return true; 1452 1441 } 1453 1442 1454 public static function ASFCodecListObjectTypeLookup($CodecListType) { 1455 static $ASFCodecListObjectTypeLookup = array(); 1456 if (empty($ASFCodecListObjectTypeLookup)) { 1457 $ASFCodecListObjectTypeLookup[0x0001] = 'Video Codec'; 1458 $ASFCodecListObjectTypeLookup[0x0002] = 'Audio Codec'; 1459 $ASFCodecListObjectTypeLookup[0xFFFF] = 'Unknown Codec'; 1460 } 1443 public static function codecListObjectTypeLookup($CodecListType) { 1444 static $lookup = array( 1445 0x0001 => 'Video Codec', 1446 0x0002 => 'Audio Codec', 1447 0xFFFF => 'Unknown Codec' 1448 ); 1461 1449 1462 return (isset($ ASFCodecListObjectTypeLookup[$CodecListType]) ? $ASFCodecListObjectTypeLookup[$CodecListType] : 'Invalid Codec Type');1450 return (isset($lookup[$CodecListType]) ? $lookup[$CodecListType] : 'Invalid Codec Type'); 1463 1451 } 1464 1452 1465 1453 public static function KnownGUIDs() { … … 1666 1654 } 1667 1655 1668 1656 public static function WMpictureTypeLookup($WMpictureType) { 1669 static $WMpictureTypeLookup = array(); 1670 if (empty($WMpictureTypeLookup)) { 1671 $WMpictureTypeLookup[0x03] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Front Cover'); 1672 $WMpictureTypeLookup[0x04] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Back Cover'); 1673 $WMpictureTypeLookup[0x00] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'User Defined'); 1674 $WMpictureTypeLookup[0x05] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Leaflet Page'); 1675 $WMpictureTypeLookup[0x06] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Media Label'); 1676 $WMpictureTypeLookup[0x07] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Lead Artist'); 1677 $WMpictureTypeLookup[0x08] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Artist'); 1678 $WMpictureTypeLookup[0x09] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Conductor'); 1679 $WMpictureTypeLookup[0x0A] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Band'); 1680 $WMpictureTypeLookup[0x0B] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Composer'); 1681 $WMpictureTypeLookup[0x0C] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Lyricist'); 1682 $WMpictureTypeLookup[0x0D] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Recording Location'); 1683 $WMpictureTypeLookup[0x0E] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'During Recording'); 1684 $WMpictureTypeLookup[0x0F] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'During Performance'); 1685 $WMpictureTypeLookup[0x10] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Video Screen Capture'); 1686 $WMpictureTypeLookup[0x12] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Illustration'); 1687 $WMpictureTypeLookup[0x13] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Band Logotype'); 1688 $WMpictureTypeLookup[0x14] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Publisher Logotype'); 1657 static $lookup = null; 1658 if ($lookup === null) { 1659 $lookup = array( 1660 0x03 => 'Front Cover', 1661 0x04 => 'Back Cover', 1662 0x00 => 'User Defined', 1663 0x05 => 'Leaflet Page', 1664 0x06 => 'Media Label', 1665 0x07 => 'Lead Artist', 1666 0x08 => 'Artist', 1667 0x09 => 'Conductor', 1668 0x0A => 'Band', 1669 0x0B => 'Composer', 1670 0x0C => 'Lyricist', 1671 0x0D => 'Recording Location', 1672 0x0E => 'During Recording', 1673 0x0F => 'During Performance', 1674 0x10 => 'Video Screen Capture', 1675 0x12 => 'Illustration', 1676 0x13 => 'Band Logotype', 1677 0x14 => 'Publisher Logotype' 1678 ); 1679 $lookup = array_map(function($str) { 1680 return getid3_lib::iconv_fallback('UTF-8', 'UTF-16LE', $str); 1681 }, $lookup); 1689 1682 } 1690 return (isset($WMpictureTypeLookup[$WMpictureType]) ? $WMpictureTypeLookup[$WMpictureType] : ''); 1683 1684 return (isset($lookup[$WMpictureType]) ? $lookup[$WMpictureType] : ''); 1691 1685 } 1692 1686 1693 public function ASF_HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections) {1687 public function HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections) { 1694 1688 // http://msdn.microsoft.com/en-us/library/bb643323.aspx 1695 1689 1696 1690 $offset = 0; … … 1825 1819 1826 1820 $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); 1827 1821 $offset += 2; 1828 $descriptionRecord['data_type_text'] = $this->ASFmetadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']);1822 $descriptionRecord['data_type_text'] = self::metadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']); 1829 1823 1830 1824 $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); 1831 1825 $offset += 4; … … 1897 1891 1898 1892 $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); 1899 1893 $offset += 2; 1900 $descriptionRecord['data_type_text'] = $this->ASFmetadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']);1894 $descriptionRecord['data_type_text'] = self::metadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']); 1901 1895 1902 1896 $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); 1903 1897 $offset += 4; … … 1937 1931 } 1938 1932 1939 1933 1940 public static function ASFmetadataLibraryObjectDataTypeLookup($id) {1941 static $ ASFmetadataLibraryObjectDataTypeLookup = array(1934 public static function metadataLibraryObjectDataTypeLookup($id) { 1935 static $lookup = array( 1942 1936 0x0000 => 'Unicode string', // The data consists of a sequence of Unicode characters 1943 1937 0x0001 => 'BYTE array', // The type of the data is implementation-specific 1944 1938 0x0002 => 'BOOL', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer. Only 0x0000 or 0x0001 are permitted values … … 1947 1941 0x0005 => 'WORD', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer 1948 1942 0x0006 => 'GUID', // The data is 16 bytes long and should be interpreted as a 128-bit GUID 1949 1943 ); 1950 return (isset($ ASFmetadataLibraryObjectDataTypeLookup[$id]) ? $ASFmetadataLibraryObjectDataTypeLookup[$id] : 'invalid');1944 return (isset($lookup[$id]) ? $lookup[$id] : 'invalid'); 1951 1945 } 1952 1946 1953 1947 public function ASF_WMpicture(&$data) { … … 1964 1958 $offset = 0; 1965 1959 $WMpicture['image_type_id'] = getid3_lib::LittleEndian2Int(substr($data, $offset, 1)); 1966 1960 $offset += 1; 1967 $WMpicture['image_type'] = $this->WMpictureTypeLookup($WMpicture['image_type_id']);1961 $WMpicture['image_type'] = self::WMpictureTypeLookup($WMpicture['image_type_id']); 1968 1962 $WMpicture['image_size'] = getid3_lib::LittleEndian2Int(substr($data, $offset, 4)); 1969 1963 $offset += 4; 1970 1964 … … 2016 2010 return $string; 2017 2011 } 2018 2012 2019 } 2013 } 2014 No newline at end of file -
src/wp-includes/ID3/module.audio-video.flv.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 // // 7 8 // FLV module by Seth Kaufman <sethØwhirl-i-gig*com> // 8 9 // // … … 38 39 // * version 0.6.1 (30 May 2011) // 39 40 // prevent infinite loops in expGolombUe() // 40 41 // // 42 // * version 0.7.0 (16 Jul 2013) // 43 // handle GETID3_FLV_VIDEO_VP6FLV_ALPHA // 44 // improved AVCSequenceParameterSetReader::readData() // 45 // by Xander Schouwerwou <schouwerwouØgmail*com> // 46 // // 41 47 ///////////////////////////////////////////////////////////////// 42 48 // // 43 49 // module.audio-video.flv.php // … … 67 73 define('H264_PROFILE_HIGH444', 144); 68 74 define('H264_PROFILE_HIGH444_PREDICTIVE', 244); 69 75 70 class getid3_flv extends getid3_handler 71 { 76 class getid3_flv extends getid3_handler { 77 78 const magic = 'FLV'; 79 72 80 public $max_frames = 100000; // break out of the loop if too many frames have been scanned; only scan this many if meta frame does not contain useful duration 73 81 74 82 public function Analyze() { 75 83 $info = &$this->getid3->info; 76 84 77 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);85 $this->fseek($info['avdataoffset']); 78 86 79 87 $FLVdataLength = $info['avdataend'] - $info['avdataoffset']; 80 $FLVheader = fread($this->getid3->fp,5);88 $FLVheader = $this->fread(5); 81 89 82 90 $info['fileformat'] = 'flv'; 83 91 $info['flv']['header']['signature'] = substr($FLVheader, 0, 3); … … 84 92 $info['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1)); 85 93 $TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1)); 86 94 87 $magic = 'FLV'; 88 if ($info['flv']['header']['signature'] != $magic) { 89 $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['flv']['header']['signature']).'"'; 90 unset($info['flv']); 91 unset($info['fileformat']); 95 if ($info['flv']['header']['signature'] != self::magic) { 96 $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes(self::magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['flv']['header']['signature']).'"'; 97 unset($info['flv'], $info['fileformat']); 92 98 return false; 93 99 } 94 100 … … 95 101 $info['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04); 96 102 $info['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01); 97 103 98 $FrameSizeDataLength = getid3_lib::BigEndian2Int( fread($this->getid3->fp,4));104 $FrameSizeDataLength = getid3_lib::BigEndian2Int($this->fread(4)); 99 105 $FLVheaderFrameLength = 9; 100 106 if ($FrameSizeDataLength > $FLVheaderFrameLength) { 101 fseek($this->getid3->fp,$FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);107 $this->fseek($FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR); 102 108 } 103 109 $Duration = 0; 104 110 $found_video = false; … … 108 114 $tagParseCount = 0; 109 115 $info['flv']['framecount'] = array('total'=>0, 'audio'=>0, 'video'=>0); 110 116 $flv_framecount = &$info['flv']['framecount']; 111 while ((( ftell($this->getid3->fp) + 16) < $info['avdataend']) && (($tagParseCount++ <= $this->max_frames) || !$found_valid_meta_playtime)) {112 $ThisTagHeader = fread($this->getid3->fp,16);117 while ((($this->ftell() + 16) < $info['avdataend']) && (($tagParseCount++ <= $this->max_frames) || !$found_valid_meta_playtime)) { 118 $ThisTagHeader = $this->fread(16); 113 119 114 120 $PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4)); 115 121 $TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1)); … … 116 122 $DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3)); 117 123 $Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3)); 118 124 $LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1)); 119 $NextOffset = ftell($this->getid3->fp) - 1 + $DataLength;125 $NextOffset = $this->ftell() - 1 + $DataLength; 120 126 if ($Timestamp > $Duration) { 121 127 $Duration = $Timestamp; 122 128 } … … 140 146 $found_video = true; 141 147 $info['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07; 142 148 143 $FLVvideoHeader = fread($this->getid3->fp,11);149 $FLVvideoHeader = $this->fread(11); 144 150 145 151 if ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H264) { 146 152 // this code block contributed by: moysevichØgmail*com … … 160 166 //$spsSize = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 9, 2)); 161 167 $spsSize = getid3_lib::LittleEndian2Int(substr($FLVvideoHeader, 9, 2)); 162 168 // read the first SequenceParameterSet 163 $sps = fread($this->getid3->fp,$spsSize);169 $sps = $this->fread($spsSize); 164 170 if (strlen($sps) == $spsSize) { // make sure that whole SequenceParameterSet was red 165 171 $spsReader = new AVCSequenceParameterSetReader($sps); 166 172 $spsReader->readData(); … … 185 191 //$PictureSizeEnc <<= 1; 186 192 //$info['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8; 187 193 188 $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 2)); 189 $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2)); 190 $PictureSizeEnc['x'] >>= 7; 191 $PictureSizeEnc['y'] >>= 7; 194 $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 2)) >> 7; 195 $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2)) >> 7; 192 196 $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFF; 193 197 $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFF; 194 198 break; 195 199 196 200 case 1: 197 $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 3)); 198 $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 3)); 199 $PictureSizeEnc['x'] >>= 7; 200 $PictureSizeEnc['y'] >>= 7; 201 $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 3)) >> 7; 202 $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 3)) >> 7; 201 203 $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFFFF; 202 204 $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFFFF; 203 205 break; … … 233 235 break; 234 236 235 237 } 238 239 } elseif ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_VP6FLV_ALPHA) { 240 241 /* contributed by schouwerwouØgmail*com */ 242 if (!isset($info['video']['resolution_x'])) { // only when meta data isn't set 243 $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2)); 244 $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 2)); 245 $info['video']['resolution_x'] = ($PictureSizeEnc['x'] & 0xFF) << 3; 246 $info['video']['resolution_y'] = ($PictureSizeEnc['y'] & 0xFF) << 3; 247 } 248 /* end schouwerwouØgmail*com */ 249 236 250 } 237 $info['video']['pixel_aspect_ratio'] = $info['video']['resolution_x'] / $info['video']['resolution_y']; 251 if (!empty($info['video']['resolution_x']) && !empty($info['video']['resolution_y'])) { 252 $info['video']['pixel_aspect_ratio'] = $info['video']['resolution_x'] / $info['video']['resolution_y']; 253 } 238 254 } 239 255 break; 240 256 … … 242 258 case GETID3_FLV_TAG_META: 243 259 if (!$found_meta) { 244 260 $found_meta = true; 245 fseek($this->getid3->fp,-1, SEEK_CUR);246 $datachunk = fread($this->getid3->fp,$DataLength);261 $this->fseek(-1, SEEK_CUR); 262 $datachunk = $this->fread($DataLength); 247 263 $AMFstream = new AMFStream($datachunk); 248 264 $reader = new AMFReader($AMFstream); 249 265 $eventName = $reader->readData(); … … 279 295 // noop 280 296 break; 281 297 } 282 fseek($this->getid3->fp, $NextOffset, SEEK_SET);298 $this->fseek($NextOffset); 283 299 } 284 300 285 301 $info['playtime_seconds'] = $Duration / 1000; … … 288 304 } 289 305 290 306 if ($info['flv']['header']['hasAudio']) { 291 $info['audio']['codec'] = $this->FLVaudioFormat($info['flv']['audio']['audioFormat']);292 $info['audio']['sample_rate'] = $this->FLVaudioRate($info['flv']['audio']['audioRate']);293 $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info['flv']['audio']['audioSampleSize']);307 $info['audio']['codec'] = self::audioFormatLookup($info['flv']['audio']['audioFormat']); 308 $info['audio']['sample_rate'] = self::audioRateLookup($info['flv']['audio']['audioRate']); 309 $info['audio']['bits_per_sample'] = self::audioBitDepthLookup($info['flv']['audio']['audioSampleSize']); 294 310 295 311 $info['audio']['channels'] = $info['flv']['audio']['audioType'] + 1; // 0=mono,1=stereo 296 312 $info['audio']['lossless'] = ($info['flv']['audio']['audioFormat'] ? false : true); // 0=uncompressed … … 297 313 $info['audio']['dataformat'] = 'flv'; 298 314 } 299 315 if (!empty($info['flv']['header']['hasVideo'])) { 300 $info['video']['codec'] = $this->FLVvideoCodec($info['flv']['video']['videoCodec']);316 $info['video']['codec'] = self::videoCodecLookup($info['flv']['video']['videoCodec']); 301 317 $info['video']['dataformat'] = 'flv'; 302 318 $info['video']['lossless'] = false; 303 319 } … … 308 324 $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds']; 309 325 } 310 326 if (isset($info['flv']['meta']['onMetaData']['audiocodecid'])) { 311 $info['audio']['codec'] = $this->FLVaudioFormat($info['flv']['meta']['onMetaData']['audiocodecid']);327 $info['audio']['codec'] = self::audioFormatLookup($info['flv']['meta']['onMetaData']['audiocodecid']); 312 328 } 313 329 if (isset($info['flv']['meta']['onMetaData']['videocodecid'])) { 314 $info['video']['codec'] = $this->FLVvideoCodec($info['flv']['meta']['onMetaData']['videocodecid']);330 $info['video']['codec'] = self::videoCodecLookup($info['flv']['meta']['onMetaData']['videocodecid']); 315 331 } 316 332 return true; 317 333 } 318 334 319 335 320 public function FLVaudioFormat($id) {321 $FLVaudioFormat= array(336 public static function audioFormatLookup($id) { 337 static $lookup = array( 322 338 0 => 'Linear PCM, platform endian', 323 339 1 => 'ADPCM', 324 340 2 => 'mp3', … … 330 346 8 => 'G.711 mu-law logarithmic PCM', 331 347 9 => 'reserved', 332 348 10 => 'AAC', 333 11 => false, // unknown?349 11 => 'Speex', 334 350 12 => false, // unknown? 335 351 13 => false, // unknown? 336 352 14 => 'mp3 8kHz', 337 353 15 => 'Device-specific sound', 338 354 ); 339 return (isset($ FLVaudioFormat[$id]) ? $FLVaudioFormat[$id] : false);355 return (isset($lookup[$id]) ? $lookup[$id] : false); 340 356 } 341 357 342 public function FLVaudioRate($id) {343 $FLVaudioRate= array(358 public static function audioRateLookup($id) { 359 static $lookup = array( 344 360 0 => 5500, 345 361 1 => 11025, 346 362 2 => 22050, 347 363 3 => 44100, 348 364 ); 349 return (isset($ FLVaudioRate[$id]) ? $FLVaudioRate[$id] : false);365 return (isset($lookup[$id]) ? $lookup[$id] : false); 350 366 } 351 367 352 public function FLVaudioBitDepth($id) {353 $FLVaudioBitDepth= array(368 public static function audioBitDepthLookup($id) { 369 static $lookup = array( 354 370 0 => 8, 355 371 1 => 16, 356 372 ); 357 return (isset($ FLVaudioBitDepth[$id]) ? $FLVaudioBitDepth[$id] : false);373 return (isset($lookup[$id]) ? $lookup[$id] : false); 358 374 } 359 375 360 public function FLVvideoCodec($id) {361 $FLVvideoCodec= array(376 public static function videoCodecLookup($id) { 377 static $lookup = array( 362 378 GETID3_FLV_VIDEO_H263 => 'Sorenson H.263', 363 379 GETID3_FLV_VIDEO_SCREEN => 'Screen video', 364 380 GETID3_FLV_VIDEO_VP6FLV => 'On2 VP6', … … 366 382 GETID3_FLV_VIDEO_SCREENV2 => 'Screen video v2', 367 383 GETID3_FLV_VIDEO_H264 => 'Sorenson H.264', 368 384 ); 369 return (isset($ FLVvideoCodec[$id]) ? $FLVvideoCodec[$id] : false);385 return (isset($lookup[$id]) ? $lookup[$id] : false); 370 386 } 371 387 } 372 388 … … 374 390 public $bytes; 375 391 public $pos; 376 392 377 public function AMFStream(&$bytes) {393 public function __construct(&$bytes) { 378 394 $this->bytes =& $bytes; 379 395 $this->pos = 0; 380 396 } … … 457 473 class AMFReader { 458 474 public $stream; 459 475 460 public function AMFReader(&$stream) {476 public function __construct(&$stream) { 461 477 $this->stream =& $stream; 462 478 } 463 479 … … 619 635 public $width; 620 636 public $height; 621 637 622 public function AVCSequenceParameterSetReader($sps) {638 public function __construct($sps) { 623 639 $this->sps = $sps; 624 640 } 625 641 … … 626 642 public function readData() { 627 643 $this->skipBits(8); 628 644 $this->skipBits(8); 629 $profile = $this->getBits(8); // read profile 630 $this->skipBits(16); 631 $this->expGolombUe(); // read sps id 632 if (in_array($profile, array(H264_PROFILE_HIGH, H264_PROFILE_HIGH10, H264_PROFILE_HIGH422, H264_PROFILE_HIGH444, H264_PROFILE_HIGH444_PREDICTIVE))) { 633 if ($this->expGolombUe() == 3) { 634 $this->skipBits(1); 635 } 636 $this->expGolombUe(); 637 $this->expGolombUe(); 638 $this->skipBits(1); 639 if ($this->getBit()) { 640 for ($i = 0; $i < 8; $i++) { 641 if ($this->getBit()) { 642 $size = $i < 6 ? 16 : 64; 643 $lastScale = 8; 644 $nextScale = 8; 645 for ($j = 0; $j < $size; $j++) { 646 if ($nextScale != 0) { 647 $deltaScale = $this->expGolombUe(); 648 $nextScale = ($lastScale + $deltaScale + 256) % 256; 649 } 650 if ($nextScale != 0) { 651 $lastScale = $nextScale; 652 } 653 } 654 } 645 $profile = $this->getBits(8); // read profile 646 if ($profile > 0) { 647 $this->skipBits(8); 648 $level_idc = $this->getBits(8); // level_idc 649 $this->expGolombUe(); // seq_parameter_set_id // sps 650 $this->expGolombUe(); // log2_max_frame_num_minus4 651 $picOrderType = $this->expGolombUe(); // pic_order_cnt_type 652 if ($picOrderType == 0) { 653 $this->expGolombUe(); // log2_max_pic_order_cnt_lsb_minus4 654 } elseif ($picOrderType == 1) { 655 $this->skipBits(1); // delta_pic_order_always_zero_flag 656 $this->expGolombSe(); // offset_for_non_ref_pic 657 $this->expGolombSe(); // offset_for_top_to_bottom_field 658 $num_ref_frames_in_pic_order_cnt_cycle = $this->expGolombUe(); // num_ref_frames_in_pic_order_cnt_cycle 659 for ($i = 0; $i < $num_ref_frames_in_pic_order_cnt_cycle; $i++) { 660 $this->expGolombSe(); // offset_for_ref_frame[ i ] 655 661 } 656 662 } 657 } 658 $this->expGolombUe(); 659 $pocType = $this->expGolombUe(); 660 if ($pocType == 0) { 661 $this->expGolombUe(); 662 } elseif ($pocType == 1) { 663 $this->skipBits(1); 664 $this->expGolombSe(); 665 $this->expGolombSe(); 666 $pocCycleLength = $this->expGolombUe(); 667 for ($i = 0; $i < $pocCycleLength; $i++) { 668 $this->expGolombSe(); 663 $this->expGolombUe(); // num_ref_frames 664 $this->skipBits(1); // gaps_in_frame_num_value_allowed_flag 665 $pic_width_in_mbs_minus1 = $this->expGolombUe(); // pic_width_in_mbs_minus1 666 $pic_height_in_map_units_minus1 = $this->expGolombUe(); // pic_height_in_map_units_minus1 667 668 $frame_mbs_only_flag = $this->getBits(1); // frame_mbs_only_flag 669 if ($frame_mbs_only_flag == 0) { 670 $this->skipBits(1); // mb_adaptive_frame_field_flag 669 671 } 672 $this->skipBits(1); // direct_8x8_inference_flag 673 $frame_cropping_flag = $this->getBits(1); // frame_cropping_flag 674 675 $frame_crop_left_offset = 0; 676 $frame_crop_right_offset = 0; 677 $frame_crop_top_offset = 0; 678 $frame_crop_bottom_offset = 0; 679 680 if ($frame_cropping_flag) { 681 $frame_crop_left_offset = $this->expGolombUe(); // frame_crop_left_offset 682 $frame_crop_right_offset = $this->expGolombUe(); // frame_crop_right_offset 683 $frame_crop_top_offset = $this->expGolombUe(); // frame_crop_top_offset 684 $frame_crop_bottom_offset = $this->expGolombUe(); // frame_crop_bottom_offset 685 } 686 $this->skipBits(1); // vui_parameters_present_flag 687 // etc 688 689 $this->width = (($pic_width_in_mbs_minus1 + 1) * 16) - ($frame_crop_left_offset * 2) - ($frame_crop_right_offset * 2); 690 $this->height = ((2 - $frame_mbs_only_flag) * ($pic_height_in_map_units_minus1 + 1) * 16) - ($frame_crop_top_offset * 2) - ($frame_crop_bottom_offset * 2); 670 691 } 671 $this->expGolombUe();672 $this->skipBits(1);673 $this->width = ($this->expGolombUe() + 1) * 16;674 $heightMap = $this->expGolombUe() + 1;675 $this->height = (2 - $this->getBit()) * $heightMap * 16;676 692 } 677 693 678 694 public function skipBits($bits) { … … 726 742 public function getHeight() { 727 743 return $this->height; 728 744 } 729 } 745 } 746 No newline at end of file -
src/wp-includes/ID3/module.audio-video.matroska.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 281 282 282 283 switch ($trackarray['CodecID']) { 283 284 case 'V_MS/VFW/FOURCC': 284 if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) { 285 $this->warning('Unable to parse codec private data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio-video.riff.php"'); 286 break; 287 } 285 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true); 286 288 287 $parsed = getid3_riff::ParseBITMAPINFOHEADER($trackarray['CodecPrivate']); 289 288 $track_info['codec'] = getid3_riff::fourccLookup($parsed['fourcc']); 290 289 $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed; … … 335 334 case 'A_MPEG/L3': 336 335 case 'A_MPEG/L2': 337 336 case 'A_FLAC': 338 if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.'.($track_info['dataformat'] == 'mp2' ? 'mp3' : $track_info['dataformat']).'.php', __FILE__, false)) { 339 $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio.'.$track_info['dataformat'].'.php"'); 340 break; 341 } 337 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.'.($track_info['dataformat'] == 'mp2' ? 'mp3' : $track_info['dataformat']).'.php', __FILE__, true); 342 338 343 339 if (!isset($info['matroska']['track_data_offsets'][$trackarray['TrackNumber']])) { 344 340 $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because $info[matroska][track_data_offsets]['.$trackarray['TrackNumber'].'] not set'); … … 385 381 } 386 382 if (!empty($getid3_temp->info['warning'])) { 387 383 foreach ($getid3_temp->info['warning'] as $newerror) { 388 if ($track_info['dataformat'] == 'mp3' && preg_match('/^Probable truncated file: expecting \d+ bytes of audio data, only found \d+ \(short by \d+ bytes\)$/', $newerror)) {389 // LAME/Xing header is probably set, but audio data is chunked into Matroska file and near-impossible to verify if audio stream is complete, so ignore useless warning390 continue;391 }392 384 $this->warning($class.'() says: ['.$newerror.']'); 393 385 } 394 386 } … … 400 392 case 'A_AAC/MPEG2/LC/SBR': 401 393 case 'A_AAC/MPEG4/LC': 402 394 case 'A_AAC/MPEG4/LC/SBR': 403 $this->warning($trackarray['CodecID'].' audio data contains no header, audio/video bitrates can\'t be calculated');395 $this->warning($trackarray['CodecID'].' audio data contains no header, audio/video bitrates can\'t be calculated'); 404 396 break; 405 397 406 398 case 'A_VORBIS': … … 415 407 } 416 408 $vorbis_offset -= 1; 417 409 418 if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, false)) { 419 $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio.ogg.php"'); 420 break; 421 } 410 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, true); 422 411 423 412 // create temp instance 424 413 $getid3_temp = new getID3(); … … 455 444 break; 456 445 457 446 case 'A_MS/ACM': 458 if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) { 459 $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio-video.riff.php"'); 460 break; 461 } 447 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true); 462 448 463 449 $parsed = getid3_riff::parseWAVEFORMATex($trackarray['CodecPrivate']); 464 450 foreach ($parsed as $key => $value) { … … 515 501 switch ($top_element['id']) { 516 502 517 503 case EBML_ID_EBML: 518 $info['fileformat'] = 'matroska';519 504 $info['matroska']['header']['offset'] = $top_element['offset']; 520 505 $info['matroska']['header']['length'] = $top_element['length']; 521 506 … … 534 519 case EBML_ID_DOCTYPE: 535 520 $element_data['data'] = getid3_lib::trimNullByte($element_data['data']); 536 521 $info['matroska']['doctype'] = $element_data['data']; 522 $info['fileformat'] = $element_data['data']; 537 523 break; 538 524 539 525 default: … … 1526 1512 $CodecIDlist['V_MPEG4/ISO/AVC'] = 'h264'; 1527 1513 $CodecIDlist['V_MPEG4/ISO/SP'] = 'mpeg4'; 1528 1514 $CodecIDlist['V_VP8'] = 'vp8'; 1529 $CodecIDlist['V_MS/VFW/FOURCC'] = ' riff';1530 $CodecIDlist['A_MS/ACM'] = ' riff';1515 $CodecIDlist['V_MS/VFW/FOURCC'] = 'vcm'; // Microsoft (TM) Video Codec Manager (VCM) 1516 $CodecIDlist['A_MS/ACM'] = 'acm'; // Microsoft (TM) Audio Codec Manager (ACM) 1531 1517 } 1532 1518 return (isset($CodecIDlist[$codecid]) ? $CodecIDlist[$codecid] : $codecid); 1533 1519 } … … 1762 1748 return $info; 1763 1749 } 1764 1750 1765 } 1751 } 1752 No newline at end of file -
src/wp-includes/ID3/module.audio-video.quicktime.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 30 31 $info['quicktime']['hinting'] = false; 31 32 $info['quicktime']['controller'] = 'standard'; // may be overridden if 'ctyp' atom is present 32 33 33 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);34 $this->fseek($info['avdataoffset']); 34 35 35 36 $offset = 0; 36 37 $atomcounter = 0; … … 40 41 $info['error'][] = 'Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions'; 41 42 break; 42 43 } 43 fseek($this->getid3->fp, $offset, SEEK_SET);44 $AtomHeader = fread($this->getid3->fp,8);44 $this->fseek($offset); 45 $AtomHeader = $this->fread(8); 45 46 46 47 $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4)); 47 48 $atomname = substr($AtomHeader, 4, 4); … … 48 49 49 50 // 64-bit MOV patch by jlegateØktnc*com 50 51 if ($atomsize == 1) { 51 $atomsize = getid3_lib::BigEndian2Int( fread($this->getid3->fp,8));52 $atomsize = getid3_lib::BigEndian2Int($this->fread(8)); 52 53 } 53 54 54 55 $info['quicktime'][$atomname]['name'] = $atomname; … … 66 67 // to read user data atoms, you should allow for the terminating 0. 67 68 break; 68 69 } 69 switch ($atomname) { 70 case 'mdat': // Media DATa atom 71 // 'mdat' contains the actual data for the audio/video 72 if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) { 70 $atomHierarchy = array(); 71 $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread(min($atomsize, round($this->getid3->memory_limit / 2))), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms); 73 72 74 $info['avdataoffset'] = $info['quicktime'][$atomname]['offset'] + 8;75 $OldAVDataEnd = $info['avdataend'];76 $info['avdataend'] = $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];77 78 $getid3_temp = new getID3();79 $getid3_temp->openfile($this->getid3->filename);80 $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];81 $getid3_temp->info['avdataend'] = $info['avdataend'];82 $getid3_mp3 = new getid3_mp3($getid3_temp);83 if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode(fread($this->getid3->fp, 4)))) {84 $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);85 if (!empty($getid3_temp->info['warning'])) {86 foreach ($getid3_temp->info['warning'] as $value) {87 $info['warning'][] = $value;88 }89 }90 if (!empty($getid3_temp->info['mpeg'])) {91 $info['mpeg'] = $getid3_temp->info['mpeg'];92 if (isset($info['mpeg']['audio'])) {93 $info['audio']['dataformat'] = 'mp3';94 $info['audio']['codec'] = (!empty($info['mpeg']['audio']['encoder']) ? $info['mpeg']['audio']['encoder'] : (!empty($info['mpeg']['audio']['codec']) ? $info['mpeg']['audio']['codec'] : (!empty($info['mpeg']['audio']['LAME']) ? 'LAME' :'mp3')));95 $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];96 $info['audio']['channels'] = $info['mpeg']['audio']['channels'];97 $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];98 $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);99 $info['bitrate'] = $info['audio']['bitrate'];100 }101 }102 }103 unset($getid3_mp3, $getid3_temp);104 $info['avdataend'] = $OldAVDataEnd;105 unset($OldAVDataEnd);106 107 }108 break;109 110 case 'free': // FREE space atom111 case 'skip': // SKIP atom112 case 'wide': // 64-bit expansion placeholder atom113 // 'free', 'skip' and 'wide' are just padding, contains no useful data at all114 break;115 116 default:117 $atomHierarchy = array();118 $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($this->getid3->fp, $atomsize), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);119 break;120 }121 122 73 $offset += $atomsize; 123 74 $atomcounter++; 124 75 } … … 172 123 173 124 $info = &$this->getid3->info; 174 125 175 //$atom_parent = array_pop($atomHierarchy); 176 $atom_parent = end($atomHierarchy); // http://www.getid3.org/phpBB3/viewtopic.php?t=1717 126 $atom_parent = end($atomHierarchy); // not array_pop($atomHierarchy); see http://www.getid3.org/phpBB3/viewtopic.php?t=1717 177 127 array_push($atomHierarchy, $atomname); 178 128 $atom_structure['hierarchy'] = implode(' ', $atomHierarchy); 179 129 $atom_structure['name'] = $atomname; 180 130 $atom_structure['size'] = $atomsize; 181 131 $atom_structure['offset'] = $baseoffset; 182 //echo getid3_lib::PrintHexBytes(substr($atom_data, 0, 8)).'<br>';183 //echo getid3_lib::PrintHexBytes(substr($atom_data, 0, 8), false).'<br><br>';184 132 switch ($atomname) { 185 133 case 'moov': // MOVie container atom 186 134 case 'trak': // TRAcK container atom … … 200 148 break; 201 149 202 150 case 'ilst': // Item LiST container atom 203 $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); 204 205 // some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted 206 $allnumericnames = true; 207 foreach ($atom_structure['subatoms'] as $subatomarray) { 208 if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) { 209 $allnumericnames = false; 210 break; 211 } 212 } 213 if ($allnumericnames) { 214 $newData = array(); 151 if ($atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms)) { 152 // some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted 153 $allnumericnames = true; 215 154 foreach ($atom_structure['subatoms'] as $subatomarray) { 216 foreach ($subatomarray['subatoms'] as $newData_subatomarray) { 217 unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']); 218 $newData[$subatomarray['name']] = $newData_subatomarray; 155 if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) { 156 $allnumericnames = false; 219 157 break; 220 158 } 221 159 } 222 $atom_structure['data'] = $newData; 223 unset($atom_structure['subatoms']); 160 if ($allnumericnames) { 161 $newData = array(); 162 foreach ($atom_structure['subatoms'] as $subatomarray) { 163 foreach ($subatomarray['subatoms'] as $newData_subatomarray) { 164 unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']); 165 $newData[$subatomarray['name']] = $newData_subatomarray; 166 break; 167 } 168 } 169 $atom_structure['data'] = $newData; 170 unset($atom_structure['subatoms']); 171 } 224 172 } 225 173 break; 226 174 … … 308 256 case 'geID': 309 257 case 'plID': 310 258 case 'sfID': // iTunes store country 311 case '©alb': // ALBum312 case '©art': // ARTist313 case '©ART':314 case '©aut':315 case '©cmt': // CoMmenT316 case '©com': // COMposer317 case '©cpy':318 case '©day': // content created year319 case '©dir':320 case '©ed1':321 case '©ed2':322 case '©ed3':323 case '©ed4':324 case '©ed5':325 case '©ed6':326 case '©ed7':327 case '©ed8':328 case '©ed9':329 case '©enc':330 case '©fmt':331 case '©gen': // GENre332 case '©grp': // GRouPing333 case '©hst':334 case '©inf':335 case '©lyr': // LYRics336 case '©mak':337 case '©mod':338 case '©nam': // full NAMe339 case '©ope':340 case '©PRD':341 case '©prd':342 case '©prf':343 case '©req':344 case '©src':345 case '©swr':346 case '©too': // encoder347 case '©trk': // TRacK348 case '©url':349 case '©wrn':350 case '©wrt': // WRiTer259 case "\xA9".'alb': // ALBum 260 case "\xA9".'art': // ARTist 261 case "\xA9".'ART': 262 case "\xA9".'aut': 263 case "\xA9".'cmt': // CoMmenT 264 case "\xA9".'com': // COMposer 265 case "\xA9".'cpy': 266 case "\xA9".'day': // content created year 267 case "\xA9".'dir': 268 case "\xA9".'ed1': 269 case "\xA9".'ed2': 270 case "\xA9".'ed3': 271 case "\xA9".'ed4': 272 case "\xA9".'ed5': 273 case "\xA9".'ed6': 274 case "\xA9".'ed7': 275 case "\xA9".'ed8': 276 case "\xA9".'ed9': 277 case "\xA9".'enc': 278 case "\xA9".'fmt': 279 case "\xA9".'gen': // GENre 280 case "\xA9".'grp': // GRouPing 281 case "\xA9".'hst': 282 case "\xA9".'inf': 283 case "\xA9".'lyr': // LYRics 284 case "\xA9".'mak': 285 case "\xA9".'mod': 286 case "\xA9".'nam': // full NAMe 287 case "\xA9".'ope': 288 case "\xA9".'PRD': 289 case "\xA9".'prd': 290 case "\xA9".'prf': 291 case "\xA9".'req': 292 case "\xA9".'src': 293 case "\xA9".'swr': 294 case "\xA9".'too': // encoder 295 case "\xA9".'trk': // TRacK 296 case "\xA9".'url': 297 case "\xA9".'wrn': 298 case "\xA9".'wrt': // WRiTer 351 299 case '----': // itunes specific 352 300 if ($atom_parent == 'udta') { 353 301 // User data atom handler … … 370 318 $boxsmalltype = substr($atom_data, $atomoffset + 2, 2); 371 319 $boxsmalldata = substr($atom_data, $atomoffset + 4, $boxsmallsize); 372 320 if ($boxsmallsize <= 1) { 373 $info['warning'][] = 'Invalid QuickTime atom smallbox size "'.$boxsmallsize.'" in atom "'. $atomname.'" at offset: '.($atom_structure['offset'] + $atomoffset);321 $info['warning'][] = 'Invalid QuickTime atom smallbox size "'.$boxsmallsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset); 374 322 $atom_structure['data'] = null; 375 323 $atomoffset = strlen($atom_data); 376 324 break; … … 380 328 $atom_structure['data'] = $boxsmalldata; 381 329 break; 382 330 default: 383 $info['warning'][] = 'Unknown QuickTime smallbox type: "'. getid3_lib::PrintHexBytes($boxsmalltype).'"at offset '.$baseoffset;331 $info['warning'][] = 'Unknown QuickTime smallbox type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxsmalltype).'" ('.trim(getid3_lib::PrintHexBytes($boxsmalltype)).') at offset '.$baseoffset; 384 332 $atom_structure['data'] = $atom_data; 385 333 break; 386 334 } … … 392 340 $boxtype = substr($atom_data, $atomoffset + 4, 4); 393 341 $boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8); 394 342 if ($boxsize <= 1) { 395 $info['warning'][] = 'Invalid QuickTime atom box size "'.$boxsize.'" in atom "'. $atomname.'" at offset: '.($atom_structure['offset'] + $atomoffset);343 $info['warning'][] = 'Invalid QuickTime atom box size "'.$boxsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset); 396 344 $atom_structure['data'] = null; 397 345 $atomoffset = strlen($atom_data); 398 346 break; … … 409 357 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1)); 410 358 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3)); 411 359 switch ($atom_structure['flags_raw']) { 412 case 0:// data flag360 case 0: // data flag 413 361 case 21: // tmpo/cpil flag 414 362 switch ($atomname) { 415 363 case 'cpil': … … 460 408 } 461 409 break; 462 410 463 case 1:// text flag411 case 1: // text flag 464 412 case 13: // image flag 465 413 default: 466 414 $atom_structure['data'] = substr($boxdata, 8); 415 if ($atomname == 'covr') { 416 // not a foolproof check, but better than nothing 417 if (preg_match('#^\xFF\xD8\xFF#', $atom_structure['data'])) { 418 $atom_structure['image_mime'] = 'image/jpeg'; 419 } elseif (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $atom_structure['data'])) { 420 $atom_structure['image_mime'] = 'image/png'; 421 } elseif (preg_match('#^GIF#', $atom_structure['data'])) { 422 $atom_structure['image_mime'] = 'image/gif'; 423 } 424 } 467 425 break; 468 426 469 427 } … … 470 428 break; 471 429 472 430 default: 473 $info['warning'][] = 'Unknown QuickTime box type: "'. getid3_lib::PrintHexBytes($boxtype).'"at offset '.$baseoffset;431 $info['warning'][] = 'Unknown QuickTime box type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxtype).'" ('.trim(getid3_lib::PrintHexBytes($boxtype)).') at offset '.$baseoffset; 474 432 $atom_structure['data'] = $atom_data; 475 433 476 434 } … … 840 798 $sttsEntriesDataOffset = 8; 841 799 //$FrameRateCalculatorArray = array(); 842 800 $frames_count = 0; 843 for ($i = 0; $i < $atom_structure['number_entries']; $i++) { 801 802 $max_stts_entries_to_scan = min(floor($this->getid3->memory_limit / 10000), $atom_structure['number_entries']); 803 if ($max_stts_entries_to_scan < $atom_structure['number_entries']) { 804 $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($this->getid3->memory_limit / 1048576).'MB).'; 805 } 806 for ($i = 0; $i < $max_stts_entries_to_scan; $i++) { 844 807 $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4)); 845 808 $sttsEntriesDataOffset += 4; 846 809 $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4)); … … 1086 1049 case 'sync': // SYNChronization atom 1087 1050 case 'scpt': // tranSCriPT atom 1088 1051 case 'ssrc': // non-primary SouRCe atom 1089 for ($i = 0; $i < (strlen($atom_data) % 4); $i++) {1090 $atom_structure['track_id'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $i * 4, 4));1052 for ($i = 0; $i < strlen($atom_data); $i += 4) { 1053 @$atom_structure['track_id'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4)); 1091 1054 } 1092 1055 break; 1093 1056 … … 1260 1223 break; 1261 1224 1262 1225 case 'mdat': // Media DATa atom 1226 // 'mdat' contains the actual data for the audio/video, possibly also subtitles 1227 1228 /* 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 */ 1229 1230 // first, skip any 'wide' padding, and second 'mdat' header (with specified size of zero?) 1231 $mdat_offset = 0; 1232 while (true) { 1233 if (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x08".'wide') { 1234 $mdat_offset += 8; 1235 } elseif (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x00".'mdat') { 1236 $mdat_offset += 8; 1237 } else { 1238 break; 1239 } 1240 } 1241 1242 // check to see if it looks like chapter titles, in the form of unterminated strings with a leading 16-bit size field 1243 while (($chapter_string_length = getid3_lib::BigEndian2Int(substr($atom_data, $mdat_offset, 2))) 1244 && ($chapter_string_length < 1000) 1245 && ($chapter_string_length <= (strlen($atom_data) - $mdat_offset - 2)) 1246 && preg_match('#^[\x20-\xFF]+$#', substr($atom_data, $mdat_offset + 2, $chapter_string_length), $chapter_matches)) { 1247 $mdat_offset += (2 + $chapter_string_length); 1248 @$info['quicktime']['comments']['chapters'][] = $chapter_matches[0]; 1249 } 1250 1251 1252 1253 if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) { 1254 1255 $info['avdataoffset'] = $atom_structure['offset'] + 8; // $info['quicktime'][$atomname]['offset'] + 8; 1256 $OldAVDataEnd = $info['avdataend']; 1257 $info['avdataend'] = $atom_structure['offset'] + $atom_structure['size']; // $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size']; 1258 1259 $getid3_temp = new getID3(); 1260 $getid3_temp->openfile($this->getid3->filename); 1261 $getid3_temp->info['avdataoffset'] = $info['avdataoffset']; 1262 $getid3_temp->info['avdataend'] = $info['avdataend']; 1263 $getid3_mp3 = new getid3_mp3($getid3_temp); 1264 if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode($this->fread(4)))) { 1265 $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false); 1266 if (!empty($getid3_temp->info['warning'])) { 1267 foreach ($getid3_temp->info['warning'] as $value) { 1268 $info['warning'][] = $value; 1269 } 1270 } 1271 if (!empty($getid3_temp->info['mpeg'])) { 1272 $info['mpeg'] = $getid3_temp->info['mpeg']; 1273 if (isset($info['mpeg']['audio'])) { 1274 $info['audio']['dataformat'] = 'mp3'; 1275 $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'))); 1276 $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate']; 1277 $info['audio']['channels'] = $info['mpeg']['audio']['channels']; 1278 $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate']; 1279 $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']); 1280 $info['bitrate'] = $info['audio']['bitrate']; 1281 } 1282 } 1283 } 1284 unset($getid3_mp3, $getid3_temp); 1285 $info['avdataend'] = $OldAVDataEnd; 1286 unset($OldAVDataEnd); 1287 1288 } 1289 1290 unset($mdat_offset, $chapter_string_length, $chapter_matches); 1291 break; 1292 1263 1293 case 'free': // FREE space atom 1264 1294 case 'skip': // SKIP atom 1265 1295 case 'wide': // 64-bit expansion placeholder atom 1266 // 'mdat' data is too big to deal with, contains no useful metadata1267 1296 // 'free', 'skip' and 'wide' are just padding, contains no useful data at all 1268 1297 1269 1298 // When writing QuickTime files, it is sometimes necessary to update an atom's size. … … 1329 1358 //$atom_structure['data'] = $atom_data; 1330 1359 break; 1331 1360 1332 case '©xyz': // GPS latitude+longitude+altitude1361 case "\xA9".'xyz': // GPS latitude+longitude+altitude 1333 1362 $atom_structure['data'] = $atom_data; 1334 1363 if (preg_match('#([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)?/$#i', $atom_data, $matches)) { 1335 1364 @list($all, $latitude, $longitude, $altitude) = $matches; … … 1358 1387 $info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_data, 'description'=>$atom_structure['description']); 1359 1388 } 1360 1389 break; 1361 case 'NCHD': // MakerNoteVersion 1362 // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html 1363 $atom_structure['data'] = $atom_data; 1364 break; 1365 case 'NCTG': // NikonTags 1366 // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG 1390 case 'NCTG': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG 1367 1391 $atom_structure['data'] = $this->QuicktimeParseNikonNCTG($atom_data); 1368 1392 break; 1369 case 'NCDB': // NikonTags 1370 // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html 1393 case 'NCHD': // Nikon:MakerNoteVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html 1394 case 'NCDB': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html 1395 case 'CNCV': // Canon:CompressorVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html 1371 1396 $atom_structure['data'] = $atom_data; 1372 1397 break; 1373 1398 … … 1391 1416 break; 1392 1417 1393 1418 default: 1394 $info['warning'][] = 'Unknown QuickTime atom type: "'. $atomname.'" ('.trim(getid3_lib::PrintHexBytes($atomname)).') at offset '.$baseoffset;1419 $info['warning'][] = 'Unknown QuickTime atom type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" ('.trim(getid3_lib::PrintHexBytes($atomname)).') at offset '.$baseoffset; 1395 1420 $atom_structure['data'] = $atom_data; 1396 1421 break; 1397 1422 } … … 2086 2111 public function CopyToAppropriateCommentsSection($keyname, $data, $boxname='') { 2087 2112 static $handyatomtranslatorarray = array(); 2088 2113 if (empty($handyatomtranslatorarray)) { 2089 $handyatomtranslatorarray[ '©cpy'] = 'copyright';2090 $handyatomtranslatorarray[ '©day'] = 'creation_date'; // iTunes 4.02091 $handyatomtranslatorarray[ '©dir'] = 'director';2092 $handyatomtranslatorarray[ '©ed1'] = 'edit1';2093 $handyatomtranslatorarray[ '©ed2'] = 'edit2';2094 $handyatomtranslatorarray[ '©ed3'] = 'edit3';2095 $handyatomtranslatorarray[ '©ed4'] = 'edit4';2096 $handyatomtranslatorarray[ '©ed5'] = 'edit5';2097 $handyatomtranslatorarray[ '©ed6'] = 'edit6';2098 $handyatomtranslatorarray[ '©ed7'] = 'edit7';2099 $handyatomtranslatorarray[ '©ed8'] = 'edit8';2100 $handyatomtranslatorarray[ '©ed9'] = 'edit9';2101 $handyatomtranslatorarray[ '©fmt'] = 'format';2102 $handyatomtranslatorarray[ '©inf'] = 'information';2103 $handyatomtranslatorarray[ '©prd'] = 'producer';2104 $handyatomtranslatorarray[ '©prf'] = 'performers';2105 $handyatomtranslatorarray[ '©req'] = 'system_requirements';2106 $handyatomtranslatorarray[ '©src'] = 'source_credit';2107 $handyatomtranslatorarray[ '©wrt'] = 'writer';2114 $handyatomtranslatorarray["\xA9".'cpy'] = 'copyright'; 2115 $handyatomtranslatorarray["\xA9".'day'] = 'creation_date'; // iTunes 4.0 2116 $handyatomtranslatorarray["\xA9".'dir'] = 'director'; 2117 $handyatomtranslatorarray["\xA9".'ed1'] = 'edit1'; 2118 $handyatomtranslatorarray["\xA9".'ed2'] = 'edit2'; 2119 $handyatomtranslatorarray["\xA9".'ed3'] = 'edit3'; 2120 $handyatomtranslatorarray["\xA9".'ed4'] = 'edit4'; 2121 $handyatomtranslatorarray["\xA9".'ed5'] = 'edit5'; 2122 $handyatomtranslatorarray["\xA9".'ed6'] = 'edit6'; 2123 $handyatomtranslatorarray["\xA9".'ed7'] = 'edit7'; 2124 $handyatomtranslatorarray["\xA9".'ed8'] = 'edit8'; 2125 $handyatomtranslatorarray["\xA9".'ed9'] = 'edit9'; 2126 $handyatomtranslatorarray["\xA9".'fmt'] = 'format'; 2127 $handyatomtranslatorarray["\xA9".'inf'] = 'information'; 2128 $handyatomtranslatorarray["\xA9".'prd'] = 'producer'; 2129 $handyatomtranslatorarray["\xA9".'prf'] = 'performers'; 2130 $handyatomtranslatorarray["\xA9".'req'] = 'system_requirements'; 2131 $handyatomtranslatorarray["\xA9".'src'] = 'source_credit'; 2132 $handyatomtranslatorarray["\xA9".'wrt'] = 'writer'; 2108 2133 2109 2134 // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt 2110 $handyatomtranslatorarray[ '©nam'] = 'title'; // iTunes 4.02111 $handyatomtranslatorarray[ '©cmt'] = 'comment'; // iTunes 4.02112 $handyatomtranslatorarray[ '©wrn'] = 'warning';2113 $handyatomtranslatorarray[ '©hst'] = 'host_computer';2114 $handyatomtranslatorarray[ '©mak'] = 'make';2115 $handyatomtranslatorarray[ '©mod'] = 'model';2116 $handyatomtranslatorarray[ '©PRD'] = 'product';2117 $handyatomtranslatorarray[ '©swr'] = 'software';2118 $handyatomtranslatorarray[ '©aut'] = 'author';2119 $handyatomtranslatorarray[ '©ART'] = 'artist';2120 $handyatomtranslatorarray[ '©trk'] = 'track';2121 $handyatomtranslatorarray[ '©alb'] = 'album'; // iTunes 4.02122 $handyatomtranslatorarray[ '©com'] = 'comment';2123 $handyatomtranslatorarray[ '©gen'] = 'genre'; // iTunes 4.02124 $handyatomtranslatorarray[ '©ope'] = 'composer';2125 $handyatomtranslatorarray[ '©url'] = 'url';2126 $handyatomtranslatorarray[ '©enc'] = 'encoder';2135 $handyatomtranslatorarray["\xA9".'nam'] = 'title'; // iTunes 4.0 2136 $handyatomtranslatorarray["\xA9".'cmt'] = 'comment'; // iTunes 4.0 2137 $handyatomtranslatorarray["\xA9".'wrn'] = 'warning'; 2138 $handyatomtranslatorarray["\xA9".'hst'] = 'host_computer'; 2139 $handyatomtranslatorarray["\xA9".'mak'] = 'make'; 2140 $handyatomtranslatorarray["\xA9".'mod'] = 'model'; 2141 $handyatomtranslatorarray["\xA9".'PRD'] = 'product'; 2142 $handyatomtranslatorarray["\xA9".'swr'] = 'software'; 2143 $handyatomtranslatorarray["\xA9".'aut'] = 'author'; 2144 $handyatomtranslatorarray["\xA9".'ART'] = 'artist'; 2145 $handyatomtranslatorarray["\xA9".'trk'] = 'track'; 2146 $handyatomtranslatorarray["\xA9".'alb'] = 'album'; // iTunes 4.0 2147 $handyatomtranslatorarray["\xA9".'com'] = 'comment'; 2148 $handyatomtranslatorarray["\xA9".'gen'] = 'genre'; // iTunes 4.0 2149 $handyatomtranslatorarray["\xA9".'ope'] = 'composer'; 2150 $handyatomtranslatorarray["\xA9".'url'] = 'url'; 2151 $handyatomtranslatorarray["\xA9".'enc'] = 'encoder'; 2127 2152 2128 2153 // http://atomicparsley.sourceforge.net/mpeg-4files.html 2129 $handyatomtranslatorarray[ '©art'] = 'artist'; // iTunes 4.02154 $handyatomtranslatorarray["\xA9".'art'] = 'artist'; // iTunes 4.0 2130 2155 $handyatomtranslatorarray['aART'] = 'album_artist'; 2131 2156 $handyatomtranslatorarray['trkn'] = 'track_number'; // iTunes 4.0 2132 2157 $handyatomtranslatorarray['disk'] = 'disc_number'; // iTunes 4.0 2133 2158 $handyatomtranslatorarray['gnre'] = 'genre'; // iTunes 4.0 2134 $handyatomtranslatorarray[ '©too'] = 'encoder'; // iTunes 4.02159 $handyatomtranslatorarray["\xA9".'too'] = 'encoder'; // iTunes 4.0 2135 2160 $handyatomtranslatorarray['tmpo'] = 'bpm'; // iTunes 4.0 2136 2161 $handyatomtranslatorarray['cprt'] = 'copyright'; // iTunes 4.0? 2137 2162 $handyatomtranslatorarray['cpil'] = 'compilation'; // iTunes 4.0 2138 2163 $handyatomtranslatorarray['covr'] = 'picture'; // iTunes 4.0 2139 2164 $handyatomtranslatorarray['rtng'] = 'rating'; // iTunes 4.0 2140 $handyatomtranslatorarray[ '©grp'] = 'grouping'; // iTunes 4.22165 $handyatomtranslatorarray["\xA9".'grp'] = 'grouping'; // iTunes 4.2 2141 2166 $handyatomtranslatorarray['stik'] = 'stik'; // iTunes 4.9 2142 2167 $handyatomtranslatorarray['pcst'] = 'podcast'; // iTunes 4.9 2143 2168 $handyatomtranslatorarray['catg'] = 'category'; // iTunes 4.9 … … 2145 2170 $handyatomtranslatorarray['purl'] = 'podcast_url'; // iTunes 4.9 2146 2171 $handyatomtranslatorarray['egid'] = 'episode_guid'; // iTunes 4.9 2147 2172 $handyatomtranslatorarray['desc'] = 'description'; // iTunes 5.0 2148 $handyatomtranslatorarray[ '©lyr'] = 'lyrics'; // iTunes 5.02173 $handyatomtranslatorarray["\xA9".'lyr'] = 'lyrics'; // iTunes 5.0 2149 2174 $handyatomtranslatorarray['tvnn'] = 'tv_network_name'; // iTunes 6.0 2150 2175 $handyatomtranslatorarray['tvsh'] = 'tv_show_name'; // iTunes 6.0 2151 2176 $handyatomtranslatorarray['tvsn'] = 'tv_season'; // iTunes 6.0 … … 2218 2243 return substr($pascalstring, 1); 2219 2244 } 2220 2245 2221 } 2246 } 2247 No newline at end of file -
src/wp-includes/ID3/module.audio-video.riff.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 26 27 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, true); 27 28 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.dts.php', __FILE__, true); 28 29 29 class getid3_riff extends getid3_handler 30 { 30 class getid3_riff extends getid3_handler { 31 31 32 protected $container = 'riff'; // default 33 32 34 public function Analyze() { 33 35 $info = &$this->getid3->info; 34 36 … … 58 60 switch ($RIFFtype) { 59 61 60 62 case 'FORM': // AIFF, AIFC 61 $info['fileformat'] = 'aiff'; 63 //$info['fileformat'] = 'aiff'; 64 $this->container = 'aiff'; 62 65 $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize); 63 66 $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4)); 64 67 break; … … 66 69 case 'RIFF': // AVI, WAV, etc 67 70 case 'SDSS': // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com) 68 71 case 'RMP3': // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s 69 $info['fileformat'] = 'riff'; 72 //$info['fileformat'] = 'riff'; 73 $this->container = 'riff'; 70 74 $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize); 71 75 if ($RIFFsubtype == 'RMP3') { 72 76 // RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s 73 77 $RIFFsubtype = 'WAVE'; 74 78 } 75 $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4)); 79 if ($RIFFsubtype != 'AMV ') { 80 // AMV files are RIFF-AVI files with parts of the spec deliberately broken, such as chunk size fields hardcoded to zero (because players known in hardware that these fields are always a certain size 81 // Handled separately in ParseRIFFAMV() 82 $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4)); 83 } 76 84 if (($info['avdataend'] - $info['filesize']) == 1) { 77 85 // LiteWave appears to incorrectly *not* pad actual output file 78 86 // to nearest WORD boundary so may appear to be short by one … … 110 118 $nextRIFFoffset = $chunkdata['offset'] + $chunkdata['size']; 111 119 112 120 switch ($nextRIFFheaderID) { 113 114 121 case 'RIFF': 115 122 $chunkdata['chunks'] = $this->ParseRIFF($chunkdata['offset'] + 4, $nextRIFFoffset); 116 117 123 if (!isset($thisfile_riff[$nextRIFFtype])) { 118 124 $thisfile_riff[$nextRIFFtype] = array(); 119 125 } … … 120 126 $thisfile_riff[$nextRIFFtype][] = $chunkdata; 121 127 break; 122 128 129 case 'AMV ': 130 unset($info['riff']); 131 $info['amv'] = $this->ParseRIFFAMV($chunkdata['offset'] + 4, $nextRIFFoffset); 132 break; 133 123 134 case 'JUNK': 124 135 // ignore 125 136 $thisfile_riff[$nextRIFFheaderID][] = $chunkdata; … … 152 163 153 164 default: 154 165 $this->error('Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "'.$RIFFsubtype.'" instead'); 155 unset($info['fileformat']);166 //unset($info['fileformat']); 156 167 return false; 157 168 } 158 169 159 170 $streamindex = 0; 160 171 switch ($RIFFsubtype) { 172 173 // http://en.wikipedia.org/wiki/Wav 161 174 case 'WAVE': 175 $info['fileformat'] = 'wav'; 176 162 177 if (empty($thisfile_audio['bitrate_mode'])) { 163 178 $thisfile_audio['bitrate_mode'] = 'cbr'; 164 179 } … … 588 603 } 589 604 break; 590 605 606 // http://en.wikipedia.org/wiki/Audio_Video_Interleave 591 607 case 'AVI ': 608 $info['fileformat'] = 'avi'; 609 $info['mime_type'] = 'video/avi'; 610 592 611 $thisfile_video['bitrate_mode'] = 'vbr'; // maybe not, but probably 593 612 $thisfile_video['dataformat'] = 'avi'; 594 $info['mime_type'] = 'video/avi';595 613 596 614 if (isset($thisfile_riff[$RIFFsubtype]['movi']['offset'])) { 597 615 $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['movi']['offset'] + 8; … … 825 843 826 844 switch ($strhfccType) { 827 845 case 'vids': 828 $thisfile_riff_raw_strf_strhfccType_streamindex = self::ParseBITMAPINFOHEADER(substr($strfData, 0, 40), ($ info['fileformat']== 'riff'));846 $thisfile_riff_raw_strf_strhfccType_streamindex = self::ParseBITMAPINFOHEADER(substr($strfData, 0, 40), ($this->container == 'riff')); 829 847 $thisfile_video['bits_per_sample'] = $thisfile_riff_raw_strf_strhfccType_streamindex['biBitCount']; 830 848 831 849 if ($thisfile_riff_video_current['codec'] == 'DV') { … … 875 893 } 876 894 break; 877 895 896 897 case 'AMV ': 898 $info['fileformat'] = 'amv'; 899 $info['mime_type'] = 'video/amv'; 900 901 $thisfile_video['bitrate_mode'] = 'vbr'; // it's MJPEG, presumably contant-quality encoding, thereby VBR 902 $thisfile_video['dataformat'] = 'mjpeg'; 903 $thisfile_video['codec'] = 'mjpeg'; 904 $thisfile_video['lossless'] = false; 905 $thisfile_video['bits_per_sample'] = 24; 906 907 $thisfile_audio['dataformat'] = 'adpcm'; 908 $thisfile_audio['lossless'] = false; 909 break; 910 911 912 // http://en.wikipedia.org/wiki/CD-DA 878 913 case 'CDDA': 879 $thisfile_audio['bitrate_mode'] = 'cbr'; 914 $info['fileformat'] = 'cda'; 915 unset($info['mime_type']); 916 880 917 $thisfile_audio_dataformat = 'cda'; 881 $thisfile_audio['lossless'] = true;882 unset($info['mime_type']);883 918 884 919 $info['avdataoffset'] = 44; 885 920 … … 901 936 $info['playtime_seconds'] = $thisfile_riff_CDDA_fmt_0['playtime_seconds']; 902 937 903 938 // hardcoded data for CD-audio 939 $thisfile_audio['lossless'] = true; 904 940 $thisfile_audio['sample_rate'] = 44100; 905 941 $thisfile_audio['channels'] = 2; 906 942 $thisfile_audio['bits_per_sample'] = 16; … … 909 945 } 910 946 break; 911 947 912 948 // http://en.wikipedia.org/wiki/AIFF 913 949 case 'AIFF': 914 950 case 'AIFC': 951 $info['fileformat'] = 'aiff'; 952 $info['mime_type'] = 'audio/x-aiff'; 953 915 954 $thisfile_audio['bitrate_mode'] = 'cbr'; 916 955 $thisfile_audio_dataformat = 'aiff'; 917 956 $thisfile_audio['lossless'] = true; 918 $info['mime_type'] = 'audio/x-aiff';919 957 920 958 if (isset($thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'])) { 921 959 $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'] + 8; … … 1028 1066 */ 1029 1067 break; 1030 1068 1069 // http://en.wikipedia.org/wiki/8SVX 1031 1070 case '8SVX': 1071 $info['fileformat'] = '8svx'; 1072 $info['mime_type'] = 'audio/8svx'; 1073 1032 1074 $thisfile_audio['bitrate_mode'] = 'cbr'; 1033 1075 $thisfile_audio_dataformat = '8svx'; 1034 1076 $thisfile_audio['bits_per_sample'] = 8; 1035 1077 $thisfile_audio['channels'] = 1; // overridden below, if need be 1036 $info['mime_type'] = 'audio/x-aiff';1037 1078 1038 1079 if (isset($thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'])) { 1039 1080 $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'] + 8; … … 1108 1149 } 1109 1150 break; 1110 1151 1152 case 'CDXA': 1153 $info['fileformat'] = 'vcd'; // Asume Video CD 1154 $info['mime_type'] = 'video/mpeg'; 1111 1155 1112 case 'CDXA':1113 $info['mime_type'] = 'video/mpeg';1114 1156 if (!empty($thisfile_riff['CDXA']['data'][0]['size'])) { 1115 if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.mpeg.php', __FILE__, false)) { 1116 $getid3_temp = new getID3(); 1117 $getid3_temp->openfile($this->getid3->filename); 1118 $getid3_mpeg = new getid3_mpeg($getid3_temp); 1119 $getid3_mpeg->Analyze(); 1120 if (empty($getid3_temp->info['error'])) { 1121 $info['audio'] = $getid3_temp->info['audio']; 1122 $info['video'] = $getid3_temp->info['video']; 1123 $info['mpeg'] = $getid3_temp->info['mpeg']; 1124 $info['warning'] = $getid3_temp->info['warning']; 1125 } 1126 unset($getid3_temp, $getid3_mpeg); 1157 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.mpeg.php', __FILE__, true); 1158 1159 $getid3_temp = new getID3(); 1160 $getid3_temp->openfile($this->getid3->filename); 1161 $getid3_mpeg = new getid3_mpeg($getid3_temp); 1162 $getid3_mpeg->Analyze(); 1163 if (empty($getid3_temp->info['error'])) { 1164 $info['audio'] = $getid3_temp->info['audio']; 1165 $info['video'] = $getid3_temp->info['video']; 1166 $info['mpeg'] = $getid3_temp->info['mpeg']; 1167 $info['warning'] = $getid3_temp->info['warning']; 1127 1168 } 1169 unset($getid3_temp, $getid3_mpeg); 1128 1170 } 1129 1171 break; 1130 1172 … … 1131 1173 1132 1174 default: 1133 1175 $info['error'][] = 'Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "'.$RIFFsubtype.'" instead'; 1134 unset($info['fileformat']); 1135 break; 1176 //unset($info['fileformat']); 1136 1177 } 1137 1178 1138 1179 switch ($RIFFsubtype) { … … 1150 1191 1151 1192 if (isset($thisfile_riff[$RIFFsubtype]['id3 '])) { 1152 1193 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true); 1194 1153 1195 $getid3_temp = new getID3(); 1154 1196 $getid3_temp->openfile($this->getid3->filename); 1155 1197 $getid3_id3v2 = new getid3_id3v2($getid3_temp); … … 1278 1320 return true; 1279 1321 } 1280 1322 1323 public function ParseRIFFAMV($startoffset, $maxoffset) { 1324 // AMV files are RIFF-AVI files with parts of the spec deliberately broken, such as chunk size fields hardcoded to zero (because players known in hardware that these fields are always a certain size 1325 1326 // https://code.google.com/p/amv-codec-tools/wiki/AmvDocumentation 1327 //typedef struct _amvmainheader { 1328 //FOURCC fcc; // 'amvh' 1329 //DWORD cb; 1330 //DWORD dwMicroSecPerFrame; 1331 //BYTE reserve[28]; 1332 //DWORD dwWidth; 1333 //DWORD dwHeight; 1334 //DWORD dwSpeed; 1335 //DWORD reserve0; 1336 //DWORD reserve1; 1337 //BYTE bTimeSec; 1338 //BYTE bTimeMin; 1339 //WORD wTimeHour; 1340 //} AMVMAINHEADER; 1341 1342 $info = &$this->getid3->info; 1343 $RIFFchunk = false; 1344 1345 try { 1346 1347 $this->fseek($startoffset); 1348 $maxoffset = min($maxoffset, $info['avdataend']); 1349 $AMVheader = $this->fread(284); 1350 if (substr($AMVheader, 0, 8) != 'hdrlamvh') { 1351 throw new Exception('expecting "hdrlamv" at offset '.($startoffset + 0).', found "'.substr($AMVheader, 0, 8).'"'); 1352 } 1353 if (substr($AMVheader, 8, 4) != "\x38\x00\x00\x00") { // "amvh" chunk size, hardcoded to 0x38 = 56 bytes 1354 throw new Exception('expecting "0x38000000" at offset '.($startoffset + 8).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 8, 4)).'"'); 1355 } 1356 $RIFFchunk = array(); 1357 $RIFFchunk['amvh']['us_per_frame'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 12, 4)); 1358 $RIFFchunk['amvh']['reserved28'] = substr($AMVheader, 16, 28); // null? reserved? 1359 $RIFFchunk['amvh']['resolution_x'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 44, 4)); 1360 $RIFFchunk['amvh']['resolution_y'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 48, 4)); 1361 $RIFFchunk['amvh']['frame_rate_int'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 52, 4)); 1362 $RIFFchunk['amvh']['reserved0'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 56, 4)); // 1? reserved? 1363 $RIFFchunk['amvh']['reserved1'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 60, 4)); // 0? reserved? 1364 $RIFFchunk['amvh']['runtime_sec'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 64, 1)); 1365 $RIFFchunk['amvh']['runtime_min'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 65, 1)); 1366 $RIFFchunk['amvh']['runtime_hrs'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 66, 2)); 1367 1368 $info['video']['frame_rate'] = 1000000 / $RIFFchunk['amvh']['us_per_frame']; 1369 $info['video']['resolution_x'] = $RIFFchunk['amvh']['resolution_x']; 1370 $info['video']['resolution_y'] = $RIFFchunk['amvh']['resolution_y']; 1371 $info['playtime_seconds'] = ($RIFFchunk['amvh']['runtime_hrs'] * 3600) + ($RIFFchunk['amvh']['runtime_min'] * 60) + $RIFFchunk['amvh']['runtime_sec']; 1372 1373 // the rest is all hardcoded(?) and does not appear to be useful until you get to audio info at offset 256, even then everything is probably hardcoded 1374 1375 if (substr($AMVheader, 68, 20) != 'LIST'."\x00\x00\x00\x00".'strlstrh'."\x38\x00\x00\x00") { 1376 throw new Exception('expecting "LIST<0x00000000>strlstrh<0x38000000>" at offset '.($startoffset + 68).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 68, 20)).'"'); 1377 } 1378 // followed by 56 bytes of null: substr($AMVheader, 88, 56) -> 144 1379 if (substr($AMVheader, 144, 8) != 'strf'."\x24\x00\x00\x00") { 1380 throw new Exception('expecting "strf<0x24000000>" at offset '.($startoffset + 144).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 144, 8)).'"'); 1381 } 1382 // followed by 36 bytes of null: substr($AMVheader, 144, 36) -> 180 1383 1384 if (substr($AMVheader, 188, 20) != 'LIST'."\x00\x00\x00\x00".'strlstrh'."\x30\x00\x00\x00") { 1385 throw new Exception('expecting "LIST<0x00000000>strlstrh<0x30000000>" at offset '.($startoffset + 188).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 188, 20)).'"'); 1386 } 1387 // followed by 48 bytes of null: substr($AMVheader, 208, 48) -> 256 1388 if (substr($AMVheader, 256, 8) != 'strf'."\x14\x00\x00\x00") { 1389 throw new Exception('expecting "strf<0x14000000>" at offset '.($startoffset + 256).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 256, 8)).'"'); 1390 } 1391 // followed by 20 bytes of a modified WAVEFORMATEX: 1392 // typedef struct { 1393 // WORD wFormatTag; //(Fixme: this is equal to PCM's 0x01 format code) 1394 // WORD nChannels; //(Fixme: this is always 1) 1395 // DWORD nSamplesPerSec; //(Fixme: for all known sample files this is equal to 22050) 1396 // DWORD nAvgBytesPerSec; //(Fixme: for all known sample files this is equal to 44100) 1397 // WORD nBlockAlign; //(Fixme: this seems to be 2 in AMV files, is this correct ?) 1398 // WORD wBitsPerSample; //(Fixme: this seems to be 16 in AMV files instead of the expected 4) 1399 // WORD cbSize; //(Fixme: this seems to be 0 in AMV files) 1400 // WORD reserved; 1401 // } WAVEFORMATEX; 1402 $RIFFchunk['strf']['wformattag'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 264, 2)); 1403 $RIFFchunk['strf']['nchannels'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 266, 2)); 1404 $RIFFchunk['strf']['nsamplespersec'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 268, 4)); 1405 $RIFFchunk['strf']['navgbytespersec'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 272, 4)); 1406 $RIFFchunk['strf']['nblockalign'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 276, 2)); 1407 $RIFFchunk['strf']['wbitspersample'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 278, 2)); 1408 $RIFFchunk['strf']['cbsize'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 280, 2)); 1409 $RIFFchunk['strf']['reserved'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 282, 2)); 1410 1411 1412 $info['audio']['lossless'] = false; 1413 $info['audio']['sample_rate'] = $RIFFchunk['strf']['nsamplespersec']; 1414 $info['audio']['channels'] = $RIFFchunk['strf']['nchannels']; 1415 $info['audio']['bits_per_sample'] = $RIFFchunk['strf']['wbitspersample']; 1416 $info['audio']['bitrate'] = $info['audio']['sample_rate'] * $info['audio']['channels'] * $info['audio']['bits_per_sample']; 1417 $info['audio']['bitrate_mode'] = 'cbr'; 1418 1419 1420 } catch (getid3_exception $e) { 1421 if ($e->getCode() == 10) { 1422 $this->warning('RIFFAMV parser: '.$e->getMessage()); 1423 } else { 1424 throw $e; 1425 } 1426 } 1427 1428 return $RIFFchunk; 1429 } 1430 1431 1281 1432 public function ParseRIFF($startoffset, $maxoffset) { 1282 1433 $info = &$this->getid3->info; 1283 1434 … … 1329 1480 $getid3_temp->openfile($this->getid3->filename); 1330 1481 $getid3_temp->info['avdataoffset'] = $this->ftell() - 4; 1331 1482 $getid3_temp->info['avdataend'] = $this->ftell() + $AudioChunkSize; 1332 $getid3_mp3 = new getid3_mp3($getid3_temp );1483 $getid3_mp3 = new getid3_mp3($getid3_temp, __CLASS__); 1333 1484 $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false); 1334 1485 if (isset($getid3_temp->info['mpeg']['audio'])) { 1335 1486 $info['mpeg']['audio'] = $getid3_temp->info['mpeg']['audio']; … … 1412 1563 $getid3_temp->openfile($this->getid3->filename); 1413 1564 $getid3_temp->info['avdataoffset'] = $info['avdataoffset']; 1414 1565 $getid3_temp->info['avdataend'] = $info['avdataend']; 1415 $getid3_mp3 = new getid3_mp3($getid3_temp );1566 $getid3_mp3 = new getid3_mp3($getid3_temp, __CLASS__); 1416 1567 $getid3_mp3->getOnlyMPEGaudioInfo($info['avdataoffset'], false); 1417 1568 if (empty($getid3_temp->info['error'])) { 1418 1569 $info['audio'] = $getid3_temp->info['audio']; … … 2426 2577 } 2427 2578 2428 2579 private function EitherEndian2Int($byteword, $signed=false) { 2429 if ($this-> getid3->info['fileformat']== 'riff') {2580 if ($this->container == 'riff') { 2430 2581 return getid3_lib::LittleEndian2Int($byteword, $signed); 2431 2582 } 2432 2583 return getid3_lib::BigEndian2Int($byteword, false, $signed); 2433 2584 } 2434 2585 2435 } 2586 } 2587 No newline at end of file -
src/wp-includes/ID3/module.audio.ac3.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 470 471 } 471 472 472 473 473 } 474 } 475 No newline at end of file -
src/wp-includes/ID3/module.audio.dts.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 287 288 return false; 288 289 } 289 290 290 } 291 } 292 No newline at end of file -
src/wp-includes/ID3/module.audio.flac.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 439 440 return (isset($lookup[$type_id]) ? $lookup[$type_id] : 'reserved'); 440 441 } 441 442 442 } 443 } 444 No newline at end of file -
src/wp-includes/ID3/module.audio.mp3.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 95 96 96 97 // Not sure what version of LAME this is - look in padding of last frame for longer version string 97 98 $PossibleLAMEversionStringOffset = $info['avdataend'] - $PossiblyLongerLAMEversion_FrameLength; 98 fseek($this->getid3->fp,$PossibleLAMEversionStringOffset);99 $PossiblyLongerLAMEversion_Data = fread($this->getid3->fp,$PossiblyLongerLAMEversion_FrameLength);99 $this->fseek($PossibleLAMEversionStringOffset); 100 $PossiblyLongerLAMEversion_Data = $this->fread($PossiblyLongerLAMEversion_FrameLength); 100 101 switch (substr($CurrentDataLAMEversionString, -1)) { 101 102 case 'a': 102 103 case 'b': … … 422 423 $MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray(); 423 424 } 424 425 425 if ( fseek($this->getid3->fp, $offset, SEEK_SET) != 0) {426 if ($this->fseek($offset) != 0) { 426 427 $info['error'][] = 'decodeMPEGaudioHeader() failed to seek to next offset at '.$offset; 427 428 return false; 428 429 } 429 //$headerstring = fread($this->getid3->fp,1441); // worst-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame430 $headerstring = fread($this->getid3->fp,226); // LAME header at offset 36 + 190 bytes of Xing/LAME data430 //$headerstring = $this->fread(1441); // worst-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame 431 $headerstring = $this->fread(226); // LAME header at offset 36 + 190 bytes of Xing/LAME data 431 432 432 433 // MP3 audio frame structure: 433 434 // $aa $aa $aa $aa [$bb $bb] $cc... … … 890 891 891 892 if (($ExpectedNumberOfAudioBytes > 0) && ($ExpectedNumberOfAudioBytes != ($info['avdataend'] - $info['avdataoffset']))) { 892 893 if ($ExpectedNumberOfAudioBytes > ($info['avdataend'] - $info['avdataoffset'])) { 893 if ( isset($info['fileformat']) && ($info['fileformat'] =='riff')) {894 if ($this->isDependencyFor('matroska') || $this->isDependencyFor('riff')) { 894 895 // ignore, audio data is broken into chunks so will always be data "missing" 895 } elseif (($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])) == 1) {896 $info['warning'][] = 'Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)';897 } else {898 $info['warning'][] = 'Probable truncated file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, only found '.($info['avdataend'] - $info['avdataoffset']).' (short by '.($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])).' bytes)';899 896 } 897 elseif (($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])) == 1) { 898 $this->warning('Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)'); 899 } 900 else { 901 $this->warning('Probable truncated file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, only found '.($info['avdataend'] - $info['avdataoffset']).' (short by '.($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])).' bytes)'); 902 } 900 903 } else { 901 904 if ((($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes) == 1) { 902 // $prenullbytefileoffset = ftell($this->getid3->fp);903 // fseek($this->getid3->fp, $info['avdataend'], SEEK_SET);904 // $PossibleNullByte = fread($this->getid3->fp,1);905 // fseek($this->getid3->fp, $prenullbytefileoffset, SEEK_SET);905 // $prenullbytefileoffset = $this->ftell(); 906 // $this->fseek($info['avdataend']); 907 // $PossibleNullByte = $this->fread(1); 908 // $this->fseek($prenullbytefileoffset); 906 909 // if ($PossibleNullByte === "\x00") { 907 910 $info['avdataend']--; 908 911 // $info['warning'][] = 'Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored'; … … 1118 1121 public function FreeFormatFrameLength($offset, $deepscan=false) { 1119 1122 $info = &$this->getid3->info; 1120 1123 1121 fseek($this->getid3->fp, $offset, SEEK_SET);1122 $MPEGaudioData = fread($this->getid3->fp,32768);1124 $this->fseek($offset); 1125 $MPEGaudioData = $this->fread(32768); 1123 1126 1124 1127 $SyncPattern1 = substr($MPEGaudioData, 0, 4); 1125 1128 // may be different pattern due to padding … … 1166 1169 $ActualFrameLengthValues = array(); 1167 1170 $nextoffset = $offset + $framelength; 1168 1171 while ($nextoffset < ($info['avdataend'] - 6)) { 1169 fseek($this->getid3->fp, $nextoffset - 1, SEEK_SET);1170 $NextSyncPattern = fread($this->getid3->fp,6);1172 $this->fseek($nextoffset - 1); 1173 $NextSyncPattern = $this->fread(6); 1171 1174 if ((substr($NextSyncPattern, 1, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 1, strlen($SyncPattern2)) == $SyncPattern2)) { 1172 1175 // good - found where expected 1173 1176 $ActualFrameLengthValues[] = $framelength; … … 1215 1218 $Distribution['padding'] = array(); 1216 1219 1217 1220 $info = &$this->getid3->info; 1218 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);1221 $this->fseek($info['avdataoffset']); 1219 1222 1220 1223 $max_frames_scan = 5000; 1221 1224 $frames_scanned = 0; 1222 1225 1223 1226 $previousvalidframe = $info['avdataoffset']; 1224 while ( ftell($this->getid3->fp) < $info['avdataend']) {1227 while ($this->ftell() < $info['avdataend']) { 1225 1228 set_time_limit(30); 1226 $head4 = fread($this->getid3->fp,4);1229 $head4 = $this->fread(4); 1227 1230 if (strlen($head4) < 4) { 1228 1231 break; 1229 1232 } … … 1230 1233 if ($head4{0} != "\xFF") { 1231 1234 for ($i = 1; $i < 4; $i++) { 1232 1235 if ($head4{$i} == "\xFF") { 1233 fseek($this->getid3->fp,$i - 4, SEEK_CUR);1236 $this->fseek($i - 4, SEEK_CUR); 1234 1237 continue 2; 1235 1238 } 1236 1239 } … … 1258 1261 $LongMPEGfrequencyLookup[$head4]); 1259 1262 } 1260 1263 if ($MPEGaudioHeaderLengthCache[$head4] > 4) { 1261 $WhereWeWere = ftell($this->getid3->fp);1262 fseek($this->getid3->fp,$MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR);1263 $next4 = fread($this->getid3->fp,4);1264 $WhereWeWere = $this->ftell(); 1265 $this->fseek($MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR); 1266 $next4 = $this->fread(4); 1264 1267 if ($next4{0} == "\xFF") { 1265 1268 if (!isset($MPEGaudioHeaderDecodeCache[$next4])) { 1266 1269 $MPEGaudioHeaderDecodeCache[$next4] = self::MPEGaudioHeaderDecode($next4); … … 1269 1272 $MPEGaudioHeaderValidCache[$next4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false); 1270 1273 } 1271 1274 if ($MPEGaudioHeaderValidCache[$next4]) { 1272 fseek($this->getid3->fp,-4, SEEK_CUR);1275 $this->fseek(-4, SEEK_CUR); 1273 1276 1274 1277 getid3_lib::safe_inc($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]); 1275 1278 getid3_lib::safe_inc($Distribution['layer'][$LongMPEGlayerLookup[$head4]]); … … 1277 1280 getid3_lib::safe_inc($Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]); 1278 1281 getid3_lib::safe_inc($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]); 1279 1282 if ($max_frames_scan && (++$frames_scanned >= $max_frames_scan)) { 1280 $pct_data_scanned = ( ftell($this->getid3->fp) - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']);1283 $pct_data_scanned = ($this->ftell() - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']); 1281 1284 $info['warning'][] = 'too many MPEG audio frames to scan, only scanned first '.$max_frames_scan.' frames ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.'; 1282 1285 foreach ($Distribution as $key1 => $value1) { 1283 1286 foreach ($value1 as $key2 => $value2) { … … 1290 1293 } 1291 1294 } 1292 1295 unset($next4); 1293 fseek($this->getid3->fp, $WhereWeWere - 3, SEEK_SET);1296 $this->fseek($WhereWeWere - 3); 1294 1297 } 1295 1298 1296 1299 } … … 1355 1358 1356 1359 } 1357 1360 1358 fseek($this->getid3->fp, $avdataoffset, SEEK_SET);1361 $this->fseek($avdataoffset); 1359 1362 $sync_seek_buffer_size = min(128 * 1024, $info['avdataend'] - $avdataoffset); 1360 1363 if ($sync_seek_buffer_size <= 0) { 1361 1364 $info['error'][] = 'Invalid $sync_seek_buffer_size at offset '.$avdataoffset; 1362 1365 return false; 1363 1366 } 1364 $header = fread($this->getid3->fp,$sync_seek_buffer_size);1367 $header = $this->fread($sync_seek_buffer_size); 1365 1368 $sync_seek_buffer_size = strlen($header); 1366 1369 $SynchSeekOffset = 0; 1367 1370 while ($SynchSeekOffset < $sync_seek_buffer_size) { … … 1473 1476 1474 1477 $dummy = array('error'=>$info['error'], 'warning'=>$info['warning'], 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']); 1475 1478 $synchstartoffset = $info['avdataoffset']; 1476 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);1479 $this->fseek($info['avdataoffset']); 1477 1480 1478 1481 // you can play with these numbers: 1479 1482 $max_frames_scan = 50000; … … 1488 1491 $pct_data_scanned = 0; 1489 1492 for ($current_segment = 0; $current_segment < $max_scan_segments; $current_segment++) { 1490 1493 $frames_scanned_this_segment = 0; 1491 if ( ftell($this->getid3->fp) >= $info['avdataend']) {1494 if ($this->ftell() >= $info['avdataend']) { 1492 1495 break; 1493 1496 } 1494 $scan_start_offset[$current_segment] = max( ftell($this->getid3->fp), $info['avdataoffset'] + round($current_segment * (($info['avdataend'] - $info['avdataoffset']) / $max_scan_segments)));1497 $scan_start_offset[$current_segment] = max($this->ftell(), $info['avdataoffset'] + round($current_segment * (($info['avdataend'] - $info['avdataoffset']) / $max_scan_segments))); 1495 1498 if ($current_segment > 0) { 1496 fseek($this->getid3->fp, $scan_start_offset[$current_segment], SEEK_SET);1497 $buffer_4k = fread($this->getid3->fp,4096);1499 $this->fseek($scan_start_offset[$current_segment]); 1500 $buffer_4k = $this->fread(4096); 1498 1501 for ($j = 0; $j < (strlen($buffer_4k) - 4); $j++) { 1499 1502 if (($buffer_4k{$j} == "\xFF") && ($buffer_4k{($j + 1)} > "\xE0")) { // synch detected 1500 1503 if ($this->decodeMPEGaudioHeader($scan_start_offset[$current_segment] + $j, $dummy, false, false, $FastMode)) { … … 1523 1526 } 1524 1527 $frames_scanned++; 1525 1528 if ($frames_scan_per_segment && (++$frames_scanned_this_segment >= $frames_scan_per_segment)) { 1526 $this_pct_scanned = ( ftell($this->getid3->fp) - $scan_start_offset[$current_segment]) / ($info['avdataend'] - $info['avdataoffset']);1529 $this_pct_scanned = ($this->ftell() - $scan_start_offset[$current_segment]) / ($info['avdataend'] - $info['avdataoffset']); 1527 1530 if (($current_segment == 0) && (($this_pct_scanned * $max_scan_segments) >= 1)) { 1528 1531 // file likely contains < $max_frames_scan, just scan as one segment 1529 1532 $max_scan_segments = 1; … … 2006 2009 return (isset($LAMEpresetUsedLookup[$LAMEtag['preset_used_id']]) ? $LAMEpresetUsedLookup[$LAMEtag['preset_used_id']] : 'new/unknown preset: '.$LAMEtag['preset_used_id'].' - report to info@getid3.org'); 2007 2010 } 2008 2011 2009 } 2012 } 2013 No newline at end of file -
src/wp-includes/ID3/module.audio.ogg.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 114 115 $info['audio']['bitrate_mode'] = 'vbr'; 115 116 } 116 117 118 } elseif (substr($filedata, 0, 7) == "\x80".'theora') { 117 119 120 // http://www.theora.org/doc/Theora.pdf (section 6.2) 121 122 $info['ogg']['pageheader']['theora']['theora_magic'] = substr($filedata, $filedataoffset, 7); // hard-coded to "\x80.'theora' 123 $filedataoffset += 7; 124 $info['ogg']['pageheader']['theora']['version_major'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); 125 $filedataoffset += 1; 126 $info['ogg']['pageheader']['theora']['version_minor'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); 127 $filedataoffset += 1; 128 $info['ogg']['pageheader']['theora']['version_revision'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); 129 $filedataoffset += 1; 130 $info['ogg']['pageheader']['theora']['frame_width_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); 131 $filedataoffset += 2; 132 $info['ogg']['pageheader']['theora']['frame_height_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); 133 $filedataoffset += 2; 134 $info['ogg']['pageheader']['theora']['resolution_x'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); 135 $filedataoffset += 3; 136 $info['ogg']['pageheader']['theora']['resolution_y'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); 137 $filedataoffset += 3; 138 $info['ogg']['pageheader']['theora']['picture_offset_x'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); 139 $filedataoffset += 1; 140 $info['ogg']['pageheader']['theora']['picture_offset_y'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); 141 $filedataoffset += 1; 142 $info['ogg']['pageheader']['theora']['frame_rate_numerator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4)); 143 $filedataoffset += 4; 144 $info['ogg']['pageheader']['theora']['frame_rate_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4)); 145 $filedataoffset += 4; 146 $info['ogg']['pageheader']['theora']['pixel_aspect_numerator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); 147 $filedataoffset += 3; 148 $info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); 149 $filedataoffset += 3; 150 $info['ogg']['pageheader']['theora']['color_space_id'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); 151 $filedataoffset += 1; 152 $info['ogg']['pageheader']['theora']['nominal_bitrate'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); 153 $filedataoffset += 3; 154 $info['ogg']['pageheader']['theora']['flags'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); 155 $filedataoffset += 2; 156 157 $info['ogg']['pageheader']['theora']['quality'] = ($info['ogg']['pageheader']['theora']['flags'] & 0xFC00) >> 10; 158 $info['ogg']['pageheader']['theora']['kfg_shift'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x03E0) >> 5; 159 $info['ogg']['pageheader']['theora']['pixel_format_id'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0018) >> 3; 160 $info['ogg']['pageheader']['theora']['reserved'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0007) >> 0; // should be 0 161 $info['ogg']['pageheader']['theora']['color_space'] = self::TheoraColorSpace($info['ogg']['pageheader']['theora']['color_space_id']); 162 $info['ogg']['pageheader']['theora']['pixel_format'] = self::TheoraPixelFormat($info['ogg']['pageheader']['theora']['pixel_format_id']); 163 164 $info['video']['dataformat'] = 'theora'; 165 $info['mime_type'] = 'video/ogg'; 166 //$info['audio']['bitrate_mode'] = 'abr'; 167 //$info['audio']['lossless'] = false; 168 $info['video']['resolution_x'] = $info['ogg']['pageheader']['theora']['resolution_x']; 169 $info['video']['resolution_y'] = $info['ogg']['pageheader']['theora']['resolution_y']; 170 if ($info['ogg']['pageheader']['theora']['frame_rate_denominator'] > 0) { 171 $info['video']['frame_rate'] = (float) $info['ogg']['pageheader']['theora']['frame_rate_numerator'] / $info['ogg']['pageheader']['theora']['frame_rate_denominator']; 172 } 173 if ($info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] > 0) { 174 $info['video']['pixel_aspect_ratio'] = (float) $info['ogg']['pageheader']['theora']['pixel_aspect_numerator'] / $info['ogg']['pageheader']['theora']['pixel_aspect_denominator']; 175 } 176 $info['warning'][] = 'Ogg Theora (v3) not fully supported in this version of getID3 ['.$this->getid3->version().'] -- bitrate, playtime and all audio data are currently unavailable'; 177 178 118 179 } elseif (substr($filedata, 0, 8) == "fishead\x00") { 119 180 120 181 // Ogg Skeleton version 3.0 Format Specification … … 172 233 173 234 } elseif (substr($filedata, 1, 6) == 'theora') { 174 235 175 $info['video']['dataformat'] = 'theora ';176 $info['error'][] = 'Ogg Theora not correctly handled in this version of getID3 ['.$this->getid3->version().']';236 $info['video']['dataformat'] = 'theora1'; 237 $info['error'][] = 'Ogg Theora (v1) not correctly handled in this version of getID3 ['.$this->getid3->version().']'; 177 238 //break; 178 239 179 240 } elseif (substr($filedata, 1, 6) == 'vorbis') { … … 668 729 return round($qval, 1); // 5 or 4.9 669 730 } 670 731 671 } 732 public static function TheoraColorSpace($colorspace_id) { 733 // http://www.theora.org/doc/Theora.pdf (table 6.3) 734 static $TheoraColorSpaceLookup = array(); 735 if (empty($TheoraColorSpaceLookup)) { 736 $TheoraColorSpaceLookup[0] = 'Undefined'; 737 $TheoraColorSpaceLookup[1] = 'Rec. 470M'; 738 $TheoraColorSpaceLookup[2] = 'Rec. 470BG'; 739 $TheoraColorSpaceLookup[3] = 'Reserved'; 740 } 741 return (isset($TheoraColorSpaceLookup[$colorspace_id]) ? $TheoraColorSpaceLookup[$colorspace_id] : null); 742 } 743 744 public static function TheoraPixelFormat($pixelformat_id) { 745 // http://www.theora.org/doc/Theora.pdf (table 6.4) 746 static $TheoraPixelFormatLookup = array(); 747 if (empty($TheoraPixelFormatLookup)) { 748 $TheoraPixelFormatLookup[0] = '4:2:0'; 749 $TheoraPixelFormatLookup[1] = 'Reserved'; 750 $TheoraPixelFormatLookup[2] = '4:2:2'; 751 $TheoraPixelFormatLookup[3] = '4:4:4'; 752 } 753 return (isset($TheoraPixelFormatLookup[$pixelformat_id]) ? $TheoraPixelFormatLookup[$pixelformat_id] : null); 754 } 755 756 } 757 No newline at end of file -
src/wp-includes/ID3/module.tag.apetag.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 32 33 33 34 if ($this->overrideendoffset == 0) { 34 35 35 fseek($this->getid3->fp,0 - $id3v1tagsize - $apetagheadersize - $lyrics3tagsize, SEEK_END);36 $APEfooterID3v1 = fread($this->getid3->fp,$id3v1tagsize + $apetagheadersize + $lyrics3tagsize);36 $this->fseek(0 - $id3v1tagsize - $apetagheadersize - $lyrics3tagsize, SEEK_END); 37 $APEfooterID3v1 = $this->fread($id3v1tagsize + $apetagheadersize + $lyrics3tagsize); 37 38 38 39 //if (preg_match('/APETAGEX.{24}TAG.{125}$/i', $APEfooterID3v1)) { 39 40 if (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $id3v1tagsize - $apetagheadersize, 8) == 'APETAGEX') { … … 51 52 52 53 } else { 53 54 54 fseek($this->getid3->fp, $this->overrideendoffset - $apetagheadersize, SEEK_SET);55 if ( fread($this->getid3->fp,8) == 'APETAGEX') {55 $this->fseek($this->overrideendoffset - $apetagheadersize); 56 if ($this->fread(8) == 'APETAGEX') { 56 57 $info['ape']['tag_offset_end'] = $this->overrideendoffset; 57 58 } 58 59 … … 68 69 // shortcut 69 70 $thisfile_ape = &$info['ape']; 70 71 71 fseek($this->getid3->fp, $thisfile_ape['tag_offset_end'] - $apetagheadersize, SEEK_SET);72 $APEfooterData = fread($this->getid3->fp,32);72 $this->fseek($thisfile_ape['tag_offset_end'] - $apetagheadersize); 73 $APEfooterData = $this->fread(32); 73 74 if (!($thisfile_ape['footer'] = $this->parseAPEheaderFooter($APEfooterData))) { 74 75 $info['error'][] = 'Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end']; 75 76 return false; … … 76 77 } 77 78 78 79 if (isset($thisfile_ape['footer']['flags']['header']) && $thisfile_ape['footer']['flags']['header']) { 79 fseek($this->getid3->fp, $thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'] - $apetagheadersize, SEEK_SET);80 $thisfile_ape['tag_offset_start'] = ftell($this->getid3->fp);81 $APEtagData = fread($this->getid3->fp,$thisfile_ape['footer']['raw']['tagsize'] + $apetagheadersize);80 $this->fseek($thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'] - $apetagheadersize); 81 $thisfile_ape['tag_offset_start'] = $this->ftell(); 82 $APEtagData = $this->fread($thisfile_ape['footer']['raw']['tagsize'] + $apetagheadersize); 82 83 } else { 83 84 $thisfile_ape['tag_offset_start'] = $thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize']; 84 fseek($this->getid3->fp, $thisfile_ape['tag_offset_start'], SEEK_SET);85 $APEtagData = fread($this->getid3->fp,$thisfile_ape['footer']['raw']['tagsize']);85 $this->fseek($thisfile_ape['tag_offset_start']); 86 $APEtagData = $this->fread($thisfile_ape['footer']['raw']['tagsize']); 86 87 } 87 88 $info['avdataend'] = $thisfile_ape['tag_offset_start']; 88 89 … … 367 368 return in_array(strtolower($itemkey), $APEtagItemIsUTF8Lookup); 368 369 } 369 370 370 } 371 } 372 No newline at end of file -
src/wp-includes/ID3/module.tag.id3v1.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 25 26 return false; 26 27 } 27 28 28 fseek($this->getid3->fp,-256, SEEK_END);29 $preid3v1 = fread($this->getid3->fp,128);30 $id3v1tag = fread($this->getid3->fp,128);29 $this->fseek(-256, SEEK_END); 30 $preid3v1 = $this->fread(128); 31 $id3v1tag = $this->fread(128); 31 32 32 33 if (substr($id3v1tag, 0, 3) == 'TAG') { 33 34 … … 356 357 return $ID3v1Tag; 357 358 } 358 359 359 } 360 } 361 No newline at end of file -
src/wp-includes/ID3/module.tag.id3v2.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 51 52 $thisfile_id3v2_flags = &$thisfile_id3v2['flags']; 52 53 53 54 54 fseek($this->getid3->fp, $this->StartingOffset, SEEK_SET);55 $header = fread($this->getid3->fp,10);55 $this->fseek($this->StartingOffset); 56 $header = $this->fread(10); 56 57 if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) { 57 58 58 59 $thisfile_id3v2['majorversion'] = ord($header{3}); … … 131 132 } 132 133 if ($sizeofframes > 0) { 133 134 134 $framedata = fread($this->getid3->fp,$sizeofframes); // read all frames from file into $framedata variable135 $framedata = $this->fread($sizeofframes); // read all frames from file into $framedata variable 135 136 136 137 // if entire frame data is unsynched, de-unsynch it now (ID3v2.3.x) 137 138 if (!empty($thisfile_id3v2_flags['unsynch']) && ($id3v2_majorversion <= 3)) { … … 423 424 // ID3v2 size 4 * %0xxxxxxx 424 425 425 426 if (isset($thisfile_id3v2_flags['isfooter']) && $thisfile_id3v2_flags['isfooter']) { 426 $footer = fread($this->getid3->fp,10);427 $footer = $this->fread(10); 427 428 if (substr($footer, 0, 3) == '3DI') { 428 429 $thisfile_id3v2['footer'] = true; 429 430 $thisfile_id3v2['majorversion_footer'] = ord($footer{3}); … … 642 643 $parsedFrame['description'] = $frame_description; 643 644 $parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding))); 644 645 if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { 645 $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data'])); 646 $commentkey = ($parsedFrame['description'] ? $parsedFrame['description'] : (isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0)); 647 if (!isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || !array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) { 648 $info['id3v2']['comments'][$parsedFrame['framenameshort']][$commentkey] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data'])); 649 } else { 650 $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data'])); 651 } 646 652 } 647 653 //unset($parsedFrame['data']); do not unset, may be needed elsewhere, e.g. for replaygain 648 654 … … 1077 1083 $parsedFrame['description'] = $frame_description; 1078 1084 $parsedFrame['data'] = $frame_text; 1079 1085 if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { 1080 $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); 1086 $commentkey = ($parsedFrame['description'] ? $parsedFrame['description'] : (!empty($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0)); 1087 if (!isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || !array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) { 1088 $info['id3v2']['comments'][$parsedFrame['framenameshort']][$commentkey] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); 1089 } else { 1090 $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); 1091 } 1081 1092 } 1082 1093 1083 1094 } … … 1885 1896 $frame_offset += 2; 1886 1897 $parsedFrame['bitsperpoint'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); 1887 1898 $frame_bytesperpoint = ceil($parsedFrame['bitsperpoint'] / 8); 1888 for ($i = 0; $i < $ frame_indexpoints; $i++) {1899 for ($i = 0; $i < $parsedFrame['indexpoints']; $i++) { 1889 1900 $parsedFrame['indexes'][$i] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesperpoint)); 1890 1901 $frame_offset += $frame_bytesperpoint; 1891 1902 } … … 3411 3422 } 3412 3423 3413 3424 } 3414 -
src/wp-includes/ID3/module.tag.lyrics3.php
3 3 /// getID3() by James Heinrich <info@getid3.org> // 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // See readme.txt for more details // 8 9 ///////////////////////////////////////////////////////////////// … … 27 28 return false; 28 29 } 29 30 30 fseek($this->getid3->fp,(0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size]31 $lyrics3_id3v1 = fread($this->getid3->fp,128 + 9 + 6);31 $this->fseek((0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size] 32 $lyrics3_id3v1 = $this->fread(128 + 9 + 6); 32 33 $lyrics3lsz = substr($lyrics3_id3v1, 0, 6); // Lyrics3size 33 34 $lyrics3end = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200 34 35 $id3v1tag = substr($lyrics3_id3v1, 15, 128); // ID3v1 … … 68 69 69 70 if (isset($info['ape']['tag_offset_start']) && ($info['ape']['tag_offset_start'] > 15)) { 70 71 71 fseek($this->getid3->fp, $info['ape']['tag_offset_start'] - 15, SEEK_SET);72 $lyrics3lsz = fread($this->getid3->fp,6);73 $lyrics3end = fread($this->getid3->fp,9);72 $this->fseek($info['ape']['tag_offset_start'] - 15); 73 $lyrics3lsz = $this->fread(6); 74 $lyrics3end = $this->fread(9); 74 75 75 76 if ($lyrics3end == 'LYRICSEND') { 76 77 // Lyrics3v1, APE, maybe ID3v1 … … 101 102 102 103 if (!isset($info['ape'])) { 103 104 $GETID3_ERRORARRAY = &$info['warning']; 104 if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, false)) { 105 $getid3_temp = new getID3(); 106 $getid3_temp->openfile($this->getid3->filename); 107 $getid3_apetag = new getid3_apetag($getid3_temp); 108 $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start']; 109 $getid3_apetag->Analyze(); 110 if (!empty($getid3_temp->info['ape'])) { 111 $info['ape'] = $getid3_temp->info['ape']; 112 } 113 if (!empty($getid3_temp->info['replay_gain'])) { 114 $info['replay_gain'] = $getid3_temp->info['replay_gain']; 115 } 116 unset($getid3_temp, $getid3_apetag); 105 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true); 106 $getid3_temp = new getID3(); 107 $getid3_temp->openfile($this->getid3->filename); 108 $getid3_apetag = new getid3_apetag($getid3_temp); 109 $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start']; 110 $getid3_apetag->Analyze(); 111 if (!empty($getid3_temp->info['ape'])) { 112 $info['ape'] = $getid3_temp->info['ape']; 117 113 } 114 if (!empty($getid3_temp->info['replay_gain'])) { 115 $info['replay_gain'] = $getid3_temp->info['replay_gain']; 116 } 117 unset($getid3_temp, $getid3_apetag); 118 118 } 119 119 120 120 } … … 132 132 return false; 133 133 } 134 134 135 fseek($this->getid3->fp, $endoffset, SEEK_SET);135 $this->fseek($endoffset); 136 136 if ($length <= 0) { 137 137 return false; 138 138 } 139 $rawdata = fread($this->getid3->fp,$length);139 $rawdata = $this->fread($length); 140 140 141 141 $ParsedLyrics3['raw']['lyrics3version'] = $version; 142 142 $ParsedLyrics3['raw']['lyrics3tagsize'] = $length; … … 169 169 $ParsedLyrics3['raw']['LYR'] = trim(substr($rawdata, 11, strlen($rawdata) - 11 - 9)); 170 170 $this->Lyrics3LyricsTimestampParse($ParsedLyrics3); 171 171 } else { 172 $info['error'][] = '"LYRICSEND" expected at '.( ftell($this->getid3->fp) - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead';172 $info['error'][] = '"LYRICSEND" expected at '.($this->ftell() - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead'; 173 173 return false; 174 174 } 175 175 break; … … 217 217 $this->Lyrics3LyricsTimestampParse($ParsedLyrics3); 218 218 } 219 219 } else { 220 $info['error'][] = '"LYRICS200" expected at '.( ftell($this->getid3->fp) - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead';220 $info['error'][] = '"LYRICS200" expected at '.($this->ftell() - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead'; 221 221 return false; 222 222 } 223 223 break; … … 291 291 } 292 292 return null; 293 293 } 294 } 294 } 295 No newline at end of file -
src/wp-includes/ID3/readme.txt
2 2 /// getID3() by James Heinrich <info@getid3.org> // 3 3 // available at http://getid3.sourceforge.net // 4 4 // or http://www.getid3.org // 5 // also https://github.com/JamesHeinrich/getID3 // 5 6 ///////////////////////////////////////////////////////////////// 6 7 7 8 ***************************************************************** … … 67 68 =========================================================================== 68 69 69 70 Reads & parses (to varying degrees): 70 #tags:71 ¤ tags: 71 72 * APE (v1 and v2) 72 73 * ID3v1 (& ID3v1.1) 73 74 * ID3v2 (v2.4, v2.3, v2.2) 74 75 * Lyrics3 (v1 & v2) 75 76 76 #audio-lossy:77 ¤ audio-lossy: 77 78 * MP3/MP2/MP1 78 79 * MPC / Musepack 79 80 * Ogg (Vorbis, OggFLAC, Speex) … … 85 86 * DSS 86 87 * VQF 87 88 88 #audio-lossless:89 ¤ audio-lossless: 89 90 * AIFF 90 91 * AU 91 92 * Bonk … … 104 105 * WAV (RIFF) 105 106 * WavPack 106 107 107 #audio-video:108 ¤ audio-video: 108 109 * ASF: ASF, Windows Media Audio (WMA), Windows Media Video (WMV) 109 110 * AVI (RIFF) 110 111 * Flash … … 114 115 * Quicktime (including MP4) 115 116 * RealVideo 116 117 117 #still image:118 ¤ still image: 118 119 * BMP 119 120 * GIF 120 121 * JPEG … … 123 124 * SWF (Flash) 124 125 * PhotoCD 125 126 126 #data:127 ¤ data: 127 128 * ISO-9660 CD-ROM image (directory structure) 128 129 * SZIP (limited support) 129 130 * ZIP (directory structure) … … 309 310 (http://web.inter.nl.net/users/hvdh/lossless/lossless.htm) 310 311 * Support for RIFF-INFO chunks 311 312 * http://lotto.st-andrews.ac.uk/~njh/tag_interchange.html 312 (thanks Nick Humfrey <njh @surgeradio*co*uk>)313 (thanks Nick Humfrey <njhØsurgeradio*co*uk>) 313 314 * http://abcavi.narod.ru/sof/abcavi/infotags.htm 314 315 (thanks Kibi) 315 316 * Better support for Bink video … … 324 325 * Support for IFF 325 326 * Support for ICO 326 327 * Support for ANI 327 * Support for EXE (comments, author, etc) (thanks p*quaedackers @planet*nl)328 * Support for EXE (comments, author, etc) (thanks p*quaedackersØplanet*nl) 328 329 * Support for DVD-IFO (region, subtitles, aspect ratio, etc) 329 (thanks p*quaedackers @planet*nl)330 (thanks p*quaedackersØplanet*nl) 330 331 * More complete support for SWF - parsing encapsulated MP3 and/or JPEG content 331 (thanks n8n8 @yahoo*com)332 (thanks n8n8Øyahoo*com) 332 333 * Support for a2b 333 334 * Optional scan-through-frames for AVI verification 334 (thanks rockcohen @massive-interactive*nl)335 * Support for TTF (thanks info @butterflyx*com)335 (thanks rockcohenØmassive-interactive*nl) 336 * Support for TTF (thanks infoØbutterflyx*com) 336 337 * Support for DSS (http://www.getid3.org/phpBB3/viewtopic.php?t=171) 337 338 * Support for SMAF (http://smaf-yamaha.com/what/demo.html) 338 339 http://www.getid3.org/phpBB3/viewtopic.php?t=182 339 340 * Support for AMR (http://www.getid3.org/phpBB3/viewtopic.php?t=195) 340 341 * Support for 3gpp (http://www.getid3.org/phpBB3/viewtopic.php?t=195) 341 * Support for ID4 (http://www.wackysoft.cjb.net grizlyY2K @hotmail*com)342 * Support for ID4 (http://www.wackysoft.cjb.net grizlyY2KØhotmail*com) 342 343 * Parse XML data returned in Ogg comments 343 * Parse XML data from Quicktime SMIL metafiles (klausrath @mac*com)344 * Parse XML data from Quicktime SMIL metafiles (klausrathØmac*com) 344 345 * ID3v2 genre string creator function 345 346 * More complete parsing of JPG 346 347 * Support for all old-style ASF packets … … 424 425 "movi" chunk that fits in the first 2GB, should issue error 425 426 to show that playtime is incorrect. Other data should be mostly 426 427 correct, assuming that data is constant throughout the file) 428 * PHP <= v5 on Windows cannot read UTF-8 filenames 427 429 428 430 429 430 431 Known Bugs/Issues in other programs 431 432 ----------------------------------- 432 433 http://www.getid3.org/phpBB3/viewtopic.php?t=25 … … 600 601 * http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm 601 602 * http://trac.musepack.net/trac/wiki/SV8Specification 602 603 * http://wyday.com/cuesharp/specification.php 603 * http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html 604 * http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html 605 No newline at end of file
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)