summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-04-13 16:40:10 -0400
committerGeorg Ehrke <dev@georgswebsite.de>2012-04-13 16:40:10 -0400
commitafcb0aee40230c68dd99f5ea2501b7ba7e444560 (patch)
tree5ccd10e78128c70e71a36ca9080a652a7bd833d5
parent02dc34320978bfbcb30dea34b87808837586bb65 (diff)
parentb9f9228a22944184803a8835282862e468812c1d (diff)
downloadnextcloud-server-afcb0aee40230c68dd99f5ea2501b7ba7e444560.tar.gz
nextcloud-server-afcb0aee40230c68dd99f5ea2501b7ba7e444560.zip
fix merge conflicts
-rw-r--r--3rdparty/getid3/extension.cache.dbm.php (renamed from apps/media/getID3/getid3/extension.cache.dbm.php)45
-rw-r--r--3rdparty/getid3/extension.cache.mysql.php (renamed from apps/media/getID3/getid3/extension.cache.mysql.php)54
-rw-r--r--3rdparty/getid3/getid3.lib.php (renamed from apps/media/getID3/getid3/getid3.lib.php)556
-rw-r--r--3rdparty/getid3/getid3.php (renamed from apps/media/getID3/getid3/getid3.php)1003
-rw-r--r--3rdparty/getid3/license.txt (renamed from apps/media/getID3/license.txt)0
-rw-r--r--3rdparty/getid3/module.archive.gzip.php (renamed from apps/media/getID3/getid3/module.archive.gzip.php)123
-rw-r--r--3rdparty/getid3/module.archive.rar.php (renamed from apps/media/getID3/getid3/module.archive.rar.php)19
-rw-r--r--3rdparty/getid3/module.archive.szip.php (renamed from apps/media/getID3/getid3/module.archive.szip.php)33
-rw-r--r--3rdparty/getid3/module.archive.tar.php (renamed from apps/media/getID3/getid3/module.archive.tar.php)59
-rw-r--r--3rdparty/getid3/module.archive.zip.php (renamed from apps/media/getID3/getid3/module.archive.zip.php)206
-rw-r--r--3rdparty/getid3/module.audio-video.asf.php (renamed from apps/media/getID3/getid3/module.audio-video.asf.php)922
-rw-r--r--3rdparty/getid3/module.audio-video.bink.php73
-rw-r--r--3rdparty/getid3/module.audio-video.flv.php731
-rw-r--r--3rdparty/getid3/module.audio-video.matroska.php (renamed from apps/media/getID3/getid3/module.audio-video.matroska.php)1700
-rw-r--r--3rdparty/getid3/module.audio-video.mpeg.php (renamed from apps/media/getID3/getid3/module.audio-video.mpeg.php)131
-rw-r--r--3rdparty/getid3/module.audio-video.nsv.php226
-rw-r--r--3rdparty/getid3/module.audio-video.quicktime.php2134
-rw-r--r--3rdparty/getid3/module.audio-video.real.php (renamed from apps/media/getID3/getid3/module.audio-video.real.php)146
-rw-r--r--3rdparty/getid3/module.audio-video.riff.php (renamed from apps/media/getID3/getid3/module.audio-video.riff.php)1067
-rw-r--r--3rdparty/getid3/module.audio-video.swf.php (renamed from apps/media/getID3/getid3/module.audio-video.swf.php)75
-rw-r--r--3rdparty/getid3/module.audio.aa.php59
-rw-r--r--3rdparty/getid3/module.audio.aac.php515
-rw-r--r--3rdparty/getid3/module.audio.ac3.php473
-rw-r--r--3rdparty/getid3/module.audio.au.php (renamed from apps/media/getID3/getid3/module.audio.au.php)42
-rw-r--r--3rdparty/getid3/module.audio.avr.php127
-rw-r--r--3rdparty/getid3/module.audio.bonk.php (renamed from apps/media/getID3/getid3/module.audio.bonk.php)139
-rw-r--r--3rdparty/getid3/module.audio.dss.php (renamed from apps/media/getID3/getid3/module.audio.dss.php)39
-rw-r--r--3rdparty/getid3/module.audio.dts.php246
-rw-r--r--3rdparty/getid3/module.audio.flac.php480
-rw-r--r--3rdparty/getid3/module.audio.la.php229
-rw-r--r--3rdparty/getid3/module.audio.lpac.php130
-rw-r--r--3rdparty/getid3/module.audio.midi.php (renamed from apps/media/getID3/getid3/module.audio.midi.php)62
-rw-r--r--3rdparty/getid3/module.audio.mod.php101
-rw-r--r--3rdparty/getid3/module.audio.monkey.php (renamed from apps/media/getID3/getid3/module.audio.monkey.php)73
-rw-r--r--3rdparty/getid3/module.audio.mp3.php (renamed from apps/media/getID3/getid3/module.audio.mp3.php)699
-rw-r--r--3rdparty/getid3/module.audio.mpc.php (renamed from apps/media/getID3/getid3/module.audio.mpc.php)169
-rw-r--r--3rdparty/getid3/module.audio.ogg.php705
-rw-r--r--3rdparty/getid3/module.audio.optimfrog.php (renamed from apps/media/getID3/getid3/module.audio.optimfrog.php)171
-rw-r--r--3rdparty/getid3/module.audio.rkau.php94
-rw-r--r--3rdparty/getid3/module.audio.shorten.php (renamed from apps/media/getID3/getid3/module.audio.shorten.php)103
-rw-r--r--3rdparty/getid3/module.audio.tta.php109
-rw-r--r--3rdparty/getid3/module.audio.voc.php (renamed from apps/media/getID3/getid3/module.audio.voc.php)62
-rw-r--r--3rdparty/getid3/module.audio.vqf.php (renamed from apps/media/getID3/getid3/module.audio.vqf.php)75
-rw-r--r--3rdparty/getid3/module.audio.wavpack.php400
-rw-r--r--3rdparty/getid3/module.graphic.bmp.php (renamed from apps/media/getID3/getid3/module.graphic.bmp.php)93
-rw-r--r--3rdparty/getid3/module.graphic.efax.php53
-rw-r--r--3rdparty/getid3/module.graphic.gif.php184
-rw-r--r--3rdparty/getid3/module.graphic.jpg.php338
-rw-r--r--3rdparty/getid3/module.graphic.pcd.php (renamed from apps/media/getID3/getid3/module.graphic.pcd.php)52
-rw-r--r--3rdparty/getid3/module.graphic.png.php (renamed from apps/media/getID3/getid3/module.graphic.png.php)43
-rw-r--r--3rdparty/getid3/module.graphic.svg.php104
-rw-r--r--3rdparty/getid3/module.graphic.tiff.php (renamed from apps/media/getID3/getid3/module.graphic.tiff.php)86
-rw-r--r--3rdparty/getid3/module.misc.cue.php312
-rw-r--r--3rdparty/getid3/module.misc.exe.php61
-rw-r--r--3rdparty/getid3/module.misc.iso.php (renamed from apps/media/getID3/getid3/module.misc.iso.php)125
-rw-r--r--3rdparty/getid3/module.misc.msoffice.php (renamed from apps/media/getID3/getid3/module.misc.msoffice.php)18
-rw-r--r--3rdparty/getid3/module.misc.par2.php (renamed from apps/media/getID3/getid3/module.misc.par2.php)9
-rw-r--r--3rdparty/getid3/module.misc.pdf.php (renamed from apps/media/getID3/getid3/module.misc.pdf.php)9
-rw-r--r--3rdparty/getid3/module.tag.apetag.php (renamed from apps/media/getID3/getid3/module.tag.apetag.php)166
-rw-r--r--3rdparty/getid3/module.tag.id3v1.php (renamed from apps/media/getID3/getid3/module.tag.id3v1.php)57
-rw-r--r--3rdparty/getid3/module.tag.id3v2.php (renamed from apps/media/getID3/getid3/module.tag.id3v2.php)631
-rw-r--r--3rdparty/getid3/module.tag.lyrics3.php (renamed from apps/media/getID3/getid3/module.tag.lyrics3.php)125
-rw-r--r--3rdparty/getid3/module.tag.xmp.php766
-rw-r--r--3rdparty/getid3/write.apetag.php (renamed from apps/media/getID3/getid3/write.apetag.php)15
-rw-r--r--3rdparty/getid3/write.id3v1.php (renamed from apps/media/getID3/getid3/write.id3v1.php)77
-rw-r--r--3rdparty/getid3/write.id3v2.php (renamed from apps/media/getID3/getid3/write.id3v2.php)118
-rw-r--r--3rdparty/getid3/write.lyrics3.php (renamed from apps/media/getID3/getid3/write.lyrics3.php)9
-rw-r--r--3rdparty/getid3/write.metaflac.php163
-rw-r--r--3rdparty/getid3/write.php (renamed from apps/media/getID3/getid3/write.php)85
-rw-r--r--3rdparty/getid3/write.real.php275
-rw-r--r--3rdparty/getid3/write.vorbiscomment.php121
-rw-r--r--apps/admin_dependencies_chk/appinfo/info.xml1
-rw-r--r--apps/calendar/ajax/categories/rescan.php42
-rw-r--r--apps/calendar/ajax/event/edit.form.php21
-rw-r--r--apps/calendar/ajax/event/new.form.php3
-rw-r--r--apps/calendar/index.php4
-rw-r--r--apps/calendar/js/calendar.js15
-rw-r--r--apps/calendar/lib/app.php79
-rw-r--r--apps/calendar/lib/calendar.php4
-rw-r--r--apps/calendar/lib/object.php31
-rwxr-xr-xapps/calendar/templates/calendar.php1
-rw-r--r--apps/calendar/templates/part.eventform.php10
-rw-r--r--apps/contacts/ajax/categories/list.php2
-rw-r--r--apps/contacts/ajax/categories/rescan.php9
-rw-r--r--apps/contacts/index.php26
-rw-r--r--apps/contacts/js/contacts.js5
-rw-r--r--apps/contacts/lib/app.php43
-rw-r--r--apps/contacts/lib/vcard.php6
-rw-r--r--apps/contacts/templates/index.php2
-rw-r--r--apps/contacts/templates/part.contact.php4
-rw-r--r--apps/files_external/tests/config.php3
-rw-r--r--apps/files_external/tests/ftp.php31
-rw-r--r--apps/files_external/tests/google.php31
-rw-r--r--apps/files_external/tests/webdav.php29
-rw-r--r--apps/media/appinfo/database.xml69
-rw-r--r--apps/media/appinfo/info.xml2
-rw-r--r--apps/media/getID3/changelog.txt2435
-rw-r--r--apps/media/getID3/dependencies.txt24
-rw-r--r--apps/media/getID3/getid3/module.audio-video.bink.php70
-rw-r--r--apps/media/getID3/getid3/module.audio-video.flv.php505
-rw-r--r--apps/media/getID3/getid3/module.audio-video.nsv.php224
-rw-r--r--apps/media/getID3/getid3/module.audio-video.quicktime.php1382
-rw-r--r--apps/media/getID3/getid3/module.audio.aac.php542
-rw-r--r--apps/media/getID3/getid3/module.audio.ac3.php497
-rw-r--r--apps/media/getID3/getid3/module.audio.avr.php125
-rw-r--r--apps/media/getID3/getid3/module.audio.dts.php239
-rw-r--r--apps/media/getID3/getid3/module.audio.flac.php397
-rw-r--r--apps/media/getID3/getid3/module.audio.la.php228
-rw-r--r--apps/media/getID3/getid3/module.audio.lpac.php126
-rw-r--r--apps/media/getID3/getid3/module.audio.mod.php101
-rw-r--r--apps/media/getID3/getid3/module.audio.ogg.php556
-rw-r--r--apps/media/getID3/getid3/module.audio.rkau.php92
-rw-r--r--apps/media/getID3/getid3/module.audio.tta.php107
-rw-r--r--apps/media/getID3/getid3/module.audio.wavpack.php372
-rw-r--r--apps/media/getID3/getid3/module.graphic.gif.php183
-rw-r--r--apps/media/getID3/getid3/module.graphic.jpg.php249
-rw-r--r--apps/media/getID3/getid3/module.graphic.svg.php52
-rw-r--r--apps/media/getID3/getid3/module.misc.doc.php32
-rw-r--r--apps/media/getID3/getid3/module.misc.exe.php59
-rw-r--r--apps/media/getID3/getid3/write.metaflac.php167
-rw-r--r--apps/media/getID3/getid3/write.real.php295
-rw-r--r--apps/media/getID3/getid3/write.vorbiscomment.php124
-rw-r--r--apps/media/getID3/helperapps/readme.txt55
-rw-r--r--apps/media/getID3/license.commercial.txt27
-rw-r--r--apps/media/getID3/readme.txt549
-rw-r--r--apps/media/getID3/structure.txt2251
-rw-r--r--apps/media/js/loader.js4
-rw-r--r--apps/media/js/music.js2
-rw-r--r--apps/media/lib_scanner.php2
-rw-r--r--apps/user_openid/templates/settings.php2
-rw-r--r--core/ajax/appconfig.php2
-rw-r--r--core/ajax/vcategories/delete.php2
-rw-r--r--core/css/oc-vcategories.css7
-rw-r--r--core/css/styles.css14
-rw-r--r--core/js/config.js2
-rw-r--r--core/js/js.js5
-rw-r--r--core/js/oc-vcategories.js36
-rw-r--r--core/templates/layout.user.php2
-rw-r--r--files/admin.php20
-rw-r--r--files/js/fileactions.js4
-rw-r--r--files/templates/admin.php4
-rw-r--r--lib/base.php4
-rw-r--r--lib/db.php4
-rw-r--r--lib/files.php55
-rw-r--r--lib/filesystem.php8
-rw-r--r--lib/group.php161
-rw-r--r--lib/group/backend.php119
-rw-r--r--lib/group/database.php4
-rw-r--r--lib/group/dummy.php159
-rw-r--r--lib/group/example.php102
-rwxr-xr-xlib/helper.php24
-rw-r--r--lib/user.php6
-rw-r--r--lib/util.php4
-rw-r--r--lib/vcategories.php8
-rw-r--r--tests/lib/filestorage/local.php5
-rw-r--r--tests/lib/filesystem.php64
-rw-r--r--tests/lib/group.php114
-rw-r--r--tests/lib/group/backend.php105
-rw-r--r--tests/lib/group/database.php55
-rw-r--r--tests/lib/group/dummy.php27
160 files changed, 15871 insertions, 16503 deletions
diff --git a/apps/media/getID3/getid3/extension.cache.dbm.php b/3rdparty/getid3/extension.cache.dbm.php
index c18b52d5dca..9a88c22b246 100644
--- a/apps/media/getID3/getid3/extension.cache.dbm.php
+++ b/3rdparty/getid3/extension.cache.dbm.php
@@ -77,35 +77,24 @@ class getID3_cached_dbm extends getID3
// Check for dba extension
if (!extension_loaded('dba')) {
- die('PHP is not compiled with dba support, required to use DBM style cache.');
+ throw new Exception('PHP is not compiled with dba support, required to use DBM style cache.');
}
// Check for specific dba driver
- if (function_exists('dba_handlers')) { // PHP 4.3.0+
- if (!in_array('db3', dba_handlers())) {
- die('PHP is not compiled --with '.$cache_type.' support, required to use DBM style cache.');
- }
- }
- else { // PHP <= 4.2.3
- ob_start(); // nasty, buy the only way to check...
- phpinfo();
- $contents = ob_get_contents();
- @ob_end_clean();
- if (!strstr($contents, $cache_type)) {
- die('PHP is not compiled --with '.$cache_type.' support, required to use DBM style cache.');
- }
+ if (!function_exists('dba_handlers') || !in_array($cache_type, dba_handlers())) {
+ throw new Exception('PHP is not compiled --with '.$cache_type.' support, required to use DBM style cache.');
}
// Create lock file if needed
if (!file_exists($lock_filename)) {
if (!touch($lock_filename)) {
- die('failed to create lock file: ' . $lock_filename);
+ throw new Exception('failed to create lock file: '.$lock_filename);
}
}
// Open lock file for writing
if (!is_writeable($lock_filename)) {
- die('lock file: ' . $lock_filename . ' is not writable');
+ throw new Exception('lock file: '.$lock_filename.' is not writable');
}
$this->lock = fopen($lock_filename, 'w');
@@ -115,23 +104,23 @@ class getID3_cached_dbm extends getID3
// Create dbm-file if needed
if (!file_exists($dbm_filename)) {
if (!touch($dbm_filename)) {
- die('failed to create dbm file: ' . $dbm_filename);
+ throw new Exception('failed to create dbm file: '.$dbm_filename);
}
}
// Try to open dbm file for writing
- $this->dba = @dba_open($dbm_filename, 'w', $cache_type);
+ $this->dba = dba_open($dbm_filename, 'w', $cache_type);
if (!$this->dba) {
// Failed - create new dbm file
$this->dba = dba_open($dbm_filename, 'n', $cache_type);
if (!$this->dba) {
- die('failed to create dbm file: ' . $dbm_filename);
+ throw new Exception('failed to create dbm file: '.$dbm_filename);
}
// Insert getID3 version number
- dba_insert(GETID3_VERSION, GETID3_VERSION, $this->dba);
+ dba_insert(getID3::VERSION, getID3::VERSION, $this->dba);
}
// Init misc values
@@ -142,7 +131,7 @@ class getID3_cached_dbm extends getID3
register_shutdown_function(array($this, '__destruct'));
// Check version number and clear cache if changed
- if (dba_fetch(GETID3_VERSION, $this->dba) != GETID3_VERSION) {
+ if (dba_fetch(getID3::VERSION, $this->dba) != getID3::VERSION) {
$this->clear_cache();
}
@@ -155,13 +144,13 @@ class getID3_cached_dbm extends getID3
function __destruct() {
// Close dbm file
- @dba_close($this->dba);
+ dba_close($this->dba);
// Release exclusive lock
- @flock($this->lock, LOCK_UN);
+ flock($this->lock, LOCK_UN);
// Close lock file
- @fclose($this->lock);
+ fclose($this->lock);
}
@@ -176,13 +165,13 @@ class getID3_cached_dbm extends getID3
$this->dba = dba_open($this->dbm_filename, 'n', $this->cache_type);
if (!$this->dba) {
- die('failed to clear cache/recreate dbm file: ' . $this->dbm_filename);
+ throw new Exception('failed to clear cache/recreate dbm file: '.$this->dbm_filename);
}
// Insert getID3 version number
- dba_insert(GETID3_VERSION, GETID3_VERSION, $this->dba);
+ dba_insert(getID3::VERSION, getID3::VERSION, $this->dba);
- // Reregister shutdown function
+ // Re-register shutdown function
register_shutdown_function(array($this, '__destruct'));
}
@@ -194,7 +183,7 @@ class getID3_cached_dbm extends getID3
if (file_exists($filename)) {
// Calc key filename::mod_time::size - should be unique
- $key = $filename . '::' . filemtime($filename) . '::' . filesize($filename);
+ $key = $filename.'::'.filemtime($filename).'::'.filesize($filename);
// Loopup key
$result = dba_fetch($key, $this->dba);
diff --git a/apps/media/getID3/getid3/extension.cache.mysql.php b/3rdparty/getid3/extension.cache.mysql.php
index 40ea6883eaa..1e1f91fa14a 100644
--- a/apps/media/getID3/getid3/extension.cache.mysql.php
+++ b/3rdparty/getid3/extension.cache.mysql.php
@@ -11,6 +11,7 @@
/////////////////////////////////////////////////////////////////
// //
// This extension written by Allan Hansen <ahØartemis*dk> //
+// Table name mod by Carlo Capocasa <calroØcarlocapocasa*com> //
// ///
/////////////////////////////////////////////////////////////////
@@ -33,8 +34,8 @@
*
* require_once 'getid3/getid3.php';
* require_once 'getid3/getid3/extension.cache.mysql.php';
-* $getID3 = new getID3_cached_mysql('localhost', 'database',
-* 'username', 'password');
+* // 5th parameter (tablename) is optional, default is 'getid3_cache'
+* $getID3 = new getID3_cached_mysql('localhost', 'database', 'username', 'password', 'tablename');
* $getID3->encoding = 'UTF-8';
* $info1 = $getID3->analyze('file1.flac');
* $info2 = $getID3->analyze('file2.wv');
@@ -78,31 +79,36 @@ class getID3_cached_mysql extends getID3
// public: constructor - see top of this file for cache type and cache_options
- function getID3_cached_mysql($host, $database, $username, $password) {
+ function getID3_cached_mysql($host, $database, $username, $password, $table='getid3_cache') {
// Check for mysql support
if (!function_exists('mysql_pconnect')) {
- die('PHP not compiled with mysql support.');
+ throw new Exception('PHP not compiled with mysql support.');
}
// Connect to database
$this->connection = mysql_pconnect($host, $username, $password);
if (!$this->connection) {
- die('mysql_pconnect() failed - check permissions and spelling.');
+ throw new Exception('mysql_pconnect() failed - check permissions and spelling.');
}
// Select database
if (!mysql_select_db($database, $this->connection)) {
- die('Cannot use database '.$database);
+ throw new Exception('Cannot use database '.$database);
}
+ // Set table
+ $this->table = $table;
+
// Create cache table if not exists
$this->create_table();
// Check version number and clear cache if changed
- $this->cursor = mysql_query("SELECT `value` FROM `getid3_cache` WHERE (`filename` = '".GETID3_VERSION."') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')", $this->connection);
- list($version) = @mysql_fetch_array($this->cursor);
- if ($version != GETID3_VERSION) {
+ $version = '';
+ if ($this->cursor = mysql_query("SELECT `value` FROM `".mysql_real_escape_string($this->table)."` WHERE (`filename` = '".mysql_real_escape_string(getID3::VERSION)."') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')", $this->connection)) {
+ list($version) = mysql_fetch_array($this->cursor);
+ }
+ if ($version != getID3::VERSION) {
$this->clear_cache();
}
@@ -114,8 +120,8 @@ class getID3_cached_mysql extends getID3
// public: clear cache
function clear_cache() {
- $this->cursor = mysql_query("DELETE FROM `getid3_cache`", $this->connection);
- $this->cursor = mysql_query("INSERT INTO `getid3_cache` VALUES ('".GETID3_VERSION."', -1, -1, -1, '".GETID3_VERSION."')", $this->connection);
+ $this->cursor = mysql_query("DELETE FROM `".mysql_real_escape_string($this->table)."`", $this->connection);
+ $this->cursor = mysql_query("INSERT INTO `".mysql_real_escape_string($this->table)."` VALUES ('".getID3::VERSION."', -1, -1, -1, '".getID3::VERSION."')", $this->connection);
}
@@ -128,35 +134,32 @@ class getID3_cached_mysql extends getID3
// Short-hands
$filetime = filemtime($filename);
$filesize = filesize($filename);
- $filenam2 = mysql_escape_string($filename);
- // Loopup file
- $this->cursor = mysql_query("SELECT `value` FROM `getid3_cache` WHERE (`filename`='".$filenam2."') AND (`filesize`='".$filesize."') AND (`filetime`='".$filetime."')", $this->connection);
- list($result) = @mysql_fetch_array($this->cursor);
-
- // Hit
- if ($result) {
- return unserialize($result);
+ // Lookup file
+ $this->cursor = mysql_query("SELECT `value` FROM `".mysql_real_escape_string($this->table)."` WHERE (`filename` = '".mysql_real_escape_string($filename)."') AND (`filesize` = '".mysql_real_escape_string($filesize)."') AND (`filetime` = '".mysql_real_escape_string($filetime)."')", $this->connection);
+ if (mysql_num_rows($this->cursor) > 0) {
+ // Hit
+ list($result) = mysql_fetch_array($this->cursor);
+ return unserialize(base64_decode($result));
}
}
// Miss
- $result = parent::analyze($filename);
+ $analysis = parent::analyze($filename);
// Save result
if (file_exists($filename)) {
- $res2 = mysql_escape_string(serialize($result));
- $this->cursor = mysql_query("INSERT INTO `getid3_cache` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES ('".$filenam2."', '".$filesize."', '".$filetime."', '".time()."', '".$res2."')", $this->connection);
+ $this->cursor = mysql_query("INSERT INTO `".mysql_real_escape_string($this->table)."` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES ('".mysql_real_escape_string($filename)."', '".mysql_real_escape_string($filesize)."', '".mysql_real_escape_string($filetime)."', '".mysql_real_escape_string(time())."', '".mysql_real_escape_string(base64_encode(serialize($analysis)))."')", $this->connection);
}
- return $result;
+ return $analysis;
}
// private: (re)create sql table
- function create_table($drop = false) {
+ function create_table($drop=false) {
- $this->cursor = mysql_query("CREATE TABLE IF NOT EXISTS `getid3_cache` (
+ $this->cursor = mysql_query("CREATE TABLE IF NOT EXISTS `".mysql_real_escape_string($this->table)."` (
`filename` VARCHAR(255) NOT NULL DEFAULT '',
`filesize` INT(11) NOT NULL DEFAULT '0',
`filetime` INT(11) NOT NULL DEFAULT '0',
@@ -167,5 +170,4 @@ class getID3_cached_mysql extends getID3
}
}
-
?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/getid3.lib.php b/3rdparty/getid3/getid3.lib.php
index 9322cae4dd8..723e2e24c20 100644
--- a/apps/media/getID3/getid3/getid3.lib.php
+++ b/3rdparty/getid3/getid3.lib.php
@@ -14,33 +14,28 @@
class getid3_lib
{
- function PrintHexBytes($string, $hex=true, $spaces=true, $htmlsafe=true) {
+ static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') {
$returnstring = '';
for ($i = 0; $i < strlen($string); $i++) {
if ($hex) {
$returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
} else {
- $returnstring .= ' '.(ereg("[\x20-\x7E]", $string{$i}) ? $string{$i} : '¤');
+ $returnstring .= ' '.(preg_match("#[\x20-\x7E]#", $string{$i}) ? $string{$i} : '¤');
}
if ($spaces) {
$returnstring .= ' ';
}
}
- if ($htmlsafe) {
- $returnstring = htmlentities($returnstring);
+ if (!empty($htmlencoding)) {
+ if ($htmlencoding === true) {
+ $htmlencoding = 'UTF-8'; // prior to getID3 v1.9.0 the function's 4th parameter was boolean
+ }
+ $returnstring = htmlentities($returnstring, ENT_QUOTES, $htmlencoding);
}
return $returnstring;
}
- function SafeStripSlashes($text) {
- if (get_magic_quotes_gpc()) {
- return stripslashes($text);
- }
- return $text;
- }
-
-
- function trunc($floatnumber) {
+ static function trunc($floatnumber) {
// truncates a floating-point number at the decimal point
// returns int (if possible, otherwise float)
if ($floatnumber >= 1) {
@@ -50,21 +45,30 @@ class getid3_lib
} else {
$truncatednumber = 0;
}
- if ($truncatednumber <= 1073741824) { // 2^30
+ if (getid3_lib::intValueSupported($truncatednumber)) {
$truncatednumber = (int) $truncatednumber;
}
return $truncatednumber;
}
- function CastAsInt($floatnum) {
+ static function safe_inc(&$variable, $increment=1) {
+ if (isset($variable)) {
+ $variable += $increment;
+ } else {
+ $variable = $increment;
+ }
+ return true;
+ }
+
+ static function CastAsInt($floatnum) {
// convert to float if not already
$floatnum = (float) $floatnum;
// convert a float to type int, only if possible
if (getid3_lib::trunc($floatnum) == $floatnum) {
// it's not floating point
- if ($floatnum <= 2147483647) { // 2^31
+ if (getid3_lib::intValueSupported($floatnum)) {
// it's within int range
$floatnum = (int) $floatnum;
}
@@ -72,15 +76,36 @@ class getid3_lib
return $floatnum;
}
+ public static function intValueSupported($num) {
+ // check if integers are 64-bit
+ static $hasINT64 = null;
+ if ($hasINT64 === null) { // 10x faster than is_null()
+ $hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1
+ if (!$hasINT64 && !defined('PHP_INT_MIN')) {
+ define('PHP_INT_MIN', ~PHP_INT_MAX);
+ }
+ }
+ // if integers are 64-bit - no other check required
+ if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) {
+ return true;
+ }
+ return false;
+ }
+
+ static function DecimalizeFraction($fraction) {
+ list($numerator, $denominator) = explode('/', $fraction);
+ return $numerator / ($denominator ? $denominator : 1);
+ }
+
- function DecimalBinary2Float($binarynumerator) {
+ static function DecimalBinary2Float($binarynumerator) {
$numerator = getid3_lib::Bin2Dec($binarynumerator);
$denominator = getid3_lib::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
return ($numerator / $denominator);
}
- function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
+ static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
if (strpos($binarypointnumber, '.') === false) {
$binarypointnumber = '0.'.$binarypointnumber;
@@ -104,7 +129,7 @@ class getid3_lib
}
- function Float2BinaryDecimal($floatvalue) {
+ static function Float2BinaryDecimal($floatvalue) {
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
$maxbits = 128; // to how many bits of precision should the calculations be taken?
$intpart = getid3_lib::trunc($floatvalue);
@@ -120,7 +145,7 @@ class getid3_lib
}
- function Float2String($floatvalue, $bits) {
+ static function Float2String($floatvalue, $bits) {
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
switch ($bits) {
case 32:
@@ -151,20 +176,20 @@ class getid3_lib
}
- function LittleEndian2Float($byteword) {
+ static function LittleEndian2Float($byteword) {
return getid3_lib::BigEndian2Float(strrev($byteword));
}
- function BigEndian2Float($byteword) {
+ static function BigEndian2Float($byteword) {
// ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
// http://www.psc.edu/general/software/packages/ieee/ieee.html
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
$bitword = getid3_lib::BigEndian2Bin($byteword);
if (!$bitword) {
- return 0;
- }
+ return 0;
+ }
$signbit = $bitword{0};
switch (strlen($byteword) * 8) {
@@ -234,44 +259,42 @@ class getid3_lib
}
- function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
+ static function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
$intvalue = 0;
$bytewordlen = strlen($byteword);
+ if ($bytewordlen == 0) {
+ return false;
+ }
for ($i = 0; $i < $bytewordlen; $i++) {
if ($synchsafe) { // disregard MSB, effectively 7-bit bytes
- $intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7);
+ //$intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7); // faster, but runs into problems past 2^31 on 32-bit systems
+ $intvalue += (ord($byteword{$i}) & 0x7F) * pow(2, ($bytewordlen - 1 - $i) * 7);
} else {
$intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
}
}
if ($signed && !$synchsafe) {
// synchsafe ints are not allowed to be signed
- switch ($bytewordlen) {
- case 1:
- case 2:
- case 3:
- case 4:
- $signmaskbit = 0x80 << (8 * ($bytewordlen - 1));
- if ($intvalue & $signmaskbit) {
- $intvalue = 0 - ($intvalue & ($signmaskbit - 1));
- }
- break;
-
- default:
- die('ERROR: Cannot have signed integers larger than 32-bits in getid3_lib::BigEndian2Int()');
- break;
+ if ($bytewordlen <= PHP_INT_SIZE) {
+ $signMaskBit = 0x80 << (8 * ($bytewordlen - 1));
+ if ($intvalue & $signMaskBit) {
+ $intvalue = 0 - ($intvalue & ($signMaskBit - 1));
+ }
+ } else {
+ throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in getid3_lib::BigEndian2Int()');
+ break;
}
}
return getid3_lib::CastAsInt($intvalue);
}
- function LittleEndian2Int($byteword, $signed=false) {
+ static function LittleEndian2Int($byteword, $signed=false) {
return getid3_lib::BigEndian2Int(strrev($byteword), false, $signed);
}
- function BigEndian2Bin($byteword) {
+ static function BigEndian2Bin($byteword) {
$binvalue = '';
$bytewordlen = strlen($byteword);
for ($i = 0; $i < $bytewordlen; $i++) {
@@ -281,15 +304,15 @@ class getid3_lib
}
- function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
+ static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
if ($number < 0) {
- return false;
+ throw new Exception('ERROR: getid3_lib::BigEndian2String() does not support negative numbers');
}
$maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
$intstring = '';
if ($signed) {
- if ($minbytes > 4) {
- die('ERROR: Cannot have signed integers larger than 32-bits in getid3_lib::BigEndian2String()');
+ if ($minbytes > PHP_INT_SIZE) {
+ throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in getid3_lib::BigEndian2String()');
}
$number = $number & (0x80 << (8 * ($minbytes - 1)));
}
@@ -302,7 +325,7 @@ class getid3_lib
}
- function Dec2Bin($number) {
+ static function Dec2Bin($number) {
while ($number >= 256) {
$bytes[] = (($number / 256) - (floor($number / 256))) * 256;
$number = floor($number / 256);
@@ -316,7 +339,7 @@ class getid3_lib
}
- function Bin2Dec($binstring, $signed=false) {
+ static function Bin2Dec($binstring, $signed=false) {
$signmult = 1;
if ($signed) {
if ($binstring{0} == '1') {
@@ -332,7 +355,7 @@ class getid3_lib
}
- function Bin2String($binstring) {
+ static function Bin2String($binstring) {
// return 'hi' for input of '0110100001101001'
$string = '';
$binstringreversed = strrev($binstring);
@@ -343,7 +366,7 @@ class getid3_lib
}
- function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
+ static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
$intstring = '';
while ($number > 0) {
if ($synchsafe) {
@@ -358,7 +381,7 @@ class getid3_lib
}
- function array_merge_clobber($array1, $array2) {
+ static function array_merge_clobber($array1, $array2) {
// written by kcØhireability*com
// taken from http://www.php.net/manual/en/function.array-merge-recursive.php
if (!is_array($array1) || !is_array($array2)) {
@@ -376,7 +399,7 @@ class getid3_lib
}
- function array_merge_noclobber($array1, $array2) {
+ static function array_merge_noclobber($array1, $array2) {
if (!is_array($array1) || !is_array($array2)) {
return false;
}
@@ -392,7 +415,17 @@ class getid3_lib
}
- function fileextension($filename, $numextensions=1) {
+ static function ksort_recursive(&$theArray) {
+ ksort($theArray);
+ foreach ($theArray as $key => $value) {
+ if (is_array($value)) {
+ self::ksort_recursive($theArray[$key]);
+ }
+ }
+ return true;
+ }
+
+ static function fileextension($filename, $numextensions=1) {
if (strstr($filename, '.')) {
$reversedfilename = strrev($filename);
$offset = 0;
@@ -408,66 +441,40 @@ class getid3_lib
}
- function PlaytimeString($playtimeseconds) {
- $sign = (($playtimeseconds < 0) ? '-' : '');
- $playtimeseconds = abs($playtimeseconds);
- $contentseconds = round((($playtimeseconds / 60) - floor($playtimeseconds / 60)) * 60);
- $contentminutes = floor($playtimeseconds / 60);
- if ($contentseconds >= 60) {
- $contentseconds -= 60;
- $contentminutes++;
- }
- return $sign.intval($contentminutes).':'.str_pad($contentseconds, 2, 0, STR_PAD_LEFT);
- }
-
-
- function image_type_to_mime_type($imagetypeid) {
- // only available in PHP v4.3.0+
- static $image_type_to_mime_type = array();
- if (empty($image_type_to_mime_type)) {
- $image_type_to_mime_type[1] = 'image/gif'; // GIF
- $image_type_to_mime_type[2] = 'image/jpeg'; // JPEG
- $image_type_to_mime_type[3] = 'image/png'; // PNG
- $image_type_to_mime_type[4] = 'application/x-shockwave-flash'; // Flash
- $image_type_to_mime_type[5] = 'image/psd'; // PSD
- $image_type_to_mime_type[6] = 'image/bmp'; // BMP
- $image_type_to_mime_type[7] = 'image/tiff'; // TIFF: little-endian (Intel)
- $image_type_to_mime_type[8] = 'image/tiff'; // TIFF: big-endian (Motorola)
- //$image_type_to_mime_type[9] = 'image/jpc'; // JPC
- //$image_type_to_mime_type[10] = 'image/jp2'; // JPC
- //$image_type_to_mime_type[11] = 'image/jpx'; // JPC
- //$image_type_to_mime_type[12] = 'image/jb2'; // JPC
- $image_type_to_mime_type[13] = 'application/x-shockwave-flash'; // Shockwave
- $image_type_to_mime_type[14] = 'image/iff'; // IFF
- }
- return (isset($image_type_to_mime_type[$imagetypeid]) ? $image_type_to_mime_type[$imagetypeid] : 'application/octet-stream');
+ static function PlaytimeString($seconds) {
+ $sign = (($seconds < 0) ? '-' : '');
+ $seconds = abs($seconds);
+ $H = floor( $seconds / 3600);
+ $M = floor(($seconds - (3600 * $H) ) / 60);
+ $S = round( $seconds - (3600 * $H) - (60 * $M) );
+ return $sign.($H ? $H.':' : '').($H ? str_pad($M, 2, '0', STR_PAD_LEFT) : intval($M)).':'.str_pad($S, 2, 0, STR_PAD_LEFT);
}
- function DateMac2Unix($macdate) {
+ static function DateMac2Unix($macdate) {
// Macintosh timestamp: seconds since 00:00h January 1, 1904
// UNIX timestamp: seconds since 00:00h January 1, 1970
return getid3_lib::CastAsInt($macdate - 2082844800);
}
- function FixedPoint8_8($rawdata) {
+ static function FixedPoint8_8($rawdata) {
return getid3_lib::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
}
- function FixedPoint16_16($rawdata) {
+ static function FixedPoint16_16($rawdata) {
return getid3_lib::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
}
- function FixedPoint2_30($rawdata) {
+ static function FixedPoint2_30($rawdata) {
$binarystring = getid3_lib::BigEndian2Bin($rawdata);
- return getid3_lib::Bin2Dec(substr($binarystring, 0, 2)) + (float) (getid3_lib::Bin2Dec(substr($binarystring, 2, 30)) / 1073741824);
+ return getid3_lib::Bin2Dec(substr($binarystring, 0, 2)) + (float) (getid3_lib::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
}
- function CreateDeepArray($ArrayPath, $Separator, $Value) {
+ static function CreateDeepArray($ArrayPath, $Separator, $Value) {
// assigns $Value to a nested array path:
// $foo = getid3_lib::CreateDeepArray('/path/to/my', '/', 'file.txt')
// is the same as:
@@ -485,7 +492,7 @@ class getid3_lib
return $ReturnedArray;
}
- function array_max($arraydata, $returnkey=false) {
+ static function array_max($arraydata, $returnkey=false) {
$maxvalue = false;
$maxkey = false;
foreach ($arraydata as $key => $value) {
@@ -499,7 +506,7 @@ class getid3_lib
return ($returnkey ? $maxkey : $maxvalue);
}
- function array_min($arraydata, $returnkey=false) {
+ static function array_min($arraydata, $returnkey=false) {
$minvalue = false;
$minkey = false;
foreach ($arraydata as $key => $value) {
@@ -513,82 +520,35 @@ class getid3_lib
return ($returnkey ? $minkey : $minvalue);
}
-
- function md5_file($file) {
-
- // md5_file() exists in PHP 4.2.0+.
- if (function_exists('md5_file')) {
- return md5_file($file);
- }
-
- if (GETID3_OS_ISWINDOWS) {
-
- $RequiredFiles = array('cygwin1.dll', 'md5sum.exe');
- foreach ($RequiredFiles as $required_file) {
- if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
- die(implode(' and ', $RequiredFiles).' are required in '.GETID3_HELPERAPPSDIR.' for getid3_lib::md5_file() to function under Windows in PHP < v4.2.0');
- }
- }
- $commandline = GETID3_HELPERAPPSDIR.'md5sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"';
- if (ereg("^[\\]?([0-9a-f]{32})", strtolower(`$commandline`), $r)) {
- return $r[1];
- }
-
- } else {
-
- // The following works under UNIX only
- $file = str_replace('`', '\\`', $file);
- if (ereg("^([0-9a-f]{32})[ \t\n\r]", `md5sum "$file"`, $r)) {
- return $r[1];
+ static function XML2array($XMLstring) {
+ if (function_exists('simplexml_load_string')) {
+ if (function_exists('get_object_vars')) {
+ $XMLobject = simplexml_load_string($XMLstring);
+ return self::SimpleXMLelement2array($XMLobject);
}
-
}
return false;
}
-
- function sha1_file($file) {
-
- // sha1_file() exists in PHP 4.3.0+.
- if (function_exists('sha1_file')) {
- return sha1_file($file);
+ static function SimpleXMLelement2array($XMLobject) {
+ if (!is_object($XMLobject) && !is_array($XMLobject)) {
+ return $XMLobject;
}
-
- $file = str_replace('`', '\\`', $file);
-
- if (GETID3_OS_ISWINDOWS) {
-
- $RequiredFiles = array('cygwin1.dll', 'sha1sum.exe');
- foreach ($RequiredFiles as $required_file) {
- if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
- die(implode(' and ', $RequiredFiles).' are required in '.GETID3_HELPERAPPSDIR.' for getid3_lib::sha1_file() to function under Windows in PHP < v4.3.0');
- }
- }
- $commandline = GETID3_HELPERAPPSDIR.'sha1sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"';
- if (ereg("^sha1=([0-9a-f]{40})", strtolower(`$commandline`), $r)) {
- return $r[1];
- }
-
- } else {
-
- $commandline = 'sha1sum '.escapeshellarg($file).'';
- if (ereg("^([0-9a-f]{40})[ \t\n\r]", strtolower(`$commandline`), $r)) {
- return $r[1];
- }
-
+ $XMLarray = (is_object($XMLobject) ? get_object_vars($XMLobject) : $XMLobject);
+ foreach ($XMLarray as $key => $value) {
+ $XMLarray[$key] = self::SimpleXMLelement2array($value);
}
-
- return false;
+ return $XMLarray;
}
// Allan Hansen <ahØartemis*dk>
// getid3_lib::md5_data() - returns md5sum for a file from startuing position to absolute end position
- function hash_data($file, $offset, $end, $algorithm) {
- if ($end >= pow(2, 31)) {
+ static function hash_data($file, $offset, $end, $algorithm) {
+ static $tempdir = '';
+ if (!getid3_lib::intValueSupported($end)) {
return false;
}
-
switch ($algorithm) {
case 'md5':
$hash_function = 'md5_file';
@@ -605,7 +565,7 @@ class getid3_lib
break;
default:
- die('Invalid algorithm ('.$algorithm.') in getid3_lib::hash_data()');
+ throw new Exception('Invalid algorithm ('.$algorithm.') in getid3_lib::hash_data()');
break;
}
$size = $end - $offset;
@@ -636,16 +596,23 @@ class getid3_lib
$commandline .= $unix_call;
}
- if ((bool) ini_get('safe_mode')) {
- $ThisFileInfo['warning'][] = 'PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm';
+ if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
+ //throw new Exception('PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm');
break;
}
return substr(`$commandline`, 0, $hash_length);
}
+ if (empty($tempdir)) {
+ // yes this is ugly, feel free to suggest a better way
+ require_once(dirname(__FILE__).'/getid3.php');
+ $getid3_temp = new getID3();
+ $tempdir = $getid3_temp->tempdir;
+ unset($getid3_temp);
+ }
// try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
- if (($data_filename = tempnam('*', 'getID3')) === false) {
- // can't find anywhere to create a temp file, just die
+ if (($data_filename = tempnam($tempdir, 'gI3')) === false) {
+ // can't find anywhere to create a temp file, just fail
return false;
}
@@ -653,52 +620,68 @@ class getid3_lib
$result = false;
// copy parts of file
- if ($fp = @fopen($file, 'rb')) {
-
- if ($fp_data = @fopen($data_filename, 'wb')) {
-
- fseek($fp, $offset, SEEK_SET);
- $byteslefttowrite = $end - $offset;
- while (($byteslefttowrite > 0) && ($buffer = fread($fp, GETID3_FREAD_BUFFER_SIZE))) {
- $byteswritten = fwrite($fp_data, $buffer, $byteslefttowrite);
- $byteslefttowrite -= $byteswritten;
- }
- fclose($fp_data);
- $result = getid3_lib::$hash_function($data_filename);
-
- }
- fclose($fp);
+ try {
+ getid3_lib::CopyFileParts($file, $data_filename, $offset, $end - $offset);
+ $result = $hash_function($data_filename);
+ } catch (Exception $e) {
+ throw new Exception('getid3_lib::CopyFileParts() failed in getid_lib::hash_data(): '.$e->getMessage());
}
unlink($data_filename);
return $result;
}
+ static function CopyFileParts($filename_source, $filename_dest, $offset, $length) {
+ if (!getid3_lib::intValueSupported($offset + $length)) {
+ throw new Exception('cannot copy file portion, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
+ }
+ if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) {
+ if (($fp_dest = fopen($filename_dest, 'wb'))) {
+ if (fseek($fp_src, $offset, SEEK_SET) == 0) {
+ $byteslefttowrite = $length;
+ while (($byteslefttowrite > 0) && ($buffer = fread($fp_src, min($byteslefttowrite, getID3::FREAD_BUFFER_SIZE)))) {
+ $byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite);
+ $byteslefttowrite -= $byteswritten;
+ }
+ return true;
+ } else {
+ throw new Exception('failed to seek to offset '.$offset.' in '.$filename_source);
+ }
+ fclose($fp_dest);
+ } else {
+ throw new Exception('failed to create file for writing '.$filename_dest);
+ }
+ fclose($fp_src);
+ } else {
+ throw new Exception('failed to open file for reading '.$filename_source);
+ }
+ return false;
+ }
- function iconv_fallback_int_utf8($charval) {
+ static function iconv_fallback_int_utf8($charval) {
if ($charval < 128) {
// 0bbbbbbb
$newcharstring = chr($charval);
} elseif ($charval < 2048) {
// 110bbbbb 10bbbbbb
- $newcharstring = chr(($charval >> 6) | 0xC0);
+ $newcharstring = chr(($charval >> 6) | 0xC0);
$newcharstring .= chr(($charval & 0x3F) | 0x80);
} elseif ($charval < 65536) {
// 1110bbbb 10bbbbbb 10bbbbbb
- $newcharstring = chr(($charval >> 12) | 0xE0);
- $newcharstring .= chr(($charval >> 6) | 0xC0);
+ $newcharstring = chr(($charval >> 12) | 0xE0);
+ $newcharstring .= chr(($charval >> 6) | 0xC0);
$newcharstring .= chr(($charval & 0x3F) | 0x80);
} else {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
- $newcharstring = chr(($charval >> 18) | 0xF0);
- $newcharstring .= chr(($charval >> 12) | 0xC0);
- $newcharstring .= chr(($charval >> 6) | 0xC0);
+ $newcharstring = chr(($charval >> 18) | 0xF0);
+ $newcharstring .= chr(($charval >> 12) | 0xC0);
+ $newcharstring .= chr(($charval >> 6) | 0xC0);
$newcharstring .= chr(($charval & 0x3F) | 0x80);
}
return $newcharstring;
}
// ISO-8859-1 => UTF-8
- function iconv_fallback_iso88591_utf8($string, $bom=false) {
+ static function iconv_fallback_iso88591_utf8($string, $bom=false) {
if (function_exists('utf8_encode')) {
return utf8_encode($string);
}
@@ -715,7 +698,7 @@ class getid3_lib
}
// ISO-8859-1 => UTF-16BE
- function iconv_fallback_iso88591_utf16be($string, $bom=false) {
+ static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFE\xFF";
@@ -727,7 +710,7 @@ class getid3_lib
}
// ISO-8859-1 => UTF-16LE
- function iconv_fallback_iso88591_utf16le($string, $bom=false) {
+ static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFF\xFE";
@@ -739,12 +722,12 @@ class getid3_lib
}
// ISO-8859-1 => UTF-16LE (BOM)
- function iconv_fallback_iso88591_utf16($string) {
+ static function iconv_fallback_iso88591_utf16($string) {
return getid3_lib::iconv_fallback_iso88591_utf16le($string, true);
}
// UTF-8 => ISO-8859-1
- function iconv_fallback_utf8_iso88591($string) {
+ static function iconv_fallback_utf8_iso88591($string) {
if (function_exists('utf8_decode')) {
return utf8_decode($string);
}
@@ -756,20 +739,20 @@ class getid3_lib
if ((ord($string{$offset}) | 0x07) == 0xF7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
- (ord($string{($offset + 3)}) & 0x3F);
+ ((ord($string{($offset + 1)}) & 0x3F) << 12) &
+ ((ord($string{($offset + 2)}) & 0x3F) << 6) &
+ (ord($string{($offset + 3)}) & 0x3F);
$offset += 4;
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
- (ord($string{($offset + 2)}) & 0x3F);
+ ((ord($string{($offset + 1)}) & 0x3F) << 6) &
+ (ord($string{($offset + 2)}) & 0x3F);
$offset += 3;
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
// 110bbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
- (ord($string{($offset + 1)}) & 0x3F);
+ (ord($string{($offset + 1)}) & 0x3F);
$offset += 2;
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
// 0bbbbbbb
@@ -788,7 +771,7 @@ class getid3_lib
}
// UTF-8 => UTF-16BE
- function iconv_fallback_utf8_utf16be($string, $bom=false) {
+ static function iconv_fallback_utf8_utf16be($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFE\xFF";
@@ -799,20 +782,20 @@ class getid3_lib
if ((ord($string{$offset}) | 0x07) == 0xF7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
- (ord($string{($offset + 3)}) & 0x3F);
+ ((ord($string{($offset + 1)}) & 0x3F) << 12) &
+ ((ord($string{($offset + 2)}) & 0x3F) << 6) &
+ (ord($string{($offset + 3)}) & 0x3F);
$offset += 4;
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
- (ord($string{($offset + 2)}) & 0x3F);
+ ((ord($string{($offset + 1)}) & 0x3F) << 6) &
+ (ord($string{($offset + 2)}) & 0x3F);
$offset += 3;
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
// 110bbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
- (ord($string{($offset + 1)}) & 0x3F);
+ (ord($string{($offset + 1)}) & 0x3F);
$offset += 2;
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
// 0bbbbbbb
@@ -831,7 +814,7 @@ class getid3_lib
}
// UTF-8 => UTF-16LE
- function iconv_fallback_utf8_utf16le($string, $bom=false) {
+ static function iconv_fallback_utf8_utf16le($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFF\xFE";
@@ -842,20 +825,20 @@ class getid3_lib
if ((ord($string{$offset}) | 0x07) == 0xF7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
- (ord($string{($offset + 3)}) & 0x3F);
+ ((ord($string{($offset + 1)}) & 0x3F) << 12) &
+ ((ord($string{($offset + 2)}) & 0x3F) << 6) &
+ (ord($string{($offset + 3)}) & 0x3F);
$offset += 4;
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
- (ord($string{($offset + 2)}) & 0x3F);
+ ((ord($string{($offset + 1)}) & 0x3F) << 6) &
+ (ord($string{($offset + 2)}) & 0x3F);
$offset += 3;
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
// 110bbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
- (ord($string{($offset + 1)}) & 0x3F);
+ (ord($string{($offset + 1)}) & 0x3F);
$offset += 2;
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
// 0bbbbbbb
@@ -874,12 +857,12 @@ class getid3_lib
}
// UTF-8 => UTF-16LE (BOM)
- function iconv_fallback_utf8_utf16($string) {
+ static function iconv_fallback_utf8_utf16($string) {
return getid3_lib::iconv_fallback_utf8_utf16le($string, true);
}
// UTF-16BE => UTF-8
- function iconv_fallback_utf16be_utf8($string) {
+ static function iconv_fallback_utf16be_utf8($string) {
if (substr($string, 0, 2) == "\xFE\xFF") {
// strip BOM
$string = substr($string, 2);
@@ -893,7 +876,7 @@ class getid3_lib
}
// UTF-16LE => UTF-8
- function iconv_fallback_utf16le_utf8($string) {
+ static function iconv_fallback_utf16le_utf8($string) {
if (substr($string, 0, 2) == "\xFF\xFE") {
// strip BOM
$string = substr($string, 2);
@@ -907,7 +890,7 @@ class getid3_lib
}
// UTF-16BE => ISO-8859-1
- function iconv_fallback_utf16be_iso88591($string) {
+ static function iconv_fallback_utf16be_iso88591($string) {
if (substr($string, 0, 2) == "\xFE\xFF") {
// strip BOM
$string = substr($string, 2);
@@ -921,7 +904,7 @@ class getid3_lib
}
// UTF-16LE => ISO-8859-1
- function iconv_fallback_utf16le_iso88591($string) {
+ static function iconv_fallback_utf16le_iso88591($string) {
if (substr($string, 0, 2) == "\xFF\xFE") {
// strip BOM
$string = substr($string, 2);
@@ -935,7 +918,7 @@ class getid3_lib
}
// UTF-16 (BOM) => ISO-8859-1
- function iconv_fallback_utf16_iso88591($string) {
+ static function iconv_fallback_utf16_iso88591($string) {
$bom = substr($string, 0, 2);
if ($bom == "\xFE\xFF") {
return getid3_lib::iconv_fallback_utf16be_iso88591(substr($string, 2));
@@ -946,7 +929,7 @@ class getid3_lib
}
// UTF-16 (BOM) => UTF-8
- function iconv_fallback_utf16_utf8($string) {
+ static function iconv_fallback_utf16_utf8($string) {
$bom = substr($string, 0, 2);
if ($bom == "\xFE\xFF") {
return getid3_lib::iconv_fallback_utf16be_utf8(substr($string, 2));
@@ -956,7 +939,7 @@ class getid3_lib
return $string;
}
- function iconv_fallback($in_charset, $out_charset, $string) {
+ static function iconv_fallback($in_charset, $out_charset, $string) {
if ($in_charset == $out_charset) {
return $string;
@@ -964,23 +947,22 @@ class getid3_lib
// iconv() availble
if (function_exists('iconv')) {
+ if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
+ switch ($out_charset) {
+ case 'ISO-8859-1':
+ $converted_string = rtrim($converted_string, "\x00");
+ break;
+ }
+ return $converted_string;
+ }
- if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
- switch ($out_charset) {
- case 'ISO-8859-1':
- $converted_string = rtrim($converted_string, "\x00");
- break;
- }
- return $converted_string;
- }
-
- // iconv() may sometimes fail with "illegal character in input string" error message
- // and return an empty string, but returning the unconverted string is more useful
- return $string;
- }
+ // iconv() may sometimes fail with "illegal character in input string" error message
+ // and return an empty string, but returning the unconverted string is more useful
+ return $string;
+ }
- // iconv() not available
+ // iconv() not available
static $ConversionFunctionList = array();
if (empty($ConversionFunctionList)) {
$ConversionFunctionList['ISO-8859-1']['UTF-8'] = 'iconv_fallback_iso88591_utf8';
@@ -1002,41 +984,42 @@ class getid3_lib
$ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
return getid3_lib::$ConversionFunction($string);
}
- die('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
+ throw new Exception('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
}
static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
+ $string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string
$HTMLstring = '';
switch ($charset) {
- case 'ISO-8859-1':
- case 'ISO8859-1':
- case 'ISO-8859-15':
- case 'ISO8859-15':
- case 'cp866':
- case 'ibm866':
+ case '1251':
+ case '1252':
case '866':
+ case '932':
+ case '936':
+ case '950':
+ case 'BIG5':
+ case 'BIG5-HKSCS':
case 'cp1251':
- case 'Windows-1251':
- case 'win-1251':
- case '1251':
case 'cp1252':
- case 'Windows-1252':
- case '1252':
+ case 'cp866':
+ case 'EUC-JP':
+ case 'EUCJP':
+ case 'GB2312':
+ case 'ibm866':
+ case 'ISO-8859-1':
+ case 'ISO-8859-15':
+ case 'ISO8859-1':
+ case 'ISO8859-15':
case 'KOI8-R':
case 'koi8-ru':
case 'koi8r':
- case 'BIG5':
- case '950':
- case 'GB2312':
- case '936':
- case 'BIG5-HKSCS':
case 'Shift_JIS':
case 'SJIS':
- case '932':
- case 'EUC-JP':
- case 'EUCJP':
+ case 'win-1251':
+ case 'Windows-1251':
+ case 'Windows-1252':
$HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
break;
@@ -1099,7 +1082,7 @@ class getid3_lib
- function RGADnameLookup($namecode) {
+ static function RGADnameLookup($namecode) {
static $RGADname = array();
if (empty($RGADname)) {
$RGADname[0] = 'not set';
@@ -1111,7 +1094,7 @@ class getid3_lib
}
- function RGADoriginatorLookup($originatorcode) {
+ static function RGADoriginatorLookup($originatorcode) {
static $RGADoriginator = array();
if (empty($RGADoriginator)) {
$RGADoriginator[0] = 'unspecified';
@@ -1124,7 +1107,7 @@ class getid3_lib
}
- function RGADadjustmentLookup($rawadjustment, $signbit) {
+ static function RGADadjustmentLookup($rawadjustment, $signbit) {
$adjustment = $rawadjustment / 10;
if ($signbit == 1) {
$adjustment *= -1;
@@ -1133,7 +1116,7 @@ class getid3_lib
}
- function RGADgainString($namecode, $originatorcode, $replaygain) {
+ static function RGADgainString($namecode, $originatorcode, $replaygain) {
if ($replaygain < 0) {
$signbit = '1';
} else {
@@ -1148,15 +1131,23 @@ class getid3_lib
return $gainstring;
}
- function RGADamplitude2dB($amplitude) {
+ static function RGADamplitude2dB($amplitude) {
return 20 * log10($amplitude);
}
- function GetDataImageSize($imgData, &$imageinfo) {
+ static function GetDataImageSize($imgData, &$imageinfo) {
+ static $tempdir = '';
+ if (empty($tempdir)) {
+ // yes this is ugly, feel free to suggest a better way
+ require_once(dirname(__FILE__).'/getid3.php');
+ $getid3_temp = new getID3();
+ $tempdir = $getid3_temp->tempdir;
+ unset($getid3_temp);
+ }
$GetDataImageSize = false;
- if ($tempfilename = tempnam('*', 'getID3')) {
- if ($tmp = @fopen($tempfilename, 'wb')) {
+ if ($tempfilename = tempnam($tempdir, 'gI3')) {
+ if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename, 'wb'))) {
fwrite($tmp, $imgData);
fclose($tmp);
$GetDataImageSize = @GetImageSize($tempfilename, $imageinfo);
@@ -1166,7 +1157,7 @@ class getid3_lib
return $GetDataImageSize;
}
- function ImageTypesLookup($imagetypeid) {
+ static function ImageTypesLookup($imagetypeid) {
static $ImageTypesLookup = array();
if (empty($ImageTypesLookup)) {
$ImageTypesLookup[1] = 'gif';
@@ -1210,7 +1201,7 @@ class getid3_lib
}
}
- } else {
+ } elseif (!is_array($value)) {
$newvaluelength = strlen(trim($value));
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
@@ -1222,8 +1213,9 @@ class getid3_lib
}
}
- if (empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
- $ThisFileInfo['comments'][$tagname][] = trim($value);
+ if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
+ $value = (is_string($value) ? trim($value) : $value);
+ $ThisFileInfo['comments'][$tagname][] = $value;
}
}
}
@@ -1231,21 +1223,31 @@ class getid3_lib
}
// Copy to ['comments_html']
- foreach ($ThisFileInfo['comments'] as $field => $values) {
- foreach ($values as $index => $value) {
- $ThisFileInfo['comments_html'][$field][$index] = str_replace('&#0;', '', getid3_lib::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
- }
- }
+ foreach ($ThisFileInfo['comments'] as $field => $values) {
+ if ($field == 'picture') {
+ // pictures can take up a lot of space, and we don't need multiple copies of them
+ // let there be a single copy in [comments][picture], and not elsewhere
+ continue;
+ }
+ foreach ($values as $index => $value) {
+ if (is_array($value)) {
+ $ThisFileInfo['comments_html'][$field][$index] = $value;
+ } else {
+ $ThisFileInfo['comments_html'][$field][$index] = str_replace('&#0;', '', getid3_lib::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
+ }
+ }
+ }
}
+ return true;
}
- function EmbeddedLookup($key, $begin, $end, $file, $name) {
+ static function EmbeddedLookup($key, $begin, $end, $file, $name) {
// Cached
static $cache;
if (isset($cache[$file][$name])) {
- return @$cache[$file][$name][$key];
+ return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
}
// Init
@@ -1275,20 +1277,22 @@ class getid3_lib
// METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
//$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
- @list($ThisKey, $ThisValue) = explode("\t", $line, 2);
+ $explodedLine = explode("\t", $line, 2);
+ $ThisKey = (isset($explodedLine[0]) ? $explodedLine[0] : '');
+ $ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : '');
$cache[$file][$name][$ThisKey] = trim($ThisValue);
}
// Close and return
fclose($fp);
- return @$cache[$file][$name][$key];
+ return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
}
- function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
+ static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
global $GETID3_ERRORARRAY;
if (file_exists($filename)) {
- if (@include_once($filename)) {
+ if (include_once($filename)) {
return true;
} else {
$diemessage = basename($sourcefile).' depends on '.$filename.', which has errors';
@@ -1297,13 +1301,17 @@ class getid3_lib
$diemessage = basename($sourcefile).' depends on '.$filename.', which is missing';
}
if ($DieOnFailure) {
- die($diemessage);
+ throw new Exception($diemessage);
} else {
$GETID3_ERRORARRAY[] = $diemessage;
}
return false;
}
+ public static function trimNullByte($string) {
+ return trim($string, "\x00");
+ }
+
}
?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/getid3.php b/3rdparty/getid3/getid3.php
index f9dcf706d0a..e8a3f7e2de6 100644
--- a/apps/media/getID3/getid3/getid3.php
+++ b/3rdparty/getid3/getid3.php
@@ -9,91 +9,164 @@
// ///
/////////////////////////////////////////////////////////////////
-// Defines
-define('GETID3_VERSION', '1.7.9-20090308');
-define('GETID3_FREAD_BUFFER_SIZE', 16384); // read buffer size in bytes
+// attempt to define temp dir as something flexible but reliable
+$temp_dir = ini_get('upload_tmp_dir');
+if ($temp_dir && (!is_dir($temp_dir) || !is_readable($temp_dir))) {
+ $temp_dir = '';
+}
+if (!$temp_dir && function_exists('sys_get_temp_dir')) {
+ // PHP v5.2.1+
+ // sys_get_temp_dir() may give inaccessible temp dir, e.g. with open_basedir on virtual hosts
+ $temp_dir = sys_get_temp_dir();
+}
+$temp_dir = realpath($temp_dir);
+$open_basedir = ini_get('open_basedir');
+if ($open_basedir) {
+ // e.g. "/var/www/vhosts/getid3.org/httpdocs/:/tmp/"
+ $temp_dir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $temp_dir);
+ $open_basedir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $open_basedir);
+ if (substr($temp_dir, -1, 1) != DIRECTORY_SEPARATOR) {
+ $temp_dir .= DIRECTORY_SEPARATOR;
+ }
+ $found_valid_tempdir = false;
+ $open_basedirs = explode(':', $open_basedir);
+ foreach ($open_basedirs as $basedir) {
+ if (substr($basedir, -1, 1) != DIRECTORY_SEPARATOR) {
+ $basedir .= DIRECTORY_SEPARATOR;
+ }
+ if (preg_match('#^'.preg_quote($basedir).'#', $temp_dir)) {
+ $found_valid_tempdir = true;
+ break;
+ }
+ }
+ if (!$found_valid_tempdir) {
+ $temp_dir = '';
+ }
+ unset($open_basedirs, $found_valid_tempdir, $basedir);
+}
+if (!$temp_dir) {
+ $temp_dir = '*'; // invalid directory name should force tempnam() to use system default temp dir
+}
+// $temp_dir = '/something/else/'; // feel free to override temp dir here if it works better for your system
+define('GETID3_TEMP_DIR', $temp_dir);
+unset($open_basedir, $temp_dir);
+
+
+// define a constant rather than looking up every time it is needed
+if (!defined('GETID3_OS_ISWINDOWS')) {
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ define('GETID3_OS_ISWINDOWS', true);
+ } else {
+ define('GETID3_OS_ISWINDOWS', false);
+ }
+}
+// Get base path of getID3() - ONCE
+if (!defined('GETID3_INCLUDEPATH')) {
+ foreach (get_included_files() as $key => $val) {
+ if (basename($val) == 'getid3.php') {
+ define('GETID3_INCLUDEPATH', dirname($val).DIRECTORY_SEPARATOR);
+ break;
+ }
+ }
+}
+
+// End: Defines
class getID3
{
// public: Settings
- var $encoding = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv())
- // Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
-
- var $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN'
-
- var $tempdir = '*'; // default '*' should use system temp dir
+ public $encoding = 'UTF-8'; // CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
+ public $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN' or 'CP1252'
// public: Optional tag checks - disable for speed.
- var $option_tag_id3v1 = true; // Read and process ID3v1 tags
- var $option_tag_id3v2 = true; // Read and process ID3v2 tags
- var $option_tag_lyrics3 = true; // Read and process Lyrics3 tags
- var $option_tag_apetag = true; // Read and process APE tags
- var $option_tags_process = true; // Copy tags to root key 'tags' and encode to $this->encoding
- var $option_tags_html = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
+ public $option_tag_id3v1 = true; // Read and process ID3v1 tags
+ public $option_tag_id3v2 = true; // Read and process ID3v2 tags
+ public $option_tag_lyrics3 = true; // Read and process Lyrics3 tags
+ public $option_tag_apetag = true; // Read and process APE tags
+ public $option_tags_process = true; // Copy tags to root key 'tags' and encode to $this->encoding
+ public $option_tags_html = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
// public: Optional tag/comment calucations
- var $option_extra_info = true; // Calculate additional info such as bitrate, channelmode etc
+ public $option_extra_info = true; // Calculate additional info such as bitrate, channelmode etc
+
+ // public: Optional handling of embedded attachments (e.g. images)
+ public $option_save_attachments = true; // defaults to true (ATTACHMENTS_INLINE) for backward compatibility
// public: Optional calculations
- var $option_md5_data = false; // Get MD5 sum of data part - slow
- var $option_md5_data_source = false; // Use MD5 of source file if availble - only FLAC and OptimFROG
- var $option_sha1_data = false; // Get SHA1 sum of data part - slow
- var $option_max_2gb_check = true; // Check whether file is larger than 2 Gb and thus not supported by PHP
+ public $option_md5_data = false; // Get MD5 sum of data part - slow
+ public $option_md5_data_source = false; // Use MD5 of source file if availble - only FLAC and OptimFROG
+ public $option_sha1_data = false; // Get SHA1 sum of data part - slow
+ public $option_max_2gb_check = null; // Check whether file is larger than 2GB and thus not supported by 32-bit PHP (null: auto-detect based on PHP_INT_MAX)
- // private
- var $filename;
+ // public: Read buffer size in bytes
+ public $option_fread_buffer_size = 32768;
+ // Public variables
+ public $filename; // Filename of file being analysed.
+ public $fp; // Filepointer to file being analysed.
+ public $info; // Result array.
- // public: constructor
- function getID3()
- {
+ // Protected variables
+ protected $startup_error = '';
+ protected $startup_warning = '';
+ protected $memory_limit = 0;
+
+ const VERSION = '1.9.3-20111213';
+ const FREAD_BUFFER_SIZE = 32768;
+ var $tempdir = GETID3_TEMP_DIR;
+
+ const ATTACHMENTS_NONE = false;
+ const ATTACHMENTS_INLINE = true;
- $this->startup_error = '';
- $this->startup_warning = '';
+ // public: constructor
+ public function __construct() {
- // Check for PHP version >= 4.2.0
- if (phpversion() < '4.2.0') {
- $this->startup_error .= 'getID3() requires PHP v4.2.0 or higher - you are running v'.phpversion();
+ // Check for PHP version
+ $required_php_version = '5.0.5';
+ if (version_compare(PHP_VERSION, $required_php_version, '<')) {
+ $this->startup_error .= 'getID3() requires PHP v'.$required_php_version.' or higher - you are running v'.PHP_VERSION;
+ return false;
}
// Check memory
- $memory_limit = ini_get('memory_limit');
- if (eregi('([0-9]+)M', $memory_limit, $matches)) {
+ $this->memory_limit = ini_get('memory_limit');
+ if (preg_match('#([0-9]+)M#i', $this->memory_limit, $matches)) {
// could be stored as "16M" rather than 16777216 for example
- $memory_limit = $matches[1] * 1048576;
+ $this->memory_limit = $matches[1] * 1048576;
+ } elseif (preg_match('#([0-9]+)G#i', $this->memory_limit, $matches)) { // The 'G' modifier is available since PHP 5.1.0
+ // could be stored as "2G" rather than 2147483648 for example
+ $this->memory_limit = $matches[1] * 1073741824;
}
- if ($memory_limit <= 0) {
+ if ($this->memory_limit <= 0) {
// memory limits probably disabled
- } elseif ($memory_limit <= 3145728) {
- $this->startup_error .= 'PHP has less than 3MB available memory and will very likely run out. Increase memory_limit in php.ini';
- } elseif ($memory_limit <= 12582912) {
- $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
+ } elseif ($this->memory_limit <= 4194304) {
+ $this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini';
+ } elseif ($this->memory_limit <= 12582912) {
+ $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
}
// Check safe_mode off
- if ((bool) ini_get('safe_mode')) {
- $this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
+ if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
+ $this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
}
+ if (intval(ini_get('mbstring.func_overload')) > 0) {
+ $this->warning('WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", this may break things.');
+ }
- // define a constant rather than looking up every time it is needed
- if (!defined('GETID3_OS_ISWINDOWS')) {
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- define('GETID3_OS_ISWINDOWS', true);
- } else {
- define('GETID3_OS_ISWINDOWS', false);
+ // Check for magic_quotes_runtime
+ if (function_exists('get_magic_quotes_runtime')) {
+ if (get_magic_quotes_runtime()) {
+ return $this->startup_error('magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).');
}
}
- // Get base path of getID3() - ONCE
- if (!defined('GETID3_INCLUDEPATH')) {
- foreach (get_included_files() as $key => $val) {
- if (basename($val) == 'getid3.php') {
- define('GETID3_INCLUDEPATH', dirname($val).DIRECTORY_SEPARATOR);
- break;
- }
+ // Check for magic_quotes_gpc
+ if (function_exists('magic_quotes_gpc')) {
+ if (get_magic_quotes_gpc()) {
+ return $this->startup_error('magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).');
}
}
@@ -102,36 +175,61 @@ class getID3
$this->startup_error .= 'getid3.lib.php is missing or corrupt';
}
+ if ($this->option_max_2gb_check === null) {
+ $this->option_max_2gb_check = (PHP_INT_MAX <= 2147483647);
+ }
+
// Needed for Windows only:
// Define locations of helper applications for Shorten, VorbisComment, MetaFLAC
// as well as other helper functions such as head, tail, md5sum, etc
- // IMPORTANT: This path cannot have spaces in it. If neccesary, use the 8dot3 equivalent
- // ie for "C:/Program Files/Apache/" put "C:/PROGRA~1/APACHE/"
+ // This path cannot contain spaces, but the below code will attempt to get the
+ // 8.3-equivalent path automatically
// IMPORTANT: This path must include the trailing slash
if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
$helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
if (!is_dir($helperappsdir)) {
- $this->startup_error .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
+ $this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
} elseif (strpos(realpath($helperappsdir), ' ') !== false) {
$DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
+ $path_so_far = array();
foreach ($DirPieces as $key => $value) {
- if ((strpos($value, '.') !== false) && (strpos($value, ' ') === false)) {
- if (strpos($value, '.') > 8) {
- $value = substr($value, 0, 6).'~1';
+ if (strpos($value, ' ') !== false) {
+ if (!empty($path_so_far)) {
+ $commandline = 'dir /x '.escapeshellarg(implode(DIRECTORY_SEPARATOR, $path_so_far));
+ $dir_listing = `$commandline`;
+ $lines = explode("\n", $dir_listing);
+ foreach ($lines as $line) {
+ $line = trim($line);
+ if (preg_match('#^([0-9/]{10}) +([0-9:]{4,5}( [AP]M)?) +(<DIR>|[0-9,]+) +([^ ]{0,11}) +(.+)$#', $line, $matches)) {
+ list($dummy, $date, $time, $ampm, $filesize, $shortname, $filename) = $matches;
+ if ((strtoupper($filesize) == '<DIR>') && (strtolower($filename) == strtolower($value))) {
+ $value = $shortname;
+ }
+ }
+ }
+ } else {
+ $this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.';
}
- } elseif ((strpos($value, ' ') !== false) || strlen($value) > 8) {
- $value = substr($value, 0, 6).'~1';
}
- $DirPieces[$key] = strtoupper($value);
+ $path_so_far[] = $value;
}
- $this->startup_error .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary (on this server that would be something like "'.implode(DIRECTORY_SEPARATOR, $DirPieces).'" - NOTE: this may or may not be the actual 8.3 equivalent of "'.$helperappsdir.'", please double-check). You can run "dir /x" from the commandline to see the correct 8.3-style names.';
+ $helperappsdir = implode(DIRECTORY_SEPARATOR, $path_so_far);
}
- define('GETID3_HELPERAPPSDIR', realpath($helperappsdir).DIRECTORY_SEPARATOR);
+ define('GETID3_HELPERAPPSDIR', $helperappsdir.DIRECTORY_SEPARATOR);
}
+ return true;
+ }
+
+ public function version() {
+ return self::VERSION;
+ }
+
+ public function fread_buffer_size() {
+ return $this->option_fread_buffer_size;
}
@@ -141,7 +239,6 @@ class getID3
return false;
}
foreach ($optArray as $opt => $val) {
- //if (isset($this, $opt) === false) {
if (isset($this->$opt) === false) {
continue;
}
@@ -151,265 +248,255 @@ class getID3
}
- // public: analyze file - replaces GetAllFileInfo() and GetTagOnly()
- function analyze($filename) {
+ public function openfile($filename) {
+ try {
+ if (!empty($this->startup_error)) {
+ throw new getid3_exception($this->startup_error);
+ }
+ if (!empty($this->startup_warning)) {
+ $this->warning($this->startup_warning);
+ }
- if (!empty($this->startup_error)) {
- return $this->error($this->startup_error);
- }
- if (!empty($this->startup_warning)) {
- $this->warning($this->startup_warning);
- }
+ // init result array and set parameters
+ $this->filename = $filename;
+ $this->info = array();
+ $this->info['GETID3_VERSION'] = $this->version();
+ $this->info['php_memory_limit'] = $this->memory_limit;
- // init result array and set parameters
- $this->info = array();
- $this->info['GETID3_VERSION'] = GETID3_VERSION;
+ // remote files not supported
+ if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
+ throw new getid3_exception('Remote files are not supported - please copy the file locally first');
+ }
- // Check encoding/iconv support
- if (!function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
- $errormessage = 'iconv() support is needed for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
- if (GETID3_OS_ISWINDOWS) {
- $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
+ $filename = str_replace('/', DIRECTORY_SEPARATOR, $filename);
+ $filename = preg_replace('#(.+)'.preg_quote(DIRECTORY_SEPARATOR).'{2,}#U', '\1'.DIRECTORY_SEPARATOR, $filename);
+
+ // open local file
+ if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) {
+ // great
} else {
- $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
+ throw new getid3_exception('Could not open "'.$filename.'" (does not exist, or is not a file)');
}
- return $this->error($errormessage);
- }
- // Disable magic_quotes_runtime, if neccesary
- $old_magic_quotes_runtime = get_magic_quotes_runtime(); // store current setting of magic_quotes_runtime
- if ($old_magic_quotes_runtime) {
- set_magic_quotes_runtime(0); // turn off magic_quotes_runtime
- if (get_magic_quotes_runtime()) {
- return $this->error('Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled');
+ $this->info['filesize'] = filesize($filename);
+ // set redundant parameters - might be needed in some include file
+ $this->info['filename'] = basename($filename);
+ $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
+ $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
+
+
+ // option_max_2gb_check
+ if ($this->option_max_2gb_check) {
+ // PHP (32-bit all, and 64-bit Windows) doesn't support integers larger than 2^31 (~2GB)
+ // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
+ // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
+ $fseek = fseek($this->fp, 0, SEEK_END);
+ if (($fseek < 0) || (($this->info['filesize'] != 0) && (ftell($this->fp) == 0)) ||
+ ($this->info['filesize'] < 0) ||
+ (ftell($this->fp) < 0)) {
+ $real_filesize = false;
+ if (GETID3_OS_ISWINDOWS) {
+ $commandline = 'dir /-C "'.str_replace('/', DIRECTORY_SEPARATOR, $filename).'"';
+ $dir_output = `$commandline`;
+ if (preg_match('#1 File\(s\)[ ]+([0-9]+) bytes#i', $dir_output, $matches)) {
+ $real_filesize = (float) $matches[1];
+ }
+ } else {
+ $commandline = 'ls -o -g -G --time-style=long-iso '.escapeshellarg($filename);
+ $dir_output = `$commandline`;
+ if (preg_match('#([0-9]+) ([0-9]{4}-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}) '.str_replace('#', '\\#', preg_quote($filename)).'$#', $dir_output, $matches)) {
+ $real_filesize = (float) $matches[1];
+ }
+ }
+ if ($real_filesize === false) {
+ unset($this->info['filesize']);
+ fclose($this->fp);
+ throw new getid3_exception('Unable to determine actual filesize. File is most likely larger than '.round(PHP_INT_MAX / 1073741824).'GB and is not supported by PHP.');
+ } elseif (getid3_lib::intValueSupported($real_filesize)) {
+ unset($this->info['filesize']);
+ fclose($this->fp);
+ throw new getid3_exception('PHP seems to think the file is larger than '.round(PHP_INT_MAX / 1073741824).'GB, but filesystem reports it as '.number_format($real_filesize, 3).'GB, please report to info@getid3.org');
+ }
+ $this->info['filesize'] = $real_filesize;
+ $this->error('File is larger than '.round(PHP_INT_MAX / 1073741824).'GB (filesystem reports it as '.number_format($real_filesize, 3).'GB) and is not properly supported by PHP.');
+ }
}
- }
- // remote files not supported
- if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
- return $this->error('Remote files are not supported in this version of getID3() - please copy the file locally first');
+ // set more parameters
+ $this->info['avdataoffset'] = 0;
+ $this->info['avdataend'] = $this->info['filesize'];
+ $this->info['fileformat'] = ''; // filled in later
+ $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
+ $this->info['video']['dataformat'] = ''; // filled in later, unset if not used
+ $this->info['tags'] = array(); // filled in later, unset if not used
+ $this->info['error'] = array(); // filled in later, unset if not used
+ $this->info['warning'] = array(); // filled in later, unset if not used
+ $this->info['comments'] = array(); // filled in later, unset if not used
+ $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
+
+ return true;
+
+ } catch (Exception $e) {
+ $this->error($e->getMessage());
}
+ return false;
+ }
- $filename = str_replace('/', DIRECTORY_SEPARATOR, $filename);
- $filename = preg_replace('#'.preg_quote(DIRECTORY_SEPARATOR).'{2,}#', DIRECTORY_SEPARATOR, $filename);
-
- // open local file
- if (file_exists($filename) && ($fp = @fopen($filename, 'rb'))) {
- // great
- } else {
- return $this->error('Could not open file "'.$filename.'"');
- }
+ // public: analyze file
+ function analyze($filename) {
+ try {
+ if (!$this->openfile($filename)) {
+ return $this->info;
+ }
- // set parameters
- $this->info['filesize'] = filesize($filename);
-
- // option_max_2gb_check
- if ($this->option_max_2gb_check) {
- // PHP doesn't support integers larger than 31-bit (~2GB)
- // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
- // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
- fseek($fp, 0, SEEK_END);
- if ((($this->info['filesize'] != 0) && (ftell($fp) == 0)) ||
- ($this->info['filesize'] < 0) ||
- (ftell($fp) < 0)) {
- $real_filesize = false;
- if (GETID3_OS_ISWINDOWS) {
- $commandline = 'dir /-C "'.str_replace('/', DIRECTORY_SEPARATOR, $filename).'"';
- $dir_output = `$commandline`;
- if (eregi('1 File\(s\)[ ]+([0-9]+) bytes', $dir_output, $matches)) {
- $real_filesize = (float) $matches[1];
- }
- } else {
- $commandline = 'ls -o -g -G --time-style=long-iso '.escapeshellarg($filename);
- $dir_output = `$commandline`;
- if (eregi('([0-9]+) ([0-9]{4}-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}) '.preg_quote($filename).'$', $dir_output, $matches)) {
- $real_filesize = (float) $matches[1];
- }
+ // Handle tags
+ foreach (array('id3v2'=>'id3v2', 'id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
+ $option_tag = 'option_tag_'.$tag_name;
+ if ($this->$option_tag) {
+ $this->include_module('tag.'.$tag_name);
+ try {
+ $tag_class = 'getid3_'.$tag_name;
+ $tag = new $tag_class($this);
+ $tag->Analyze();
}
- if ($real_filesize === false) {
- unset($this->info['filesize']);
- fclose($fp);
- return $this->error('File is most likely larger than 2GB and is not supported by PHP');
- } elseif ($real_filesize < pow(2, 31)) {
- unset($this->info['filesize']);
- fclose($fp);
- return $this->error('PHP seems to think the file is larger than 2GB, but filesystem reports it as '.number_format($real_filesize, 3).'GB, please report to info@getid3.org');
+ catch (getid3_exception $e) {
+ throw $e;
}
- $this->info['filesize'] = $real_filesize;
- $this->error('File is larger than 2GB (filesystem reports it as '.number_format($real_filesize, 3).'GB) and is not properly supported by PHP.');
+ }
}
- }
-
- // set more parameters
- $this->info['avdataoffset'] = 0;
- $this->info['avdataend'] = $this->info['filesize'];
- $this->info['fileformat'] = ''; // filled in later
- $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
- $this->info['video']['dataformat'] = ''; // filled in later, unset if not used
- $this->info['tags'] = array(); // filled in later, unset if not used
- $this->info['error'] = array(); // filled in later, unset if not used
- $this->info['warning'] = array(); // filled in later, unset if not used
- $this->info['comments'] = array(); // filled in later, unset if not used
- $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
-
- // set redundant parameters - might be needed in some include file
- $this->info['filename'] = basename($filename);
- $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
- $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
-
-
- // handle ID3v2 tag - done first - already at beginning of file
- // ID3v2 detection (even if not parsing) is always done otherwise fileformat is much harder to detect
- if ($this->option_tag_id3v2) {
-
- $GETID3_ERRORARRAY = &$this->info['warning'];
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, false)) {
- $tag = new getid3_id3v2($fp, $this->info);
- unset($tag);
+ if (isset($this->info['id3v2']['tag_offset_start'])) {
+ $this->info['avdataoffset'] = max($this->info['avdataoffset'], $this->info['id3v2']['tag_offset_end']);
+ }
+ foreach (array('id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
+ if (isset($this->info[$tag_key]['tag_offset_start'])) {
+ $this->info['avdataend'] = min($this->info['avdataend'], $this->info[$tag_key]['tag_offset_start']);
+ }
}
- } else {
-
- fseek($fp, 0, SEEK_SET);
- $header = fread($fp, 10);
- if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) {
- $this->info['id3v2']['header'] = true;
- $this->info['id3v2']['majorversion'] = ord($header{3});
- $this->info['id3v2']['minorversion'] = ord($header{4});
- $this->info['id3v2']['headerlength'] = getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
-
- $this->info['id3v2']['tag_offset_start'] = 0;
- $this->info['id3v2']['tag_offset_end'] = $this->info['id3v2']['tag_offset_start'] + $this->info['id3v2']['headerlength'];
- $this->info['avdataoffset'] = $this->info['id3v2']['tag_offset_end'];
+ // ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier
+ if (!$this->option_tag_id3v2) {
+ fseek($this->fp, 0, SEEK_SET);
+ $header = fread($this->fp, 10);
+ if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) {
+ $this->info['id3v2']['header'] = true;
+ $this->info['id3v2']['majorversion'] = ord($header{3});
+ $this->info['id3v2']['minorversion'] = ord($header{4});
+ $this->info['avdataoffset'] += getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
+ }
}
- }
+ // read 32 kb file data
+ fseek($this->fp, $this->info['avdataoffset'], SEEK_SET);
+ $formattest = fread($this->fp, 32774);
+ // determine format
+ $determined_format = $this->GetFileFormat($formattest, $filename);
- // handle ID3v1 tag
- if ($this->option_tag_id3v1) {
- if (!@include_once(GETID3_INCLUDEPATH.'module.tag.id3v1.php')) {
- return $this->error('module.tag.id3v1.php is missing - you may disable option_tag_id3v1.');
+ // unable to determine file format
+ if (!$determined_format) {
+ fclose($this->fp);
+ return $this->error('unable to determine file format');
}
- $tag = new getid3_id3v1($fp, $this->info);
- unset($tag);
- }
- // handle APE tag
- if ($this->option_tag_apetag) {
- if (!@include_once(GETID3_INCLUDEPATH.'module.tag.apetag.php')) {
- return $this->error('module.tag.apetag.php is missing - you may disable option_tag_apetag.');
+ // check for illegal ID3 tags
+ if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) {
+ if ($determined_format['fail_id3'] === 'ERROR') {
+ fclose($this->fp);
+ return $this->error('ID3 tags not allowed on this file type.');
+ } elseif ($determined_format['fail_id3'] === 'WARNING') {
+ $this->warning('ID3 tags not allowed on this file type.');
+ }
}
- $tag = new getid3_apetag($fp, $this->info);
- unset($tag);
- }
- // handle lyrics3 tag
- if ($this->option_tag_lyrics3) {
- if (!@include_once(GETID3_INCLUDEPATH.'module.tag.lyrics3.php')) {
- return $this->error('module.tag.lyrics3.php is missing - you may disable option_tag_lyrics3.');
+ // check for illegal APE tags
+ if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) {
+ if ($determined_format['fail_ape'] === 'ERROR') {
+ fclose($this->fp);
+ return $this->error('APE tags not allowed on this file type.');
+ } elseif ($determined_format['fail_ape'] === 'WARNING') {
+ $this->warning('APE tags not allowed on this file type.');
+ }
}
- $tag = new getid3_lyrics3($fp, $this->info);
- unset($tag);
- }
-
- // read 32 kb file data
- fseek($fp, $this->info['avdataoffset'], SEEK_SET);
- $formattest = fread($fp, 32774);
-
- // determine format
- $determined_format = $this->GetFileFormat($formattest, $filename);
- // unable to determine file format
- if (!$determined_format) {
- fclose($fp);
- return $this->error('unable to determine file format');
- }
+ // set mime type
+ $this->info['mime_type'] = $determined_format['mime_type'];
- // check for illegal ID3 tags
- if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) {
- if ($determined_format['fail_id3'] === 'ERROR') {
- fclose($fp);
- return $this->error('ID3 tags not allowed on this file type.');
- } elseif ($determined_format['fail_id3'] === 'WARNING') {
- $this->info['warning'][] = 'ID3 tags not allowed on this file type.';
+ // supported format signature pattern detected, but module deleted
+ if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
+ fclose($this->fp);
+ return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
}
- }
- // check for illegal APE tags
- if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) {
- if ($determined_format['fail_ape'] === 'ERROR') {
- fclose($fp);
- return $this->error('APE tags not allowed on this file type.');
- } elseif ($determined_format['fail_ape'] === 'WARNING') {
- $this->info['warning'][] = 'APE tags not allowed on this file type.';
+ // module requires iconv support
+ // Check encoding/iconv support
+ if (!empty($determined_format['iconv_req']) && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
+ $errormessage = 'iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
+ if (GETID3_OS_ISWINDOWS) {
+ $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
+ } else {
+ $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
+ }
+ return $this->error($errormessage);
}
- }
- // set mime type
- $this->info['mime_type'] = $determined_format['mime_type'];
+ // include module
+ include_once(GETID3_INCLUDEPATH.$determined_format['include']);
- // supported format signature pattern detected, but module deleted
- if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
- fclose($fp);
- return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
- }
-
- // module requires iconv support
- if (!function_exists('iconv') && @$determined_format['iconv_req']) {
- return $this->error('iconv support is required for this module ('.$determined_format['include'].').');
- }
-
- // include module
- include_once(GETID3_INCLUDEPATH.$determined_format['include']);
+ // instantiate module class
+ $class_name = 'getid3_'.$determined_format['module'];
+ if (!class_exists($class_name)) {
+ return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
+ }
+ //if (isset($determined_format['option'])) {
+ // //$class = new $class_name($this->fp, $this->info, $determined_format['option']);
+ //} else {
+ //$class = new $class_name($this->fp, $this->info);
+ $class = new $class_name($this);
+ //}
+
+ if (!empty($determined_format['set_inline_attachments'])) {
+ $class->inline_attachments = $this->option_save_attachments;
+ }
+ $class->Analyze();
- // instantiate module class
- $class_name = 'getid3_'.$determined_format['module'];
- if (!class_exists($class_name)) {
- return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
- }
- if (isset($determined_format['option'])) {
- $class = new $class_name($fp, $this->info, $determined_format['option']);
- } else {
- $class = new $class_name($fp, $this->info);
- }
- unset($class);
+ unset($class);
- // close file
- fclose($fp);
+ // close file
+ fclose($this->fp);
- // process all tags - copy to 'tags' and convert charsets
- if ($this->option_tags_process) {
- $this->HandleAllTags();
- }
+ // process all tags - copy to 'tags' and convert charsets
+ if ($this->option_tags_process) {
+ $this->HandleAllTags();
+ }
- // perform more calculations
- if ($this->option_extra_info) {
- $this->ChannelsBitratePlaytimeCalculations();
- $this->CalculateCompressionRatioVideo();
- $this->CalculateCompressionRatioAudio();
- $this->CalculateReplayGain();
- $this->ProcessAudioStreams();
- }
+ // perform more calculations
+ if ($this->option_extra_info) {
+ $this->ChannelsBitratePlaytimeCalculations();
+ $this->CalculateCompressionRatioVideo();
+ $this->CalculateCompressionRatioAudio();
+ $this->CalculateReplayGain();
+ $this->ProcessAudioStreams();
+ }
- // get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
- if ($this->option_md5_data) {
- // do not cald md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
- if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
- $this->getHashdata('md5');
+ // get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
+ if ($this->option_md5_data) {
+ // do not cald md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
+ if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
+ $this->getHashdata('md5');
+ }
}
- }
- // get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
- if ($this->option_sha1_data) {
- $this->getHashdata('sha1');
- }
+ // get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
+ if ($this->option_sha1_data) {
+ $this->getHashdata('sha1');
+ }
- // remove undesired keys
- $this->CleanUp();
+ // remove undesired keys
+ $this->CleanUp();
- // restore magic_quotes_runtime setting
- set_magic_quotes_runtime($old_magic_quotes_runtime);
+ } catch (Exception $e) {
+ $this->error('Caught exception: '.$e->getMessage());
+ }
// return info array
return $this->info;
@@ -418,9 +505,10 @@ class getID3
// private: error handling
function error($message) {
-
$this->CleanUp();
-
+ if (!isset($this->info['error'])) {
+ $this->info['error'] = array();
+ }
$this->info['error'][] = $message;
return $this->info;
}
@@ -465,6 +553,19 @@ class getID3
unset($this->info['avdataend']);
}
}
+
+ // remove possible duplicated identical entries
+ if (!empty($this->info['error'])) {
+ $this->info['error'] = array_values(array_unique($this->info['error']));
+ }
+ if (!empty($this->info['warning'])) {
+ $this->info['warning'] = array_values(array_unique($this->info['warning']));
+ }
+
+ // remove "global variable" type keys
+ unset($this->info['php_memory_limit']);
+
+ return true;
}
@@ -489,18 +590,24 @@ class getID3
'pattern' => '^ADIF',
'group' => 'audio',
'module' => 'aac',
- 'option' => 'adif',
'mime_type' => 'application/octet-stream',
'fail_ape' => 'WARNING',
),
+ // AA - audio - Audible Audiobook
+ 'adts' => array(
+ 'pattern' => '^.{4}\x57\x90\x75\x36',
+ 'group' => 'audio',
+ 'module' => 'aa',
+ 'mime_type' => 'audio/audible ',
+ ),
+
// AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
'adts' => array(
'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]',
'group' => 'audio',
'module' => 'aac',
- 'option' => 'adts',
'mime_type' => 'application/octet-stream',
'fail_ape' => 'WARNING',
),
@@ -532,7 +639,7 @@ class getID3
// DSS - audio - Digital Speech Standard
'dss' => array(
- 'pattern' => '^[\x02]dss',
+ 'pattern' => '^[\x02-\x03]dss',
'group' => 'audio',
'module' => 'dss',
'mime_type' => 'application/octet-stream',
@@ -552,6 +659,7 @@ class getID3
'group' => 'audio',
'module' => 'flac',
'mime_type' => 'audio/x-flac',
+ 'set_inline_attachments' => true,
),
// LA - audio - Lossless Audio (LA)
@@ -601,7 +709,7 @@ class getID3
'pattern' => '^IMPM',
'group' => 'audio',
'module' => 'mod',
- 'option' => 'it',
+ //'option' => 'it',
'mime_type' => 'audio/it',
),
@@ -610,7 +718,7 @@ class getID3
'pattern' => '^Extended Module',
'group' => 'audio',
'module' => 'mod',
- 'option' => 'xm',
+ //'option' => 'xm',
'mime_type' => 'audio/xm',
),
@@ -619,7 +727,7 @@ class getID3
'pattern' => '^.{44}SCRM',
'group' => 'audio',
'module' => 'mod',
- 'option' => 's3m',
+ //'option' => 's3m',
'mime_type' => 'audio/s3m',
),
@@ -633,7 +741,7 @@ class getID3
// MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS)
'mp3' => array(
- 'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]',
+ 'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\x0B\x10-\x1B\x20-\x2B\x30-\x3B\x40-\x4B\x50-\x5B\x60-\x6B\x70-\x7B\x80-\x8B\x90-\x9B\xA0-\xAB\xB0-\xBB\xC0-\xCB\xD0-\xDB\xE0-\xEB\xF0-\xFB]',
'group' => 'audio',
'module' => 'mp3',
'mime_type' => 'audio/mpeg',
@@ -731,6 +839,7 @@ class getID3
'group' => 'audio-video',
'module' => 'matroska',
'mime_type' => 'video/x-matroska', // may also be audio/x-matroska
+ 'set_inline_attachments' => true,
),
// MPEG - audio/video - MPEG (Moving Pictures Experts Group)
@@ -757,6 +866,7 @@ class getID3
'mime_type' => 'application/ogg',
'fail_id3' => 'WARNING',
'fail_ape' => 'WARNING',
+ 'set_inline_attachments' => true,
),
// QT - audio/video - Quicktime
@@ -847,9 +957,9 @@ class getID3
),
- // SVG - still image - Scalable Vector Graphics (SVG)
+ // SVG - still image - Scalable Vector Graphics (SVG)
'svg' => array(
- 'pattern' => '<!DOCTYPE svg PUBLIC ',
+ 'pattern' => '(<!DOCTYPE svg PUBLIC |xmlns="http:\/\/www\.w3\.org\/2000\/svg")',
'group' => 'graphic',
'module' => 'svg',
'mime_type' => 'image/svg+xml',
@@ -858,7 +968,7 @@ class getID3
),
- // TIFF - still image - Tagged Information File Format (TIFF)
+ // TIFF - still image - Tagged Information File Format (TIFF)
'tiff' => array(
'pattern' => '^(II\x2A\x00|MM\x00\x2A)',
'group' => 'graphic',
@@ -869,6 +979,17 @@ class getID3
),
+ // EFAX - still image - eFax (TIFF derivative)
+ 'bmp' => array(
+ 'pattern' => '^\xDC\xFE',
+ 'group' => 'graphic',
+ 'module' => 'efax',
+ 'mime_type' => 'image/efax',
+ 'fail_id3' => 'ERROR',
+ 'fail_ape' => 'ERROR',
+ ),
+
+
// Data formats
// ISO - data - International Standards Organization (ISO) CD-ROM Image
@@ -935,10 +1056,10 @@ class getID3
// Misc other formats
- // PAR2 - data - Parity Volume Set Specification 2.0
- 'par2' => array (
- 'pattern' => '^PAR2\x00PKT',
- 'group' => 'misc',
+ // PAR2 - data - Parity Volume Set Specification 2.0
+ 'par2' => array (
+ 'pattern' => '^PAR2\x00PKT',
+ 'group' => 'misc',
'module' => 'par2',
'mime_type' => 'application/octet-stream',
'fail_id3' => 'ERROR',
@@ -957,13 +1078,22 @@ class getID3
// MSOFFICE - data - ZIP compressed data
'msoffice' => array(
- 'pattern' => '^\xD0\xCF\x11\xE0', // D0CF11E == DOCFILE == Microsoft Office Document
+ 'pattern' => '^\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1', // D0CF11E == DOCFILE == Microsoft Office Document
'group' => 'misc',
'module' => 'msoffice',
'mime_type' => 'application/octet-stream',
'fail_id3' => 'ERROR',
'fail_ape' => 'ERROR',
),
+
+ // CUE - data - CUEsheet (index to single-file disc images)
+ 'cue' => array(
+ 'pattern' => '', // empty pattern means cannot be automatically detected, will fall through all other formats and match based on filename and very basic file contents
+ 'group' => 'misc',
+ 'module' => 'cue',
+ 'mime_type' => 'application/octet-stream',
+ ),
+
);
}
@@ -980,23 +1110,30 @@ class getID3
// Identify file format - loop through $format_info and detect with reg expr
foreach ($this->GetFileFormatArray() as $format_name => $info) {
- // Using preg_match() instead of ereg() - much faster
// The /s switch on preg_match() forces preg_match() NOT to treat
// newline (0x0A) characters as special chars but do a binary match
- if (preg_match('/'.$info['pattern'].'/s', $filedata)) {
+ if (!empty($info['pattern']) && preg_match('#'.$info['pattern'].'#s', $filedata)) {
$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
return $info;
}
}
- if (preg_match('/\.mp[123a]$/i', $filename)) {
+ if (preg_match('#\.mp[123a]$#i', $filename)) {
// Too many mp3 encoders on the market put gabage in front of mpeg files
// use assume format on these if format detection failed
$GetFileFormatArray = $this->GetFileFormatArray();
$info = $GetFileFormatArray['mp3'];
$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
return $info;
+ } elseif (preg_match('/\.cue$/i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) {
+ // there's not really a useful consistent "magic" at the beginning of .cue files to identify them
+ // so until I think of something better, just go by filename if all other format checks fail
+ // and verify there's at least one instance of "TRACK xx AUDIO" in the file
+ $GetFileFormatArray = $this->GetFileFormatArray();
+ $info = $GetFileFormatArray['cue'];
+ $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
+ return $info;
}
return false;
@@ -1039,7 +1176,7 @@ class getID3
'ogg' => array('vorbiscomment' , 'UTF-8'),
'png' => array('png' , 'UTF-8'),
'tiff' => array('tiff' , 'ISO-8859-1'),
- 'quicktime' => array('quicktime' , 'ISO-8859-1'),
+ 'quicktime' => array('quicktime' , 'UTF-8'),
'real' => array('real' , 'ISO-8859-1'),
'vqf' => array('vqf' , 'ISO-8859-1'),
'zip' => array('zip' , 'ISO-8859-1'),
@@ -1047,11 +1184,13 @@ class getID3
'lyrics3' => array('lyrics3' , 'ISO-8859-1'),
'id3v1' => array('id3v1' , $this->encoding_id3v1),
'id3v2' => array('id3v2' , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
- 'ape' => array('ape' , 'UTF-8')
+ 'ape' => array('ape' , 'UTF-8'),
+ 'cue' => array('cue' , 'ISO-8859-1'),
+ 'matroska' => array('matroska' , 'UTF-8'),
);
}
- // loop thru comments array
+ // loop through comments array
foreach ($tags as $comment_name => $tagname_encoding_array) {
list($tag_name, $encoding) = $tagname_encoding_array;
@@ -1065,8 +1204,11 @@ class getID3
foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
foreach ($valuearray as $key => $value) {
- if (strlen(trim($value)) > 0) {
- $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value; // do not trim!! Unicode characters will get mangled if trailing nulls are removed!
+ if (is_string($value)) {
+ $value = trim($value, " \r\n\t"); // do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed!
+ }
+ if ($value) {
+ $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value;
}
}
}
@@ -1081,7 +1223,7 @@ class getID3
foreach ($valuearray as $key => $value) {
if (is_string($value)) {
//$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);
- $this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('&#0;', '', getid3_lib::MultiByteCharString2HTML($value, $encoding));
+ $this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('&#0;', '', trim(getid3_lib::MultiByteCharString2HTML($value, $encoding)));
} else {
$this->info['tags_html'][$tag_name][$tag_key][$key] = $value;
}
@@ -1093,6 +1235,51 @@ class getID3
}
}
+
+ // pictures can take up a lot of space, and we don't need multiple copies of them
+ // let there be a single copy in [comments][picture], and not elsewhere
+ if (!empty($this->info['tags'])) {
+ $unset_keys = array('tags', 'tags_html');
+ foreach ($this->info['tags'] as $tagtype => $tagarray) {
+ foreach ($tagarray as $tagname => $tagdata) {
+ if ($tagname == 'picture') {
+ foreach ($tagdata as $key => $tagarray) {
+ $this->info['comments']['picture'][] = $tagarray;
+ if (isset($tagarray['data']) && isset($tagarray['image_mime'])) {
+ if (isset($this->info['tags'][$tagtype][$tagname][$key])) {
+ unset($this->info['tags'][$tagtype][$tagname][$key]);
+ }
+ if (isset($this->info['tags_html'][$tagtype][$tagname][$key])) {
+ unset($this->info['tags_html'][$tagtype][$tagname][$key]);
+ }
+ }
+ }
+ }
+ }
+ foreach ($unset_keys as $unset_key) {
+ // remove possible empty keys from (e.g. [tags][id3v2][picture])
+ if (empty($this->info[$unset_key][$tagtype]['picture'])) {
+ unset($this->info[$unset_key][$tagtype]['picture']);
+ }
+ if (empty($this->info[$unset_key][$tagtype])) {
+ unset($this->info[$unset_key][$tagtype]);
+ }
+ if (empty($this->info[$unset_key])) {
+ unset($this->info[$unset_key]);
+ }
+ }
+ // remove duplicate copy of picture data from (e.g. [id3v2][comments][picture])
+ if (isset($this->info[$tagtype]['comments']['picture'])) {
+ unset($this->info[$tagtype]['comments']['picture']);
+ }
+ if (empty($this->info[$tagtype]['comments'])) {
+ unset($this->info[$tagtype]['comments']);
+ }
+ if (empty($this->info[$tagtype])) {
+ unset($this->info[$tagtype]);
+ }
+ }
+ }
return true;
}
@@ -1108,7 +1295,7 @@ class getID3
break;
}
- if ((@$this->info['fileformat'] == 'ogg') && (@$this->info['audio']['dataformat'] == 'vorbis')) {
+ if (!empty($this->info['fileformat']) && !empty($this->info['dataformat']) && ($this->info['fileformat'] == 'ogg') && ($this->info['audio']['dataformat'] == 'vorbis')) {
// We cannot get an identical md5_data value for Ogg files where the comments
// span more than 1 Ogg page (compared to the same audio data with smaller
@@ -1128,10 +1315,10 @@ class getID3
// page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
// currently vorbiscomment only works on OggVorbis files.
- if ((bool) ini_get('safe_mode')) {
+ if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
- $this->info['warning'][] = 'Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)';
- $this->info[$algorithm.'_data'] = false;
+ $this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)');
+ $this->info[$algorithm.'_data'] = false;
} else {
@@ -1139,12 +1326,11 @@ class getID3
$old_abort = ignore_user_abort(true);
// Create empty file
- $empty = tempnam('*', 'getID3');
+ $empty = tempnam(GETID3_TEMP_DIR, 'getID3');
touch($empty);
-
// Use vorbiscomment to make temp file without comments
- $temp = tempnam('*', 'getID3');
+ $temp = tempnam(GETID3_TEMP_DIR, 'getID3');
$file = $this->info['filenamepath'];
if (GETID3_OS_ISWINDOWS) {
@@ -1178,11 +1364,11 @@ class getID3
// Get hash of newly created file
switch ($algorithm) {
case 'md5':
- $this->info[$algorithm.'_data'] = getid3_lib::md5_file($temp);
+ $this->info[$algorithm.'_data'] = md5_file($temp);
break;
case 'sha1':
- $this->info[$algorithm.'_data'] = getid3_lib::sha1_file($temp);
+ $this->info[$algorithm.'_data'] = sha1_file($temp);
break;
}
}
@@ -1208,11 +1394,11 @@ class getID3
// get hash from whole file
switch ($algorithm) {
case 'md5':
- $this->info[$algorithm.'_data'] = getid3_lib::md5_file($this->info['filenamepath']);
+ $this->info[$algorithm.'_data'] = md5_file($this->info['filenamepath']);
break;
case 'sha1':
- $this->info[$algorithm.'_data'] = getid3_lib::sha1_file($this->info['filenamepath']);
+ $this->info[$algorithm.'_data'] = sha1_file($this->info['filenamepath']);
break;
}
}
@@ -1225,9 +1411,11 @@ class getID3
function ChannelsBitratePlaytimeCalculations() {
// set channelmode on audio
- if (@$this->info['audio']['channels'] == '1') {
+ if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
+ // ignore
+ } elseif ($this->info['audio']['channels'] == 1) {
$this->info['audio']['channelmode'] = 'mono';
- } elseif (@$this->info['audio']['channels'] == '2') {
+ } elseif ($this->info['audio']['channels'] == 2) {
$this->info['audio']['channelmode'] = 'stereo';
}
@@ -1268,11 +1456,6 @@ class getID3
if (!isset($this->info['bitrate']) && !empty($this->info['playtime_seconds'])) {
$this->info['bitrate'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds'];
}
-//echo '<pre>';
-//var_dump($this->info['bitrate']);
-//var_dump($this->info['audio']['bitrate']);
-//var_dump($this->info['video']['bitrate']);
-//echo '</pre>';
if (isset($this->info['bitrate']) && empty($this->info['audio']['bitrate']) && empty($this->info['video']['bitrate'])) {
if (isset($this->info['audio']['dataformat']) && empty($this->info['video']['resolution_x'])) {
// audio only
@@ -1357,7 +1540,9 @@ class getID3
function CalculateReplayGain() {
if (isset($this->info['replay_gain'])) {
- $this->info['replay_gain']['reference_volume'] = 89;
+ if (!isset($this->info['replay_gain']['reference_volume'])) {
+ $this->info['replay_gain']['reference_volume'] = (double) 89.0;
+ }
if (isset($this->info['replay_gain']['track']['adjustment'])) {
$this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
}
@@ -1392,6 +1577,168 @@ class getID3
return tempnam($this->tempdir, 'gI3');
}
+
+ public function saveAttachment(&$ThisFileInfoIndex, $filename, $offset, $length) {
+ try {
+ if (!getid3_lib::intValueSupported($offset + $length)) {
+ throw new Exception('cannot extract attachment, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
+ }
+
+ // do not extract at all
+ if ($this->option_save_attachments === getID3::ATTACHMENTS_NONE) {
+
+ unset($ThisFileInfoIndex); // do not set any
+
+ // extract to return array
+ } elseif ($this->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
+
+ // get whole data in one pass, till it is anyway stored in memory
+ $ThisFileInfoIndex = file_get_contents($this->info['filenamepath'], false, null, $offset, $length);
+ if (($ThisFileInfoIndex === false) || (strlen($ThisFileInfoIndex) != $length)) { // verify
+ throw new Exception('failed to read attachment data');
+ }
+
+ // assume directory path is given
+ } else {
+
+ $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->option_save_attachments), DIRECTORY_SEPARATOR);
+ // check supplied directory
+ if (!is_dir($dir) || !is_writable($dir)) {
+ throw new Exception('getID3::saveAttachment() -- supplied path ('.$dir.') does not exist, or is not writable');
+ }
+
+ // set up destination path
+ $dest = $dir.DIRECTORY_SEPARATOR.$filename;
+
+ // optimize speed if read buffer size is configured to be large enough
+ // here stream_copy_to_stream() may also be used. need to do speed-compare tests
+ if ($length <= $this->fread_buffer_size()) {
+ $data = file_get_contents($this->info['filenamepath'], false, null, $offset, $length);
+ if (($data === false) || (strlen($data) != $length)) { // verify
+ throw new Exception('failed to read attachment data');
+ }
+ if (!file_put_contents($dest, $data)) {
+ throw new Exception('failed to create file '.$dest);
+ }
+ } else {
+ // optimization not available - copy data in loop
+ // here stream_copy_to_stream() shouldn't be used because it's internal read buffer may be larger than ours!
+ getid3_lib::CopyFileParts($this->info['filenamepath'], $dest, $offset, $length);
+ }
+ $ThisFileInfoIndex = $dest;
+ }
+
+ } catch (Exception $e) {
+
+ unset($ThisFileInfoIndex); // do not set any is case of error
+ $this->warning('Failed to extract attachment '.$filename.': '.$e->getMessage());
+ return false;
+
+ }
+ return true;
+ }
+
+
+ public function include_module($name) {
+ //if (!file_exists($this->include_path.'module.'.$name.'.php')) {
+ if (!file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) {
+ throw new getid3_exception('Required module.'.$name.'.php is missing.');
+ }
+ include_once(GETID3_INCLUDEPATH.'module.'.$name.'.php');
+ return true;
+ }
+
+}
+
+
+abstract class getid3_handler
+{
+ protected $getid3; // pointer
+
+ protected $data_string_flag = false; // analyzing filepointer or string
+ protected $data_string; // string to analyze
+ protected $data_string_position = 0; // seek position in string
+
+
+ public function __construct(getID3 $getid3) {
+ $this->getid3 = $getid3;
+ }
+
+
+ // Analyze from file pointer
+ abstract public function Analyze();
+
+
+ // Analyze from string instead
+ public function AnalyzeString(&$string) {
+ // Enter string mode
+ $this->data_string_flag = true;
+ $this->data_string = $string;
+
+ // Save info
+ $saved_avdataoffset = $this->getid3->info['avdataoffset'];
+ $saved_avdataend = $this->getid3->info['avdataend'];
+ $saved_filesize = $this->getid3->info['filesize'];
+
+ // Reset some info
+ $this->getid3->info['avdataoffset'] = 0;
+ $this->getid3->info['avdataend'] = $this->getid3->info['filesize'] = strlen($string);
+
+ // Analyze
+ $this->Analyze();
+
+ // Restore some info
+ $this->getid3->info['avdataoffset'] = $saved_avdataoffset;
+ $this->getid3->info['avdataend'] = $saved_avdataend;
+ $this->getid3->info['filesize'] = $saved_filesize;
+
+ // Exit string mode
+ $this->data_string_flag = false;
+ }
+
+
+ protected function ftell() {
+ if ($this->data_string_flag) {
+ return $this->data_string_position;
+ }
+ return ftell($this->getid3->fp);
+ }
+
+
+ protected function fread($bytes) {
+ if ($this->data_string_flag) {
+ $this->data_string_position += $bytes;
+ return substr($this->data_string, $this->data_string_position - $bytes, $bytes);
+ }
+ return fread($this->getid3->fp, $bytes);
+ }
+
+
+ protected function fseek($bytes, $whence = SEEK_SET) {
+ if ($this->data_string_flag) {
+ switch ($whence) {
+ case SEEK_SET:
+ $this->data_string_position = $bytes;
+ return;
+
+ case SEEK_CUR:
+ $this->data_string_position += $bytes;
+ return;
+
+ case SEEK_END:
+ $this->data_string_position = strlen($this->data_string) + $bytes;
+ return;
+ }
+ }
+ return fseek($this->getid3->fp, $bytes, $whence);
+ }
+
+}
+
+
+class getid3_exception extends Exception
+{
+ public $message;
}
?> \ No newline at end of file
diff --git a/apps/media/getID3/license.txt b/3rdparty/getid3/license.txt
index 9fec8082904..9fec8082904 100644
--- a/apps/media/getID3/license.txt
+++ b/3rdparty/getid3/license.txt
diff --git a/apps/media/getID3/getid3/module.archive.gzip.php b/3rdparty/getid3/module.archive.gzip.php
index 7e9376f37ba..c30052eda40 100644
--- a/apps/media/getID3/getid3/module.archive.gzip.php
+++ b/3rdparty/getid3/module.archive.gzip.php
@@ -19,21 +19,28 @@
/////////////////////////////////////////////////////////////////
-class getid3_gzip {
+class getid3_gzip extends getid3_handler {
// public: Optional file list - disable for speed.
var $option_gzip_parse_contents = false; // decode gzipped files, if possible, and parse recursively (.tar.gz for example)
- function getid3_gzip(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'gzip';
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $info['fileformat'] = 'gzip';
$start_length = 10;
$unpack_header = 'a1id1/a1id2/a1cmethod/a1flags/a4mtime/a1xflags/a1os';
//+---+---+---+---+---+---+---+---+---+---+
//|ID1|ID2|CM |FLG| MTIME |XFL|OS |
//+---+---+---+---+---+---+---+---+---+---+
- @fseek($fd, 0);
- $buffer = @fread($fd, $ThisFileInfo['filesize']);
+
+ if ($info['filesize'] > $info['php_memory_limit']) {
+ $info['error'][] = 'File is too large ('.number_format($info['filesize']).' bytes) to read into memory (limit: '.number_format($info['php_memory_limit'] / 1048576).'MB)';
+ return false;
+ }
+ fseek($this->getid3->fp, 0);
+ $buffer = fread($this->getid3->fp, $info['filesize']);
$arr_members = explode("\x1F\x8B\x08", $buffer);
while (true) {
@@ -59,7 +66,7 @@ class getid3_gzip {
}
}
- $ThisFileInfo['gzip']['files'] = array();
+ $info['gzip']['files'] = array();
$fpointer = 0;
$idx = 0;
@@ -67,29 +74,29 @@ class getid3_gzip {
if (strlen($arr_members[$i]) == 0) {
continue;
}
- $thisThisFileInfo = &$ThisFileInfo['gzip']['member_header'][++$idx];
+ $thisInfo = &$info['gzip']['member_header'][++$idx];
$buff = "\x1F\x8B\x08".$arr_members[$i];
$attr = unpack($unpack_header, substr($buff, 0, $start_length));
- $thisThisFileInfo['filemtime'] = getid3_lib::LittleEndian2Int($attr['mtime']);
- $thisThisFileInfo['raw']['id1'] = ord($attr['cmethod']);
- $thisThisFileInfo['raw']['id2'] = ord($attr['cmethod']);
- $thisThisFileInfo['raw']['cmethod'] = ord($attr['cmethod']);
- $thisThisFileInfo['raw']['os'] = ord($attr['os']);
- $thisThisFileInfo['raw']['xflags'] = ord($attr['xflags']);
- $thisThisFileInfo['raw']['flags'] = ord($attr['flags']);
+ $thisInfo['filemtime'] = getid3_lib::LittleEndian2Int($attr['mtime']);
+ $thisInfo['raw']['id1'] = ord($attr['cmethod']);
+ $thisInfo['raw']['id2'] = ord($attr['cmethod']);
+ $thisInfo['raw']['cmethod'] = ord($attr['cmethod']);
+ $thisInfo['raw']['os'] = ord($attr['os']);
+ $thisInfo['raw']['xflags'] = ord($attr['xflags']);
+ $thisInfo['raw']['flags'] = ord($attr['flags']);
- $thisThisFileInfo['flags']['crc16'] = (bool) ($thisThisFileInfo['raw']['flags'] & 0x02);
- $thisThisFileInfo['flags']['extra'] = (bool) ($thisThisFileInfo['raw']['flags'] & 0x04);
- $thisThisFileInfo['flags']['filename'] = (bool) ($thisThisFileInfo['raw']['flags'] & 0x08);
- $thisThisFileInfo['flags']['comment'] = (bool) ($thisThisFileInfo['raw']['flags'] & 0x10);
+ $thisInfo['flags']['crc16'] = (bool) ($thisInfo['raw']['flags'] & 0x02);
+ $thisInfo['flags']['extra'] = (bool) ($thisInfo['raw']['flags'] & 0x04);
+ $thisInfo['flags']['filename'] = (bool) ($thisInfo['raw']['flags'] & 0x08);
+ $thisInfo['flags']['comment'] = (bool) ($thisInfo['raw']['flags'] & 0x10);
- $thisThisFileInfo['compression'] = $this->get_xflag_type($thisThisFileInfo['raw']['xflags']);
+ $thisInfo['compression'] = $this->get_xflag_type($thisInfo['raw']['xflags']);
- $thisThisFileInfo['os'] = $this->get_os_type($thisThisFileInfo['raw']['os']);
- if (!$thisThisFileInfo['os']) {
- $ThisFileInfo['error'][] = 'Read error on gzip file';
+ $thisInfo['os'] = $this->get_os_type($thisInfo['raw']['os']);
+ if (!$thisInfo['os']) {
+ $info['error'][] = 'Read error on gzip file';
return false;
}
@@ -99,12 +106,12 @@ class getid3_gzip {
//+---+---+=================================+
//| XLEN |...XLEN bytes of "extra field"...|
//+---+---+=================================+
- if ($thisThisFileInfo['flags']['extra']) {
+ if ($thisInfo['flags']['extra']) {
$w_xlen = substr($buff, $fpointer, 2);
$xlen = getid3_lib::LittleEndian2Int($w_xlen);
$fpointer += 2;
- $thisThisFileInfo['raw']['xfield'] = substr($buff, $fpointer, $xlen);
+ $thisInfo['raw']['xfield'] = substr($buff, $fpointer, $xlen);
// Extra SubFields
//+---+---+---+---+==================================+
//|SI1|SI2| LEN |... LEN bytes of subfield data ...|
@@ -133,14 +140,14 @@ class getid3_gzip {
//|...original file name, zero-terminated...|
//+=========================================+
// GZIP files may have only one file, with no filename, so assume original filename is current filename without .gz
- $thisThisFileInfo['filename'] = eregi_replace('.gz$', '', $ThisFileInfo['filename']);
- if ($thisThisFileInfo['flags']['filename']) {
+ $thisInfo['filename'] = preg_replace('#\.gz$#i', '', $info['filename']);
+ if ($thisInfo['flags']['filename']) {
while (true) {
if (ord($buff[$fpointer]) == 0) {
$fpointer++;
break;
}
- $thisThisFileInfo['filename'] .= $buff[$fpointer];
+ $thisInfo['filename'] .= $buff[$fpointer];
$fpointer++;
}
}
@@ -148,13 +155,13 @@ class getid3_gzip {
//+===================================+
//|...file comment, zero-terminated...|
//+===================================+
- if ($thisThisFileInfo['flags']['comment']) {
+ if ($thisInfo['flags']['comment']) {
while (true) {
if (ord($buff[$fpointer]) == 0) {
$fpointer++;
break;
}
- $thisThisFileInfo['comment'] .= $buff[$fpointer];
+ $thisInfo['comment'] .= $buff[$fpointer];
$fpointer++;
}
}
@@ -162,21 +169,21 @@ class getid3_gzip {
//+---+---+
//| CRC16 |
//+---+---+
- if ($thisThisFileInfo['flags']['crc16']) {
+ if ($thisInfo['flags']['crc16']) {
$w_crc = substr($buff, $fpointer, 2);
- $thisThisFileInfo['crc16'] = getid3_lib::LittleEndian2Int($w_crc);
+ $thisInfo['crc16'] = getid3_lib::LittleEndian2Int($w_crc);
$fpointer += 2;
}
// bit 0 - FLG.FTEXT
- //if ($thisThisFileInfo['raw']['flags'] & 0x01) {
+ //if ($thisInfo['raw']['flags'] & 0x01) {
// Ignored...
//}
// bits 5, 6, 7 - reserved
- $thisThisFileInfo['crc32'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 8, 4));
- $thisThisFileInfo['filesize'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 4));
+ $thisInfo['crc32'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 8, 4));
+ $thisInfo['filesize'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 4));
- $ThisFileInfo['gzip']['files'] = getid3_lib::array_merge_clobber($ThisFileInfo['gzip']['files'], getid3_lib::CreateDeepArray($thisThisFileInfo['filename'], '/', $thisThisFileInfo['filesize']));
+ $info['gzip']['files'] = getid3_lib::array_merge_clobber($info['gzip']['files'], getid3_lib::CreateDeepArray($thisInfo['filename'], '/', $thisInfo['filesize']));
if ($this->option_gzip_parse_contents) {
// Try to inflate GZip
@@ -190,44 +197,46 @@ class getid3_gzip {
$inflated = gzinflate($cdata);
// Calculate CRC32 for inflated content
- $thisThisFileInfo['crc32_valid'] = (bool) (sprintf('%u', crc32($inflated)) == $thisThisFileInfo['crc32']);
+ $thisInfo['crc32_valid'] = (bool) (sprintf('%u', crc32($inflated)) == $thisInfo['crc32']);
// determine format
$formattest = substr($inflated, 0, 32774);
- $newgetID3 = new getID3();
- $determined_format = $newgetID3->GetFileFormat($formattest);
- unset($newgetID3);
+ $getid3_temp = new getID3();
+ $determined_format = $getid3_temp->GetFileFormat($formattest);
+ unset($getid3_temp);
- // file format is determined
- switch (@$determined_format['module']) {
- case 'tar':
+ // file format is determined
+ $determined_format['module'] = (isset($determined_format['module']) ? $determined_format['module'] : '');
+ switch ($determined_format['module']) {
+ case 'tar':
// view TAR-file info
- if (file_exists(GETID3_INCLUDEPATH.$determined_format['include']) && @include_once(GETID3_INCLUDEPATH.$determined_format['include'])) {
- if (($temp_tar_filename = tempnam('*', 'getID3')) === false) {
+ if (file_exists(GETID3_INCLUDEPATH.$determined_format['include']) && include_once(GETID3_INCLUDEPATH.$determined_format['include'])) {
+ if (($temp_tar_filename = tempnam(GETID3_TEMP_DIR, 'getID3')) === false) {
// can't find anywhere to create a temp file, abort
- $ThisFileInfo['error'][] = 'Unable to create temp file to parse TAR inside GZIP file';
+ $info['error'][] = 'Unable to create temp file to parse TAR inside GZIP file';
break;
}
if ($fp_temp_tar = fopen($temp_tar_filename, 'w+b')) {
fwrite($fp_temp_tar, $inflated);
- rewind($fp_temp_tar);
- $getid3_tar = new getid3_tar($fp_temp_tar, $dummy);
- $ThisFileInfo['gzip']['member_header'][$idx]['tar'] = $dummy['tar'];
- unset($dummy);
- unset($getid3_tar);
fclose($fp_temp_tar);
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($temp_tar_filename);
+ $getid3_tar = new getid3_tar($getid3_temp);
+ $getid3_tar->Analyze();
+ $info['gzip']['member_header'][$idx]['tar'] = $getid3_temp->info['tar'];
+ unset($getid3_temp, $getid3_tar);
unlink($temp_tar_filename);
} else {
- $ThisFileInfo['error'][] = 'Unable to fopen() temp file to parse TAR inside GZIP file';
+ $info['error'][] = 'Unable to fopen() temp file to parse TAR inside GZIP file';
break;
}
}
break;
- case '':
- default:
- // unknown or unhandled format
- break;
+ case '':
+ default:
+ // unknown or unhandled format
+ break;
}
}
}
@@ -254,7 +263,7 @@ class getid3_gzip {
'13' => 'Acorn RISCOS',
'255' => 'unknown'
);
- return @$os_type[$key];
+ return (isset($os_type[$key]) ? $os_type[$key] : '');
}
// Converts the eXtra FLags
@@ -264,7 +273,7 @@ class getid3_gzip {
'2' => 'maximum compression',
'4' => 'fastest algorithm'
);
- return @$xflag_type[$key];
+ return (isset($xflag_type[$key]) ? $xflag_type[$key] : '');
}
}
diff --git a/apps/media/getID3/getid3/module.archive.rar.php b/3rdparty/getid3/module.archive.rar.php
index 59820b2fad9..4f5d46f8373 100644
--- a/apps/media/getID3/getid3/module.archive.rar.php
+++ b/3rdparty/getid3/module.archive.rar.php
@@ -14,33 +14,34 @@
/////////////////////////////////////////////////////////////////
-class getid3_rar
+class getid3_rar extends getid3_handler
{
var $option_use_rar_extension = false;
- function getid3_rar(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- $ThisFileInfo['fileformat'] = 'rar';
+ $info['fileformat'] = 'rar';
if ($this->option_use_rar_extension === true) {
if (function_exists('rar_open')) {
- if ($rp = rar_open($ThisFileInfo['filename'])) {
- $ThisFileInfo['rar']['files'] = array();
+ if ($rp = rar_open($info['filenamepath'])) {
+ $info['rar']['files'] = array();
$entries = rar_list($rp);
foreach ($entries as $entry) {
- $ThisFileInfo['rar']['files'] = getid3_lib::array_merge_clobber($ThisFileInfo['rar']['files'], getid3_lib::CreateDeepArray($entry->getName(), '/', $entry->getUnpackedSize()));
+ $info['rar']['files'] = getid3_lib::array_merge_clobber($info['rar']['files'], getid3_lib::CreateDeepArray($entry->getName(), '/', $entry->getUnpackedSize()));
}
rar_close($rp);
return true;
} else {
- $ThisFileInfo['error'][] = 'failed to rar_open('.$ThisFileInfo['filename'].')';
+ $info['error'][] = 'failed to rar_open('.$info['filename'].')';
}
} else {
- $ThisFileInfo['error'][] = 'RAR support does not appear to be available in this PHP installation';
+ $info['error'][] = 'RAR support does not appear to be available in this PHP installation';
}
} else {
- $ThisFileInfo['error'][] = 'PHP-RAR processing has been disabled (set $getid3_rar->option_use_rar_extension=true to enable)';
+ $info['error'][] = 'PHP-RAR processing has been disabled (set $getid3_rar->option_use_rar_extension=true to enable)';
}
return false;
diff --git a/apps/media/getID3/getid3/module.archive.szip.php b/3rdparty/getid3/module.archive.szip.php
index 2513c85c7b3..3be6253263e 100644
--- a/apps/media/getID3/getid3/module.archive.szip.php
+++ b/3rdparty/getid3/module.archive.szip.php
@@ -14,36 +14,35 @@
/////////////////////////////////////////////////////////////////
-class getid3_szip
+class getid3_szip extends getid3_handler
{
- function getid3_szip(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $SZIPHeader = fread($fd, 6);
- if (substr($SZIPHeader, 0, 4) != 'SZ'."\x0A\x04") {
- $ThisFileInfo['error'][] = 'Expecting "SZ[x0A][x04]" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($SZIPHeader, 0, 4).'"';
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $SZIPHeader = fread($this->getid3->fp, 6);
+ if (substr($SZIPHeader, 0, 4) != "SZ\x0A\x04") {
+ $info['error'][] = 'Expecting "53 5A 0A 04" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($SZIPHeader, 0, 4)).'"';
return false;
}
+ $info['fileformat'] = 'szip';
+ $info['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 4, 1));
+ $info['szip']['minor_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 5, 1));
- $ThisFileInfo['fileformat'] = 'szip';
-
- $ThisFileInfo['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 4, 1));
- $ThisFileInfo['szip']['minor_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 5, 1));
-
- while (!feof($fd)) {
- $NextBlockID = fread($fd, 2);
+ while (!feof($this->getid3->fp)) {
+ $NextBlockID = fread($this->getid3->fp, 2);
switch ($NextBlockID) {
case 'SZ':
// Note that szip files can be concatenated, this has the same effect as
// concatenating the files. this also means that global header blocks
// might be present between directory/data blocks.
- fseek($fd, 4, SEEK_CUR);
+ fseek($this->getid3->fp, 4, SEEK_CUR);
break;
case 'BH':
- $BHheaderbytes = getid3_lib::BigEndian2Int(fread($fd, 3));
- $BHheaderdata = fread($fd, $BHheaderbytes);
+ $BHheaderbytes = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 3));
+ $BHheaderdata = fread($this->getid3->fp, $BHheaderbytes);
$BHheaderoffset = 0;
while (strpos($BHheaderdata, "\x00", $BHheaderoffset) > 0) {
//filename as \0 terminated string (empty string indicates end)
@@ -79,7 +78,7 @@ class getid3_szip
$BHdataArray['access_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
$BHheaderoffset += 4;
- $ThisFileInfo['szip']['BH'][] = $BHdataArray;
+ $info['szip']['BH'][] = $BHdataArray;
}
break;
diff --git a/apps/media/getID3/getid3/module.archive.tar.php b/3rdparty/getid3/module.archive.tar.php
index aa4390fc9f9..94d32039899 100644
--- a/apps/media/getID3/getid3/module.archive.tar.php
+++ b/3rdparty/getid3/module.archive.tar.php
@@ -19,18 +19,21 @@
/////////////////////////////////////////////////////////////////
-class getid3_tar {
+class getid3_tar extends getid3_handler
+{
- function getid3_tar(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'tar';
- $ThisFileInfo['tar']['files'] = array();
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $info['fileformat'] = 'tar';
+ $info['tar']['files'] = array();
$unpack_header = 'a100fname/a8mode/a8uid/a8gid/a12size/a12mtime/a8chksum/a1typflag/a100lnkname/a6magic/a2ver/a32uname/a32gname/a8devmaj/a8devmin/a155prefix';
$null_512k = str_repeat("\x00", 512); // end-of-file marker
- @fseek($fd, 0);
- while (!feof($fd)) {
- $buffer = fread($fd, 512);
+ fseek($this->getid3->fp, 0);
+ while (!feof($this->getid3->fp)) {
+ $buffer = fread($this->getid3->fp, 512);
if (strlen($buffer) < 512) {
break;
}
@@ -47,22 +50,22 @@ class getid3_tar {
$checksum += ord($buffer{$i});
}
$attr = unpack($unpack_header, $buffer);
- $name = trim(@$attr['fname']);
- $mode = octdec(trim(@$attr['mode']));
- $uid = octdec(trim(@$attr['uid']));
- $gid = octdec(trim(@$attr['gid']));
- $size = octdec(trim(@$attr['size']));
- $mtime = octdec(trim(@$attr['mtime']));
- $chksum = octdec(trim(@$attr['chksum']));
- $typflag = trim(@$attr['typflag']);
- $lnkname = trim(@$attr['lnkname']);
- $magic = trim(@$attr['magic']);
- $ver = trim(@$attr['ver']);
- $uname = trim(@$attr['uname']);
- $gname = trim(@$attr['gname']);
- $devmaj = octdec(trim(@$attr['devmaj']));
- $devmin = octdec(trim(@$attr['devmin']));
- $prefix = trim(@$attr['prefix']);
+ $name = (isset($attr['fname'] ) ? trim($attr['fname'] ) : '');
+ $mode = octdec(isset($attr['mode'] ) ? trim($attr['mode'] ) : '');
+ $uid = octdec(isset($attr['uid'] ) ? trim($attr['uid'] ) : '');
+ $gid = octdec(isset($attr['gid'] ) ? trim($attr['gid'] ) : '');
+ $size = octdec(isset($attr['size'] ) ? trim($attr['size'] ) : '');
+ $mtime = octdec(isset($attr['mtime'] ) ? trim($attr['mtime'] ) : '');
+ $chksum = octdec(isset($attr['chksum'] ) ? trim($attr['chksum'] ) : '');
+ $typflag = (isset($attr['typflag']) ? trim($attr['typflag']) : '');
+ $lnkname = (isset($attr['lnkname']) ? trim($attr['lnkname']) : '');
+ $magic = (isset($attr['magic'] ) ? trim($attr['magic'] ) : '');
+ $ver = (isset($attr['ver'] ) ? trim($attr['ver'] ) : '');
+ $uname = (isset($attr['uname'] ) ? trim($attr['uname'] ) : '');
+ $gname = (isset($attr['gname'] ) ? trim($attr['gname'] ) : '');
+ $devmaj = octdec(isset($attr['devmaj'] ) ? trim($attr['devmaj'] ) : '');
+ $devmin = octdec(isset($attr['devmin'] ) ? trim($attr['devmin'] ) : '');
+ $prefix = (isset($attr['prefix'] ) ? trim($attr['prefix'] ) : '');
if (($checksum == 256) && ($chksum == 0)) {
// EOF Found
break;
@@ -79,18 +82,18 @@ class getid3_tar {
}
// Read to the next chunk
- fseek($fd, $size, SEEK_CUR);
+ fseek($this->getid3->fp, $size, SEEK_CUR);
$diff = $size % 512;
if ($diff != 0) {
// Padding, throw away
- fseek($fd, (512 - $diff), SEEK_CUR);
+ fseek($this->getid3->fp, (512 - $diff), SEEK_CUR);
}
// Protect against tar-files with garbage at the end
if ($name == '') {
break;
}
- $ThisFileInfo['tar']['file_details'][$name] = array (
+ $info['tar']['file_details'][$name] = array (
'name' => $name,
'mode_raw' => $mode,
'mode' => getid3_tar::display_perms($mode),
@@ -108,7 +111,7 @@ class getid3_tar {
'devmajor' => $devmaj,
'devminor' => $devmin
);
- $ThisFileInfo['tar']['files'] = getid3_lib::array_merge_clobber($ThisFileInfo['tar']['files'], getid3_lib::CreateDeepArray($ThisFileInfo['tar']['file_details'][$name]['name'], '/', $size));
+ $info['tar']['files'] = getid3_lib::array_merge_clobber($info['tar']['files'], getid3_lib::CreateDeepArray($info['tar']['file_details'][$name]['name'], '/', $size));
}
return true;
}
@@ -167,7 +170,7 @@ class getid3_tar {
'S' => 'LF_SPARSE',
'V' => 'LF_VOLHDR'
);
- return @$flag_types[$typflag];
+ return (isset($flag_types[$typflag]) ? $flag_types[$typflag] : '');
}
}
diff --git a/apps/media/getID3/getid3/module.archive.zip.php b/3rdparty/getid3/module.archive.zip.php
index 1d2be0691f8..7db8fd23f13 100644
--- a/apps/media/getID3/getid3/module.archive.zip.php
+++ b/3rdparty/getid3/module.archive.zip.php
@@ -14,63 +14,67 @@
/////////////////////////////////////////////////////////////////
-class getid3_zip
+class getid3_zip extends getid3_handler
{
- function getid3_zip(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- $ThisFileInfo['fileformat'] = 'zip';
- $ThisFileInfo['zip']['encoding'] = 'ISO-8859-1';
- $ThisFileInfo['zip']['files'] = array();
+ $info['fileformat'] = 'zip';
+ $info['zip']['encoding'] = 'ISO-8859-1';
+ $info['zip']['files'] = array();
- $ThisFileInfo['zip']['compressed_size'] = 0;
- $ThisFileInfo['zip']['uncompressed_size'] = 0;
- $ThisFileInfo['zip']['entries_count'] = 0;
+ $info['zip']['compressed_size'] = 0;
+ $info['zip']['uncompressed_size'] = 0;
+ $info['zip']['entries_count'] = 0;
- if ($ThisFileInfo['filesize'] < pow(2, 31)) {
+ if (!getid3_lib::intValueSupported($info['filesize'])) {
+ $info['error'][] = 'File is larger than '.round(PHP_INT_MAX / 1073741824).'GB, not supported by PHP';
+ return false;
+ } else {
$EOCDsearchData = '';
$EOCDsearchCounter = 0;
while ($EOCDsearchCounter++ < 512) {
- fseek($fd, -128 * $EOCDsearchCounter, SEEK_END);
- $EOCDsearchData = fread($fd, 128).$EOCDsearchData;
+ fseek($this->getid3->fp, -128 * $EOCDsearchCounter, SEEK_END);
+ $EOCDsearchData = fread($this->getid3->fp, 128).$EOCDsearchData;
if (strstr($EOCDsearchData, 'PK'."\x05\x06")) {
$EOCDposition = strpos($EOCDsearchData, 'PK'."\x05\x06");
- fseek($fd, (-128 * $EOCDsearchCounter) + $EOCDposition, SEEK_END);
- $ThisFileInfo['zip']['end_central_directory'] = $this->ZIPparseEndOfCentralDirectory($fd);
+ fseek($this->getid3->fp, (-128 * $EOCDsearchCounter) + $EOCDposition, SEEK_END);
+ $info['zip']['end_central_directory'] = $this->ZIPparseEndOfCentralDirectory();
- fseek($fd, $ThisFileInfo['zip']['end_central_directory']['directory_offset'], SEEK_SET);
- $ThisFileInfo['zip']['entries_count'] = 0;
- while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($fd)) {
- $ThisFileInfo['zip']['central_directory'][] = $centraldirectoryentry;
- $ThisFileInfo['zip']['entries_count']++;
- $ThisFileInfo['zip']['compressed_size'] += $centraldirectoryentry['compressed_size'];
- $ThisFileInfo['zip']['uncompressed_size'] += $centraldirectoryentry['uncompressed_size'];
+ fseek($this->getid3->fp, $info['zip']['end_central_directory']['directory_offset'], SEEK_SET);
+ $info['zip']['entries_count'] = 0;
+ while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($this->getid3->fp)) {
+ $info['zip']['central_directory'][] = $centraldirectoryentry;
+ $info['zip']['entries_count']++;
+ $info['zip']['compressed_size'] += $centraldirectoryentry['compressed_size'];
+ $info['zip']['uncompressed_size'] += $centraldirectoryentry['uncompressed_size'];
if ($centraldirectoryentry['uncompressed_size'] > 0) {
- $ThisFileInfo['zip']['files'] = getid3_lib::array_merge_clobber($ThisFileInfo['zip']['files'], getid3_lib::CreateDeepArray($centraldirectoryentry['filename'], '/', $centraldirectoryentry['uncompressed_size']));
+ $info['zip']['files'] = getid3_lib::array_merge_clobber($info['zip']['files'], getid3_lib::CreateDeepArray($centraldirectoryentry['filename'], '/', $centraldirectoryentry['uncompressed_size']));
}
}
- if ($ThisFileInfo['zip']['entries_count'] == 0) {
- $ThisFileInfo['error'][] = 'No Central Directory entries found (truncated file?)';
+ if ($info['zip']['entries_count'] == 0) {
+ $info['error'][] = 'No Central Directory entries found (truncated file?)';
return false;
}
- if (!empty($ThisFileInfo['zip']['end_central_directory']['comment'])) {
- $ThisFileInfo['zip']['comments']['comment'][] = $ThisFileInfo['zip']['end_central_directory']['comment'];
+ if (!empty($info['zip']['end_central_directory']['comment'])) {
+ $info['zip']['comments']['comment'][] = $info['zip']['end_central_directory']['comment'];
}
- if (isset($ThisFileInfo['zip']['central_directory'][0]['compression_method'])) {
- $ThisFileInfo['zip']['compression_method'] = $ThisFileInfo['zip']['central_directory'][0]['compression_method'];
+ if (isset($info['zip']['central_directory'][0]['compression_method'])) {
+ $info['zip']['compression_method'] = $info['zip']['central_directory'][0]['compression_method'];
}
- if (isset($ThisFileInfo['zip']['central_directory'][0]['flags']['compression_speed'])) {
- $ThisFileInfo['zip']['compression_speed'] = $ThisFileInfo['zip']['central_directory'][0]['flags']['compression_speed'];
+ if (isset($info['zip']['central_directory'][0]['flags']['compression_speed'])) {
+ $info['zip']['compression_speed'] = $info['zip']['central_directory'][0]['flags']['compression_speed'];
}
- if (isset($ThisFileInfo['zip']['compression_method']) && ($ThisFileInfo['zip']['compression_method'] == 'store') && !isset($ThisFileInfo['zip']['compression_speed'])) {
- $ThisFileInfo['zip']['compression_speed'] = 'store';
+ if (isset($info['zip']['compression_method']) && ($info['zip']['compression_method'] == 'store') && !isset($info['zip']['compression_speed'])) {
+ $info['zip']['compression_speed'] = 'store';
}
return true;
@@ -79,88 +83,92 @@ class getid3_zip
}
}
- if ($this->getZIPentriesFilepointer($fd, $ThisFileInfo)) {
+ if ($this->getZIPentriesFilepointer()) {
// central directory couldn't be found and/or parsed
// scan through actual file data entries, recover as much as possible from probable trucated file
- if ($ThisFileInfo['zip']['compressed_size'] > ($ThisFileInfo['filesize'] - 46 - 22)) {
- $ThisFileInfo['error'][] = 'Warning: Truncated file! - Total compressed file sizes ('.$ThisFileInfo['zip']['compressed_size'].' bytes) is greater than filesize minus Central Directory and End Of Central Directory structures ('.($ThisFileInfo['filesize'] - 46 - 22).' bytes)';
+ if ($info['zip']['compressed_size'] > ($info['filesize'] - 46 - 22)) {
+ $info['error'][] = 'Warning: Truncated file! - Total compressed file sizes ('.$info['zip']['compressed_size'].' bytes) is greater than filesize minus Central Directory and End Of Central Directory structures ('.($info['filesize'] - 46 - 22).' bytes)';
}
- $ThisFileInfo['error'][] = 'Cannot find End Of Central Directory - returned list of files in [zip][entries] array may not be complete';
- foreach ($ThisFileInfo['zip']['entries'] as $key => $valuearray) {
- $ThisFileInfo['zip']['files'][$valuearray['filename']] = $valuearray['uncompressed_size'];
+ $info['error'][] = 'Cannot find End Of Central Directory - returned list of files in [zip][entries] array may not be complete';
+ foreach ($info['zip']['entries'] as $key => $valuearray) {
+ $info['zip']['files'][$valuearray['filename']] = $valuearray['uncompressed_size'];
}
return true;
} else {
- unset($ThisFileInfo['zip']);
- $ThisFileInfo['fileformat'] = '';
- $ThisFileInfo['error'][] = 'Cannot find End Of Central Directory (truncated file?)';
+ unset($info['zip']);
+ $info['fileformat'] = '';
+ $info['error'][] = 'Cannot find End Of Central Directory (truncated file?)';
return false;
}
}
- function getZIPHeaderFilepointerTopDown(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'zip';
+ function getZIPHeaderFilepointerTopDown() {
+ $info = &$this->getid3->info;
- $ThisFileInfo['zip']['compressed_size'] = 0;
- $ThisFileInfo['zip']['uncompressed_size'] = 0;
- $ThisFileInfo['zip']['entries_count'] = 0;
+ $info['fileformat'] = 'zip';
- rewind($fd);
- while ($fileentry = $this->ZIPparseLocalFileHeader($fd)) {
- $ThisFileInfo['zip']['entries'][] = $fileentry;
- $ThisFileInfo['zip']['entries_count']++;
+ $info['zip']['compressed_size'] = 0;
+ $info['zip']['uncompressed_size'] = 0;
+ $info['zip']['entries_count'] = 0;
+
+ rewind($this->getid3->fp);
+ while ($fileentry = $this->ZIPparseLocalFileHeader()) {
+ $info['zip']['entries'][] = $fileentry;
+ $info['zip']['entries_count']++;
}
- if ($ThisFileInfo['zip']['entries_count'] == 0) {
- $ThisFileInfo['error'][] = 'No Local File Header entries found';
+ if ($info['zip']['entries_count'] == 0) {
+ $info['error'][] = 'No Local File Header entries found';
return false;
}
- $ThisFileInfo['zip']['entries_count'] = 0;
- while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($fd)) {
- $ThisFileInfo['zip']['central_directory'][] = $centraldirectoryentry;
- $ThisFileInfo['zip']['entries_count']++;
- $ThisFileInfo['zip']['compressed_size'] += $centraldirectoryentry['compressed_size'];
- $ThisFileInfo['zip']['uncompressed_size'] += $centraldirectoryentry['uncompressed_size'];
+ $info['zip']['entries_count'] = 0;
+ while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($this->getid3->fp)) {
+ $info['zip']['central_directory'][] = $centraldirectoryentry;
+ $info['zip']['entries_count']++;
+ $info['zip']['compressed_size'] += $centraldirectoryentry['compressed_size'];
+ $info['zip']['uncompressed_size'] += $centraldirectoryentry['uncompressed_size'];
}
- if ($ThisFileInfo['zip']['entries_count'] == 0) {
- $ThisFileInfo['error'][] = 'No Central Directory entries found (truncated file?)';
+ if ($info['zip']['entries_count'] == 0) {
+ $info['error'][] = 'No Central Directory entries found (truncated file?)';
return false;
}
- if ($EOCD = $this->ZIPparseEndOfCentralDirectory($fd)) {
- $ThisFileInfo['zip']['end_central_directory'] = $EOCD;
+ if ($EOCD = $this->ZIPparseEndOfCentralDirectory()) {
+ $info['zip']['end_central_directory'] = $EOCD;
} else {
- $ThisFileInfo['error'][] = 'No End Of Central Directory entry found (truncated file?)';
+ $info['error'][] = 'No End Of Central Directory entry found (truncated file?)';
return false;
}
- if (!empty($ThisFileInfo['zip']['end_central_directory']['comment'])) {
- $ThisFileInfo['zip']['comments']['comment'][] = $ThisFileInfo['zip']['end_central_directory']['comment'];
+ if (!empty($info['zip']['end_central_directory']['comment'])) {
+ $info['zip']['comments']['comment'][] = $info['zip']['end_central_directory']['comment'];
}
return true;
}
- function getZIPentriesFilepointer(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['zip']['compressed_size'] = 0;
- $ThisFileInfo['zip']['uncompressed_size'] = 0;
- $ThisFileInfo['zip']['entries_count'] = 0;
+ function getZIPentriesFilepointer() {
+ $info = &$this->getid3->info;
+
+ $info['zip']['compressed_size'] = 0;
+ $info['zip']['uncompressed_size'] = 0;
+ $info['zip']['entries_count'] = 0;
- rewind($fd);
- while ($fileentry = $this->ZIPparseLocalFileHeader($fd)) {
- $ThisFileInfo['zip']['entries'][] = $fileentry;
- $ThisFileInfo['zip']['entries_count']++;
- $ThisFileInfo['zip']['compressed_size'] += $fileentry['compressed_size'];
- $ThisFileInfo['zip']['uncompressed_size'] += $fileentry['uncompressed_size'];
+ rewind($this->getid3->fp);
+ while ($fileentry = $this->ZIPparseLocalFileHeader()) {
+ $info['zip']['entries'][] = $fileentry;
+ $info['zip']['entries_count']++;
+ $info['zip']['compressed_size'] += $fileentry['compressed_size'];
+ $info['zip']['uncompressed_size'] += $fileentry['uncompressed_size'];
}
- if ($ThisFileInfo['zip']['entries_count'] == 0) {
- $ThisFileInfo['error'][] = 'No Local File Header entries found';
+ if ($info['zip']['entries_count'] == 0) {
+ $info['error'][] = 'No Local File Header entries found';
return false;
}
@@ -168,15 +176,15 @@ class getid3_zip
}
- function ZIPparseLocalFileHeader(&$fd) {
- $LocalFileHeader['offset'] = ftell($fd);
+ function ZIPparseLocalFileHeader() {
+ $LocalFileHeader['offset'] = ftell($this->getid3->fp);
- $ZIPlocalFileHeader = fread($fd, 30);
+ $ZIPlocalFileHeader = fread($this->getid3->fp, 30);
$LocalFileHeader['raw']['signature'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 0, 4));
if ($LocalFileHeader['raw']['signature'] != 0x04034B50) {
// invalid Local File Header Signature
- fseek($fd, $LocalFileHeader['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
+ fseek($this->getid3->fp, $LocalFileHeader['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
return false;
}
$LocalFileHeader['raw']['extract_version'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 4, 2));
@@ -200,7 +208,7 @@ class getid3_zip
$FilenameExtrafieldLength = $LocalFileHeader['raw']['filename_length'] + $LocalFileHeader['raw']['extra_field_length'];
if ($FilenameExtrafieldLength > 0) {
- $ZIPlocalFileHeader .= fread($fd, $FilenameExtrafieldLength);
+ $ZIPlocalFileHeader .= fread($this->getid3->fp, $FilenameExtrafieldLength);
if ($LocalFileHeader['raw']['filename_length'] > 0) {
$LocalFileHeader['filename'] = substr($ZIPlocalFileHeader, 30, $LocalFileHeader['raw']['filename_length']);
@@ -210,12 +218,12 @@ class getid3_zip
}
}
- $LocalFileHeader['data_offset'] = ftell($fd);
- //$LocalFileHeader['compressed_data'] = fread($fd, $LocalFileHeader['raw']['compressed_size']);
- fseek($fd, $LocalFileHeader['raw']['compressed_size'], SEEK_CUR);
+ $LocalFileHeader['data_offset'] = ftell($this->getid3->fp);
+ //$LocalFileHeader['compressed_data'] = fread($this->getid3->fp, $LocalFileHeader['raw']['compressed_size']);
+ fseek($this->getid3->fp, $LocalFileHeader['raw']['compressed_size'], SEEK_CUR);
if ($LocalFileHeader['flags']['data_descriptor_used']) {
- $DataDescriptor = fread($fd, 12);
+ $DataDescriptor = fread($this->getid3->fp, 12);
$LocalFileHeader['data_descriptor']['crc_32'] = getid3_lib::LittleEndian2Int(substr($DataDescriptor, 0, 4));
$LocalFileHeader['data_descriptor']['compressed_size'] = getid3_lib::LittleEndian2Int(substr($DataDescriptor, 4, 4));
$LocalFileHeader['data_descriptor']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($DataDescriptor, 8, 4));
@@ -225,15 +233,15 @@ class getid3_zip
}
- function ZIPparseCentralDirectory(&$fd) {
- $CentralDirectory['offset'] = ftell($fd);
+ function ZIPparseCentralDirectory() {
+ $CentralDirectory['offset'] = ftell($this->getid3->fp);
- $ZIPcentralDirectory = fread($fd, 46);
+ $ZIPcentralDirectory = fread($this->getid3->fp, 46);
$CentralDirectory['raw']['signature'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 0, 4));
if ($CentralDirectory['raw']['signature'] != 0x02014B50) {
// invalid Central Directory Signature
- fseek($fd, $CentralDirectory['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
+ fseek($this->getid3->fp, $CentralDirectory['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
return false;
}
$CentralDirectory['raw']['create_version'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 4, 2));
@@ -265,7 +273,7 @@ class getid3_zip
$FilenameExtrafieldCommentLength = $CentralDirectory['raw']['filename_length'] + $CentralDirectory['raw']['extra_field_length'] + $CentralDirectory['raw']['file_comment_length'];
if ($FilenameExtrafieldCommentLength > 0) {
- $FilenameExtrafieldComment = fread($fd, $FilenameExtrafieldCommentLength);
+ $FilenameExtrafieldComment = fread($this->getid3->fp, $FilenameExtrafieldCommentLength);
if ($CentralDirectory['raw']['filename_length'] > 0) {
$CentralDirectory['filename'] = substr($FilenameExtrafieldComment, 0, $CentralDirectory['raw']['filename_length']);
@@ -281,15 +289,15 @@ class getid3_zip
return $CentralDirectory;
}
- function ZIPparseEndOfCentralDirectory(&$fd) {
- $EndOfCentralDirectory['offset'] = ftell($fd);
+ function ZIPparseEndOfCentralDirectory() {
+ $EndOfCentralDirectory['offset'] = ftell($this->getid3->fp);
- $ZIPendOfCentralDirectory = fread($fd, 22);
+ $ZIPendOfCentralDirectory = fread($this->getid3->fp, 22);
$EndOfCentralDirectory['signature'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 0, 4));
if ($EndOfCentralDirectory['signature'] != 0x06054B50) {
// invalid End Of Central Directory Signature
- fseek($fd, $EndOfCentralDirectory['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
+ fseek($this->getid3->fp, $EndOfCentralDirectory['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
return false;
}
$EndOfCentralDirectory['disk_number_current'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 4, 2));
@@ -301,14 +309,14 @@ class getid3_zip
$EndOfCentralDirectory['comment_length'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 20, 2));
if ($EndOfCentralDirectory['comment_length'] > 0) {
- $EndOfCentralDirectory['comment'] = fread($fd, $EndOfCentralDirectory['comment_length']);
+ $EndOfCentralDirectory['comment'] = fread($this->getid3->fp, $EndOfCentralDirectory['comment_length']);
}
return $EndOfCentralDirectory;
}
- function ZIPparseGeneralPurposeFlags($flagbytes, $compressionmethod) {
+ static function ZIPparseGeneralPurposeFlags($flagbytes, $compressionmethod) {
$ParsedFlags['encrypted'] = (bool) ($flagbytes & 0x0001);
switch ($compressionmethod) {
@@ -341,7 +349,7 @@ class getid3_zip
}
- function ZIPversionOSLookup($index) {
+ static function ZIPversionOSLookup($index) {
static $ZIPversionOSLookup = array(
0 => 'MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)',
1 => 'Amiga',
@@ -366,7 +374,7 @@ class getid3_zip
return (isset($ZIPversionOSLookup[$index]) ? $ZIPversionOSLookup[$index] : '[unknown]');
}
- function ZIPcompressionMethodLookup($index) {
+ static function ZIPcompressionMethodLookup($index) {
static $ZIPcompressionMethodLookup = array(
0 => 'store',
1 => 'shrink',
@@ -384,7 +392,7 @@ class getid3_zip
return (isset($ZIPcompressionMethodLookup[$index]) ? $ZIPcompressionMethodLookup[$index] : '[unknown]');
}
- function DOStime2UNIXtime($DOSdate, $DOStime) {
+ static function DOStime2UNIXtime($DOSdate, $DOStime) {
// wFatDate
// Specifies the MS-DOS date. The date is a packed 16-bit value with the following format:
// Bits Contents
diff --git a/apps/media/getID3/getid3/module.audio-video.asf.php b/3rdparty/getid3/module.audio-video.asf.php
index 4526291be23..0bb095f52ee 100644
--- a/apps/media/getID3/getid3/module.audio-video.asf.php
+++ b/3rdparty/getid3/module.audio-video.asf.php
@@ -15,24 +15,29 @@
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
-$GUIDarray = getid3_asf::KnownGUIDs();
-foreach ($GUIDarray as $GUIDname => $hexstringvalue) {
- // initialize all GUID constants
- define($GUIDname, getid3_asf::GUIDtoBytestring($hexstringvalue));
-}
-
+class getid3_asf extends getid3_handler
+{
+ function __construct(getID3 $getid3) {
+ parent::__construct($getid3); // extends getid3_handler::__construct()
-class getid3_asf
-{
+ // initialize all GUID constants
+ $GUIDarray = $this->KnownGUIDs();
+ foreach ($GUIDarray as $GUIDname => $hexstringvalue) {
+ if (!defined($GUIDname)) {
+ define($GUIDname, $this->GUIDtoBytestring($hexstringvalue));
+ }
+ }
+ }
- function getid3_asf(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
// Shortcuts
- $thisfile_audio = &$ThisFileInfo['audio'];
- $thisfile_video = &$ThisFileInfo['video'];
- $ThisFileInfo['asf'] = array();
- $thisfile_asf = &$ThisFileInfo['asf'];
+ $thisfile_audio = &$info['audio'];
+ $thisfile_video = &$info['video'];
+ $info['asf'] = array();
+ $thisfile_asf = &$info['asf'];
$thisfile_asf['comments'] = array();
$thisfile_asf_comments = &$thisfile_asf['comments'];
$thisfile_asf['header_object'] = array();
@@ -59,17 +64,17 @@ class getid3_asf
// Reserved1 BYTE 8 // hardcoded: 0x01
// Reserved2 BYTE 8 // hardcoded: 0x02
- $ThisFileInfo['fileformat'] = 'asf';
+ $info['fileformat'] = 'asf';
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $HeaderObjectData = fread($fd, 30);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $HeaderObjectData = fread($this->getid3->fp, 30);
$thisfile_asf_headerobject['objectid'] = substr($HeaderObjectData, 0, 16);
$thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']);
if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) {
- $ThisFileInfo['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).'}';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['asf']);
+ $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).'}';
+ unset($info['fileformat']);
+ unset($info['asf']);
return false;
break;
}
@@ -78,11 +83,12 @@ class getid3_asf
$thisfile_asf_headerobject['reserved1'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1));
$thisfile_asf_headerobject['reserved2'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1));
- $ASFHeaderData = fread($fd, $thisfile_asf_headerobject['objectsize'] - 30);
+ $NextObjectOffset = ftell($this->getid3->fp);
+ $ASFHeaderData = fread($this->getid3->fp, $thisfile_asf_headerobject['objectsize'] - 30);
$offset = 0;
for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) {
- $NextObjectGUID = substr($ASFHeaderData, $offset, 16);
+ $NextObjectGUID = substr($ASFHeaderData, $offset, 16);
$offset += 16;
$NextObjectGUIDtext = $this->BytestringToGUID($NextObjectGUID);
$NextObjectSize = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
@@ -113,6 +119,7 @@ class getid3_asf
$thisfile_asf['file_properties_object'] = array();
$thisfile_asf_filepropertiesobject = &$thisfile_asf['file_properties_object'];
+ $thisfile_asf_filepropertiesobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_filepropertiesobject['objectid'] = $NextObjectGUID;
$thisfile_asf_filepropertiesobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_filepropertiesobject['objectsize'] = $NextObjectSize;
@@ -157,10 +164,10 @@ class getid3_asf
} else {
// broadcast flag NOT set, perform calculations
- $ThisFileInfo['playtime_seconds'] = ($thisfile_asf_filepropertiesobject['play_duration'] / 10000000) - ($thisfile_asf_filepropertiesobject['preroll'] / 1000);
+ $info['playtime_seconds'] = ($thisfile_asf_filepropertiesobject['play_duration'] / 10000000) - ($thisfile_asf_filepropertiesobject['preroll'] / 1000);
- //$ThisFileInfo['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate'];
- $ThisFileInfo['bitrate'] = ((isset($thisfile_asf_filepropertiesobject['filesize']) ? $thisfile_asf_filepropertiesobject['filesize'] : $ThisFileInfo['filesize']) * 8) / $ThisFileInfo['playtime_seconds'];
+ //$info['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate'];
+ $info['bitrate'] = ((isset($thisfile_asf_filepropertiesobject['filesize']) ? $thisfile_asf_filepropertiesobject['filesize'] : $info['filesize']) * 8) / $info['playtime_seconds'];
}
break;
@@ -186,6 +193,7 @@ class getid3_asf
// stream number isn't known until halfway through decoding the structure, hence it
// it is decoded to a temporary variable and then stuck in the appropriate index later
+ $StreamPropertiesObjectData['offset'] = $NextObjectOffset + $offset;
$StreamPropertiesObjectData['objectid'] = $NextObjectGUID;
$StreamPropertiesObjectData['objectid_guid'] = $NextObjectGUIDtext;
$StreamPropertiesObjectData['objectsize'] = $NextObjectSize;
@@ -253,6 +261,7 @@ class getid3_asf
$thisfile_asf['header_extension_object'] = array();
$thisfile_asf_headerextensionobject = &$thisfile_asf['header_extension_object'];
+ $thisfile_asf_headerextensionobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_headerextensionobject['objectid'] = $NextObjectGUID;
$thisfile_asf_headerextensionobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_headerextensionobject['objectsize'] = $NextObjectSize;
@@ -260,20 +269,25 @@ class getid3_asf
$offset += 16;
$thisfile_asf_headerextensionobject['reserved_1_guid'] = $this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']);
if ($thisfile_asf_headerextensionobject['reserved_1'] != GETID3_ASF_Reserved_1) {
- $ThisFileInfo['warning'][] = 'header_extension_object.reserved_1 GUID ('.$this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']).') does not match expected "GETID3_ASF_Reserved_1" GUID ('.$this->BytestringToGUID(GETID3_ASF_Reserved_1).')';
+ $info['warning'][] = 'header_extension_object.reserved_1 GUID ('.$this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']).') does not match expected "GETID3_ASF_Reserved_1" GUID ('.$this->BytestringToGUID(GETID3_ASF_Reserved_1).')';
//return false;
break;
}
$thisfile_asf_headerextensionobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
$offset += 2;
if ($thisfile_asf_headerextensionobject['reserved_2'] != 6) {
- $ThisFileInfo['warning'][] = 'header_extension_object.reserved_2 ('.getid3_lib::PrintHexBytes($thisfile_asf_headerextensionobject['reserved_2']).') does not match expected value of "6"';
+ $info['warning'][] = 'header_extension_object.reserved_2 ('.getid3_lib::PrintHexBytes($thisfile_asf_headerextensionobject['reserved_2']).') does not match expected value of "6"';
//return false;
break;
}
$thisfile_asf_headerextensionobject['extension_data_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
$offset += 4;
$thisfile_asf_headerextensionobject['extension_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_headerextensionobject['extension_data_size']);
+ $unhandled_sections = 0;
+ $thisfile_asf_headerextensionobject['extension_data_parsed'] = $this->ASF_HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections);
+ if ($unhandled_sections === 0) {
+ unset($thisfile_asf_headerextensionobject['extension_data']);
+ }
$offset += $thisfile_asf_headerextensionobject['extension_data_size'];
break;
@@ -297,6 +311,7 @@ class getid3_asf
$thisfile_asf['codec_list_object'] = array();
$thisfile_asf_codeclistobject = &$thisfile_asf['codec_list_object'];
+ $thisfile_asf_codeclistobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_codeclistobject['objectid'] = $NextObjectGUID;
$thisfile_asf_codeclistobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_codeclistobject['objectsize'] = $NextObjectSize;
@@ -304,7 +319,7 @@ class getid3_asf
$offset += 16;
$thisfile_asf_codeclistobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']);
if ($thisfile_asf_codeclistobject['reserved'] != $this->GUIDtoBytestring('86D15241-311D-11D0-A3A4-00A0C90348F6')) {
- $ThisFileInfo['warning'][] = 'codec_list_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {86D15241-311D-11D0-A3A4-00A0C90348F6}';
+ $info['warning'][] = 'codec_list_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {86D15241-311D-11D0-A3A4-00A0C90348F6}';
//return false;
break;
}
@@ -334,82 +349,84 @@ class getid3_asf
$thisfile_asf_codeclistobject_codecentries_current['information'] = substr($ASFHeaderData, $offset, $CodecInformationLength);
$offset += $CodecInformationLength;
- if ($thisfile_asf_codeclistobject_codecentries_current['type_raw'] == 2) {
- // audio codec
+ if ($thisfile_asf_codeclistobject_codecentries_current['type_raw'] == 2) { // audio codec
+
if (strpos($thisfile_asf_codeclistobject_codecentries_current['description'], ',') === false) {
- $ThisFileInfo['error'][] = '[asf][codec_list_object][codec_entries]['.$CodecEntryCounter.'][description] expected to contain comma-seperated list of parameters: "'.$thisfile_asf_codeclistobject_codecentries_current['description'].'"';
- return false;
- }
- list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(',', $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']));
- $thisfile_audio['codec'] = $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['name']);
+ $info['warning'][] = '[asf][codec_list_object][codec_entries]['.$CodecEntryCounter.'][description] expected to contain comma-seperated list of parameters: "'.$thisfile_asf_codeclistobject_codecentries_current['description'].'"';
+ } else {
- if (!isset($thisfile_audio['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) {
- $thisfile_audio['bitrate'] = (int) (trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000);
- }
- //if (!isset($thisfile_video['bitrate']) && isset($thisfile_audio['bitrate']) && isset($thisfile_asf['file_properties_object']['max_bitrate']) && ($thisfile_asf_codeclistobject['codec_entries_count'] > 1)) {
- if (!@$thisfile_video['bitrate'] && @$thisfile_audio['bitrate'] && @$ThisFileInfo['bitrate']) {
- //$thisfile_video['bitrate'] = $thisfile_asf['file_properties_object']['max_bitrate'] - $thisfile_audio['bitrate'];
- $thisfile_video['bitrate'] = $ThisFileInfo['bitrate'] - $thisfile_audio['bitrate'];
- }
+ list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(',', $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']));
+ $thisfile_audio['codec'] = $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['name']);
- $AudioCodecFrequency = (int) trim(str_replace('kHz', '', $AudioCodecFrequency));
- switch ($AudioCodecFrequency) {
- case 8:
- case 8000:
- $thisfile_audio['sample_rate'] = 8000;
- break;
+ if (!isset($thisfile_audio['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) {
+ $thisfile_audio['bitrate'] = (int) (trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000);
+ }
+ //if (!isset($thisfile_video['bitrate']) && isset($thisfile_audio['bitrate']) && isset($thisfile_asf['file_properties_object']['max_bitrate']) && ($thisfile_asf_codeclistobject['codec_entries_count'] > 1)) {
+ if (empty($thisfile_video['bitrate']) && !empty($thisfile_audio['bitrate']) && !empty($info['bitrate'])) {
+ //$thisfile_video['bitrate'] = $thisfile_asf['file_properties_object']['max_bitrate'] - $thisfile_audio['bitrate'];
+ $thisfile_video['bitrate'] = $info['bitrate'] - $thisfile_audio['bitrate'];
+ }
- case 11:
- case 11025:
- $thisfile_audio['sample_rate'] = 11025;
- break;
+ $AudioCodecFrequency = (int) trim(str_replace('kHz', '', $AudioCodecFrequency));
+ switch ($AudioCodecFrequency) {
+ case 8:
+ case 8000:
+ $thisfile_audio['sample_rate'] = 8000;
+ break;
- case 12:
- case 12000:
- $thisfile_audio['sample_rate'] = 12000;
- break;
+ case 11:
+ case 11025:
+ $thisfile_audio['sample_rate'] = 11025;
+ break;
- case 16:
- case 16000:
- $thisfile_audio['sample_rate'] = 16000;
- break;
+ case 12:
+ case 12000:
+ $thisfile_audio['sample_rate'] = 12000;
+ break;
- case 22:
- case 22050:
- $thisfile_audio['sample_rate'] = 22050;
- break;
+ case 16:
+ case 16000:
+ $thisfile_audio['sample_rate'] = 16000;
+ break;
- case 24:
- case 24000:
- $thisfile_audio['sample_rate'] = 24000;
- break;
+ case 22:
+ case 22050:
+ $thisfile_audio['sample_rate'] = 22050;
+ break;
- case 32:
- case 32000:
- $thisfile_audio['sample_rate'] = 32000;
- break;
+ case 24:
+ case 24000:
+ $thisfile_audio['sample_rate'] = 24000;
+ break;
- case 44:
- case 441000:
- $thisfile_audio['sample_rate'] = 44100;
- break;
+ case 32:
+ case 32000:
+ $thisfile_audio['sample_rate'] = 32000;
+ break;
- case 48:
- case 48000:
- $thisfile_audio['sample_rate'] = 48000;
- break;
+ case 44:
+ case 441000:
+ $thisfile_audio['sample_rate'] = 44100;
+ break;
- default:
- $ThisFileInfo['warning'][] = 'unknown frequency: "'.$AudioCodecFrequency.'" ('.$this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']).')';
- break;
- }
+ case 48:
+ case 48000:
+ $thisfile_audio['sample_rate'] = 48000;
+ break;
+
+ default:
+ $info['warning'][] = 'unknown frequency: "'.$AudioCodecFrequency.'" ('.$this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']).')';
+ break;
+ }
- if (!isset($thisfile_audio['channels'])) {
- if (strstr($AudioCodecChannels, 'stereo')) {
- $thisfile_audio['channels'] = 2;
- } elseif (strstr($AudioCodecChannels, 'mono')) {
- $thisfile_audio['channels'] = 1;
+ if (!isset($thisfile_audio['channels'])) {
+ if (strstr($AudioCodecChannels, 'stereo')) {
+ $thisfile_audio['channels'] = 2;
+ } elseif (strstr($AudioCodecChannels, 'mono')) {
+ $thisfile_audio['channels'] = 1;
+ }
}
+
}
}
}
@@ -436,6 +453,7 @@ class getid3_asf
$thisfile_asf['script_command_object'] = array();
$thisfile_asf_scriptcommandobject = &$thisfile_asf['script_command_object'];
+ $thisfile_asf_scriptcommandobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_scriptcommandobject['objectid'] = $NextObjectGUID;
$thisfile_asf_scriptcommandobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_scriptcommandobject['objectsize'] = $NextObjectSize;
@@ -443,7 +461,7 @@ class getid3_asf
$offset += 16;
$thisfile_asf_scriptcommandobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']);
if ($thisfile_asf_scriptcommandobject['reserved'] != $this->GUIDtoBytestring('4B1ACBE3-100B-11D0-A39B-00A0C90348F6')) {
- $ThisFileInfo['warning'][] = 'script_command_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4B1ACBE3-100B-11D0-A39B-00A0C90348F6}';
+ $info['warning'][] = 'script_command_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4B1ACBE3-100B-11D0-A39B-00A0C90348F6}';
//return false;
break;
}
@@ -494,6 +512,7 @@ class getid3_asf
$thisfile_asf['marker_object'] = array();
$thisfile_asf_markerobject = &$thisfile_asf['marker_object'];
+ $thisfile_asf_markerobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_markerobject['objectid'] = $NextObjectGUID;
$thisfile_asf_markerobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_markerobject['objectsize'] = $NextObjectSize;
@@ -501,7 +520,7 @@ class getid3_asf
$offset += 16;
$thisfile_asf_markerobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_markerobject['reserved']);
if ($thisfile_asf_markerobject['reserved'] != $this->GUIDtoBytestring('4CFEDB20-75F6-11CF-9C0F-00A0C90349CB')) {
- $ThisFileInfo['warning'][] = 'marker_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_markerobject['reserved_1']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}';
+ $info['warning'][] = 'marker_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_markerobject['reserved_1']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}';
break;
}
$thisfile_asf_markerobject['markers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
@@ -509,7 +528,7 @@ class getid3_asf
$thisfile_asf_markerobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
$offset += 2;
if ($thisfile_asf_markerobject['reserved_2'] != 0) {
- $ThisFileInfo['warning'][] = 'marker_object.reserved_2 ('.getid3_lib::PrintHexBytes($thisfile_asf_markerobject['reserved_2']).') does not match expected value of "0"';
+ $info['warning'][] = 'marker_object.reserved_2 ('.getid3_lib::PrintHexBytes($thisfile_asf_markerobject['reserved_2']).') does not match expected value of "0"';
break;
}
$thisfile_asf_markerobject['name_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
@@ -552,6 +571,7 @@ class getid3_asf
$thisfile_asf['bitrate_mutual_exclusion_object'] = array();
$thisfile_asf_bitratemutualexclusionobject = &$thisfile_asf['bitrate_mutual_exclusion_object'];
+ $thisfile_asf_bitratemutualexclusionobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_bitratemutualexclusionobject['objectid'] = $NextObjectGUID;
$thisfile_asf_bitratemutualexclusionobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_bitratemutualexclusionobject['objectsize'] = $NextObjectSize;
@@ -559,7 +579,7 @@ class getid3_asf
$thisfile_asf_bitratemutualexclusionobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']);
$offset += 16;
if (($thisfile_asf_bitratemutualexclusionobject['reserved'] != GETID3_ASF_Mutex_Bitrate) && ($thisfile_asf_bitratemutualexclusionobject['reserved'] != GETID3_ASF_Mutex_Unknown)) {
- $ThisFileInfo['warning'][] = 'bitrate_mutual_exclusion_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']).'} does not match expected "GETID3_ASF_Mutex_Bitrate" GUID {'.$this->BytestringToGUID(GETID3_ASF_Mutex_Bitrate).'} or "GETID3_ASF_Mutex_Unknown" GUID {'.$this->BytestringToGUID(GETID3_ASF_Mutex_Unknown).'}';
+ $info['warning'][] = 'bitrate_mutual_exclusion_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']).'} does not match expected "GETID3_ASF_Mutex_Bitrate" GUID {'.$this->BytestringToGUID(GETID3_ASF_Mutex_Bitrate).'} or "GETID3_ASF_Mutex_Unknown" GUID {'.$this->BytestringToGUID(GETID3_ASF_Mutex_Unknown).'}';
//return false;
break;
}
@@ -584,6 +604,7 @@ class getid3_asf
$thisfile_asf['error_correction_object'] = array();
$thisfile_asf_errorcorrectionobject = &$thisfile_asf['error_correction_object'];
+ $thisfile_asf_errorcorrectionobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_errorcorrectionobject['objectid'] = $NextObjectGUID;
$thisfile_asf_errorcorrectionobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_errorcorrectionobject['objectsize'] = $NextObjectSize;
@@ -619,7 +640,7 @@ class getid3_asf
break;
default:
- $ThisFileInfo['warning'][] = 'error_correction_object.error_correction_type GUID {'.$this->BytestringToGUID($thisfile_asf_errorcorrectionobject['reserved']).'} does not match expected "GETID3_ASF_No_Error_Correction" GUID {'.$this->BytestringToGUID(GETID3_ASF_No_Error_Correction).'} or "GETID3_ASF_Audio_Spread" GUID {'.$this->BytestringToGUID(GETID3_ASF_Audio_Spread).'}';
+ $info['warning'][] = 'error_correction_object.error_correction_type GUID {'.$this->BytestringToGUID($thisfile_asf_errorcorrectionobject['reserved']).'} does not match expected "GETID3_ASF_No_Error_Correction" GUID {'.$this->BytestringToGUID(GETID3_ASF_No_Error_Correction).'} or "GETID3_ASF_Audio_Spread" GUID {'.$this->BytestringToGUID(GETID3_ASF_Audio_Spread).'}';
//return false;
break;
}
@@ -646,6 +667,7 @@ class getid3_asf
$thisfile_asf['content_description_object'] = array();
$thisfile_asf_contentdescriptionobject = &$thisfile_asf['content_description_object'];
+ $thisfile_asf_contentdescriptionobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_contentdescriptionobject['objectid'] = $NextObjectGUID;
$thisfile_asf_contentdescriptionobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_contentdescriptionobject['objectsize'] = $NextObjectSize;
@@ -701,6 +723,7 @@ class getid3_asf
$thisfile_asf['extended_content_description_object'] = array();
$thisfile_asf_extendedcontentdescriptionobject = &$thisfile_asf['extended_content_description_object'];
+ $thisfile_asf_extendedcontentdescriptionobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_extendedcontentdescriptionobject['objectid'] = $NextObjectGUID;
$thisfile_asf_extendedcontentdescriptionobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_extendedcontentdescriptionobject['objectsize'] = $NextObjectSize;
@@ -709,7 +732,7 @@ class getid3_asf
for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) {
// shortcut
$thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter] = array();
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current = &$thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter];
+ $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current = &$thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter];
$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['base_offset'] = $offset + 30;
$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
@@ -741,7 +764,7 @@ class getid3_asf
break;
default:
- $ThisFileInfo['warning'][] = 'extended_content_description.content_descriptors.'.$ExtendedContentDescriptorsCounter.'.value_type is invalid ('.$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type'].')';
+ $info['warning'][] = 'extended_content_description.content_descriptors.'.$ExtendedContentDescriptorsCounter.'.value_type is invalid ('.$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type'].')';
//return false;
break;
}
@@ -749,7 +772,8 @@ class getid3_asf
case 'wm/albumartist':
case 'artist':
- $thisfile_asf_comments['artist'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
+ // Note: not 'artist', that comes from 'author' tag
+ $thisfile_asf_comments['albumartist'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
break;
case 'wm/albumtitle':
@@ -762,9 +786,19 @@ class getid3_asf
$thisfile_asf_comments['genre'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
break;
+ case 'wm/partofset':
+ $thisfile_asf_comments['partofset'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
+ break;
+
case 'wm/tracknumber':
case 'tracknumber':
- $thisfile_asf_comments['track'] = array(intval($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'])));
+ // be careful casting to int: casting unicode strings to int gives unexpected results (stops parsing at first non-numeric character)
+ $thisfile_asf_comments['track'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
+ foreach ($thisfile_asf_comments['track'] as $key => $value) {
+ if (preg_match('/^[0-9\x00]+$/', $value)) {
+ $thisfile_asf_comments['track'][$key] = intval(str_replace("\x00", '', $value));
+ }
+ }
break;
case 'wm/track':
@@ -794,20 +828,20 @@ class getid3_asf
case 'id3':
// id3v2 module might not be loaded
if (class_exists('getid3_id3v2')) {
- $tempfile = tempnam('*', 'getID3');
- $tempfilehandle = fopen($tempfile, "wb");
- $tempThisfileInfo = array('encoding'=>$ThisFileInfo['encoding']);
+ $tempfile = tempnam(GETID3_TEMP_DIR, 'getID3');
+ $tempfilehandle = fopen($tempfile, 'wb');
+ $tempThisfileInfo = array('encoding'=>$info['encoding']);
fwrite($tempfilehandle, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
fclose($tempfilehandle);
- $tempfilehandle = fopen($tempfile, "rb");
- $id3 = new getid3_id3v2($tempfilehandle, $tempThisfileInfo);
- unset($id3);
- fclose($tempfilehandle);
- unlink($tempfile);
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($tempfile);
+ $getid3_id3v2 = new getid3_id3v2($getid3_temp);
+ $getid3_id3v2->Analyze();
+ $info['id3v2'] = $getid3_temp->info['id3v2'];
+ unset($getid3_temp, $getid3_id3v2);
- $ThisFileInfo['id3v2'] = $tempThisfileInfo['id3v2'];
- unset($tempThisfileInfo);
+ unlink($tempfile);
}
break;
@@ -817,14 +851,12 @@ class getid3_asf
break;
case 'wm/picture':
- //typedef struct _WMPicture{
- // LPWSTR pwszMIMEType;
- // BYTE bPictureType;
- // LPWSTR pwszDescription;
- // DWORD dwDataLen;
- // BYTE* pbData;
- //} WM_PICTURE;
-
+ $WMpicture = $this->ASF_WMpicture($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
+ foreach ($WMpicture as $key => $value) {
+ $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[$key] = $value;
+ }
+ unset($WMpicture);
+/*
$wm_picture_offset = 0;
$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 1));
$wm_picture_offset += 1;
@@ -850,6 +882,18 @@ class getid3_asf
$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'] = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset);
unset($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
+ $imageinfo = array();
+ $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = '';
+ $imagechunkcheck = getid3_lib::GetDataImageSize($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'], $imageinfo);
+ unset($imageinfo);
+ if (!empty($imagechunkcheck)) {
+ $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
+ }
+ if (!isset($thisfile_asf_comments['picture'])) {
+ $thisfile_asf_comments['picture'] = array();
+ }
+ $thisfile_asf_comments['picture'][] = array('data'=>$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'], 'image_mime'=>$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime']);
+*/
break;
default:
@@ -885,6 +929,7 @@ class getid3_asf
$thisfile_asf['stream_bitrate_properties_object'] = array();
$thisfile_asf_streambitratepropertiesobject = &$thisfile_asf['stream_bitrate_properties_object'];
+ $thisfile_asf_streambitratepropertiesobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_streambitratepropertiesobject['objectid'] = $NextObjectGUID;
$thisfile_asf_streambitratepropertiesobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_streambitratepropertiesobject['objectsize'] = $NextObjectSize;
@@ -910,6 +955,7 @@ class getid3_asf
$thisfile_asf['padding_object'] = array();
$thisfile_asf_paddingobject = &$thisfile_asf['padding_object'];
+ $thisfile_asf_paddingobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_paddingobject['objectid'] = $NextObjectGUID;
$thisfile_asf_paddingobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_paddingobject['objectsize'] = $NextObjectSize;
@@ -927,9 +973,9 @@ class getid3_asf
default:
// Implementations shall ignore any standard or non-standard object that they do not know how to handle.
if ($this->GUIDname($NextObjectGUIDtext)) {
- $ThisFileInfo['warning'][] = 'unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF header at offset '.($offset - 16 - 8);
+ $info['warning'][] = 'unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF header at offset '.($offset - 16 - 8);
} else {
- $ThisFileInfo['warning'][] = 'unknown GUID {'.$NextObjectGUIDtext.'} in ASF header at offset '.($offset - 16 - 8);
+ $info['warning'][] = 'unknown GUID {'.$NextObjectGUIDtext.'} in ASF header at offset '.($offset - 16 - 8);
}
$offset += ($NextObjectSize - 16 - 8);
break;
@@ -1000,16 +1046,16 @@ class getid3_asf
if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) {
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
- if (@$dataarray['flags']['stream_number'] == $streamnumber) {
+ if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
$thisfile_asf_audiomedia_currentstream['bitrate'] = $dataarray['bitrate'];
$thisfile_audio['bitrate'] += $dataarray['bitrate'];
break;
}
}
} else {
- if (@$thisfile_asf_audiomedia_currentstream['bytes_sec']) {
+ if (!empty($thisfile_asf_audiomedia_currentstream['bytes_sec'])) {
$thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bytes_sec'] * 8;
- } elseif (@$thisfile_asf_audiomedia_currentstream['bitrate']) {
+ } elseif (!empty($thisfile_asf_audiomedia_currentstream['bitrate'])) {
$thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bitrate'];
}
}
@@ -1086,7 +1132,7 @@ class getid3_asf
if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) {
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
- if (@$dataarray['flags']['stream_number'] == $streamnumber) {
+ if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
$thisfile_asf_videomedia_currentstream['bitrate'] = $dataarray['bitrate'];
$thisfile_video['streams'][$streamnumber]['bitrate'] = $dataarray['bitrate'];
$thisfile_video['bitrate'] += $dataarray['bitrate'];
@@ -1110,8 +1156,8 @@ class getid3_asf
}
}
- while (ftell($fd) < $ThisFileInfo['avdataend']) {
- $NextObjectDataHeader = fread($fd, 24);
+ while (ftell($this->getid3->fp) < $info['avdataend']) {
+ $NextObjectDataHeader = fread($this->getid3->fp, 24);
$offset = 0;
$NextObjectGUID = substr($NextObjectDataHeader, 0, 16);
$offset += 16;
@@ -1133,7 +1179,7 @@ class getid3_asf
$thisfile_asf['data_object'] = array();
$thisfile_asf_dataobject = &$thisfile_asf['data_object'];
- $DataObjectData = $NextObjectDataHeader.fread($fd, 50 - 24);
+ $DataObjectData = $NextObjectDataHeader.fread($this->getid3->fp, 50 - 24);
$offset = 24;
$thisfile_asf_dataobject['objectid'] = $NextObjectGUID;
@@ -1148,7 +1194,7 @@ class getid3_asf
$thisfile_asf_dataobject['reserved'] = getid3_lib::LittleEndian2Int(substr($DataObjectData, $offset, 2));
$offset += 2;
if ($thisfile_asf_dataobject['reserved'] != 0x0101) {
- $ThisFileInfo['warning'][] = 'data_object.reserved ('.getid3_lib::PrintHexBytes($thisfile_asf_dataobject['reserved']).') does not match expected value of "0x0101"';
+ $info['warning'][] = 'data_object.reserved ('.getid3_lib::PrintHexBytes($thisfile_asf_dataobject['reserved']).') does not match expected value of "0x0101"';
//return false;
break;
}
@@ -1161,9 +1207,9 @@ class getid3_asf
// * * Error Correction Present bits 1 // If set, use Opaque Data Packet structure, else use Payload structure
// * Error Correction Data
- $ThisFileInfo['avdataoffset'] = ftell($fd);
- fseek($fd, ($thisfile_asf_dataobject['objectsize'] - 50), SEEK_CUR); // skip actual audio/video data
- $ThisFileInfo['avdataend'] = ftell($fd);
+ $info['avdataoffset'] = ftell($this->getid3->fp);
+ fseek($this->getid3->fp, ($thisfile_asf_dataobject['objectsize'] - 50), SEEK_CUR); // skip actual audio/video data
+ $info['avdataend'] = ftell($this->getid3->fp);
break;
case GETID3_ASF_Simple_Index_Object:
@@ -1183,7 +1229,7 @@ class getid3_asf
$thisfile_asf['simple_index_object'] = array();
$thisfile_asf_simpleindexobject = &$thisfile_asf['simple_index_object'];
- $SimpleIndexObjectData = $NextObjectDataHeader.fread($fd, 56 - 24);
+ $SimpleIndexObjectData = $NextObjectDataHeader.fread($this->getid3->fp, 56 - 24);
$offset = 24;
$thisfile_asf_simpleindexobject['objectid'] = $NextObjectGUID;
@@ -1200,7 +1246,7 @@ class getid3_asf
$thisfile_asf_simpleindexobject['index_entries_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
$offset += 4;
- $IndexEntriesData = $SimpleIndexObjectData.fread($fd, 6 * $thisfile_asf_simpleindexobject['index_entries_count']);
+ $IndexEntriesData = $SimpleIndexObjectData.fread($this->getid3->fp, 6 * $thisfile_asf_simpleindexobject['index_entries_count']);
for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; $IndexEntriesCounter++) {
$thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
$offset += 4;
@@ -1237,7 +1283,7 @@ class getid3_asf
$thisfile_asf['asf_index_object'] = array();
$thisfile_asf_asfindexobject = &$thisfile_asf['asf_index_object'];
- $ASFIndexObjectData = $NextObjectDataHeader.fread($fd, 34 - 24);
+ $ASFIndexObjectData = $NextObjectDataHeader.fread($this->getid3->fp, 34 - 24);
$offset = 24;
$thisfile_asf_asfindexobject['objectid'] = $NextObjectGUID;
@@ -1251,7 +1297,7 @@ class getid3_asf
$thisfile_asf_asfindexobject['index_blocks_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
$offset += 4;
- $ASFIndexObjectData .= fread($fd, 4 * $thisfile_asf_asfindexobject['index_specifiers_count']);
+ $ASFIndexObjectData .= fread($this->getid3->fp, 4 * $thisfile_asf_asfindexobject['index_specifiers_count']);
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
$IndexSpecifierStreamNumber = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
$offset += 2;
@@ -1261,17 +1307,17 @@ class getid3_asf
$thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type_text'] = $this->ASFIndexObjectIndexTypeLookup($thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type']);
}
- $ASFIndexObjectData .= fread($fd, 4);
+ $ASFIndexObjectData .= fread($this->getid3->fp, 4);
$thisfile_asf_asfindexobject['index_entry_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
$offset += 4;
- $ASFIndexObjectData .= fread($fd, 8 * $thisfile_asf_asfindexobject['index_specifiers_count']);
+ $ASFIndexObjectData .= fread($this->getid3->fp, 8 * $thisfile_asf_asfindexobject['index_specifiers_count']);
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
$thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8));
$offset += 8;
}
- $ASFIndexObjectData .= fread($fd, 4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']);
+ $ASFIndexObjectData .= fread($this->getid3->fp, 4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']);
for ($IndexEntryCounter = 0; $IndexEntryCounter < $thisfile_asf_asfindexobject['index_entry_count']; $IndexEntryCounter++) {
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
$thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
@@ -1284,11 +1330,11 @@ class getid3_asf
default:
// Implementations shall ignore any standard or non-standard object that they do not know how to handle.
if ($this->GUIDname($NextObjectGUIDtext)) {
- $ThisFileInfo['warning'][] = 'unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF body at offset '.($offset - 16 - 8);
+ $info['warning'][] = 'unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF body at offset '.($offset - 16 - 8);
} else {
- $ThisFileInfo['warning'][] = 'unknown GUID {'.$NextObjectGUIDtext.'} in ASF body at offset '.(ftell($fd) - 16 - 8);
+ $info['warning'][] = 'unknown GUID {'.$NextObjectGUIDtext.'} in ASF body at offset '.(ftell($this->getid3->fp) - 16 - 8);
}
- fseek($fd, ($NextObjectSize - 16 - 8), SEEK_CUR);
+ fseek($this->getid3->fp, ($NextObjectSize - 16 - 8), SEEK_CUR);
break;
}
}
@@ -1299,14 +1345,14 @@ class getid3_asf
case 'WMV1':
case 'WMV2':
case 'WMV3':
- case 'MSS1':
- case 'MSS2':
- case 'WMVA':
- case 'WVC1':
- case 'WMVP':
- case 'WVP2':
+ case 'MSS1':
+ case 'MSS2':
+ case 'WMVA':
+ case 'WVC1':
+ case 'WMVP':
+ case 'WVP2':
$thisfile_video['dataformat'] = 'wmv';
- $ThisFileInfo['mime_type'] = 'video/x-ms-wmv';
+ $info['mime_type'] = 'video/x-ms-wmv';
break;
case 'MP42':
@@ -1314,7 +1360,7 @@ class getid3_asf
case 'MP4S':
case 'mp4s':
$thisfile_video['dataformat'] = 'asf';
- $ThisFileInfo['mime_type'] = 'video/x-ms-asf';
+ $info['mime_type'] = 'video/x-ms-asf';
break;
default:
@@ -1322,8 +1368,8 @@ class getid3_asf
case 1:
if (strstr($this->TrimConvert($streamdata['name']), 'Windows Media')) {
$thisfile_video['dataformat'] = 'wmv';
- if ($ThisFileInfo['mime_type'] == 'video/x-ms-asf') {
- $ThisFileInfo['mime_type'] = 'video/x-ms-wmv';
+ if ($info['mime_type'] == 'video/x-ms-asf') {
+ $info['mime_type'] = 'video/x-ms-wmv';
}
}
break;
@@ -1331,8 +1377,8 @@ class getid3_asf
case 2:
if (strstr($this->TrimConvert($streamdata['name']), 'Windows Media')) {
$thisfile_audio['dataformat'] = 'wma';
- if ($ThisFileInfo['mime_type'] == 'video/x-ms-asf') {
- $ThisFileInfo['mime_type'] = 'audio/x-ms-wma';
+ if ($info['mime_type'] == 'video/x-ms-asf') {
+ $info['mime_type'] = 'audio/x-ms-wma';
}
}
break;
@@ -1343,7 +1389,7 @@ class getid3_asf
}
}
- switch (@$thisfile_audio['codec']) {
+ switch (isset($thisfile_audio['codec']) ? $thisfile_audio['codec'] : '') {
case 'MPEG Layer-3':
$thisfile_audio['dataformat'] = 'mp3';
break;
@@ -1370,14 +1416,14 @@ class getid3_asf
break;
default:
- $ThisFileInfo['warning'][] = 'Unknown streamtype: [codec_list_object][codec_entries]['.$streamnumber.'][type_raw] == '.$streamdata['type_raw'];
+ $info['warning'][] = 'Unknown streamtype: [codec_list_object][codec_entries]['.$streamnumber.'][type_raw] == '.$streamdata['type_raw'];
break;
}
}
}
- if (isset($ThisFileInfo['audio'])) {
+ if (isset($info['audio'])) {
$thisfile_audio['lossless'] = (isset($thisfile_audio['lossless']) ? $thisfile_audio['lossless'] : false);
$thisfile_audio['dataformat'] = (!empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf');
}
@@ -1396,16 +1442,16 @@ class getid3_asf
}
}
}
- $ThisFileInfo['bitrate'] = @$thisfile_audio['bitrate'] + @$thisfile_video['bitrate'];
+ $info['bitrate'] = (isset($thisfile_audio['bitrate']) ? $thisfile_audio['bitrate'] : 0) + (isset($thisfile_video['bitrate']) ? $thisfile_video['bitrate'] : 0);
- if ((!isset($ThisFileInfo['playtime_seconds']) || ($ThisFileInfo['playtime_seconds'] <= 0)) && ($ThisFileInfo['bitrate'] > 0)) {
- $ThisFileInfo['playtime_seconds'] = ($ThisFileInfo['filesize'] - $ThisFileInfo['avdataoffset']) / ($ThisFileInfo['bitrate'] / 8);
+ if ((!isset($info['playtime_seconds']) || ($info['playtime_seconds'] <= 0)) && ($info['bitrate'] > 0)) {
+ $info['playtime_seconds'] = ($info['filesize'] - $info['avdataoffset']) / ($info['bitrate'] / 8);
}
return true;
}
- function ASFCodecListObjectTypeLookup($CodecListType) {
+ static function ASFCodecListObjectTypeLookup($CodecListType) {
static $ASFCodecListObjectTypeLookup = array();
if (empty($ASFCodecListObjectTypeLookup)) {
$ASFCodecListObjectTypeLookup[0x0001] = 'Video Codec';
@@ -1416,128 +1462,129 @@ class getid3_asf
return (isset($ASFCodecListObjectTypeLookup[$CodecListType]) ? $ASFCodecListObjectTypeLookup[$CodecListType] : 'Invalid Codec Type');
}
- function KnownGUIDs() {
- static $GUIDarray = array();
- if (empty($GUIDarray)) {
- $GUIDarray['GETID3_ASF_Extended_Stream_Properties_Object'] = '14E6A5CB-C672-4332-8399-A96952065B5A';
- $GUIDarray['GETID3_ASF_Padding_Object'] = '1806D474-CADF-4509-A4BA-9AABCB96AAE8';
- $GUIDarray['GETID3_ASF_Payload_Ext_Syst_Pixel_Aspect_Ratio'] = '1B1EE554-F9EA-4BC8-821A-376B74E4C4B8';
- $GUIDarray['GETID3_ASF_Script_Command_Object'] = '1EFB1A30-0B62-11D0-A39B-00A0C90348F6';
- $GUIDarray['GETID3_ASF_No_Error_Correction'] = '20FB5700-5B55-11CF-A8FD-00805F5C442B';
- $GUIDarray['GETID3_ASF_Content_Branding_Object'] = '2211B3FA-BD23-11D2-B4B7-00A0C955FC6E';
- $GUIDarray['GETID3_ASF_Content_Encryption_Object'] = '2211B3FB-BD23-11D2-B4B7-00A0C955FC6E';
- $GUIDarray['GETID3_ASF_Digital_Signature_Object'] = '2211B3FC-BD23-11D2-B4B7-00A0C955FC6E';
- $GUIDarray['GETID3_ASF_Extended_Content_Encryption_Object'] = '298AE614-2622-4C17-B935-DAE07EE9289C';
- $GUIDarray['GETID3_ASF_Simple_Index_Object'] = '33000890-E5B1-11CF-89F4-00A0C90349CB';
- $GUIDarray['GETID3_ASF_Degradable_JPEG_Media'] = '35907DE0-E415-11CF-A917-00805F5C442B';
- $GUIDarray['GETID3_ASF_Payload_Extension_System_Timecode'] = '399595EC-8667-4E2D-8FDB-98814CE76C1E';
- $GUIDarray['GETID3_ASF_Binary_Media'] = '3AFB65E2-47EF-40F2-AC2C-70A90D71D343';
- $GUIDarray['GETID3_ASF_Timecode_Index_Object'] = '3CB73FD0-0C4A-4803-953D-EDF7B6228F0C';
- $GUIDarray['GETID3_ASF_Metadata_Library_Object'] = '44231C94-9498-49D1-A141-1D134E457054';
- $GUIDarray['GETID3_ASF_Reserved_3'] = '4B1ACBE3-100B-11D0-A39B-00A0C90348F6';
- $GUIDarray['GETID3_ASF_Reserved_4'] = '4CFEDB20-75F6-11CF-9C0F-00A0C90349CB';
- $GUIDarray['GETID3_ASF_Command_Media'] = '59DACFC0-59E6-11D0-A3AC-00A0C90348F6';
- $GUIDarray['GETID3_ASF_Header_Extension_Object'] = '5FBF03B5-A92E-11CF-8EE3-00C00C205365';
- $GUIDarray['GETID3_ASF_Media_Object_Index_Parameters_Obj'] = '6B203BAD-3F11-4E84-ACA8-D7613DE2CFA7';
- $GUIDarray['GETID3_ASF_Header_Object'] = '75B22630-668E-11CF-A6D9-00AA0062CE6C';
- $GUIDarray['GETID3_ASF_Content_Description_Object'] = '75B22633-668E-11CF-A6D9-00AA0062CE6C';
- $GUIDarray['GETID3_ASF_Error_Correction_Object'] = '75B22635-668E-11CF-A6D9-00AA0062CE6C';
- $GUIDarray['GETID3_ASF_Data_Object'] = '75B22636-668E-11CF-A6D9-00AA0062CE6C';
- $GUIDarray['GETID3_ASF_Web_Stream_Media_Subtype'] = '776257D4-C627-41CB-8F81-7AC7FF1C40CC';
- $GUIDarray['GETID3_ASF_Stream_Bitrate_Properties_Object'] = '7BF875CE-468D-11D1-8D82-006097C9A2B2';
- $GUIDarray['GETID3_ASF_Language_List_Object'] = '7C4346A9-EFE0-4BFC-B229-393EDE415C85';
- $GUIDarray['GETID3_ASF_Codec_List_Object'] = '86D15240-311D-11D0-A3A4-00A0C90348F6';
- $GUIDarray['GETID3_ASF_Reserved_2'] = '86D15241-311D-11D0-A3A4-00A0C90348F6';
- $GUIDarray['GETID3_ASF_File_Properties_Object'] = '8CABDCA1-A947-11CF-8EE4-00C00C205365';
- $GUIDarray['GETID3_ASF_File_Transfer_Media'] = '91BD222C-F21C-497A-8B6D-5AA86BFC0185';
- $GUIDarray['GETID3_ASF_Old_RTP_Extension_Data'] = '96800C63-4C94-11D1-837B-0080C7A37F95';
- $GUIDarray['GETID3_ASF_Advanced_Mutual_Exclusion_Object'] = 'A08649CF-4775-4670-8A16-6E35357566CD';
- $GUIDarray['GETID3_ASF_Bandwidth_Sharing_Object'] = 'A69609E6-517B-11D2-B6AF-00C04FD908E9';
- $GUIDarray['GETID3_ASF_Reserved_1'] = 'ABD3D211-A9BA-11cf-8EE6-00C00C205365';
- $GUIDarray['GETID3_ASF_Bandwidth_Sharing_Exclusive'] = 'AF6060AA-5197-11D2-B6AF-00C04FD908E9';
- $GUIDarray['GETID3_ASF_Bandwidth_Sharing_Partial'] = 'AF6060AB-5197-11D2-B6AF-00C04FD908E9';
- $GUIDarray['GETID3_ASF_JFIF_Media'] = 'B61BE100-5B4E-11CF-A8FD-00805F5C442B';
- $GUIDarray['GETID3_ASF_Stream_Properties_Object'] = 'B7DC0791-A9B7-11CF-8EE6-00C00C205365';
- $GUIDarray['GETID3_ASF_Video_Media'] = 'BC19EFC0-5B4D-11CF-A8FD-00805F5C442B';
- $GUIDarray['GETID3_ASF_Audio_Spread'] = 'BFC3CD50-618F-11CF-8BB2-00AA00B4E220';
- $GUIDarray['GETID3_ASF_Metadata_Object'] = 'C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA';
- $GUIDarray['GETID3_ASF_Payload_Ext_Syst_Sample_Duration'] = 'C6BD9450-867F-4907-83A3-C77921B733AD';
- $GUIDarray['GETID3_ASF_Group_Mutual_Exclusion_Object'] = 'D1465A40-5A79-4338-B71B-E36B8FD6C249';
- $GUIDarray['GETID3_ASF_Extended_Content_Description_Object'] = 'D2D0A440-E307-11D2-97F0-00A0C95EA850';
- $GUIDarray['GETID3_ASF_Stream_Prioritization_Object'] = 'D4FED15B-88D3-454F-81F0-ED5C45999E24';
- $GUIDarray['GETID3_ASF_Payload_Ext_System_Content_Type'] = 'D590DC20-07BC-436C-9CF7-F3BBFBF1A4DC';
- $GUIDarray['GETID3_ASF_Old_File_Properties_Object'] = 'D6E229D0-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_ASF_Header_Object'] = 'D6E229D1-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_ASF_Data_Object'] = 'D6E229D2-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Index_Object'] = 'D6E229D3-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Stream_Properties_Object'] = 'D6E229D4-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Content_Description_Object'] = 'D6E229D5-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Script_Command_Object'] = 'D6E229D6-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Marker_Object'] = 'D6E229D7-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Component_Download_Object'] = 'D6E229D8-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Stream_Group_Object'] = 'D6E229D9-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Scalable_Object'] = 'D6E229DA-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Prioritization_Object'] = 'D6E229DB-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Bitrate_Mutual_Exclusion_Object'] = 'D6E229DC-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Inter_Media_Dependency_Object'] = 'D6E229DD-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Rating_Object'] = 'D6E229DE-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Index_Parameters_Object'] = 'D6E229DF-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Color_Table_Object'] = 'D6E229E0-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Language_List_Object'] = 'D6E229E1-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Audio_Media'] = 'D6E229E2-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Video_Media'] = 'D6E229E3-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Image_Media'] = 'D6E229E4-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Timecode_Media'] = 'D6E229E5-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Text_Media'] = 'D6E229E6-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_MIDI_Media'] = 'D6E229E7-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Command_Media'] = 'D6E229E8-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_No_Error_Concealment'] = 'D6E229EA-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Scrambled_Audio'] = 'D6E229EB-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_No_Color_Table'] = 'D6E229EC-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_SMPTE_Time'] = 'D6E229ED-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_ASCII_Text'] = 'D6E229EE-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Unicode_Text'] = 'D6E229EF-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_HTML_Text'] = 'D6E229F0-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_URL_Command'] = 'D6E229F1-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Filename_Command'] = 'D6E229F2-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_ACM_Codec'] = 'D6E229F3-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_VCM_Codec'] = 'D6E229F4-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_QuickTime_Codec'] = 'D6E229F5-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_DirectShow_Transform_Filter'] = 'D6E229F6-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_DirectShow_Rendering_Filter'] = 'D6E229F7-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_No_Enhancement'] = 'D6E229F8-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Unknown_Enhancement_Type'] = 'D6E229F9-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Temporal_Enhancement'] = 'D6E229FA-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Spatial_Enhancement'] = 'D6E229FB-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Quality_Enhancement'] = 'D6E229FC-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Number_of_Channels_Enhancement'] = 'D6E229FD-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Frequency_Response_Enhancement'] = 'D6E229FE-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Media_Object'] = 'D6E229FF-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Mutex_Language'] = 'D6E22A00-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Mutex_Bitrate'] = 'D6E22A01-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Mutex_Unknown'] = 'D6E22A02-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_ASF_Placeholder_Object'] = 'D6E22A0E-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Old_Data_Unit_Extension_Object'] = 'D6E22A0F-35DA-11D1-9034-00A0C90349BE';
- $GUIDarray['GETID3_ASF_Web_Stream_Format'] = 'DA1E6B13-8359-4050-B398-388E965BF00C';
- $GUIDarray['GETID3_ASF_Payload_Ext_System_File_Name'] = 'E165EC0E-19ED-45D7-B4A7-25CBD1E28E9B';
- $GUIDarray['GETID3_ASF_Marker_Object'] = 'F487CD01-A951-11CF-8EE6-00C00C205365';
- $GUIDarray['GETID3_ASF_Timecode_Index_Parameters_Object'] = 'F55E496D-9797-4B5D-8C8B-604DFE9BFB24';
- $GUIDarray['GETID3_ASF_Audio_Media'] = 'F8699E40-5B4D-11CF-A8FD-00805F5C442B';
- $GUIDarray['GETID3_ASF_Media_Object_Index_Object'] = 'FEB103F8-12AD-4C64-840F-2A1D2F7AD48C';
- $GUIDarray['GETID3_ASF_Alt_Extended_Content_Encryption_Obj'] = 'FF889EF1-ADEE-40DA-9E71-98704BB928CE';
- }
+ static function KnownGUIDs() {
+ static $GUIDarray = array(
+ 'GETID3_ASF_Extended_Stream_Properties_Object' => '14E6A5CB-C672-4332-8399-A96952065B5A',
+ 'GETID3_ASF_Padding_Object' => '1806D474-CADF-4509-A4BA-9AABCB96AAE8',
+ 'GETID3_ASF_Payload_Ext_Syst_Pixel_Aspect_Ratio' => '1B1EE554-F9EA-4BC8-821A-376B74E4C4B8',
+ 'GETID3_ASF_Script_Command_Object' => '1EFB1A30-0B62-11D0-A39B-00A0C90348F6',
+ 'GETID3_ASF_No_Error_Correction' => '20FB5700-5B55-11CF-A8FD-00805F5C442B',
+ 'GETID3_ASF_Content_Branding_Object' => '2211B3FA-BD23-11D2-B4B7-00A0C955FC6E',
+ 'GETID3_ASF_Content_Encryption_Object' => '2211B3FB-BD23-11D2-B4B7-00A0C955FC6E',
+ 'GETID3_ASF_Digital_Signature_Object' => '2211B3FC-BD23-11D2-B4B7-00A0C955FC6E',
+ 'GETID3_ASF_Extended_Content_Encryption_Object' => '298AE614-2622-4C17-B935-DAE07EE9289C',
+ 'GETID3_ASF_Simple_Index_Object' => '33000890-E5B1-11CF-89F4-00A0C90349CB',
+ 'GETID3_ASF_Degradable_JPEG_Media' => '35907DE0-E415-11CF-A917-00805F5C442B',
+ 'GETID3_ASF_Payload_Extension_System_Timecode' => '399595EC-8667-4E2D-8FDB-98814CE76C1E',
+ 'GETID3_ASF_Binary_Media' => '3AFB65E2-47EF-40F2-AC2C-70A90D71D343',
+ 'GETID3_ASF_Timecode_Index_Object' => '3CB73FD0-0C4A-4803-953D-EDF7B6228F0C',
+ 'GETID3_ASF_Metadata_Library_Object' => '44231C94-9498-49D1-A141-1D134E457054',
+ 'GETID3_ASF_Reserved_3' => '4B1ACBE3-100B-11D0-A39B-00A0C90348F6',
+ 'GETID3_ASF_Reserved_4' => '4CFEDB20-75F6-11CF-9C0F-00A0C90349CB',
+ 'GETID3_ASF_Command_Media' => '59DACFC0-59E6-11D0-A3AC-00A0C90348F6',
+ 'GETID3_ASF_Header_Extension_Object' => '5FBF03B5-A92E-11CF-8EE3-00C00C205365',
+ 'GETID3_ASF_Media_Object_Index_Parameters_Obj' => '6B203BAD-3F11-4E84-ACA8-D7613DE2CFA7',
+ 'GETID3_ASF_Header_Object' => '75B22630-668E-11CF-A6D9-00AA0062CE6C',
+ 'GETID3_ASF_Content_Description_Object' => '75B22633-668E-11CF-A6D9-00AA0062CE6C',
+ 'GETID3_ASF_Error_Correction_Object' => '75B22635-668E-11CF-A6D9-00AA0062CE6C',
+ 'GETID3_ASF_Data_Object' => '75B22636-668E-11CF-A6D9-00AA0062CE6C',
+ 'GETID3_ASF_Web_Stream_Media_Subtype' => '776257D4-C627-41CB-8F81-7AC7FF1C40CC',
+ 'GETID3_ASF_Stream_Bitrate_Properties_Object' => '7BF875CE-468D-11D1-8D82-006097C9A2B2',
+ 'GETID3_ASF_Language_List_Object' => '7C4346A9-EFE0-4BFC-B229-393EDE415C85',
+ 'GETID3_ASF_Codec_List_Object' => '86D15240-311D-11D0-A3A4-00A0C90348F6',
+ 'GETID3_ASF_Reserved_2' => '86D15241-311D-11D0-A3A4-00A0C90348F6',
+ 'GETID3_ASF_File_Properties_Object' => '8CABDCA1-A947-11CF-8EE4-00C00C205365',
+ 'GETID3_ASF_File_Transfer_Media' => '91BD222C-F21C-497A-8B6D-5AA86BFC0185',
+ 'GETID3_ASF_Old_RTP_Extension_Data' => '96800C63-4C94-11D1-837B-0080C7A37F95',
+ 'GETID3_ASF_Advanced_Mutual_Exclusion_Object' => 'A08649CF-4775-4670-8A16-6E35357566CD',
+ 'GETID3_ASF_Bandwidth_Sharing_Object' => 'A69609E6-517B-11D2-B6AF-00C04FD908E9',
+ 'GETID3_ASF_Reserved_1' => 'ABD3D211-A9BA-11cf-8EE6-00C00C205365',
+ 'GETID3_ASF_Bandwidth_Sharing_Exclusive' => 'AF6060AA-5197-11D2-B6AF-00C04FD908E9',
+ 'GETID3_ASF_Bandwidth_Sharing_Partial' => 'AF6060AB-5197-11D2-B6AF-00C04FD908E9',
+ 'GETID3_ASF_JFIF_Media' => 'B61BE100-5B4E-11CF-A8FD-00805F5C442B',
+ 'GETID3_ASF_Stream_Properties_Object' => 'B7DC0791-A9B7-11CF-8EE6-00C00C205365',
+ 'GETID3_ASF_Video_Media' => 'BC19EFC0-5B4D-11CF-A8FD-00805F5C442B',
+ 'GETID3_ASF_Audio_Spread' => 'BFC3CD50-618F-11CF-8BB2-00AA00B4E220',
+ 'GETID3_ASF_Metadata_Object' => 'C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA',
+ 'GETID3_ASF_Payload_Ext_Syst_Sample_Duration' => 'C6BD9450-867F-4907-83A3-C77921B733AD',
+ 'GETID3_ASF_Group_Mutual_Exclusion_Object' => 'D1465A40-5A79-4338-B71B-E36B8FD6C249',
+ 'GETID3_ASF_Extended_Content_Description_Object' => 'D2D0A440-E307-11D2-97F0-00A0C95EA850',
+ 'GETID3_ASF_Stream_Prioritization_Object' => 'D4FED15B-88D3-454F-81F0-ED5C45999E24',
+ 'GETID3_ASF_Payload_Ext_System_Content_Type' => 'D590DC20-07BC-436C-9CF7-F3BBFBF1A4DC',
+ 'GETID3_ASF_Old_File_Properties_Object' => 'D6E229D0-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_ASF_Header_Object' => 'D6E229D1-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_ASF_Data_Object' => 'D6E229D2-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Index_Object' => 'D6E229D3-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Stream_Properties_Object' => 'D6E229D4-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Content_Description_Object' => 'D6E229D5-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Script_Command_Object' => 'D6E229D6-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Marker_Object' => 'D6E229D7-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Component_Download_Object' => 'D6E229D8-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Stream_Group_Object' => 'D6E229D9-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Scalable_Object' => 'D6E229DA-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Prioritization_Object' => 'D6E229DB-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Bitrate_Mutual_Exclusion_Object' => 'D6E229DC-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Inter_Media_Dependency_Object' => 'D6E229DD-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Rating_Object' => 'D6E229DE-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Index_Parameters_Object' => 'D6E229DF-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Color_Table_Object' => 'D6E229E0-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Language_List_Object' => 'D6E229E1-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Audio_Media' => 'D6E229E2-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Video_Media' => 'D6E229E3-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Image_Media' => 'D6E229E4-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Timecode_Media' => 'D6E229E5-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Text_Media' => 'D6E229E6-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_MIDI_Media' => 'D6E229E7-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Command_Media' => 'D6E229E8-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_No_Error_Concealment' => 'D6E229EA-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Scrambled_Audio' => 'D6E229EB-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_No_Color_Table' => 'D6E229EC-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_SMPTE_Time' => 'D6E229ED-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_ASCII_Text' => 'D6E229EE-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Unicode_Text' => 'D6E229EF-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_HTML_Text' => 'D6E229F0-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_URL_Command' => 'D6E229F1-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Filename_Command' => 'D6E229F2-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_ACM_Codec' => 'D6E229F3-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_VCM_Codec' => 'D6E229F4-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_QuickTime_Codec' => 'D6E229F5-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_DirectShow_Transform_Filter' => 'D6E229F6-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_DirectShow_Rendering_Filter' => 'D6E229F7-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_No_Enhancement' => 'D6E229F8-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Unknown_Enhancement_Type' => 'D6E229F9-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Temporal_Enhancement' => 'D6E229FA-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Spatial_Enhancement' => 'D6E229FB-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Quality_Enhancement' => 'D6E229FC-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Number_of_Channels_Enhancement' => 'D6E229FD-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Frequency_Response_Enhancement' => 'D6E229FE-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Media_Object' => 'D6E229FF-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Mutex_Language' => 'D6E22A00-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Mutex_Bitrate' => 'D6E22A01-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Mutex_Unknown' => 'D6E22A02-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_ASF_Placeholder_Object' => 'D6E22A0E-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Old_Data_Unit_Extension_Object' => 'D6E22A0F-35DA-11D1-9034-00A0C90349BE',
+ 'GETID3_ASF_Web_Stream_Format' => 'DA1E6B13-8359-4050-B398-388E965BF00C',
+ 'GETID3_ASF_Payload_Ext_System_File_Name' => 'E165EC0E-19ED-45D7-B4A7-25CBD1E28E9B',
+ 'GETID3_ASF_Marker_Object' => 'F487CD01-A951-11CF-8EE6-00C00C205365',
+ 'GETID3_ASF_Timecode_Index_Parameters_Object' => 'F55E496D-9797-4B5D-8C8B-604DFE9BFB24',
+ 'GETID3_ASF_Audio_Media' => 'F8699E40-5B4D-11CF-A8FD-00805F5C442B',
+ 'GETID3_ASF_Media_Object_Index_Object' => 'FEB103F8-12AD-4C64-840F-2A1D2F7AD48C',
+ 'GETID3_ASF_Alt_Extended_Content_Encryption_Obj' => 'FF889EF1-ADEE-40DA-9E71-98704BB928CE',
+ 'GETID3_ASF_Index_Placeholder_Object' => 'D9AADE20-7C17-4F9C-BC28-8555DD98E2A2', // http://cpan.uwinnipeg.ca/htdocs/Audio-WMA/Audio/WMA.pm.html
+ 'GETID3_ASF_Compatibility_Object' => '26F18B5D-4584-47EC-9F5F-0E651F0452C9', // http://cpan.uwinnipeg.ca/htdocs/Audio-WMA/Audio/WMA.pm.html
+ );
return $GUIDarray;
}
- function GUIDname($GUIDstring) {
+ static function GUIDname($GUIDstring) {
static $GUIDarray = array();
if (empty($GUIDarray)) {
- $GUIDarray = $this->KnownGUIDs();
+ $GUIDarray = getid3_asf::KnownGUIDs();
}
return array_search($GUIDstring, $GUIDarray);
}
- function ASFIndexObjectIndexTypeLookup($id) {
+ static function ASFIndexObjectIndexTypeLookup($id) {
static $ASFIndexObjectIndexTypeLookup = array();
if (empty($ASFIndexObjectIndexTypeLookup)) {
$ASFIndexObjectIndexTypeLookup[1] = 'Nearest Past Data Packet';
@@ -1547,7 +1594,7 @@ class getid3_asf
return (isset($ASFIndexObjectIndexTypeLookup[$id]) ? $ASFIndexObjectIndexTypeLookup[$id] : 'invalid');
}
- function GUIDtoBytestring($GUIDstring) {
+ static function GUIDtoBytestring($GUIDstring) {
// Microsoft defines these 16-byte (128-bit) GUIDs in the strangest way:
// first 4 bytes are in little-endian order
// next 2 bytes are appended in little-endian order
@@ -1582,7 +1629,7 @@ class getid3_asf
return $hexbytecharstring;
}
- function BytestringToGUID($Bytestring) {
+ static function BytestringToGUID($Bytestring) {
$GUIDstring = str_pad(dechex(ord($Bytestring{3})), 2, '0', STR_PAD_LEFT);
$GUIDstring .= str_pad(dechex(ord($Bytestring{2})), 2, '0', STR_PAD_LEFT);
$GUIDstring .= str_pad(dechex(ord($Bytestring{1})), 2, '0', STR_PAD_LEFT);
@@ -1607,7 +1654,7 @@ class getid3_asf
return strtoupper($GUIDstring);
}
- function FILETIMEtoUNIXtime($FILETIME, $round=true) {
+ static function FILETIMEtoUNIXtime($FILETIME, $round=true) {
// FILETIME is a 64-bit unsigned integer representing
// the number of 100-nanosecond intervals since January 1, 1601
// UNIX timestamp is number of seconds since January 1, 1970
@@ -1618,7 +1665,7 @@ class getid3_asf
return ($FILETIME - 116444736000000000) / 10000000;
}
- function WMpictureTypeLookup($WMpictureType) {
+ static function WMpictureTypeLookup($WMpictureType) {
static $WMpictureTypeLookup = array();
if (empty($WMpictureTypeLookup)) {
$WMpictureTypeLookup[0x03] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Front Cover');
@@ -1640,34 +1687,335 @@ class getid3_asf
$WMpictureTypeLookup[0x13] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Band Logotype');
$WMpictureTypeLookup[0x14] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Publisher Logotype');
}
- return @$WMpictureTypeLookup[$WMpictureType];
+ return (isset($WMpictureTypeLookup[$WMpictureType]) ? $WMpictureTypeLookup[$WMpictureType] : '');
}
+ function ASF_HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections) {
+ // http://msdn.microsoft.com/en-us/library/bb643323.aspx
- // Remove terminator 00 00 and convert UNICODE to Latin-1
- function TrimConvert($string) {
+ $offset = 0;
+ $objectOffset = 0;
+ $HeaderExtensionObjectParsed = array();
+ while ($objectOffset < strlen($asf_header_extension_object_data)) {
+ $offset = $objectOffset;
+ $thisObject = array();
- // remove terminator, only if present (it should be, but...)
- if (substr($string, strlen($string) - 2, 2) == "\x00\x00") {
- $string = substr($string, 0, strlen($string) - 2);
+ $thisObject['guid'] = substr($asf_header_extension_object_data, $offset, 16);
+ $offset += 16;
+ $thisObject['guid_text'] = $this->BytestringToGUID($thisObject['guid']);
+ $thisObject['guid_name'] = $this->GUIDname($thisObject['guid_text']);
+
+ $thisObject['size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 8));
+ $offset += 8;
+ if ($thisObject['size'] <= 0) {
+ break;
+ }
+
+ switch ($thisObject['guid']) {
+ case GETID3_ASF_Extended_Stream_Properties_Object:
+ $thisObject['start_time'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 8));
+ $offset += 8;
+ $thisObject['start_time_unix'] = $this->FILETIMEtoUNIXtime($thisObject['start_time']);
+
+ $thisObject['end_time'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 8));
+ $offset += 8;
+ $thisObject['end_time_unix'] = $this->FILETIMEtoUNIXtime($thisObject['end_time']);
+
+ $thisObject['data_bitrate'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $thisObject['buffer_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $thisObject['initial_buffer_fullness'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $thisObject['alternate_data_bitrate'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $thisObject['alternate_buffer_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $thisObject['alternate_initial_buffer_fullness'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $thisObject['maximum_object_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $thisObject['flags_raw'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+ $thisObject['flags']['reliable'] = (bool) $thisObject['flags_raw'] & 0x00000001;
+ $thisObject['flags']['seekable'] = (bool) $thisObject['flags_raw'] & 0x00000002;
+ $thisObject['flags']['no_cleanpoints'] = (bool) $thisObject['flags_raw'] & 0x00000004;
+ $thisObject['flags']['resend_live_cleanpoints'] = (bool) $thisObject['flags_raw'] & 0x00000008;
+
+ $thisObject['stream_number'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ $thisObject['stream_language_id_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ $thisObject['average_time_per_frame'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $thisObject['stream_name_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ $thisObject['payload_extension_system_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ for ($i = 0; $i < $thisObject['stream_name_count']; $i++) {
+ $streamName = array();
+
+ $streamName['language_id_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ $streamName['stream_name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ $streamName['stream_name'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, $streamName['stream_name_length']));
+ $offset += $streamName['stream_name_length'];
+
+ $thisObject['stream_names'][$i] = $streamName;
+ }
+
+ for ($i = 0; $i < $thisObject['payload_extension_system_count']; $i++) {
+ $payloadExtensionSystem = array();
+
+ $payloadExtensionSystem['extension_system_id'] = substr($asf_header_extension_object_data, $offset, 16);
+ $offset += 16;
+ $payloadExtensionSystem['extension_system_id_text'] = $this->BytestringToGUID($payloadExtensionSystem['extension_system_id']);
+
+ $payloadExtensionSystem['extension_system_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+ if ($payloadExtensionSystem['extension_system_size'] <= 0) {
+ break 2;
+ }
+
+ $payloadExtensionSystem['extension_system_info_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $payloadExtensionSystem['extension_system_info_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, $payloadExtensionSystem['extension_system_info_length']));
+ $offset += $payloadExtensionSystem['extension_system_info_length'];
+
+ $thisObject['payload_extension_systems'][$i] = $payloadExtensionSystem;
+ }
+
+ break;
+
+ case GETID3_ASF_Padding_Object:
+ // padding, skip it
+ break;
+
+ case GETID3_ASF_Metadata_Object:
+ $thisObject['description_record_counts'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ for ($i = 0; $i < $thisObject['description_record_counts']; $i++) {
+ $descriptionRecord = array();
+
+ $descriptionRecord['reserved_1'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); // must be zero
+ $offset += 2;
+
+ $descriptionRecord['stream_number'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ $descriptionRecord['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+ $descriptionRecord['data_type_text'] = $this->ASFmetadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']);
+
+ $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $descriptionRecord['name'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['name_length']);
+ $offset += $descriptionRecord['name_length'];
+
+ $descriptionRecord['data'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['data_length']);
+ $offset += $descriptionRecord['data_length'];
+ switch ($descriptionRecord['data_type']) {
+ case 0x0000: // Unicode string
+ break;
+
+ case 0x0001: // BYTE array
+ // do nothing
+ break;
+
+ case 0x0002: // BOOL
+ $descriptionRecord['data'] = (bool) getid3_lib::LittleEndian2Int($descriptionRecord['data']);
+ break;
+
+ case 0x0003: // DWORD
+ case 0x0004: // QWORD
+ case 0x0005: // WORD
+ $descriptionRecord['data'] = getid3_lib::LittleEndian2Int($descriptionRecord['data']);
+ break;
+
+ case 0x0006: // GUID
+ $descriptionRecord['data_text'] = $this->BytestringToGUID($descriptionRecord['data']);
+ break;
+ }
+
+ $thisObject['description_record'][$i] = $descriptionRecord;
+ }
+ break;
+
+ case GETID3_ASF_Language_List_Object:
+ $thisObject['language_id_record_counts'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ for ($i = 0; $i < $thisObject['language_id_record_counts']; $i++) {
+ $languageIDrecord = array();
+
+ $languageIDrecord['language_id_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 1));
+ $offset += 1;
+
+ $languageIDrecord['language_id'] = substr($asf_header_extension_object_data, $offset, $languageIDrecord['language_id_length']);
+ $offset += $languageIDrecord['language_id_length'];
+
+ $thisObject['language_id_record'][$i] = $languageIDrecord;
+ }
+ break;
+
+ case GETID3_ASF_Metadata_Library_Object:
+ $thisObject['description_records_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ for ($i = 0; $i < $thisObject['description_records_count']; $i++) {
+ $descriptionRecord = array();
+
+ $descriptionRecord['language_list_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ $descriptionRecord['stream_number'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ $descriptionRecord['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+
+ $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
+ $offset += 2;
+ $descriptionRecord['data_type_text'] = $this->ASFmetadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']);
+
+ $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
+ $offset += 4;
+
+ $descriptionRecord['name'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['name_length']);
+ $offset += $descriptionRecord['name_length'];
+
+ $descriptionRecord['data'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['data_length']);
+ $offset += $descriptionRecord['data_length'];
+
+ if (preg_match('#^WM/Picture$#', str_replace("\x00", '', trim($descriptionRecord['name'])))) {
+ $WMpicture = $this->ASF_WMpicture($descriptionRecord['data']);
+ foreach ($WMpicture as $key => $value) {
+ $descriptionRecord['data'] = $WMpicture;
+ }
+ unset($WMpicture);
+ }
+
+ $thisObject['description_record'][$i] = $descriptionRecord;
+ }
+ break;
+
+ default:
+ $unhandled_sections++;
+ if ($this->GUIDname($thisObject['guid_text'])) {
+ $this->getid3->info['warning'][] = 'unhandled Header Extension Object GUID "'.$this->GUIDname($thisObject['guid_text']).'" {'.$thisObject['guid_text'].'} at offset '.($offset - 16 - 8);
+ } else {
+ $this->getid3->info['warning'][] = 'unknown Header Extension Object GUID {'.$thisObject['guid_text'].'} in at offset '.($offset - 16 - 8);
+ }
+ break;
+ }
+ $HeaderExtensionObjectParsed[] = $thisObject;
+
+ $objectOffset += $thisObject['size'];
+ }
+ return $HeaderExtensionObjectParsed;
+ }
+
+
+ static function ASFmetadataLibraryObjectDataTypeLookup($id) {
+ static $ASFmetadataLibraryObjectDataTypeLookup = array(
+ 0x0000 => 'Unicode string', // The data consists of a sequence of Unicode characters
+ 0x0001 => 'BYTE array', // The type of the data is implementation-specific
+ 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
+ 0x0003 => 'DWORD', // The data is 4 bytes long and should be interpreted as a 32-bit unsigned integer
+ 0x0004 => 'QWORD', // The data is 8 bytes long and should be interpreted as a 64-bit unsigned integer
+ 0x0005 => 'WORD', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer
+ 0x0006 => 'GUID', // The data is 16 bytes long and should be interpreted as a 128-bit GUID
+ );
+ return (isset($ASFmetadataLibraryObjectDataTypeLookup[$id]) ? $ASFmetadataLibraryObjectDataTypeLookup[$id] : 'invalid');
+ }
+
+ function ASF_WMpicture(&$data) {
+ //typedef struct _WMPicture{
+ // LPWSTR pwszMIMEType;
+ // BYTE bPictureType;
+ // LPWSTR pwszDescription;
+ // DWORD dwDataLen;
+ // BYTE* pbData;
+ //} WM_PICTURE;
+
+ $WMpicture = array();
+
+ $offset = 0;
+ $WMpicture['image_type_id'] = getid3_lib::LittleEndian2Int(substr($data, $offset, 1));
+ $offset += 1;
+ $WMpicture['image_type'] = $this->WMpictureTypeLookup($WMpicture['image_type_id']);
+ $WMpicture['image_size'] = getid3_lib::LittleEndian2Int(substr($data, $offset, 4));
+ $offset += 4;
+
+ $WMpicture['image_mime'] = '';
+ do {
+ $next_byte_pair = substr($data, $offset, 2);
+ $offset += 2;
+ $WMpicture['image_mime'] .= $next_byte_pair;
+ } while ($next_byte_pair !== "\x00\x00");
+
+ $WMpicture['image_description'] = '';
+ do {
+ $next_byte_pair = substr($data, $offset, 2);
+ $offset += 2;
+ $WMpicture['image_description'] .= $next_byte_pair;
+ } while ($next_byte_pair !== "\x00\x00");
+
+ $WMpicture['dataoffset'] = $offset;
+ $WMpicture['data'] = substr($data, $offset);
+
+ $imageinfo = array();
+ $WMpicture['image_mime'] = '';
+ $imagechunkcheck = getid3_lib::GetDataImageSize($WMpicture['data'], $imageinfo);
+ unset($imageinfo);
+ if (!empty($imagechunkcheck)) {
+ $WMpicture['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
+ }
+ if (!isset($this->getid3->info['asf']['comments']['picture'])) {
+ $this->getid3->info['asf']['comments']['picture'] = array();
}
+ $this->getid3->info['asf']['comments']['picture'][] = array('data'=>$WMpicture['data'], 'image_mime'=>$WMpicture['image_mime']);
- // convert
- return trim(getid3_lib::iconv_fallback('UTF-16LE', 'ISO-8859-1', $string), ' ');
+ return $WMpicture;
}
- function TrimTerm($string) {
+ // Remove terminator 00 00 and convert UTF-16LE to Latin-1
+ static function TrimConvert($string) {
+ return trim(getid3_lib::iconv_fallback('UTF-16LE', 'ISO-8859-1', getid3_asf::TrimTerm($string)), ' ');
+ }
+
+ // Remove terminator 00 00
+ static function TrimTerm($string) {
// remove terminator, only if present (it should be, but...)
- if (substr($string, -2) == "\x00\x00") {
+ if (substr($string, -2) === "\x00\x00") {
$string = substr($string, 0, -2);
}
return $string;
}
-
}
-
?> \ No newline at end of file
diff --git a/3rdparty/getid3/module.audio-video.bink.php b/3rdparty/getid3/module.audio-video.bink.php
new file mode 100644
index 00000000000..0a321396765
--- /dev/null
+++ b/3rdparty/getid3/module.audio-video.bink.php
@@ -0,0 +1,73 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.bink.php //
+// module for analyzing Bink or Smacker audio-video files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_bink extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+$info['error'][] = 'Bink / Smacker files not properly processed by this version of getID3() ['.$this->getid3->version().']';
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $fileTypeID = fread($this->getid3->fp, 3);
+ switch ($fileTypeID) {
+ case 'BIK':
+ return $this->ParseBink();
+ break;
+
+ case 'SMK':
+ return $this->ParseSmacker();
+ break;
+
+ default:
+ $info['error'][] = 'Expecting "BIK" or "SMK" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($fileTypeID).'"';
+ return false;
+ break;
+ }
+
+ return true;
+
+ }
+
+ function ParseBink() {
+ $info = &$this->getid3->info;
+ $info['fileformat'] = 'bink';
+ $info['video']['dataformat'] = 'bink';
+
+ $fileData = 'BIK'.fread($this->getid3->fp, 13);
+
+ $info['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
+ $info['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
+
+ if (($info['avdataend'] - $info['avdataoffset']) != ($info['bink']['data_size'] + 8)) {
+ $info['error'][] = 'Probably truncated file: expecting '.$info['bink']['data_size'].' bytes, found '.($info['avdataend'] - $info['avdataoffset']);
+ }
+
+ return true;
+ }
+
+ function ParseSmacker() {
+ $info = &$this->getid3->info;
+ $info['fileformat'] = 'smacker';
+ $info['video']['dataformat'] = 'smacker';
+
+ return true;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/3rdparty/getid3/module.audio-video.flv.php b/3rdparty/getid3/module.audio-video.flv.php
new file mode 100644
index 00000000000..ba3cd908df1
--- /dev/null
+++ b/3rdparty/getid3/module.audio-video.flv.php
@@ -0,0 +1,731 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+// //
+// FLV module by Seth Kaufman <seth@whirl-i-gig.com> //
+// //
+// * version 0.1 (26 June 2005) //
+// //
+// //
+// * version 0.1.1 (15 July 2005) //
+// minor modifications by James Heinrich <info@getid3.org> //
+// //
+// * version 0.2 (22 February 2006) //
+// Support for On2 VP6 codec and meta information //
+// by Steve Webster <steve.webster@featurecreep.com> //
+// //
+// * version 0.3 (15 June 2006) //
+// Modified to not read entire file into memory //
+// by James Heinrich <info@getid3.org> //
+// //
+// * version 0.4 (07 December 2007) //
+// Bugfixes for incorrectly parsed FLV dimensions //
+// and incorrect parsing of onMetaTag //
+// by Evgeny Moysevich <moysevich@gmail.com> //
+// //
+// * version 0.5 (21 May 2009) //
+// Fixed parsing of audio tags and added additional codec //
+// details. The duration is now read from onMetaTag (if //
+// exists), rather than parsing whole file //
+// by Nigel Barnes <ngbarnes@hotmail.com> //
+// //
+// * version 0.6 (24 May 2009) //
+// Better parsing of files with h264 video //
+// by Evgeny Moysevich <moysevichØgmail*com> //
+// //
+// * version 0.6.1 (30 May 2011) //
+// prevent infinite loops in expGolombUe() //
+// //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio-video.flv.php //
+// module for analyzing Shockwave Flash Video files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+define('GETID3_FLV_TAG_AUDIO', 8);
+define('GETID3_FLV_TAG_VIDEO', 9);
+define('GETID3_FLV_TAG_META', 18);
+
+define('GETID3_FLV_VIDEO_H263', 2);
+define('GETID3_FLV_VIDEO_SCREEN', 3);
+define('GETID3_FLV_VIDEO_VP6FLV', 4);
+define('GETID3_FLV_VIDEO_VP6FLV_ALPHA', 5);
+define('GETID3_FLV_VIDEO_SCREENV2', 6);
+define('GETID3_FLV_VIDEO_H264', 7);
+
+define('H264_AVC_SEQUENCE_HEADER', 0);
+define('H264_PROFILE_BASELINE', 66);
+define('H264_PROFILE_MAIN', 77);
+define('H264_PROFILE_EXTENDED', 88);
+define('H264_PROFILE_HIGH', 100);
+define('H264_PROFILE_HIGH10', 110);
+define('H264_PROFILE_HIGH422', 122);
+define('H264_PROFILE_HIGH444', 144);
+define('H264_PROFILE_HIGH444_PREDICTIVE', 244);
+
+class getid3_flv extends getid3_handler
+{
+ var $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
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+
+ $FLVdataLength = $info['avdataend'] - $info['avdataoffset'];
+ $FLVheader = fread($this->getid3->fp, 5);
+
+ $info['fileformat'] = 'flv';
+ $info['flv']['header']['signature'] = substr($FLVheader, 0, 3);
+ $info['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
+ $TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));
+
+ $magic = 'FLV';
+ if ($info['flv']['header']['signature'] != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['flv']['header']['signature']).'"';
+ unset($info['flv']);
+ unset($info['fileformat']);
+ return false;
+ }
+
+ $info['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04);
+ $info['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01);
+
+ $FrameSizeDataLength = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4));
+ $FLVheaderFrameLength = 9;
+ if ($FrameSizeDataLength > $FLVheaderFrameLength) {
+ fseek($this->getid3->fp, $FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
+ }
+ $Duration = 0;
+ $found_video = false;
+ $found_audio = false;
+ $found_meta = false;
+ $found_valid_meta_playtime = false;
+ $tagParseCount = 0;
+ $info['flv']['framecount'] = array('total'=>0, 'audio'=>0, 'video'=>0);
+ $flv_framecount = &$info['flv']['framecount'];
+ while (((ftell($this->getid3->fp) + 16) < $info['avdataend']) && (($tagParseCount++ <= $this->max_frames) || !$found_valid_meta_playtime)) {
+ $ThisTagHeader = fread($this->getid3->fp, 16);
+
+ $PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4));
+ $TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1));
+ $DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3));
+ $Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3));
+ $LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1));
+ $NextOffset = ftell($this->getid3->fp) - 1 + $DataLength;
+ if ($Timestamp > $Duration) {
+ $Duration = $Timestamp;
+ }
+
+ $flv_framecount['total']++;
+ switch ($TagType) {
+ case GETID3_FLV_TAG_AUDIO:
+ $flv_framecount['audio']++;
+ if (!$found_audio) {
+ $found_audio = true;
+ $info['flv']['audio']['audioFormat'] = ($LastHeaderByte >> 4) & 0x0F;
+ $info['flv']['audio']['audioRate'] = ($LastHeaderByte >> 2) & 0x03;
+ $info['flv']['audio']['audioSampleSize'] = ($LastHeaderByte >> 1) & 0x01;
+ $info['flv']['audio']['audioType'] = $LastHeaderByte & 0x01;
+ }
+ break;
+
+ case GETID3_FLV_TAG_VIDEO:
+ $flv_framecount['video']++;
+ if (!$found_video) {
+ $found_video = true;
+ $info['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07;
+
+ $FLVvideoHeader = fread($this->getid3->fp, 11);
+
+ if ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H264) {
+ // this code block contributed by: moysevichØgmail*com
+
+ $AVCPacketType = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 0, 1));
+ if ($AVCPacketType == H264_AVC_SEQUENCE_HEADER) {
+ // read AVCDecoderConfigurationRecord
+ $configurationVersion = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 1));
+ $AVCProfileIndication = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 1));
+ $profile_compatibility = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 1));
+ $lengthSizeMinusOne = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 1));
+ $numOfSequenceParameterSets = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 8, 1));
+
+ if (($numOfSequenceParameterSets & 0x1F) != 0) {
+ // there is at least one SequenceParameterSet
+ // read size of the first SequenceParameterSet
+ //$spsSize = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 9, 2));
+ $spsSize = getid3_lib::LittleEndian2Int(substr($FLVvideoHeader, 9, 2));
+ // read the first SequenceParameterSet
+ $sps = fread($this->getid3->fp, $spsSize);
+ if (strlen($sps) == $spsSize) { // make sure that whole SequenceParameterSet was red
+ $spsReader = new AVCSequenceParameterSetReader($sps);
+ $spsReader->readData();
+ $info['video']['resolution_x'] = $spsReader->getWidth();
+ $info['video']['resolution_y'] = $spsReader->getHeight();
+ }
+ }
+ }
+ // end: moysevichØgmail*com
+
+ } elseif ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H263) {
+
+ $PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 3, 2))) >> 7;
+ $PictureSizeType = $PictureSizeType & 0x0007;
+ $info['flv']['header']['videoSizeType'] = $PictureSizeType;
+ switch ($PictureSizeType) {
+ case 0:
+ //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
+ //$PictureSizeEnc <<= 1;
+ //$info['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8;
+ //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
+ //$PictureSizeEnc <<= 1;
+ //$info['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8;
+
+ $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 2));
+ $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
+ $PictureSizeEnc['x'] >>= 7;
+ $PictureSizeEnc['y'] >>= 7;
+ $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFF;
+ $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFF;
+ break;
+
+ case 1:
+ $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 3));
+ $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 3));
+ $PictureSizeEnc['x'] >>= 7;
+ $PictureSizeEnc['y'] >>= 7;
+ $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFFFF;
+ $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFFFF;
+ break;
+
+ case 2:
+ $info['video']['resolution_x'] = 352;
+ $info['video']['resolution_y'] = 288;
+ break;
+
+ case 3:
+ $info['video']['resolution_x'] = 176;
+ $info['video']['resolution_y'] = 144;
+ break;
+
+ case 4:
+ $info['video']['resolution_x'] = 128;
+ $info['video']['resolution_y'] = 96;
+ break;
+
+ case 5:
+ $info['video']['resolution_x'] = 320;
+ $info['video']['resolution_y'] = 240;
+ break;
+
+ case 6:
+ $info['video']['resolution_x'] = 160;
+ $info['video']['resolution_y'] = 120;
+ break;
+
+ default:
+ $info['video']['resolution_x'] = 0;
+ $info['video']['resolution_y'] = 0;
+ break;
+
+ }
+ }
+ $info['video']['pixel_aspect_ratio'] = $info['video']['resolution_x'] / $info['video']['resolution_y'];
+ }
+ break;
+
+ // Meta tag
+ case GETID3_FLV_TAG_META:
+ if (!$found_meta) {
+ $found_meta = true;
+ fseek($this->getid3->fp, -1, SEEK_CUR);
+ $datachunk = fread($this->getid3->fp, $DataLength);
+ $AMFstream = new AMFStream($datachunk);
+ $reader = new AMFReader($AMFstream);
+ $eventName = $reader->readData();
+ $info['flv']['meta'][$eventName] = $reader->readData();
+ unset($reader);
+
+ $copykeys = array('framerate'=>'frame_rate', 'width'=>'resolution_x', 'height'=>'resolution_y', 'audiodatarate'=>'bitrate', 'videodatarate'=>'bitrate');
+ foreach ($copykeys as $sourcekey => $destkey) {
+ if (isset($info['flv']['meta']['onMetaData'][$sourcekey])) {
+ switch ($sourcekey) {
+ case 'width':
+ case 'height':
+ $info['video'][$destkey] = intval(round($info['flv']['meta']['onMetaData'][$sourcekey]));
+ break;
+ case 'audiodatarate':
+ $info['audio'][$destkey] = getid3_lib::CastAsInt(round($info['flv']['meta']['onMetaData'][$sourcekey] * 1000));
+ break;
+ case 'videodatarate':
+ case 'frame_rate':
+ default:
+ $info['video'][$destkey] = $info['flv']['meta']['onMetaData'][$sourcekey];
+ break;
+ }
+ }
+ }
+ if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
+ $found_valid_meta_playtime = true;
+ }
+ }
+ break;
+
+ default:
+ // noop
+ break;
+ }
+ fseek($this->getid3->fp, $NextOffset, SEEK_SET);
+ }
+
+ $info['playtime_seconds'] = $Duration / 1000;
+ if ($info['playtime_seconds'] > 0) {
+ $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+ }
+
+ if ($info['flv']['header']['hasAudio']) {
+ $info['audio']['codec'] = $this->FLVaudioFormat($info['flv']['audio']['audioFormat']);
+ $info['audio']['sample_rate'] = $this->FLVaudioRate($info['flv']['audio']['audioRate']);
+ $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info['flv']['audio']['audioSampleSize']);
+
+ $info['audio']['channels'] = $info['flv']['audio']['audioType'] + 1; // 0=mono,1=stereo
+ $info['audio']['lossless'] = ($info['flv']['audio']['audioFormat'] ? false : true); // 0=uncompressed
+ $info['audio']['dataformat'] = 'flv';
+ }
+ if (!empty($info['flv']['header']['hasVideo'])) {
+ $info['video']['codec'] = $this->FLVvideoCodec($info['flv']['video']['videoCodec']);
+ $info['video']['dataformat'] = 'flv';
+ $info['video']['lossless'] = false;
+ }
+
+ // Set information from meta
+ if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
+ $info['playtime_seconds'] = $info['flv']['meta']['onMetaData']['duration'];
+ $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+ }
+ if (isset($info['flv']['meta']['onMetaData']['audiocodecid'])) {
+ $info['audio']['codec'] = $this->FLVaudioFormat($info['flv']['meta']['onMetaData']['audiocodecid']);
+ }
+ if (isset($info['flv']['meta']['onMetaData']['videocodecid'])) {
+ $info['video']['codec'] = $this->FLVvideoCodec($info['flv']['meta']['onMetaData']['videocodecid']);
+ }
+ return true;
+ }
+
+
+ function FLVaudioFormat($id) {
+ $FLVaudioFormat = array(
+ 0 => 'Linear PCM, platform endian',
+ 1 => 'ADPCM',
+ 2 => 'mp3',
+ 3 => 'Linear PCM, little endian',
+ 4 => 'Nellymoser 16kHz mono',
+ 5 => 'Nellymoser 8kHz mono',
+ 6 => 'Nellymoser',
+ 7 => 'G.711A-law logarithmic PCM',
+ 8 => 'G.711 mu-law logarithmic PCM',
+ 9 => 'reserved',
+ 10 => 'AAC',
+ 11 => false, // unknown?
+ 12 => false, // unknown?
+ 13 => false, // unknown?
+ 14 => 'mp3 8kHz',
+ 15 => 'Device-specific sound',
+ );
+ return (isset($FLVaudioFormat[$id]) ? $FLVaudioFormat[$id] : false);
+ }
+
+ function FLVaudioRate($id) {
+ $FLVaudioRate = array(
+ 0 => 5500,
+ 1 => 11025,
+ 2 => 22050,
+ 3 => 44100,
+ );
+ return (isset($FLVaudioRate[$id]) ? $FLVaudioRate[$id] : false);
+ }
+
+ function FLVaudioBitDepth($id) {
+ $FLVaudioBitDepth = array(
+ 0 => 8,
+ 1 => 16,
+ );
+ return (isset($FLVaudioBitDepth[$id]) ? $FLVaudioBitDepth[$id] : false);
+ }
+
+ function FLVvideoCodec($id) {
+ $FLVvideoCodec = array(
+ GETID3_FLV_VIDEO_H263 => 'Sorenson H.263',
+ GETID3_FLV_VIDEO_SCREEN => 'Screen video',
+ GETID3_FLV_VIDEO_VP6FLV => 'On2 VP6',
+ GETID3_FLV_VIDEO_VP6FLV_ALPHA => 'On2 VP6 with alpha channel',
+ GETID3_FLV_VIDEO_SCREENV2 => 'Screen video v2',
+ GETID3_FLV_VIDEO_H264 => 'Sorenson H.264',
+ );
+ return (isset($FLVvideoCodec[$id]) ? $FLVvideoCodec[$id] : false);
+ }
+}
+
+class AMFStream {
+ var $bytes;
+ var $pos;
+
+ function AMFStream(&$bytes) {
+ $this->bytes =& $bytes;
+ $this->pos = 0;
+ }
+
+ function readByte() {
+ return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
+ }
+
+ function readInt() {
+ return ($this->readByte() << 8) + $this->readByte();
+ }
+
+ function readLong() {
+ return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
+ }
+
+ function readDouble() {
+ return getid3_lib::BigEndian2Float($this->read(8));
+ }
+
+ function readUTF() {
+ $length = $this->readInt();
+ return $this->read($length);
+ }
+
+ function readLongUTF() {
+ $length = $this->readLong();
+ return $this->read($length);
+ }
+
+ function read($length) {
+ $val = substr($this->bytes, $this->pos, $length);
+ $this->pos += $length;
+ return $val;
+ }
+
+ function peekByte() {
+ $pos = $this->pos;
+ $val = $this->readByte();
+ $this->pos = $pos;
+ return $val;
+ }
+
+ function peekInt() {
+ $pos = $this->pos;
+ $val = $this->readInt();
+ $this->pos = $pos;
+ return $val;
+ }
+
+ function peekLong() {
+ $pos = $this->pos;
+ $val = $this->readLong();
+ $this->pos = $pos;
+ return $val;
+ }
+
+ function peekDouble() {
+ $pos = $this->pos;
+ $val = $this->readDouble();
+ $this->pos = $pos;
+ return $val;
+ }
+
+ function peekUTF() {
+ $pos = $this->pos;
+ $val = $this->readUTF();
+ $this->pos = $pos;
+ return $val;
+ }
+
+ function peekLongUTF() {
+ $pos = $this->pos;
+ $val = $this->readLongUTF();
+ $this->pos = $pos;
+ return $val;
+ }
+}
+
+class AMFReader {
+ var $stream;
+
+ function AMFReader(&$stream) {
+ $this->stream =& $stream;
+ }
+
+ function readData() {
+ $value = null;
+
+ $type = $this->stream->readByte();
+ switch ($type) {
+
+ // Double
+ case 0:
+ $value = $this->readDouble();
+ break;
+
+ // Boolean
+ case 1:
+ $value = $this->readBoolean();
+ break;
+
+ // String
+ case 2:
+ $value = $this->readString();
+ break;
+
+ // Object
+ case 3:
+ $value = $this->readObject();
+ break;
+
+ // null
+ case 6:
+ return null;
+ break;
+
+ // Mixed array
+ case 8:
+ $value = $this->readMixedArray();
+ break;
+
+ // Array
+ case 10:
+ $value = $this->readArray();
+ break;
+
+ // Date
+ case 11:
+ $value = $this->readDate();
+ break;
+
+ // Long string
+ case 13:
+ $value = $this->readLongString();
+ break;
+
+ // XML (handled as string)
+ case 15:
+ $value = $this->readXML();
+ break;
+
+ // Typed object (handled as object)
+ case 16:
+ $value = $this->readTypedObject();
+ break;
+
+ // Long string
+ default:
+ $value = '(unknown or unsupported data type)';
+ break;
+ }
+
+ return $value;
+ }
+
+ function readDouble() {
+ return $this->stream->readDouble();
+ }
+
+ function readBoolean() {
+ return $this->stream->readByte() == 1;
+ }
+
+ function readString() {
+ return $this->stream->readUTF();
+ }
+
+ function readObject() {
+ // Get highest numerical index - ignored
+// $highestIndex = $this->stream->readLong();
+
+ $data = array();
+
+ while ($key = $this->stream->readUTF()) {
+ $data[$key] = $this->readData();
+ }
+ // Mixed array record ends with empty string (0x00 0x00) and 0x09
+ if (($key == '') && ($this->stream->peekByte() == 0x09)) {
+ // Consume byte
+ $this->stream->readByte();
+ }
+ return $data;
+ }
+
+ function readMixedArray() {
+ // Get highest numerical index - ignored
+ $highestIndex = $this->stream->readLong();
+
+ $data = array();
+
+ while ($key = $this->stream->readUTF()) {
+ if (is_numeric($key)) {
+ $key = (float) $key;
+ }
+ $data[$key] = $this->readData();
+ }
+ // Mixed array record ends with empty string (0x00 0x00) and 0x09
+ if (($key == '') && ($this->stream->peekByte() == 0x09)) {
+ // Consume byte
+ $this->stream->readByte();
+ }
+
+ return $data;
+ }
+
+ function readArray() {
+ $length = $this->stream->readLong();
+ $data = array();
+
+ for ($i = 0; $i < $length; $i++) {
+ $data[] = $this->readData();
+ }
+ return $data;
+ }
+
+ function readDate() {
+ $timestamp = $this->stream->readDouble();
+ $timezone = $this->stream->readInt();
+ return $timestamp;
+ }
+
+ function readLongString() {
+ return $this->stream->readLongUTF();
+ }
+
+ function readXML() {
+ return $this->stream->readLongUTF();
+ }
+
+ function readTypedObject() {
+ $className = $this->stream->readUTF();
+ return $this->readObject();
+ }
+}
+
+class AVCSequenceParameterSetReader {
+ var $sps;
+ var $start = 0;
+ var $currentBytes = 0;
+ var $currentBits = 0;
+ var $width;
+ var $height;
+
+ function AVCSequenceParameterSetReader($sps) {
+ $this->sps = $sps;
+ }
+
+ function readData() {
+ $this->skipBits(8);
+ $this->skipBits(8);
+ $profile = $this->getBits(8); // read profile
+ $this->skipBits(16);
+ $this->expGolombUe(); // read sps id
+ if (in_array($profile, array(H264_PROFILE_HIGH, H264_PROFILE_HIGH10, H264_PROFILE_HIGH422, H264_PROFILE_HIGH444, H264_PROFILE_HIGH444_PREDICTIVE))) {
+ if ($this->expGolombUe() == 3) {
+ $this->skipBits(1);
+ }
+ $this->expGolombUe();
+ $this->expGolombUe();
+ $this->skipBits(1);
+ if ($this->getBit()) {
+ for ($i = 0; $i < 8; $i++) {
+ if ($this->getBit()) {
+ $size = $i < 6 ? 16 : 64;
+ $lastScale = 8;
+ $nextScale = 8;
+ for ($j = 0; $j < $size; $j++) {
+ if ($nextScale != 0) {
+ $deltaScale = $this->expGolombUe();
+ $nextScale = ($lastScale + $deltaScale + 256) % 256;
+ }
+ if ($nextScale != 0) {
+ $lastScale = $nextScale;
+ }
+ }
+ }
+ }
+ }
+ }
+ $this->expGolombUe();
+ $pocType = $this->expGolombUe();
+ if ($pocType == 0) {
+ $this->expGolombUe();
+ } elseif ($pocType == 1) {
+ $this->skipBits(1);
+ $this->expGolombSe();
+ $this->expGolombSe();
+ $pocCycleLength = $this->expGolombUe();
+ for ($i = 0; $i < $pocCycleLength; $i++) {
+ $this->expGolombSe();
+ }
+ }
+ $this->expGolombUe();
+ $this->skipBits(1);
+ $this->width = ($this->expGolombUe() + 1) * 16;
+ $heightMap = $this->expGolombUe() + 1;
+ $this->height = (2 - $this->getBit()) * $heightMap * 16;
+ }
+
+ function skipBits($bits) {
+ $newBits = $this->currentBits + $bits;
+ $this->currentBytes += (int)floor($newBits / 8);
+ $this->currentBits = $newBits % 8;
+ }
+
+ function getBit() {
+ $result = (getid3_lib::BigEndian2Int(substr($this->sps, $this->currentBytes, 1)) >> (7 - $this->currentBits)) & 0x01;
+ $this->skipBits(1);
+ return $result;
+ }
+
+ function getBits($bits) {
+ $result = 0;
+ for ($i = 0; $i < $bits; $i++) {
+ $result = ($result << 1) + $this->getBit();
+ }
+ return $result;
+ }
+
+ function expGolombUe() {
+ $significantBits = 0;
+ $bit = $this->getBit();
+ while ($bit == 0) {
+ $significantBits++;
+ $bit = $this->getBit();
+
+ if ($significantBits > 31) {
+ // something is broken, this is an emergency escape to prevent infinite loops
+ return 0;
+ }
+ }
+ return (1 << $significantBits) + $this->getBits($significantBits) - 1;
+ }
+
+ function expGolombSe() {
+ $result = $this->expGolombUe();
+ if (($result & 0x01) == 0) {
+ return -($result >> 1);
+ } else {
+ return ($result + 1) >> 1;
+ }
+ }
+
+ function getWidth() {
+ return $this->width;
+ }
+
+ function getHeight() {
+ return $this->height;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio-video.matroska.php b/3rdparty/getid3/module.audio-video.matroska.php
index 004056edb0e..b7ab667989b 100644
--- a/apps/media/getID3/getid3/module.audio-video.matroska.php
+++ b/3rdparty/getid3/module.audio-video.matroska.php
@@ -14,9 +14,10 @@
/////////////////////////////////////////////////////////////////
+// from: http://www.matroska.org/technical/specs/index.html
define('EBML_ID_CHAPTERS', 0x0043A770); // [10][43][A7][70] -- A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation.
define('EBML_ID_SEEKHEAD', 0x014D9B74); // [11][4D][9B][74] -- Contains the position of other level 1 elements.
-define('EBML_ID_TAGS', 0x0254C367); // [12][54][C3][67] -- Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here.
+define('EBML_ID_TAGS', 0x0254C367); // [12][54][C3][67] -- Element containing elements specific to Tracks/Chapters. A list of valid tags can be found <http://www.matroska.org/technical/specs/tagging/index.html>.
define('EBML_ID_INFO', 0x0549A966); // [15][49][A9][66] -- Contains miscellaneous general information and statistics on the file.
define('EBML_ID_TRACKS', 0x0654AE6B); // [16][54][AE][6B] -- A top-level block of information with many tracks described.
define('EBML_ID_SEGMENT', 0x08538067); // [18][53][80][67] -- This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment.
@@ -111,7 +112,7 @@ define('EBML_ID_TARGETS', 0x23C0); // [63][C0] --
define('EBML_ID_CHAPTERPHYSICALEQUIV', 0x23C3); // [63][C3] -- Specify the physical equivalent of this ChapterAtom like "DVD" (60) or "SIDE" (50), see complete list of values.
define('EBML_ID_TAGCHAPTERUID', 0x23C4); // [63][C4] -- A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment.
define('EBML_ID_TAGTRACKUID', 0x23C5); // [63][C5] -- A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment.
-define('EBML_ID_ATTACHMENTUID', 0x23C6); // [63][C6] -- A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment.
+define('EBML_ID_TAGATTACHMENTUID', 0x23C6); // [63][C6] -- A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment.
define('EBML_ID_TAGEDITIONUID', 0x23C9); // [63][C9] -- A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment.
define('EBML_ID_TARGETTYPE', 0x23CA); // [63][CA] -- An informational string that can be used to display the logical level of the target like "ALBUM", "TRACK", "MOVIE", "CHAPTER", etc (see TargetType).
define('EBML_ID_TRACKTRANSLATE', 0x2624); // [66][24] -- The track identification for the given Chapter Codec.
@@ -205,176 +206,367 @@ define('EBML_ID_CLUSTERREFERENCEBLOCK', 0x7B); // [FB] --
define('EBML_ID_CLUSTERREFERENCEVIRTUAL', 0x7D); // [FD] -- Relative position of the data that should be in position of the virtual block.
-class getid3_matroska
+class getid3_matroska extends getid3_handler
{
- var $read_buffer_size = 32768; // size of read buffer, 32kB is default
- var $hide_clusters = true; // if true, do not return information about CLUSTER chunks, since there's a lot of them and they're not usually useful
- var $warnings = array();
-
- function getid3_matroska(&$fd, &$ThisFileInfo) {
+ // public options
+ public static $hide_clusters = true; // if true, do not return information about CLUSTER chunks, since there's a lot of them and they're not usually useful [default: TRUE]
+ public static $parse_whole_file = false; // true to parse the whole file, not only header [default: FALSE]
+
+ // private parser settings/placeholders
+ private $EBMLbuffer = '';
+ private $EBMLbuffer_offset = 0;
+ private $EBMLbuffer_length = 0;
+ private $current_offset = 0;
+ private $unuseful_elements = array(EBML_ID_CRC32, EBML_ID_VOID);
+
+ public function Analyze()
+ {
+ $info = &$this->getid3->info;
+
+ // parse container
+ try {
+ $this->parseEBML($info);
+ }
+ catch (Exception $e) {
+ $info['error'][] = 'EBML parser: '.$e->getMessage();
+ }
- // http://www.matroska.org/technical/specs/index.html#EBMLBasics
- $offset = $ThisFileInfo['avdataoffset'];
- $EBMLdata = '';
- $EBMLdata_offset = $offset;
+ // calculate playtime
+ if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
+ foreach ($info['matroska']['info'] as $key => $infoarray) {
+ if (isset($infoarray['Duration'])) {
+ // TimecodeScale is how many nanoseconds each Duration unit is
+ $info['playtime_seconds'] = $infoarray['Duration'] * ((isset($infoarray['TimecodeScale']) ? $infoarray['TimecodeScale'] : 1000000) / 1000000000);
+ break;
+ }
+ }
+ }
- if ($ThisFileInfo['avdataend'] > 2147483648) {
- $this->warnings[] = 'This version of getID3() may or may not correctly handle Matroska files larger than 2GB';
+ // extract tags
+ if (isset($info['matroska']['tags']) && is_array($info['matroska']['tags'])) {
+ foreach ($info['matroska']['tags'] as $key => $infoarray) {
+ $this->ExtractCommentsSimpleTag($infoarray);
+ }
}
- while ($offset < $ThisFileInfo['avdataend']) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
+ // process tracks
+ if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
+ foreach ($info['matroska']['tracks']['tracks'] as $key => $trackarray) {
+
+ $track_info = array();
+ $track_info['dataformat'] = self::MatroskaCodecIDtoCommonName($trackarray['CodecID']);
+ $track_info['default'] = (isset($trackarray['FlagDefault']) ? $trackarray['FlagDefault'] : true);
+ if (isset($trackarray['Name'])) { $track_info['name'] = $trackarray['Name']; }
+
+ switch ($trackarray['TrackType']) {
+
+ case 1: // Video
+ $track_info['resolution_x'] = $trackarray['PixelWidth'];
+ $track_info['resolution_y'] = $trackarray['PixelHeight'];
+ if (isset($trackarray['DisplayWidth'])) { $track_info['display_x'] = $trackarray['DisplayWidth']; }
+ if (isset($trackarray['DisplayHeight'])) { $track_info['display_y'] = $trackarray['DisplayHeight']; }
+ if (isset($trackarray['DefaultDuration'])) { $track_info['frame_rate'] = round(1000000000 / $trackarray['DefaultDuration'], 3); }
+ //if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; }
+
+ switch ($trackarray['CodecID']) {
+ case 'V_MS/VFW/FOURCC':
+ if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) {
+ $this->getid3->warning('Unable to parse codec private data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio-video.riff.php"');
+ break;
+ }
+ $parsed = getid3_riff::ParseBITMAPINFOHEADER($trackarray['CodecPrivate']);
+ $track_info['codec'] = getid3_riff::RIFFfourccLookup($parsed['fourcc']);
+ $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
+ break;
+ }
+
+ $info['video']['streams'][] = $track_info;
+ break;
+
+ case 2: // Audio
+ $track_info['sample_rate'] = (isset($trackarray['SamplingFrequency']) ? $trackarray['SamplingFrequency'] : 8000.0);
+ $track_info['channels'] = (isset($trackarray['Channels']) ? $trackarray['Channels'] : 1);
+ $track_info['language'] = (isset($trackarray['Language']) ? $trackarray['Language'] : 'eng');
+ if (isset($trackarray['BitDepth'])) { $track_info['bits_per_sample'] = $trackarray['BitDepth']; }
+ //if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; }
+
+ switch ($trackarray['CodecID']) {
+ case 'A_PCM/INT/LIT':
+ case 'A_PCM/INT/BIG':
+ $track_info['bitrate'] = $trackarray['SamplingFrequency'] * $trackarray['Channels'] * $trackarray['BitDepth'];
+ break;
+
+ case 'A_AC3':
+ case 'A_DTS':
+ case 'A_MPEG/L3':
+ //case 'A_FLAC':
+ if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.'.$track_info['dataformat'].'.php', __FILE__, false)) {
+ $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio.'.$track_info['dataformat'].'.php"');
+ break;
+ }
- $top_element_offset = $offset;
- $top_element_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $top_element_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- if ($top_element_length === false) {
- $this->warnings[] = 'invalid chunk length at '.$top_element_offset;
- $offset = pow(2, 63);
- break;
+ if (!isset($info['matroska']['track_data_offsets'][$trackarray['TrackNumber']])) {
+ $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because $info[matroska][track_data_offsets]['.$trackarray['TrackNumber'].'] not set');
+ break;
+ }
+
+ // create temp instance
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataoffset'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'];
+ if ($track_info['dataformat'] == 'mp3' || $track_info['dataformat'] == 'flac') {
+ $getid3_temp->info['avdataend'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'] + $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['length'];
+ }
+
+ // analyze
+ $class = 'getid3_'.$track_info['dataformat'];
+ $header_data_key = $track_info['dataformat'] == 'mp3' ? 'mpeg' : $track_info['dataformat'];
+ $getid3_audio = new $class($getid3_temp);
+ if ($track_info['dataformat'] == 'mp3') {
+ $getid3_audio->allow_bruteforce = true;
+ }
+ if ($track_info['dataformat'] == 'flac') {
+ $getid3_audio->AnalyzeString($trackarray['CodecPrivate']);
+ }
+ else {
+ $getid3_audio->Analyze();
+ }
+ if (!empty($getid3_temp->info[$header_data_key])) {
+ unset($getid3_temp->info[$header_data_key]['GETID3_VERSION']);
+ $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info[$header_data_key];
+ if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) {
+ foreach ($getid3_temp->info['audio'] as $key => $value) {
+ $track_info[$key] = $value;
+ }
+ }
+ }
+ else {
+ $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because '.$class.'::Analyze() failed at offset '.$getid3_temp->info['avdataoffset']);
+ }
+
+ // copy errors and warnings
+ if (!empty($getid3_temp->info['error'])) {
+ foreach ($getid3_temp->info['error'] as $newerror) {
+ $this->getid3->warning($class.'() says: ['.$newerror.']');
+ }
+ }
+ if (!empty($getid3_temp->info['warning'])) {
+ foreach ($getid3_temp->info['warning'] as $newerror) {
+ if ($track_info['dataformat'] == 'mp3' && preg_match('/^Probable truncated file: expecting \d+ bytes of audio data, only found \d+ \(short by \d+ bytes\)$/', $newerror)) {
+ // 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 warning
+ continue;
+ }
+ $this->getid3->warning($class.'() says: ['.$newerror.']');
+ }
+ }
+ unset($getid3_temp, $getid3_audio);
+ break;
+
+ case 'A_AAC':
+ case 'A_AAC/MPEG2/LC':
+ case 'A_AAC/MPEG4/LC':
+ case 'A_AAC/MPEG4/LC/SBR':
+ $this->getid3->warning($trackarray['CodecID'].' audio data contains no header, audio/video bitrates can\'t be calculated');
+ break;
+
+ case 'A_VORBIS':
+ if (!isset($trackarray['CodecPrivate'])) {
+ $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because CodecPrivate data not set');
+ break;
+ }
+ $vorbis_offset = strpos($trackarray['CodecPrivate'], 'vorbis', 1);
+ if ($vorbis_offset === false) {
+ $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because CodecPrivate data does not contain "vorbis" keyword');
+ break;
+ }
+ $vorbis_offset -= 1;
+
+ if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, false)) {
+ $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio.ogg.php"');
+ }
+
+ // create temp instance
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+
+ // analyze
+ $getid3_ogg = new getid3_ogg($getid3_temp);
+ $oggpageinfo['page_seqno'] = 0;
+ $getid3_ogg->ParseVorbisPageHeader($trackarray['CodecPrivate'], $vorbis_offset, $oggpageinfo);
+ if (!empty($getid3_temp->info['ogg'])) {
+ $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info['ogg'];
+ if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) {
+ foreach ($getid3_temp->info['audio'] as $key => $value) {
+ $track_info[$key] = $value;
+ }
+ }
+ }
+
+ // copy errors and warnings
+ if (!empty($getid3_temp->info['error'])) {
+ foreach ($getid3_temp->info['error'] as $newerror) {
+ $this->getid3->warning('getid3_ogg() says: ['.$newerror.']');
+ }
+ }
+ if (!empty($getid3_temp->info['warning'])) {
+ foreach ($getid3_temp->info['warning'] as $newerror) {
+ $this->getid3->warning('getid3_ogg() says: ['.$newerror.']');
+ }
+ }
+
+ if (!empty($getid3_temp->info['ogg']['bitrate_nominal'])) {
+ $track_info['bitrate'] = $getid3_temp->info['ogg']['bitrate_nominal'];
+ }
+ unset($getid3_temp, $getid3_ogg, $oggpageinfo, $vorbis_offset);
+ break;
+
+ case 'A_MS/ACM':
+ if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) {
+ $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio-video.riff.php"');
+ break;
+ }
+
+ $parsed = getid3_riff::RIFFparseWAVEFORMATex($trackarray['CodecPrivate']);
+ foreach ($parsed as $key => $value) {
+ if ($key != 'raw') {
+ $track_info[$key] = $value;
+ }
+ }
+ $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
+ break;
+
+ default:
+ $this->getid3->warning('Unhandled audio type "'.(isset($trackarray['CodecID']) ? $trackarray['CodecID'] : '').'"');
+ }
+
+ $info['audio']['streams'][] = $track_info;
+ break;
+ }
+ }
+
+ if (!empty($info['video']['streams'])) {
+ $info['video'] = self::getDefaultStreamInfo($info['video']['streams']);
}
- $top_element_endoffset = $offset + $top_element_length;
- switch ($top_element_id) {
+ if (!empty($info['audio']['streams'])) {
+ $info['audio'] = self::getDefaultStreamInfo($info['audio']['streams']);
+ }
+ }
+
+ // determine mime type
+ if (!empty($info['video']['streams'])) {
+ $info['mime_type'] = ($info['matroska']['doctype'] == 'webm' ? 'video/webm' : 'video/x-matroska');
+ } elseif (!empty($info['audio']['streams'])) {
+ $info['mime_type'] = ($info['matroska']['doctype'] == 'webm' ? 'audio/webm' : 'audio/x-matroska');
+ } elseif (isset($info['mime_type'])) {
+ unset($info['mime_type']);
+ }
+
+ return true;
+ }
+
+
+///////////////////////////////////////
+
+ private function parseEBML(&$info)
+ {
+ // http://www.matroska.org/technical/specs/index.html#EBMLBasics
+ $this->current_offset = $info['avdataoffset'];
+
+ while ($this->getEBMLelement($top_element, $info['avdataend'])) {
+ switch ($top_element['id']) {
+
case EBML_ID_EBML:
- $ThisFileInfo['fileformat'] = 'matroska';
- $ThisFileInfo['matroska']['header']['offset'] = $top_element_offset;
- $ThisFileInfo['matroska']['header']['length'] = $top_element_length;
-
- while ($offset < $top_element_endoffset) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $element_data = array();
- $element_data_offset = $offset;
- $element_data['id'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $element_data['id_name'] = $this->EBMLidName($element_data['id']);
- $element_data['length'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $end_offset = $offset + $element_data['length'];
+ $info['fileformat'] = 'matroska';
+ $info['matroska']['header']['offset'] = $top_element['offset'];
+ $info['matroska']['header']['length'] = $top_element['length'];
+ while ($this->getEBMLelement($element_data, $top_element['end'], true)) {
switch ($element_data['id']) {
+
case EBML_ID_EBMLVERSION:
case EBML_ID_EBMLREADVERSION:
case EBML_ID_EBMLMAXIDLENGTH:
case EBML_ID_EBMLMAXSIZELENGTH:
case EBML_ID_DOCTYPEVERSION:
case EBML_ID_DOCTYPEREADVERSION:
- $element_data['data'] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $element_data['length']));
+ $element_data['data'] = getid3_lib::BigEndian2Int($element_data['data']);
break;
+
case EBML_ID_DOCTYPE:
- $element_data['data'] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $element_data['length']), "\x00");
+ $element_data['data'] = getid3_lib::trimNullByte($element_data['data']);
+ $info['matroska']['doctype'] = $element_data['data'];
break;
- default:
- $this->warnings[] = 'Unhandled track.video element['.__LINE__.'] ('.$element_data['id'].'::'.$element_data['id_name'].') at '.$element_data_offset;
+
+ case EBML_ID_CRC32: // not useful, ignore
+ $this->current_offset = $element_data['end'];
+ unset($element_data);
break;
+
+ default:
+ $this->unhandledElement('header', __LINE__, $element_data);
+ }
+ if (!empty($element_data)) {
+ unset($element_data['offset'], $element_data['end']);
+ $info['matroska']['header']['elements'][] = $element_data;
}
- $offset = $end_offset;
- $ThisFileInfo['matroska']['header']['elements'][] = $element_data;
}
break;
-
case EBML_ID_SEGMENT:
- $ThisFileInfo['matroska']['segment'][0]['offset'] = $top_element_offset;
- $ThisFileInfo['matroska']['segment'][0]['length'] = $top_element_length;
-
- $segment_key = -1;
- while ($offset < $ThisFileInfo['avdataend']) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
-
- $element_data = array();
- $element_data['offset'] = $offset;
- $element_data['id'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $element_data['id_name'] = $this->EBMLidName($element_data['id']);
- $element_data['length'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- if ($element_data['length'] === false) {
- $this->warnings[] = 'invalid chunk length at '.$element_data['offset'];
- //$offset = pow(2, 63);
- $offset = $ThisFileInfo['avdataend'];
- break;
+ $info['matroska']['segment'][0]['offset'] = $top_element['offset'];
+ $info['matroska']['segment'][0]['length'] = $top_element['length'];
+
+ while ($this->getEBMLelement($element_data, $top_element['end'])) {
+ if ($element_data['id'] != EBML_ID_CLUSTER || !self::$hide_clusters) { // collect clusters only if required
+ $info['matroska']['segments'][] = $element_data;
}
- $element_end = $offset + $element_data['length'];
switch ($element_data['id']) {
- //case EBML_ID_CLUSTER:
- // // too many cluster entries, probably not useful
- // break;
- case false:
- $this->warnings[] = 'invalid ID at '.$element_data['offset'];
- $offset = $element_end;
- continue 3;
- default:
- $ThisFileInfo['matroska']['segments'][] = $element_data;
- break;
- }
- $segment_key++;
- switch ($element_data['id']) {
- case EBML_ID_SEEKHEAD: // Contains the position of other level 1 elements
- while ($offset < $element_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $seek_entry = array();
- $seek_entry['offset'] = $offset;
- $seek_entry['id'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $seek_entry['id_name'] = $this->EBMLidName($seek_entry['id']);
- $seek_entry['length'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $seek_end_offset = $offset + $seek_entry['length'];
+ case EBML_ID_SEEKHEAD: // Contains the position of other level 1 elements.
+
+ while ($this->getEBMLelement($seek_entry, $element_data['end'])) {
switch ($seek_entry['id']) {
+
case EBML_ID_SEEK: // Contains a single seek entry to an EBML element
- while ($offset < $seek_end_offset) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $value = substr($EBMLdata, $offset - $EBMLdata_offset, $length);
- $offset += $length;
- switch ($id) {
+ while ($this->getEBMLelement($sub_seek_entry, $seek_entry['end'], true)) {
+
+ switch ($sub_seek_entry['id']) {
+
case EBML_ID_SEEKID:
- $dummy = 0;
- $seek_entry['target_id'] = $this->readEBMLint($value, $dummy);
- $seek_entry['target_name'] = $this->EBMLidName($seek_entry['target_id']);
+ $seek_entry['target_id'] = self::EBML2Int($sub_seek_entry['data']);
+ $seek_entry['target_name'] = self::EBMLidName($seek_entry['target_id']);
break;
+
case EBML_ID_SEEKPOSITION:
- $seek_entry['target_offset'] = $element_data['offset'] + getid3_lib::BigEndian2Int($value);
+ $seek_entry['target_offset'] = $element_data['offset'] + getid3_lib::BigEndian2Int($sub_seek_entry['data']);
break;
+
default:
- $ThisFileInfo['error'][] = 'Unhandled segment['.__LINE__.'] ('.$id.') at '.$offset;
- break;
- }
+ $this->unhandledElement('seekhead.seek', __LINE__, $sub_seek_entry); }
+ }
+
+ if ($seek_entry['target_id'] != EBML_ID_CLUSTER || !self::$hide_clusters) { // collect clusters only if required
+ $info['matroska']['seek'][] = $seek_entry;
}
- $ThisFileInfo['matroska']['seek'][] = $seek_entry;
- //switch ($seek_entry['target_id']) {
- // case EBML_ID_CLUSTER:
- // // too many cluster seek points, probably not useful
- // break;
- // default:
- // $ThisFileInfo['matroska']['seek'][] = $seek_entry;
- // break;
- //}
break;
+
default:
- $this->warnings[] = 'Unhandled seekhead element['.__LINE__.'] ('.$seek_entry['id'].') at '.$offset;
- break;
+ $this->unhandledElement('seekhead', __LINE__, $seek_entry);
}
- $offset = $seek_end_offset;
}
break;
- case EBML_ID_TRACKS: // information about all tracks in segment
- $ThisFileInfo['matroska']['tracks'] = $element_data;
- while ($offset < $element_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $track_entry = array();
- $track_entry['offset'] = $offset;
- $track_entry['id'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $track_entry['id_name'] = $this->EBMLidName($track_entry['id']);
- $track_entry['length'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $track_entry_endoffset = $offset + $track_entry['length'];
+ case EBML_ID_TRACKS: // A top-level block of information with many tracks described.
+ $info['matroska']['tracks'] = $element_data;
+
+ while ($this->getEBMLelement($track_entry, $element_data['end'])) {
switch ($track_entry['id']) {
+
case EBML_ID_TRACKENTRY: //subelements: Describes a track with all elements.
- while ($offset < $track_entry_endoffset) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $subelement_offset = $offset;
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_idname = $this->EBMLidName($subelement_id);
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_end = $offset + $subelement_length;
- switch ($subelement_id) {
+
+ while ($this->getEBMLelement($subelement, $track_entry['end'], array(EBML_ID_VIDEO, EBML_ID_AUDIO, EBML_ID_CONTENTENCODINGS))) {
+ switch ($subelement['id']) {
+
case EBML_ID_TRACKNUMBER:
case EBML_ID_TRACKUID:
case EBML_ID_TRACKTYPE:
@@ -382,33 +574,37 @@ class getid3_matroska
case EBML_ID_MAXCACHE:
case EBML_ID_MAXBLOCKADDITIONID:
case EBML_ID_DEFAULTDURATION: // nanoseconds per frame
- $track_entry[$subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
+ $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
break;
+
case EBML_ID_TRACKTIMECODESCALE:
- $track_entry[$subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
+ $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Float($subelement['data']);
break;
+
case EBML_ID_CODECID:
case EBML_ID_LANGUAGE:
case EBML_ID_NAME:
+ case EBML_ID_CODECNAME:
+ $track_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
+ break;
+
case EBML_ID_CODECPRIVATE:
- $track_entry[$subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length), "\x00");
+ $track_entry[$subelement['id_name']] = $subelement['data'];
break;
+
case EBML_ID_FLAGENABLED:
case EBML_ID_FLAGDEFAULT:
case EBML_ID_FLAGFORCED:
case EBML_ID_FLAGLACING:
case EBML_ID_CODECDECODEALL:
- $track_entry[$subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
+ $track_entry[$subelement['id_name']] = (bool) getid3_lib::BigEndian2Int($subelement['data']);
break;
+
case EBML_ID_VIDEO:
- while ($offset < $subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_offset = $offset;
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_end = $offset + $sub_subelement_length;
- switch ($sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
+ switch ($sub_subelement['id']) {
+
case EBML_ID_PIXELWIDTH:
case EBML_ID_PIXELHEIGHT:
case EBML_ID_STEREOMODE:
@@ -420,1005 +616,767 @@ class getid3_matroska
case EBML_ID_DISPLAYHEIGHT:
case EBML_ID_DISPLAYUNIT:
case EBML_ID_ASPECTRATIOTYPE:
- $track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
+
case EBML_ID_FLAGINTERLACED:
- $track_entry[$sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $track_entry[$sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
+
case EBML_ID_GAMMAVALUE:
- $track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Float($sub_subelement['data']);
break;
+
case EBML_ID_COLOURSPACE:
- $track_entry[$sub_subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), "\x00");
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
break;
- default:
- $this->warnings[] = 'Unhandled track.video element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
- break;
- }
- $offset = $sub_subelement_end;
- }
- if ((@$track_entry[$this->EBMLidName(EBML_ID_CODECID)] == 'V_MS/VFW/FOURCC') && isset($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)])) {
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) {
- $track_entry['codec_private_parsed'] = getid3_riff::ParseBITMAPINFOHEADER($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)]);
- } else {
- $this->warnings[] = 'Unable to parse codec private data['.__LINE__.'] because cannot include "module.audio-video.riff.php"';
+ default:
+ $this->unhandledElement('track.video', __LINE__, $sub_subelement);
}
}
break;
+
case EBML_ID_AUDIO:
- while ($offset < $subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_offset = $offset;
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_end = $offset + $sub_subelement_length;
- switch ($sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
+ switch ($sub_subelement['id']) {
+
case EBML_ID_CHANNELS:
case EBML_ID_BITDEPTH:
- $track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
+
case EBML_ID_SAMPLINGFREQUENCY:
case EBML_ID_OUTPUTSAMPLINGFREQUENCY:
- $track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Float($sub_subelement['data']);
break;
+
case EBML_ID_CHANNELPOSITIONS:
- $track_entry[$sub_subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), "\x00");
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
break;
+
default:
- $this->warnings[] = 'Unhandled track.video element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
- break;
+ $this->unhandledElement('track.audio', __LINE__, $sub_subelement);
}
- $offset = $sub_subelement_end;
}
break;
case EBML_ID_CONTENTENCODINGS:
- while ($offset < $subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_offset = $offset;
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_end = $offset + $sub_subelement_length;
- switch ($sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'])) {
+ switch ($sub_subelement['id']) {
+
case EBML_ID_CONTENTENCODING:
- while ($offset < $sub_subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_offset = $offset;
- $sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
- $sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_end = $offset + $sub_sub_subelement_length;
- switch ($sub_sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], array(EBML_ID_CONTENTCOMPRESSION, EBML_ID_CONTENTENCRYPTION))) {
+ switch ($sub_sub_subelement['id']) {
+
case EBML_ID_CONTENTENCODINGORDER:
case EBML_ID_CONTENTENCODINGSCOPE:
case EBML_ID_CONTENTENCODINGTYPE:
- $track_entry[$sub_subelement_idname][$sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
+ $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
break;
+
case EBML_ID_CONTENTCOMPRESSION:
- while ($offset < $sub_sub_subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_offset = $offset;
- $sub_sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
- $sub_sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_end = $offset + $sub_sub_sub_subelement_length;
- switch ($sub_sub_sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
+ switch ($sub_sub_sub_subelement['id']) {
+
case EBML_ID_CONTENTCOMPALGO:
- $track_entry[$sub_subelement_idname][$sub_sub_subelement_idname][$sub_sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length));
+ $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']);
break;
+
case EBML_ID_CONTENTCOMPSETTINGS:
- $track_entry[$sub_subelement_idname][$sub_sub_subelement_idname][$sub_sub_sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length);
+ $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data'];
break;
+
default:
- $this->warnings[] = 'Unhandled track.contentencodings.contentencoding.contentcompression element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
- break;
+ $this->unhandledElement('track.contentencodings.contentencoding.contentcompression', __LINE__, $sub_sub_sub_subelement);
}
- $offset = $sub_sub_sub_subelement_end;
}
break;
case EBML_ID_CONTENTENCRYPTION:
- while ($offset < $sub_sub_subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_offset = $offset;
- $sub_sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
- $sub_sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_end = $offset + $sub_sub_sub_subelement_length;
- switch ($sub_sub_sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
+ switch ($sub_sub_sub_subelement['id']) {
+
case EBML_ID_CONTENTENCALGO:
case EBML_ID_CONTENTSIGALGO:
case EBML_ID_CONTENTSIGHASHALGO:
- $track_entry[$sub_subelement_idname][$sub_sub_subelement_idname][$sub_sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length));
+ $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']);
break;
+
case EBML_ID_CONTENTENCKEYID:
case EBML_ID_CONTENTSIGNATURE:
case EBML_ID_CONTENTSIGKEYID:
- $track_entry[$sub_subelement_idname][$sub_sub_subelement_idname][$sub_sub_sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length);
+ $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data'];
break;
+
default:
- $this->warnings[] = 'Unhandled track.contentencodings.contentencoding.contentcompression element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
- break;
+ $this->unhandledElement('track.contentencodings.contentencoding.contentcompression', __LINE__, $sub_sub_sub_subelement);
}
- $offset = $sub_sub_sub_subelement_end;
}
break;
default:
- $this->warnings[] = 'Unhandled track.contentencodings.contentencoding element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
- break;
+ $this->unhandledElement('track.contentencodings.contentencoding', __LINE__, $sub_sub_subelement);
}
- $offset = $sub_sub_subelement_end;
}
break;
+
default:
- $this->warnings[] = 'Unhandled track.contentencodings element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
- break;
+ $this->unhandledElement('track.contentencodings', __LINE__, $sub_subelement);
}
- $offset = $sub_subelement_end;
}
break;
default:
- $this->warnings[] = 'Unhandled track element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
- break;
+ $this->unhandledElement('track', __LINE__, $subelement);
}
- $offset = $subelement_end;
}
+
+ $info['matroska']['tracks']['tracks'][] = $track_entry;
break;
+
default:
- $this->warnings[] = 'Unhandled track element['.__LINE__.'] ('.$track_entry['id'].'::'.$track_entry['id_name'].') at '.$track_entry['offset'];
- $offset = $track_entry_endoffset;
- break;
+ $this->unhandledElement('tracks', __LINE__, $track_entry);
}
- $ThisFileInfo['matroska']['tracks']['tracks'][] = $track_entry;
}
break;
- case EBML_ID_INFO: // Contains the position of other level 1 elements
+ case EBML_ID_INFO: // Contains miscellaneous general information and statistics on the file.
$info_entry = array();
- while ($offset < $element_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $subelement_offset = $offset;
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_idname = $this->EBMLidName($subelement_id);
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_end = $offset + $subelement_length;
- switch ($subelement_id) {
+
+ while ($this->getEBMLelement($subelement, $element_data['end'], true)) {
+ switch ($subelement['id']) {
+
case EBML_ID_CHAPTERTRANSLATEEDITIONUID:
case EBML_ID_CHAPTERTRANSLATECODEC:
case EBML_ID_TIMECODESCALE:
- $info_entry[$subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
+ $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
break;
+
case EBML_ID_DURATION:
- $info_entry[$subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
+ $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Float($subelement['data']);
break;
+
case EBML_ID_DATEUTC:
- $info_entry[$subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
- $info_entry[$subelement_idname.'_unix'] = $this->EBMLdate2unix($info_entry[$subelement_idname]);
+ $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
+ $info_entry[$subelement['id_name'].'_unix'] = self::EBMLdate2unix($info_entry[$subelement['id_name']]);
break;
+
case EBML_ID_SEGMENTUID:
case EBML_ID_PREVUID:
case EBML_ID_NEXTUID:
case EBML_ID_SEGMENTFAMILY:
case EBML_ID_CHAPTERTRANSLATEID:
- $info_entry[$subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length), "\x00");
+ $info_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
break;
+
case EBML_ID_SEGMENTFILENAME:
case EBML_ID_PREVFILENAME:
case EBML_ID_NEXTFILENAME:
case EBML_ID_TITLE:
case EBML_ID_MUXINGAPP:
case EBML_ID_WRITINGAPP:
- $info_entry[$subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length), "\x00");
+ $info_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
+ $info['matroska']['comments'][strtolower($subelement['id_name'])][] = $info_entry[$subelement['id_name']];
break;
+
default:
- $this->warnings[] = 'Unhandled info element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
- break;
+ $this->unhandledElement('info', __LINE__, $subelement);
}
- $offset = $subelement_end;
}
- $ThisFileInfo['matroska']['info'][] = $info_entry;
+ $info['matroska']['info'][] = $info_entry;
break;
- case EBML_ID_CUES:
+ case EBML_ID_CUES: // A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non "live" streams.
+ if (self::$hide_clusters) { // do not parse cues if hide clusters is "ON" till they point to clusters anyway
+ $this->current_offset = $element_data['end'];
+ break;
+ }
$cues_entry = array();
- while ($offset < $element_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $subelement_offset = $offset;
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_idname = $this->EBMLidName($subelement_id);
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_end = $offset + $subelement_length;
- switch ($subelement_id) {
+
+ while ($this->getEBMLelement($subelement, $element_data['end'])) {
+ switch ($subelement['id']) {
+
case EBML_ID_CUEPOINT:
$cuepoint_entry = array();
- while ($offset < $subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_offset = $offset;
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_end = $offset + $sub_subelement_length;
- switch ($sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CUETRACKPOSITIONS))) {
+ switch ($sub_subelement['id']) {
+
case EBML_ID_CUETRACKPOSITIONS:
- while ($offset < $sub_subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_offset = $offset;
- $sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
- $sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_end = $offset + $sub_sub_subelement_length;
- switch ($sub_sub_subelement_id) {
+ $cuetrackpositions_entry = array();
+
+ while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], true)) {
+ switch ($sub_sub_subelement['id']) {
+
case EBML_ID_CUETRACK:
- $cuepoint_entry[$sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
+ case EBML_ID_CUECLUSTERPOSITION:
+ case EBML_ID_CUEBLOCKNUMBER:
+ case EBML_ID_CUECODECSTATE:
+ $cuetrackpositions_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
break;
+
default:
- $this->warnings[] = 'Unhandled cues.cuepoint.cuetrackpositions element['.__LINE__.'] ('.$sub_sub_subelement_id.'::'.$sub_sub_subelement_idname.') at '.$sub_sub_subelement_offset;
- break;
+ $this->unhandledElement('cues.cuepoint.cuetrackpositions', __LINE__, $sub_sub_subelement);
}
- $offset = $sub_subelement_end;
}
+ $cuepoint_entry[$sub_subelement['id_name']][] = $cuetrackpositions_entry;
break;
+
case EBML_ID_CUETIME:
- $cuepoint_entry[$subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $cuepoint_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
+
default:
- $this->warnings[] = 'Unhandled cues.cuepoint element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
- break;
+ $this->unhandledElement('cues.cuepoint', __LINE__, $sub_subelement);
}
- $offset = $sub_subelement_end;
}
$cues_entry[] = $cuepoint_entry;
- $offset = $sub_subelement_end;
break;
+
default:
- $this->warnings[] = 'Unhandled cues element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
- break;
+ $this->unhandledElement('cues', __LINE__, $subelement);
}
- $offset = $subelement_end;
}
- $ThisFileInfo['matroska']['cues'] = $cues_entry;
+ $info['matroska']['cues'] = $cues_entry;
break;
- case EBML_ID_TAGS:
- $tags_entry = array();
- while ($offset < $element_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $subelement_offset = $offset;
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_idname = $this->EBMLidName($subelement_id);
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_end = $offset + $subelement_length;
- switch ($subelement_id) {
- case EBML_ID_WRITINGAPP:
- $tags_entry[$subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length);
- break;
+ case EBML_ID_TAGS: // Element containing elements specific to Tracks/Chapters.
+ $tags_entry = array();
+
+ while ($this->getEBMLelement($subelement, $element_data['end'], false)) {
+ switch ($subelement['id']) {
+
case EBML_ID_TAG:
$tag_entry = array();
- while ($offset < $subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_offset = $offset;
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_end = $offset + $sub_subelement_length;
- switch ($sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], false)) {
+ switch ($sub_subelement['id']) {
+
case EBML_ID_TARGETS:
$targets_entry = array();
- while ($offset < $sub_subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_offset = $offset;
- $sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
- $sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_end = $offset + $sub_sub_subelement_length;
- switch ($sub_sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], true)) {
+ switch ($sub_sub_subelement['id']) {
+
case EBML_ID_TARGETTYPEVALUE:
- case EBML_ID_EDITIONUID:
- case EBML_ID_CHAPTERUID:
- case EBML_ID_ATTACHMENTUID:
- case EBML_ID_TAGTRACKUID:
- case EBML_ID_TAGCHAPTERUID:
- $targets_entry[$sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
+ $targets_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
+ $targets_entry[strtolower($sub_sub_subelement['id_name']).'_long'] = self::MatroskaTargetTypeValue($targets_entry[$sub_sub_subelement['id_name']]);
break;
- default:
- $this->warnings[] = 'Unhandled tag.targets element['.__LINE__.'] ('.$sub_sub_subelement_id.'::'.$sub_sub_subelement_idname.') at '.$sub_sub_subelement_offset;
- break;
- }
- $offset = $sub_sub_subelement_end;
- }
- $tag_entry[$sub_subelement_idname][] = $targets_entry;
- break;
- case EBML_ID_SIMPLETAG:
- $simpletag_entry = array();
- while ($offset < $sub_subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_offset = $offset;
- $sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
- $sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_end = $offset + $sub_sub_subelement_length;
- switch ($sub_sub_subelement_id) {
- case EBML_ID_TAGNAME:
- case EBML_ID_TAGLANGUAGE:
- case EBML_ID_TAGSTRING:
- case EBML_ID_TAGBINARY:
- $simpletag_entry[$sub_sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length);
+
+ case EBML_ID_TARGETTYPE:
+ $targets_entry[$sub_sub_subelement['id_name']] = $sub_sub_subelement['data'];
break;
- case EBML_ID_TAGDEFAULT:
- $simpletag_entry[$sub_sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
+
+ case EBML_ID_TAGTRACKUID:
+ case EBML_ID_TAGEDITIONUID:
+ case EBML_ID_TAGCHAPTERUID:
+ case EBML_ID_TAGATTACHMENTUID:
+ $targets_entry[$sub_sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
break;
+
default:
- $this->warnings[] = 'Unhandled tag.simpletag element['.__LINE__.'] ('.$sub_sub_subelement_id.'::'.$sub_sub_subelement_idname.') at '.$sub_sub_subelement_offset;
- break;
+ $this->unhandledElement('tags.tag.targets', __LINE__, $sub_sub_subelement);
}
- $offset = $sub_sub_subelement_end;
}
- $tag_entry[$sub_subelement_idname][] = $simpletag_entry;
+ $tag_entry[$sub_subelement['id_name']] = $targets_entry;
break;
- case EBML_ID_TARGETTYPE:
- $tag_entry[$sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length);
- break;
- case EBML_ID_TRACKUID:
- $tag_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+
+ case EBML_ID_SIMPLETAG:
+ $tag_entry[$sub_subelement['id_name']][] = $this->HandleEMBLSimpleTag($sub_subelement['end']);
break;
+
default:
- $this->warnings[] = 'Unhandled tags.tag element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
- break;
+ $this->unhandledElement('tags.tag', __LINE__, $sub_subelement);
}
- $offset = $sub_subelement_end;
}
- $tags_entry['tags'][] = $tag_entry;
- $offset = $sub_subelement_end;
+ $tags_entry[] = $tag_entry;
break;
+
default:
- $this->warnings[] = 'Unhandled tags element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
- break;
+ $this->unhandledElement('tags', __LINE__, $subelement);
}
- $offset = $subelement_end;
}
- $ThisFileInfo['matroska']['tags'] = $tags_entry;
+ $info['matroska']['tags'] = $tags_entry;
break;
+ case EBML_ID_ATTACHMENTS: // Contain attached files.
+
+ while ($this->getEBMLelement($subelement, $element_data['end'])) {
+ switch ($subelement['id']) {
- case EBML_ID_ATTACHMENTS:
- while ($offset < $element_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $subelement_offset = $offset;
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_idname = $this->EBMLidName($subelement_id);
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_end = $offset + $subelement_length;
- switch ($subelement_id) {
case EBML_ID_ATTACHEDFILE:
$attachedfile_entry = array();
- while ($offset < $subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_offset = $offset;
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_end = $offset + $sub_subelement_length;
- switch ($sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_FILEDATA))) {
+ switch ($sub_subelement['id']) {
+
case EBML_ID_FILEDESCRIPTION:
case EBML_ID_FILENAME:
case EBML_ID_FILEMIMETYPE:
- $attachedfile_entry[$sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length);
+ $attachedfile_entry[$sub_subelement['id_name']] = $sub_subelement['data'];
break;
case EBML_ID_FILEDATA:
- $attachedfile_entry['data_offset'] = $offset;
- $attachedfile_entry['data_length'] = $sub_subelement_length;
- if ($sub_subelement_length < 1024) {
- $attachedfile_entry[$sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length);
+ $attachedfile_entry['data_offset'] = $this->current_offset;
+ $attachedfile_entry['data_length'] = $sub_subelement['length'];
+
+ $this->getid3->saveAttachment(
+ $attachedfile_entry[$sub_subelement['id_name']],
+ $attachedfile_entry['FileName'],
+ $attachedfile_entry['data_offset'],
+ $attachedfile_entry['data_length']);
+
+ if (@$attachedfile_entry[$sub_subelement['id_name']] && is_file($attachedfile_entry[$sub_subelement['id_name']])) {
+ $attachedfile_entry[$sub_subelement['id_name'].'_filename'] = $attachedfile_entry[$sub_subelement['id_name']];
+ unset($attachedfile_entry[$sub_subelement['id_name']]);
}
+
+ $this->current_offset = $sub_subelement['end'];
break;
case EBML_ID_FILEUID:
- $attachedfile_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $attachedfile_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
default:
- $this->warnings[] = 'Unhandled attachment.attachedfile element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
- break;
+ $this->unhandledElement('attachments.attachedfile', __LINE__, $sub_subelement);
}
- $offset = $sub_subelement_end;
}
- $ThisFileInfo['matroska']['attachments'][] = $attachedfile_entry;
- $offset = $sub_subelement_end;
+ if (!empty($attachedfile_entry['FileData']) && !empty($attachedfile_entry['FileMimeType']) && preg_match('#^image/#i', $attachedfile_entry['FileMimeType'])) {
+ if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
+ $attachedfile_entry['data'] = $attachedfile_entry['FileData'];
+ $attachedfile_entry['image_mime'] = $attachedfile_entry['FileMimeType'];
+ $info['matroska']['comments']['picture'][] = array('data' => $attachedfile_entry['data'], 'image_mime' => $attachedfile_entry['image_mime'], 'filename' => (!empty($attachedfile_entry['FileName']) ? $attachedfile_entry['FileName'] : ''));
+ unset($attachedfile_entry['FileData'], $attachedfile_entry['FileMimeType']);
+ }
+ }
+ if (!empty($attachedfile_entry['image_mime']) && preg_match('#^image/#i', $attachedfile_entry['image_mime'])) {
+ // don't add a second copy of attached images, which are grouped under the standard location [comments][picture]
+ } else {
+ $info['matroska']['attachments'][] = $attachedfile_entry;
+ }
break;
+
default:
- $this->warnings[] = 'Unhandled tags element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
- break;
+ $this->unhandledElement('attachments', __LINE__, $subelement);
}
- $offset = $subelement_end;
}
break;
+ case EBML_ID_CHAPTERS:
+
+ while ($this->getEBMLelement($subelement, $element_data['end'])) {
+ switch ($subelement['id']) {
- case EBML_ID_CHAPTERS: // not important to us, contains mostly actual audio/video data, ignore
- while ($offset < $element_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $subelement_offset = $offset;
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_idname = $this->EBMLidName($subelement_id);
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $subelement_end = $offset + $subelement_length;
- switch ($subelement_id) {
case EBML_ID_EDITIONENTRY:
$editionentry_entry = array();
- while ($offset < $subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_offset = $offset;
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_end = $offset + $sub_subelement_length;
- switch ($sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CHAPTERATOM))) {
+ switch ($sub_subelement['id']) {
+
case EBML_ID_EDITIONUID:
- $editionentry_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $editionentry_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
+
case EBML_ID_EDITIONFLAGHIDDEN:
case EBML_ID_EDITIONFLAGDEFAULT:
case EBML_ID_EDITIONFLAGORDERED:
- $editionentry_entry[$sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $editionentry_entry[$sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
+
case EBML_ID_CHAPTERATOM:
$chapteratom_entry = array();
- while ($offset < $sub_subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_offset = $offset;
- $sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
- $sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_subelement_end = $offset + $sub_sub_subelement_length;
- switch ($sub_sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], array(EBML_ID_CHAPTERTRACK, EBML_ID_CHAPTERDISPLAY))) {
+ switch ($sub_sub_subelement['id']) {
+
case EBML_ID_CHAPTERSEGMENTUID:
case EBML_ID_CHAPTERSEGMENTEDITIONUID:
- $chapteratom_entry[$sub_sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length);
+ $chapteratom_entry[$sub_sub_subelement['id_name']] = $sub_sub_subelement['data'];
break;
+
case EBML_ID_CHAPTERFLAGENABLED:
case EBML_ID_CHAPTERFLAGHIDDEN:
- $chapteratom_entry[$sub_sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
+ $chapteratom_entry[$sub_sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
break;
+
case EBML_ID_CHAPTERUID:
case EBML_ID_CHAPTERTIMESTART:
case EBML_ID_CHAPTERTIMEEND:
- $chapteratom_entry[$sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
+ $chapteratom_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
break;
+
case EBML_ID_CHAPTERTRACK:
$chaptertrack_entry = array();
- while ($offset < $sub_sub_subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_offset = $offset;
- $sub_sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
- $sub_sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_end = $offset + $sub_sub_sub_subelement_length;
- switch ($sub_sub_sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
+ switch ($sub_sub_sub_subelement['id']) {
+
case EBML_ID_CHAPTERTRACKNUMBER:
- $chaptertrack_entry[$sub_sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length));
+ $chaptertrack_entry[$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']);
break;
+
default:
- $this->warnings[] = 'Unhandled chapters.editionentry.chapteratom.chaptertrack element['.__LINE__.'] ('.$sub_sub_sub_subelement_id.'::'.$sub_sub_sub_subelement_idname.') at '.$sub_sub_sub_subelement_offset;
- break;
+ $this->unhandledElement('chapters.editionentry.chapteratom.chaptertrack', __LINE__, $sub_sub_sub_subelement);
}
- $offset = $sub_sub_sub_subelement_end;
}
- $chapteratom_entry[$sub_sub_subelement_idname][] = $chaptertrack_entry;
+ $chapteratom_entry[$sub_sub_subelement['id_name']][] = $chaptertrack_entry;
break;
+
case EBML_ID_CHAPTERDISPLAY:
$chapterdisplay_entry = array();
- while ($offset < $sub_sub_subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_offset = $offset;
- $sub_sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_idname = $this->EBMLidName($sub_sub_sub_subelement_id);
- $sub_sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_sub_sub_subelement_end = $offset + $sub_sub_sub_subelement_length;
- switch ($sub_sub_sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
+ switch ($sub_sub_sub_subelement['id']) {
+
case EBML_ID_CHAPSTRING:
case EBML_ID_CHAPLANGUAGE:
case EBML_ID_CHAPCOUNTRY:
- $chapterdisplay_entry[$sub_sub_sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length);
+ $chapterdisplay_entry[$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data'];
break;
+
default:
- $this->warnings[] = 'Unhandled chapters.editionentry.chapteratom.chapterdisplay element['.__LINE__.'] ('.$sub_sub_sub_subelement_id.'::'.$sub_sub_sub_subelement_idname.') at '.$sub_sub_sub_subelement_offset;
- break;
+ $this->unhandledElement('chapters.editionentry.chapteratom.chapterdisplay', __LINE__, $sub_sub_sub_subelement);
}
- $offset = $sub_sub_sub_subelement_end;
}
- $chapteratom_entry[$sub_sub_subelement_idname][] = $chapterdisplay_entry;
+ $chapteratom_entry[$sub_sub_subelement['id_name']][] = $chapterdisplay_entry;
break;
+
default:
- $this->warnings[] = 'Unhandled chapters.editionentry.chapteratom element['.__LINE__.'] ('.$sub_sub_subelement_id.'::'.$sub_sub_subelement_idname.') at '.$sub_sub_subelement_offset;
- break;
+ $this->unhandledElement('chapters.editionentry.chapteratom', __LINE__, $sub_sub_subelement);
}
- $offset = $sub_sub_subelement_end;
}
- $editionentry_entry[$sub_subelement_idname][] = $chapteratom_entry;
+ $editionentry_entry[$sub_subelement['id_name']][] = $chapteratom_entry;
break;
+
default:
- $this->warnings[] = 'Unhandled chapters.editionentry element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
- break;
+ $this->unhandledElement('chapters.editionentry', __LINE__, $sub_subelement);
}
- $offset = $sub_subelement_end;
}
- $ThisFileInfo['matroska']['chapters'][] = $editionentry_entry;
- $offset = $sub_subelement_end;
+ $info['matroska']['chapters'][] = $editionentry_entry;
break;
+
default:
- $this->warnings[] = 'Unhandled chapters element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
- break;
+ $this->unhandledElement('chapters', __LINE__, $subelement);
}
- $offset = $subelement_end;
}
break;
+ case EBML_ID_CLUSTER: // The lower level element containing the (monolithic) Block structure.
+ $cluster_entry = array();
- case EBML_ID_VOID: // padding, ignore
- $void_entry = array();
- $void_entry['offset'] = $offset;
- $ThisFileInfo['matroska']['void'][] = $void_entry;
- break;
+ while ($this->getEBMLelement($subelement, $element_data['end'], array(EBML_ID_CLUSTERSILENTTRACKS, EBML_ID_CLUSTERBLOCKGROUP, EBML_ID_CLUSTERSIMPLEBLOCK))) {
+ switch ($subelement['id']) {
- case EBML_ID_CLUSTER: // not important to us, contains mostly actual audio/video data, ignore
- $cluster_entry = array();
- while ($offset < $element_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $subelement_offset = $offset;
-//var_dump($offset);
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
-//var_dump($subelement_id);
-//echo '<br>';
- $subelement_idname = $this->EBMLidName($subelement_id);
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
-//var_dump($subelement_length);
- $subelement_end = $offset + $subelement_length;
-//exit;
- switch ($subelement_id) {
case EBML_ID_CLUSTERTIMECODE:
case EBML_ID_CLUSTERPOSITION:
case EBML_ID_CLUSTERPREVSIZE:
- $cluster_entry[$subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
+ $cluster_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
break;
case EBML_ID_CLUSTERSILENTTRACKS:
$cluster_silent_tracks = array();
- while ($offset < $subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_offset = $offset;
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_end = $offset + $sub_subelement_length;
- switch ($sub_subelement_id) {
+
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
+ switch ($sub_subelement['id']) {
+
case EBML_ID_CLUSTERSILENTTRACKNUMBER:
- $cluster_silent_tracks[] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $cluster_silent_tracks[] = getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
+
default:
- $this->warnings[] = 'Unhandled clusters.silenttracks element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
- break;
+ $this->unhandledElement('cluster.silenttracks', __LINE__, $sub_subelement);
}
- $offset = $sub_subelement_end;
}
- $cluster_entry[$subelement_idname][] = $cluster_silent_tracks;
- $offset = $sub_subelement_end;
+ $cluster_entry[$subelement['id_name']][] = $cluster_silent_tracks;
break;
case EBML_ID_CLUSTERBLOCKGROUP:
- $cluster_block_group = array('offset'=>$offset);
- while ($offset < $subelement_end) {
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_offset = $offset;
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $sub_subelement_end = $offset + $sub_subelement_length;
- switch ($sub_subelement_id) {
+ $cluster_block_group = array('offset' => $this->current_offset);
+
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CLUSTERBLOCK))) {
+ switch ($sub_subelement['id']) {
+
case EBML_ID_CLUSTERBLOCK:
- $cluster_block_data = array();
- $cluster_block_data['tracknumber'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
- $cluster_block_data['timecode'] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset, 2));
- $offset += 2;
- // unsure whether this is 1 octect or 2 octets? (http://matroska.org/technical/specs/index.html#block_structure)
- $cluster_block_data['flags_raw'] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset, 1));
- $offset += 1;
- //$cluster_block_data['flags']['reserved1'] = (($cluster_block_data['flags_raw'] & 0xF0) >> 4);
- $cluster_block_data['flags']['invisible'] = (bool) (($cluster_block_data['flags_raw'] & 0x08) >> 3);
- $cluster_block_data['flags']['lacing'] = (($cluster_block_data['flags_raw'] & 0x06) >> 1);
- //$cluster_block_data['flags']['reserved2'] = (($cluster_block_data['flags_raw'] & 0x01) >> 0);
- $cluster_block_data['flags']['lacing_type'] = $this->MatroskaBlockLacingType($cluster_block_data['flags']['lacing']);
- if ($cluster_block_data['flags']['lacing'] != 0) {
- $cluster_block_data['lace_frames'] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset, 1)); // Number of frames in the lace-1 (uint8)
- $offset += 1;
- if ($cluster_block_data['flags']['lacing'] != 2) {
- $cluster_block_data['lace_frames'] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset, 1)); // Lace-coded size of each frame of the lace, except for the last one (multiple uint8). *This is not used with Fixed-size lacing as it is calculated automatically from (total size of lace) / (number of frames in lace).
- $offset += 1;
- }
- }
- if (!isset($ThisFileInfo['matroska']['track_data_offsets'][$cluster_block_data['tracknumber']])) {
- $ThisFileInfo['matroska']['track_data_offsets'][$cluster_block_data['tracknumber']] = $offset;
- }
- $cluster_block_group[$sub_subelement_idname] = $cluster_block_data;
+ $cluster_block_group[$sub_subelement['id_name']] = $this->HandleEMBLClusterBlock($sub_subelement, EBML_ID_CLUSTERBLOCK, $info);
break;
case EBML_ID_CLUSTERREFERENCEPRIORITY: // unsigned-int
case EBML_ID_CLUSTERBLOCKDURATION: // unsigned-int
- $cluster_block_group[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
+ $cluster_block_group[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
case EBML_ID_CLUSTERREFERENCEBLOCK: // signed-int
- $cluster_block_group[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), false, true);
+ $cluster_block_group[$sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_subelement['data'], false, true);
+ break;
+
+ case EBML_ID_CLUSTERCODECSTATE:
+ $cluster_block_group[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
break;
default:
- $this->warnings[] = 'Unhandled clusters.blockgroup element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
- break;
+ $this->unhandledElement('clusters.blockgroup', __LINE__, $sub_subelement);
}
- $offset = $sub_subelement_end;
}
- $cluster_entry[$subelement_idname][] = $cluster_block_group;
- $offset = $sub_subelement_end;
+ $cluster_entry[$subelement['id_name']][] = $cluster_block_group;
break;
- default:
- $this->warnings[] = 'Unhandled cluster element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
+ case EBML_ID_CLUSTERSIMPLEBLOCK:
+ $cluster_entry[$subelement['id_name']][] = $this->HandleEMBLClusterBlock($subelement, EBML_ID_CLUSTERSIMPLEBLOCK, $info);
break;
+
+ default:
+ $this->unhandledElement('cluster', __LINE__, $subelement);
}
- $offset = $subelement_end;
+ $this->current_offset = $subelement['end'];
+ }
+ if (!self::$hide_clusters) {
+ $info['matroska']['cluster'][] = $cluster_entry;
}
- $ThisFileInfo['matroska']['cluster'][] = $cluster_entry;
// check to see if all the data we need exists already, if so, break out of the loop
- if (isset($ThisFileInfo['matroska']['info']) && is_array($ThisFileInfo['matroska']['info'])) {
- if (isset($ThisFileInfo['matroska']['tracks']['tracks']) && is_array($ThisFileInfo['matroska']['tracks']['tracks'])) {
- break 2;
+ if (!self::$parse_whole_file) {
+ if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
+ if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
+ return;
+ }
}
}
break;
default:
- if ($element_data['id_name'] == dechex($element_data['id'])) {
- $ThisFileInfo['error'][] = 'Unhandled segment['.__LINE__.'] ('.$element_data['id'].') at '.$element_data_offset;
- } else {
- $this->warnings[] = 'Unhandled segment['.__LINE__.'] ('.$element_data['id'].'::'.$element_data['id_name'].') at '.$element_data['offset'];
- }
- break;
+ $this->unhandledElement('segment', __LINE__, $element_data);
}
- $offset = $element_end;
}
break;
-
default:
- $ThisFileInfo['error'][] = 'Unhandled chunk['.__LINE__.'] ('.$top_element_id.') at '.$offset;
- break;
+ $this->unhandledElement('root', __LINE__, $top_element);
}
- $offset = $top_element_endoffset;
}
+ }
+ private function EnsureBufferHasEnoughData($min_data = 1024)
+ {
+ if (($this->current_offset - $this->EBMLbuffer_offset) >= ($this->EBMLbuffer_length - $min_data)) {
+ if (!getid3_lib::intValueSupported($this->current_offset + $this->getid3->fread_buffer_size())) {
+ $this->getid3->info['error'][] = 'EBML parser: cannot read past '.$this->current_offset;
+ return false;
+ }
- if (isset($ThisFileInfo['matroska']['info']) && is_array($ThisFileInfo['matroska']['info'])) {
- foreach ($ThisFileInfo['matroska']['info'] as $key => $infoarray) {
- if (isset($infoarray['Duration'])) {
- // TimecodeScale is how many nanoseconds each Duration unit is
- $ThisFileInfo['playtime_seconds'] = $infoarray['Duration'] * ((isset($infoarray['TimecodeScale']) ? $infoarray['TimecodeScale'] : 1000000) / 1000000000);
- break;
- }
+ fseek($this->getid3->fp, $this->current_offset, SEEK_SET);
+ $this->EBMLbuffer_offset = $this->current_offset;
+ $this->EBMLbuffer = fread($this->getid3->fp, max($min_data, $this->getid3->fread_buffer_size()));
+ $this->EBMLbuffer_length = strlen($this->EBMLbuffer);
+
+ if ($this->EBMLbuffer_length == 0 && feof($this->getid3->fp)) {
+ $this->getid3->info['error'][] = 'EBML parser: ran out of file at offset '.$this->current_offset;
+ return false;
}
}
- if (isset($ThisFileInfo['matroska']['tracks']['tracks']) && is_array($ThisFileInfo['matroska']['tracks']['tracks'])) {
- foreach ($ThisFileInfo['matroska']['tracks']['tracks'] as $key => $trackarray) {
- $track_info = array();
- switch (@$trackarray['TrackType']) {
- case 1: // Video
- if (@$trackarray['PixelWidth']) { $track_info['resolution_x'] = $trackarray['PixelWidth']; }
- if (@$trackarray['PixelHeight']) { $track_info['resolution_y'] = $trackarray['PixelHeight']; }
- if (@$trackarray['DisplayWidth']) { $track_info['display_x'] = $trackarray['DisplayWidth']; }
- if (@$trackarray['DisplayHeight']) { $track_info['display_y'] = $trackarray['DisplayHeight']; }
- if (@$trackarray['DefaultDuration']) { $track_info['frame_rate'] = round(1000000000 / $trackarray['DefaultDuration'], 3); }
- if (@$trackarray['CodecID']) { $track_info['dataformat'] = $this->MatroskaCodecIDtoCommonName($trackarray['CodecID']); }
- if (!empty($trackarray['codec_private_parsed']['fourcc'])) {
- $track_info['fourcc'] = $trackarray['codec_private_parsed']['fourcc'];
- }
- $ThisFileInfo['video']['streams'][] = $track_info;
- if (isset($track_info['resolution_x']) && empty($ThisFileInfo['video']['resolution_x'])) {
- foreach ($track_info as $key => $value) {
- $ThisFileInfo['video'][$key] = $value;
- }
- }
- break;
- case 2: // Audio
- if (@$trackarray['CodecID']) { $track_info['dataformat'] = $this->MatroskaCodecIDtoCommonName($trackarray['CodecID']); }
- if (@$trackarray['SamplingFrequency']) { $track_info['sample_rate'] = $trackarray['SamplingFrequency']; }
- if (@$trackarray['Channels']) { $track_info['channels'] = $trackarray['Channels']; }
- if (@$trackarray['BitDepth']) { $track_info['bits_per_sample'] = $trackarray['BitDepth']; }
- switch (@$trackarray[$this->EBMLidName(EBML_ID_CODECID)]) {
- case 'A_PCM/INT/LIT':
- case 'A_PCM/INT/BIG':
- $track_info['bitrate'] = $trackarray['SamplingFrequency'] * $trackarray['Channels'] * $trackarray['BitDepth'];
- break;
- case 'A_AC3':
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
- $ac3_thisfileinfo = array('avdataoffset'=>$ThisFileInfo['matroska']['track_data_offsets'][$trackarray['TrackNumber']]);
- $getid3_ac3 = new getid3_ac3($fd, $ac3_thisfileinfo);
- $ThisFileInfo['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $ac3_thisfileinfo;
- if (!empty($ac3_thisfileinfo['error'])) {
- foreach ($ac3_thisfileinfo['error'] as $newerror) {
- $this->warnings[] = 'getid3_ac3() says: ['.$newerror.']';
- }
- }
- if (!empty($ac3_thisfileinfo['warning'])) {
- foreach ($ac3_thisfileinfo['warning'] as $newerror) {
- $this->warnings[] = 'getid3_ac3() says: ['.$newerror.']';
- }
- }
- if (isset($ac3_thisfileinfo['audio']) && is_array($ac3_thisfileinfo['audio'])) {
- foreach ($ac3_thisfileinfo['audio'] as $key => $value) {
- $track_info[$key] = $value;
- }
- }
- unset($ac3_thisfileinfo);
- unset($getid3_ac3);
- } else {
- $this->warnings[] = 'Unable to parse audio data['.__LINE__.'] because cannot include "module.audio.ac3.php"';
- }
- break;
+ return true;
+ }
- case 'A_DTS':
- $dts_offset = $ThisFileInfo['matroska']['track_data_offsets'][$trackarray['TrackNumber']];
- // this is a NASTY hack, but sometimes audio data is off by a byte or two and not sure why, email info@getid3.org if you can explain better
- fseek($fd, $dts_offset, SEEK_SET);
- $magic_test = fread($fd, 8);
- for ($i = 0; $i < 4; $i++) {
- // look to see if DTS "magic" is here, if so adjust offset by that many bytes
- if (substr($magic_test, $i, 4) == "\x7F\xFE\x80\x01") {
- $dts_offset += $i;
- break;
- }
- }
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.dts.php', __FILE__, false)) {
- $dts_thisfileinfo = array('avdataoffset'=>$dts_offset);
- $getid3_dts = new getid3_dts($fd, $dts_thisfileinfo);
- $ThisFileInfo['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $dts_thisfileinfo;
- if (!empty($dts_thisfileinfo['error'])) {
- foreach ($dts_thisfileinfo['error'] as $newerror) {
- $this->warnings[] = 'getid3_dts() says: ['.$newerror.']';
- }
- }
- if (!empty($dts_thisfileinfo['warning'])) {
- foreach ($dts_thisfileinfo['warning'] as $newerror) {
- $this->warnings[] = 'getid3_dts() says: ['.$newerror.']';
- }
- }
- if (isset($dts_thisfileinfo['audio']) && is_array($dts_thisfileinfo['audio'])) {
- foreach ($dts_thisfileinfo['audio'] as $key => $value) {
- $track_info[$key] = $value;
- }
- }
- unset($dts_thisfileinfo);
- unset($getid3_dts);
- } else {
- $this->warnings[] = 'Unable to parse audio data['.__LINE__.'] because cannot include "module.audio.dts.php"';
- }
- break;
+ private function readEBMLint()
+ {
+ $actual_offset = $this->current_offset - $this->EBMLbuffer_offset;
- //case 'A_AAC':
- // if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.aac.php', __FILE__, false)) {
- // $aac_thisfileinfo = array('avdataoffset'=>$ThisFileInfo['matroska']['track_data_offsets'][$trackarray['TrackNumber']]);
- // $getid3_aac = new getid3_aac($fd, $aac_thisfileinfo);
- // $ThisFileInfo['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $aac_thisfileinfo;
- // if (isset($aac_thisfileinfo['audio']) && is_array($aac_thisfileinfo['audio'])) {
- // foreach ($aac_thisfileinfo['audio'] as $key => $value) {
- // $track_info[$key] = $value;
- // }
- // }
- // unset($aac_thisfileinfo);
- // unset($getid3_aac);
- // } else {
- // $this->warnings[] = 'Unable to parse audio data['.__LINE__.'] because cannot include "module.audio.aac.php"';
- // }
- // break;
+ // get length of integer
+ $first_byte_int = ord($this->EBMLbuffer[$actual_offset]);
+ if (0x80 & $first_byte_int) {
+ $length = 1;
+ } elseif (0x40 & $first_byte_int) {
+ $length = 2;
+ } elseif (0x20 & $first_byte_int) {
+ $length = 3;
+ } elseif (0x10 & $first_byte_int) {
+ $length = 4;
+ } elseif (0x08 & $first_byte_int) {
+ $length = 5;
+ } elseif (0x04 & $first_byte_int) {
+ $length = 6;
+ } elseif (0x02 & $first_byte_int) {
+ $length = 7;
+ } elseif (0x01 & $first_byte_int) {
+ $length = 8;
+ } else {
+ throw new Exception('invalid EBML integer (leading 0x00) at '.$this->current_offset);
+ }
- case 'A_MPEG/L3':
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, false)) {
- $mp3_thisfileinfo = array(
- 'avdataoffset' => $ThisFileInfo['matroska']['track_data_offsets'][$trackarray['TrackNumber']],
- 'avdataend' => $ThisFileInfo['matroska']['track_data_offsets'][$trackarray['TrackNumber']] + 1024,
- );
- $getid3_mp3 = new getid3_mp3($fd, $mp3_thisfileinfo);
- $getid3_mp3->allow_bruteforce = true;
- //getid3_mp3::getOnlyMPEGaudioInfo($fd, $mp3_thisfileinfo, $offset, false);
- $ThisFileInfo['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $mp3_thisfileinfo;
- if (!empty($mp3_thisfileinfo['error'])) {
- foreach ($mp3_thisfileinfo['error'] as $newerror) {
- $this->warnings[] = 'getid3_mp3() says: ['.$newerror.']';
- }
- }
- if (!empty($mp3_thisfileinfo['warning'])) {
- foreach ($mp3_thisfileinfo['warning'] as $newerror) {
- $this->warnings[] = 'getid3_mp3() says: ['.$newerror.']';
- }
- }
- if (isset($mp3_thisfileinfo['audio']) && is_array($mp3_thisfileinfo['audio'])) {
- foreach ($mp3_thisfileinfo['audio'] as $key => $value) {
- $track_info[$key] = $value;
- }
- }
- unset($mp3_thisfileinfo);
- unset($getid3_mp3);
- } else {
- $this->warnings[] = 'Unable to parse audio data['.__LINE__.'] because cannot include "module.audio.mp3.php"';
- }
- break;
+ // read
+ $int_value = self::EBML2Int(substr($this->EBMLbuffer, $actual_offset, $length));
+ $this->current_offset += $length;
- case 'A_VORBIS':
- if (isset($trackarray['CodecPrivate'])) {
- // this is a NASTY hack, email info@getid3.org if you have a better idea how to get this info out
- $found_vorbis = false;
- for ($vorbis_offset = 1; $vorbis_offset < 16; $vorbis_offset++) {
- if (substr($trackarray['CodecPrivate'], $vorbis_offset, 6) == 'vorbis') {
- $vorbis_offset--;
- $found_vorbis = true;
- break;
- }
- }
- if ($found_vorbis) {
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, false)) {
- $vorbis_fileinfo = array();
- $oggpageinfo['page_seqno'] = 0;
- getid3_ogg::ParseVorbisPageHeader($trackarray['CodecPrivate'], $vorbis_offset, $vorbis_fileinfo, $oggpageinfo);
- $ThisFileInfo['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $vorbis_fileinfo;
- if (!empty($vorbis_fileinfo['error'])) {
- foreach ($vorbis_fileinfo['error'] as $newerror) {
- $this->warnings[] = 'getid3_ogg() says: ['.$newerror.']';
- }
- }
- if (!empty($vorbis_fileinfo['warning'])) {
- foreach ($vorbis_fileinfo['warning'] as $newerror) {
- $this->warnings[] = 'getid3_ogg() says: ['.$newerror.']';
- }
- }
- if (isset($vorbis_fileinfo['audio']) && is_array($vorbis_fileinfo['audio'])) {
- foreach ($vorbis_fileinfo['audio'] as $key => $value) {
- $track_info[$key] = $value;
- }
- }
- if (@$vorbis_fileinfo['ogg']['bitrate_average']) {
- $track_info['bitrate'] = $vorbis_fileinfo['ogg']['bitrate_average'];
- } elseif (@$vorbis_fileinfo['ogg']['bitrate_nominal']) {
- $track_info['bitrate'] = $vorbis_fileinfo['ogg']['bitrate_nominal'];
- }
- unset($vorbis_fileinfo);
- unset($oggpageinfo);
- } else {
- $this->warnings[] = 'Unable to parse audio data['.__LINE__.'] because cannot include "module.audio.ogg.php"';
- }
- } else {
- }
- } else {
- }
- break;
+ return $int_value;
+ }
- default:
- $this->warnings[] = 'Unhandled audio type "'.@$trackarray[$this->EBMLidName(EBML_ID_CODECID)].'"';
- break;
- }
+ private function readEBMLelementData($length)
+ {
+ $data = substr($this->EBMLbuffer, $this->current_offset - $this->EBMLbuffer_offset, $length);
+ $this->current_offset += $length;
+ return $data;
+ }
- $ThisFileInfo['audio']['streams'][] = $track_info;
- if (isset($track_info['dataformat']) && empty($ThisFileInfo['audio']['dataformat'])) {
- foreach ($track_info as $key => $value) {
- $ThisFileInfo['audio'][$key] = $value;
- }
- }
- break;
- default:
- // ignore, do nothing
- break;
- }
- }
+ private function getEBMLelement(&$element, $parent_end, $get_data = false)
+ {
+ if ($this->current_offset >= $parent_end) {
+ return false;
}
- if ($this->hide_clusters) {
- // too much data returned that is usually not useful
- if (isset($ThisFileInfo['matroska']['segments']) && is_array($ThisFileInfo['matroska']['segments'])) {
- foreach ($ThisFileInfo['matroska']['segments'] as $key => $segmentsarray) {
- if ($segmentsarray['id'] == EBML_ID_CLUSTER) {
- unset($ThisFileInfo['matroska']['segments'][$key]);
- }
- }
- }
- if (isset($ThisFileInfo['matroska']['seek']) && is_array($ThisFileInfo['matroska']['seek'])) {
- foreach ($ThisFileInfo['matroska']['seek'] as $key => $seekarray) {
- if ($seekarray['target_id'] == EBML_ID_CLUSTER) {
- unset($ThisFileInfo['matroska']['seek'][$key]);
- }
- }
- }
- //unset($ThisFileInfo['matroska']['cluster']);
- //unset($ThisFileInfo['matroska']['track_data_offsets']);
+ if (!$this->EnsureBufferHasEnoughData()) {
+ $this->current_offset = PHP_INT_MAX; // do not exit parser right now, allow to finish current loop to gather maximum information
+ return false;
+ }
+
+ $element = array();
+
+ // set offset
+ $element['offset'] = $this->current_offset;
+
+ // get ID
+ $element['id'] = $this->readEBMLint();
+
+ // get name
+ $element['id_name'] = self::EBMLidName($element['id']);
+
+ // get length
+ $element['length'] = $this->readEBMLint();
+
+ // get end offset
+ $element['end'] = $this->current_offset + $element['length'];
+
+ // get raw data
+ $dont_parse = (in_array($element['id'], $this->unuseful_elements) || $element['id_name'] == dechex($element['id']));
+ if (($get_data === true || (is_array($get_data) && !in_array($element['id'], $get_data))) && !$dont_parse) {
+ $element['data'] = $this->readEBMLelementData($element['length'], $element);
+ }
+
+ return true;
+ }
+
+ private function unhandledElement($type, $line, $element)
+ {
+ // warn only about unknown and missed elements, not about unuseful
+ if (!in_array($element['id'], $this->unuseful_elements)) {
+ $this->getid3->warning('Unhandled '.$type.' element ['.basename(__FILE__).':'.$line.'] ('.$element['id'].'::'.$element['id_name'].' ['.$element['length'].' bytes]) at '.$element['offset']);
}
- if (!empty($ThisFileInfo['video']['streams'])) {
- $ThisFileInfo['mime_type'] = 'video/x-matroska';
- } elseif (!empty($ThisFileInfo['video']['streams'])) {
- $ThisFileInfo['mime_type'] = 'audio/x-matroska';
- } elseif (isset($ThisFileInfo['mime_type'])) {
- unset($ThisFileInfo['mime_type']);
+ // increase offset for unparsed elements
+ if (!isset($element['data'])) {
+ $this->current_offset = $element['end'];
}
+ }
- foreach ($this->warnings as $key => $value) {
- $ThisFileInfo['warning'][] = $value;
+ private function ExtractCommentsSimpleTag($SimpleTagArray)
+ {
+ if (!empty($SimpleTagArray['SimpleTag'])) {
+ foreach ($SimpleTagArray['SimpleTag'] as $SimpleTagKey => $SimpleTagData) {
+ if (!empty($SimpleTagData['TagName']) && !empty($SimpleTagData['TagString'])) {
+ $this->getid3->info['matroska']['comments'][strtolower($SimpleTagData['TagName'])][] = $SimpleTagData['TagString'];
+ }
+ if (!empty($SimpleTagData['SimpleTag'])) {
+ $this->ExtractCommentsSimpleTag($SimpleTagData);
+ }
+ }
}
return true;
}
+ private function HandleEMBLSimpleTag($parent_end)
+ {
+ $simpletag_entry = array();
-///////////////////////////////////////
+ while ($this->getEBMLelement($element, $parent_end, array(EBML_ID_SIMPLETAG))) {
+ switch ($element['id']) {
+ case EBML_ID_TAGNAME:
+ case EBML_ID_TAGLANGUAGE:
+ case EBML_ID_TAGSTRING:
+ case EBML_ID_TAGBINARY:
+ $simpletag_entry[$element['id_name']] = $element['data'];
+ break;
- function EnsureBufferHasEnoughData(&$fd, &$EBMLdata, &$offset, &$EBMLdata_offset) {
- $min_data = 1024;
- if ($offset > 2147450880) { // 2^31 - 2^15 (2G-32k)
- $offset = pow(2,63);
- return false;
- } elseif (($offset - $EBMLdata_offset) >= (strlen($EBMLdata) - $min_data)) {
- fseek($fd, $offset, SEEK_SET);
- $EBMLdata_offset = ftell($fd);
- $EBMLdata = fread($fd, $this->read_buffer_size);
+ case EBML_ID_SIMPLETAG:
+ $simpletag_entry[$element['id_name']][] = $this->HandleEMBLSimpleTag($element['end']);
+ break;
+
+ case EBML_ID_TAGDEFAULT:
+ $simpletag_entry[$element['id_name']] = (bool)getid3_lib::BigEndian2Int($element['data']);
+ break;
+
+ default:
+ $this->unhandledElement('tag.simpletag', __LINE__, $element);
+ }
}
- return true;
+
+ return $simpletag_entry;
}
- function readEBMLint(&$string, &$offset, $dataoffset=0) {
- $actual_offset = $offset - $dataoffset;
- if ($offset > 2147450880) { // 2^31 - 2^15 (2G-32k)
- $this->warnings[] = 'aborting readEBMLint() because $offset larger than 2GB';
- return false;
- } elseif ($actual_offset >= strlen($string)) {
- $this->warnings[] = '$actual_offset > $string in readEBMLint($string['.strlen($string).'], '.$offset.', '.$dataoffset.')';
- return false;
- } elseif ($actual_offset < 0) {
- $this->warnings[] = '$actual_offset < 0 in readEBMLint($string['.strlen($string).'], '.$offset.', '.$dataoffset.')';
- return false;
+ private function HandleEMBLClusterBlock($element, $block_type, &$info)
+ {
+ // http://www.matroska.org/technical/specs/index.html#block_structure
+ // http://www.matroska.org/technical/specs/index.html#simpleblock_structure
+
+ $cluster_block_data = array();
+ $cluster_block_data['tracknumber'] = $this->readEBMLint();
+ $cluster_block_data['timecode'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(2));
+ $cluster_block_data['flags_raw'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1));
+
+ if ($block_type == EBML_ID_CLUSTERSIMPLEBLOCK) {
+ $cluster_block_data['flags']['keyframe'] = (($cluster_block_data['flags_raw'] & 0x80) >> 7);
+ //$cluster_block_data['flags']['reserved1'] = (($cluster_block_data['flags_raw'] & 0x70) >> 4);
}
- $first_byte_int = ord($string{$actual_offset});
- if (0x80 & $first_byte_int) {
- $length = 1;
- } elseif (0x40 & $first_byte_int) {
- $length = 2;
- } elseif (0x20 & $first_byte_int) {
- $length = 3;
- } elseif (0x10 & $first_byte_int) {
- $length = 4;
- } elseif (0x08 & $first_byte_int) {
- $length = 5;
- } elseif (0x04 & $first_byte_int) {
- $length = 6;
- } elseif (0x02 & $first_byte_int) {
- $length = 7;
- } elseif (0x01 & $first_byte_int) {
- $length = 8;
- } else {
- $offset = pow(2,63); // abort processing, skip to end of file
- $this->warnings[] = 'invalid EBML integer (leading 0x00) at '.$offset;
- return false;
+ else {
+ //$cluster_block_data['flags']['reserved1'] = (($cluster_block_data['flags_raw'] & 0xF0) >> 4);
}
- $int_value = $this->EBML2Int(substr($string, $actual_offset, $length));
- $offset += $length;
- return $int_value;
+ $cluster_block_data['flags']['invisible'] = (bool)(($cluster_block_data['flags_raw'] & 0x08) >> 3);
+ $cluster_block_data['flags']['lacing'] = (($cluster_block_data['flags_raw'] & 0x06) >> 1); // 00=no lacing; 01=Xiph lacing; 11=EBML lacing; 10=fixed-size lacing
+ if ($block_type == EBML_ID_CLUSTERSIMPLEBLOCK) {
+ $cluster_block_data['flags']['discardable'] = (($cluster_block_data['flags_raw'] & 0x01));
+ }
+ else {
+ //$cluster_block_data['flags']['reserved2'] = (($cluster_block_data['flags_raw'] & 0x01) >> 0);
+ }
+ $cluster_block_data['flags']['lacing_type'] = self::MatroskaBlockLacingType($cluster_block_data['flags']['lacing']);
+
+ // Lace (when lacing bit is set)
+ if ($cluster_block_data['flags']['lacing'] > 0) {
+ $cluster_block_data['lace_frames'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1)) + 1; // Number of frames in the lace-1 (uint8)
+ if ($cluster_block_data['flags']['lacing'] != 0x02) { // Lace-coded size of each frame of the lace, except for the last one (multiple uint8). *This is not used with Fixed-size lacing as it is calculated automatically from (total size of lace) / (number of frames in lace).
+ for ($i = 1; $i < $cluster_block_data['lace_frames']; $i ++) {
+ if ($cluster_block_data['flags']['lacing'] == 0x03) { // EBML lacing
+ // TODO: read size correctly, calc size for the last frame. For now offsets are deteminded OK with readEBMLint() and that's the most important thing.
+ $cluster_block_data['lace_frames_size'][$i] = $this->readEBMLint();
+ }
+ else { // Xiph lacing
+ $cluster_block_data['lace_frames_size'][$i] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1));
+ }
+ }
+ }
+ }
+
+ if (!isset($info['matroska']['track_data_offsets'][$cluster_block_data['tracknumber']])) {
+ $info['matroska']['track_data_offsets'][$cluster_block_data['tracknumber']]['offset'] = $this->current_offset;
+ $info['matroska']['track_data_offsets'][$cluster_block_data['tracknumber']]['length'] = $element['end'] - $this->current_offset;
+ }
+
+ // set offset manually
+ $this->current_offset = $element['end'];
+
+ return $cluster_block_data;
}
- function EBML2Int($EBMLstring) {
+ private static function EBML2Int($EBMLstring) {
// http://matroska.org/specs/
// Element ID coded with an UTF-8 like system:
@@ -1438,38 +1396,50 @@ class getid3_matroska
// 0000 001x xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^49-2
// 0000 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^56-2
- $first_byte_int = ord($EBMLstring{0});
+ $first_byte_int = ord($EBMLstring[0]);
if (0x80 & $first_byte_int) {
- $EBMLstring{0} = chr($first_byte_int & 0x7F);
+ $EBMLstring[0] = chr($first_byte_int & 0x7F);
} elseif (0x40 & $first_byte_int) {
- $EBMLstring{0} = chr($first_byte_int & 0x3F);
+ $EBMLstring[0] = chr($first_byte_int & 0x3F);
} elseif (0x20 & $first_byte_int) {
- $EBMLstring{0} = chr($first_byte_int & 0x1F);
+ $EBMLstring[0] = chr($first_byte_int & 0x1F);
} elseif (0x10 & $first_byte_int) {
- $EBMLstring{0} = chr($first_byte_int & 0x0F);
+ $EBMLstring[0] = chr($first_byte_int & 0x0F);
} elseif (0x08 & $first_byte_int) {
- $EBMLstring{0} = chr($first_byte_int & 0x07);
+ $EBMLstring[0] = chr($first_byte_int & 0x07);
} elseif (0x04 & $first_byte_int) {
- $EBMLstring{0} = chr($first_byte_int & 0x03);
+ $EBMLstring[0] = chr($first_byte_int & 0x03);
} elseif (0x02 & $first_byte_int) {
- $EBMLstring{0} = chr($first_byte_int & 0x01);
+ $EBMLstring[0] = chr($first_byte_int & 0x01);
} elseif (0x01 & $first_byte_int) {
- $EBMLstring{0} = chr($first_byte_int & 0x00);
- } else {
- return false;
+ $EBMLstring[0] = chr($first_byte_int & 0x00);
}
+
return getid3_lib::BigEndian2Int($EBMLstring);
}
-
- function EBMLdate2unix($EBMLdatestamp) {
+ private static function EBMLdate2unix($EBMLdatestamp) {
// Date - signed 8 octets integer in nanoseconds with 0 indicating the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC)
// 978307200 == mktime(0, 0, 0, 1, 1, 2001) == January 1, 2001 12:00:00am UTC
return round(($EBMLdatestamp / 1000000000) + 978307200);
}
+ public static function MatroskaTargetTypeValue($target_type) {
+ // http://www.matroska.org/technical/specs/tagging/index.html
+ static $MatroskaTargetTypeValue = array();
+ if (empty($MatroskaTargetTypeValue)) {
+ $MatroskaTargetTypeValue[10] = 'A: ~ V:shot'; // the lowest hierarchy found in music or movies
+ $MatroskaTargetTypeValue[20] = 'A:subtrack/part/movement ~ V:scene'; // corresponds to parts of a track for audio (like a movement)
+ $MatroskaTargetTypeValue[30] = 'A:track/song ~ V:chapter'; // the common parts of an album or a movie
+ $MatroskaTargetTypeValue[40] = 'A:part/session ~ V:part/session'; // when an album or episode has different logical parts
+ $MatroskaTargetTypeValue[50] = 'A:album/opera/concert ~ V:movie/episode/concert'; // the most common grouping level of music and video (equals to an episode for TV series)
+ $MatroskaTargetTypeValue[60] = 'A:edition/issue/volume/opus ~ V:season/sequel/volume'; // a list of lower levels grouped together
+ $MatroskaTargetTypeValue[70] = 'A:collection ~ V:collection'; // the high hierarchy consisting of many different lower items
+ }
+ return (isset($MatroskaTargetTypeValue[$target_type]) ? $MatroskaTargetTypeValue[$target_type] : $target_type);
+ }
- function MatroskaBlockLacingType($lacingtype) {
+ public static function MatroskaBlockLacingType($lacingtype) {
// http://matroska.org/technical/specs/index.html#block_structure
static $MatroskaBlockLacingType = array();
if (empty($MatroskaBlockLacingType)) {
@@ -1481,7 +1451,7 @@ class getid3_matroska
return (isset($MatroskaBlockLacingType[$lacingtype]) ? $MatroskaBlockLacingType[$lacingtype] : $lacingtype);
}
- function MatroskaCodecIDtoCommonName($codecid) {
+ public static function MatroskaCodecIDtoCommonName($codecid) {
// http://www.matroska.org/technical/specs/codecid/index.html
static $MatroskaCodecIDlist = array();
if (empty($MatroskaCodecIDlist)) {
@@ -1509,18 +1479,20 @@ class getid3_matroska
$MatroskaCodecIDlist['V_MPEG4/ISO/ASP'] = 'mpeg4';
$MatroskaCodecIDlist['V_MPEG4/ISO/AVC'] = 'h264';
$MatroskaCodecIDlist['V_MPEG4/ISO/SP'] = 'mpeg4';
+ $MatroskaCodecIDlist['V_VP8'] = 'vp8';
+ $MatroskaCodecIDlist['V_MS/VFW/FOURCC'] = 'riff';
+ $MatroskaCodecIDlist['A_MS/ACM'] = 'riff';
}
return (isset($MatroskaCodecIDlist[$codecid]) ? $MatroskaCodecIDlist[$codecid] : $codecid);
}
- function EBMLidName($value) {
+ private static function EBMLidName($value) {
static $EBMLidList = array();
if (empty($EBMLidList)) {
$EBMLidList[EBML_ID_ASPECTRATIOTYPE] = 'AspectRatioType';
$EBMLidList[EBML_ID_ATTACHEDFILE] = 'AttachedFile';
$EBMLidList[EBML_ID_ATTACHMENTLINK] = 'AttachmentLink';
$EBMLidList[EBML_ID_ATTACHMENTS] = 'Attachments';
- $EBMLidList[EBML_ID_ATTACHMENTUID] = 'AttachmentUID';
$EBMLidList[EBML_ID_AUDIO] = 'Audio';
$EBMLidList[EBML_ID_BITDEPTH] = 'BitDepth';
$EBMLidList[EBML_ID_CHANNELPOSITIONS] = 'ChannelPositions';
@@ -1623,6 +1595,7 @@ class getid3_matroska
$EBMLidList[EBML_ID_DOCTYPEREADVERSION] = 'DocTypeReadVersion';
$EBMLidList[EBML_ID_DOCTYPEVERSION] = 'DocTypeVersion';
$EBMLidList[EBML_ID_DURATION] = 'Duration';
+ $EBMLidList[EBML_ID_EBML] = 'EBML';
$EBMLidList[EBML_ID_EBMLMAXIDLENGTH] = 'EBMLMaxIDLength';
$EBMLidList[EBML_ID_EBMLMAXSIZELENGTH] = 'EBMLMaxSizeLength';
$EBMLidList[EBML_ID_EBMLREADVERSION] = 'EBMLReadVersion';
@@ -1667,6 +1640,7 @@ class getid3_matroska
$EBMLidList[EBML_ID_SEEKHEAD] = 'SeekHead';
$EBMLidList[EBML_ID_SEEKID] = 'SeekID';
$EBMLidList[EBML_ID_SEEKPOSITION] = 'SeekPosition';
+ $EBMLidList[EBML_ID_SEGMENT] = 'Segment';
$EBMLidList[EBML_ID_SEGMENTFAMILY] = 'SegmentFamily';
$EBMLidList[EBML_ID_SEGMENTFILENAME] = 'SegmentFilename';
$EBMLidList[EBML_ID_SEGMENTUID] = 'SegmentUID';
@@ -1674,6 +1648,7 @@ class getid3_matroska
$EBMLidList[EBML_ID_CLUSTERSLICES] = 'ClusterSlices';
$EBMLidList[EBML_ID_STEREOMODE] = 'StereoMode';
$EBMLidList[EBML_ID_TAG] = 'Tag';
+ $EBMLidList[EBML_ID_TAGATTACHMENTUID] = 'TagAttachmentUID';
$EBMLidList[EBML_ID_TAGBINARY] = 'TagBinary';
$EBMLidList[EBML_ID_TAGCHAPTERUID] = 'TagChapterUID';
$EBMLidList[EBML_ID_TAGDEFAULT] = 'TagDefault';
@@ -1704,8 +1679,27 @@ class getid3_matroska
$EBMLidList[EBML_ID_VOID] = 'Void';
$EBMLidList[EBML_ID_WRITINGAPP] = 'WritingApp';
}
+
return (isset($EBMLidList[$value]) ? $EBMLidList[$value] : dechex($value));
}
+
+ private static function getDefaultStreamInfo($streams)
+ {
+ foreach (array_reverse($streams) as $stream) {
+ if ($stream['default']) {
+ break;
+ }
+ }
+ unset($stream['default']);
+ if (isset($stream['name'])) {
+ unset($stream['name']);
+ }
+
+ $info = $stream;
+ $info['streams'] = $streams;
+
+ return $info;
+ }
}
diff --git a/apps/media/getID3/getid3/module.audio-video.mpeg.php b/3rdparty/getid3/module.audio-video.mpeg.php
index 8f487848495..499b740c390 100644
--- a/apps/media/getID3/getid3/module.audio-video.mpeg.php
+++ b/3rdparty/getid3/module.audio-video.mpeg.php
@@ -25,17 +25,19 @@ define('GETID3_MPEG_VIDEO_GROUP_START', "\x00\x00\x01\xB8");
define('GETID3_MPEG_AUDIO_START', "\x00\x00\x01\xC0");
-class getid3_mpeg
+class getid3_mpeg extends getid3_handler
{
- function getid3_mpeg(&$fd, &$ThisFileInfo) {
- if ($ThisFileInfo['avdataend'] <= $ThisFileInfo['avdataoffset']) {
- $ThisFileInfo['error'][] = '"avdataend" ('.$ThisFileInfo['avdataend'].') is unexpectedly less-than-or-equal-to "avdataoffset" ('.$ThisFileInfo['avdataoffset'].')';
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ if ($info['avdataend'] <= $info['avdataoffset']) {
+ $info['error'][] = '"avdataend" ('.$info['avdataend'].') is unexpectedly less-than-or-equal-to "avdataoffset" ('.$info['avdataoffset'].')';
return false;
}
- $ThisFileInfo['fileformat'] = 'mpeg';
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $MPEGstreamData = fread($fd, min(100000, $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']));
+ $info['fileformat'] = 'mpeg';
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $MPEGstreamData = fread($this->getid3->fp, min(100000, $info['avdataend'] - $info['avdataoffset']));
$MPEGstreamDataLength = strlen($MPEGstreamData);
$foundVideo = true;
@@ -62,7 +64,7 @@ class getid3_mpeg
// non-intra quant. matrix flag 1 bit
// non-intra quant. matrix values 512 bits (present if matrix flag == 1)
- $ThisFileInfo['video']['dataformat'] = 'mpeg';
+ $info['video']['dataformat'] = 'mpeg';
$VideoChunkOffset += (strlen(GETID3_MPEG_VIDEO_SEQUENCE_HEADER) - 1);
@@ -75,71 +77,71 @@ class getid3_mpeg
$assortedinformation = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 4));
$VideoChunkOffset += 4;
- $ThisFileInfo['mpeg']['video']['raw']['framesize_horizontal'] = ($FrameSizeDWORD & 0xFFF000) >> 12; // 12 bits for horizontal frame size
- $ThisFileInfo['mpeg']['video']['raw']['framesize_vertical'] = ($FrameSizeDWORD & 0x000FFF); // 12 bits for vertical frame size
- $ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio'] = ($AspectRatioFrameRateDWORD & 0xF0) >> 4;
- $ThisFileInfo['mpeg']['video']['raw']['frame_rate'] = ($AspectRatioFrameRateDWORD & 0x0F);
+ $info['mpeg']['video']['raw']['framesize_horizontal'] = ($FrameSizeDWORD & 0xFFF000) >> 12; // 12 bits for horizontal frame size
+ $info['mpeg']['video']['raw']['framesize_vertical'] = ($FrameSizeDWORD & 0x000FFF); // 12 bits for vertical frame size
+ $info['mpeg']['video']['raw']['pixel_aspect_ratio'] = ($AspectRatioFrameRateDWORD & 0xF0) >> 4;
+ $info['mpeg']['video']['raw']['frame_rate'] = ($AspectRatioFrameRateDWORD & 0x0F);
- $ThisFileInfo['mpeg']['video']['framesize_horizontal'] = $ThisFileInfo['mpeg']['video']['raw']['framesize_horizontal'];
- $ThisFileInfo['mpeg']['video']['framesize_vertical'] = $ThisFileInfo['mpeg']['video']['raw']['framesize_vertical'];
+ $info['mpeg']['video']['framesize_horizontal'] = $info['mpeg']['video']['raw']['framesize_horizontal'];
+ $info['mpeg']['video']['framesize_vertical'] = $info['mpeg']['video']['raw']['framesize_vertical'];
- $ThisFileInfo['mpeg']['video']['pixel_aspect_ratio'] = $this->MPEGvideoAspectRatioLookup($ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio']);
- $ThisFileInfo['mpeg']['video']['pixel_aspect_ratio_text'] = $this->MPEGvideoAspectRatioTextLookup($ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio']);
- $ThisFileInfo['mpeg']['video']['frame_rate'] = $this->MPEGvideoFramerateLookup($ThisFileInfo['mpeg']['video']['raw']['frame_rate']);
+ $info['mpeg']['video']['pixel_aspect_ratio'] = $this->MPEGvideoAspectRatioLookup($info['mpeg']['video']['raw']['pixel_aspect_ratio']);
+ $info['mpeg']['video']['pixel_aspect_ratio_text'] = $this->MPEGvideoAspectRatioTextLookup($info['mpeg']['video']['raw']['pixel_aspect_ratio']);
+ $info['mpeg']['video']['frame_rate'] = $this->MPEGvideoFramerateLookup($info['mpeg']['video']['raw']['frame_rate']);
- $ThisFileInfo['mpeg']['video']['raw']['bitrate'] = getid3_lib::Bin2Dec(substr($assortedinformation, 0, 18));
- $ThisFileInfo['mpeg']['video']['raw']['marker_bit'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 18, 1));
- $ThisFileInfo['mpeg']['video']['raw']['vbv_buffer_size'] = getid3_lib::Bin2Dec(substr($assortedinformation, 19, 10));
- $ThisFileInfo['mpeg']['video']['raw']['constrained_param_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 29, 1));
- $ThisFileInfo['mpeg']['video']['raw']['intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 30, 1));
- if ($ThisFileInfo['mpeg']['video']['raw']['intra_quant_flag']) {
+ $info['mpeg']['video']['raw']['bitrate'] = getid3_lib::Bin2Dec(substr($assortedinformation, 0, 18));
+ $info['mpeg']['video']['raw']['marker_bit'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 18, 1));
+ $info['mpeg']['video']['raw']['vbv_buffer_size'] = getid3_lib::Bin2Dec(substr($assortedinformation, 19, 10));
+ $info['mpeg']['video']['raw']['constrained_param_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 29, 1));
+ $info['mpeg']['video']['raw']['intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 30, 1));
+ if ($info['mpeg']['video']['raw']['intra_quant_flag']) {
// read 512 bits
- $ThisFileInfo['mpeg']['video']['raw']['intra_quant'] = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64));
+ $info['mpeg']['video']['raw']['intra_quant'] = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64));
$VideoChunkOffset += 64;
- $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($ThisFileInfo['mpeg']['video']['raw']['intra_quant'], 511, 1));
- $ThisFileInfo['mpeg']['video']['raw']['intra_quant'] = getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1)).substr(getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64)), 0, 511);
+ $info['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($info['mpeg']['video']['raw']['intra_quant'], 511, 1));
+ $info['mpeg']['video']['raw']['intra_quant'] = getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1)).substr(getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64)), 0, 511);
- if ($ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag']) {
- $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
+ if ($info['mpeg']['video']['raw']['non_intra_quant_flag']) {
+ $info['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
$VideoChunkOffset += 64;
}
} else {
- $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1));
- if ($ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag']) {
- $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
+ $info['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1));
+ if ($info['mpeg']['video']['raw']['non_intra_quant_flag']) {
+ $info['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
$VideoChunkOffset += 64;
}
}
- if ($ThisFileInfo['mpeg']['video']['raw']['bitrate'] == 0x3FFFF) { // 18 set bits
+ if ($info['mpeg']['video']['raw']['bitrate'] == 0x3FFFF) { // 18 set bits
- $ThisFileInfo['warning'][] = 'This version of getID3() ['.GETID3_VERSION.'] cannot determine average bitrate of VBR MPEG video files';
- $ThisFileInfo['mpeg']['video']['bitrate_mode'] = 'vbr';
+ $info['warning'][] = 'This version of getID3() ['.$this->getid3->version().'] cannot determine average bitrate of VBR MPEG video files';
+ $info['mpeg']['video']['bitrate_mode'] = 'vbr';
} else {
- $ThisFileInfo['mpeg']['video']['bitrate'] = $ThisFileInfo['mpeg']['video']['raw']['bitrate'] * 400;
- $ThisFileInfo['mpeg']['video']['bitrate_mode'] = 'cbr';
- $ThisFileInfo['video']['bitrate'] = $ThisFileInfo['mpeg']['video']['bitrate'];
+ $info['mpeg']['video']['bitrate'] = $info['mpeg']['video']['raw']['bitrate'] * 400;
+ $info['mpeg']['video']['bitrate_mode'] = 'cbr';
+ $info['video']['bitrate'] = $info['mpeg']['video']['bitrate'];
}
- $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['mpeg']['video']['framesize_horizontal'];
- $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['mpeg']['video']['framesize_vertical'];
- $ThisFileInfo['video']['frame_rate'] = $ThisFileInfo['mpeg']['video']['frame_rate'];
- $ThisFileInfo['video']['bitrate_mode'] = $ThisFileInfo['mpeg']['video']['bitrate_mode'];
- $ThisFileInfo['video']['pixel_aspect_ratio'] = $ThisFileInfo['mpeg']['video']['pixel_aspect_ratio'];
- $ThisFileInfo['video']['lossless'] = false;
- $ThisFileInfo['video']['bits_per_sample'] = 24;
+ $info['video']['resolution_x'] = $info['mpeg']['video']['framesize_horizontal'];
+ $info['video']['resolution_y'] = $info['mpeg']['video']['framesize_vertical'];
+ $info['video']['frame_rate'] = $info['mpeg']['video']['frame_rate'];
+ $info['video']['bitrate_mode'] = $info['mpeg']['video']['bitrate_mode'];
+ $info['video']['pixel_aspect_ratio'] = $info['mpeg']['video']['pixel_aspect_ratio'];
+ $info['video']['lossless'] = false;
+ $info['video']['bits_per_sample'] = 24;
} else {
- $ThisFileInfo['error'][] = 'Could not find start of video block in the first 100,000 bytes (or before end of file) - this might not be an MPEG-video file?';
+ $info['error'][] = 'Could not find start of video block in the first 100,000 bytes (or before end of file) - this might not be an MPEG-video file?';
}
@@ -151,9 +153,9 @@ class getid3_mpeg
//difference between MPEG-1 and MPEG-2 video streams.
if (substr($MPEGstreamData, $VideoChunkOffset, 4) == GETID3_MPEG_VIDEO_EXTENSION_START) {
- $ThisFileInfo['video']['codec'] = 'MPEG-2';
+ $info['video']['codec'] = 'MPEG-2';
} else {
- $ThisFileInfo['video']['codec'] = 'MPEG-1';
+ $info['video']['codec'] = 'MPEG-1';
}
@@ -165,33 +167,38 @@ class getid3_mpeg
}
}
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info = $info;
+ $getid3_mp3 = new getid3_mp3($getid3_temp);
for ($i = 0; $i <= 7; $i++) {
// some files have the MPEG-audio header 8 bytes after the end of the $00 $00 $01 $C0 signature, some have it up to 13 bytes (or more?) after
// I have no idea why or what the difference is, so this is a stupid hack.
// If anybody has any better idea of what's going on, please let me know - info@getid3.org
-
- $dummy = $ThisFileInfo;
- if (getid3_mp3::decodeMPEGaudioHeader($fd, ($AudioChunkOffset + 3) + 8 + $i, $dummy, false)) {
- $ThisFileInfo = $dummy;
- $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
- $ThisFileInfo['audio']['lossless'] = false;
+ fseek($getid3_temp->fp, ftell($this->getid3->fp), SEEK_SET);
+ $getid3_temp->info = $info; // only overwrite real data if valid header found
+ if ($getid3_mp3->decodeMPEGaudioHeader(($AudioChunkOffset + 3) + 8 + $i, $getid3_temp->info, false)) {
+ $info = $getid3_temp->info;
+ $info['audio']['bitrate_mode'] = 'cbr';
+ $info['audio']['lossless'] = false;
+ unset($getid3_temp, $getid3_mp3);
break 2;
-
}
}
+ unset($getid3_temp, $getid3_mp3);
}
// Temporary hack to account for interleaving overhead:
- if (!empty($ThisFileInfo['video']['bitrate']) && !empty($ThisFileInfo['audio']['bitrate'])) {
- $ThisFileInfo['playtime_seconds'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / ($ThisFileInfo['video']['bitrate'] + $ThisFileInfo['audio']['bitrate']);
+ if (!empty($info['video']['bitrate']) && !empty($info['audio']['bitrate'])) {
+ $info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['video']['bitrate'] + $info['audio']['bitrate']);
// Interleaved MPEG audio/video files have a certain amount of overhead that varies
// by both video and audio bitrates, and not in any sensible, linear/logarithmic patter
// Use interpolated lookup tables to approximately guess how much is overhead, because
// playtime is calculated as filesize / total-bitrate
- $ThisFileInfo['playtime_seconds'] *= $this->MPEGsystemNonOverheadPercentage($ThisFileInfo['video']['bitrate'], $ThisFileInfo['audio']['bitrate']);
+ $info['playtime_seconds'] *= $this->MPEGsystemNonOverheadPercentage($info['video']['bitrate'], $info['audio']['bitrate']);
- //switch ($ThisFileInfo['video']['bitrate']) {
+ //switch ($info['video']['bitrate']) {
// case('5000000'):
// $multiplier = 0.93292642112380355828048824319889;
// break;
@@ -208,10 +215,10 @@ class getid3_mpeg
// $multiplier = 1;
// break;
//}
- //$ThisFileInfo['playtime_seconds'] *= $multiplier;
- //$ThisFileInfo['warning'][] = 'Interleaved MPEG audio/video playtime may be inaccurate. With current hack should be within a few seconds of accurate. Report to info@getid3.org if off by more than 10 seconds.';
- if ($ThisFileInfo['video']['bitrate'] < 50000) {
- $ThisFileInfo['warning'][] = 'Interleaved MPEG audio/video playtime may be slightly inaccurate for video bitrates below 100kbps. Except in extreme low-bitrate situations, error should be less than 1%. Report to info@getid3.org if greater than this.';
+ //$info['playtime_seconds'] *= $multiplier;
+ //$info['warning'][] = 'Interleaved MPEG audio/video playtime may be inaccurate. With current hack should be within a few seconds of accurate. Report to info@getid3.org if off by more than 10 seconds.';
+ if ($info['video']['bitrate'] < 50000) {
+ $info['warning'][] = 'Interleaved MPEG audio/video playtime may be slightly inaccurate for video bitrates below 100kbps. Except in extreme low-bitrate situations, error should be less than 1%. Report to info@getid3.org if greater than this.';
}
}
diff --git a/3rdparty/getid3/module.audio-video.nsv.php b/3rdparty/getid3/module.audio-video.nsv.php
new file mode 100644
index 00000000000..5a587e67208
--- /dev/null
+++ b/3rdparty/getid3/module.audio-video.nsv.php
@@ -0,0 +1,226 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.nsv.php //
+// module for analyzing Nullsoft NSV files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_nsv extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $NSVheader = fread($this->getid3->fp, 4);
+
+ switch ($NSVheader) {
+ case 'NSVs':
+ if ($this->getNSVsHeaderFilepointer(0)) {
+ $info['fileformat'] = 'nsv';
+ $info['audio']['dataformat'] = 'nsv';
+ $info['video']['dataformat'] = 'nsv';
+ $info['audio']['lossless'] = false;
+ $info['video']['lossless'] = false;
+ }
+ break;
+
+ case 'NSVf':
+ if ($this->getNSVfHeaderFilepointer(0)) {
+ $info['fileformat'] = 'nsv';
+ $info['audio']['dataformat'] = 'nsv';
+ $info['video']['dataformat'] = 'nsv';
+ $info['audio']['lossless'] = false;
+ $info['video']['lossless'] = false;
+ $this->getNSVsHeaderFilepointer($info['nsv']['NSVf']['header_length']);
+ }
+ break;
+
+ default:
+ $info['error'][] = 'Expecting "NSVs" or "NSVf" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($NSVheader).'"';
+ return false;
+ break;
+ }
+
+ if (!isset($info['nsv']['NSVf'])) {
+ $info['warning'][] = 'NSVf header not present - cannot calculate playtime or bitrate';
+ }
+
+ return true;
+ }
+
+ function getNSVsHeaderFilepointer($fileoffset) {
+ $info = &$this->getid3->info;
+ fseek($this->getid3->fp, $fileoffset, SEEK_SET);
+ $NSVsheader = fread($this->getid3->fp, 28);
+ $offset = 0;
+
+ $info['nsv']['NSVs']['identifier'] = substr($NSVsheader, $offset, 4);
+ $offset += 4;
+
+ if ($info['nsv']['NSVs']['identifier'] != 'NSVs') {
+ $info['error'][] = 'expected "NSVs" at offset ('.$fileoffset.'), found "'.$info['nsv']['NSVs']['identifier'].'" instead';
+ unset($info['nsv']['NSVs']);
+ return false;
+ }
+
+ $info['nsv']['NSVs']['offset'] = $fileoffset;
+
+ $info['nsv']['NSVs']['video_codec'] = substr($NSVsheader, $offset, 4);
+ $offset += 4;
+ $info['nsv']['NSVs']['audio_codec'] = substr($NSVsheader, $offset, 4);
+ $offset += 4;
+ $info['nsv']['NSVs']['resolution_x'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
+ $offset += 2;
+ $info['nsv']['NSVs']['resolution_y'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
+ $offset += 2;
+
+ $info['nsv']['NSVs']['framerate_index'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+ $offset += 1;
+ //$info['nsv']['NSVs']['unknown1b'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+ $offset += 1;
+ //$info['nsv']['NSVs']['unknown1c'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+ $offset += 1;
+ //$info['nsv']['NSVs']['unknown1d'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+ $offset += 1;
+ //$info['nsv']['NSVs']['unknown2a'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+ $offset += 1;
+ //$info['nsv']['NSVs']['unknown2b'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+ $offset += 1;
+ //$info['nsv']['NSVs']['unknown2c'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+ $offset += 1;
+ //$info['nsv']['NSVs']['unknown2d'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+ $offset += 1;
+
+ switch ($info['nsv']['NSVs']['audio_codec']) {
+ case 'PCM ':
+ $info['nsv']['NSVs']['bits_channel'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+ $offset += 1;
+ $info['nsv']['NSVs']['channels'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+ $offset += 1;
+ $info['nsv']['NSVs']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
+ $offset += 2;
+
+ $info['audio']['sample_rate'] = $info['nsv']['NSVs']['sample_rate'];
+ break;
+
+ case 'MP3 ':
+ case 'NONE':
+ default:
+ //$info['nsv']['NSVs']['unknown3'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 4));
+ $offset += 4;
+ break;
+ }
+
+ $info['video']['resolution_x'] = $info['nsv']['NSVs']['resolution_x'];
+ $info['video']['resolution_y'] = $info['nsv']['NSVs']['resolution_y'];
+ $info['nsv']['NSVs']['frame_rate'] = $this->NSVframerateLookup($info['nsv']['NSVs']['framerate_index']);
+ $info['video']['frame_rate'] = $info['nsv']['NSVs']['frame_rate'];
+ $info['video']['bits_per_sample'] = 24;
+ $info['video']['pixel_aspect_ratio'] = (float) 1;
+
+ return true;
+ }
+
+ function getNSVfHeaderFilepointer($fileoffset, $getTOCoffsets=false) {
+ $info = &$this->getid3->info;
+ fseek($this->getid3->fp, $fileoffset, SEEK_SET);
+ $NSVfheader = fread($this->getid3->fp, 28);
+ $offset = 0;
+
+ $info['nsv']['NSVf']['identifier'] = substr($NSVfheader, $offset, 4);
+ $offset += 4;
+
+ if ($info['nsv']['NSVf']['identifier'] != 'NSVf') {
+ $info['error'][] = 'expected "NSVf" at offset ('.$fileoffset.'), found "'.$info['nsv']['NSVf']['identifier'].'" instead';
+ unset($info['nsv']['NSVf']);
+ return false;
+ }
+
+ $info['nsv']['NSVs']['offset'] = $fileoffset;
+
+ $info['nsv']['NSVf']['header_length'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
+ $offset += 4;
+ $info['nsv']['NSVf']['file_size'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
+ $offset += 4;
+
+ if ($info['nsv']['NSVf']['file_size'] > $info['avdataend']) {
+ $info['warning'][] = 'truncated file - NSVf header indicates '.$info['nsv']['NSVf']['file_size'].' bytes, file actually '.$info['avdataend'].' bytes';
+ }
+
+ $info['nsv']['NSVf']['playtime_ms'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
+ $offset += 4;
+ $info['nsv']['NSVf']['meta_size'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
+ $offset += 4;
+ $info['nsv']['NSVf']['TOC_entries_1'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
+ $offset += 4;
+ $info['nsv']['NSVf']['TOC_entries_2'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
+ $offset += 4;
+
+ if ($info['nsv']['NSVf']['playtime_ms'] == 0) {
+ $info['error'][] = 'Corrupt NSV file: NSVf.playtime_ms == zero';
+ return false;
+ }
+
+ $NSVfheader .= fread($this->getid3->fp, $info['nsv']['NSVf']['meta_size'] + (4 * $info['nsv']['NSVf']['TOC_entries_1']) + (4 * $info['nsv']['NSVf']['TOC_entries_2']));
+ $NSVfheaderlength = strlen($NSVfheader);
+ $info['nsv']['NSVf']['metadata'] = substr($NSVfheader, $offset, $info['nsv']['NSVf']['meta_size']);
+ $offset += $info['nsv']['NSVf']['meta_size'];
+
+ if ($getTOCoffsets) {
+ $TOCcounter = 0;
+ while ($TOCcounter < $info['nsv']['NSVf']['TOC_entries_1']) {
+ if ($TOCcounter < $info['nsv']['NSVf']['TOC_entries_1']) {
+ $info['nsv']['NSVf']['TOC_1'][$TOCcounter] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
+ $offset += 4;
+ $TOCcounter++;
+ }
+ }
+ }
+
+ if (trim($info['nsv']['NSVf']['metadata']) != '') {
+ $info['nsv']['NSVf']['metadata'] = str_replace('`', "\x01", $info['nsv']['NSVf']['metadata']);
+ $CommentPairArray = explode("\x01".' ', $info['nsv']['NSVf']['metadata']);
+ foreach ($CommentPairArray as $CommentPair) {
+ if (strstr($CommentPair, '='."\x01")) {
+ list($key, $value) = explode('='."\x01", $CommentPair, 2);
+ $info['nsv']['comments'][strtolower($key)][] = trim(str_replace("\x01", '', $value));
+ }
+ }
+ }
+
+ $info['playtime_seconds'] = $info['nsv']['NSVf']['playtime_ms'] / 1000;
+ $info['bitrate'] = ($info['nsv']['NSVf']['file_size'] * 8) / $info['playtime_seconds'];
+
+ return true;
+ }
+
+
+ static function NSVframerateLookup($framerateindex) {
+ if ($framerateindex <= 127) {
+ return (float) $framerateindex;
+ }
+ static $NSVframerateLookup = array();
+ if (empty($NSVframerateLookup)) {
+ $NSVframerateLookup[129] = (float) 29.970;
+ $NSVframerateLookup[131] = (float) 23.976;
+ $NSVframerateLookup[133] = (float) 14.985;
+ $NSVframerateLookup[197] = (float) 59.940;
+ $NSVframerateLookup[199] = (float) 47.952;
+ }
+ return (isset($NSVframerateLookup[$framerateindex]) ? $NSVframerateLookup[$framerateindex] : false);
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/3rdparty/getid3/module.audio-video.quicktime.php b/3rdparty/getid3/module.audio-video.quicktime.php
new file mode 100644
index 00000000000..3e96ea1a0c2
--- /dev/null
+++ b/3rdparty/getid3/module.audio-video.quicktime.php
@@ -0,0 +1,2134 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio-video.quicktime.php //
+// module for analyzing Quicktime and MP3-in-MP4 files //
+// dependencies: module.audio.mp3.php //
+// ///
+/////////////////////////////////////////////////////////////////
+
+getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
+
+class getid3_quicktime extends getid3_handler
+{
+
+ var $ReturnAtomData = true;
+ var $ParseAllPossibleAtoms = false;
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $info['fileformat'] = 'quicktime';
+ $info['quicktime']['hinting'] = false;
+ $info['quicktime']['controller'] = 'standard'; // may be overridden if 'ctyp' atom is present
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+
+ $offset = 0;
+ $atomcounter = 0;
+
+ while ($offset < $info['avdataend']) {
+ if (!getid3_lib::intValueSupported($offset)) {
+ $info['error'][] = 'Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
+ break;
+ }
+ fseek($this->getid3->fp, $offset, SEEK_SET);
+ $AtomHeader = fread($this->getid3->fp, 8);
+
+ $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
+ $atomname = substr($AtomHeader, 4, 4);
+
+ // 64-bit MOV patch by jlegateØktnc*com
+ if ($atomsize == 1) {
+ $atomsize = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 8));
+ }
+
+ $info['quicktime'][$atomname]['name'] = $atomname;
+ $info['quicktime'][$atomname]['size'] = $atomsize;
+ $info['quicktime'][$atomname]['offset'] = $offset;
+
+ if (($offset + $atomsize) > $info['avdataend']) {
+ $info['error'][] = 'Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)';
+ return false;
+ }
+
+ if ($atomsize == 0) {
+ // Furthermore, for historical reasons the list of atoms is optionally
+ // terminated by a 32-bit integer set to 0. If you are writing a program
+ // to read user data atoms, you should allow for the terminating 0.
+ break;
+ }
+ switch ($atomname) {
+ case 'mdat': // Media DATa atom
+ // 'mdat' contains the actual data for the audio/video
+ if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) {
+
+ $info['avdataoffset'] = $info['quicktime'][$atomname]['offset'] + 8;
+ $OldAVDataEnd = $info['avdataend'];
+ $info['avdataend'] = $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];
+
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
+ $getid3_temp->info['avdataend'] = $info['avdataend'];
+ $getid3_mp3 = new getid3_mp3($getid3_temp);
+ if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode(fread($this->getid3->fp, 4)))) {
+ $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
+ if (!empty($getid3_temp->info['warning'])) {
+ foreach ($getid3_temp->info['warning'] as $value) {
+ $info['warning'][] = $value;
+ }
+ }
+ if (!empty($getid3_temp->info['mpeg'])) {
+ $info['mpeg'] = $getid3_temp->info['mpeg'];
+ if (isset($info['mpeg']['audio'])) {
+ $info['audio']['dataformat'] = 'mp3';
+ $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')));
+ $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
+ $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
+ $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
+ $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
+ $info['bitrate'] = $info['audio']['bitrate'];
+ }
+ }
+ }
+ unset($getid3_mp3, $getid3_temp);
+ $info['avdataend'] = $OldAVDataEnd;
+ unset($OldAVDataEnd);
+
+ }
+ break;
+
+ case 'free': // FREE space atom
+ case 'skip': // SKIP atom
+ case 'wide': // 64-bit expansion placeholder atom
+ // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
+ break;
+
+ default:
+ $atomHierarchy = array();
+ $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($this->getid3->fp, $atomsize), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);
+ break;
+ }
+
+ $offset += $atomsize;
+ $atomcounter++;
+ }
+
+ if (!empty($info['avdataend_tmp'])) {
+ // this value is assigned to a temp value and then erased because
+ // otherwise any atoms beyond the 'mdat' atom would not get parsed
+ $info['avdataend'] = $info['avdataend_tmp'];
+ unset($info['avdataend_tmp']);
+ }
+
+ if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) {
+ $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+ }
+ if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info['quicktime']['video'])) {
+ $info['audio']['bitrate'] = $info['bitrate'];
+ }
+ if (!empty($info['playtime_seconds']) && !isset($info['video']['frame_rate']) && !empty($info['quicktime']['stts_framecount'])) {
+ foreach ($info['quicktime']['stts_framecount'] as $key => $samples_count) {
+ $samples_per_second = $samples_count / $info['playtime_seconds'];
+ if ($samples_per_second > 240) {
+ // has to be audio samples
+ } else {
+ $info['video']['frame_rate'] = $samples_per_second;
+ break;
+ }
+ }
+ }
+ if (($info['audio']['dataformat'] == 'mp4') && empty($info['video']['resolution_x'])) {
+ $info['fileformat'] = 'mp4';
+ $info['mime_type'] = 'audio/mp4';
+ unset($info['video']['dataformat']);
+ }
+
+ if (!$this->ReturnAtomData) {
+ unset($info['quicktime']['moov']);
+ }
+
+ if (empty($info['audio']['dataformat']) && !empty($info['quicktime']['audio'])) {
+ $info['audio']['dataformat'] = 'quicktime';
+ }
+ if (empty($info['video']['dataformat']) && !empty($info['quicktime']['video'])) {
+ $info['video']['dataformat'] = 'quicktime';
+ }
+
+ return true;
+ }
+
+ function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
+ // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm
+
+ $info = &$this->getid3->info;
+
+ $atom_parent = array_pop($atomHierarchy);
+ array_push($atomHierarchy, $atomname);
+ $atom_structure['hierarchy'] = implode(' ', $atomHierarchy);
+ $atom_structure['name'] = $atomname;
+ $atom_structure['size'] = $atomsize;
+ $atom_structure['offset'] = $baseoffset;
+//echo getid3_lib::PrintHexBytes(substr($atom_data, 0, 8)).'<br>';
+//echo getid3_lib::PrintHexBytes(substr($atom_data, 0, 8), false).'<br><br>';
+ switch ($atomname) {
+ case 'moov': // MOVie container atom
+ case 'trak': // TRAcK container atom
+ case 'clip': // CLIPping container atom
+ case 'matt': // track MATTe container atom
+ case 'edts': // EDiTS container atom
+ case 'tref': // Track REFerence container atom
+ case 'mdia': // MeDIA container atom
+ case 'minf': // Media INFormation container atom
+ case 'dinf': // Data INFormation container atom
+ case 'udta': // User DaTA container atom
+ case 'cmov': // Compressed MOVie container atom
+ case 'rmra': // Reference Movie Record Atom
+ case 'rmda': // Reference Movie Descriptor Atom
+ case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR)
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
+ break;
+
+ case 'ilst': // Item LiST container atom
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
+
+ // some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted
+ $allnumericnames = true;
+ foreach ($atom_structure['subatoms'] as $subatomarray) {
+ if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) {
+ $allnumericnames = false;
+ break;
+ }
+ }
+ if ($allnumericnames) {
+ $newData = array();
+ foreach ($atom_structure['subatoms'] as $subatomarray) {
+ foreach ($subatomarray['subatoms'] as $newData_subatomarray) {
+ unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']);
+ $newData[$subatomarray['name']] = $newData_subatomarray;
+ break;
+ }
+ }
+ $atom_structure['data'] = $newData;
+ unset($atom_structure['subatoms']);
+ }
+ break;
+
+ case "\x00\x00\x00\x01":
+ case "\x00\x00\x00\x02":
+ case "\x00\x00\x00\x03":
+ case "\x00\x00\x00\x04":
+ case "\x00\x00\x00\x05":
+ $atomname = getid3_lib::BigEndian2Int($atomname);
+ $atom_structure['name'] = $atomname;
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
+ break;
+
+ case 'stbl': // Sample TaBLe container atom
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
+ $isVideo = false;
+ $framerate = 0;
+ $framecount = 0;
+ foreach ($atom_structure['subatoms'] as $key => $value_array) {
+ if (isset($value_array['sample_description_table'])) {
+ foreach ($value_array['sample_description_table'] as $key2 => $value_array2) {
+ if (isset($value_array2['data_format'])) {
+ switch ($value_array2['data_format']) {
+ case 'avc1':
+ case 'mp4v':
+ // video data
+ $isVideo = true;
+ break;
+ case 'mp4a':
+ // audio data
+ break;
+ }
+ }
+ }
+ } elseif (isset($value_array['time_to_sample_table'])) {
+ foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) {
+ if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0)) {
+ $framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3);
+ $framecount = $value_array2['sample_count'];
+ }
+ }
+ }
+ }
+ if ($isVideo && $framerate) {
+ $info['quicktime']['video']['frame_rate'] = $framerate;
+ $info['video']['frame_rate'] = $info['quicktime']['video']['frame_rate'];
+ }
+ if ($isVideo && $framecount) {
+ $info['quicktime']['video']['frame_count'] = $framecount;
+ }
+ break;
+
+
+ case 'aART': // Album ARTist
+ case 'catg': // CaTeGory
+ case 'covr': // COVeR artwork
+ case 'cpil': // ComPILation
+ case 'cprt': // CoPyRighT
+ case 'desc': // DESCription
+ case 'disk': // DISK number
+ case 'egid': // Episode Global ID
+ case 'gnre': // GeNRE
+ case 'keyw': // KEYWord
+ case 'ldes':
+ case 'pcst': // PodCaST
+ case 'pgap': // GAPless Playback
+ case 'purd': // PURchase Date
+ case 'purl': // Podcast URL
+ case 'rati':
+ case 'rndu':
+ case 'rpdu':
+ case 'rtng': // RaTiNG
+ case 'stik':
+ case 'tmpo': // TeMPO (BPM)
+ case 'trkn': // TRacK Number
+ case 'tves': // TV EpiSode
+ case 'tvnn': // TV Network Name
+ case 'tvsh': // TV SHow Name
+ case 'tvsn': // TV SeasoN
+ case 'akID': // iTunes store account type
+ case 'apID':
+ case 'atID':
+ case 'cmID':
+ case 'cnID':
+ case 'geID':
+ case 'plID':
+ case 'sfID': // iTunes store country
+ case '©alb': // ALBum
+ case '©art': // ARTist
+ case '©ART':
+ case '©aut':
+ case '©cmt': // CoMmenT
+ case '©com': // COMposer
+ case '©cpy':
+ case '©day': // content created year
+ case '©dir':
+ case '©ed1':
+ case '©ed2':
+ case '©ed3':
+ case '©ed4':
+ case '©ed5':
+ case '©ed6':
+ case '©ed7':
+ case '©ed8':
+ case '©ed9':
+ case '©enc':
+ case '©fmt':
+ case '©gen': // GENre
+ case '©grp': // GRouPing
+ case '©hst':
+ case '©inf':
+ case '©lyr': // LYRics
+ case '©mak':
+ case '©mod':
+ case '©nam': // full NAMe
+ case '©ope':
+ case '©PRD':
+ case '©prd':
+ case '©prf':
+ case '©req':
+ case '©src':
+ case '©swr':
+ case '©too': // encoder
+ case '©trk': // TRacK
+ case '©url':
+ case '©wrn':
+ case '©wrt': // WRiTer
+ case '----': // itunes specific
+ if ($atom_parent == 'udta') {
+ // User data atom handler
+ $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
+ $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
+ $atom_structure['data'] = substr($atom_data, 4);
+
+ $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
+ if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
+ $info['comments']['language'][] = $atom_structure['language'];
+ }
+ } else {
+ // Apple item list box atom handler
+ $atomoffset = 0;
+ if (substr($atom_data, 2, 2) == "\x10\xB5") {
+ // not sure what it means, but observed on iPhone4 data.
+ // Each $atom_data has 2 bytes of datasize, plus 0x10B5, then data
+ while ($atomoffset < strlen($atom_data)) {
+ $boxsmallsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 2));
+ $boxsmalltype = substr($atom_data, $atomoffset + 2, 2);
+ $boxsmalldata = substr($atom_data, $atomoffset + 4, $boxsmallsize);
+ switch ($boxsmalltype) {
+ case "\x10\xB5":
+ $atom_structure['data'] = $boxsmalldata;
+ break;
+ default:
+ $info['warning'][] = 'Unknown QuickTime smallbox type: "'.getid3_lib::PrintHexBytes($boxsmalltype).'" at offset '.$baseoffset;
+ $atom_structure['data'] = $atom_data;
+ break;
+ }
+ $atomoffset += (4 + $boxsmallsize);
+ }
+ } else {
+ while ($atomoffset < strlen($atom_data)) {
+ $boxsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 4));
+ $boxtype = substr($atom_data, $atomoffset + 4, 4);
+ $boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8);
+
+ switch ($boxtype) {
+ case 'mean':
+ case 'name':
+ $atom_structure[$boxtype] = substr($boxdata, 4);
+ break;
+
+ case 'data':
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3));
+ switch ($atom_structure['flags_raw']) {
+ case 0: // data flag
+ case 21: // tmpo/cpil flag
+ switch ($atomname) {
+ case 'cpil':
+ case 'pcst':
+ case 'pgap':
+ $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
+ break;
+
+ case 'tmpo':
+ $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2));
+ break;
+
+ case 'disk':
+ case 'trkn':
+ $num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2));
+ $num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2));
+ $atom_structure['data'] = empty($num) ? '' : $num;
+ $atom_structure['data'] .= empty($num_total) ? '' : '/'.$num_total;
+ break;
+
+ case 'gnre':
+ $GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
+ $atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1);
+ break;
+
+ case 'rtng':
+ $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
+ $atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]);
+ break;
+
+ case 'stik':
+ $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
+ $atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]);
+ break;
+
+ case 'sfID':
+ $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
+ $atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]);
+ break;
+
+ case 'egid':
+ case 'purl':
+ $atom_structure['data'] = substr($boxdata, 8);
+ break;
+
+ default:
+ $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
+ }
+ break;
+
+ case 1: // text flag
+ case 13: // image flag
+ default:
+ $atom_structure['data'] = substr($boxdata, 8);
+ break;
+
+ }
+ break;
+
+ default:
+ $info['warning'][] = 'Unknown QuickTime box type: "'.getid3_lib::PrintHexBytes($boxtype).'" at offset '.$baseoffset;
+ $atom_structure['data'] = $atom_data;
+
+ }
+ $atomoffset += $boxsize;
+ }
+ }
+ }
+ $this->CopyToAppropriateCommentsSection($atomname, $atom_structure['data'], $atom_structure['name']);
+ break;
+
+
+ case 'play': // auto-PLAY atom
+ $atom_structure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+
+ $info['quicktime']['autoplay'] = $atom_structure['autoplay'];
+ break;
+
+
+ case 'WLOC': // Window LOCation atom
+ $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
+ $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
+ break;
+
+
+ case 'LOOP': // LOOPing atom
+ case 'SelO': // play SELection Only atom
+ case 'AllF': // play ALL Frames atom
+ $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data);
+ break;
+
+
+ case 'name': //
+ case 'MCPS': // Media Cleaner PRo
+ case '@PRM': // adobe PReMiere version
+ case '@PRQ': // adobe PRemiere Quicktime version
+ $atom_structure['data'] = $atom_data;
+ break;
+
+
+ case 'cmvd': // Compressed MooV Data atom
+ // Code by ubergeekØubergeek*tv based on information from
+ // http://developer.apple.com/quicktime/icefloe/dispatch012.html
+ $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
+
+ $CompressedFileData = substr($atom_data, 4);
+ if ($UncompressedHeader = @gzuncompress($CompressedFileData)) {
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, 0, $atomHierarchy, $ParseAllPossibleAtoms);
+ } else {
+ $info['warning'][] = 'Error decompressing compressed MOV atom at offset '.$atom_structure['offset'];
+ }
+ break;
+
+
+ case 'dcom': // Data COMpression atom
+ $atom_structure['compression_id'] = $atom_data;
+ $atom_structure['compression_text'] = $this->QuicktimeDCOMLookup($atom_data);
+ break;
+
+
+ case 'rdrf': // Reference movie Data ReFerence atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
+ $atom_structure['flags']['internal_data'] = (bool) ($atom_structure['flags_raw'] & 0x000001);
+
+ $atom_structure['reference_type_name'] = substr($atom_data, 4, 4);
+ $atom_structure['reference_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
+ switch ($atom_structure['reference_type_name']) {
+ case 'url ':
+ $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12));
+ break;
+
+ case 'alis':
+ $atom_structure['file_alias'] = substr($atom_data, 12);
+ break;
+
+ case 'rsrc':
+ $atom_structure['resource_alias'] = substr($atom_data, 12);
+ break;
+
+ default:
+ $atom_structure['data'] = substr($atom_data, 12);
+ break;
+ }
+ break;
+
+
+ case 'rmqu': // Reference Movie QUality atom
+ $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data);
+ break;
+
+
+ case 'rmcs': // Reference Movie Cpu Speed atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
+ break;
+
+
+ case 'rmvc': // Reference Movie Version Check atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['gestalt_selector'] = substr($atom_data, 4, 4);
+ $atom_structure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
+ $atom_structure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
+ $atom_structure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
+ break;
+
+
+ case 'rmcd': // Reference Movie Component check atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['component_type'] = substr($atom_data, 4, 4);
+ $atom_structure['component_subtype'] = substr($atom_data, 8, 4);
+ $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
+ $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
+ $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
+ $atom_structure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 4));
+ break;
+
+
+ case 'rmdr': // Reference Movie Data Rate atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['data_rate'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+
+ $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10;
+ break;
+
+
+ case 'rmla': // Reference Movie Language Atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
+
+ $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
+ if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
+ $info['comments']['language'][] = $atom_structure['language'];
+ }
+ break;
+
+
+ case 'rmla': // Reference Movie Language Atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
+ break;
+
+
+ case 'ptv ': // Print To Video - defines a movie's full screen mode
+ // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm
+ $atom_structure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
+ $atom_structure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); // hardcoded: 0x0000
+ $atom_structure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x0000
+ $atom_structure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 1));
+ $atom_structure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 7, 1));
+
+ $atom_structure['flags']['play_on_open'] = (bool) $atom_structure['play_on_open_flag'];
+ $atom_structure['flags']['slide_show'] = (bool) $atom_structure['slide_show_flag'];
+
+ $ptv_lookup[0] = 'normal';
+ $ptv_lookup[1] = 'double';
+ $ptv_lookup[2] = 'half';
+ $ptv_lookup[3] = 'full';
+ $ptv_lookup[4] = 'current';
+ if (isset($ptv_lookup[$atom_structure['display_size_raw']])) {
+ $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']];
+ } else {
+ $info['warning'][] = 'unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')';
+ }
+ break;
+
+
+ case 'stsd': // Sample Table Sample Description atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $stsdEntriesDataOffset = 8;
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
+ $atom_structure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 4));
+ $stsdEntriesDataOffset += 4;
+ $atom_structure['sample_description_table'][$i]['data_format'] = substr($atom_data, $stsdEntriesDataOffset, 4);
+ $stsdEntriesDataOffset += 4;
+ $atom_structure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 6));
+ $stsdEntriesDataOffset += 6;
+ $atom_structure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 2));
+ $stsdEntriesDataOffset += 2;
+ $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));
+ $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);
+
+ $atom_structure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 0, 2));
+ $atom_structure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 2, 2));
+ $atom_structure['sample_description_table'][$i]['encoder_vendor'] = substr($atom_structure['sample_description_table'][$i]['data'], 4, 4);
+
+ switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) {
+
+ case "\x00\x00\x00\x00":
+ // audio atom
+ $atom_structure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 2));
+ $atom_structure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 10, 2));
+ $atom_structure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 2));
+ $atom_structure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 14, 2));
+ $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4));
+
+ switch ($atom_structure['sample_description_table'][$i]['data_format']) {
+ case 'avc1':
+ case 'mp4v':
+ $info['fileformat'] = 'mp4';
+ $info['video']['fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
+ //$info['warning'][] = 'This version of getID3() ['.$this->getid3->version().'] does not fully support MPEG-4 audio/video streams'; // 2011-02-18: why am I warning about this again? What's not supported?
+ break;
+
+ case 'qtvr':
+ $info['video']['dataformat'] = 'quicktimevr';
+ break;
+
+ case 'mp4a':
+ default:
+ $info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
+ $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate'];
+ $info['quicktime']['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels'];
+ $info['quicktime']['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth'];
+ $info['audio']['codec'] = $info['quicktime']['audio']['codec'];
+ $info['audio']['sample_rate'] = $info['quicktime']['audio']['sample_rate'];
+ $info['audio']['channels'] = $info['quicktime']['audio']['channels'];
+ $info['audio']['bits_per_sample'] = $info['quicktime']['audio']['bit_depth'];
+ switch ($atom_structure['sample_description_table'][$i]['data_format']) {
+ case 'raw ': // PCM
+ case 'alac': // Apple Lossless Audio Codec
+ $info['audio']['lossless'] = true;
+ break;
+ default:
+ $info['audio']['lossless'] = false;
+ break;
+ }
+ break;
+ }
+ break;
+
+ default:
+ switch ($atom_structure['sample_description_table'][$i]['data_format']) {
+ case 'mp4s':
+ $info['fileformat'] = 'mp4';
+ break;
+
+ default:
+ // video atom
+ $atom_structure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));
+ $atom_structure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));
+ $atom_structure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));
+ $atom_structure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));
+ $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4));
+ $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));
+ $atom_structure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));
+ $atom_structure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 2));
+ $atom_structure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 34, 1));
+ $atom_structure['sample_description_table'][$i]['video_encoder_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 35, $atom_structure['sample_description_table'][$i]['video_encoder_name_len']);
+ $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2));
+ $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2));
+
+ $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color');
+ $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']);
+
+ if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') {
+ $info['quicktime']['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
+ $info['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
+ $info['quicktime']['video']['codec'] = (($atom_structure['sample_description_table'][$i]['video_encoder_name_len'] > 0) ? $atom_structure['sample_description_table'][$i]['video_encoder_name'] : $atom_structure['sample_description_table'][$i]['data_format']);
+ $info['quicktime']['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'];
+ $info['quicktime']['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name'];
+
+ $info['video']['codec'] = $info['quicktime']['video']['codec'];
+ $info['video']['bits_per_sample'] = $info['quicktime']['video']['color_depth'];
+ }
+ $info['video']['lossless'] = false;
+ $info['video']['pixel_aspect_ratio'] = (float) 1;
+ break;
+ }
+ break;
+ }
+ switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) {
+ case 'mp4a':
+ $info['audio']['dataformat'] = 'mp4';
+ $info['quicktime']['audio']['codec'] = 'mp4';
+ break;
+
+ case '3ivx':
+ case '3iv1':
+ case '3iv2':
+ $info['video']['dataformat'] = '3ivx';
+ break;
+
+ case 'xvid':
+ $info['video']['dataformat'] = 'xvid';
+ break;
+
+ case 'mp4v':
+ $info['video']['dataformat'] = 'mpeg4';
+ break;
+
+ case 'divx':
+ case 'div1':
+ case 'div2':
+ case 'div3':
+ case 'div4':
+ case 'div5':
+ case 'div6':
+ $info['video']['dataformat'] = 'divx';
+ break;
+
+ default:
+ // do nothing
+ break;
+ }
+ unset($atom_structure['sample_description_table'][$i]['data']);
+ }
+ break;
+
+
+ case 'stts': // Sample Table Time-to-Sample atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $sttsEntriesDataOffset = 8;
+ //$FrameRateCalculatorArray = array();
+ $frames_count = 0;
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
+ $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
+ $sttsEntriesDataOffset += 4;
+ $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
+ $sttsEntriesDataOffset += 4;
+
+ $frames_count += $atom_structure['time_to_sample_table'][$i]['sample_count'];
+
+ // THIS SECTION REPLACED WITH CODE IN "stbl" ATOM
+ //if (!empty($info['quicktime']['time_scale']) && ($atom_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) {
+ // $stts_new_framerate = $info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'];
+ // if ($stts_new_framerate <= 60) {
+ // // some atoms have durations of "1" giving a very large framerate, which probably is not right
+ // $info['video']['frame_rate'] = max($info['video']['frame_rate'], $stts_new_framerate);
+ // }
+ //}
+ //
+ //$FrameRateCalculatorArray[($info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count'];
+ }
+ $info['quicktime']['stts_framecount'][] = $frames_count;
+ //$sttsFramesTotal = 0;
+ //$sttsSecondsTotal = 0;
+ //foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) {
+ // if (($frames_per_second > 60) || ($frames_per_second < 1)) {
+ // // not video FPS information, probably audio information
+ // $sttsFramesTotal = 0;
+ // $sttsSecondsTotal = 0;
+ // break;
+ // }
+ // $sttsFramesTotal += $frame_count;
+ // $sttsSecondsTotal += $frame_count / $frames_per_second;
+ //}
+ //if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) {
+ // if (($sttsFramesTotal / $sttsSecondsTotal) > $info['video']['frame_rate']) {
+ // $info['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal;
+ // }
+ //}
+ break;
+
+
+ case 'stss': // Sample Table Sync Sample (key frames) atom
+ if ($ParseAllPossibleAtoms) {
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $stssEntriesDataOffset = 8;
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
+ $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stssEntriesDataOffset, 4));
+ $stssEntriesDataOffset += 4;
+ }
+ }
+ break;
+
+
+ case 'stsc': // Sample Table Sample-to-Chunk atom
+ if ($ParseAllPossibleAtoms) {
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $stscEntriesDataOffset = 8;
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
+ $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
+ $stscEntriesDataOffset += 4;
+ $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
+ $stscEntriesDataOffset += 4;
+ $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
+ $stscEntriesDataOffset += 4;
+ }
+ }
+ break;
+
+
+ case 'stsz': // Sample Table SiZe atom
+ if ($ParseAllPossibleAtoms) {
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
+ $stszEntriesDataOffset = 12;
+ if ($atom_structure['sample_size'] == 0) {
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
+ $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stszEntriesDataOffset, 4));
+ $stszEntriesDataOffset += 4;
+ }
+ }
+ }
+ break;
+
+
+ case 'stco': // Sample Table Chunk Offset atom
+ if ($ParseAllPossibleAtoms) {
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $stcoEntriesDataOffset = 8;
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
+ $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 4));
+ $stcoEntriesDataOffset += 4;
+ }
+ }
+ break;
+
+
+ case 'co64': // Chunk Offset 64-bit (version of "stco" that supports > 2GB files)
+ if ($ParseAllPossibleAtoms) {
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $stcoEntriesDataOffset = 8;
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
+ $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 8));
+ $stcoEntriesDataOffset += 8;
+ }
+ }
+ break;
+
+
+ case 'dref': // Data REFerence atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $drefDataOffset = 8;
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
+ $atom_structure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 4));
+ $drefDataOffset += 4;
+ $atom_structure['data_references'][$i]['type'] = substr($atom_data, $drefDataOffset, 4);
+ $drefDataOffset += 4;
+ $atom_structure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 1));
+ $drefDataOffset += 1;
+ $atom_structure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 3)); // hardcoded: 0x0000
+ $drefDataOffset += 3;
+ $atom_structure['data_references'][$i]['data'] = substr($atom_data, $drefDataOffset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));
+ $drefDataOffset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);
+
+ $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool) ($atom_structure['data_references'][$i]['flags_raw'] & 0x001);
+ }
+ break;
+
+
+ case 'gmin': // base Media INformation atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
+ $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
+ $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
+ $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
+ $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 2));
+ $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
+ break;
+
+
+ case 'smhd': // Sound Media information HeaDer atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
+ $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
+ break;
+
+
+ case 'vmhd': // Video Media information HeaDer atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
+ $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
+ $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
+ $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
+ $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
+
+ $atom_structure['flags']['no_lean_ahead'] = (bool) ($atom_structure['flags_raw'] & 0x001);
+ break;
+
+
+ case 'hdlr': // HanDLeR reference atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['component_type'] = substr($atom_data, 4, 4);
+ $atom_structure['component_subtype'] = substr($atom_data, 8, 4);
+ $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
+ $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
+ $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
+ $atom_structure['component_name'] = $this->Pascal2String(substr($atom_data, 24));
+
+ if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) {
+ $info['video']['dataformat'] = 'quicktimevr';
+ }
+ break;
+
+
+ case 'mdhd': // MeDia HeaDer atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
+ $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
+ $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
+ $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 2));
+ $atom_structure['quality'] = getid3_lib::BigEndian2Int(substr($atom_data, 22, 2));
+
+ if ($atom_structure['time_scale'] == 0) {
+ $info['error'][] = 'Corrupt Quicktime file: mdhd.time_scale == zero';
+ return false;
+ }
+ $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
+
+ $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
+ $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
+ $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
+ $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
+ if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
+ $info['comments']['language'][] = $atom_structure['language'];
+ }
+ break;
+
+
+ case 'pnot': // Preview atom
+ $atom_structure['modification_date'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // "standard Macintosh format"
+ $atom_structure['version_number'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x00
+ $atom_structure['atom_type'] = substr($atom_data, 6, 4); // usually: 'PICT'
+ $atom_structure['atom_index'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); // usually: 0x01
+
+ $atom_structure['modification_date_unix'] = getid3_lib::DateMac2Unix($atom_structure['modification_date']);
+ break;
+
+
+ case 'crgn': // Clipping ReGioN atom
+ $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box,
+ $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields
+ $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region.
+ break;
+
+
+ case 'load': // track LOAD settings atom
+ $atom_structure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
+ $atom_structure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $atom_structure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
+ $atom_structure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
+
+ $atom_structure['default_hints']['double_buffer'] = (bool) ($atom_structure['default_hints_raw'] & 0x0020);
+ $atom_structure['default_hints']['high_quality'] = (bool) ($atom_structure['default_hints_raw'] & 0x0100);
+ break;
+
+
+ case 'tmcd': // TiMe CoDe atom
+ case 'chap': // CHAPter list atom
+ case 'sync': // SYNChronization atom
+ case 'scpt': // tranSCriPT atom
+ case 'ssrc': // non-primary SouRCe atom
+ for ($i = 0; $i < (strlen($atom_data) % 4); $i++) {
+ $atom_structure['track_id'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $i * 4, 4));
+ }
+ break;
+
+
+ case 'elst': // Edit LiST atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) {
+ $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4));
+ $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4));
+ $atom_structure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4));
+ }
+ break;
+
+
+ case 'kmat': // compressed MATte atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
+ $atom_structure['matte_data_raw'] = substr($atom_data, 4);
+ break;
+
+
+ case 'ctab': // Color TABle atom
+ $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000
+ $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000
+ $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1;
+ for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) {
+ $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2));
+ $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2));
+ $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2));
+ $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2));
+ }
+ break;
+
+
+ case 'mvhd': // MoVie HeaDer atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
+ $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
+ $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
+ $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
+ $atom_structure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 20, 4));
+ $atom_structure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 24, 2));
+ $atom_structure['reserved'] = substr($atom_data, 26, 10);
+ $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 36, 4));
+ $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
+ $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 44, 4));
+ $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4));
+ $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
+ $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 56, 4));
+ $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4));
+ $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));
+ $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4));
+ $atom_structure['preview_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 72, 4));
+ $atom_structure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 76, 4));
+ $atom_structure['poster_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 80, 4));
+ $atom_structure['selection_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 84, 4));
+ $atom_structure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 88, 4));
+ $atom_structure['current_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 92, 4));
+ $atom_structure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 96, 4));
+
+ if ($atom_structure['time_scale'] == 0) {
+ $info['error'][] = 'Corrupt Quicktime file: mvhd.time_scale == zero';
+ return false;
+ }
+ $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
+ $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
+ $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
+ $info['quicktime']['display_scale'] = $atom_structure['matrix_a'];
+ $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
+ break;
+
+
+ case 'tkhd': // TracK HeaDer atom
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
+ $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
+ $atom_structure['trackid'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
+ $atom_structure['reserved1'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
+ $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
+ $atom_structure['reserved2'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 8));
+ $atom_structure['layer'] = getid3_lib::BigEndian2Int(substr($atom_data, 32, 2));
+ $atom_structure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atom_data, 34, 2));
+ $atom_structure['volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 36, 2));
+ $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2));
+ $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
+ $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 44, 4));
+ $atom_structure['matrix_u'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4));
+ $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
+ $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 56, 4));
+ $atom_structure['matrix_v'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4));
+ $atom_structure['matrix_x'] = getid3_lib::FixedPoint2_30(substr($atom_data, 64, 4));
+ $atom_structure['matrix_y'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4));
+ $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 72, 4));
+ $atom_structure['width'] = getid3_lib::FixedPoint16_16(substr($atom_data, 76, 4));
+ $atom_structure['height'] = getid3_lib::FixedPoint16_16(substr($atom_data, 80, 4));
+
+ $atom_structure['flags']['enabled'] = (bool) ($atom_structure['flags_raw'] & 0x0001);
+ $atom_structure['flags']['in_movie'] = (bool) ($atom_structure['flags_raw'] & 0x0002);
+ $atom_structure['flags']['in_preview'] = (bool) ($atom_structure['flags_raw'] & 0x0004);
+ $atom_structure['flags']['in_poster'] = (bool) ($atom_structure['flags_raw'] & 0x0008);
+ $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
+ $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
+
+ if ($atom_structure['flags']['enabled'] == 1) {
+ if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) {
+ $info['video']['resolution_x'] = $atom_structure['width'];
+ $info['video']['resolution_y'] = $atom_structure['height'];
+ }
+ $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']);
+ $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']);
+ $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];
+ $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];
+ } else {
+ if (isset($info['video']['resolution_x'])) { unset($info['video']['resolution_x']); }
+ if (isset($info['video']['resolution_y'])) { unset($info['video']['resolution_y']); }
+ if (isset($info['quicktime']['video'])) { unset($info['quicktime']['video']); }
+ }
+ break;
+
+
+ case 'iods': // Initial Object DeScriptor atom
+ // http://www.koders.com/c/fid1FAB3E762903DC482D8A246D4A4BF9F28E049594.aspx?s=windows.h
+ // http://libquicktime.sourcearchive.com/documentation/1.0.2plus-pdebian/iods_8c-source.html
+ $offset = 0;
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
+ $offset += 1;
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 3));
+ $offset += 3;
+ $atom_structure['mp4_iod_tag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
+ $offset += 1;
+ $atom_structure['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
+ //$offset already adjusted by quicktime_read_mp4_descr_length()
+ $atom_structure['object_descriptor_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2));
+ $offset += 2;
+ $atom_structure['od_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
+ $offset += 1;
+ $atom_structure['scene_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
+ $offset += 1;
+ $atom_structure['audio_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
+ $offset += 1;
+ $atom_structure['video_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
+ $offset += 1;
+ $atom_structure['graphics_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
+ $offset += 1;
+
+ $atom_structure['num_iods_tracks'] = ($atom_structure['length'] - 7) / 6; // 6 bytes would only be right if all tracks use 1-byte length fields
+ for ($i = 0; $i < $atom_structure['num_iods_tracks']; $i++) {
+ $atom_structure['track'][$i]['ES_ID_IncTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
+ $offset += 1;
+ $atom_structure['track'][$i]['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
+ //$offset already adjusted by quicktime_read_mp4_descr_length()
+ $atom_structure['track'][$i]['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4));
+ $offset += 4;
+ }
+
+ $atom_structure['audio_profile_name'] = $this->QuicktimeIODSaudioProfileName($atom_structure['audio_profile_id']);
+ $atom_structure['video_profile_name'] = $this->QuicktimeIODSvideoProfileName($atom_structure['video_profile_id']);
+ break;
+
+ case 'ftyp': // FileTYPe (?) atom (for MP4 it seems)
+ $atom_structure['signature'] = substr($atom_data, 0, 4);
+ $atom_structure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
+ $atom_structure['fourcc'] = substr($atom_data, 8, 4);
+ break;
+
+ case 'mdat': // Media DATa atom
+ case 'free': // FREE space atom
+ case 'skip': // SKIP atom
+ case 'wide': // 64-bit expansion placeholder atom
+ // 'mdat' data is too big to deal with, contains no useful metadata
+ // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
+
+ // When writing QuickTime files, it is sometimes necessary to update an atom's size.
+ // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom
+ // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime
+ // puts an 8-byte placeholder atom before any atoms it may have to update the size of.
+ // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the
+ // placeholder atom can be overwritten to obtain the necessary 8 extra bytes.
+ // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ).
+ break;
+
+
+ case 'nsav': // NoSAVe atom
+ // http://developer.apple.com/technotes/tn/tn2038.html
+ $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
+ break;
+
+ case 'ctyp': // Controller TYPe atom (seen on QTVR)
+ // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt
+ // some controller names are:
+ // 0x00 + 'std' for linear movie
+ // 'none' for no controls
+ $atom_structure['ctyp'] = substr($atom_data, 0, 4);
+ $info['quicktime']['controller'] = $atom_structure['ctyp'];
+ switch ($atom_structure['ctyp']) {
+ case 'qtvr':
+ $info['video']['dataformat'] = 'quicktimevr';
+ break;
+ }
+ break;
+
+ case 'pano': // PANOrama track (seen on QTVR)
+ $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
+ break;
+
+ case 'hint': // HINT track
+ case 'hinf': //
+ case 'hinv': //
+ case 'hnti': //
+ $info['quicktime']['hinting'] = true;
+ break;
+
+ case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR)
+ for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) {
+ $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));
+ }
+ break;
+
+
+ // Observed-but-not-handled atom types are just listed here to prevent warnings being generated
+ case 'FXTC': // Something to do with Adobe After Effects (?)
+ case 'PrmA':
+ case 'code':
+ case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
+ case 'tapt': // TrackApertureModeDimensionsAID - http://developer.apple.com/documentation/QuickTime/Reference/QT7-1_Update_Reference/Constants/Constants.html
+ // tapt seems to be used to compute the video size [http://www.getid3.org/phpBB3/viewtopic.php?t=838]
+ // * http://lists.apple.com/archives/quicktime-api/2006/Aug/msg00014.html
+ // * http://handbrake.fr/irclogs/handbrake-dev/handbrake-dev20080128_pg2.html
+ case 'ctts':// STCompositionOffsetAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
+ case 'cslg':// STCompositionShiftLeastGreatestAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
+ case 'sdtp':// STSampleDependencyAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
+ case 'stps':// STPartialSyncSampleAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
+ //$atom_structure['data'] = $atom_data;
+ break;
+
+ case '©xyz': // GPS latitude+longitude+altitude
+ $atom_structure['data'] = $atom_data;
+ if (preg_match('#([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)?/$#i', $atom_data, $matches)) {
+ @list($all, $latitude, $longitude, $altitude) = $matches;
+ $info['quicktime']['comments']['gps_latitude'][] = floatval($latitude);
+ $info['quicktime']['comments']['gps_longitude'][] = floatval($longitude);
+ if (!empty($altitude)) {
+ $info['quicktime']['comments']['gps_altitude'][] = floatval($altitude);
+ }
+ } else {
+ $info['warning'][] = 'QuickTime atom "©xyz" data does not match expected data pattern at offset '.$baseoffset.'. Please report as getID3() bug.';
+ }
+ break;
+
+ case 'NCDT':
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
+ // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 4, $atomHierarchy, $ParseAllPossibleAtoms);
+ break;
+ case 'NCTH': // Nikon Camera THumbnail image
+ case 'NCVW': // Nikon Camera preVieW image
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
+ if (preg_match('/^\xFF\xD8\xFF/', $atom_data)) {
+ $atom_structure['data'] = $atom_data;
+ $atom_structure['image_mime'] = 'image/jpeg';
+ $atom_structure['description'] = (($atomname == 'NCTH') ? 'Nikon Camera Thumbnail Image' : (($atomname == 'NCVW') ? 'Nikon Camera Preview Image' : 'Nikon preview image'));
+ $info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_data, 'description'=>$atom_structure['description']);
+ }
+ break;
+ case 'NCHD': // MakerNoteVersion
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
+ $atom_structure['data'] = $atom_data;
+ break;
+ case 'NCTG': // NikonTags
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
+ $atom_structure['data'] = $this->QuicktimeParseNikonNCTG($atom_data);
+ break;
+ case 'NCDB': // NikonTags
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
+ $atom_structure['data'] = $atom_data;
+ break;
+
+ case "\x00\x00\x00\x00":
+ case 'meta': // METAdata atom
+ // some kind of metacontainer, may contain a big data dump such as:
+ // mdta keys  mdtacom.apple.quicktime.make (mdtacom.apple.quicktime.creationdate ,mdtacom.apple.quicktime.location.ISO6709 $mdtacom.apple.quicktime.software !mdtacom.apple.quicktime.model ilst   data DEApple 0  (data DE2011-05-11T17:54:04+0200 2  *data DE+52.4936+013.3897+040.247/   data DE4.3.1  data DEiPhone 4
+ // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
+
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_data, 4), $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
+ //$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
+ break;
+
+ case 'data': // metaDATA atom
+ // seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in sample I have), remainder is useful data
+ $atom_structure['language'] = substr($atom_data, 4 + 0, 2);
+ $atom_structure['unknown'] = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2));
+ $atom_structure['data'] = substr($atom_data, 4 + 4);
+ break;
+
+ default:
+ $info['warning'][] = 'Unknown QuickTime atom type: "'.getid3_lib::PrintHexBytes($atomname).'" at offset '.$baseoffset;
+ $atom_structure['data'] = $atom_data;
+ break;
+ }
+ array_pop($atomHierarchy);
+ return $atom_structure;
+ }
+
+ function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
+//echo 'QuicktimeParseContainerAtom('.substr($atom_data, 4, 4).') @ '.$baseoffset.'<br><br>';
+ $atom_structure = false;
+ $subatomoffset = 0;
+ $subatomcounter = 0;
+ if ((strlen($atom_data) == 4) && (getid3_lib::BigEndian2Int($atom_data) == 0x00000000)) {
+ return false;
+ }
+ while ($subatomoffset < strlen($atom_data)) {
+ $subatomsize = getid3_lib::BigEndian2Int(substr($atom_data, $subatomoffset + 0, 4));
+ $subatomname = substr($atom_data, $subatomoffset + 4, 4);
+ $subatomdata = substr($atom_data, $subatomoffset + 8, $subatomsize - 8);
+ if ($subatomsize == 0) {
+ // Furthermore, for historical reasons the list of atoms is optionally
+ // terminated by a 32-bit integer set to 0. If you are writing a program
+ // to read user data atoms, you should allow for the terminating 0.
+ return $atom_structure;
+ }
+
+ $atom_structure[$subatomcounter] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms);
+
+ $subatomoffset += $subatomsize;
+ $subatomcounter++;
+ }
+ return $atom_structure;
+ }
+
+
+ function quicktime_read_mp4_descr_length($data, &$offset) {
+ // http://libquicktime.sourcearchive.com/documentation/2:1.0.2plus-pdebian-2build1/esds_8c-source.html
+ $num_bytes = 0;
+ $length = 0;
+ do {
+ $b = ord(substr($data, $offset++, 1));
+ $length = ($length << 7) | ($b & 0x7F);
+ } while (($b & 0x80) && ($num_bytes++ < 4));
+ return $length;
+ }
+
+
+ function QuicktimeLanguageLookup($languageid) {
+ static $QuicktimeLanguageLookup = array();
+ if (empty($QuicktimeLanguageLookup)) {
+ $QuicktimeLanguageLookup[0] = 'English';
+ $QuicktimeLanguageLookup[1] = 'French';
+ $QuicktimeLanguageLookup[2] = 'German';
+ $QuicktimeLanguageLookup[3] = 'Italian';
+ $QuicktimeLanguageLookup[4] = 'Dutch';
+ $QuicktimeLanguageLookup[5] = 'Swedish';
+ $QuicktimeLanguageLookup[6] = 'Spanish';
+ $QuicktimeLanguageLookup[7] = 'Danish';
+ $QuicktimeLanguageLookup[8] = 'Portuguese';
+ $QuicktimeLanguageLookup[9] = 'Norwegian';
+ $QuicktimeLanguageLookup[10] = 'Hebrew';
+ $QuicktimeLanguageLookup[11] = 'Japanese';
+ $QuicktimeLanguageLookup[12] = 'Arabic';
+ $QuicktimeLanguageLookup[13] = 'Finnish';
+ $QuicktimeLanguageLookup[14] = 'Greek';
+ $QuicktimeLanguageLookup[15] = 'Icelandic';
+ $QuicktimeLanguageLookup[16] = 'Maltese';
+ $QuicktimeLanguageLookup[17] = 'Turkish';
+ $QuicktimeLanguageLookup[18] = 'Croatian';
+ $QuicktimeLanguageLookup[19] = 'Chinese (Traditional)';
+ $QuicktimeLanguageLookup[20] = 'Urdu';
+ $QuicktimeLanguageLookup[21] = 'Hindi';
+ $QuicktimeLanguageLookup[22] = 'Thai';
+ $QuicktimeLanguageLookup[23] = 'Korean';
+ $QuicktimeLanguageLookup[24] = 'Lithuanian';
+ $QuicktimeLanguageLookup[25] = 'Polish';
+ $QuicktimeLanguageLookup[26] = 'Hungarian';
+ $QuicktimeLanguageLookup[27] = 'Estonian';
+ $QuicktimeLanguageLookup[28] = 'Lettish';
+ $QuicktimeLanguageLookup[28] = 'Latvian';
+ $QuicktimeLanguageLookup[29] = 'Saamisk';
+ $QuicktimeLanguageLookup[29] = 'Lappish';
+ $QuicktimeLanguageLookup[30] = 'Faeroese';
+ $QuicktimeLanguageLookup[31] = 'Farsi';
+ $QuicktimeLanguageLookup[31] = 'Persian';
+ $QuicktimeLanguageLookup[32] = 'Russian';
+ $QuicktimeLanguageLookup[33] = 'Chinese (Simplified)';
+ $QuicktimeLanguageLookup[34] = 'Flemish';
+ $QuicktimeLanguageLookup[35] = 'Irish';
+ $QuicktimeLanguageLookup[36] = 'Albanian';
+ $QuicktimeLanguageLookup[37] = 'Romanian';
+ $QuicktimeLanguageLookup[38] = 'Czech';
+ $QuicktimeLanguageLookup[39] = 'Slovak';
+ $QuicktimeLanguageLookup[40] = 'Slovenian';
+ $QuicktimeLanguageLookup[41] = 'Yiddish';
+ $QuicktimeLanguageLookup[42] = 'Serbian';
+ $QuicktimeLanguageLookup[43] = 'Macedonian';
+ $QuicktimeLanguageLookup[44] = 'Bulgarian';
+ $QuicktimeLanguageLookup[45] = 'Ukrainian';
+ $QuicktimeLanguageLookup[46] = 'Byelorussian';
+ $QuicktimeLanguageLookup[47] = 'Uzbek';
+ $QuicktimeLanguageLookup[48] = 'Kazakh';
+ $QuicktimeLanguageLookup[49] = 'Azerbaijani';
+ $QuicktimeLanguageLookup[50] = 'AzerbaijanAr';
+ $QuicktimeLanguageLookup[51] = 'Armenian';
+ $QuicktimeLanguageLookup[52] = 'Georgian';
+ $QuicktimeLanguageLookup[53] = 'Moldavian';
+ $QuicktimeLanguageLookup[54] = 'Kirghiz';
+ $QuicktimeLanguageLookup[55] = 'Tajiki';
+ $QuicktimeLanguageLookup[56] = 'Turkmen';
+ $QuicktimeLanguageLookup[57] = 'Mongolian';
+ $QuicktimeLanguageLookup[58] = 'MongolianCyr';
+ $QuicktimeLanguageLookup[59] = 'Pashto';
+ $QuicktimeLanguageLookup[60] = 'Kurdish';
+ $QuicktimeLanguageLookup[61] = 'Kashmiri';
+ $QuicktimeLanguageLookup[62] = 'Sindhi';
+ $QuicktimeLanguageLookup[63] = 'Tibetan';
+ $QuicktimeLanguageLookup[64] = 'Nepali';
+ $QuicktimeLanguageLookup[65] = 'Sanskrit';
+ $QuicktimeLanguageLookup[66] = 'Marathi';
+ $QuicktimeLanguageLookup[67] = 'Bengali';
+ $QuicktimeLanguageLookup[68] = 'Assamese';
+ $QuicktimeLanguageLookup[69] = 'Gujarati';
+ $QuicktimeLanguageLookup[70] = 'Punjabi';
+ $QuicktimeLanguageLookup[71] = 'Oriya';
+ $QuicktimeLanguageLookup[72] = 'Malayalam';
+ $QuicktimeLanguageLookup[73] = 'Kannada';
+ $QuicktimeLanguageLookup[74] = 'Tamil';
+ $QuicktimeLanguageLookup[75] = 'Telugu';
+ $QuicktimeLanguageLookup[76] = 'Sinhalese';
+ $QuicktimeLanguageLookup[77] = 'Burmese';
+ $QuicktimeLanguageLookup[78] = 'Khmer';
+ $QuicktimeLanguageLookup[79] = 'Lao';
+ $QuicktimeLanguageLookup[80] = 'Vietnamese';
+ $QuicktimeLanguageLookup[81] = 'Indonesian';
+ $QuicktimeLanguageLookup[82] = 'Tagalog';
+ $QuicktimeLanguageLookup[83] = 'MalayRoman';
+ $QuicktimeLanguageLookup[84] = 'MalayArabic';
+ $QuicktimeLanguageLookup[85] = 'Amharic';
+ $QuicktimeLanguageLookup[86] = 'Tigrinya';
+ $QuicktimeLanguageLookup[87] = 'Galla';
+ $QuicktimeLanguageLookup[87] = 'Oromo';
+ $QuicktimeLanguageLookup[88] = 'Somali';
+ $QuicktimeLanguageLookup[89] = 'Swahili';
+ $QuicktimeLanguageLookup[90] = 'Ruanda';
+ $QuicktimeLanguageLookup[91] = 'Rundi';
+ $QuicktimeLanguageLookup[92] = 'Chewa';
+ $QuicktimeLanguageLookup[93] = 'Malagasy';
+ $QuicktimeLanguageLookup[94] = 'Esperanto';
+ $QuicktimeLanguageLookup[128] = 'Welsh';
+ $QuicktimeLanguageLookup[129] = 'Basque';
+ $QuicktimeLanguageLookup[130] = 'Catalan';
+ $QuicktimeLanguageLookup[131] = 'Latin';
+ $QuicktimeLanguageLookup[132] = 'Quechua';
+ $QuicktimeLanguageLookup[133] = 'Guarani';
+ $QuicktimeLanguageLookup[134] = 'Aymara';
+ $QuicktimeLanguageLookup[135] = 'Tatar';
+ $QuicktimeLanguageLookup[136] = 'Uighur';
+ $QuicktimeLanguageLookup[137] = 'Dzongkha';
+ $QuicktimeLanguageLookup[138] = 'JavaneseRom';
+ }
+ return (isset($QuicktimeLanguageLookup[$languageid]) ? $QuicktimeLanguageLookup[$languageid] : 'invalid');
+ }
+
+ function QuicktimeVideoCodecLookup($codecid) {
+ static $QuicktimeVideoCodecLookup = array();
+ if (empty($QuicktimeVideoCodecLookup)) {
+ $QuicktimeVideoCodecLookup['.SGI'] = 'SGI';
+ $QuicktimeVideoCodecLookup['3IV1'] = '3ivx MPEG-4 v1';
+ $QuicktimeVideoCodecLookup['3IV2'] = '3ivx MPEG-4 v2';
+ $QuicktimeVideoCodecLookup['3IVX'] = '3ivx MPEG-4';
+ $QuicktimeVideoCodecLookup['8BPS'] = 'Planar RGB';
+ $QuicktimeVideoCodecLookup['avc1'] = 'H.264/MPEG-4 AVC';
+ $QuicktimeVideoCodecLookup['avr '] = 'AVR-JPEG';
+ $QuicktimeVideoCodecLookup['b16g'] = '16Gray';
+ $QuicktimeVideoCodecLookup['b32a'] = '32AlphaGray';
+ $QuicktimeVideoCodecLookup['b48r'] = '48RGB';
+ $QuicktimeVideoCodecLookup['b64a'] = '64ARGB';
+ $QuicktimeVideoCodecLookup['base'] = 'Base';
+ $QuicktimeVideoCodecLookup['clou'] = 'Cloud';
+ $QuicktimeVideoCodecLookup['cmyk'] = 'CMYK';
+ $QuicktimeVideoCodecLookup['cvid'] = 'Cinepak';
+ $QuicktimeVideoCodecLookup['dmb1'] = 'OpenDML JPEG';
+ $QuicktimeVideoCodecLookup['dvc '] = 'DVC-NTSC';
+ $QuicktimeVideoCodecLookup['dvcp'] = 'DVC-PAL';
+ $QuicktimeVideoCodecLookup['dvpn'] = 'DVCPro-NTSC';
+ $QuicktimeVideoCodecLookup['dvpp'] = 'DVCPro-PAL';
+ $QuicktimeVideoCodecLookup['fire'] = 'Fire';
+ $QuicktimeVideoCodecLookup['flic'] = 'FLC';
+ $QuicktimeVideoCodecLookup['gif '] = 'GIF';
+ $QuicktimeVideoCodecLookup['h261'] = 'H261';
+ $QuicktimeVideoCodecLookup['h263'] = 'H263';
+ $QuicktimeVideoCodecLookup['IV41'] = 'Indeo4';
+ $QuicktimeVideoCodecLookup['jpeg'] = 'JPEG';
+ $QuicktimeVideoCodecLookup['kpcd'] = 'PhotoCD';
+ $QuicktimeVideoCodecLookup['mjpa'] = 'Motion JPEG-A';
+ $QuicktimeVideoCodecLookup['mjpb'] = 'Motion JPEG-B';
+ $QuicktimeVideoCodecLookup['msvc'] = 'Microsoft Video1';
+ $QuicktimeVideoCodecLookup['myuv'] = 'MPEG YUV420';
+ $QuicktimeVideoCodecLookup['path'] = 'Vector';
+ $QuicktimeVideoCodecLookup['png '] = 'PNG';
+ $QuicktimeVideoCodecLookup['PNTG'] = 'MacPaint';
+ $QuicktimeVideoCodecLookup['qdgx'] = 'QuickDrawGX';
+ $QuicktimeVideoCodecLookup['qdrw'] = 'QuickDraw';
+ $QuicktimeVideoCodecLookup['raw '] = 'RAW';
+ $QuicktimeVideoCodecLookup['ripl'] = 'WaterRipple';
+ $QuicktimeVideoCodecLookup['rpza'] = 'Video';
+ $QuicktimeVideoCodecLookup['smc '] = 'Graphics';
+ $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 1';
+ $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 3';
+ $QuicktimeVideoCodecLookup['syv9'] = 'Sorenson YUV9';
+ $QuicktimeVideoCodecLookup['tga '] = 'Targa';
+ $QuicktimeVideoCodecLookup['tiff'] = 'TIFF';
+ $QuicktimeVideoCodecLookup['WRAW'] = 'Windows RAW';
+ $QuicktimeVideoCodecLookup['WRLE'] = 'BMP';
+ $QuicktimeVideoCodecLookup['y420'] = 'YUV420';
+ $QuicktimeVideoCodecLookup['yuv2'] = 'ComponentVideo';
+ $QuicktimeVideoCodecLookup['yuvs'] = 'ComponentVideoUnsigned';
+ $QuicktimeVideoCodecLookup['yuvu'] = 'ComponentVideoSigned';
+ }
+ return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : '');
+ }
+
+ function QuicktimeAudioCodecLookup($codecid) {
+ static $QuicktimeAudioCodecLookup = array();
+ if (empty($QuicktimeAudioCodecLookup)) {
+ $QuicktimeAudioCodecLookup['.mp3'] = 'Fraunhofer MPEG Layer-III alias';
+ $QuicktimeAudioCodecLookup['aac '] = 'ISO/IEC 14496-3 AAC';
+ $QuicktimeAudioCodecLookup['agsm'] = 'Apple GSM 10:1';
+ $QuicktimeAudioCodecLookup['alac'] = 'Apple Lossless Audio Codec';
+ $QuicktimeAudioCodecLookup['alaw'] = 'A-law 2:1';
+ $QuicktimeAudioCodecLookup['conv'] = 'Sample Format';
+ $QuicktimeAudioCodecLookup['dvca'] = 'DV';
+ $QuicktimeAudioCodecLookup['dvi '] = 'DV 4:1';
+ $QuicktimeAudioCodecLookup['eqal'] = 'Frequency Equalizer';
+ $QuicktimeAudioCodecLookup['fl32'] = '32-bit Floating Point';
+ $QuicktimeAudioCodecLookup['fl64'] = '64-bit Floating Point';
+ $QuicktimeAudioCodecLookup['ima4'] = 'Interactive Multimedia Association 4:1';
+ $QuicktimeAudioCodecLookup['in24'] = '24-bit Integer';
+ $QuicktimeAudioCodecLookup['in32'] = '32-bit Integer';
+ $QuicktimeAudioCodecLookup['lpc '] = 'LPC 23:1';
+ $QuicktimeAudioCodecLookup['MAC3'] = 'Macintosh Audio Compression/Expansion (MACE) 3:1';
+ $QuicktimeAudioCodecLookup['MAC6'] = 'Macintosh Audio Compression/Expansion (MACE) 6:1';
+ $QuicktimeAudioCodecLookup['mixb'] = '8-bit Mixer';
+ $QuicktimeAudioCodecLookup['mixw'] = '16-bit Mixer';
+ $QuicktimeAudioCodecLookup['mp4a'] = 'ISO/IEC 14496-3 AAC';
+ $QuicktimeAudioCodecLookup['MS'."\x00\x02"] = 'Microsoft ADPCM';
+ $QuicktimeAudioCodecLookup['MS'."\x00\x11"] = 'DV IMA';
+ $QuicktimeAudioCodecLookup['MS'."\x00\x55"] = 'Fraunhofer MPEG Layer III';
+ $QuicktimeAudioCodecLookup['NONE'] = 'No Encoding';
+ $QuicktimeAudioCodecLookup['Qclp'] = 'Qualcomm PureVoice';
+ $QuicktimeAudioCodecLookup['QDM2'] = 'QDesign Music 2';
+ $QuicktimeAudioCodecLookup['QDMC'] = 'QDesign Music 1';
+ $QuicktimeAudioCodecLookup['ratb'] = '8-bit Rate';
+ $QuicktimeAudioCodecLookup['ratw'] = '16-bit Rate';
+ $QuicktimeAudioCodecLookup['raw '] = 'raw PCM';
+ $QuicktimeAudioCodecLookup['sour'] = 'Sound Source';
+ $QuicktimeAudioCodecLookup['sowt'] = 'signed/two\'s complement (Little Endian)';
+ $QuicktimeAudioCodecLookup['str1'] = 'Iomega MPEG layer II';
+ $QuicktimeAudioCodecLookup['str2'] = 'Iomega MPEG *layer II';
+ $QuicktimeAudioCodecLookup['str3'] = 'Iomega MPEG **layer II';
+ $QuicktimeAudioCodecLookup['str4'] = 'Iomega MPEG ***layer II';
+ $QuicktimeAudioCodecLookup['twos'] = 'signed/two\'s complement (Big Endian)';
+ $QuicktimeAudioCodecLookup['ulaw'] = 'mu-law 2:1';
+ }
+ return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : '');
+ }
+
+ function QuicktimeDCOMLookup($compressionid) {
+ static $QuicktimeDCOMLookup = array();
+ if (empty($QuicktimeDCOMLookup)) {
+ $QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate';
+ $QuicktimeDCOMLookup['adec'] = 'Apple Compression';
+ }
+ return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : '');
+ }
+
+ function QuicktimeColorNameLookup($colordepthid) {
+ static $QuicktimeColorNameLookup = array();
+ if (empty($QuicktimeColorNameLookup)) {
+ $QuicktimeColorNameLookup[1] = '2-color (monochrome)';
+ $QuicktimeColorNameLookup[2] = '4-color';
+ $QuicktimeColorNameLookup[4] = '16-color';
+ $QuicktimeColorNameLookup[8] = '256-color';
+ $QuicktimeColorNameLookup[16] = 'thousands (16-bit color)';
+ $QuicktimeColorNameLookup[24] = 'millions (24-bit color)';
+ $QuicktimeColorNameLookup[32] = 'millions+ (32-bit color)';
+ $QuicktimeColorNameLookup[33] = 'black & white';
+ $QuicktimeColorNameLookup[34] = '4-gray';
+ $QuicktimeColorNameLookup[36] = '16-gray';
+ $QuicktimeColorNameLookup[40] = '256-gray';
+ }
+ return (isset($QuicktimeColorNameLookup[$colordepthid]) ? $QuicktimeColorNameLookup[$colordepthid] : 'invalid');
+ }
+
+ function QuicktimeSTIKLookup($stik) {
+ static $QuicktimeSTIKLookup = array();
+ if (empty($QuicktimeSTIKLookup)) {
+ $QuicktimeSTIKLookup[0] = 'Movie';
+ $QuicktimeSTIKLookup[1] = 'Normal';
+ $QuicktimeSTIKLookup[2] = 'Audiobook';
+ $QuicktimeSTIKLookup[5] = 'Whacked Bookmark';
+ $QuicktimeSTIKLookup[6] = 'Music Video';
+ $QuicktimeSTIKLookup[9] = 'Short Film';
+ $QuicktimeSTIKLookup[10] = 'TV Show';
+ $QuicktimeSTIKLookup[11] = 'Booklet';
+ $QuicktimeSTIKLookup[14] = 'Ringtone';
+ $QuicktimeSTIKLookup[21] = 'Podcast';
+ }
+ return (isset($QuicktimeSTIKLookup[$stik]) ? $QuicktimeSTIKLookup[$stik] : 'invalid');
+ }
+
+ function QuicktimeIODSaudioProfileName($audio_profile_id) {
+ static $QuicktimeIODSaudioProfileNameLookup = array();
+ if (empty($QuicktimeIODSaudioProfileNameLookup)) {
+ $QuicktimeIODSaudioProfileNameLookup = array(
+ 0x00 => 'ISO Reserved (0x00)',
+ 0x01 => 'Main Audio Profile @ Level 1',
+ 0x02 => 'Main Audio Profile @ Level 2',
+ 0x03 => 'Main Audio Profile @ Level 3',
+ 0x04 => 'Main Audio Profile @ Level 4',
+ 0x05 => 'Scalable Audio Profile @ Level 1',
+ 0x06 => 'Scalable Audio Profile @ Level 2',
+ 0x07 => 'Scalable Audio Profile @ Level 3',
+ 0x08 => 'Scalable Audio Profile @ Level 4',
+ 0x09 => 'Speech Audio Profile @ Level 1',
+ 0x0A => 'Speech Audio Profile @ Level 2',
+ 0x0B => 'Synthetic Audio Profile @ Level 1',
+ 0x0C => 'Synthetic Audio Profile @ Level 2',
+ 0x0D => 'Synthetic Audio Profile @ Level 3',
+ 0x0E => 'High Quality Audio Profile @ Level 1',
+ 0x0F => 'High Quality Audio Profile @ Level 2',
+ 0x10 => 'High Quality Audio Profile @ Level 3',
+ 0x11 => 'High Quality Audio Profile @ Level 4',
+ 0x12 => 'High Quality Audio Profile @ Level 5',
+ 0x13 => 'High Quality Audio Profile @ Level 6',
+ 0x14 => 'High Quality Audio Profile @ Level 7',
+ 0x15 => 'High Quality Audio Profile @ Level 8',
+ 0x16 => 'Low Delay Audio Profile @ Level 1',
+ 0x17 => 'Low Delay Audio Profile @ Level 2',
+ 0x18 => 'Low Delay Audio Profile @ Level 3',
+ 0x19 => 'Low Delay Audio Profile @ Level 4',
+ 0x1A => 'Low Delay Audio Profile @ Level 5',
+ 0x1B => 'Low Delay Audio Profile @ Level 6',
+ 0x1C => 'Low Delay Audio Profile @ Level 7',
+ 0x1D => 'Low Delay Audio Profile @ Level 8',
+ 0x1E => 'Natural Audio Profile @ Level 1',
+ 0x1F => 'Natural Audio Profile @ Level 2',
+ 0x20 => 'Natural Audio Profile @ Level 3',
+ 0x21 => 'Natural Audio Profile @ Level 4',
+ 0x22 => 'Mobile Audio Internetworking Profile @ Level 1',
+ 0x23 => 'Mobile Audio Internetworking Profile @ Level 2',
+ 0x24 => 'Mobile Audio Internetworking Profile @ Level 3',
+ 0x25 => 'Mobile Audio Internetworking Profile @ Level 4',
+ 0x26 => 'Mobile Audio Internetworking Profile @ Level 5',
+ 0x27 => 'Mobile Audio Internetworking Profile @ Level 6',
+ 0x28 => 'AAC Profile @ Level 1',
+ 0x29 => 'AAC Profile @ Level 2',
+ 0x2A => 'AAC Profile @ Level 4',
+ 0x2B => 'AAC Profile @ Level 5',
+ 0x2C => 'High Efficiency AAC Profile @ Level 2',
+ 0x2D => 'High Efficiency AAC Profile @ Level 3',
+ 0x2E => 'High Efficiency AAC Profile @ Level 4',
+ 0x2F => 'High Efficiency AAC Profile @ Level 5',
+ 0xFE => 'Not part of MPEG-4 audio profiles',
+ 0xFF => 'No audio capability required',
+ );
+ }
+ return (isset($QuicktimeIODSaudioProfileNameLookup[$audio_profile_id]) ? $QuicktimeIODSaudioProfileNameLookup[$audio_profile_id] : 'ISO Reserved / User Private');
+ }
+
+
+ function QuicktimeIODSvideoProfileName($video_profile_id) {
+ static $QuicktimeIODSvideoProfileNameLookup = array();
+ if (empty($QuicktimeIODSvideoProfileNameLookup)) {
+ $QuicktimeIODSvideoProfileNameLookup = array(
+ 0x00 => 'Reserved (0x00) Profile',
+ 0x01 => 'Simple Profile @ Level 1',
+ 0x02 => 'Simple Profile @ Level 2',
+ 0x03 => 'Simple Profile @ Level 3',
+ 0x08 => 'Simple Profile @ Level 0',
+ 0x10 => 'Simple Scalable Profile @ Level 0',
+ 0x11 => 'Simple Scalable Profile @ Level 1',
+ 0x12 => 'Simple Scalable Profile @ Level 2',
+ 0x15 => 'AVC/H264 Profile',
+ 0x21 => 'Core Profile @ Level 1',
+ 0x22 => 'Core Profile @ Level 2',
+ 0x32 => 'Main Profile @ Level 2',
+ 0x33 => 'Main Profile @ Level 3',
+ 0x34 => 'Main Profile @ Level 4',
+ 0x42 => 'N-bit Profile @ Level 2',
+ 0x51 => 'Scalable Texture Profile @ Level 1',
+ 0x61 => 'Simple Face Animation Profile @ Level 1',
+ 0x62 => 'Simple Face Animation Profile @ Level 2',
+ 0x63 => 'Simple FBA Profile @ Level 1',
+ 0x64 => 'Simple FBA Profile @ Level 2',
+ 0x71 => 'Basic Animated Texture Profile @ Level 1',
+ 0x72 => 'Basic Animated Texture Profile @ Level 2',
+ 0x81 => 'Hybrid Profile @ Level 1',
+ 0x82 => 'Hybrid Profile @ Level 2',
+ 0x91 => 'Advanced Real Time Simple Profile @ Level 1',
+ 0x92 => 'Advanced Real Time Simple Profile @ Level 2',
+ 0x93 => 'Advanced Real Time Simple Profile @ Level 3',
+ 0x94 => 'Advanced Real Time Simple Profile @ Level 4',
+ 0xA1 => 'Core Scalable Profile @ Level1',
+ 0xA2 => 'Core Scalable Profile @ Level2',
+ 0xA3 => 'Core Scalable Profile @ Level3',
+ 0xB1 => 'Advanced Coding Efficiency Profile @ Level 1',
+ 0xB2 => 'Advanced Coding Efficiency Profile @ Level 2',
+ 0xB3 => 'Advanced Coding Efficiency Profile @ Level 3',
+ 0xB4 => 'Advanced Coding Efficiency Profile @ Level 4',
+ 0xC1 => 'Advanced Core Profile @ Level 1',
+ 0xC2 => 'Advanced Core Profile @ Level 2',
+ 0xD1 => 'Advanced Scalable Texture @ Level1',
+ 0xD2 => 'Advanced Scalable Texture @ Level2',
+ 0xE1 => 'Simple Studio Profile @ Level 1',
+ 0xE2 => 'Simple Studio Profile @ Level 2',
+ 0xE3 => 'Simple Studio Profile @ Level 3',
+ 0xE4 => 'Simple Studio Profile @ Level 4',
+ 0xE5 => 'Core Studio Profile @ Level 1',
+ 0xE6 => 'Core Studio Profile @ Level 2',
+ 0xE7 => 'Core Studio Profile @ Level 3',
+ 0xE8 => 'Core Studio Profile @ Level 4',
+ 0xF0 => 'Advanced Simple Profile @ Level 0',
+ 0xF1 => 'Advanced Simple Profile @ Level 1',
+ 0xF2 => 'Advanced Simple Profile @ Level 2',
+ 0xF3 => 'Advanced Simple Profile @ Level 3',
+ 0xF4 => 'Advanced Simple Profile @ Level 4',
+ 0xF5 => 'Advanced Simple Profile @ Level 5',
+ 0xF7 => 'Advanced Simple Profile @ Level 3b',
+ 0xF8 => 'Fine Granularity Scalable Profile @ Level 0',
+ 0xF9 => 'Fine Granularity Scalable Profile @ Level 1',
+ 0xFA => 'Fine Granularity Scalable Profile @ Level 2',
+ 0xFB => 'Fine Granularity Scalable Profile @ Level 3',
+ 0xFC => 'Fine Granularity Scalable Profile @ Level 4',
+ 0xFD => 'Fine Granularity Scalable Profile @ Level 5',
+ 0xFE => 'Not part of MPEG-4 Visual profiles',
+ 0xFF => 'No visual capability required',
+ );
+ }
+ return (isset($QuicktimeIODSvideoProfileNameLookup[$video_profile_id]) ? $QuicktimeIODSvideoProfileNameLookup[$video_profile_id] : 'ISO Reserved Profile');
+ }
+
+
+ function QuicktimeContentRatingLookup($rtng) {
+ static $QuicktimeContentRatingLookup = array();
+ if (empty($QuicktimeContentRatingLookup)) {
+ $QuicktimeContentRatingLookup[0] = 'None';
+ $QuicktimeContentRatingLookup[2] = 'Clean';
+ $QuicktimeContentRatingLookup[4] = 'Explicit';
+ }
+ return (isset($QuicktimeContentRatingLookup[$rtng]) ? $QuicktimeContentRatingLookup[$rtng] : 'invalid');
+ }
+
+ function QuicktimeStoreAccountTypeLookup($akid) {
+ static $QuicktimeStoreAccountTypeLookup = array();
+ if (empty($QuicktimeStoreAccountTypeLookup)) {
+ $QuicktimeStoreAccountTypeLookup[0] = 'iTunes';
+ $QuicktimeStoreAccountTypeLookup[1] = 'AOL';
+ }
+ return (isset($QuicktimeStoreAccountTypeLookup[$akid]) ? $QuicktimeStoreAccountTypeLookup[$akid] : 'invalid');
+ }
+
+ function QuicktimeStoreFrontCodeLookup($sfid) {
+ static $QuicktimeStoreFrontCodeLookup = array();
+ if (empty($QuicktimeStoreFrontCodeLookup)) {
+ $QuicktimeStoreFrontCodeLookup[143460] = 'Australia';
+ $QuicktimeStoreFrontCodeLookup[143445] = 'Austria';
+ $QuicktimeStoreFrontCodeLookup[143446] = 'Belgium';
+ $QuicktimeStoreFrontCodeLookup[143455] = 'Canada';
+ $QuicktimeStoreFrontCodeLookup[143458] = 'Denmark';
+ $QuicktimeStoreFrontCodeLookup[143447] = 'Finland';
+ $QuicktimeStoreFrontCodeLookup[143442] = 'France';
+ $QuicktimeStoreFrontCodeLookup[143443] = 'Germany';
+ $QuicktimeStoreFrontCodeLookup[143448] = 'Greece';
+ $QuicktimeStoreFrontCodeLookup[143449] = 'Ireland';
+ $QuicktimeStoreFrontCodeLookup[143450] = 'Italy';
+ $QuicktimeStoreFrontCodeLookup[143462] = 'Japan';
+ $QuicktimeStoreFrontCodeLookup[143451] = 'Luxembourg';
+ $QuicktimeStoreFrontCodeLookup[143452] = 'Netherlands';
+ $QuicktimeStoreFrontCodeLookup[143461] = 'New Zealand';
+ $QuicktimeStoreFrontCodeLookup[143457] = 'Norway';
+ $QuicktimeStoreFrontCodeLookup[143453] = 'Portugal';
+ $QuicktimeStoreFrontCodeLookup[143454] = 'Spain';
+ $QuicktimeStoreFrontCodeLookup[143456] = 'Sweden';
+ $QuicktimeStoreFrontCodeLookup[143459] = 'Switzerland';
+ $QuicktimeStoreFrontCodeLookup[143444] = 'United Kingdom';
+ $QuicktimeStoreFrontCodeLookup[143441] = 'United States';
+ }
+ return (isset($QuicktimeStoreFrontCodeLookup[$sfid]) ? $QuicktimeStoreFrontCodeLookup[$sfid] : 'invalid');
+ }
+
+ function QuicktimeParseNikonNCTG($atom_data) {
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
+ // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
+ // Data is stored as records of:
+ // * 4 bytes record type
+ // * 2 bytes size of data field type:
+ // 0x0001 = flag (size field *= 1-byte)
+ // 0x0002 = char (size field *= 1-byte)
+ // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB
+ // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD
+ // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together
+ // 0x0007 = bytes (size field *= 1-byte), values are stored as ??????
+ // 0x0008 = ????? (size field *= 2-byte), values are stored as ??????
+ // * 2 bytes data size field
+ // * ? bytes data (string data may be null-padded; datestamp fields are in the format "2011:05:25 20:24:15")
+ // all integers are stored BigEndian
+
+ $NCTGtagName = array(
+ 0x00000001 => 'Make',
+ 0x00000002 => 'Model',
+ 0x00000003 => 'Software',
+ 0x00000011 => 'CreateDate',
+ 0x00000012 => 'DateTimeOriginal',
+ 0x00000013 => 'FrameCount',
+ 0x00000016 => 'FrameRate',
+ 0x00000022 => 'FrameWidth',
+ 0x00000023 => 'FrameHeight',
+ 0x00000032 => 'AudioChannels',
+ 0x00000033 => 'AudioBitsPerSample',
+ 0x00000034 => 'AudioSampleRate',
+ 0x02000001 => 'MakerNoteVersion',
+ 0x02000005 => 'WhiteBalance',
+ 0x0200000b => 'WhiteBalanceFineTune',
+ 0x0200001e => 'ColorSpace',
+ 0x02000023 => 'PictureControlData',
+ 0x02000024 => 'WorldTime',
+ 0x02000032 => 'UnknownInfo',
+ 0x02000083 => 'LensType',
+ 0x02000084 => 'Lens',
+ );
+
+ $offset = 0;
+ $datalength = strlen($atom_data);
+ $parsed = array();
+ while ($offset < $datalength) {
+//echo getid3_lib::PrintHexBytes(substr($atom_data, $offset, 4)).'<br>';
+ $record_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4)); $offset += 4;
+ $data_size_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2;
+ $data_size = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2;
+ switch ($data_size_type) {
+ case 0x0001: // 0x0001 = flag (size field *= 1-byte)
+ $data = getid3_lib::BigEndian2Int(substr($atom_data, $offset, $data_size * 1));
+ $offset += ($data_size * 1);
+ break;
+ case 0x0002: // 0x0002 = char (size field *= 1-byte)
+ $data = substr($atom_data, $offset, $data_size * 1);
+ $offset += ($data_size * 1);
+ $data = rtrim($data, "\x00");
+ break;
+ case 0x0003: // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB
+ $data = '';
+ for ($i = $data_size - 1; $i >= 0; $i--) {
+ $data .= substr($atom_data, $offset + ($i * 2), 2);
+ }
+ $data = getid3_lib::BigEndian2Int($data);
+ $offset += ($data_size * 2);
+ break;
+ case 0x0004: // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD
+ $data = '';
+ for ($i = $data_size - 1; $i >= 0; $i--) {
+ $data .= substr($atom_data, $offset + ($i * 4), 4);
+ }
+ $data = getid3_lib::BigEndian2Int($data);
+ $offset += ($data_size * 4);
+ break;
+ case 0x0005: // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together
+ $data = array();
+ for ($i = 0; $i < $data_size; $i++) {
+ $numerator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 0, 4));
+ $denomninator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 4, 4));
+ if ($denomninator == 0) {
+ $data[$i] = false;
+ } else {
+ $data[$i] = (double) $numerator / $denomninator;
+ }
+ }
+ $offset += (8 * $data_size);
+ if (count($data) == 1) {
+ $data = $data[0];
+ }
+ break;
+ case 0x0007: // 0x0007 = bytes (size field *= 1-byte), values are stored as ??????
+ $data = substr($atom_data, $offset, $data_size * 1);
+ $offset += ($data_size * 1);
+ break;
+ case 0x0008: // 0x0008 = ????? (size field *= 2-byte), values are stored as ??????
+ $data = substr($atom_data, $offset, $data_size * 2);
+ $offset += ($data_size * 2);
+ break;
+ default:
+echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br>';
+ break 2;
+ }
+
+ switch ($record_type) {
+ case 0x00000011: // CreateDate
+ case 0x00000012: // DateTimeOriginal
+ $data = strtotime($data);
+ break;
+ case 0x0200001e: // ColorSpace
+ switch ($data) {
+ case 1:
+ $data = 'sRGB';
+ break;
+ case 2:
+ $data = 'Adobe RGB';
+ break;
+ }
+ break;
+ case 0x02000023: // PictureControlData
+ $PictureControlAdjust = array(0=>'default', 1=>'quick', 2=>'full');
+ $FilterEffect = array(0x80=>'off', 0x81=>'yellow', 0x82=>'orange', 0x83=>'red', 0x84=>'green', 0xff=>'n/a');
+ $ToningEffect = array(0x80=>'b&w', 0x81=>'sepia', 0x82=>'cyanotype', 0x83=>'red', 0x84=>'yellow', 0x85=>'green', 0x86=>'blue-green', 0x87=>'blue', 0x88=>'purple-blue', 0x89=>'red-purple', 0xff=>'n/a');
+ $data = array(
+ 'PictureControlVersion' => substr($data, 0, 4),
+ 'PictureControlName' => rtrim(substr($data, 4, 20), "\x00"),
+ 'PictureControlBase' => rtrim(substr($data, 24, 20), "\x00"),
+ //'?' => substr($data, 44, 4),
+ 'PictureControlAdjust' => $PictureControlAdjust[ord(substr($data, 48, 1))],
+ 'PictureControlQuickAdjust' => ord(substr($data, 49, 1)),
+ 'Sharpness' => ord(substr($data, 50, 1)),
+ 'Contrast' => ord(substr($data, 51, 1)),
+ 'Brightness' => ord(substr($data, 52, 1)),
+ 'Saturation' => ord(substr($data, 53, 1)),
+ 'HueAdjustment' => ord(substr($data, 54, 1)),
+ 'FilterEffect' => $FilterEffect[ord(substr($data, 55, 1))],
+ 'ToningEffect' => $ToningEffect[ord(substr($data, 56, 1))],
+ 'ToningSaturation' => ord(substr($data, 57, 1)),
+ );
+ break;
+ case 0x02000024: // WorldTime
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#WorldTime
+ // timezone is stored as offset from GMT in minutes
+ $timezone = getid3_lib::BigEndian2Int(substr($data, 0, 2));
+ if ($timezone & 0x8000) {
+ $timezone = 0 - (0x10000 - $timezone);
+ }
+ $timezone /= 60;
+
+ $dst = (bool) getid3_lib::BigEndian2Int(substr($data, 2, 1));
+ switch (getid3_lib::BigEndian2Int(substr($data, 3, 1))) {
+ case 2:
+ $datedisplayformat = 'D/M/Y'; break;
+ case 1:
+ $datedisplayformat = 'M/D/Y'; break;
+ case 0:
+ default:
+ $datedisplayformat = 'Y/M/D'; break;
+ }
+
+ $data = array('timezone'=>floatval($timezone), 'dst'=>$dst, 'display'=>$datedisplayformat);
+ break;
+ case 0x02000083: // LensType
+ $data = array(
+ //'_' => $data,
+ 'mf' => (bool) ($data & 0x01),
+ 'd' => (bool) ($data & 0x02),
+ 'g' => (bool) ($data & 0x04),
+ 'vr' => (bool) ($data & 0x08),
+ );
+ break;
+ }
+ $tag_name = (isset($NCTGtagName[$record_type]) ? $NCTGtagName[$record_type] : '0x'.str_pad(dechex($record_type), 8, '0', STR_PAD_LEFT));
+ $parsed[$tag_name] = $data;
+ }
+ return $parsed;
+ }
+
+
+ function CopyToAppropriateCommentsSection($keyname, $data, $boxname='') {
+ static $handyatomtranslatorarray = array();
+ if (empty($handyatomtranslatorarray)) {
+ $handyatomtranslatorarray['©cpy'] = 'copyright';
+ $handyatomtranslatorarray['©day'] = 'creation_date'; // iTunes 4.0
+ $handyatomtranslatorarray['©dir'] = 'director';
+ $handyatomtranslatorarray['©ed1'] = 'edit1';
+ $handyatomtranslatorarray['©ed2'] = 'edit2';
+ $handyatomtranslatorarray['©ed3'] = 'edit3';
+ $handyatomtranslatorarray['©ed4'] = 'edit4';
+ $handyatomtranslatorarray['©ed5'] = 'edit5';
+ $handyatomtranslatorarray['©ed6'] = 'edit6';
+ $handyatomtranslatorarray['©ed7'] = 'edit7';
+ $handyatomtranslatorarray['©ed8'] = 'edit8';
+ $handyatomtranslatorarray['©ed9'] = 'edit9';
+ $handyatomtranslatorarray['©fmt'] = 'format';
+ $handyatomtranslatorarray['©inf'] = 'information';
+ $handyatomtranslatorarray['©prd'] = 'producer';
+ $handyatomtranslatorarray['©prf'] = 'performers';
+ $handyatomtranslatorarray['©req'] = 'system_requirements';
+ $handyatomtranslatorarray['©src'] = 'source_credit';
+ $handyatomtranslatorarray['©wrt'] = 'writer';
+
+ // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt
+ $handyatomtranslatorarray['©nam'] = 'title'; // iTunes 4.0
+ $handyatomtranslatorarray['©cmt'] = 'comment'; // iTunes 4.0
+ $handyatomtranslatorarray['©wrn'] = 'warning';
+ $handyatomtranslatorarray['©hst'] = 'host_computer';
+ $handyatomtranslatorarray['©mak'] = 'make';
+ $handyatomtranslatorarray['©mod'] = 'model';
+ $handyatomtranslatorarray['©PRD'] = 'product';
+ $handyatomtranslatorarray['©swr'] = 'software';
+ $handyatomtranslatorarray['©aut'] = 'author';
+ $handyatomtranslatorarray['©ART'] = 'artist';
+ $handyatomtranslatorarray['©trk'] = 'track';
+ $handyatomtranslatorarray['©alb'] = 'album'; // iTunes 4.0
+ $handyatomtranslatorarray['©com'] = 'comment';
+ $handyatomtranslatorarray['©gen'] = 'genre'; // iTunes 4.0
+ $handyatomtranslatorarray['©ope'] = 'composer';
+ $handyatomtranslatorarray['©url'] = 'url';
+ $handyatomtranslatorarray['©enc'] = 'encoder';
+
+ // http://atomicparsley.sourceforge.net/mpeg-4files.html
+ $handyatomtranslatorarray['©art'] = 'artist'; // iTunes 4.0
+ $handyatomtranslatorarray['aART'] = 'album_artist';
+ $handyatomtranslatorarray['trkn'] = 'track_number'; // iTunes 4.0
+ $handyatomtranslatorarray['disk'] = 'disc_number'; // iTunes 4.0
+ $handyatomtranslatorarray['gnre'] = 'genre'; // iTunes 4.0
+ $handyatomtranslatorarray['©too'] = 'encoder'; // iTunes 4.0
+ $handyatomtranslatorarray['tmpo'] = 'bpm'; // iTunes 4.0
+ $handyatomtranslatorarray['cprt'] = 'copyright'; // iTunes 4.0?
+ $handyatomtranslatorarray['cpil'] = 'compilation'; // iTunes 4.0
+ $handyatomtranslatorarray['covr'] = 'picture'; // iTunes 4.0
+ $handyatomtranslatorarray['rtng'] = 'rating'; // iTunes 4.0
+ $handyatomtranslatorarray['©grp'] = 'grouping'; // iTunes 4.2
+ $handyatomtranslatorarray['stik'] = 'stik'; // iTunes 4.9
+ $handyatomtranslatorarray['pcst'] = 'podcast'; // iTunes 4.9
+ $handyatomtranslatorarray['catg'] = 'category'; // iTunes 4.9
+ $handyatomtranslatorarray['keyw'] = 'keyword'; // iTunes 4.9
+ $handyatomtranslatorarray['purl'] = 'podcast_url'; // iTunes 4.9
+ $handyatomtranslatorarray['egid'] = 'episode_guid'; // iTunes 4.9
+ $handyatomtranslatorarray['desc'] = 'description'; // iTunes 5.0
+ $handyatomtranslatorarray['©lyr'] = 'lyrics'; // iTunes 5.0
+ $handyatomtranslatorarray['tvnn'] = 'tv_network_name'; // iTunes 6.0
+ $handyatomtranslatorarray['tvsh'] = 'tv_show_name'; // iTunes 6.0
+ $handyatomtranslatorarray['tvsn'] = 'tv_season'; // iTunes 6.0
+ $handyatomtranslatorarray['tves'] = 'tv_episode'; // iTunes 6.0
+ $handyatomtranslatorarray['purd'] = 'purchase_date'; // iTunes 6.0.2
+ $handyatomtranslatorarray['pgap'] = 'gapless_playback'; // iTunes 7.0
+
+ // http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt
+
+
+
+ // boxnames:
+ $handyatomtranslatorarray['iTunSMPB'] = 'iTunSMPB';
+ $handyatomtranslatorarray['iTunNORM'] = 'iTunNORM';
+ $handyatomtranslatorarray['Encoding Params'] = 'Encoding Params';
+ $handyatomtranslatorarray['replaygain_track_gain'] = 'replaygain_track_gain';
+ $handyatomtranslatorarray['replaygain_track_peak'] = 'replaygain_track_peak';
+ $handyatomtranslatorarray['replaygain_track_minmax'] = 'replaygain_track_minmax';
+ $handyatomtranslatorarray['MusicIP PUID'] = 'MusicIP PUID';
+ $handyatomtranslatorarray['MusicBrainz Artist Id'] = 'MusicBrainz Artist Id';
+ $handyatomtranslatorarray['MusicBrainz Album Id'] = 'MusicBrainz Album Id';
+ $handyatomtranslatorarray['MusicBrainz Album Artist Id'] = 'MusicBrainz Album Artist Id';
+ $handyatomtranslatorarray['MusicBrainz Track Id'] = 'MusicBrainz Track Id';
+ $handyatomtranslatorarray['MusicBrainz Disc Id'] = 'MusicBrainz Disc Id';
+ }
+ $info = &$this->getid3->info;
+ $comment_key = '';
+ if ($boxname && ($boxname != $keyname) && isset($handyatomtranslatorarray[$boxname])) {
+ $comment_key = $handyatomtranslatorarray[$boxname];
+ } elseif (isset($handyatomtranslatorarray[$keyname])) {
+ $comment_key = $handyatomtranslatorarray[$keyname];
+ }
+ if ($comment_key) {
+ if ($comment_key == 'picture') {
+ if (!is_array($data)) {
+ $image_mime = '';
+ if (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $data)) {
+ $image_mime = 'image/png';
+ } elseif (preg_match('#^\xFF\xD8\xFF#', $data)) {
+ $image_mime = 'image/jpeg';
+ } elseif (preg_match('#^GIF#', $data)) {
+ $image_mime = 'image/gif';
+ } elseif (preg_match('#^BM#', $data)) {
+ $image_mime = 'image/bmp';
+ }
+ $data = array('data'=>$data, 'image_mime'=>$image_mime);
+ }
+ }
+ $info['quicktime']['comments'][$comment_key][] = $data;
+ }
+ return true;
+ }
+
+ function NoNullString($nullterminatedstring) {
+ // remove the single null terminator on null terminated strings
+ if (substr($nullterminatedstring, strlen($nullterminatedstring) - 1, 1) === "\x00") {
+ return substr($nullterminatedstring, 0, strlen($nullterminatedstring) - 1);
+ }
+ return $nullterminatedstring;
+ }
+
+ function Pascal2String($pascalstring) {
+ // Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string
+ return substr($pascalstring, 1);
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio-video.real.php b/3rdparty/getid3/module.audio-video.real.php
index 013f4784bcb..d716e7da3c2 100644
--- a/apps/media/getID3/getid3/module.audio-video.real.php
+++ b/3rdparty/getid3/module.audio-video.real.php
@@ -15,67 +15,69 @@
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
-class getid3_real
+class getid3_real extends getid3_handler
{
- function getid3_real(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'real';
- $ThisFileInfo['bitrate'] = 0;
- $ThisFileInfo['playtime_seconds'] = 0;
+ function Analyze() {
+ $info = &$this->getid3->info;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
+ $info['fileformat'] = 'real';
+ $info['bitrate'] = 0;
+ $info['playtime_seconds'] = 0;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$ChunkCounter = 0;
- while (ftell($fd) < $ThisFileInfo['avdataend']) {
- $ChunkData = fread($fd, 8);
+ while (ftell($this->getid3->fp) < $info['avdataend']) {
+ $ChunkData = fread($this->getid3->fp, 8);
$ChunkName = substr($ChunkData, 0, 4);
$ChunkSize = getid3_lib::BigEndian2Int(substr($ChunkData, 4, 4));
if ($ChunkName == '.ra'."\xFD") {
- $ChunkData .= fread($fd, $ChunkSize - 8);
- if ($this->ParseOldRAheader(substr($ChunkData, 0, 128), $ThisFileInfo['real']['old_ra_header'])) {
- $ThisFileInfo['audio']['dataformat'] = 'real';
- $ThisFileInfo['audio']['lossless'] = false;
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['real']['old_ra_header']['sample_rate'];
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['real']['old_ra_header']['bits_per_sample'];
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['real']['old_ra_header']['channels'];
-
- $ThisFileInfo['playtime_seconds'] = 60 * ($ThisFileInfo['real']['old_ra_header']['audio_bytes'] / $ThisFileInfo['real']['old_ra_header']['bytes_per_minute']);
- $ThisFileInfo['audio']['bitrate'] = 8 * ($ThisFileInfo['real']['old_ra_header']['audio_bytes'] / $ThisFileInfo['playtime_seconds']);
- $ThisFileInfo['audio']['codec'] = $this->RealAudioCodecFourCClookup($ThisFileInfo['real']['old_ra_header']['fourcc'], $ThisFileInfo['audio']['bitrate']);
-
- foreach ($ThisFileInfo['real']['old_ra_header']['comments'] as $key => $valuearray) {
+ $ChunkData .= fread($this->getid3->fp, $ChunkSize - 8);
+ if ($this->ParseOldRAheader(substr($ChunkData, 0, 128), $info['real']['old_ra_header'])) {
+ $info['audio']['dataformat'] = 'real';
+ $info['audio']['lossless'] = false;
+ $info['audio']['sample_rate'] = $info['real']['old_ra_header']['sample_rate'];
+ $info['audio']['bits_per_sample'] = $info['real']['old_ra_header']['bits_per_sample'];
+ $info['audio']['channels'] = $info['real']['old_ra_header']['channels'];
+
+ $info['playtime_seconds'] = 60 * ($info['real']['old_ra_header']['audio_bytes'] / $info['real']['old_ra_header']['bytes_per_minute']);
+ $info['audio']['bitrate'] = 8 * ($info['real']['old_ra_header']['audio_bytes'] / $info['playtime_seconds']);
+ $info['audio']['codec'] = $this->RealAudioCodecFourCClookup($info['real']['old_ra_header']['fourcc'], $info['audio']['bitrate']);
+
+ foreach ($info['real']['old_ra_header']['comments'] as $key => $valuearray) {
if (strlen(trim($valuearray[0])) > 0) {
- $ThisFileInfo['real']['comments'][$key][] = trim($valuearray[0]);
+ $info['real']['comments'][$key][] = trim($valuearray[0]);
}
}
return true;
}
- $ThisFileInfo['error'][] = 'There was a problem parsing this RealAudio file. Please submit it for analysis to http://www.getid3.org/upload/ or info@getid3.org';
- unset($ThisFileInfo['bitrate']);
- unset($ThisFileInfo['playtime_seconds']);
+ $info['error'][] = 'There was a problem parsing this RealAudio file. Please submit it for analysis to info@getid3.org';
+ unset($info['bitrate']);
+ unset($info['playtime_seconds']);
return false;
}
// shortcut
- $ThisFileInfo['real']['chunks'][$ChunkCounter] = array();
- $thisfile_real_chunks_currentchunk = &$ThisFileInfo['real']['chunks'][$ChunkCounter];
+ $info['real']['chunks'][$ChunkCounter] = array();
+ $thisfile_real_chunks_currentchunk = &$info['real']['chunks'][$ChunkCounter];
$thisfile_real_chunks_currentchunk['name'] = $ChunkName;
- $thisfile_real_chunks_currentchunk['offset'] = ftell($fd) - 8;
+ $thisfile_real_chunks_currentchunk['offset'] = ftell($this->getid3->fp) - 8;
$thisfile_real_chunks_currentchunk['length'] = $ChunkSize;
- if (($thisfile_real_chunks_currentchunk['offset'] + $thisfile_real_chunks_currentchunk['length']) > $ThisFileInfo['avdataend']) {
- $ThisFileInfo['warning'][] = 'Chunk "'.$thisfile_real_chunks_currentchunk['name'].'" at offset '.$thisfile_real_chunks_currentchunk['offset'].' claims to be '.$thisfile_real_chunks_currentchunk['length'].' bytes long, which is beyond end of file';
+ if (($thisfile_real_chunks_currentchunk['offset'] + $thisfile_real_chunks_currentchunk['length']) > $info['avdataend']) {
+ $info['warning'][] = 'Chunk "'.$thisfile_real_chunks_currentchunk['name'].'" at offset '.$thisfile_real_chunks_currentchunk['offset'].' claims to be '.$thisfile_real_chunks_currentchunk['length'].' bytes long, which is beyond end of file';
return false;
}
- if ($ChunkSize > (GETID3_FREAD_BUFFER_SIZE + 8)) {
+ if ($ChunkSize > ($this->getid3->fread_buffer_size() + 8)) {
- $ChunkData .= fread($fd, GETID3_FREAD_BUFFER_SIZE - 8);
- fseek($fd, $thisfile_real_chunks_currentchunk['offset'] + $ChunkSize, SEEK_SET);
+ $ChunkData .= fread($this->getid3->fp, $this->getid3->fread_buffer_size() - 8);
+ fseek($this->getid3->fp, $thisfile_real_chunks_currentchunk['offset'] + $ChunkSize, SEEK_SET);
} elseif(($ChunkSize - 8) > 0) {
-
- $ChunkData .= fread($fd, $ChunkSize - 8);
+
+ $ChunkData .= fread($this->getid3->fp, $ChunkSize - 8);
}
$offset = 8;
@@ -95,7 +97,7 @@ class getid3_real
break;
default:
- //$ThisFileInfo['warning'][] = 'Expected .RMF-object_version to be "0", actual value is "'.$thisfile_real_chunks_currentchunk['object_version'].'" (should not be a problem)';
+ //$info['warning'][] = 'Expected .RMF-object_version to be "0", actual value is "'.$thisfile_real_chunks_currentchunk['object_version'].'" (should not be a problem)';
break;
}
@@ -128,9 +130,9 @@ class getid3_real
$offset += 2;
$thisfile_real_chunks_currentchunk['flags_raw'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
$offset += 2;
- $ThisFileInfo['playtime_seconds'] = $thisfile_real_chunks_currentchunk['duration'] / 1000;
+ $info['playtime_seconds'] = $thisfile_real_chunks_currentchunk['duration'] / 1000;
if ($thisfile_real_chunks_currentchunk['duration'] > 0) {
- $ThisFileInfo['bitrate'] += $thisfile_real_chunks_currentchunk['avg_bit_rate'];
+ $info['bitrate'] += $thisfile_real_chunks_currentchunk['avg_bit_rate'];
}
$thisfile_real_chunks_currentchunk['flags']['save_enabled'] = (bool) ($thisfile_real_chunks_currentchunk['flags_raw'] & 0x0001);
$thisfile_real_chunks_currentchunk['flags']['perfect_play'] = (bool) ($thisfile_real_chunks_currentchunk['flags_raw'] & 0x0002);
@@ -202,24 +204,24 @@ class getid3_real
$thisfile_real_chunks_currentchunk_videoinfo['codec'] = getid3_riff::RIFFfourccLookup($thisfile_real_chunks_currentchunk_videoinfo['fourcc2']);
- $ThisFileInfo['video']['resolution_x'] = $thisfile_real_chunks_currentchunk_videoinfo['width'];
- $ThisFileInfo['video']['resolution_y'] = $thisfile_real_chunks_currentchunk_videoinfo['height'];
- $ThisFileInfo['video']['frame_rate'] = (float) $thisfile_real_chunks_currentchunk_videoinfo['frames_per_second'];
- $ThisFileInfo['video']['codec'] = $thisfile_real_chunks_currentchunk_videoinfo['codec'];
- $ThisFileInfo['video']['bits_per_sample'] = $thisfile_real_chunks_currentchunk_videoinfo['bits_per_sample'];
+ $info['video']['resolution_x'] = $thisfile_real_chunks_currentchunk_videoinfo['width'];
+ $info['video']['resolution_y'] = $thisfile_real_chunks_currentchunk_videoinfo['height'];
+ $info['video']['frame_rate'] = (float) $thisfile_real_chunks_currentchunk_videoinfo['frames_per_second'];
+ $info['video']['codec'] = $thisfile_real_chunks_currentchunk_videoinfo['codec'];
+ $info['video']['bits_per_sample'] = $thisfile_real_chunks_currentchunk_videoinfo['bits_per_sample'];
break;
case 'audio/x-pn-realaudio':
case 'audio/x-pn-multirate-realaudio':
$this->ParseOldRAheader($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk['parsed_audio_data']);
- $ThisFileInfo['audio']['sample_rate'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['sample_rate'];
- $ThisFileInfo['audio']['bits_per_sample'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['bits_per_sample'];
- $ThisFileInfo['audio']['channels'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['channels'];
- if (!empty($ThisFileInfo['audio']['dataformat'])) {
- foreach ($ThisFileInfo['audio'] as $key => $value) {
+ $info['audio']['sample_rate'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['sample_rate'];
+ $info['audio']['bits_per_sample'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['bits_per_sample'];
+ $info['audio']['channels'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['channels'];
+ if (!empty($info['audio']['dataformat'])) {
+ foreach ($info['audio'] as $key => $value) {
if ($key != 'streams') {
- $ThisFileInfo['audio']['streams'][$thisfile_real_chunks_currentchunk['stream_number']][$key] = $value;
+ $info['audio']['streams'][$thisfile_real_chunks_currentchunk['stream_number']][$key] = $value;
}
}
}
@@ -255,36 +257,36 @@ class getid3_real
}
- if (empty($ThisFileInfo['playtime_seconds'])) {
- $ThisFileInfo['playtime_seconds'] = max($ThisFileInfo['playtime_seconds'], ($thisfile_real_chunks_currentchunk['duration'] + $thisfile_real_chunks_currentchunk['start_time']) / 1000);
+ if (empty($info['playtime_seconds'])) {
+ $info['playtime_seconds'] = max($info['playtime_seconds'], ($thisfile_real_chunks_currentchunk['duration'] + $thisfile_real_chunks_currentchunk['start_time']) / 1000);
}
if ($thisfile_real_chunks_currentchunk['duration'] > 0) {
switch ($thisfile_real_chunks_currentchunk['mime_type']) {
case 'audio/x-pn-realaudio':
case 'audio/x-pn-multirate-realaudio':
- $ThisFileInfo['audio']['bitrate'] = (isset($ThisFileInfo['audio']['bitrate']) ? $ThisFileInfo['audio']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
- $ThisFileInfo['audio']['codec'] = $this->RealAudioCodecFourCClookup($thisfile_real_chunks_currentchunk['parsed_audio_data']['fourcc'], $ThisFileInfo['audio']['bitrate']);
- $ThisFileInfo['audio']['dataformat'] = 'real';
- $ThisFileInfo['audio']['lossless'] = false;
+ $info['audio']['bitrate'] = (isset($info['audio']['bitrate']) ? $info['audio']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
+ $info['audio']['codec'] = $this->RealAudioCodecFourCClookup($thisfile_real_chunks_currentchunk['parsed_audio_data']['fourcc'], $info['audio']['bitrate']);
+ $info['audio']['dataformat'] = 'real';
+ $info['audio']['lossless'] = false;
break;
case 'video/x-pn-realvideo':
case 'video/x-pn-multirate-realvideo':
- $ThisFileInfo['video']['bitrate'] = (isset($ThisFileInfo['video']['bitrate']) ? $ThisFileInfo['video']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
- $ThisFileInfo['video']['bitrate_mode'] = 'cbr';
- $ThisFileInfo['video']['dataformat'] = 'real';
- $ThisFileInfo['video']['lossless'] = false;
- $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
+ $info['video']['bitrate'] = (isset($info['video']['bitrate']) ? $info['video']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
+ $info['video']['bitrate_mode'] = 'cbr';
+ $info['video']['dataformat'] = 'real';
+ $info['video']['lossless'] = false;
+ $info['video']['pixel_aspect_ratio'] = (float) 1;
break;
case 'audio/x-ralf-mpeg4-generic':
- $ThisFileInfo['audio']['bitrate'] = (isset($ThisFileInfo['audio']['bitrate']) ? $ThisFileInfo['audio']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
- $ThisFileInfo['audio']['codec'] = 'RealAudio Lossless';
- $ThisFileInfo['audio']['dataformat'] = 'real';
- $ThisFileInfo['audio']['lossless'] = true;
+ $info['audio']['bitrate'] = (isset($info['audio']['bitrate']) ? $info['audio']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
+ $info['audio']['codec'] = 'RealAudio Lossless';
+ $info['audio']['dataformat'] = 'real';
+ $info['audio']['lossless'] = true;
break;
}
- $ThisFileInfo['bitrate'] = (isset($ThisFileInfo['video']['bitrate']) ? $ThisFileInfo['video']['bitrate'] : 0) + (isset($ThisFileInfo['audio']['bitrate']) ? $ThisFileInfo['audio']['bitrate'] : 0);
+ $info['bitrate'] = (isset($info['video']['bitrate']) ? $info['video']['bitrate'] : 0) + (isset($info['audio']['bitrate']) ? $info['audio']['bitrate'] : 0);
}
}
break;
@@ -317,7 +319,7 @@ class getid3_real
$commentkeystocopy = array('title'=>'title', 'artist'=>'artist', 'copyright'=>'copyright', 'comment'=>'comment');
foreach ($commentkeystocopy as $key => $val) {
if ($thisfile_real_chunks_currentchunk[$key]) {
- $ThisFileInfo['real']['comments'][$val][] = trim($thisfile_real_chunks_currentchunk[$key]);
+ $info['real']['comments'][$val][] = trim($thisfile_real_chunks_currentchunk[$key]);
}
}
@@ -345,22 +347,22 @@ class getid3_real
break 2;
} else {
// non-last index chunk, seek to next index chunk (skipping actual index data)
- fseek($fd, $thisfile_real_chunks_currentchunk['next_index_header'], SEEK_SET);
+ fseek($this->getid3->fp, $thisfile_real_chunks_currentchunk['next_index_header'], SEEK_SET);
}
}
break;
default:
- $ThisFileInfo['warning'][] = 'Unhandled RealMedia chunk "'.$ChunkName.'" at offset '.$thisfile_real_chunks_currentchunk['offset'];
+ $info['warning'][] = 'Unhandled RealMedia chunk "'.$ChunkName.'" at offset '.$thisfile_real_chunks_currentchunk['offset'];
break;
}
$ChunkCounter++;
}
- if (!empty($ThisFileInfo['audio']['streams'])) {
- $ThisFileInfo['audio']['bitrate'] = 0;
- foreach ($ThisFileInfo['audio']['streams'] as $key => $valuearray) {
- $ThisFileInfo['audio']['bitrate'] += $valuearray['bitrate'];
+ if (!empty($info['audio']['streams'])) {
+ $info['audio']['bitrate'] = 0;
+ foreach ($info['audio']['streams'] as $key => $valuearray) {
+ $info['audio']['bitrate'] += $valuearray['bitrate'];
}
}
diff --git a/apps/media/getID3/getid3/module.audio-video.riff.php b/3rdparty/getid3/module.audio-video.riff.php
index 74ea33966c0..8e8f53a403f 100644
--- a/apps/media/getID3/getid3/module.audio-video.riff.php
+++ b/3rdparty/getid3/module.audio-video.riff.php
@@ -19,65 +19,115 @@
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
-class getid3_riff
+class getid3_riff extends getid3_handler
{
- function getid3_riff(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
// initialize these values to an empty array, otherwise they default to NULL
// and you can't append array values to a NULL value
- $ThisFileInfo['riff'] = array('raw'=>array());
+ $info['riff'] = array('raw'=>array());
// Shortcuts
- $thisfile_riff = &$ThisFileInfo['riff'];
+ $thisfile_riff = &$info['riff'];
$thisfile_riff_raw = &$thisfile_riff['raw'];
- $thisfile_audio = &$ThisFileInfo['audio'];
- $thisfile_video = &$ThisFileInfo['video'];
- $thisfile_avdataoffset = &$ThisFileInfo['avdataoffset'];
- $thisfile_avdataend = &$ThisFileInfo['avdataend'];
+ $thisfile_audio = &$info['audio'];
+ $thisfile_video = &$info['video'];
$thisfile_audio_dataformat = &$thisfile_audio['dataformat'];
$thisfile_riff_audio = &$thisfile_riff['audio'];
$thisfile_riff_video = &$thisfile_riff['video'];
- $Original['avdataoffset'] = $thisfile_avdataoffset;
- $Original['avdataend'] = $thisfile_avdataend;
+ $Original['avdataoffset'] = $info['avdataoffset'];
+ $Original['avdataend'] = $info['avdataend'];
- fseek($fd, $thisfile_avdataoffset, SEEK_SET);
- $RIFFheader = fread($fd, 12);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $RIFFheader = fread($this->getid3->fp, 12);
$RIFFsubtype = substr($RIFFheader, 8, 4);
switch (substr($RIFFheader, 0, 4)) {
case 'FORM':
- $ThisFileInfo['fileformat'] = 'aiff';
- $RIFFheaderSize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($RIFFheader, 4, 4));
- $thisfile_riff[$RIFFsubtype] = getid3_riff::ParseRIFF($fd, $thisfile_avdataoffset + 12, $thisfile_avdataoffset + $RIFFheaderSize, $ThisFileInfo);
- $thisfile_riff['header_size'] = $RIFFheaderSize;
+ $info['fileformat'] = 'aiff';
+ $thisfile_riff['header_size'] = $this->EitherEndian2Int(substr($RIFFheader, 4, 4));
+ $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($info['avdataoffset'] + 12, $info['avdataoffset'] + $thisfile_riff['header_size']);
break;
- case 'RIFF':
+ case 'RIFF': // AVI, WAV, etc
case 'SDSS': // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
case 'RMP3': // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s
+ $info['fileformat'] = 'riff';
+ $thisfile_riff['header_size'] = $this->EitherEndian2Int(substr($RIFFheader, 4, 4));
if ($RIFFsubtype == 'RMP3') {
// RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s
$RIFFsubtype = 'WAVE';
}
+ $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($info['avdataoffset'] + 12, $info['avdataoffset'] + $thisfile_riff['header_size']);
+ if (($info['avdataend'] - $info['filesize']) == 1) {
+ // LiteWave appears to incorrectly *not* pad actual output file
+ // to nearest WORD boundary so may appear to be short by one
+ // byte, in which case - skip warning
+ $info['avdataend'] = $info['filesize'];
+ }
+
+ $nextRIFFoffset = $Original['avdataoffset'] + 8 + $thisfile_riff['header_size']; // 8 = "RIFF" + 32-bit offset
+ while ($nextRIFFoffset < min($info['filesize'], $info['avdataend'])) {
+ if (!getid3_lib::intValueSupported($nextRIFFoffset + 1024)) {
+ $info['error'][] = 'AVI extends beyond '.round(PHP_INT_MAX / 1073741824).'GB and PHP filesystem functions cannot read that far, playtime is probably wrong';
+ $info['warning'][] = '[avdataend] value may be incorrect, multiple AVIX chunks may be present';
+ break;
+ } else {
+ fseek($this->getid3->fp, $nextRIFFoffset, SEEK_SET);
+ $nextRIFFheader = fread($this->getid3->fp, 12);
+ if ($nextRIFFoffset == ($info['avdataend'] - 1)) {
+ if (substr($nextRIFFheader, 0, 1) == "\x00") {
+ // RIFF padded to WORD boundary, we're actually already at the end
+ break;
+ }
+ }
+ $nextRIFFheaderID = substr($nextRIFFheader, 0, 4);
+ $nextRIFFsize = $this->EitherEndian2Int(substr($nextRIFFheader, 4, 4));
+ $nextRIFFtype = substr($nextRIFFheader, 8, 4);
+ $chunkdata = array();
+ $chunkdata['offset'] = $nextRIFFoffset + 8;
+ $chunkdata['size'] = $nextRIFFsize;
+ $nextRIFFoffset = $chunkdata['offset'] + $chunkdata['size'];
+ switch ($nextRIFFheaderID) {
+ case 'RIFF':
+ $info['avdataend'] = $nextRIFFoffset;
+ if (!getid3_lib::intValueSupported($info['avdataend'])) {
+ $info['error'][] = 'AVI extends beyond '.round(PHP_INT_MAX / 1073741824).'GB and PHP filesystem functions cannot read that far, playtime is probably wrong';
+ $info['warning'][] = '[avdataend] value may be incorrect, multiple AVIX chunks may be present';
+ }
+ $chunkdata['chunks'] = $this->ParseRIFF($chunkdata['offset'] + 4, $chunkdata['offset'] + $chunkdata['size']);
- $ThisFileInfo['fileformat'] = 'riff';
- $RIFFheaderSize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($RIFFheader, 4, 4));
- $thisfile_riff['header_size'] = $RIFFheaderSize;
- $thisfile_riff[$RIFFsubtype] = getid3_riff::ParseRIFF($fd, $thisfile_avdataoffset + 12, $thisfile_avdataoffset + $RIFFheaderSize, $ThisFileInfo);
-
- fseek($fd, $thisfile_avdataoffset + $RIFFheaderSize);
- $nextRIFFheader = fread($fd, 20);
- if (substr($nextRIFFheader, 8, 4) == 'RIFF') {
- $nextRIFFsize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($nextRIFFheader, 12, 4));
- $nextRIFFtype = substr($nextRIFFheader, 16, 4).'<br>';
- $thisfile_riff[$nextRIFFtype]['offset'] = ftell($fd) - 4;
- $thisfile_riff[$nextRIFFtype]['size'] = $nextRIFFsize;
- $ThisFileInfo['avdataend'] = $thisfile_riff[$nextRIFFtype]['offset'] + $thisfile_riff[$nextRIFFtype]['size'];
- $ThisFileInfo['error'][] = 'AVI extends beyond 2GB and PHP filesystem functions cannot read that far, playtime is probably wrong';
- $ThisFileInfo['warning'][] = '[avdataend] value may be incorrect, multiple AVIX chunks may be present';
- $thisfile_riff[$nextRIFFtype] = getid3_riff::ParseRIFF($fd, $thisfile_riff[$nextRIFFtype]['offset'] + 4, $thisfile_riff[$nextRIFFtype]['offset'] + $thisfile_riff[$nextRIFFtype]['size'], $ThisFileInfo);
+ if (!isset($thisfile_riff[$nextRIFFtype])) {
+ $thisfile_riff[$nextRIFFtype] = array();
+ }
+ $thisfile_riff[$nextRIFFtype][] = $chunkdata;
+ break;
+ case 'JUNK':
+ // ignore
+ $thisfile_riff[$nextRIFFheaderID][] = $chunkdata;
+ break;
+ default:
+ if ($info['filesize'] == ($chunkdata['offset'] - 8 + 128)) {
+ $DIVXTAG = $nextRIFFheader.fread($this->getid3->fp, 128 - 12);
+ if (substr($DIVXTAG, -7) == 'DIVXTAG') {
+ // DIVXTAG is supposed to be inside an IDVX chunk in a LIST chunk, but some bad encoders just slap it on the end of a file
+ $info['warning'][] = 'Found wrongly-structured DIVXTAG at offset '.(ftell($this->getid3->fp) - 128 + 12).', parsing anyway';
+ $thisfile_riff['DIVXTAG'] = $this->ParseDIVXTAG($DIVXTAG);
+ foreach ($thisfile_riff['DIVXTAG'] as $key => $value) {
+ if ($value && !preg_match('#_id$#', $key)) {
+ $thisfile_riff['comments'][$key][] = $value;
+ }
+ }
+ break 2;
+ }
+ }
+ $info['warning'][] = 'expecting "RIFF" or "JUNK" at '.$nextRIFFoffset.', found '.getid3_lib::PrintHexBytes(substr($nextRIFFheader, 0, 4)).' - skipping rest of file';
+ break 2;
+ }
+ }
}
if ($RIFFsubtype == 'WAVE') {
$thisfile_riff_WAVE = &$thisfile_riff['WAVE'];
@@ -85,8 +135,8 @@ class getid3_riff
break;
default:
- $ThisFileInfo['error'][] = 'Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "'.$RIFFsubtype.'" instead';
- unset($ThisFileInfo['fileformat']);
+ $info['error'][] = 'Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "'.$RIFFsubtype.'" instead';
+ unset($info['fileformat']);
return false;
break;
}
@@ -102,15 +152,15 @@ class getid3_riff
}
if (isset($thisfile_riff_WAVE['data'][0]['offset'])) {
- $thisfile_avdataoffset = $thisfile_riff_WAVE['data'][0]['offset'] + 8;
- $thisfile_avdataend = $thisfile_avdataoffset + $thisfile_riff_WAVE['data'][0]['size'];
+ $info['avdataoffset'] = $thisfile_riff_WAVE['data'][0]['offset'] + 8;
+ $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff_WAVE['data'][0]['size'];
}
if (isset($thisfile_riff_WAVE['fmt '][0]['data'])) {
$thisfile_riff_audio[$streamindex] = getid3_riff::RIFFparseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']);
$thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
- if (@$thisfile_riff_audio[$streamindex]['bitrate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';
+ if (!isset($thisfile_riff_audio[$streamindex]['bitrate']) || ($thisfile_riff_audio[$streamindex]['bitrate'] == 0)) {
+ $info['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';
return false;
}
$thisfile_riff_raw['fmt '] = $thisfile_riff_audio[$streamindex]['raw'];
@@ -119,11 +169,11 @@ class getid3_riff
$thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
if (substr($thisfile_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
- $ThisFileInfo['warning'][] = 'Audio codec = '.$thisfile_audio['codec'];
+ $info['warning'][] = 'Audio codec = '.$thisfile_audio['codec'];
}
$thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
- $ThisFileInfo['playtime_seconds'] = (float) ((($thisfile_avdataend - $thisfile_avdataoffset) * 8) / $thisfile_audio['bitrate']);
+ $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $thisfile_audio['bitrate']);
$thisfile_audio['lossless'] = false;
if (isset($thisfile_riff_WAVE['data'][0]['offset']) && isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
@@ -158,9 +208,9 @@ class getid3_riff
$thisfile_riff_raw_rgad_track = &$thisfile_riff_raw_rgad['track'];
$thisfile_riff_raw_rgad_album = &$thisfile_riff_raw_rgad['album'];
- $thisfile_riff_raw_rgad['fPeakAmplitude'] = getid3_lib::LittleEndian2Float(substr($rgadData, 0, 4));
- $thisfile_riff_raw_rgad['nRadioRgAdjust'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($rgadData, 4, 2));
- $thisfile_riff_raw_rgad['nAudiophileRgAdjust'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($rgadData, 6, 2));
+ $thisfile_riff_raw_rgad['fPeakAmplitude'] = getid3_lib::LittleEndian2Float(substr($rgadData, 0, 4));
+ $thisfile_riff_raw_rgad['nRadioRgAdjust'] = $this->EitherEndian2Int(substr($rgadData, 4, 2));
+ $thisfile_riff_raw_rgad['nAudiophileRgAdjust'] = $this->EitherEndian2Int(substr($rgadData, 6, 2));
$nRadioRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
$nAudiophileRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
@@ -187,14 +237,14 @@ class getid3_riff
}
if (isset($thisfile_riff_WAVE['fact'][0]['data'])) {
- $thisfile_riff_raw['fact']['NumberOfSamples'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_WAVE['fact'][0]['data'], 0, 4));
+ $thisfile_riff_raw['fact']['NumberOfSamples'] = $this->EitherEndian2Int(substr($thisfile_riff_WAVE['fact'][0]['data'], 0, 4));
// This should be a good way of calculating exact playtime,
// but some sample files have had incorrect number of samples,
// so cannot use this method
// if (!empty($thisfile_riff_raw['fmt ']['nSamplesPerSec'])) {
- // $ThisFileInfo['playtime_seconds'] = (float) $thisfile_riff_raw['fact']['NumberOfSamples'] / $thisfile_riff_raw['fmt ']['nSamplesPerSec'];
+ // $info['playtime_seconds'] = (float) $thisfile_riff_raw['fact']['NumberOfSamples'] / $thisfile_riff_raw['fmt ']['nSamplesPerSec'];
// }
}
if (!empty($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'])) {
@@ -212,17 +262,19 @@ class getid3_riff
$thisfile_riff_WAVE_bext_0['origin_time'] = substr($thisfile_riff_WAVE_bext_0['data'], 330, 8);
$thisfile_riff_WAVE_bext_0['time_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 338, 8));
$thisfile_riff_WAVE_bext_0['bwf_version'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 346, 1));
- $thisfile_riff_WAVE_bext_0['reserved'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 347, 254));
+ $thisfile_riff_WAVE_bext_0['reserved'] = substr($thisfile_riff_WAVE_bext_0['data'], 347, 254);
$thisfile_riff_WAVE_bext_0['coding_history'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601)));
-
- $thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime(
- substr($thisfile_riff_WAVE_bext_0['origin_time'], 0, 2),
- substr($thisfile_riff_WAVE_bext_0['origin_time'], 3, 2),
- substr($thisfile_riff_WAVE_bext_0['origin_time'], 6, 2),
- substr($thisfile_riff_WAVE_bext_0['origin_date'], 5, 2),
- substr($thisfile_riff_WAVE_bext_0['origin_date'], 8, 2),
- substr($thisfile_riff_WAVE_bext_0['origin_date'], 0, 4));
-
+ if (preg_match('#^([0-9]{4}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_date'], $matches_bext_date)) {
+ if (preg_match('#^([0-9]{2}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_time'], $matches_bext_time)) {
+ list($dummy, $bext_timestamp['year'], $bext_timestamp['month'], $bext_timestamp['day']) = $matches_bext_date;
+ list($dummy, $bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second']) = $matches_bext_time;
+ $thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime($bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second'], $bext_timestamp['month'], $bext_timestamp['day'], $bext_timestamp['year']);
+ } else {
+ $info['warning'][] = 'RIFF.WAVE.BEXT.origin_time is invalid';
+ }
+ } else {
+ $info['warning'][] = 'RIFF.WAVE.BEXT.origin_date is invalid';
+ }
$thisfile_riff['comments']['author'][] = $thisfile_riff_WAVE_bext_0['author'];
$thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_bext_0['title'];
}
@@ -278,40 +330,132 @@ class getid3_riff
$thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_cart_0['title'];
}
+ if (isset($thisfile_riff_WAVE['SNDM'][0]['data'])) {
+ // SoundMiner metadata
+
+ // shortcuts
+ $thisfile_riff_WAVE_SNDM_0 = &$thisfile_riff_WAVE['SNDM'][0];
+ $thisfile_riff_WAVE_SNDM_0_data = &$thisfile_riff_WAVE_SNDM_0['data'];
+ $SNDM_startoffset = 0;
+ $SNDM_endoffset = $thisfile_riff_WAVE_SNDM_0['size'];
+
+ while ($SNDM_startoffset < $SNDM_endoffset) {
+ $SNDM_thisTagOffset = 0;
+ $SNDM_thisTagSize = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 4));
+ $SNDM_thisTagOffset += 4;
+ $SNDM_thisTagKey = substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 4);
+ $SNDM_thisTagOffset += 4;
+ $SNDM_thisTagDataSize = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 2));
+ $SNDM_thisTagOffset += 2;
+ $SNDM_thisTagDataFlags = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 2));
+ $SNDM_thisTagOffset += 2;
+ $SNDM_thisTagDataText = substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, $SNDM_thisTagDataSize);
+ $SNDM_thisTagOffset += $SNDM_thisTagDataSize;
+
+ if ($SNDM_thisTagSize != (4 + 4 + 2 + 2 + $SNDM_thisTagDataSize)) {
+ $info['warning'][] = 'RIFF.WAVE.SNDM.data contains tag not expected length (expected: '.$SNDM_thisTagSize.', found: '.(4 + 4 + 2 + 2 + $SNDM_thisTagDataSize).') at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')';
+ break;
+ } elseif ($SNDM_thisTagSize <= 0) {
+ $info['warning'][] = 'RIFF.WAVE.SNDM.data contains zero-size tag at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')';
+ break;
+ }
+ $SNDM_startoffset += $SNDM_thisTagSize;
+
+ $thisfile_riff_WAVE_SNDM_0['parsed_raw'][$SNDM_thisTagKey] = $SNDM_thisTagDataText;
+ if ($parsedkey = $this->RIFFwaveSNDMtagLookup($SNDM_thisTagKey)) {
+ $thisfile_riff_WAVE_SNDM_0['parsed'][$parsedkey] = $SNDM_thisTagDataText;
+ } else {
+ $info['warning'][] = 'RIFF.WAVE.SNDM contains unknown tag "'.$SNDM_thisTagKey.'" at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')';
+ }
+ }
+
+ $tagmapping = array(
+ 'tracktitle'=>'title',
+ 'category' =>'genre',
+ 'cdtitle' =>'album',
+ 'tracktitle'=>'title',
+ );
+ foreach ($tagmapping as $fromkey => $tokey) {
+ if (isset($thisfile_riff_WAVE_SNDM_0['parsed'][$fromkey])) {
+ $thisfile_riff['comments'][$tokey][] = $thisfile_riff_WAVE_SNDM_0['parsed'][$fromkey];
+ }
+ }
+ }
+
+ if (isset($thisfile_riff_WAVE['iXML'][0]['data'])) {
+ // requires functions simplexml_load_string and get_object_vars
+ if ($parsedXML = getid3_lib::XML2array($thisfile_riff_WAVE['iXML'][0]['data'])) {
+ $thisfile_riff_WAVE['iXML'][0]['parsed'] = $parsedXML;
+ if (isset($parsedXML['SPEED']['MASTER_SPEED'])) {
+ @list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['MASTER_SPEED']);
+ $thisfile_riff_WAVE['iXML'][0]['master_speed'] = $numerator / ($denominator ? $denominator : 1000);
+ }
+ if (isset($parsedXML['SPEED']['TIMECODE_RATE'])) {
+ @list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['TIMECODE_RATE']);
+ $thisfile_riff_WAVE['iXML'][0]['timecode_rate'] = $numerator / ($denominator ? $denominator : 1000);
+ }
+ if (isset($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO']) && !empty($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) && !empty($thisfile_riff_WAVE['iXML'][0]['timecode_rate'])) {
+ $samples_since_midnight = floatval(ltrim($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_HI'].$parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO'], '0'));
+ $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] = $samples_since_midnight / $parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE'];
+ $h = floor( $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] / 3600);
+ $m = floor(($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - ($h * 3600)) / 60);
+ $s = floor( $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - ($h * 3600) - ($m * 60));
+ $f = ($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - ($h * 3600) - ($m * 60) - $s) * $thisfile_riff_WAVE['iXML'][0]['timecode_rate'];
+ $thisfile_riff_WAVE['iXML'][0]['timecode_string'] = sprintf('%02d:%02d:%02d:%05.2f', $h, $m, $s, $f);
+ $thisfile_riff_WAVE['iXML'][0]['timecode_string_round'] = sprintf('%02d:%02d:%02d:%02d', $h, $m, $s, round($f));
+ }
+ unset($parsedXML);
+ }
+ }
+
+
+
if (!isset($thisfile_audio['bitrate']) && isset($thisfile_riff_audio[$streamindex]['bitrate'])) {
$thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
- $ThisFileInfo['playtime_seconds'] = (float) ((($thisfile_avdataend - $thisfile_avdataoffset) * 8) / $thisfile_audio['bitrate']);
+ $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $thisfile_audio['bitrate']);
}
- if (!empty($ThisFileInfo['wavpack'])) {
+ if (!empty($info['wavpack'])) {
$thisfile_audio_dataformat = 'wavpack';
$thisfile_audio['bitrate_mode'] = 'vbr';
- $thisfile_audio['encoder'] = 'WavPack v'.$ThisFileInfo['wavpack']['version'];
+ $thisfile_audio['encoder'] = 'WavPack v'.$info['wavpack']['version'];
// Reset to the way it was - RIFF parsing will have messed this up
- $thisfile_avdataend = $Original['avdataend'];
- $thisfile_audio['bitrate'] = (($thisfile_avdataend - $thisfile_avdataoffset) * 8) / $ThisFileInfo['playtime_seconds'];
+ $info['avdataend'] = $Original['avdataend'];
+ $thisfile_audio['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
- fseek($fd, $thisfile_avdataoffset - 44, SEEK_SET);
- $RIFFdata = fread($fd, 44);
+ fseek($this->getid3->fp, $info['avdataoffset'] - 44, SEEK_SET);
+ $RIFFdata = fread($this->getid3->fp, 44);
$OrignalRIFFheaderSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 4, 4)) + 8;
$OrignalRIFFdataSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 40, 4)) + 44;
if ($OrignalRIFFheaderSize > $OrignalRIFFdataSize) {
- $thisfile_avdataend -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
- fseek($fd, $thisfile_avdataend, SEEK_SET);
- $RIFFdata .= fread($fd, $OrignalRIFFheaderSize - $OrignalRIFFdataSize);
+ $info['avdataend'] -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
+ fseek($this->getid3->fp, $info['avdataend'], SEEK_SET);
+ $RIFFdata .= fread($this->getid3->fp, $OrignalRIFFheaderSize - $OrignalRIFFdataSize);
}
// move the data chunk after all other chunks (if any)
// so that the RIFF parser doesn't see EOF when trying
// to skip over the data chunk
$RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8);
- getid3_riff::ParseRIFFdata($RIFFdata, $ThisFileInfo);
+ $getid3_riff = new getid3_riff($this->getid3);
+ $getid3_riff->ParseRIFFdata($RIFFdata);
+ unset($getid3_riff);
}
if (isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
+ case 0x0001: // PCM
+ if (!empty($info['ac3'])) {
+ // Dolby Digital WAV files masquerade as PCM-WAV, but they're not
+ $thisfile_audio['wformattag'] = 0x2000;
+ $thisfile_audio['codec'] = $this->RIFFwFormatTagLookup($thisfile_audio['wformattag']);
+ $thisfile_audio['lossless'] = false;
+ $thisfile_audio['bitrate'] = $info['ac3']['bitrate'];
+ $thisfile_audio['sample_rate'] = $info['ac3']['sample_rate'];
+ }
+ break;
case 0x08AE: // ClearJump LiteWave
$thisfile_audio['bitrate_mode'] = 'vbr';
$thisfile_audio_dataformat = 'litewave';
@@ -363,8 +507,8 @@ class getid3_riff
break;
}
}
- if ($thisfile_avdataend > $ThisFileInfo['filesize']) {
- switch (@$thisfile_audio_dataformat) {
+ if ($info['avdataend'] > $info['filesize']) {
+ switch (!empty($thisfile_audio_dataformat) ? $thisfile_audio_dataformat : '') {
case 'wavpack': // WavPack
case 'lpac': // LPAC
case 'ofr': // OptimFROG
@@ -373,41 +517,41 @@ class getid3_riff
break;
case 'litewave':
- if (($thisfile_avdataend - $ThisFileInfo['filesize']) == 1) {
+ if (($info['avdataend'] - $info['filesize']) == 1) {
// LiteWave appears to incorrectly *not* pad actual output file
// to nearest WORD boundary so may appear to be short by one
// byte, in which case - skip warning
} else {
// Short by more than one byte, throw warning
- $ThisFileInfo['warning'][] = 'Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' (short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($ThisFileInfo['filesize'] - $thisfile_avdataoffset)).' bytes)';
- $thisfile_avdataend = $ThisFileInfo['filesize'];
+ $info['warning'][] = 'Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' (short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])).' bytes)';
+ $info['avdataend'] = $info['filesize'];
}
break;
default:
- if ((($thisfile_avdataend - $ThisFileInfo['filesize']) == 1) && (($thisfile_riff[$RIFFsubtype]['data'][0]['size'] % 2) == 0) && ((($ThisFileInfo['filesize'] - $thisfile_avdataoffset) % 2) == 1)) {
+ if ((($info['avdataend'] - $info['filesize']) == 1) && (($thisfile_riff[$RIFFsubtype]['data'][0]['size'] % 2) == 0) && ((($info['filesize'] - $info['avdataoffset']) % 2) == 1)) {
// output file appears to be incorrectly *not* padded to nearest WORD boundary
// Output less severe warning
- $ThisFileInfo['warning'][] = 'File should probably be padded to nearest WORD boundary, but it is not (expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' therefore short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($ThisFileInfo['filesize'] - $thisfile_avdataoffset)).' bytes)';
- $thisfile_avdataend = $ThisFileInfo['filesize'];
- break;
+ $info['warning'][] = 'File should probably be padded to nearest WORD boundary, but it is not (expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' therefore short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])).' bytes)';
+ $info['avdataend'] = $info['filesize'];
+ } else {
+ // Short by more than one byte, throw warning
+ $info['warning'][] = 'Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' (short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])).' bytes)';
+ $info['avdataend'] = $info['filesize'];
}
- // Short by more than one byte, throw warning
- $ThisFileInfo['warning'][] = 'Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' (short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($ThisFileInfo['filesize'] - $thisfile_avdataoffset)).' bytes)';
- $thisfile_avdataend = $ThisFileInfo['filesize'];
break;
}
}
- if (!empty($ThisFileInfo['mpeg']['audio']['LAME']['audio_bytes'])) {
- if ((($thisfile_avdataend - $thisfile_avdataoffset) - $ThisFileInfo['mpeg']['audio']['LAME']['audio_bytes']) == 1) {
- $thisfile_avdataend--;
- $ThisFileInfo['warning'][] = 'Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored';
+ if (!empty($info['mpeg']['audio']['LAME']['audio_bytes'])) {
+ if ((($info['avdataend'] - $info['avdataoffset']) - $info['mpeg']['audio']['LAME']['audio_bytes']) == 1) {
+ $info['avdataend']--;
+ $info['warning'][] = 'Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored';
}
}
- if (@$thisfile_audio_dataformat == 'ac3') {
+ if (isset($thisfile_audio_dataformat) && ($thisfile_audio_dataformat == 'ac3')) {
unset($thisfile_audio['bits_per_sample']);
- if (!empty($ThisFileInfo['ac3']['bitrate']) && ($ThisFileInfo['ac3']['bitrate'] != $thisfile_audio['bitrate'])) {
- $thisfile_audio['bitrate'] = $ThisFileInfo['ac3']['bitrate'];
+ if (!empty($info['ac3']['bitrate']) && ($info['ac3']['bitrate'] != $thisfile_audio['bitrate'])) {
+ $thisfile_audio['bitrate'] = $info['ac3']['bitrate'];
}
}
break;
@@ -415,14 +559,18 @@ class getid3_riff
case 'AVI ':
$thisfile_video['bitrate_mode'] = 'vbr'; // maybe not, but probably
$thisfile_video['dataformat'] = 'avi';
- $ThisFileInfo['mime_type'] = 'video/avi';
+ $info['mime_type'] = 'video/avi';
if (isset($thisfile_riff[$RIFFsubtype]['movi']['offset'])) {
- $thisfile_avdataoffset = $thisfile_riff[$RIFFsubtype]['movi']['offset'] + 8;
- $thisfile_avdataend = $thisfile_avdataoffset + $thisfile_riff[$RIFFsubtype]['movi']['size'];
- if ($thisfile_avdataend > $ThisFileInfo['filesize']) {
- $ThisFileInfo['warning'][] = 'Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['movi']['size'].' bytes of data, only found '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' (short by '.($thisfile_riff[$RIFFsubtype]['movi']['size'] - ($ThisFileInfo['filesize'] - $thisfile_avdataoffset)).' bytes)';
- $thisfile_avdataend = $ThisFileInfo['filesize'];
+ $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['movi']['offset'] + 8;
+ if (isset($thisfile_riff['AVIX'])) {
+ $info['avdataend'] = $thisfile_riff['AVIX'][(count($thisfile_riff['AVIX']) - 1)]['chunks']['movi']['offset'] + $thisfile_riff['AVIX'][(count($thisfile_riff['AVIX']) - 1)]['chunks']['movi']['size'];
+ } else {
+ $info['avdataend'] = $thisfile_riff['AVI ']['movi']['offset'] + $thisfile_riff['AVI ']['movi']['size'];
+ }
+ if ($info['avdataend'] > $info['filesize']) {
+ $info['warning'][] = 'Probably truncated file - expecting '.($info['avdataend'] - $info['avdataoffset']).' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' (short by '.($info['avdataend'] - $info['filesize']).' bytes)';
+ $info['avdataend'] = $info['filesize'];
}
}
@@ -440,15 +588,15 @@ class getid3_riff
foreach ($thisfile_riff['AVI ']['hdrl']['strl']['indx'] as $streamnumber => $steamdataarray) {
$thisfile_riff_avi_hdrl_strl_indx_stream_data = &$thisfile_riff['AVI ']['hdrl']['strl']['indx'][$streamnumber]['data'];
- $thisfile_riff_raw['indx'][$streamnumber]['wLongsPerEntry'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 0, 2));
- $thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 2, 1));
- $thisfile_riff_raw['indx'][$streamnumber]['bIndexType'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 3, 1));
- $thisfile_riff_raw['indx'][$streamnumber]['nEntriesInUse'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 4, 4));
- $thisfile_riff_raw['indx'][$streamnumber]['dwChunkId'] = substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 8, 4);
- $thisfile_riff_raw['indx'][$streamnumber]['dwReserved'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 12, 4));
+ $thisfile_riff_raw['indx'][$streamnumber]['wLongsPerEntry'] = $this->EitherEndian2Int(substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 0, 2));
+ $thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType'] = $this->EitherEndian2Int(substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 2, 1));
+ $thisfile_riff_raw['indx'][$streamnumber]['bIndexType'] = $this->EitherEndian2Int(substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 3, 1));
+ $thisfile_riff_raw['indx'][$streamnumber]['nEntriesInUse'] = $this->EitherEndian2Int(substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 4, 4));
+ $thisfile_riff_raw['indx'][$streamnumber]['dwChunkId'] = substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 8, 4);
+ $thisfile_riff_raw['indx'][$streamnumber]['dwReserved'] = $this->EitherEndian2Int(substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 12, 4));
- //$thisfile_riff_raw['indx'][$streamnumber]['bIndexType_name'] = @$bIndexType[$thisfile_riff_raw['indx'][$streamnumber]['bIndexType']];
- //$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType_name'] = @$bIndexSubtype[$thisfile_riff_raw['indx'][$streamnumber]['bIndexType']][$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType']];
+ //$thisfile_riff_raw['indx'][$streamnumber]['bIndexType_name'] = $bIndexType[$thisfile_riff_raw['indx'][$streamnumber]['bIndexType']];
+ //$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType_name'] = $bIndexSubtype[$thisfile_riff_raw['indx'][$streamnumber]['bIndexType']][$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType']];
unset($thisfile_riff_avi_hdrl_strl_indx_stream_data);
}
@@ -460,24 +608,24 @@ class getid3_riff
$thisfile_riff_raw['avih'] = array();
$thisfile_riff_raw_avih = &$thisfile_riff_raw['avih'];
- $thisfile_riff_raw_avih['dwMicroSecPerFrame'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 0, 4)); // frame display rate (or 0L)
+ $thisfile_riff_raw_avih['dwMicroSecPerFrame'] = $this->EitherEndian2Int(substr($avihData, 0, 4)); // frame display rate (or 0L)
if ($thisfile_riff_raw_avih['dwMicroSecPerFrame'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt RIFF file: avih.dwMicroSecPerFrame == zero';
+ $info['error'][] = 'Corrupt RIFF file: avih.dwMicroSecPerFrame == zero';
return false;
}
- $thisfile_riff_raw_avih['dwMaxBytesPerSec'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 4, 4)); // max. transfer rate
- $thisfile_riff_raw_avih['dwPaddingGranularity'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 8, 4)); // pad to multiples of this size; normally 2K.
- $thisfile_riff_raw_avih['dwFlags'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 12, 4)); // the ever-present flags
- $thisfile_riff_raw_avih['dwTotalFrames'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 16, 4)); // # frames in file
- $thisfile_riff_raw_avih['dwInitialFrames'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 20, 4));
- $thisfile_riff_raw_avih['dwStreams'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 24, 4));
- $thisfile_riff_raw_avih['dwSuggestedBufferSize'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 28, 4));
- $thisfile_riff_raw_avih['dwWidth'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 32, 4));
- $thisfile_riff_raw_avih['dwHeight'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 36, 4));
- $thisfile_riff_raw_avih['dwScale'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 40, 4));
- $thisfile_riff_raw_avih['dwRate'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 44, 4));
- $thisfile_riff_raw_avih['dwStart'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 48, 4));
- $thisfile_riff_raw_avih['dwLength'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 52, 4));
+ $thisfile_riff_raw_avih['dwMaxBytesPerSec'] = $this->EitherEndian2Int(substr($avihData, 4, 4)); // max. transfer rate
+ $thisfile_riff_raw_avih['dwPaddingGranularity'] = $this->EitherEndian2Int(substr($avihData, 8, 4)); // pad to multiples of this size; normally 2K.
+ $thisfile_riff_raw_avih['dwFlags'] = $this->EitherEndian2Int(substr($avihData, 12, 4)); // the ever-present flags
+ $thisfile_riff_raw_avih['dwTotalFrames'] = $this->EitherEndian2Int(substr($avihData, 16, 4)); // # frames in file
+ $thisfile_riff_raw_avih['dwInitialFrames'] = $this->EitherEndian2Int(substr($avihData, 20, 4));
+ $thisfile_riff_raw_avih['dwStreams'] = $this->EitherEndian2Int(substr($avihData, 24, 4));
+ $thisfile_riff_raw_avih['dwSuggestedBufferSize'] = $this->EitherEndian2Int(substr($avihData, 28, 4));
+ $thisfile_riff_raw_avih['dwWidth'] = $this->EitherEndian2Int(substr($avihData, 32, 4));
+ $thisfile_riff_raw_avih['dwHeight'] = $this->EitherEndian2Int(substr($avihData, 36, 4));
+ $thisfile_riff_raw_avih['dwScale'] = $this->EitherEndian2Int(substr($avihData, 40, 4));
+ $thisfile_riff_raw_avih['dwRate'] = $this->EitherEndian2Int(substr($avihData, 44, 4));
+ $thisfile_riff_raw_avih['dwStart'] = $this->EitherEndian2Int(substr($avihData, 48, 4));
+ $thisfile_riff_raw_avih['dwLength'] = $this->EitherEndian2Int(substr($avihData, 52, 4));
$thisfile_riff_raw_avih['flags']['hasindex'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00000010);
$thisfile_riff_raw_avih['flags']['mustuseindex'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00000020);
@@ -595,20 +743,20 @@ class getid3_riff
$thisfile_riff_raw['strh'][$i] = array();
$thisfile_riff_raw_strh_current = &$thisfile_riff_raw['strh'][$i];
- $thisfile_riff_raw_strh_current['fccType'] = substr($strhData, 0, 4); // same as $strhfccType;
- $thisfile_riff_raw_strh_current['fccHandler'] = substr($strhData, 4, 4);
- $thisfile_riff_raw_strh_current['dwFlags'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 8, 4)); // Contains AVITF_* flags
- $thisfile_riff_raw_strh_current['wPriority'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 12, 2));
- $thisfile_riff_raw_strh_current['wLanguage'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 14, 2));
- $thisfile_riff_raw_strh_current['dwInitialFrames'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 16, 4));
- $thisfile_riff_raw_strh_current['dwScale'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 20, 4));
- $thisfile_riff_raw_strh_current['dwRate'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 24, 4));
- $thisfile_riff_raw_strh_current['dwStart'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 28, 4));
- $thisfile_riff_raw_strh_current['dwLength'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 32, 4));
- $thisfile_riff_raw_strh_current['dwSuggestedBufferSize'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 36, 4));
- $thisfile_riff_raw_strh_current['dwQuality'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 40, 4));
- $thisfile_riff_raw_strh_current['dwSampleSize'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 44, 4));
- $thisfile_riff_raw_strh_current['rcFrame'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 48, 4));
+ $thisfile_riff_raw_strh_current['fccType'] = substr($strhData, 0, 4); // same as $strhfccType;
+ $thisfile_riff_raw_strh_current['fccHandler'] = substr($strhData, 4, 4);
+ $thisfile_riff_raw_strh_current['dwFlags'] = $this->EitherEndian2Int(substr($strhData, 8, 4)); // Contains AVITF_* flags
+ $thisfile_riff_raw_strh_current['wPriority'] = $this->EitherEndian2Int(substr($strhData, 12, 2));
+ $thisfile_riff_raw_strh_current['wLanguage'] = $this->EitherEndian2Int(substr($strhData, 14, 2));
+ $thisfile_riff_raw_strh_current['dwInitialFrames'] = $this->EitherEndian2Int(substr($strhData, 16, 4));
+ $thisfile_riff_raw_strh_current['dwScale'] = $this->EitherEndian2Int(substr($strhData, 20, 4));
+ $thisfile_riff_raw_strh_current['dwRate'] = $this->EitherEndian2Int(substr($strhData, 24, 4));
+ $thisfile_riff_raw_strh_current['dwStart'] = $this->EitherEndian2Int(substr($strhData, 28, 4));
+ $thisfile_riff_raw_strh_current['dwLength'] = $this->EitherEndian2Int(substr($strhData, 32, 4));
+ $thisfile_riff_raw_strh_current['dwSuggestedBufferSize'] = $this->EitherEndian2Int(substr($strhData, 36, 4));
+ $thisfile_riff_raw_strh_current['dwQuality'] = $this->EitherEndian2Int(substr($strhData, 40, 4));
+ $thisfile_riff_raw_strh_current['dwSampleSize'] = $this->EitherEndian2Int(substr($strhData, 44, 4));
+ $thisfile_riff_raw_strh_current['rcFrame'] = $this->EitherEndian2Int(substr($strhData, 48, 4));
$thisfile_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($thisfile_riff_raw_strh_current['fccHandler']);
$thisfile_video['fourcc'] = $thisfile_riff_raw_strh_current['fccHandler'];
@@ -632,19 +780,8 @@ class getid3_riff
switch ($strhfccType) {
case 'vids':
- $thisfile_riff_raw_strf_strhfccType_streamindex = getid3_riff::ParseBITMAPINFOHEADER(substr($strfData, 0, 40), ($ThisFileInfo['fileformat'] == 'riff'));
- //$thisfile_riff_raw_strf_strhfccType_streamindex['biSize'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strfData, 0, 4)); // number of bytes required by the BITMAPINFOHEADER structure
- //$thisfile_riff_raw_strf_strhfccType_streamindex['biWidth'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strfData, 4, 4)); // width of the bitmap in pixels
- //$thisfile_riff_raw_strf_strhfccType_streamindex['biHeight'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strfData, 8, 4)); // height of the bitmap in pixels. If biHeight is positive, the bitmap is a 'bottom-up' DIB and its origin is the lower left corner. If biHeight is negative, the bitmap is a 'top-down' DIB and its origin is the upper left corner
- //$thisfile_riff_raw_strf_strhfccType_streamindex['biPlanes'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strfData, 12, 2)); // number of color planes on the target device. In most cases this value must be set to 1
- //$thisfile_riff_raw_strf_strhfccType_streamindex['biBitCount'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strfData, 14, 2)); // Specifies the number of bits per pixels
- //$thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'] = substr($strfData, 16, 4); //
- //$thisfile_riff_raw_strf_strhfccType_streamindex['biSizeImage'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strfData, 20, 4)); // size of the bitmap data section of the image (the actual pixel data, excluding BITMAPINFOHEADER and RGBQUAD structures)
- //$thisfile_riff_raw_strf_strhfccType_streamindex['biXPelsPerMeter'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strfData, 24, 4)); // horizontal resolution, in pixels per metre, of the target device
- //$thisfile_riff_raw_strf_strhfccType_streamindex['biYPelsPerMeter'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strfData, 28, 4)); // vertical resolution, in pixels per metre, of the target device
- //$thisfile_riff_raw_strf_strhfccType_streamindex['biClrUsed'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strfData, 32, 4)); // actual number of color indices in the color table used by the bitmap. If this value is zero, the bitmap uses the maximum number of colors corresponding to the value of the biBitCount member for the compression mode specified by biCompression
- //$thisfile_riff_raw_strf_strhfccType_streamindex['biClrImportant'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strfData, 36, 4)); // number of color indices that are considered important for displaying the bitmap. If this value is zero, all colors are important
-
+ $thisfile_riff_raw_strf_strhfccType_streamindex = getid3_riff::ParseBITMAPINFOHEADER(substr($strfData, 0, 40), ($info['fileformat'] == 'riff'));
+//echo '<pre>'.print_r($thisfile_riff_raw_strf_strhfccType_streamindex, true).'</pre>';
$thisfile_video['bits_per_sample'] = $thisfile_riff_raw_strf_strhfccType_streamindex['biBitCount'];
if ($thisfile_riff_video_current['codec'] == 'DV') {
@@ -659,30 +796,32 @@ class getid3_riff
break;
default:
- $ThisFileInfo['warning'][] = 'Unhandled fccType for stream ('.$i.'): "'.$strhfccType.'"';
+ $info['warning'][] = 'Unhandled fccType for stream ('.$i.'): "'.$strhfccType.'"';
break;
}
}
}
- if (isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) && getid3_riff::RIFFfourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
+ if (isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
- $thisfile_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']);
- $thisfile_video['codec'] = $thisfile_riff_video_current['codec'];
- $thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'];
+ $thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'];
+ if (getid3_riff::RIFFfourccLookup($thisfile_video['fourcc'])) {
+ $thisfile_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($thisfile_video['fourcc']);
+ $thisfile_video['codec'] = $thisfile_riff_video_current['codec'];
+ }
switch ($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) {
case 'HFYU': // Huffman Lossless Codec
case 'IRAW': // Intel YUV Uncompressed
case 'YUY2': // Uncompressed YUV 4:2:2
$thisfile_video['lossless'] = true;
- $thisfile_video['bits_per_sample'] = 24;
+ //$thisfile_video['bits_per_sample'] = 24;
break;
default:
$thisfile_video['lossless'] = false;
- $thisfile_video['bits_per_sample'] = 24;
+ //$thisfile_video['bits_per_sample'] = 24;
break;
}
@@ -696,26 +835,26 @@ class getid3_riff
$thisfile_audio['bitrate_mode'] = 'cbr';
$thisfile_audio_dataformat = 'cda';
$thisfile_audio['lossless'] = true;
- unset($ThisFileInfo['mime_type']);
+ unset($info['mime_type']);
- $thisfile_avdataoffset = 44;
+ $info['avdataoffset'] = 44;
if (isset($thisfile_riff['CDDA']['fmt '][0]['data'])) {
// shortcut
$thisfile_riff_CDDA_fmt_0 = &$thisfile_riff['CDDA']['fmt '][0];
- $thisfile_riff_CDDA_fmt_0['unknown1'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 0, 2));
- $thisfile_riff_CDDA_fmt_0['track_num'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 2, 2));
- $thisfile_riff_CDDA_fmt_0['disc_id'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 4, 4));
- $thisfile_riff_CDDA_fmt_0['start_offset_frame'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 8, 4));
- $thisfile_riff_CDDA_fmt_0['playtime_frames'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 12, 4));
- $thisfile_riff_CDDA_fmt_0['unknown6'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 16, 4));
- $thisfile_riff_CDDA_fmt_0['unknown7'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 20, 4));
+ $thisfile_riff_CDDA_fmt_0['unknown1'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 0, 2));
+ $thisfile_riff_CDDA_fmt_0['track_num'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 2, 2));
+ $thisfile_riff_CDDA_fmt_0['disc_id'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 4, 4));
+ $thisfile_riff_CDDA_fmt_0['start_offset_frame'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 8, 4));
+ $thisfile_riff_CDDA_fmt_0['playtime_frames'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 12, 4));
+ $thisfile_riff_CDDA_fmt_0['unknown6'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 16, 4));
+ $thisfile_riff_CDDA_fmt_0['unknown7'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 20, 4));
$thisfile_riff_CDDA_fmt_0['start_offset_seconds'] = (float) $thisfile_riff_CDDA_fmt_0['start_offset_frame'] / 75;
$thisfile_riff_CDDA_fmt_0['playtime_seconds'] = (float) $thisfile_riff_CDDA_fmt_0['playtime_frames'] / 75;
- $ThisFileInfo['comments']['track'] = $thisfile_riff_CDDA_fmt_0['track_num'];
- $ThisFileInfo['playtime_seconds'] = $thisfile_riff_CDDA_fmt_0['playtime_seconds'];
+ $info['comments']['track'] = $thisfile_riff_CDDA_fmt_0['track_num'];
+ $info['playtime_seconds'] = $thisfile_riff_CDDA_fmt_0['playtime_seconds'];
// hardcoded data for CD-audio
$thisfile_audio['sample_rate'] = 44100;
@@ -732,19 +871,19 @@ class getid3_riff
$thisfile_audio['bitrate_mode'] = 'cbr';
$thisfile_audio_dataformat = 'aiff';
$thisfile_audio['lossless'] = true;
- $ThisFileInfo['mime_type'] = 'audio/x-aiff';
+ $info['mime_type'] = 'audio/x-aiff';
if (isset($thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'])) {
- $thisfile_avdataoffset = $thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'] + 8;
- $thisfile_avdataend = $thisfile_avdataoffset + $thisfile_riff[$RIFFsubtype]['SSND'][0]['size'];
- if ($thisfile_avdataend > $ThisFileInfo['filesize']) {
- if (($thisfile_avdataend == ($ThisFileInfo['filesize'] + 1)) && (($ThisFileInfo['filesize'] % 2) == 1)) {
+ $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'] + 8;
+ $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff[$RIFFsubtype]['SSND'][0]['size'];
+ if ($info['avdataend'] > $info['filesize']) {
+ if (($info['avdataend'] == ($info['filesize'] + 1)) && (($info['filesize'] % 2) == 1)) {
// structures rounded to 2-byte boundary, but dumb encoders
// forget to pad end of file to make this actually work
} else {
- $ThisFileInfo['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['SSND'][0]['size'].' bytes of audio data, only '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' bytes found';
+ $info['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['SSND'][0]['size'].' bytes of audio data, only '.($info['filesize'] - $info['avdataoffset']).' bytes found';
}
- $thisfile_avdataend = $ThisFileInfo['filesize'];
+ $info['avdataend'] = $info['filesize'];
}
}
@@ -799,28 +938,28 @@ class getid3_riff
}
$thisfile_audio['sample_rate'] = $thisfile_riff_audio['sample_rate'];
if ($thisfile_audio['sample_rate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupted AIFF file: sample_rate == zero';
+ $info['error'][] = 'Corrupted AIFF file: sample_rate == zero';
return false;
}
- $ThisFileInfo['playtime_seconds'] = $thisfile_riff_audio['total_samples'] / $thisfile_audio['sample_rate'];
+ $info['playtime_seconds'] = $thisfile_riff_audio['total_samples'] / $thisfile_audio['sample_rate'];
}
if (isset($thisfile_riff[$RIFFsubtype]['COMT'])) {
$offset = 0;
- $CommentCount = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);
+ $CommentCount = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);
$offset += 2;
for ($i = 0; $i < $CommentCount; $i++) {
- $ThisFileInfo['comments_raw'][$i]['timestamp'] = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 4), false);
+ $info['comments_raw'][$i]['timestamp'] = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 4), false);
$offset += 4;
- $ThisFileInfo['comments_raw'][$i]['marker_id'] = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), true);
+ $info['comments_raw'][$i]['marker_id'] = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), true);
$offset += 2;
- $CommentLength = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);
+ $CommentLength = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);
$offset += 2;
- $ThisFileInfo['comments_raw'][$i]['comment'] = substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, $CommentLength);
+ $info['comments_raw'][$i]['comment'] = substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, $CommentLength);
$offset += $CommentLength;
- $ThisFileInfo['comments_raw'][$i]['timestamp_unix'] = getid3_lib::DateMac2Unix($ThisFileInfo['comments_raw'][$i]['timestamp']);
- $thisfile_riff['comments']['comment'][] = $ThisFileInfo['comments_raw'][$i]['comment'];
+ $info['comments_raw'][$i]['timestamp_unix'] = getid3_lib::DateMac2Unix($info['comments_raw'][$i]['timestamp']);
+ $thisfile_riff['comments']['comment'][] = $info['comments_raw'][$i]['comment'];
}
}
@@ -830,6 +969,18 @@ class getid3_riff
$thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];
}
}
+
+ if (isset($thisfile_riff[$RIFFsubtype]['ID3 '])) {
+ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true);
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_id3v2 = new getid3_id3v2($getid3_temp);
+ $getid3_id3v2->StartingOffset = $thisfile_riff[$RIFFsubtype]['ID3 '][0]['offset'] + 8;
+ if ($thisfile_riff[$RIFFsubtype]['ID3 '][0]['valid'] = $getid3_id3v2->Analyze()) {
+ $info['id3v2'] = $getid3_temp->info['id3v2'];
+ }
+ unset($getid3_temp, $getid3_id3v2);
+ }
break;
case '8SVX':
@@ -837,13 +988,13 @@ class getid3_riff
$thisfile_audio_dataformat = '8svx';
$thisfile_audio['bits_per_sample'] = 8;
$thisfile_audio['channels'] = 1; // overridden below, if need be
- $ThisFileInfo['mime_type'] = 'audio/x-aiff';
+ $info['mime_type'] = 'audio/x-aiff';
if (isset($thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'])) {
- $thisfile_avdataoffset = $thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'] + 8;
- $thisfile_avdataend = $thisfile_avdataoffset + $thisfile_riff[$RIFFsubtype]['BODY'][0]['size'];
- if ($thisfile_avdataend > $ThisFileInfo['filesize']) {
- $ThisFileInfo['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['BODY'][0]['size'].' bytes of audio data, only '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' bytes found';
+ $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'] + 8;
+ $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff[$RIFFsubtype]['BODY'][0]['size'];
+ if ($info['avdataend'] > $info['filesize']) {
+ $info['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['BODY'][0]['size'].' bytes of audio data, only '.($info['filesize'] - $info['avdataoffset']).' bytes found';
}
}
@@ -865,17 +1016,17 @@ class getid3_riff
case 0:
$thisfile_audio['codec'] = 'Pulse Code Modulation (PCM)';
$thisfile_audio['lossless'] = true;
- $ActualBitsPerSample = 8;
+ $ActualBitsPerSample = 8;
break;
case 1:
$thisfile_audio['codec'] = 'Fibonacci-delta encoding';
$thisfile_audio['lossless'] = false;
- $ActualBitsPerSample = 4;
+ $ActualBitsPerSample = 4;
break;
default:
- $ThisFileInfo['warning'][] = 'Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "'.sCompression.'"';
+ $info['warning'][] = 'Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "'.sCompression.'"';
break;
}
}
@@ -893,7 +1044,7 @@ class getid3_riff
break;
default:
- $ThisFileInfo['warning'][] = 'Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "'.$ChannelsIndex.'"';
+ $info['warning'][] = 'Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "'.$ChannelsIndex.'"';
break;
}
@@ -908,41 +1059,41 @@ class getid3_riff
$thisfile_audio['bitrate'] = $thisfile_audio['sample_rate'] * $ActualBitsPerSample * $thisfile_audio['channels'];
if (!empty($thisfile_audio['bitrate'])) {
- $ThisFileInfo['playtime_seconds'] = ($thisfile_avdataend - $thisfile_avdataoffset) / ($thisfile_audio['bitrate'] / 8);
+ $info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) / ($thisfile_audio['bitrate'] / 8);
}
break;
case 'CDXA':
- $ThisFileInfo['mime_type'] = 'video/mpeg';
+ $info['mime_type'] = 'video/mpeg';
if (!empty($thisfile_riff['CDXA']['data'][0]['size'])) {
- $GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.mpeg.php', __FILE__, false)) {
- $dummy = $ThisFileInfo;
- $dummy['error'] = array();
- $mpeg_scanner = new getid3_mpeg($fd, $dummy);
- if (empty($dummy['error'])) {
- $ThisFileInfo['audio'] = $dummy['audio'];
- $ThisFileInfo['video'] = $dummy['video'];
- $ThisFileInfo['mpeg'] = $dummy['mpeg'];
- $ThisFileInfo['warning'] = $dummy['warning'];
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_mpeg = new getid3_mpeg($getid3_temp);
+ $getid3_mpeg->Analyze();
+ if (empty($getid3_temp->info['error'])) {
+ $info['audio'] = $getid3_temp->info['audio'];
+ $info['video'] = $getid3_temp->info['video'];
+ $info['mpeg'] = $getid3_temp->info['mpeg'];
+ $info['warning'] = $getid3_temp->info['warning'];
}
- unset($mpeg_scanner);
+ unset($getid3_temp, $getid3_mpeg);
}
}
break;
default:
- $ThisFileInfo['error'][] = 'Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "'.$RIFFsubtype.'" instead';
- unset($ThisFileInfo['fileformat']);
+ $info['error'][] = 'Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "'.$RIFFsubtype.'" instead';
+ unset($info['fileformat']);
break;
}
- if (@$thisfile_riff_raw['fmt ']['wFormatTag'] == 1) {
+ if (isset($thisfile_riff_raw['fmt ']['wFormatTag']) && ($thisfile_riff_raw['fmt ']['wFormatTag'] == 1)) {
// http://www.mega-nerd.com/erikd/Blog/Windiots/dts.html
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $FirstFourBytes = fread($fd, 4);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $FirstFourBytes = fread($this->getid3->fp, 4);
if (preg_match('/^\xFF\x1F\x00\xE8/s', $FirstFourBytes)) {
// DTSWAV
$thisfile_audio_dataformat = 'dts';
@@ -959,46 +1110,52 @@ class getid3_riff
if (isset($thisfile_riff_WAVE['INFO']) && is_array($thisfile_riff_WAVE['INFO'])) {
$this->RIFFcommentsParse($thisfile_riff_WAVE['INFO'], $thisfile_riff['comments']);
}
+ if (isset($thisfile_riff['AVI ']['INFO']) && is_array($thisfile_riff['AVI ']['INFO'])) {
+ $this->RIFFcommentsParse($thisfile_riff['AVI ']['INFO'], $thisfile_riff['comments']);
+ }
- if (empty($thisfile_audio['encoder']) && !empty($ThisFileInfo['mpeg']['audio']['LAME']['short_version'])) {
- $thisfile_audio['encoder'] = $ThisFileInfo['mpeg']['audio']['LAME']['short_version'];
+ if (empty($thisfile_audio['encoder']) && !empty($info['mpeg']['audio']['LAME']['short_version'])) {
+ $thisfile_audio['encoder'] = $info['mpeg']['audio']['LAME']['short_version'];
}
- if (!isset($ThisFileInfo['playtime_seconds'])) {
- $ThisFileInfo['playtime_seconds'] = 0;
+ if (!isset($info['playtime_seconds'])) {
+ $info['playtime_seconds'] = 0;
}
- if (isset($thisfile_riff_raw['avih']['dwTotalFrames']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) {
- $ThisFileInfo['playtime_seconds'] = $thisfile_riff_raw['avih']['dwTotalFrames'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
+ if (isset($thisfile_riff_raw['strh'][0]['dwLength']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) {
+ // needed for >2GB AVIs where 'avih' chunk only lists number of frames in that chunk, not entire movie
+ $info['playtime_seconds'] = $thisfile_riff_raw['strh'][0]['dwLength'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
+ } elseif (isset($thisfile_riff_raw['avih']['dwTotalFrames']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) {
+ $info['playtime_seconds'] = $thisfile_riff_raw['avih']['dwTotalFrames'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
}
- if ($ThisFileInfo['playtime_seconds'] > 0) {
+ if ($info['playtime_seconds'] > 0) {
if (isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {
- if (!isset($ThisFileInfo['bitrate'])) {
- $ThisFileInfo['bitrate'] = ((($thisfile_avdataend - $thisfile_avdataoffset) / $ThisFileInfo['playtime_seconds']) * 8);
+ if (!isset($info['bitrate'])) {
+ $info['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8);
}
} elseif (isset($thisfile_riff_audio) && !isset($thisfile_riff_video)) {
if (!isset($thisfile_audio['bitrate'])) {
- $thisfile_audio['bitrate'] = ((($thisfile_avdataend - $thisfile_avdataoffset) / $ThisFileInfo['playtime_seconds']) * 8);
+ $thisfile_audio['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8);
}
} elseif (!isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {
if (!isset($thisfile_video['bitrate'])) {
- $thisfile_video['bitrate'] = ((($thisfile_avdataend - $thisfile_avdataoffset) / $ThisFileInfo['playtime_seconds']) * 8);
+ $thisfile_video['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8);
}
}
}
- if (isset($thisfile_riff_video) && isset($thisfile_audio['bitrate']) && ($thisfile_audio['bitrate'] > 0) && ($ThisFileInfo['playtime_seconds'] > 0)) {
+ if (isset($thisfile_riff_video) && isset($thisfile_audio['bitrate']) && ($thisfile_audio['bitrate'] > 0) && ($info['playtime_seconds'] > 0)) {
- $ThisFileInfo['bitrate'] = ((($thisfile_avdataend - $thisfile_avdataoffset) / $ThisFileInfo['playtime_seconds']) * 8);
+ $info['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8);
$thisfile_audio['bitrate'] = 0;
- $thisfile_video['bitrate'] = $ThisFileInfo['bitrate'];
+ $thisfile_video['bitrate'] = $info['bitrate'];
foreach ($thisfile_riff_audio as $channelnumber => $audioinfoarray) {
$thisfile_video['bitrate'] -= $audioinfoarray['bitrate'];
$thisfile_audio['bitrate'] += $audioinfoarray['bitrate'];
@@ -1011,14 +1168,14 @@ class getid3_riff
}
}
- if (isset($ThisFileInfo['mpeg']['audio'])) {
- $thisfile_audio_dataformat = 'mp'.$ThisFileInfo['mpeg']['audio']['layer'];
- $thisfile_audio['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
- $thisfile_audio['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
- $thisfile_audio['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
- $thisfile_audio['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
- if (!empty($ThisFileInfo['mpeg']['audio']['codec'])) {
- $thisfile_audio['codec'] = $ThisFileInfo['mpeg']['audio']['codec'].' '.$thisfile_audio['codec'];
+ if (isset($info['mpeg']['audio'])) {
+ $thisfile_audio_dataformat = 'mp'.$info['mpeg']['audio']['layer'];
+ $thisfile_audio['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
+ $thisfile_audio['channels'] = $info['mpeg']['audio']['channels'];
+ $thisfile_audio['bitrate'] = $info['mpeg']['audio']['bitrate'];
+ $thisfile_audio['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
+ if (!empty($info['mpeg']['audio']['codec'])) {
+ $thisfile_audio['codec'] = $info['mpeg']['audio']['codec'].' '.$thisfile_audio['codec'];
}
if (!empty($thisfile_audio['streams'])) {
foreach ($thisfile_audio['streams'] as $streamnumber => $streamdata) {
@@ -1031,7 +1188,9 @@ class getid3_riff
}
}
}
- $thisfile_audio['encoder_options'] = getid3_mp3::GuessEncoderOptions($ThisFileInfo);
+ $getid3_mp3 = new getid3_mp3($this->getid3);
+ $thisfile_audio['encoder_options'] = $getid3_mp3->GuessEncoderOptions();
+ unset($getid3_mp3);
}
@@ -1062,7 +1221,7 @@ class getid3_riff
}
- function RIFFcommentsParse(&$RIFFinfoArray, &$CommentsTargetArray) {
+ static function RIFFcommentsParse(&$RIFFinfoArray, &$CommentsTargetArray) {
$RIFFinfoKeyLookup = array(
'IARL'=>'archivallocation',
'IART'=>'artist',
@@ -1108,7 +1267,11 @@ class getid3_riff
if (isset($RIFFinfoArray[$key])) {
foreach ($RIFFinfoArray[$key] as $commentid => $commentdata) {
if (trim($commentdata['data']) != '') {
- @$CommentsTargetArray[$value][] = trim($commentdata['data']);
+ if (isset($CommentsTargetArray[$value])) {
+ $CommentsTargetArray[$value][] = trim($commentdata['data']);
+ } else {
+ $CommentsTargetArray[$value] = array(trim($commentdata['data']));
+ }
}
}
}
@@ -1116,29 +1279,39 @@ class getid3_riff
return true;
}
- function ParseRIFF(&$fd, $startoffset, $maxoffset, &$ThisFileInfo) {
- $maxoffset = min($maxoffset, $ThisFileInfo['avdataend']);
+ function ParseRIFF($startoffset, $maxoffset) {
+ $info = &$this->getid3->info;
+
+ $maxoffset = min($maxoffset, $info['avdataend']);
$RIFFchunk = false;
$FoundAllChunksWeNeed = false;
- if (($startoffset < 0) || ($startoffset >= pow(2, 31))) {
- $ThisFileInfo['warning'][] = 'Unable to ParseRIFF() at '.$startoffset.' because beyond 2GB limit of PHP filesystem functions';
+ if (($startoffset < 0) || !getid3_lib::intValueSupported($startoffset)) {
+ $info['warning'][] = 'Unable to ParseRIFF() at '.$startoffset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
return false;
}
- fseek($fd, $startoffset, SEEK_SET);
+ $max_usable_offset = min(PHP_INT_MAX - 1024, $maxoffset);
+ if ($maxoffset > $max_usable_offset) {
+ $info['warning'][] = 'ParseRIFF() may return incomplete data for chunk starting at '.$startoffset.' because beyond it extends to '.$maxoffset.', which is beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
+ }
+ fseek($this->getid3->fp, $startoffset, SEEK_SET);
- while (ftell($fd) < $maxoffset) {
- $chunkname = fread($fd, 4);
+ while (ftell($this->getid3->fp) < $max_usable_offset) {
+ $chunknamesize = fread($this->getid3->fp, 8);
+ $chunkname = substr($chunknamesize, 0, 4);
+ $chunksize = $this->EitherEndian2Int(substr($chunknamesize, 4, 4));
if (strlen($chunkname) < 4) {
- $ThisFileInfo['error'][] = 'Expecting chunk name at offset '.(ftell($fd) - 4).' but found nothing. Aborting RIFF parsing.';
+ $info['error'][] = 'Expecting chunk name at offset '.(ftell($this->getid3->fp) - 4).' but found nothing. Aborting RIFF parsing.';
break;
}
-
- $chunksize = getid3_riff::EitherEndian2Int($ThisFileInfo, fread($fd, 4));
if ($chunksize == 0) {
- $ThisFileInfo['warning'][] = 'Chunk size at offset '.(ftell($fd) - 4).' is zero. Aborting RIFF parsing.';
- continue;
+ if ($chunkname == 'JUNK') {
+ // we'll allow zero-size JUNK frames
+ } else {
+ $info['warning'][] = 'Chunk size at offset '.(ftell($this->getid3->fp) - 4).' is zero. Aborting RIFF parsing.';
+ break;
+ }
}
if (($chunksize % 2) != 0) {
// all structures are packed on word boundaries
@@ -1147,9 +1320,9 @@ class getid3_riff
switch ($chunkname) {
case 'LIST':
- $listname = fread($fd, 4);
- if (eregi('^(movi|rec )$', $listname)) {
- $RIFFchunk[$listname]['offset'] = ftell($fd) - 4;
+ $listname = fread($this->getid3->fp, 4);
+ if (preg_match('#^(movi|rec )$#i', $listname)) {
+ $RIFFchunk[$listname]['offset'] = ftell($this->getid3->fp) - 4;
$RIFFchunk[$listname]['size'] = $chunksize;
if ($FoundAllChunksWeNeed) {
@@ -1158,8 +1331,8 @@ class getid3_riff
} else {
- $WhereWeWere = ftell($fd);
- $AudioChunkHeader = fread($fd, 12);
+ $WhereWeWere = ftell($this->getid3->fp);
+ $AudioChunkHeader = fread($this->getid3->fp, 12);
$AudioChunkStreamNum = substr($AudioChunkHeader, 0, 2);
$AudioChunkStreamType = substr($AudioChunkHeader, 2, 2);
$AudioChunkSize = getid3_lib::LittleEndian2Int(substr($AudioChunkHeader, 4, 4));
@@ -1169,40 +1342,45 @@ class getid3_riff
if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', $FirstFourBytes)) {
// MP3
if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) {
- $dummy = $ThisFileInfo;
- $dummy['avdataoffset'] = ftell($fd) - 4;
- $dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
- getid3_mp3::getOnlyMPEGaudioInfo($fd, $dummy, $dummy['avdataoffset'], false);
- if (isset($dummy['mpeg']['audio'])) {
- $ThisFileInfo = $dummy;
- $ThisFileInfo['audio']['dataformat'] = 'mp'.$ThisFileInfo['mpeg']['audio']['layer'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
- $ThisFileInfo['bitrate'] = $ThisFileInfo['audio']['bitrate'];
- $ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataoffset'] = ftell($this->getid3->fp) - 4;
+ $getid3_temp->info['avdataend'] = ftell($this->getid3->fp) + $AudioChunkSize;
+ $getid3_mp3 = new getid3_mp3($getid3_temp);
+ $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
+ if (isset($getid3_temp->info['mpeg']['audio'])) {
+ $info['mpeg']['audio'] = $getid3_temp->info['mpeg']['audio'];
+ $info['audio'] = $getid3_temp->info['audio'];
+ $info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer'];
+ $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
+ $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
+ $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
+ $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
+ //$info['bitrate'] = $info['audio']['bitrate'];
}
- unset($dummy);
+ unset($getid3_temp, $getid3_mp3);
}
} elseif (preg_match('/^\x0B\x77/s', $FirstFourBytes)) {
// AC3
- $GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
-
- $dummy = $ThisFileInfo;
- $dummy['avdataoffset'] = ftell($fd) - 4;
- $dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
- $dummy['error'] = array();
- $ac3_tag = new getid3_ac3($fd, $dummy);
- if (empty($dummy['error'])) {
- $ThisFileInfo['audio'] = $dummy['audio'];
- $ThisFileInfo['ac3'] = $dummy['ac3'];
- $ThisFileInfo['warning'] = $dummy['warning'];
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataoffset'] = ftell($this->getid3->fp) - 4;
+ $getid3_temp->info['avdataend'] = ftell($this->getid3->fp) + $AudioChunkSize;
+ $getid3_ac3 = new getid3_ac3($getid3_temp);
+ $getid3_ac3->Analyze();
+ if (empty($getid3_temp->info['error'])) {
+ $info['audio'] = $getid3_temp->info['audio'];
+ $info['ac3'] = $getid3_temp->info['ac3'];
+ if (!empty($getid3_temp->info['warning'])) {
+ foreach ($getid3_temp->info['warning'] as $key => $value) {
+ $info['warning'][] = $value;
+ }
+ }
}
- unset($ac3_tag);
-
+ unset($getid3_temp, $getid3_ac3);
}
}
@@ -1210,23 +1388,23 @@ class getid3_riff
}
$FoundAllChunksWeNeed = true;
- fseek($fd, $WhereWeWere, SEEK_SET);
+ fseek($this->getid3->fp, $WhereWeWere, SEEK_SET);
}
- fseek($fd, $chunksize - 4, SEEK_CUR);
+ fseek($this->getid3->fp, $chunksize - 4, SEEK_CUR);
- //} elseif (ereg('^[0-9]{2}(wb|pc|dc|db)$', $listname)) {
- //
+ //} elseif (preg_match('#^[0-9]{2}(wb|pc|dc|db)$#i', $listname)) {
+ //
// // data chunk, ignore
- //
+ //
} else {
if (!isset($RIFFchunk[$listname])) {
$RIFFchunk[$listname] = array();
}
$LISTchunkParent = $listname;
- $LISTchunkMaxOffset = ftell($fd) - 4 + $chunksize;
- if ($parsedChunk = getid3_riff::ParseRIFF($fd, ftell($fd), ftell($fd) + $chunksize - 4, $ThisFileInfo)) {
+ $LISTchunkMaxOffset = ftell($this->getid3->fp) - 4 + $chunksize;
+ if ($parsedChunk = $this->ParseRIFF(ftell($this->getid3->fp), ftell($this->getid3->fp) + $chunksize - 4)) {
$RIFFchunk[$listname] = array_merge_recursive($RIFFchunk[$listname], $parsedChunk);
}
@@ -1234,63 +1412,61 @@ class getid3_riff
break;
default:
- if (eregi('^[0-9]{2}(wb|pc|dc|db)$', $chunkname)) {
- $nextoffset = ftell($fd) + $chunksize;
- if (($nextoffset < 0) || ($nextoffset >= pow(2, 31))) {
- $ThisFileInfo['warning'][] = 'Unable to parse chunk at offset '.$nextoffset.' because beyond 2GB limit of PHP filesystem functions';
+ if (preg_match('#^[0-9]{2}(wb|pc|dc|db)$#', $chunkname)) {
+ $nextoffset = ftell($this->getid3->fp) + $chunksize;
+ if (($nextoffset < 0) || !getid3_lib::intValueSupported($nextoffset)) {
+ $info['warning'][] = 'Unable to parse chunk at offset '.$nextoffset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
break 2;
}
- fseek($fd, $nextoffset, SEEK_SET);
+ fseek($this->getid3->fp, $nextoffset, SEEK_SET);
break;
}
$thisindex = 0;
if (isset($RIFFchunk[$chunkname]) && is_array($RIFFchunk[$chunkname])) {
$thisindex = count($RIFFchunk[$chunkname]);
}
- $RIFFchunk[$chunkname][$thisindex]['offset'] = ftell($fd) - 8;
+ $RIFFchunk[$chunkname][$thisindex]['offset'] = ftell($this->getid3->fp) - 8;
$RIFFchunk[$chunkname][$thisindex]['size'] = $chunksize;
switch ($chunkname) {
case 'data':
- $ThisFileInfo['avdataoffset'] = ftell($fd);
- $ThisFileInfo['avdataend'] = $ThisFileInfo['avdataoffset'] + $chunksize;
+ $info['avdataoffset'] = ftell($this->getid3->fp);
+ $info['avdataend'] = $info['avdataoffset'] + $chunksize;
- $RIFFdataChunkContentsTest = fread($fd, 36);
+ $RIFFdataChunkContentsTest = fread($this->getid3->fp, 36);
if ((strlen($RIFFdataChunkContentsTest) > 0) && preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', substr($RIFFdataChunkContentsTest, 0, 4))) {
// Probably is MP3 data
if (getid3_mp3::MPEGaudioHeaderBytesValid(substr($RIFFdataChunkContentsTest, 0, 4))) {
-
- // copy info array
- $dummy = $ThisFileInfo;
-
- getid3_mp3::getOnlyMPEGaudioInfo($fd, $dummy, $RIFFchunk[$chunkname][$thisindex]['offset'], false);
-
- // use dummy array unless error
- if (empty($dummy['error'])) {
- $ThisFileInfo = $dummy;
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataoffset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
+ $getid3_temp->info['avdataend'] = $RIFFchunk[$chunkname][$thisindex]['offset'] + $RIFFchunk[$chunkname][$thisindex]['size'];
+ $getid3_mp3 = new getid3_mp3($getid3_temp);
+ $getid3_mp3->getOnlyMPEGaudioInfo($RIFFchunk[$chunkname][$thisindex]['offset'], false);
+ if (empty($getid3_temp->info['error'])) {
+ $info['mpeg'] = $getid3_temp->info['mpeg'];
+ $info['audio'] = $getid3_temp->info['audio'];
}
+ unset($getid3_temp, $getid3_mp3);
}
} elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 0, 2) == "\x0B\x77")) {
// This is probably AC-3 data
- $GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
-
- $dummy = $ThisFileInfo;
- $dummy['avdataoffset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
- $dummy['avdataend'] = $dummy['avdataoffset'] + $RIFFchunk[$chunkname][$thisindex]['size'];
- $dummy['error'] = array();
-
- $ac3_tag = new getid3_ac3($fd, $dummy);
- if (empty($dummy['error'])) {
- $ThisFileInfo['audio'] = $dummy['audio'];
- $ThisFileInfo['ac3'] = $dummy['ac3'];
- $ThisFileInfo['warning'] = $dummy['warning'];
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataoffset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
+ $getid3_temp->info['avdataend'] = $RIFFchunk[$chunkname][$thisindex]['offset'] + $RIFFchunk[$chunkname][$thisindex]['size'];
+ $getid3_ac3 = new getid3_ac3($getid3_temp);
+ $getid3_ac3->Analyze();
+ if (empty($getid3_temp->info['error'])) {
+ $info['audio'] = $getid3_temp->info['audio'];
+ $info['ac3'] = $getid3_temp->info['ac3'];
+ $info['warning'] = $getid3_temp->info['warning'];
}
- unset($ac3_tag);
-
+ unset($getid3_temp, $getid3_ac3);
}
} elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 8, 2) == "\x77\x0B")) {
@@ -1299,37 +1475,38 @@ class getid3_riff
// AC-3 content, but not encoded in same format as normal AC-3 file
// For one thing, byte order is swapped
- $GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
// ok to use tmpfile here - only 56 bytes
- if ($fd_temp = tmpfile()) {
-
- for ($i = 0; $i < 28; $i += 2) {
- // swap byte order
- fwrite($fd_temp, substr($RIFFdataChunkContentsTest, 8 + $i + 1, 1));
- fwrite($fd_temp, substr($RIFFdataChunkContentsTest, 8 + $i + 0, 1));
- }
-
- $dummy = $ThisFileInfo;
- $dummy['avdataoffset'] = 0;
- $dummy['avdataend'] = 20;
- $dummy['error'] = array();
- $ac3_tag = new getid3_ac3($fd_temp, $dummy);
- fclose($fd_temp);
- if (empty($dummy['error'])) {
- $ThisFileInfo['audio'] = $dummy['audio'];
- $ThisFileInfo['ac3'] = $dummy['ac3'];
- $ThisFileInfo['warning'] = $dummy['warning'];
+ if ($RIFFtempfilename = tempnam(GETID3_TEMP_DIR, 'id3')) {
+ if ($fd_temp = fopen($RIFFtempfilename, 'wb')) {
+ for ($i = 0; $i < 28; $i += 2) {
+ // swap byte order
+ fwrite($fd_temp, substr($RIFFdataChunkContentsTest, 8 + $i + 1, 1));
+ fwrite($fd_temp, substr($RIFFdataChunkContentsTest, 8 + $i + 0, 1));
+ }
+ fclose($fd_temp);
+
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($RIFFtempfilename);
+ $getid3_temp->info['avdataend'] = 20;
+ $getid3_ac3 = new getid3_ac3($getid3_temp);
+ $getid3_ac3->Analyze();
+ if (empty($getid3_temp->info['error'])) {
+ $info['audio'] = $getid3_temp->info['audio'];
+ $info['ac3'] = $getid3_temp->info['ac3'];
+ $info['warning'] = $getid3_temp->info['warning'];
+ } else {
+ $info['error'][] = 'Error parsing Dolby Digital WAV (AC3-in-RIFF): '.implode(';', $getid3_temp->info['error']);
+ }
+ unset($getid3_ac3, $getid3_temp);
} else {
- $ThisFileInfo['error'][] = 'Errors parsing DolbyDigital WAV: '.explode(';', $dummy['error']);
+ $info['error'][] = 'Error parsing Dolby Digital WAV (AC3-in-RIFF): failed to write temp file';
}
- unset($ac3_tag);
+ unlink($RIFFtempfilename);
} else {
-
- $ThisFileInfo['error'][] = 'Could not create temporary file to analyze DolbyDigital WAV';
-
+ $info['error'][] = 'Error parsing Dolby Digital WAV (AC3-in-RIFF): failed to write temp file';
}
}
@@ -1337,9 +1514,9 @@ class getid3_riff
} elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 0, 4) == 'wvpk')) {
// This is WavPack data
- $ThisFileInfo['wavpack']['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
- $ThisFileInfo['wavpack']['size'] = getid3_lib::LittleEndian2Int(substr($RIFFdataChunkContentsTest, 4, 4));
- getid3_riff::RIFFparseWavPackHeader(substr($RIFFdataChunkContentsTest, 8, 28), $ThisFileInfo);
+ $info['wavpack']['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
+ $info['wavpack']['size'] = getid3_lib::LittleEndian2Int(substr($RIFFdataChunkContentsTest, 4, 4));
+ $this->RIFFparseWavPackHeader(substr($RIFFdataChunkContentsTest, 8, 28));
} else {
@@ -1348,13 +1525,14 @@ class getid3_riff
}
$nextoffset = $RIFFchunk[$chunkname][$thisindex]['offset'] + 8 + $chunksize;
- if (($nextoffset < 0) || ($nextoffset >= pow(2, 31))) {
- $ThisFileInfo['warning'][] = 'Unable to parse chunk at offset '.$nextoffset.' because beyond 2GB limit of PHP filesystem functions';
+ if (($nextoffset < 0) || !getid3_lib::intValueSupported($nextoffset)) {
+ $info['warning'][] = 'Unable to parse chunk at offset '.$nextoffset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
break 3;
}
- fseek($fd, $RIFFchunk[$chunkname][$thisindex]['offset'] + 8 + $chunksize, SEEK_SET);
+ fseek($this->getid3->fp, $RIFFchunk[$chunkname][$thisindex]['offset'] + 8 + $chunksize, SEEK_SET);
break;
+ case 'iXML':
case 'bext':
case 'cart':
case 'fmt ':
@@ -1364,11 +1542,35 @@ class getid3_riff
case 'MEXT':
case 'DISP':
// always read data in
- $RIFFchunk[$chunkname][$thisindex]['data'] = fread($fd, $chunksize);
+ case 'JUNK':
+ // should be: never read data in
+ // but some programs write their version strings in a JUNK chunk (e.g. VirtualDub, AVIdemux, etc)
+ if ($chunksize < 1048576) {
+ if ($chunksize > 0) {
+ $RIFFchunk[$chunkname][$thisindex]['data'] = fread($this->getid3->fp, $chunksize);
+ if ($chunkname == 'JUNK') {
+ if (preg_match('#^([\\x20-\\x7F]+)#', $RIFFchunk[$chunkname][$thisindex]['data'], $matches)) {
+ // only keep text characters [chr(32)-chr(127)]
+ $info['riff']['comments']['junk'][] = trim($matches[1]);
+ }
+ // but if nothing there, ignore
+ // remove the key in either case
+ unset($RIFFchunk[$chunkname][$thisindex]['data']);
+ }
+ }
+ } else {
+ $info['warning'][] = 'chunk "'.$chunkname.'" at offset '.ftell($this->getid3->fp).' is unexpectedly larger than 1MB (claims to be '.number_format($chunksize).' bytes), skipping data';
+ $nextoffset = ftell($this->getid3->fp) + $chunksize;
+ if (($nextoffset < 0) || !getid3_lib::intValueSupported($nextoffset)) {
+ $info['warning'][] = 'Unable to parse chunk at offset '.$nextoffset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
+ break 3;
+ }
+ fseek($this->getid3->fp, $nextoffset, SEEK_SET);
+ }
break;
default:
- if (!ereg('^[0-9]{2}(wb|pc|dc|db)$', $chunkname) && !empty($LISTchunkParent) && (($RIFFchunk[$chunkname][$thisindex]['offset'] + $RIFFchunk[$chunkname][$thisindex]['size']) <= $LISTchunkMaxOffset)) {
+ if (!preg_match('#^[0-9]{2}(wb|pc|dc|db)$#', $chunkname) && !empty($LISTchunkParent) && (($RIFFchunk[$chunkname][$thisindex]['offset'] + $RIFFchunk[$chunkname][$thisindex]['size']) <= $LISTchunkMaxOffset)) {
$RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
$RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['size'] = $RIFFchunk[$chunkname][$thisindex]['size'];
unset($RIFFchunk[$chunkname][$thisindex]['offset']);
@@ -1379,17 +1581,18 @@ class getid3_riff
if (isset($RIFFchunk[$chunkname]) && empty($RIFFchunk[$chunkname])) {
unset($RIFFchunk[$chunkname]);
}
- $RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['data'] = fread($fd, $chunksize);
- } elseif ($chunksize < 2048) {
+ $RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['data'] = fread($this->getid3->fp, $chunksize);
+ //} elseif (in_array($chunkname, array('ID3 ')) || (($chunksize > 0) && ($chunksize < 2048))) {
+ } elseif (($chunksize > 0) && ($chunksize < 2048)) {
// only read data in if smaller than 2kB
- $RIFFchunk[$chunkname][$thisindex]['data'] = fread($fd, $chunksize);
+ $RIFFchunk[$chunkname][$thisindex]['data'] = fread($this->getid3->fp, $chunksize);
} else {
- $nextoffset = ftell($fd) + $chunksize;
- if (($nextoffset < 0) || ($nextoffset >= pow(2, 31))) {
- $ThisFileInfo['warning'][] = 'Unable to parse chunk at offset '.$nextoffset.' because beyond 2GB limit of PHP filesystem functions';
+ $nextoffset = ftell($this->getid3->fp) + $chunksize;
+ if (($nextoffset < 0) || !getid3_lib::intValueSupported($nextoffset)) {
+ $info['warning'][] = 'Unable to parse chunk at offset '.$nextoffset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
break 3;
}
- fseek($fd, $nextoffset, SEEK_SET);
+ fseek($this->getid3->fp, $nextoffset, SEEK_SET);
}
break;
}
@@ -1403,11 +1606,11 @@ class getid3_riff
}
- function ParseRIFFdata(&$RIFFdata, &$ThisFileInfo) {
+ function ParseRIFFdata(&$RIFFdata) {
+ $info = &$this->getid3->info;
if ($RIFFdata) {
-
- $tempfile = tempnam('*', 'getID3');
- $fp_temp = fopen($tempfile, "wb");
+ $tempfile = tempnam(GETID3_TEMP_DIR, 'getID3');
+ $fp_temp = fopen($tempfile, 'wb');
$RIFFdataLength = strlen($RIFFdata);
$NewLengthString = getid3_lib::LittleEndian2String($RIFFdataLength, 4);
for ($i = 0; $i < 4; $i++) {
@@ -1416,24 +1619,32 @@ class getid3_riff
fwrite($fp_temp, $RIFFdata);
fclose($fp_temp);
- $fp_temp = fopen($tempfile, "rb");
- $dummy = array('filesize'=>$RIFFdataLength, 'filenamepath'=>$ThisFileInfo['filenamepath'], 'tags'=>$ThisFileInfo['tags'], 'avdataoffset'=>0, 'avdataend'=>$RIFFdataLength, 'warning'=>$ThisFileInfo['warning'], 'error'=>$ThisFileInfo['error'], 'comments'=>$ThisFileInfo['comments'], 'audio'=>(isset($ThisFileInfo['audio']) ? $ThisFileInfo['audio'] : array()), 'video'=>(isset($ThisFileInfo['video']) ? $ThisFileInfo['video'] : array()));
- $riff = new getid3_riff($fp_temp, $dummy);
- $ThisFileInfo['riff'] = $dummy['riff'];
- $ThisFileInfo['warning'] = $dummy['warning'];
- $ThisFileInfo['error'] = $dummy['error'];
- $ThisFileInfo['tags'] = $dummy['tags'];
- $ThisFileInfo['comments'] = $dummy['comments'];
- unset($riff);
- fclose($fp_temp);
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($tempfile);
+ $getid3_temp->info['filesize'] = $RIFFdataLength;
+ $getid3_temp->info['filenamepath'] = $info['filenamepath'];
+ $getid3_temp->info['tags'] = $info['tags'];
+ $getid3_temp->info['warning'] = $info['warning'];
+ $getid3_temp->info['error'] = $info['error'];
+ $getid3_temp->info['comments'] = $info['comments'];
+ $getid3_temp->info['audio'] = (isset($info['audio']) ? $info['audio'] : array());
+ $getid3_temp->info['video'] = (isset($info['video']) ? $info['video'] : array());
+ $getid3_riff = new getid3_riff($getid3_temp);
+ $getid3_riff->Analyze();
+
+ $info['riff'] = $getid3_temp->info['riff'];
+ $info['warning'] = $getid3_temp->info['warning'];
+ $info['error'] = $getid3_temp->info['error'];
+ $info['tags'] = $getid3_temp->info['tags'];
+ $info['comments'] = $getid3_temp->info['comments'];
+ unset($getid3_riff, $getid3_temp);
unlink($tempfile);
- return true;
}
return false;
}
- function RIFFparseWAVEFORMATex($WaveFormatExData) {
+ public static function RIFFparseWAVEFORMATex($WaveFormatExData) {
// shortcut
$WaveFormatEx['raw'] = array();
$WaveFormatEx_raw = &$WaveFormatEx['raw'];
@@ -1458,7 +1669,7 @@ class getid3_riff
}
- function RIFFparseWavPackHeader($WavPackChunkData, &$ThisFileInfo) {
+ function RIFFparseWavPackHeader($WavPackChunkData) {
// typedef struct {
// char ckID [4];
// long ckSize;
@@ -1470,8 +1681,9 @@ class getid3_riff
// } WavpackHeader;
// shortcut
- $ThisFileInfo['wavpack'] = array();
- $thisfile_wavpack = &$ThisFileInfo['wavpack'];
+ $info = &$this->getid3->info;
+ $info['wavpack'] = array();
+ $thisfile_wavpack = &$info['wavpack'];
$thisfile_wavpack['version'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 0, 2));
if ($thisfile_wavpack['version'] >= 2) {
@@ -1518,25 +1730,108 @@ class getid3_riff
return true;
}
- function ParseBITMAPINFOHEADER($BITMAPINFOHEADER, $littleEndian=true) {
- // yes it's ugly to instantiate a getid3_lib object here, suggested alternative please?
- $getid3_lib = new getid3_lib();
+ public static function ParseBITMAPINFOHEADER($BITMAPINFOHEADER, $littleEndian=true) {
+
$functionname = ($littleEndian ? 'LittleEndian2Int' : 'BigEndian2Int');
- $parsed['biSize'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 0, 4)); // number of bytes required by the BITMAPINFOHEADER structure
- $parsed['biWidth'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 4, 4)); // width of the bitmap in pixels
- $parsed['biHeight'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 8, 4)); // height of the bitmap in pixels. If biHeight is positive, the bitmap is a 'bottom-up' DIB and its origin is the lower left corner. If biHeight is negative, the bitmap is a 'top-down' DIB and its origin is the upper left corner
- $parsed['biPlanes'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 12, 2)); // number of color planes on the target device. In most cases this value must be set to 1
- $parsed['biBitCount'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 14, 2)); // Specifies the number of bits per pixels
+ $parsed['biSize'] = getid3_lib::$functionname(substr($BITMAPINFOHEADER, 0, 4)); // number of bytes required by the BITMAPINFOHEADER structure
+ $parsed['biWidth'] = getid3_lib::$functionname(substr($BITMAPINFOHEADER, 4, 4)); // width of the bitmap in pixels
+ $parsed['biHeight'] = getid3_lib::$functionname(substr($BITMAPINFOHEADER, 8, 4)); // height of the bitmap in pixels. If biHeight is positive, the bitmap is a 'bottom-up' DIB and its origin is the lower left corner. If biHeight is negative, the bitmap is a 'top-down' DIB and its origin is the upper left corner
+ $parsed['biPlanes'] = getid3_lib::$functionname(substr($BITMAPINFOHEADER, 12, 2)); // number of color planes on the target device. In most cases this value must be set to 1
+ $parsed['biBitCount'] = getid3_lib::$functionname(substr($BITMAPINFOHEADER, 14, 2)); // Specifies the number of bits per pixels
$parsed['fourcc'] = substr($BITMAPINFOHEADER, 16, 4); // compression identifier
- $parsed['biSizeImage'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 20, 4)); // size of the bitmap data section of the image (the actual pixel data, excluding BITMAPINFOHEADER and RGBQUAD structures)
- $parsed['biXPelsPerMeter'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 24, 4)); // horizontal resolution, in pixels per metre, of the target device
- $parsed['biYPelsPerMeter'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 28, 4)); // vertical resolution, in pixels per metre, of the target device
- $parsed['biClrUsed'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 32, 4)); // actual number of color indices in the color table used by the bitmap. If this value is zero, the bitmap uses the maximum number of colors corresponding to the value of the biBitCount member for the compression mode specified by biCompression
- $parsed['biClrImportant'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 36, 4)); // number of color indices that are considered important for displaying the bitmap. If this value is zero, all colors are important
+ $parsed['biSizeImage'] = getid3_lib::$functionname(substr($BITMAPINFOHEADER, 20, 4)); // size of the bitmap data section of the image (the actual pixel data, excluding BITMAPINFOHEADER and RGBQUAD structures)
+ $parsed['biXPelsPerMeter'] = getid3_lib::$functionname(substr($BITMAPINFOHEADER, 24, 4)); // horizontal resolution, in pixels per metre, of the target device
+ $parsed['biYPelsPerMeter'] = getid3_lib::$functionname(substr($BITMAPINFOHEADER, 28, 4)); // vertical resolution, in pixels per metre, of the target device
+ $parsed['biClrUsed'] = getid3_lib::$functionname(substr($BITMAPINFOHEADER, 32, 4)); // actual number of color indices in the color table used by the bitmap. If this value is zero, the bitmap uses the maximum number of colors corresponding to the value of the biBitCount member for the compression mode specified by biCompression
+ $parsed['biClrImportant'] = getid3_lib::$functionname(substr($BITMAPINFOHEADER, 36, 4)); // number of color indices that are considered important for displaying the bitmap. If this value is zero, all colors are important
+
return $parsed;
}
- function RIFFwFormatTagLookup($wFormatTag) {
+ static function ParseDIVXTAG($DIVXTAG) {
+ // structure from "IDivX" source, Form1.frm, by "Greg Frazier of Daemonic Software Group", email: gfrazier@icestorm.net, web: http://dsg.cjb.net/
+ // source available at http://files.divx-digest.com/download/c663efe7ef8ad2e90bf4af4d3ea6188a/on0SWN2r/edit/IDivX.zip
+ // 'Byte Layout: '1111111111111111
+ // '32 for Movie - 1 '1111111111111111
+ // '28 for Author - 6 '6666666666666666
+ // '4 for year - 2 '6666666666662222
+ // '3 for genre - 3 '7777777777777777
+ // '48 for Comments - 7 '7777777777777777
+ // '1 for Rating - 4 '7777777777777777
+ // '5 for Future Additions - 0 '333400000DIVXTAG
+ // '128 bytes total
+
+ static $DIVXTAGgenre = array(
+ 0 => 'Action',
+ 1 => 'Action/Adventure',
+ 2 => 'Adventure',
+ 3 => 'Adult',
+ 4 => 'Anime',
+ 5 => 'Cartoon',
+ 6 => 'Claymation',
+ 7 => 'Comedy',
+ 8 => 'Commercial',
+ 9 => 'Documentary',
+ 10 => 'Drama',
+ 11 => 'Home Video',
+ 12 => 'Horror',
+ 13 => 'Infomercial',
+ 14 => 'Interactive',
+ 15 => 'Mystery',
+ 16 => 'Music Video',
+ 17 => 'Other',
+ 18 => 'Religion',
+ 19 => 'Sci Fi',
+ 20 => 'Thriller',
+ 21 => 'Western',
+ );
+ static $DIVXTAGrating = array(
+ 0=>'Unrated',
+ 1=>'G',
+ 2=>'PG',
+ 3=>'PG-13',
+ 4=>'R',
+ 5=>'NC-17'
+ );
+
+ $parsed['title'] = trim(substr($DIVXTAG, 0, 32));
+ $parsed['artist'] = trim(substr($DIVXTAG, 32, 28));
+ $parsed['year'] = intval(trim(substr($DIVXTAG, 60, 4)));
+ $parsed['comment'] = trim(substr($DIVXTAG, 64, 48));
+ $parsed['genre_id'] = intval(trim(substr($DIVXTAG, 112, 3)));
+ $parsed['rating_id'] = ord(substr($DIVXTAG, 115, 1));
+ //$parsed['padding'] = substr($DIVXTAG, 116, 5); // 5-byte null
+ //$parsed['magic'] = substr($DIVXTAG, 121, 7); // "DIVXTAG"
+
+ $parsed['genre'] = (isset($DIVXTAGgenre[$parsed['genre_id']]) ? $DIVXTAGgenre[$parsed['genre_id']] : $parsed['genre_id']);
+ $parsed['rating'] = (isset($DIVXTAGrating[$parsed['rating_id']]) ? $DIVXTAGrating[$parsed['rating_id']] : $parsed['rating_id']);
+ return $parsed;
+ }
+
+ static function RIFFwaveSNDMtagLookup($tagshortname) {
+ $begin = __LINE__;
+
+ /** This is not a comment!
+
+ ©kwd keywords
+ ©BPM bpm
+ ©trt tracktitle
+ ©des description
+ ©gen category
+ ©fin featuredinstrument
+ ©LID longid
+ ©bex bwdescription
+ ©pub publisher
+ ©cdt cdtitle
+ ©alb library
+ ©com composer
+
+ */
+
+ return getid3_lib::EmbeddedLookup($tagshortname, $begin, __LINE__, __FILE__, 'riff-sndm');
+ }
+
+ static function RIFFwFormatTagLookup($wFormatTag) {
$begin = __LINE__;
@@ -1707,7 +2002,7 @@ class getid3_riff
}
- function RIFFfourccLookup($fourcc) {
+ public static function RIFFfourccLookup($fourcc) {
$begin = __LINE__;
@@ -1811,9 +2106,12 @@ class getid3_riff
ETV2 eTreppid Video ETV2
ETVC eTreppid Video ETVC
FLIC Autodesk FLI/FLC Animation
+ FLV1 Sorenson Spark
+ FLV4 On2 TrueMotion VP6
FRWT Darim Vision Forward Motion JPEG (www.darvision.com)
FRWU Darim Vision Forward Uncompressed (www.darvision.com)
FLJP D-Vision Field Encoded Motion JPEG
+ FPS1 FRAPS v1
FRWA SoftLab-Nsk Forward Motion JPEG w/ alpha channel
FRWD SoftLab-Nsk Forward Motion JPEG
FVF1 Iterated Systems Fractal Video Frame
@@ -2051,6 +2349,7 @@ class getid3_riff
VLV1 VideoLogic/PURE Digital Videologic Capture
VP30 On2 VP3.0
VP31 On2 VP3.1
+ VP6F On2 TrueMotion VP6
VX1K Lucent VX1000S Video Codec
VX2K Lucent VX2000S Video Codec
VXSP Lucent VX1000SP Video Codec
@@ -2098,8 +2397,8 @@ class getid3_riff
}
- function EitherEndian2Int(&$ThisFileInfo, $byteword, $signed=false) {
- if ($ThisFileInfo['fileformat'] == 'riff') {
+ function EitherEndian2Int($byteword, $signed=false) {
+ if ($this->getid3->info['fileformat'] == 'riff') {
return getid3_lib::LittleEndian2Int($byteword, $signed);
}
return getid3_lib::BigEndian2Int($byteword, false, $signed);
diff --git a/apps/media/getID3/getid3/module.audio-video.swf.php b/3rdparty/getid3/module.audio-video.swf.php
index c3dbb366bc5..a3d49f9506a 100644
--- a/apps/media/getID3/getid3/module.audio-video.swf.php
+++ b/3rdparty/getid3/module.audio-video.swf.php
@@ -14,59 +14,52 @@
/////////////////////////////////////////////////////////////////
-class getid3_swf
+class getid3_swf extends getid3_handler
{
+ var $ReturnAllTagData = false;
- function getid3_swf(&$fd, &$ThisFileInfo, $ReturnAllTagData=false) {
-//$start_time = microtime(true);
- $ThisFileInfo['fileformat'] = 'swf';
- $ThisFileInfo['video']['dataformat'] = 'swf';
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $info['fileformat'] = 'swf';
+ $info['video']['dataformat'] = 'swf';
// http://www.openswf.org/spec/SWFfileformat.html
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
- $SWFfileData = fread($fd, $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']); // 8 + 2 + 2 + max(9) bytes NOT including Frame_Size RECT data
+ $SWFfileData = fread($this->getid3->fp, $info['avdataend'] - $info['avdataoffset']); // 8 + 2 + 2 + max(9) bytes NOT including Frame_Size RECT data
- $ThisFileInfo['swf']['header']['signature'] = substr($SWFfileData, 0, 3);
- switch ($ThisFileInfo['swf']['header']['signature']) {
+ $info['swf']['header']['signature'] = substr($SWFfileData, 0, 3);
+ switch ($info['swf']['header']['signature']) {
case 'FWS':
- $ThisFileInfo['swf']['header']['compressed'] = false;
+ $info['swf']['header']['compressed'] = false;
break;
case 'CWS':
- $ThisFileInfo['swf']['header']['compressed'] = true;
+ $info['swf']['header']['compressed'] = true;
break;
default:
- $ThisFileInfo['error'][] = 'Expecting "FWS" or "CWS" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$ThisFileInfo['swf']['header']['signature'].'"';
- unset($ThisFileInfo['swf']);
- unset($ThisFileInfo['fileformat']);
+ $info['error'][] = 'Expecting "FWS" or "CWS" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['swf']['header']['signature']).'"';
+ unset($info['swf']);
+ unset($info['fileformat']);
return false;
break;
}
- $ThisFileInfo['swf']['header']['version'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 3, 1));
- $ThisFileInfo['swf']['header']['length'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 4, 4));
-
-//echo __LINE__.'='.number_format(microtime(true) - $start_time, 3).'<br>';
-
- if ($ThisFileInfo['swf']['header']['compressed']) {
+ $info['swf']['header']['version'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 3, 1));
+ $info['swf']['header']['length'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 4, 4));
+ if ($info['swf']['header']['compressed']) {
$SWFHead = substr($SWFfileData, 0, 8);
$SWFfileData = substr($SWFfileData, 8);
if ($decompressed = @gzuncompress($SWFfileData)) {
-
$SWFfileData = $SWFHead.$decompressed;
-
} else {
-
- $ThisFileInfo['error'][] = 'Error decompressing compressed SWF data ('.strlen($SWFfileData).' bytes compressed, should be '.($ThisFileInfo['swf']['header']['length'] - 8).' bytes uncompressed)';
+ $info['error'][] = 'Error decompressing compressed SWF data ('.strlen($SWFfileData).' bytes compressed, should be '.($info['swf']['header']['length'] - 8).' bytes uncompressed)';
return false;
-
}
-
}
-//echo __LINE__.'='.number_format(microtime(true) - $start_time, 3).'<br>';
$FrameSizeBitsPerValue = (ord(substr($SWFfileData, 8, 1)) & 0xF8) >> 3;
$FrameSizeDataLength = ceil((5 + (4 * $FrameSizeBitsPerValue)) / 8);
@@ -75,8 +68,8 @@ class getid3_swf
$FrameSizeDataString .= str_pad(decbin(ord(substr($SWFfileData, 8 + $i, 1))), 8, '0', STR_PAD_LEFT);
}
list($X1, $X2, $Y1, $Y2) = explode("\n", wordwrap($FrameSizeDataString, $FrameSizeBitsPerValue, "\n", 1));
- $ThisFileInfo['swf']['header']['frame_width'] = getid3_lib::Bin2Dec($X2);
- $ThisFileInfo['swf']['header']['frame_height'] = getid3_lib::Bin2Dec($Y2);
+ $info['swf']['header']['frame_width'] = getid3_lib::Bin2Dec($X2);
+ $info['swf']['header']['frame_height'] = getid3_lib::Bin2Dec($Y2);
// http://www-lehre.informatik.uni-osnabrueck.de/~fbstark/diplom/docs/swf/Flash_Uncovered.htm
// Next in the header is the frame rate, which is kind of weird.
@@ -85,16 +78,16 @@ class getid3_swf
// Example: 0x000C -> 0x0C -> 12 So the frame rate is 12 fps.
// Byte at (8 + $FrameSizeDataLength) is always zero and ignored
- $ThisFileInfo['swf']['header']['frame_rate'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 9 + $FrameSizeDataLength, 1));
- $ThisFileInfo['swf']['header']['frame_count'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 10 + $FrameSizeDataLength, 2));
+ $info['swf']['header']['frame_rate'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 9 + $FrameSizeDataLength, 1));
+ $info['swf']['header']['frame_count'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 10 + $FrameSizeDataLength, 2));
- $ThisFileInfo['video']['frame_rate'] = $ThisFileInfo['swf']['header']['frame_rate'];
- $ThisFileInfo['video']['resolution_x'] = intval(round($ThisFileInfo['swf']['header']['frame_width'] / 20));
- $ThisFileInfo['video']['resolution_y'] = intval(round($ThisFileInfo['swf']['header']['frame_height'] / 20));
- $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
+ $info['video']['frame_rate'] = $info['swf']['header']['frame_rate'];
+ $info['video']['resolution_x'] = intval(round($info['swf']['header']['frame_width'] / 20));
+ $info['video']['resolution_y'] = intval(round($info['swf']['header']['frame_height'] / 20));
+ $info['video']['pixel_aspect_ratio'] = (float) 1;
- if (($ThisFileInfo['swf']['header']['frame_count'] > 0) && ($ThisFileInfo['swf']['header']['frame_rate'] > 0)) {
- $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['swf']['header']['frame_count'] / $ThisFileInfo['swf']['header']['frame_rate'];
+ if (($info['swf']['header']['frame_count'] > 0) && ($info['swf']['header']['frame_rate'] > 0)) {
+ $info['playtime_seconds'] = $info['swf']['header']['frame_count'] / $info['swf']['header']['frame_rate'];
}
//echo __LINE__.'='.number_format(microtime(true) - $start_time, 3).'<br>';
@@ -126,13 +119,13 @@ class getid3_swf
break 2;
case 9: // Set background color
- //$ThisFileInfo['swf']['tags'][] = $TagData;
- $ThisFileInfo['swf']['bgcolor'] = strtoupper(str_pad(dechex(getid3_lib::BigEndian2Int($TagData['data'])), 6, '0', STR_PAD_LEFT));
+ //$info['swf']['tags'][] = $TagData;
+ $info['swf']['bgcolor'] = strtoupper(str_pad(dechex(getid3_lib::BigEndian2Int($TagData['data'])), 6, '0', STR_PAD_LEFT));
break;
default:
- if ($ReturnAllTagData) {
- $ThisFileInfo['swf']['tags'][] = $TagData;
+ if ($this->ReturnAllTagData) {
+ $info['swf']['tags'][] = $TagData;
}
break;
}
diff --git a/3rdparty/getid3/module.audio.aa.php b/3rdparty/getid3/module.audio.aa.php
new file mode 100644
index 00000000000..39cb77c859d
--- /dev/null
+++ b/3rdparty/getid3/module.audio.aa.php
@@ -0,0 +1,59 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.aa.php //
+// module for analyzing Audible Audiobook files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_aa extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $AAheader = fread($this->getid3->fp, 8);
+
+ $magic = "\x57\x90\x75\x36";
+ if (substr($AAheader, 4, 4) != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($AAheader, 4, 4)).'"';
+ return false;
+ }
+
+ // shortcut
+ $info['aa'] = array();
+ $thisfile_au = &$info['aa'];
+
+ $info['fileformat'] = 'aa';
+ $info['audio']['dataformat'] = 'aa';
+ $info['audio']['bitrate_mode'] = 'cbr'; // is it?
+ $thisfile_au['encoding'] = 'ISO-8859-1';
+
+ $thisfile_au['filesize'] = getid3_lib::BigEndian2Int(substr($AUheader, 0, 4));
+ if ($thisfile_au['filesize'] > ($info['avdataend'] - $info['avdataoffset'])) {
+ $info['warning'][] = 'Possible truncated file - expecting "'.$thisfile_au['filesize'].'" bytes of data, only found '.($info['avdataend'] - $info['avdataoffset']).' bytes"';
+ }
+
+ $info['audio']['bits_per_sample'] = 16; // is it?
+ $info['audio']['sample_rate'] = $thisfile_au['sample_rate'];
+ $info['audio']['channels'] = $thisfile_au['channels'];
+
+ //$info['playtime_seconds'] = 0;
+ //$info['audio']['bitrate'] = 0;
+
+ return true;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/3rdparty/getid3/module.audio.aac.php b/3rdparty/getid3/module.audio.aac.php
new file mode 100644
index 00000000000..d573e11d783
--- /dev/null
+++ b/3rdparty/getid3/module.audio.aac.php
@@ -0,0 +1,515 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.aac.php //
+// module for analyzing AAC Audio files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_aac extends getid3_handler
+{
+ function Analyze() {
+ $info = &$this->getid3->info;
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ if (fread($this->getid3->fp, 4) == 'ADIF') {
+ $this->getAACADIFheaderFilepointer();
+ } else {
+ $this->getAACADTSheaderFilepointer();
+ }
+ return true;
+ }
+
+
+
+ function getAACADIFheaderFilepointer() {
+ $info = &$this->getid3->info;
+ $info['fileformat'] = 'aac';
+ $info['audio']['dataformat'] = 'aac';
+ $info['audio']['lossless'] = false;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $AACheader = fread($this->getid3->fp, 1024);
+ $offset = 0;
+
+ if (substr($AACheader, 0, 4) == 'ADIF') {
+
+ // http://faac.sourceforge.net/wiki/index.php?page=ADIF
+
+ // http://libmpeg.org/mpeg4/doc/w2203tfs.pdf
+ // adif_header() {
+ // adif_id 32
+ // copyright_id_present 1
+ // if( copyright_id_present )
+ // copyright_id 72
+ // original_copy 1
+ // home 1
+ // bitstream_type 1
+ // bitrate 23
+ // num_program_config_elements 4
+ // for (i = 0; i < num_program_config_elements + 1; i++ ) {
+ // if( bitstream_type == '0' )
+ // adif_buffer_fullness 20
+ // program_config_element()
+ // }
+ // }
+
+ $AACheaderBitstream = getid3_lib::BigEndian2Bin($AACheader);
+ $bitoffset = 0;
+
+ $info['aac']['header_type'] = 'ADIF';
+ $bitoffset += 32;
+ $info['aac']['header']['mpeg_version'] = 4;
+
+ $info['aac']['header']['copyright'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
+ $bitoffset += 1;
+ if ($info['aac']['header']['copyright']) {
+ $info['aac']['header']['copyright_id'] = getid3_lib::Bin2String(substr($AACheaderBitstream, $bitoffset, 72));
+ $bitoffset += 72;
+ }
+ $info['aac']['header']['original_copy'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
+ $bitoffset += 1;
+ $info['aac']['header']['home'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
+ $bitoffset += 1;
+ $info['aac']['header']['is_vbr'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
+ $bitoffset += 1;
+ if ($info['aac']['header']['is_vbr']) {
+ $info['audio']['bitrate_mode'] = 'vbr';
+ $info['aac']['header']['bitrate_max'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 23));
+ $bitoffset += 23;
+ } else {
+ $info['audio']['bitrate_mode'] = 'cbr';
+ $info['aac']['header']['bitrate'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 23));
+ $bitoffset += 23;
+ $info['audio']['bitrate'] = $info['aac']['header']['bitrate'];
+ }
+ if ($info['audio']['bitrate'] == 0) {
+ $info['error'][] = 'Corrupt AAC file: bitrate_audio == zero';
+ return false;
+ }
+ $info['aac']['header']['num_program_configs'] = 1 + getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+
+ for ($i = 0; $i < $info['aac']['header']['num_program_configs']; $i++) {
+ // http://www.audiocoding.com/wiki/index.php?page=program_config_element
+
+ // buffer_fullness 20
+
+ // element_instance_tag 4
+ // object_type 2
+ // sampling_frequency_index 4
+ // num_front_channel_elements 4
+ // num_side_channel_elements 4
+ // num_back_channel_elements 4
+ // num_lfe_channel_elements 2
+ // num_assoc_data_elements 3
+ // num_valid_cc_elements 4
+ // mono_mixdown_present 1
+ // mono_mixdown_element_number 4 if mono_mixdown_present == 1
+ // stereo_mixdown_present 1
+ // stereo_mixdown_element_number 4 if stereo_mixdown_present == 1
+ // matrix_mixdown_idx_present 1
+ // matrix_mixdown_idx 2 if matrix_mixdown_idx_present == 1
+ // pseudo_surround_enable 1 if matrix_mixdown_idx_present == 1
+ // for (i = 0; i < num_front_channel_elements; i++) {
+ // front_element_is_cpe[i] 1
+ // front_element_tag_select[i] 4
+ // }
+ // for (i = 0; i < num_side_channel_elements; i++) {
+ // side_element_is_cpe[i] 1
+ // side_element_tag_select[i] 4
+ // }
+ // for (i = 0; i < num_back_channel_elements; i++) {
+ // back_element_is_cpe[i] 1
+ // back_element_tag_select[i] 4
+ // }
+ // for (i = 0; i < num_lfe_channel_elements; i++) {
+ // lfe_element_tag_select[i] 4
+ // }
+ // for (i = 0; i < num_assoc_data_elements; i++) {
+ // assoc_data_element_tag_select[i] 4
+ // }
+ // for (i = 0; i < num_valid_cc_elements; i++) {
+ // cc_element_is_ind_sw[i] 1
+ // valid_cc_element_tag_select[i] 4
+ // }
+ // byte_alignment() VAR
+ // comment_field_bytes 8
+ // for (i = 0; i < comment_field_bytes; i++) {
+ // comment_field_data[i] 8
+ // }
+
+ if (!$info['aac']['header']['is_vbr']) {
+ $info['aac']['program_configs'][$i]['buffer_fullness'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 20));
+ $bitoffset += 20;
+ }
+ $info['aac']['program_configs'][$i]['element_instance_tag'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ $info['aac']['program_configs'][$i]['object_type'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
+ $bitoffset += 2;
+ $info['aac']['program_configs'][$i]['sampling_frequency_index'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ $info['aac']['program_configs'][$i]['num_front_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ $info['aac']['program_configs'][$i]['num_side_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ $info['aac']['program_configs'][$i]['num_back_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ $info['aac']['program_configs'][$i]['num_lfe_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
+ $bitoffset += 2;
+ $info['aac']['program_configs'][$i]['num_assoc_data_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 3));
+ $bitoffset += 3;
+ $info['aac']['program_configs'][$i]['num_valid_cc_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ $info['aac']['program_configs'][$i]['mono_mixdown_present'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
+ $bitoffset += 1;
+ if ($info['aac']['program_configs'][$i]['mono_mixdown_present']) {
+ $info['aac']['program_configs'][$i]['mono_mixdown_element_number'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ }
+ $info['aac']['program_configs'][$i]['stereo_mixdown_present'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
+ $bitoffset += 1;
+ if ($info['aac']['program_configs'][$i]['stereo_mixdown_present']) {
+ $info['aac']['program_configs'][$i]['stereo_mixdown_element_number'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ }
+ $info['aac']['program_configs'][$i]['matrix_mixdown_idx_present'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
+ $bitoffset += 1;
+ if ($info['aac']['program_configs'][$i]['matrix_mixdown_idx_present']) {
+ $info['aac']['program_configs'][$i]['matrix_mixdown_idx'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
+ $bitoffset += 2;
+ $info['aac']['program_configs'][$i]['pseudo_surround_enable'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
+ $bitoffset += 1;
+ }
+ for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_front_channel_elements']; $j++) {
+ $info['aac']['program_configs'][$i]['front_element_is_cpe'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
+ $bitoffset += 1;
+ $info['aac']['program_configs'][$i]['front_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ }
+ for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_side_channel_elements']; $j++) {
+ $info['aac']['program_configs'][$i]['side_element_is_cpe'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
+ $bitoffset += 1;
+ $info['aac']['program_configs'][$i]['side_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ }
+ for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_back_channel_elements']; $j++) {
+ $info['aac']['program_configs'][$i]['back_element_is_cpe'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
+ $bitoffset += 1;
+ $info['aac']['program_configs'][$i]['back_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ }
+ for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_lfe_channel_elements']; $j++) {
+ $info['aac']['program_configs'][$i]['lfe_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ }
+ for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_assoc_data_elements']; $j++) {
+ $info['aac']['program_configs'][$i]['assoc_data_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ }
+ for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_valid_cc_elements']; $j++) {
+ $info['aac']['program_configs'][$i]['cc_element_is_ind_sw'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
+ $bitoffset += 1;
+ $info['aac']['program_configs'][$i]['valid_cc_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
+ $bitoffset += 4;
+ }
+
+ $bitoffset = ceil($bitoffset / 8) * 8;
+
+ $info['aac']['program_configs'][$i]['comment_field_bytes'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 8));
+ $bitoffset += 8;
+ $info['aac']['program_configs'][$i]['comment_field'] = getid3_lib::Bin2String(substr($AACheaderBitstream, $bitoffset, 8 * $info['aac']['program_configs'][$i]['comment_field_bytes']));
+ $bitoffset += 8 * $info['aac']['program_configs'][$i]['comment_field_bytes'];
+
+
+ $info['aac']['header']['profile'] = self::AACprofileLookup($info['aac']['program_configs'][$i]['object_type'], $info['aac']['header']['mpeg_version']);
+ $info['aac']['program_configs'][$i]['sampling_frequency'] = self::AACsampleRateLookup($info['aac']['program_configs'][$i]['sampling_frequency_index']);
+ $info['audio']['sample_rate'] = $info['aac']['program_configs'][$i]['sampling_frequency'];
+ $info['audio']['channels'] = self::AACchannelCountCalculate($info['aac']['program_configs'][$i]);
+ if ($info['aac']['program_configs'][$i]['comment_field']) {
+ $info['aac']['comments'][] = $info['aac']['program_configs'][$i]['comment_field'];
+ }
+ }
+ $info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['audio']['bitrate'];
+
+ $info['audio']['encoder_options'] = $info['aac']['header_type'].' '.$info['aac']['header']['profile'];
+
+
+
+ return true;
+
+ } else {
+
+ unset($info['fileformat']);
+ unset($info['aac']);
+ $info['error'][] = 'AAC-ADIF synch not found at offset '.$info['avdataoffset'].' (expected "ADIF", found "'.substr($AACheader, 0, 4).'" instead)';
+ return false;
+
+ }
+
+ }
+
+
+ function getAACADTSheaderFilepointer($MaxFramesToScan=1000000, $ReturnExtendedInfo=false) {
+ $info = &$this->getid3->info;
+
+ // based loosely on code from AACfile by Jurgen Faul <jfaulØgmx.de>
+ // http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
+
+
+ // http://faac.sourceforge.net/wiki/index.php?page=ADTS // dead link
+ // http://wiki.multimedia.cx/index.php?title=ADTS
+
+ // * ADTS Fixed Header: these don't change from frame to frame
+ // syncword 12 always: '111111111111'
+ // ID 1 0: MPEG-4, 1: MPEG-2
+ // MPEG layer 2 If you send AAC in MPEG-TS, set to 0
+ // protection_absent 1 0: CRC present; 1: no CRC
+ // profile 2 0: AAC Main; 1: AAC LC (Low Complexity); 2: AAC SSR (Scalable Sample Rate); 3: AAC LTP (Long Term Prediction)
+ // sampling_frequency_index 4 15 not allowed
+ // private_bit 1 usually 0
+ // channel_configuration 3
+ // original/copy 1 0: original; 1: copy
+ // home 1 usually 0
+ // emphasis 2 only if ID == 0 (ie MPEG-4) // not present in some documentation?
+
+ // * ADTS Variable Header: these can change from frame to frame
+ // copyright_identification_bit 1
+ // copyright_identification_start 1
+ // aac_frame_length 13 length of the frame including header (in bytes)
+ // adts_buffer_fullness 11 0x7FF indicates VBR
+ // no_raw_data_blocks_in_frame 2
+
+ // * ADTS Error check
+ // crc_check 16 only if protection_absent == 0
+
+ $byteoffset = $info['avdataoffset'];
+ $framenumber = 0;
+
+ // Init bit pattern array
+ static $decbin = array();
+
+ // Populate $bindec
+ for ($i = 0; $i < 256; $i++) {
+ $decbin[chr($i)] = str_pad(decbin($i), 8, '0', STR_PAD_LEFT);
+ }
+
+ // used to calculate bitrate below
+ $BitrateCache = array();
+
+
+ while (true) {
+ // breaks out when end-of-file encountered, or invalid data found,
+ // or MaxFramesToScan frames have been scanned
+
+ if (!getid3_lib::intValueSupported($byteoffset)) {
+ $info['warning'][] = 'Unable to parse AAC file beyond '.ftell($this->getid3->fp).' (PHP does not support file operations beyond '.round(PHP_INT_MAX / 1073741824).'GB)';
+ return false;
+ }
+ fseek($this->getid3->fp, $byteoffset, SEEK_SET);
+
+ // First get substring
+ $substring = fread($this->getid3->fp, 9); // header is 7 bytes (or 9 if CRC is present)
+ $substringlength = strlen($substring);
+ if ($substringlength != 9) {
+ $info['error'][] = 'Failed to read 7 bytes at offset '.(ftell($this->getid3->fp) - $substringlength).' (only read '.$substringlength.' bytes)';
+ return false;
+ }
+ // this would be easier with 64-bit math, but split it up to allow for 32-bit:
+ $header1 = getid3_lib::BigEndian2Int(substr($substring, 0, 2));
+ $header2 = getid3_lib::BigEndian2Int(substr($substring, 2, 4));
+ $header3 = getid3_lib::BigEndian2Int(substr($substring, 6, 1));
+
+ $info['aac']['header']['raw']['syncword'] = ($header1 & 0xFFF0) >> 4;
+ if ($info['aac']['header']['raw']['syncword'] != 0x0FFF) {
+ $info['error'][] = 'Synch pattern (0x0FFF) not found at offset '.(ftell($this->getid3->fp) - $substringlength).' (found 0x0'.strtoupper(dechex($info['aac']['header']['raw']['syncword'])).' instead)';
+ //if ($info['fileformat'] == 'aac') {
+ // return true;
+ //}
+ unset($info['aac']);
+ return false;
+ }
+
+ // Gather info for first frame only - this takes time to do 1000 times!
+ if ($framenumber == 0) {
+ $info['aac']['header_type'] = 'ADTS';
+ $info['fileformat'] = 'aac';
+ $info['audio']['dataformat'] = 'aac';
+
+ $info['aac']['header']['raw']['mpeg_version'] = ($header1 & 0x0008) >> 3;
+ $info['aac']['header']['raw']['mpeg_layer'] = ($header1 & 0x0006) >> 1;
+ $info['aac']['header']['raw']['protection_absent'] = ($header1 & 0x0001) >> 0;
+
+ $info['aac']['header']['raw']['profile_code'] = ($header2 & 0xC0000000) >> 30;
+ $info['aac']['header']['raw']['sample_rate_code'] = ($header2 & 0x3C000000) >> 26;
+ $info['aac']['header']['raw']['private_stream'] = ($header2 & 0x02000000) >> 25;
+ $info['aac']['header']['raw']['channels_code'] = ($header2 & 0x01C00000) >> 22;
+ $info['aac']['header']['raw']['original'] = ($header2 & 0x00200000) >> 21;
+ $info['aac']['header']['raw']['home'] = ($header2 & 0x00100000) >> 20;
+ $info['aac']['header']['raw']['copyright_stream'] = ($header2 & 0x00080000) >> 19;
+ $info['aac']['header']['raw']['copyright_start'] = ($header2 & 0x00040000) >> 18;
+ $info['aac']['header']['raw']['frame_length'] = ($header2 & 0x0003FFE0) >> 5;
+
+ $info['aac']['header']['mpeg_version'] = ($info['aac']['header']['raw']['mpeg_version'] ? 2 : 4);
+ $info['aac']['header']['crc_present'] = ($info['aac']['header']['raw']['protection_absent'] ? false: true);
+ $info['aac']['header']['profile'] = self::AACprofileLookup($info['aac']['header']['raw']['profile_code'], $info['aac']['header']['mpeg_version']);
+ $info['aac']['header']['sample_frequency'] = self::AACsampleRateLookup($info['aac']['header']['raw']['sample_rate_code']);
+ $info['aac']['header']['private'] = (bool) $info['aac']['header']['raw']['private_stream'];
+ $info['aac']['header']['original'] = (bool) $info['aac']['header']['raw']['original'];
+ $info['aac']['header']['home'] = (bool) $info['aac']['header']['raw']['home'];
+ $info['aac']['header']['channels'] = (($info['aac']['header']['raw']['channels_code'] == 7) ? 8 : $info['aac']['header']['raw']['channels_code']);
+ if ($ReturnExtendedInfo) {
+ $info['aac'][$framenumber]['copyright_id_bit'] = (bool) $info['aac']['header']['raw']['copyright_stream'];
+ $info['aac'][$framenumber]['copyright_id_start'] = (bool) $info['aac']['header']['raw']['copyright_start'];
+ }
+
+ if ($info['aac']['header']['raw']['mpeg_layer'] != 0) {
+ $info['warning'][] = 'Layer error - expected "0", found "'.$info['aac']['header']['raw']['mpeg_layer'].'" instead';
+ }
+ if ($info['aac']['header']['sample_frequency'] == 0) {
+ $info['error'][] = 'Corrupt AAC file: sample_frequency == zero';
+ return false;
+ }
+
+ $info['audio']['sample_rate'] = $info['aac']['header']['sample_frequency'];
+ $info['audio']['channels'] = $info['aac']['header']['channels'];
+ }
+
+ $FrameLength = ($header2 & 0x0003FFE0) >> 5;
+
+ if (!isset($BitrateCache[$FrameLength])) {
+ $BitrateCache[$FrameLength] = ($info['aac']['header']['sample_frequency'] / 1024) * $FrameLength * 8;
+ }
+ getid3_lib::safe_inc($info['aac']['bitrate_distribution'][$BitrateCache[$FrameLength]], 1);
+
+ $info['aac'][$framenumber]['aac_frame_length'] = $FrameLength;
+
+ $info['aac'][$framenumber]['adts_buffer_fullness'] = (($header2 & 0x0000001F) << 6) & (($header3 & 0xFC) >> 2);
+ if ($info['aac'][$framenumber]['adts_buffer_fullness'] == 0x07FF) {
+ $info['audio']['bitrate_mode'] = 'vbr';
+ } else {
+ $info['audio']['bitrate_mode'] = 'cbr';
+ }
+ $info['aac'][$framenumber]['num_raw_data_blocks'] = (($header3 & 0x03) >> 0);
+
+ if ($info['aac']['header']['crc_present']) {
+ //$info['aac'][$framenumber]['crc'] = getid3_lib::BigEndian2Int(substr($substring, 7, 2);
+ }
+
+ if (!$ReturnExtendedInfo) {
+ unset($info['aac'][$framenumber]);
+ }
+
+ /*
+ $rounded_precision = 5000;
+ $info['aac']['bitrate_distribution_rounded'] = array();
+ foreach ($info['aac']['bitrate_distribution'] as $bitrate => $count) {
+ $rounded_bitrate = round($bitrate / $rounded_precision) * $rounded_precision;
+ getid3_lib::safe_inc($info['aac']['bitrate_distribution_rounded'][$rounded_bitrate], $count);
+ }
+ ksort($info['aac']['bitrate_distribution_rounded']);
+ */
+
+ $byteoffset += $FrameLength;
+ if ((++$framenumber < $MaxFramesToScan) && (($byteoffset + 10) < $info['avdataend'])) {
+
+ // keep scanning
+
+ } else {
+
+ $info['aac']['frames'] = $framenumber;
+ $info['playtime_seconds'] = ($info['avdataend'] / $byteoffset) * (($framenumber * 1024) / $info['aac']['header']['sample_frequency']); // (1 / % of file scanned) * (samples / (samples/sec)) = seconds
+ if ($info['playtime_seconds'] == 0) {
+ $info['error'][] = 'Corrupt AAC file: playtime_seconds == zero';
+ return false;
+ }
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+ ksort($info['aac']['bitrate_distribution']);
+
+ $info['audio']['encoder_options'] = $info['aac']['header_type'].' '.$info['aac']['header']['profile'];
+
+ return true;
+
+ }
+ }
+ // should never get here.
+ }
+
+ public static function AACsampleRateLookup($samplerateid) {
+ static $AACsampleRateLookup = array();
+ if (empty($AACsampleRateLookup)) {
+ $AACsampleRateLookup[0] = 96000;
+ $AACsampleRateLookup[1] = 88200;
+ $AACsampleRateLookup[2] = 64000;
+ $AACsampleRateLookup[3] = 48000;
+ $AACsampleRateLookup[4] = 44100;
+ $AACsampleRateLookup[5] = 32000;
+ $AACsampleRateLookup[6] = 24000;
+ $AACsampleRateLookup[7] = 22050;
+ $AACsampleRateLookup[8] = 16000;
+ $AACsampleRateLookup[9] = 12000;
+ $AACsampleRateLookup[10] = 11025;
+ $AACsampleRateLookup[11] = 8000;
+ $AACsampleRateLookup[12] = 0;
+ $AACsampleRateLookup[13] = 0;
+ $AACsampleRateLookup[14] = 0;
+ $AACsampleRateLookup[15] = 0;
+ }
+ return (isset($AACsampleRateLookup[$samplerateid]) ? $AACsampleRateLookup[$samplerateid] : 'invalid');
+ }
+
+ public static function AACprofileLookup($profileid, $mpegversion) {
+ static $AACprofileLookup = array();
+ if (empty($AACprofileLookup)) {
+ $AACprofileLookup[2][0] = 'Main profile';
+ $AACprofileLookup[2][1] = 'Low Complexity profile (LC)';
+ $AACprofileLookup[2][2] = 'Scalable Sample Rate profile (SSR)';
+ $AACprofileLookup[2][3] = '(reserved)';
+ $AACprofileLookup[4][0] = 'AAC_MAIN';
+ $AACprofileLookup[4][1] = 'AAC_LC';
+ $AACprofileLookup[4][2] = 'AAC_SSR';
+ $AACprofileLookup[4][3] = 'AAC_LTP';
+ }
+ return (isset($AACprofileLookup[$mpegversion][$profileid]) ? $AACprofileLookup[$mpegversion][$profileid] : 'invalid');
+ }
+
+ public static function AACchannelCountCalculate($program_configs) {
+ $channels = 0;
+ for ($i = 0; $i < $program_configs['num_front_channel_elements']; $i++) {
+ $channels++;
+ if ($program_configs['front_element_is_cpe'][$i]) {
+ // each front element is channel pair (CPE = Channel Pair Element)
+ $channels++;
+ }
+ }
+ for ($i = 0; $i < $program_configs['num_side_channel_elements']; $i++) {
+ $channels++;
+ if ($program_configs['side_element_is_cpe'][$i]) {
+ // each side element is channel pair (CPE = Channel Pair Element)
+ $channels++;
+ }
+ }
+ for ($i = 0; $i < $program_configs['num_back_channel_elements']; $i++) {
+ $channels++;
+ if ($program_configs['back_element_is_cpe'][$i]) {
+ // each back element is channel pair (CPE = Channel Pair Element)
+ $channels++;
+ }
+ }
+ for ($i = 0; $i < $program_configs['num_lfe_channel_elements']; $i++) {
+ $channels++;
+ }
+ return $channels;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/3rdparty/getid3/module.audio.ac3.php b/3rdparty/getid3/module.audio.ac3.php
new file mode 100644
index 00000000000..ffe01746891
--- /dev/null
+++ b/3rdparty/getid3/module.audio.ac3.php
@@ -0,0 +1,473 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.ac3.php //
+// module for analyzing AC-3 (aka Dolby Digital) audio files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_ac3 extends getid3_handler
+{
+ private $AC3header = '';
+ private $BSIoffset = 0;
+
+
+ public function Analyze() {
+ $info = &$this->getid3->info;
+
+ ///AH
+ $info['ac3']['raw']['bsi'] = array();
+ $thisfile_ac3 = &$info['ac3'];
+ $thisfile_ac3_raw = &$thisfile_ac3['raw'];
+ $thisfile_ac3_raw_bsi = &$thisfile_ac3_raw['bsi'];
+
+
+ // http://www.atsc.org/standards/a_52a.pdf
+
+ $info['fileformat'] = 'ac3';
+
+ // An AC-3 serial coded audio bit stream is made up of a sequence of synchronization frames
+ // Each synchronization frame contains 6 coded audio blocks (AB), each of which represent 256
+ // new audio samples per channel. A synchronization information (SI) header at the beginning
+ // of each frame contains information needed to acquire and maintain synchronization. A
+ // bit stream information (BSI) header follows SI, and contains parameters describing the coded
+ // audio service. The coded audio blocks may be followed by an auxiliary data (Aux) field. At the
+ // end of each frame is an error check field that includes a CRC word for error detection. An
+ // additional CRC word is located in the SI header, the use of which, by a decoder, is optional.
+ //
+ // syncinfo() | bsi() | AB0 | AB1 | AB2 | AB3 | AB4 | AB5 | Aux | CRC
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $this->AC3header['syncinfo'] = fread($this->getid3->fp, 5);
+ $thisfile_ac3_raw['synchinfo']['synchword'] = substr($this->AC3header['syncinfo'], 0, 2);
+
+ $magic = "\x0B\x77";
+ if ($thisfile_ac3_raw['synchinfo']['synchword'] != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($thisfile_ac3_raw['synchinfo']['synchword']).'"';
+ unset($info['fileformat'], $info['ac3']);
+ return false;
+ }
+
+ $info['audio']['dataformat'] = 'ac3';
+ $info['audio']['bitrate_mode'] = 'cbr';
+ $info['audio']['lossless'] = false;
+
+ // syncinfo() {
+ // syncword 16
+ // crc1 16
+ // fscod 2
+ // frmsizecod 6
+ // } /* end of syncinfo */
+
+ $thisfile_ac3_raw['synchinfo']['crc1'] = getid3_lib::LittleEndian2Int(substr($this->AC3header['syncinfo'], 2, 2));
+ $ac3_synchinfo_fscod_frmsizecod = getid3_lib::LittleEndian2Int(substr($this->AC3header['syncinfo'], 4, 1));
+ $thisfile_ac3_raw['synchinfo']['fscod'] = ($ac3_synchinfo_fscod_frmsizecod & 0xC0) >> 6;
+ $thisfile_ac3_raw['synchinfo']['frmsizecod'] = ($ac3_synchinfo_fscod_frmsizecod & 0x3F);
+
+ $thisfile_ac3['sample_rate'] = $this->AC3sampleRateCodeLookup($thisfile_ac3_raw['synchinfo']['fscod']);
+ if ($thisfile_ac3_raw['synchinfo']['fscod'] <= 3) {
+ $info['audio']['sample_rate'] = $thisfile_ac3['sample_rate'];
+ }
+
+ $thisfile_ac3['frame_length'] = $this->AC3frameSizeLookup($thisfile_ac3_raw['synchinfo']['frmsizecod'], $thisfile_ac3_raw['synchinfo']['fscod']);
+ $thisfile_ac3['bitrate'] = $this->AC3bitrateLookup($thisfile_ac3_raw['synchinfo']['frmsizecod']);
+ $info['audio']['bitrate'] = $thisfile_ac3['bitrate'];
+
+ $this->AC3header['bsi'] = getid3_lib::BigEndian2Bin(fread($this->getid3->fp, 15));
+ $ac3_bsi_offset = 0;
+
+ $thisfile_ac3_raw_bsi['bsid'] = $this->readHeaderBSI(5);
+ if ($thisfile_ac3_raw_bsi['bsid'] > 8) {
+ // Decoders which can decode version 8 will thus be able to decode version numbers less than 8.
+ // If this standard is extended by the addition of additional elements or features, a value of bsid greater than 8 will be used.
+ // Decoders built to this version of the standard will not be able to decode versions with bsid greater than 8.
+ $info['error'][] = 'Bit stream identification is version '.$thisfile_ac3_raw_bsi['bsid'].', but getID3() only understands up to version 8';
+ unset($thisfile_ac3);
+ return false;
+ }
+
+ $thisfile_ac3_raw_bsi['bsmod'] = $this->readHeaderBSI(3);
+ $thisfile_ac3_raw_bsi['acmod'] = $this->readHeaderBSI(3);
+
+ $thisfile_ac3['service_type'] = $this->AC3serviceTypeLookup($thisfile_ac3_raw_bsi['bsmod'], $thisfile_ac3_raw_bsi['acmod']);
+ $ac3_coding_mode = $this->AC3audioCodingModeLookup($thisfile_ac3_raw_bsi['acmod']);
+ foreach($ac3_coding_mode as $key => $value) {
+ $thisfile_ac3[$key] = $value;
+ }
+ switch ($thisfile_ac3_raw_bsi['acmod']) {
+ case 0:
+ case 1:
+ $info['audio']['channelmode'] = 'mono';
+ break;
+ case 3:
+ case 4:
+ $info['audio']['channelmode'] = 'stereo';
+ break;
+ default:
+ $info['audio']['channelmode'] = 'surround';
+ break;
+ }
+ $info['audio']['channels'] = $thisfile_ac3['num_channels'];
+
+ if ($thisfile_ac3_raw_bsi['acmod'] & 0x01) {
+ // If the lsb of acmod is a 1, center channel is in use and cmixlev follows in the bit stream.
+ $thisfile_ac3_raw_bsi['cmixlev'] = $this->readHeaderBSI(2);
+ $thisfile_ac3['center_mix_level'] = $this->AC3centerMixLevelLookup($thisfile_ac3_raw_bsi['cmixlev']);
+ }
+
+ if ($thisfile_ac3_raw_bsi['acmod'] & 0x04) {
+ // If the msb of acmod is a 1, surround channels are in use and surmixlev follows in the bit stream.
+ $thisfile_ac3_raw_bsi['surmixlev'] = $this->readHeaderBSI(2);
+ $thisfile_ac3['surround_mix_level'] = $this->AC3surroundMixLevelLookup($thisfile_ac3_raw_bsi['surmixlev']);
+ }
+
+ if ($thisfile_ac3_raw_bsi['acmod'] == 0x02) {
+ // When operating in the two channel mode, this 2-bit code indicates whether or not the program has been encoded in Dolby Surround.
+ $thisfile_ac3_raw_bsi['dsurmod'] = $this->readHeaderBSI(2);
+ $thisfile_ac3['dolby_surround_mode'] = $this->AC3dolbySurroundModeLookup($thisfile_ac3_raw_bsi['dsurmod']);
+ }
+
+ $thisfile_ac3_raw_bsi['lfeon'] = (bool) $this->readHeaderBSI(1);
+ $thisfile_ac3['lfe_enabled'] = $thisfile_ac3_raw_bsi['lfeon'];
+ if ($thisfile_ac3_raw_bsi['lfeon']) {
+ //$info['audio']['channels']++;
+ $info['audio']['channels'] .= '.1';
+ }
+
+ $thisfile_ac3['channels_enabled'] = $this->AC3channelsEnabledLookup($thisfile_ac3_raw_bsi['acmod'], $thisfile_ac3_raw_bsi['lfeon']);
+
+ // This indicates how far the average dialogue level is below digital 100 percent. Valid values are 1–31.
+ // The value of 0 is reserved. The values of 1 to 31 are interpreted as -1 dB to -31 dB with respect to digital 100 percent.
+ $thisfile_ac3_raw_bsi['dialnorm'] = $this->readHeaderBSI(5);
+ $thisfile_ac3['dialogue_normalization'] = '-'.$thisfile_ac3_raw_bsi['dialnorm'].'dB';
+
+ $thisfile_ac3_raw_bsi['compre_flag'] = (bool) $this->readHeaderBSI(1);
+ if ($thisfile_ac3_raw_bsi['compre_flag']) {
+ $thisfile_ac3_raw_bsi['compr'] = $this->readHeaderBSI(8);
+ $thisfile_ac3['heavy_compression'] = $this->AC3heavyCompression($thisfile_ac3_raw_bsi['compr']);
+ }
+
+ $thisfile_ac3_raw_bsi['langcode_flag'] = (bool) $this->readHeaderBSI(1);
+ if ($thisfile_ac3_raw_bsi['langcode_flag']) {
+ $thisfile_ac3_raw_bsi['langcod'] = $this->readHeaderBSI(8);
+ }
+
+ $thisfile_ac3_raw_bsi['audprodie'] = (bool) $this->readHeaderBSI(1);
+ if ($thisfile_ac3_raw_bsi['audprodie']) {
+ $thisfile_ac3_raw_bsi['mixlevel'] = $this->readHeaderBSI(5);
+ $thisfile_ac3_raw_bsi['roomtyp'] = $this->readHeaderBSI(2);
+
+ $thisfile_ac3['mixing_level'] = (80 + $thisfile_ac3_raw_bsi['mixlevel']).'dB';
+ $thisfile_ac3['room_type'] = $this->AC3roomTypeLookup($thisfile_ac3_raw_bsi['roomtyp']);
+ }
+
+ if ($thisfile_ac3_raw_bsi['acmod'] == 0x00) {
+ // If acmod is 0, then two completely independent program channels (dual mono)
+ // are encoded into the bit stream, and are referenced as Ch1, Ch2. In this case,
+ // a number of additional items are present in BSI or audblk to fully describe Ch2.
+
+ // This indicates how far the average dialogue level is below digital 100 percent. Valid values are 1–31.
+ // The value of 0 is reserved. The values of 1 to 31 are interpreted as -1 dB to -31 dB with respect to digital 100 percent.
+ $thisfile_ac3_raw_bsi['dialnorm2'] = $this->readHeaderBSI(5);
+ $thisfile_ac3['dialogue_normalization2'] = '-'.$thisfile_ac3_raw_bsi['dialnorm2'].'dB';
+
+ $thisfile_ac3_raw_bsi['compre_flag2'] = (bool) $this->readHeaderBSI(1);
+ if ($thisfile_ac3_raw_bsi['compre_flag2']) {
+ $thisfile_ac3_raw_bsi['compr2'] = $this->readHeaderBSI(8);
+ $thisfile_ac3['heavy_compression2'] = $this->AC3heavyCompression($thisfile_ac3_raw_bsi['compr2']);
+ }
+
+ $thisfile_ac3_raw_bsi['langcode_flag2'] = (bool) $this->readHeaderBSI(1);
+ if ($thisfile_ac3_raw_bsi['langcode_flag2']) {
+ $thisfile_ac3_raw_bsi['langcod2'] = $this->readHeaderBSI(8);
+ }
+
+ $thisfile_ac3_raw_bsi['audprodie2'] = (bool) $this->readHeaderBSI(1);
+ if ($thisfile_ac3_raw_bsi['audprodie2']) {
+ $thisfile_ac3_raw_bsi['mixlevel2'] = $this->readHeaderBSI(5);
+ $thisfile_ac3_raw_bsi['roomtyp2'] = $this->readHeaderBSI(2);
+
+ $thisfile_ac3['mixing_level2'] = (80 + $thisfile_ac3_raw_bsi['mixlevel2']).'dB';
+ $thisfile_ac3['room_type2'] = $this->AC3roomTypeLookup($thisfile_ac3_raw_bsi['roomtyp2']);
+ }
+
+ }
+
+ $thisfile_ac3_raw_bsi['copyright'] = (bool) $this->readHeaderBSI(1);
+
+ $thisfile_ac3_raw_bsi['original'] = (bool) $this->readHeaderBSI(1);
+
+ $thisfile_ac3_raw_bsi['timecode1_flag'] = (bool) $this->readHeaderBSI(1);
+ if ($thisfile_ac3_raw_bsi['timecode1_flag']) {
+ $thisfile_ac3_raw_bsi['timecode1'] = $this->readHeaderBSI(14);
+ }
+
+ $thisfile_ac3_raw_bsi['timecode2_flag'] = (bool) $this->readHeaderBSI(1);
+ if ($thisfile_ac3_raw_bsi['timecode2_flag']) {
+ $thisfile_ac3_raw_bsi['timecode2'] = $this->readHeaderBSI(14);
+ }
+
+ $thisfile_ac3_raw_bsi['addbsi_flag'] = (bool) $this->readHeaderBSI(1);
+ if ($thisfile_ac3_raw_bsi['addbsi_flag']) {
+ $thisfile_ac3_raw_bsi['addbsi_length'] = $this->readHeaderBSI(6);
+
+ $this->AC3header['bsi'] .= getid3_lib::BigEndian2Bin(fread($this->getid3->fp, $thisfile_ac3_raw_bsi['addbsi_length']));
+
+ $thisfile_ac3_raw_bsi['addbsi_data'] = substr($this->AC3header['bsi'], $this->BSIoffset, $thisfile_ac3_raw_bsi['addbsi_length'] * 8);
+ $this->BSIoffset += $thisfile_ac3_raw_bsi['addbsi_length'] * 8;
+ }
+
+ return true;
+ }
+
+ private function readHeaderBSI($length) {
+ $data = substr($this->AC3header['bsi'], $this->BSIoffset, $length);
+ $this->BSIoffset += $length;
+
+ return bindec($data);
+ }
+
+ public static function AC3sampleRateCodeLookup($fscod) {
+ static $AC3sampleRateCodeLookup = array(
+ 0 => 48000,
+ 1 => 44100,
+ 2 => 32000,
+ 3 => 'reserved' // If the reserved code is indicated, the decoder should not attempt to decode audio and should mute.
+ );
+ return (isset($AC3sampleRateCodeLookup[$fscod]) ? $AC3sampleRateCodeLookup[$fscod] : false);
+ }
+
+ public static function AC3serviceTypeLookup($bsmod, $acmod) {
+ static $AC3serviceTypeLookup = array();
+ if (empty($AC3serviceTypeLookup)) {
+ for ($i = 0; $i <= 7; $i++) {
+ $AC3serviceTypeLookup[0][$i] = 'main audio service: complete main (CM)';
+ $AC3serviceTypeLookup[1][$i] = 'main audio service: music and effects (ME)';
+ $AC3serviceTypeLookup[2][$i] = 'associated service: visually impaired (VI)';
+ $AC3serviceTypeLookup[3][$i] = 'associated service: hearing impaired (HI)';
+ $AC3serviceTypeLookup[4][$i] = 'associated service: dialogue (D)';
+ $AC3serviceTypeLookup[5][$i] = 'associated service: commentary (C)';
+ $AC3serviceTypeLookup[6][$i] = 'associated service: emergency (E)';
+ }
+
+ $AC3serviceTypeLookup[7][1] = 'associated service: voice over (VO)';
+ for ($i = 2; $i <= 7; $i++) {
+ $AC3serviceTypeLookup[7][$i] = 'main audio service: karaoke';
+ }
+ }
+ return (isset($AC3serviceTypeLookup[$bsmod][$acmod]) ? $AC3serviceTypeLookup[$bsmod][$acmod] : false);
+ }
+
+ public static function AC3audioCodingModeLookup($acmod) {
+ static $AC3audioCodingModeLookup = array();
+ if (empty($AC3audioCodingModeLookup)) {
+ // array(channel configuration, # channels (not incl LFE), channel order)
+ $AC3audioCodingModeLookup = array (
+ 0 => array('channel_config'=>'1+1', 'num_channels'=>2, 'channel_order'=>'Ch1,Ch2'),
+ 1 => array('channel_config'=>'1/0', 'num_channels'=>1, 'channel_order'=>'C'),
+ 2 => array('channel_config'=>'2/0', 'num_channels'=>2, 'channel_order'=>'L,R'),
+ 3 => array('channel_config'=>'3/0', 'num_channels'=>3, 'channel_order'=>'L,C,R'),
+ 4 => array('channel_config'=>'2/1', 'num_channels'=>3, 'channel_order'=>'L,R,S'),
+ 5 => array('channel_config'=>'3/1', 'num_channels'=>4, 'channel_order'=>'L,C,R,S'),
+ 6 => array('channel_config'=>'2/2', 'num_channels'=>4, 'channel_order'=>'L,R,SL,SR'),
+ 7 => array('channel_config'=>'3/2', 'num_channels'=>5, 'channel_order'=>'L,C,R,SL,SR')
+ );
+ }
+ return (isset($AC3audioCodingModeLookup[$acmod]) ? $AC3audioCodingModeLookup[$acmod] : false);
+ }
+
+ public static function AC3centerMixLevelLookup($cmixlev) {
+ static $AC3centerMixLevelLookup;
+ if (empty($AC3centerMixLevelLookup)) {
+ $AC3centerMixLevelLookup = array(
+ 0 => pow(2, -3.0 / 6), // 0.707 (–3.0 dB)
+ 1 => pow(2, -4.5 / 6), // 0.595 (–4.5 dB)
+ 2 => pow(2, -6.0 / 6), // 0.500 (–6.0 dB)
+ 3 => 'reserved'
+ );
+ }
+ return (isset($AC3centerMixLevelLookup[$cmixlev]) ? $AC3centerMixLevelLookup[$cmixlev] : false);
+ }
+
+ public static function AC3surroundMixLevelLookup($surmixlev) {
+ static $AC3surroundMixLevelLookup;
+ if (empty($AC3surroundMixLevelLookup)) {
+ $AC3surroundMixLevelLookup = array(
+ 0 => pow(2, -3.0 / 6),
+ 1 => pow(2, -6.0 / 6),
+ 2 => 0,
+ 3 => 'reserved'
+ );
+ }
+ return (isset($AC3surroundMixLevelLookup[$surmixlev]) ? $AC3surroundMixLevelLookup[$surmixlev] : false);
+ }
+
+ public static function AC3dolbySurroundModeLookup($dsurmod) {
+ static $AC3dolbySurroundModeLookup = array(
+ 0 => 'not indicated',
+ 1 => 'Not Dolby Surround encoded',
+ 2 => 'Dolby Surround encoded',
+ 3 => 'reserved'
+ );
+ return (isset($AC3dolbySurroundModeLookup[$dsurmod]) ? $AC3dolbySurroundModeLookup[$dsurmod] : false);
+ }
+
+ public static function AC3channelsEnabledLookup($acmod, $lfeon) {
+ $AC3channelsEnabledLookup = array(
+ 'ch1'=>(bool) ($acmod == 0),
+ 'ch2'=>(bool) ($acmod == 0),
+ 'left'=>(bool) ($acmod > 1),
+ 'right'=>(bool) ($acmod > 1),
+ 'center'=>(bool) ($acmod & 0x01),
+ 'surround_mono'=>false,
+ 'surround_left'=>false,
+ 'surround_right'=>false,
+ 'lfe'=>$lfeon);
+ switch ($acmod) {
+ case 4:
+ case 5:
+ $AC3channelsEnabledLookup['surround_mono'] = true;
+ break;
+ case 6:
+ case 7:
+ $AC3channelsEnabledLookup['surround_left'] = true;
+ $AC3channelsEnabledLookup['surround_right'] = true;
+ break;
+ }
+ return $AC3channelsEnabledLookup;
+ }
+
+ public static function AC3heavyCompression($compre) {
+ // The first four bits indicate gain changes in 6.02dB increments which can be
+ // implemented with an arithmetic shift operation. The following four bits
+ // indicate linear gain changes, and require a 5-bit multiply.
+ // We will represent the two 4-bit fields of compr as follows:
+ // X0 X1 X2 X3 . Y4 Y5 Y6 Y7
+ // The meaning of the X values is most simply described by considering X to represent a 4-bit
+ // signed integer with values from –8 to +7. The gain indicated by X is then (X + 1) * 6.02 dB. The
+ // following table shows this in detail.
+
+ // Meaning of 4 msb of compr
+ // 7 +48.16 dB
+ // 6 +42.14 dB
+ // 5 +36.12 dB
+ // 4 +30.10 dB
+ // 3 +24.08 dB
+ // 2 +18.06 dB
+ // 1 +12.04 dB
+ // 0 +6.02 dB
+ // -1 0 dB
+ // -2 –6.02 dB
+ // -3 –12.04 dB
+ // -4 –18.06 dB
+ // -5 –24.08 dB
+ // -6 –30.10 dB
+ // -7 –36.12 dB
+ // -8 –42.14 dB
+
+ $fourbit = str_pad(decbin(($compre & 0xF0) >> 4), 4, '0', STR_PAD_LEFT);
+ if ($fourbit{0} == '1') {
+ $log_gain = -8 + bindec(substr($fourbit, 1));
+ } else {
+ $log_gain = bindec(substr($fourbit, 1));
+ }
+ $log_gain = ($log_gain + 1) * getid3_lib::RGADamplitude2dB(2);
+
+ // The value of Y is a linear representation of a gain change of up to –6 dB. Y is considered to
+ // be an unsigned fractional integer, with a leading value of 1, or: 0.1 Y4 Y5 Y6 Y7 (base 2). Y can
+ // represent values between 0.111112 (or 31/32) and 0.100002 (or 1/2). Thus, Y can represent gain
+ // changes from –0.28 dB to –6.02 dB.
+
+ $lin_gain = (16 + ($compre & 0x0F)) / 32;
+
+ // The combination of X and Y values allows compr to indicate gain changes from
+ // 48.16 – 0.28 = +47.89 dB, to
+ // –42.14 – 6.02 = –48.16 dB.
+
+ return $log_gain - $lin_gain;
+ }
+
+ public static function AC3roomTypeLookup($roomtyp) {
+ static $AC3roomTypeLookup = array(
+ 0 => 'not indicated',
+ 1 => 'large room, X curve monitor',
+ 2 => 'small room, flat monitor',
+ 3 => 'reserved'
+ );
+ return (isset($AC3roomTypeLookup[$roomtyp]) ? $AC3roomTypeLookup[$roomtyp] : false);
+ }
+
+ public static function AC3frameSizeLookup($frmsizecod, $fscod) {
+ $padding = (bool) ($frmsizecod % 2);
+ $framesizeid = floor($frmsizecod / 2);
+
+ static $AC3frameSizeLookup = array();
+ if (empty($AC3frameSizeLookup)) {
+ $AC3frameSizeLookup = array (
+ 0 => array(128, 138, 192),
+ 1 => array(40, 160, 174, 240),
+ 2 => array(48, 192, 208, 288),
+ 3 => array(56, 224, 242, 336),
+ 4 => array(64, 256, 278, 384),
+ 5 => array(80, 320, 348, 480),
+ 6 => array(96, 384, 416, 576),
+ 7 => array(112, 448, 486, 672),
+ 8 => array(128, 512, 556, 768),
+ 9 => array(160, 640, 696, 960),
+ 10 => array(192, 768, 834, 1152),
+ 11 => array(224, 896, 974, 1344),
+ 12 => array(256, 1024, 1114, 1536),
+ 13 => array(320, 1280, 1392, 1920),
+ 14 => array(384, 1536, 1670, 2304),
+ 15 => array(448, 1792, 1950, 2688),
+ 16 => array(512, 2048, 2228, 3072),
+ 17 => array(576, 2304, 2506, 3456),
+ 18 => array(640, 2560, 2786, 3840)
+ );
+ }
+ if (($fscod == 1) && $padding) {
+ // frame lengths are padded by 1 word (16 bits) at 44100
+ $AC3frameSizeLookup[$frmsizecod] += 2;
+ }
+ return (isset($AC3frameSizeLookup[$framesizeid][$fscod]) ? $AC3frameSizeLookup[$framesizeid][$fscod] : false);
+ }
+
+ public static function AC3bitrateLookup($frmsizecod) {
+ $framesizeid = floor($frmsizecod / 2);
+
+ static $AC3bitrateLookup = array(
+ 0 => 32000,
+ 1 => 40000,
+ 2 => 48000,
+ 3 => 56000,
+ 4 => 64000,
+ 5 => 80000,
+ 6 => 96000,
+ 7 => 112000,
+ 8 => 128000,
+ 9 => 160000,
+ 10 => 192000,
+ 11 => 224000,
+ 12 => 256000,
+ 13 => 320000,
+ 14 => 384000,
+ 15 => 448000,
+ 16 => 512000,
+ 17 => 576000,
+ 18 => 640000
+ );
+ return (isset($AC3bitrateLookup[$framesizeid]) ? $AC3bitrateLookup[$framesizeid] : false);
+ }
+
+
+}
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.au.php b/3rdparty/getid3/module.audio.au.php
index afbc75d6712..a1094dbcda6 100644
--- a/apps/media/getID3/getid3/module.audio.au.php
+++ b/3rdparty/getid3/module.audio.au.php
@@ -14,31 +14,33 @@
/////////////////////////////////////////////////////////////////
-class getid3_au
+class getid3_au extends getid3_handler
{
- function getid3_au(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $AUheader = fread($fd, 8);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $AUheader = fread($this->getid3->fp, 8);
- if (substr($AUheader, 0, 4) != '.snd') {
- $ThisFileInfo['error'][] = 'Expecting ".snd" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($AUheader, 0, 4).'"';
+ $magic = '.snd';
+ if (substr($AUheader, 0, 4) != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" (".snd") at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($AUheader, 0, 4)).'"';
return false;
}
// shortcut
- $ThisFileInfo['au'] = array();
- $thisfile_au = &$ThisFileInfo['au'];
+ $info['au'] = array();
+ $thisfile_au = &$info['au'];
- $ThisFileInfo['fileformat'] = 'au';
- $ThisFileInfo['audio']['dataformat'] = 'au';
- $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
+ $info['fileformat'] = 'au';
+ $info['audio']['dataformat'] = 'au';
+ $info['audio']['bitrate_mode'] = 'cbr';
$thisfile_au['encoding'] = 'ISO-8859-1';
$thisfile_au['header_length'] = getid3_lib::BigEndian2Int(substr($AUheader, 4, 4));
- $AUheader .= fread($fd, $thisfile_au['header_length'] - 8);
- $ThisFileInfo['avdataoffset'] += $thisfile_au['header_length'];
+ $AUheader .= fread($this->getid3->fp, $thisfile_au['header_length'] - 8);
+ $info['avdataoffset'] += $thisfile_au['header_length'];
$thisfile_au['data_size'] = getid3_lib::BigEndian2Int(substr($AUheader, 8, 4));
$thisfile_au['data_format_id'] = getid3_lib::BigEndian2Int(substr($AUheader, 12, 4));
@@ -49,20 +51,20 @@ class getid3_au
$thisfile_au['data_format'] = $this->AUdataFormatNameLookup($thisfile_au['data_format_id']);
$thisfile_au['used_bits_per_sample'] = $this->AUdataFormatUsedBitsPerSampleLookup($thisfile_au['data_format_id']);
if ($thisfile_au['bits_per_sample'] = $this->AUdataFormatBitsPerSampleLookup($thisfile_au['data_format_id'])) {
- $ThisFileInfo['audio']['bits_per_sample'] = $thisfile_au['bits_per_sample'];
+ $info['audio']['bits_per_sample'] = $thisfile_au['bits_per_sample'];
} else {
unset($thisfile_au['bits_per_sample']);
}
- $ThisFileInfo['audio']['sample_rate'] = $thisfile_au['sample_rate'];
- $ThisFileInfo['audio']['channels'] = $thisfile_au['channels'];
+ $info['audio']['sample_rate'] = $thisfile_au['sample_rate'];
+ $info['audio']['channels'] = $thisfile_au['channels'];
- if (($ThisFileInfo['avdataoffset'] + $thisfile_au['data_size']) > $ThisFileInfo['avdataend']) {
- $ThisFileInfo['warning'][] = 'Possible truncated file - expecting "'.$thisfile_au['data_size'].'" bytes of audio data, only found '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']).' bytes"';
+ if (($info['avdataoffset'] + $thisfile_au['data_size']) > $info['avdataend']) {
+ $info['warning'][] = 'Possible truncated file - expecting "'.$thisfile_au['data_size'].'" bytes of audio data, only found '.($info['avdataend'] - $info['avdataoffset']).' bytes"';
}
- $ThisFileInfo['playtime_seconds'] = $thisfile_au['data_size'] / ($thisfile_au['sample_rate'] * $thisfile_au['channels'] * ($thisfile_au['used_bits_per_sample'] / 8));
- $ThisFileInfo['audio']['bitrate'] = ($thisfile_au['data_size'] * 8) / $ThisFileInfo['playtime_seconds'];
+ $info['playtime_seconds'] = $thisfile_au['data_size'] / ($thisfile_au['sample_rate'] * $thisfile_au['channels'] * ($thisfile_au['used_bits_per_sample'] / 8));
+ $info['audio']['bitrate'] = ($thisfile_au['data_size'] * 8) / $info['playtime_seconds'];
return true;
}
diff --git a/3rdparty/getid3/module.audio.avr.php b/3rdparty/getid3/module.audio.avr.php
new file mode 100644
index 00000000000..9c6d6650782
--- /dev/null
+++ b/3rdparty/getid3/module.audio.avr.php
@@ -0,0 +1,127 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.avr.php //
+// module for analyzing AVR Audio files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_avr extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ // http://cui.unige.ch/OSG/info/AudioFormats/ap11.html
+ // http://www.btinternet.com/~AnthonyJ/Atari/programming/avr_format.html
+ // offset type length name comments
+ // ---------------------------------------------------------------------
+ // 0 char 4 ID format ID == "2BIT"
+ // 4 char 8 name sample name (unused space filled with 0)
+ // 12 short 1 mono/stereo 0=mono, -1 (0xFFFF)=stereo
+ // With stereo, samples are alternated,
+ // the first voice is the left :
+ // (LRLRLRLRLRLRLRLRLR...)
+ // 14 short 1 resolution 8, 12 or 16 (bits)
+ // 16 short 1 signed or not 0=unsigned, -1 (0xFFFF)=signed
+ // 18 short 1 loop or not 0=no loop, -1 (0xFFFF)=loop on
+ // 20 short 1 MIDI note 0xFFnn, where 0 <= nn <= 127
+ // 0xFFFF means "no MIDI note defined"
+ // 22 byte 1 Replay speed Frequence in the Replay software
+ // 0=5.485 Khz, 1=8.084 Khz, 2=10.971 Khz,
+ // 3=16.168 Khz, 4=21.942 Khz, 5=32.336 Khz
+ // 6=43.885 Khz, 7=47.261 Khz
+ // -1 (0xFF)=no defined Frequence
+ // 23 byte 3 sample rate in Hertz
+ // 26 long 1 size in bytes (2 * bytes in stereo)
+ // 30 long 1 loop begin 0 for no loop
+ // 34 long 1 loop size equal to 'size' for no loop
+ // 38 short 2 Reserved, MIDI keyboard split */
+ // 40 short 2 Reserved, sample compression */
+ // 42 short 2 Reserved */
+ // 44 char 20; Additional filename space, used if (name[7] != 0)
+ // 64 byte 64 user data
+ // 128 bytes ? sample data (12 bits samples are coded on 16 bits:
+ // 0000 xxxx xxxx xxxx)
+ // ---------------------------------------------------------------------
+
+ // Note that all values are in motorola (big-endian) format, and that long is
+ // assumed to be 4 bytes, and short 2 bytes.
+ // When reading the samples, you should handle both signed and unsigned data,
+ // and be prepared to convert 16->8 bit, or mono->stereo if needed. To convert
+ // 8-bit data between signed/unsigned just add 127 to the sample values.
+ // Simularly for 16-bit data you should add 32769
+
+ $info['fileformat'] = 'avr';
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $AVRheader = fread($this->getid3->fp, 128);
+
+ $info['avr']['raw']['magic'] = substr($AVRheader, 0, 4);
+ $magic = '2BIT';
+ if ($info['avr']['raw']['magic'] != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['avr']['raw']['magic']).'"';
+ unset($info['fileformat']);
+ unset($info['avr']);
+ return false;
+ }
+ $info['avdataoffset'] += 128;
+
+ $info['avr']['sample_name'] = rtrim(substr($AVRheader, 4, 8));
+ $info['avr']['raw']['mono'] = getid3_lib::BigEndian2Int(substr($AVRheader, 12, 2));
+ $info['avr']['bits_per_sample'] = getid3_lib::BigEndian2Int(substr($AVRheader, 14, 2));
+ $info['avr']['raw']['signed'] = getid3_lib::BigEndian2Int(substr($AVRheader, 16, 2));
+ $info['avr']['raw']['loop'] = getid3_lib::BigEndian2Int(substr($AVRheader, 18, 2));
+ $info['avr']['raw']['midi'] = getid3_lib::BigEndian2Int(substr($AVRheader, 20, 2));
+ $info['avr']['raw']['replay_freq'] = getid3_lib::BigEndian2Int(substr($AVRheader, 22, 1));
+ $info['avr']['sample_rate'] = getid3_lib::BigEndian2Int(substr($AVRheader, 23, 3));
+ $info['avr']['sample_length'] = getid3_lib::BigEndian2Int(substr($AVRheader, 26, 4));
+ $info['avr']['loop_start'] = getid3_lib::BigEndian2Int(substr($AVRheader, 30, 4));
+ $info['avr']['loop_end'] = getid3_lib::BigEndian2Int(substr($AVRheader, 34, 4));
+ $info['avr']['midi_split'] = getid3_lib::BigEndian2Int(substr($AVRheader, 38, 2));
+ $info['avr']['sample_compression'] = getid3_lib::BigEndian2Int(substr($AVRheader, 40, 2));
+ $info['avr']['reserved'] = getid3_lib::BigEndian2Int(substr($AVRheader, 42, 2));
+ $info['avr']['sample_name_extra'] = rtrim(substr($AVRheader, 44, 20));
+ $info['avr']['comment'] = rtrim(substr($AVRheader, 64, 64));
+
+ $info['avr']['flags']['stereo'] = (($info['avr']['raw']['mono'] == 0) ? false : true);
+ $info['avr']['flags']['signed'] = (($info['avr']['raw']['signed'] == 0) ? false : true);
+ $info['avr']['flags']['loop'] = (($info['avr']['raw']['loop'] == 0) ? false : true);
+
+ $info['avr']['midi_notes'] = array();
+ if (($info['avr']['raw']['midi'] & 0xFF00) != 0xFF00) {
+ $info['avr']['midi_notes'][] = ($info['avr']['raw']['midi'] & 0xFF00) >> 8;
+ }
+ if (($info['avr']['raw']['midi'] & 0x00FF) != 0x00FF) {
+ $info['avr']['midi_notes'][] = ($info['avr']['raw']['midi'] & 0x00FF);
+ }
+
+ if (($info['avdataend'] - $info['avdataoffset']) != ($info['avr']['sample_length'] * (($info['avr']['bits_per_sample'] == 8) ? 1 : 2))) {
+ $info['warning'][] = 'Probable truncated file: expecting '.($info['avr']['sample_length'] * (($info['avr']['bits_per_sample'] == 8) ? 1 : 2)).' bytes of audio data, found '.($info['avdataend'] - $info['avdataoffset']);
+ }
+
+ $info['audio']['dataformat'] = 'avr';
+ $info['audio']['lossless'] = true;
+ $info['audio']['bitrate_mode'] = 'cbr';
+ $info['audio']['bits_per_sample'] = $info['avr']['bits_per_sample'];
+ $info['audio']['sample_rate'] = $info['avr']['sample_rate'];
+ $info['audio']['channels'] = ($info['avr']['flags']['stereo'] ? 2 : 1);
+ $info['playtime_seconds'] = ($info['avr']['sample_length'] / $info['audio']['channels']) / $info['avr']['sample_rate'];
+ $info['audio']['bitrate'] = ($info['avr']['sample_length'] * (($info['avr']['bits_per_sample'] == 8) ? 8 : 16)) / $info['playtime_seconds'];
+
+
+ return true;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.bonk.php b/3rdparty/getid3/module.audio.bonk.php
index fef9782cfca..9f5187e3c0b 100644
--- a/apps/media/getID3/getid3/module.audio.bonk.php
+++ b/3rdparty/getid3/module.audio.bonk.php
@@ -14,67 +14,68 @@
/////////////////////////////////////////////////////////////////
-class getid3_bonk
+class getid3_bonk extends getid3_handler
{
- function getid3_bonk(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
// shortcut
- $ThisFileInfo['bonk'] = array();
- $thisfile_bonk = &$ThisFileInfo['bonk'];
+ $info['bonk'] = array();
+ $thisfile_bonk = &$info['bonk'];
- $thisfile_bonk['dataoffset'] = $ThisFileInfo['avdataoffset'];
- $thisfile_bonk['dataend'] = $ThisFileInfo['avdataend'];
+ $thisfile_bonk['dataoffset'] = $info['avdataoffset'];
+ $thisfile_bonk['dataend'] = $info['avdataend'];
- if ($thisfile_bonk['dataend'] >= pow(2, 31)) {
+ if (!getid3_lib::intValueSupported($thisfile_bonk['dataend'])) {
- $ThisFileInfo['warning'][] = 'Unable to parse BONK file from end (v0.6+ preferred method) because PHP filesystem functions only support up to 2GB';
+ $info['warning'][] = 'Unable to parse BONK file from end (v0.6+ preferred method) because PHP filesystem functions only support up to '.round(PHP_INT_MAX / 1073741824).'GB';
} else {
// scan-from-end method, for v0.6 and higher
- fseek($fd, $thisfile_bonk['dataend'] - 8, SEEK_SET);
- $PossibleBonkTag = fread($fd, 8);
+ fseek($this->getid3->fp, $thisfile_bonk['dataend'] - 8, SEEK_SET);
+ $PossibleBonkTag = fread($this->getid3->fp, 8);
while ($this->BonkIsValidTagName(substr($PossibleBonkTag, 4, 4), true)) {
$BonkTagSize = getid3_lib::LittleEndian2Int(substr($PossibleBonkTag, 0, 4));
- fseek($fd, 0 - $BonkTagSize, SEEK_CUR);
- $BonkTagOffset = ftell($fd);
- $TagHeaderTest = fread($fd, 5);
+ fseek($this->getid3->fp, 0 - $BonkTagSize, SEEK_CUR);
+ $BonkTagOffset = ftell($this->getid3->fp);
+ $TagHeaderTest = fread($this->getid3->fp, 5);
if (($TagHeaderTest{0} != "\x00") || (substr($PossibleBonkTag, 4, 4) != strtolower(substr($PossibleBonkTag, 4, 4)))) {
- $ThisFileInfo['error'][] = 'Expecting "Ø'.strtoupper(substr($PossibleBonkTag, 4, 4)).'" at offset '.$BonkTagOffset.', found "'.$TagHeaderTest.'"';
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes("\x00".strtoupper(substr($PossibleBonkTag, 4, 4))).'" at offset '.$BonkTagOffset.', found "'.getid3_lib::PrintHexBytes($TagHeaderTest).'"';
return false;
}
$BonkTagName = substr($TagHeaderTest, 1, 4);
$thisfile_bonk[$BonkTagName]['size'] = $BonkTagSize;
$thisfile_bonk[$BonkTagName]['offset'] = $BonkTagOffset;
- $this->HandleBonkTags($fd, $BonkTagName, $ThisFileInfo);
+ $this->HandleBonkTags($BonkTagName);
$NextTagEndOffset = $BonkTagOffset - 8;
if ($NextTagEndOffset < $thisfile_bonk['dataoffset']) {
- if (empty($ThisFileInfo['audio']['encoder'])) {
- $ThisFileInfo['audio']['encoder'] = 'Extended BONK v0.9+';
+ if (empty($info['audio']['encoder'])) {
+ $info['audio']['encoder'] = 'Extended BONK v0.9+';
}
return true;
}
- fseek($fd, $NextTagEndOffset, SEEK_SET);
- $PossibleBonkTag = fread($fd, 8);
+ fseek($this->getid3->fp, $NextTagEndOffset, SEEK_SET);
+ $PossibleBonkTag = fread($this->getid3->fp, 8);
}
}
// seek-from-beginning method for v0.4 and v0.5
if (empty($thisfile_bonk['BONK'])) {
- fseek($fd, $thisfile_bonk['dataoffset'], SEEK_SET);
+ fseek($this->getid3->fp, $thisfile_bonk['dataoffset'], SEEK_SET);
do {
- $TagHeaderTest = fread($fd, 5);
+ $TagHeaderTest = fread($this->getid3->fp, 5);
switch ($TagHeaderTest) {
case "\x00".'BONK':
- if (empty($ThisFileInfo['audio']['encoder'])) {
- $ThisFileInfo['audio']['encoder'] = 'BONK v0.4';
+ if (empty($info['audio']['encoder'])) {
+ $info['audio']['encoder'] = 'BONK v0.4';
}
break;
case "\x00".'INFO':
- $ThisFileInfo['audio']['encoder'] = 'Extended BONK v0.5';
+ $info['audio']['encoder'] = 'Extended BONK v0.5';
break;
default:
@@ -83,43 +84,43 @@ class getid3_bonk
$BonkTagName = substr($TagHeaderTest, 1, 4);
$thisfile_bonk[$BonkTagName]['size'] = $thisfile_bonk['dataend'] - $thisfile_bonk['dataoffset'];
$thisfile_bonk[$BonkTagName]['offset'] = $thisfile_bonk['dataoffset'];
- $this->HandleBonkTags($fd, $BonkTagName, $ThisFileInfo);
+ $this->HandleBonkTags($BonkTagName);
} while (true);
}
// parse META block for v0.6 - v0.8
if (empty($thisfile_bonk['INFO']) && isset($thisfile_bonk['META']['tags']['info'])) {
- fseek($fd, $thisfile_bonk['META']['tags']['info'], SEEK_SET);
- $TagHeaderTest = fread($fd, 5);
+ fseek($this->getid3->fp, $thisfile_bonk['META']['tags']['info'], SEEK_SET);
+ $TagHeaderTest = fread($this->getid3->fp, 5);
if ($TagHeaderTest == "\x00".'INFO') {
- $ThisFileInfo['audio']['encoder'] = 'Extended BONK v0.6 - v0.8';
+ $info['audio']['encoder'] = 'Extended BONK v0.6 - v0.8';
$BonkTagName = substr($TagHeaderTest, 1, 4);
$thisfile_bonk[$BonkTagName]['size'] = $thisfile_bonk['dataend'] - $thisfile_bonk['dataoffset'];
$thisfile_bonk[$BonkTagName]['offset'] = $thisfile_bonk['dataoffset'];
- $this->HandleBonkTags($fd, $BonkTagName, $ThisFileInfo);
+ $this->HandleBonkTags($BonkTagName);
}
}
- if (empty($ThisFileInfo['audio']['encoder'])) {
- $ThisFileInfo['audio']['encoder'] = 'Extended BONK v0.9+';
+ if (empty($info['audio']['encoder'])) {
+ $info['audio']['encoder'] = 'Extended BONK v0.9+';
}
if (empty($thisfile_bonk['BONK'])) {
- unset($ThisFileInfo['bonk']);
+ unset($info['bonk']);
}
return true;
}
- function HandleBonkTags(&$fd, &$BonkTagName, &$ThisFileInfo) {
-
+ function HandleBonkTags($BonkTagName) {
+ $info = &$this->getid3->info;
switch ($BonkTagName) {
case 'BONK':
// shortcut
- $thisfile_bonk_BONK = &$ThisFileInfo['bonk']['BONK'];
+ $thisfile_bonk_BONK = &$info['bonk']['BONK'];
- $BonkData = "\x00".'BONK'.fread($fd, 17);
+ $BonkData = "\x00".'BONK'.fread($this->getid3->fp, 17);
$thisfile_bonk_BONK['version'] = getid3_lib::LittleEndian2Int(substr($BonkData, 5, 1));
$thisfile_bonk_BONK['number_samples'] = getid3_lib::LittleEndian2Int(substr($BonkData, 6, 4));
$thisfile_bonk_BONK['sample_rate'] = getid3_lib::LittleEndian2Int(substr($BonkData, 10, 4));
@@ -131,40 +132,40 @@ class getid3_bonk
$thisfile_bonk_BONK['downsampling_ratio'] = getid3_lib::LittleEndian2Int(substr($BonkData, 19, 1));
$thisfile_bonk_BONK['samples_per_packet'] = getid3_lib::LittleEndian2Int(substr($BonkData, 20, 2));
- $ThisFileInfo['avdataoffset'] = $thisfile_bonk_BONK['offset'] + 5 + 17;
- $ThisFileInfo['avdataend'] = $thisfile_bonk_BONK['offset'] + $thisfile_bonk_BONK['size'];
-
- $ThisFileInfo['fileformat'] = 'bonk';
- $ThisFileInfo['audio']['dataformat'] = 'bonk';
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr'; // assumed
- $ThisFileInfo['audio']['channels'] = $thisfile_bonk_BONK['channels'];
- $ThisFileInfo['audio']['sample_rate'] = $thisfile_bonk_BONK['sample_rate'];
- $ThisFileInfo['audio']['channelmode'] = ($thisfile_bonk_BONK['joint_stereo'] ? 'joint stereo' : 'stereo');
- $ThisFileInfo['audio']['lossless'] = $thisfile_bonk_BONK['lossless'];
- $ThisFileInfo['audio']['codec'] = 'bonk';
-
- $ThisFileInfo['playtime_seconds'] = $thisfile_bonk_BONK['number_samples'] / ($thisfile_bonk_BONK['sample_rate'] * $thisfile_bonk_BONK['channels']);
- if ($ThisFileInfo['playtime_seconds'] > 0) {
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['bonk']['dataend'] - $ThisFileInfo['bonk']['dataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
+ $info['avdataoffset'] = $thisfile_bonk_BONK['offset'] + 5 + 17;
+ $info['avdataend'] = $thisfile_bonk_BONK['offset'] + $thisfile_bonk_BONK['size'];
+
+ $info['fileformat'] = 'bonk';
+ $info['audio']['dataformat'] = 'bonk';
+ $info['audio']['bitrate_mode'] = 'vbr'; // assumed
+ $info['audio']['channels'] = $thisfile_bonk_BONK['channels'];
+ $info['audio']['sample_rate'] = $thisfile_bonk_BONK['sample_rate'];
+ $info['audio']['channelmode'] = ($thisfile_bonk_BONK['joint_stereo'] ? 'joint stereo' : 'stereo');
+ $info['audio']['lossless'] = $thisfile_bonk_BONK['lossless'];
+ $info['audio']['codec'] = 'bonk';
+
+ $info['playtime_seconds'] = $thisfile_bonk_BONK['number_samples'] / ($thisfile_bonk_BONK['sample_rate'] * $thisfile_bonk_BONK['channels']);
+ if ($info['playtime_seconds'] > 0) {
+ $info['audio']['bitrate'] = (($info['bonk']['dataend'] - $info['bonk']['dataoffset']) * 8) / $info['playtime_seconds'];
}
break;
case 'INFO':
// shortcut
- $thisfile_bonk_INFO = &$ThisFileInfo['bonk']['INFO'];
+ $thisfile_bonk_INFO = &$info['bonk']['INFO'];
- $thisfile_bonk_INFO['version'] = getid3_lib::LittleEndian2Int(fread($fd, 1));
+ $thisfile_bonk_INFO['version'] = getid3_lib::LittleEndian2Int(fread($this->getid3->fp, 1));
$thisfile_bonk_INFO['entries_count'] = 0;
- $NextInfoDataPair = fread($fd, 5);
+ $NextInfoDataPair = fread($this->getid3->fp, 5);
if (!$this->BonkIsValidTagName(substr($NextInfoDataPair, 1, 4))) {
- while (!feof($fd)) {
+ while (!feof($this->getid3->fp)) {
//$CurrentSeekInfo['offset'] = getid3_lib::LittleEndian2Int(substr($NextInfoDataPair, 0, 4));
//$CurrentSeekInfo['nextbit'] = getid3_lib::LittleEndian2Int(substr($NextInfoDataPair, 4, 1));
//$thisfile_bonk_INFO[] = $CurrentSeekInfo;
- $NextInfoDataPair = fread($fd, 5);
+ $NextInfoDataPair = fread($this->getid3->fp, 5);
if ($this->BonkIsValidTagName(substr($NextInfoDataPair, 1, 4))) {
- fseek($fd, -5, SEEK_CUR);
+ fseek($this->getid3->fp, -5, SEEK_CUR);
break;
}
$thisfile_bonk_INFO['entries_count']++;
@@ -173,37 +174,45 @@ class getid3_bonk
break;
case 'META':
- $BonkData = "\x00".'META'.fread($fd, $ThisFileInfo['bonk']['META']['size'] - 5);
- $ThisFileInfo['bonk']['META']['version'] = getid3_lib::LittleEndian2Int(substr($BonkData, 5, 1));
+ $BonkData = "\x00".'META'.fread($this->getid3->fp, $info['bonk']['META']['size'] - 5);
+ $info['bonk']['META']['version'] = getid3_lib::LittleEndian2Int(substr($BonkData, 5, 1));
$MetaTagEntries = floor(((strlen($BonkData) - 8) - 6) / 8); // BonkData - xxxxmeta - ØMETA
$offset = 6;
for ($i = 0; $i < $MetaTagEntries; $i++) {
- $MetaEntryTagName = substr($BonkData, $offset, 4);
+ $MetaEntryTagName = substr($BonkData, $offset, 4);
$offset += 4;
$MetaEntryTagOffset = getid3_lib::LittleEndian2Int(substr($BonkData, $offset, 4));
$offset += 4;
- $ThisFileInfo['bonk']['META']['tags'][$MetaEntryTagName] = $MetaEntryTagOffset;
+ $info['bonk']['META']['tags'][$MetaEntryTagName] = $MetaEntryTagOffset;
}
break;
case ' ID3':
- $ThisFileInfo['audio']['encoder'] = 'Extended BONK v0.9+';
+ $info['audio']['encoder'] = 'Extended BONK v0.9+';
// ID3v2 checking is optional
if (class_exists('getid3_id3v2')) {
- $ThisFileInfo['bonk'][' ID3']['valid'] = new getid3_id3v2($fd, $ThisFileInfo, $ThisFileInfo['bonk'][' ID3']['offset'] + 2);
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_id3v2 = new getid3_id3v2($getid3_temp);
+ $getid3_id3v2->StartingOffset = $info['bonk'][' ID3']['offset'] + 2;
+ $info['bonk'][' ID3']['valid'] = $getid3_id3v2->Analyze();
+ if ($info['bonk'][' ID3']['valid']) {
+ $info['id3v2'] = $getid3_temp->info['id3v2'];
+ }
+ unset($getid3_temp, $getid3_id3v2);
}
break;
default:
- $ThisFileInfo['warning'][] = 'Unexpected Bonk tag "'.$BonkTagName.'" at offset '.$ThisFileInfo['bonk'][$BonkTagName]['offset'];
+ $info['warning'][] = 'Unexpected Bonk tag "'.$BonkTagName.'" at offset '.$info['bonk'][$BonkTagName]['offset'];
break;
}
}
- function BonkIsValidTagName($PossibleBonkTag, $ignorecase=false) {
+ static function BonkIsValidTagName($PossibleBonkTag, $ignorecase=false) {
static $BonkIsValidTagName = array('BONK', 'INFO', ' ID3', 'META');
foreach ($BonkIsValidTagName as $validtagname) {
if ($validtagname == $PossibleBonkTag) {
diff --git a/apps/media/getID3/getid3/module.audio.dss.php b/3rdparty/getid3/module.audio.dss.php
index b0887395c4b..b7b4367629a 100644
--- a/apps/media/getID3/getid3/module.audio.dss.php
+++ b/3rdparty/getid3/module.audio.dss.php
@@ -7,50 +7,53 @@
// See readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
-// module.audio.au.php //
+// module.audio.dss.php //
// module for analyzing Digital Speech Standard (DSS) files //
// dependencies: NONE //
// ///
/////////////////////////////////////////////////////////////////
-class getid3_dss
+class getid3_dss extends getid3_handler
{
- function getid3_dss(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $DSSheader = fread($fd, 1256);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $DSSheader = fread($this->getid3->fp, 1256);
- if (substr($DSSheader, 0, 4) != "\x02".'dss') {
- $ThisFileInfo['error'][] = 'Expecting "[x02]dss" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($DSSheader, 0, 4).'"';
+ if (!preg_match('#^(\x02|\x03)dss#', $DSSheader)) {
+ $info['error'][] = 'Expecting "[02-03] 64 73 73" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($DSSheader, 0, 4)).'"';
return false;
}
// some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
// shortcut
- $ThisFileInfo['dss'] = array();
- $thisfile_dss = &$ThisFileInfo['dss'];
+ $info['dss'] = array();
+ $thisfile_dss = &$info['dss'];
- $ThisFileInfo['fileformat'] = 'dss';
- $ThisFileInfo['audio']['dataformat'] = 'dss';
- $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
+ $info['fileformat'] = 'dss';
+ $info['audio']['dataformat'] = 'dss';
+ $info['audio']['bitrate_mode'] = 'cbr';
//$thisfile_dss['encoding'] = 'ISO-8859-1';
+ $thisfile_dss['version'] = ord(substr($DSSheader, 0, 1));
$thisfile_dss['date_create'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 38, 12));
$thisfile_dss['date_complete'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 50, 12));
- $thisfile_dss['length'] = intval(substr($DSSheader, 62, 6));
+ //$thisfile_dss['length'] = intval(substr($DSSheader, 62, 6)); // I thought time was in seconds, it's actually HHMMSS
+ $thisfile_dss['length'] = intval((substr($DSSheader, 62, 2) * 3600) + (substr($DSSheader, 64, 2) * 60) + substr($DSSheader, 66, 2));
$thisfile_dss['priority'] = ord(substr($DSSheader, 793, 1));
$thisfile_dss['comments'] = trim(substr($DSSheader, 798, 100));
- //$ThisFileInfo['audio']['bits_per_sample'] = ?;
- //$ThisFileInfo['audio']['sample_rate'] = ?;
- $ThisFileInfo['audio']['channels'] = 1;
+ //$info['audio']['bits_per_sample'] = ?;
+ //$info['audio']['sample_rate'] = ?;
+ $info['audio']['channels'] = 1;
- $ThisFileInfo['playtime_seconds'] = $thisfile_dss['length'];
- $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['filesize'] * 8) / $ThisFileInfo['playtime_seconds'];
+ $info['playtime_seconds'] = $thisfile_dss['length'];
+ $info['audio']['bitrate'] = ($info['filesize'] * 8) / $info['playtime_seconds'];
return true;
}
diff --git a/3rdparty/getid3/module.audio.dts.php b/3rdparty/getid3/module.audio.dts.php
new file mode 100644
index 00000000000..8102ba8bf53
--- /dev/null
+++ b/3rdparty/getid3/module.audio.dts.php
@@ -0,0 +1,246 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.dts.php //
+// module for analyzing DTS Audio files //
+// dependencies: NONE //
+// //
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_dts extends getid3_handler
+{
+
+ public function Analyze() {
+ $info = &$this->getid3->info;
+
+ // Specs taken from "DTS Coherent Acoustics;Core and Extensions, ETSI TS 102 114 V1.2.1 (2002-12)"
+ // (http://pda.etsi.org/pda/queryform.asp)
+ // With thanks to Gambit <macteam@users.sourceforge.net> http://mac.sourceforge.net/atl/
+
+ $info['fileformat'] = 'dts';
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $DTSheader = fread($this->getid3->fp, 16);
+ $info['dts']['raw']['magic'] = substr($DTSheader, 0, 4);
+
+ $magic = "\x7F\xFE\x80\x01";
+ if ($info['dts']['raw']['magic'] != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['dts']['raw']['magic']).'"';
+ unset($info['fileformat'], $info['dts']);
+ return false;
+ }
+
+ $fhBS = getid3_lib::BigEndian2Bin(substr($DTSheader, 4, 12));
+ $bsOffset = 0;
+ $info['dts']['raw']['frame_type'] = $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['raw']['deficit_samples'] = $this->readBinData($fhBS, $bsOffset, 5);
+ $info['dts']['flags']['crc_present'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['raw']['pcm_sample_blocks'] = $this->readBinData($fhBS, $bsOffset, 7);
+ $info['dts']['raw']['frame_byte_size'] = $this->readBinData($fhBS, $bsOffset, 14);
+ $info['dts']['raw']['channel_arrangement'] = $this->readBinData($fhBS, $bsOffset, 6);
+ $info['dts']['raw']['sample_frequency'] = $this->readBinData($fhBS, $bsOffset, 4);
+ $info['dts']['raw']['bitrate'] = $this->readBinData($fhBS, $bsOffset, 5);
+ $info['dts']['flags']['embedded_downmix'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['flags']['dynamicrange'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['flags']['timestamp'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['flags']['auxdata'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['flags']['hdcd'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['raw']['extension_audio'] = $this->readBinData($fhBS, $bsOffset, 3);
+ $info['dts']['flags']['extended_coding'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['flags']['audio_sync_insertion'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['raw']['lfe_effects'] = $this->readBinData($fhBS, $bsOffset, 2);
+ $info['dts']['flags']['predictor_history'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ if ($info['dts']['flags']['crc_present']) {
+ $info['dts']['raw']['crc16'] = $this->readBinData($fhBS, $bsOffset, 16);
+ }
+ $info['dts']['flags']['mri_perfect_reconst'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['raw']['encoder_soft_version'] = $this->readBinData($fhBS, $bsOffset, 4);
+ $info['dts']['raw']['copy_history'] = $this->readBinData($fhBS, $bsOffset, 2);
+ $info['dts']['raw']['bits_per_sample'] = $this->readBinData($fhBS, $bsOffset, 2);
+ $info['dts']['flags']['surround_es'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['flags']['front_sum_diff'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['flags']['surround_sum_diff'] = (bool) $this->readBinData($fhBS, $bsOffset, 1);
+ $info['dts']['raw']['dialog_normalization'] = $this->readBinData($fhBS, $bsOffset, 4);
+
+
+ $info['dts']['bitrate'] = self::DTSbitrateLookup($info['dts']['raw']['bitrate']);
+ $info['dts']['bits_per_sample'] = self::DTSbitPerSampleLookup($info['dts']['raw']['bits_per_sample']);
+ $info['dts']['sample_rate'] = self::DTSsampleRateLookup($info['dts']['raw']['sample_frequency']);
+ $info['dts']['dialog_normalization'] = self::DTSdialogNormalization($info['dts']['raw']['dialog_normalization'], $info['dts']['raw']['encoder_soft_version']);
+ $info['dts']['flags']['lossless'] = (($info['dts']['raw']['bitrate'] == 31) ? true : false);
+ $info['dts']['bitrate_mode'] = (($info['dts']['raw']['bitrate'] == 30) ? 'vbr' : 'cbr');
+ $info['dts']['channels'] = self::DTSnumChannelsLookup($info['dts']['raw']['channel_arrangement']);
+ $info['dts']['channel_arrangement'] = self::DTSchannelArrangementLookup($info['dts']['raw']['channel_arrangement']);
+
+ $info['audio']['dataformat'] = 'dts';
+ $info['audio']['lossless'] = $info['dts']['flags']['lossless'];
+ $info['audio']['bitrate_mode'] = $info['dts']['bitrate_mode'];
+ $info['audio']['bits_per_sample'] = $info['dts']['bits_per_sample'];
+ $info['audio']['sample_rate'] = $info['dts']['sample_rate'];
+ $info['audio']['channels'] = $info['dts']['channels'];
+ $info['audio']['bitrate'] = $info['dts']['bitrate'];
+ if (isset($info['avdataend'])) {
+ $info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) / ($info['dts']['bitrate'] / 8);
+ }
+
+ return true;
+ }
+
+ private function readBinData($bin, &$offset, $length) {
+ $data = substr($bin, $offset, $length);
+ $offset += $length;
+ return bindec($data);
+ }
+
+ private static function DTSbitrateLookup($index) {
+ $DTSbitrateLookup = array(
+ 0 => 32000,
+ 1 => 56000,
+ 2 => 64000,
+ 3 => 96000,
+ 4 => 112000,
+ 5 => 128000,
+ 6 => 192000,
+ 7 => 224000,
+ 8 => 256000,
+ 9 => 320000,
+ 10 => 384000,
+ 11 => 448000,
+ 12 => 512000,
+ 13 => 576000,
+ 14 => 640000,
+ 15 => 768000,
+ 16 => 960000,
+ 17 => 1024000,
+ 18 => 1152000,
+ 19 => 1280000,
+ 20 => 1344000,
+ 21 => 1408000,
+ 22 => 1411200,
+ 23 => 1472000,
+ 24 => 1536000,
+ 25 => 1920000,
+ 26 => 2048000,
+ 27 => 3072000,
+ 28 => 3840000,
+ 29 => 'open',
+ 30 => 'variable',
+ 31 => 'lossless'
+ );
+ return (isset($DTSbitrateLookup[$index]) ? $DTSbitrateLookup[$index] : false);
+ }
+
+ private static function DTSsampleRateLookup($index) {
+ $DTSsampleRateLookup = array(
+ 0 => 'invalid',
+ 1 => 8000,
+ 2 => 16000,
+ 3 => 32000,
+ 4 => 'invalid',
+ 5 => 'invalid',
+ 6 => 11025,
+ 7 => 22050,
+ 8 => 44100,
+ 9 => 'invalid',
+ 10 => 'invalid',
+ 11 => 12000,
+ 12 => 24000,
+ 13 => 48000,
+ 14 => 'invalid',
+ 15 => 'invalid'
+ );
+ return (isset($DTSsampleRateLookup[$index]) ? $DTSsampleRateLookup[$index] : false);
+ }
+
+ private static function DTSbitPerSampleLookup($index) {
+ $DTSbitPerSampleLookup = array(
+ 0 => 16,
+ 1 => 20,
+ 2 => 24,
+ 3 => 24,
+ );
+ return (isset($DTSbitPerSampleLookup[$index]) ? $DTSbitPerSampleLookup[$index] : false);
+ }
+
+ private static function DTSnumChannelsLookup($index) {
+ switch ($index) {
+ case 0:
+ return 1;
+ break;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ return 2;
+ break;
+ case 5:
+ case 6:
+ return 3;
+ break;
+ case 7:
+ case 8:
+ return 4;
+ break;
+ case 9:
+ return 5;
+ break;
+ case 10:
+ case 11:
+ case 12:
+ return 6;
+ break;
+ case 13:
+ return 7;
+ break;
+ case 14:
+ case 15:
+ return 8;
+ break;
+ }
+ return false;
+ }
+
+ private static function DTSchannelArrangementLookup($index) {
+ $DTSchannelArrangementLookup = array(
+ 0 => 'A',
+ 1 => 'A + B (dual mono)',
+ 2 => 'L + R (stereo)',
+ 3 => '(L+R) + (L-R) (sum-difference)',
+ 4 => 'LT + RT (left and right total)',
+ 5 => 'C + L + R',
+ 6 => 'L + R + S',
+ 7 => 'C + L + R + S',
+ 8 => 'L + R + SL + SR',
+ 9 => 'C + L + R + SL + SR',
+ 10 => 'CL + CR + L + R + SL + SR',
+ 11 => 'C + L + R+ LR + RR + OV',
+ 12 => 'CF + CR + LF + RF + LR + RR',
+ 13 => 'CL + C + CR + L + R + SL + SR',
+ 14 => 'CL + CR + L + R + SL1 + SL2 + SR1 + SR2',
+ 15 => 'CL + C+ CR + L + R + SL + S + SR',
+ );
+ return (isset($DTSchannelArrangementLookup[$index]) ? $DTSchannelArrangementLookup[$index] : 'user-defined');
+ }
+
+ private static function DTSdialogNormalization($index, $version) {
+ switch ($version) {
+ case 7:
+ return 0 - $index;
+ break;
+ case 6:
+ return 0 - 16 - $index;
+ break;
+ }
+ return false;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/3rdparty/getid3/module.audio.flac.php b/3rdparty/getid3/module.audio.flac.php
new file mode 100644
index 00000000000..98daec0fd9d
--- /dev/null
+++ b/3rdparty/getid3/module.audio.flac.php
@@ -0,0 +1,480 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.flac.php //
+// module for analyzing FLAC and OggFLAC audio files //
+// dependencies: module.audio.ogg.php //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, true);
+
+class getid3_flac extends getid3_handler
+{
+ var $inline_attachments = true; // true: return full data for all attachments; false: return no data for all attachments; integer: return data for attachments <= than this; string: save as file to this directory
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ // http://flac.sourceforge.net/format.html
+
+ $this->fseek($info['avdataoffset'], SEEK_SET);
+ $StreamMarker = $this->fread(4);
+ $magic = 'fLaC';
+ if ($StreamMarker != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($StreamMarker).'"';
+ return false;
+ }
+ $info['fileformat'] = 'flac';
+ $info['audio']['dataformat'] = 'flac';
+ $info['audio']['bitrate_mode'] = 'vbr';
+ $info['audio']['lossless'] = true;
+
+ return $this->FLACparseMETAdata();
+ }
+
+
+ function FLACparseMETAdata() {
+ $info = &$this->getid3->info;
+ do {
+ $METAdataBlockOffset = $this->ftell();
+ $METAdataBlockHeader = $this->fread(4);
+ $METAdataLastBlockFlag = (bool) (getid3_lib::BigEndian2Int(substr($METAdataBlockHeader, 0, 1)) & 0x80);
+ $METAdataBlockType = getid3_lib::BigEndian2Int(substr($METAdataBlockHeader, 0, 1)) & 0x7F;
+ $METAdataBlockLength = getid3_lib::BigEndian2Int(substr($METAdataBlockHeader, 1, 3));
+ $METAdataBlockTypeText = getid3_flac::FLACmetaBlockTypeLookup($METAdataBlockType);
+
+ if ($METAdataBlockLength < 0) {
+ $info['error'][] = 'corrupt or invalid METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$METAdataBlockType.') at offset '.$METAdataBlockOffset;
+ break;
+ }
+
+ $info['flac'][$METAdataBlockTypeText]['raw'] = array();
+ $ThisFileInfo_flac_METAdataBlockTypeText_raw = &$info['flac'][$METAdataBlockTypeText]['raw'];
+
+ $ThisFileInfo_flac_METAdataBlockTypeText_raw['offset'] = $METAdataBlockOffset;
+ $ThisFileInfo_flac_METAdataBlockTypeText_raw['last_meta_block'] = $METAdataLastBlockFlag;
+ $ThisFileInfo_flac_METAdataBlockTypeText_raw['block_type'] = $METAdataBlockType;
+ $ThisFileInfo_flac_METAdataBlockTypeText_raw['block_type_text'] = $METAdataBlockTypeText;
+ $ThisFileInfo_flac_METAdataBlockTypeText_raw['block_length'] = $METAdataBlockLength;
+ if (($METAdataBlockOffset + 4 + $METAdataBlockLength) > $info['avdataend']) {
+ $info['error'][] = 'METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$METAdataBlockType.') at offset '.$METAdataBlockOffset.' extends beyond end of file';
+ break;
+ }
+ if ($METAdataBlockLength < 1) {
+ $info['error'][] = 'METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$METAdataBlockLength.') at offset '.$METAdataBlockOffset.' is invalid';
+ break;
+ }
+ $ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'] = $this->fread($METAdataBlockLength);
+ $info['avdataoffset'] = $this->ftell();
+
+ switch ($METAdataBlockTypeText) {
+ case 'STREAMINFO': // 0x00
+ if (!$this->FLACparseSTREAMINFO($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'])) {
+ return false;
+ }
+ break;
+
+ case 'PADDING': // 0x01
+ // ignore
+ break;
+
+ case 'APPLICATION': // 0x02
+ if (!$this->FLACparseAPPLICATION($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'])) {
+ return false;
+ }
+ break;
+
+ case 'SEEKTABLE': // 0x03
+ if (!$this->FLACparseSEEKTABLE($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'])) {
+ return false;
+ }
+ break;
+
+ case 'VORBIS_COMMENT': // 0x04
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataoffset'] = $this->ftell() - $METAdataBlockLength;
+ $getid3_temp->info['audio']['dataformat'] = 'flac';
+ $getid3_temp->info['flac'] = $info['flac'];
+ $getid3_ogg = new getid3_ogg($getid3_temp);
+ $getid3_ogg->ParseVorbisCommentsFilepointer();
+ $maybe_copy_keys = array('vendor', 'comments_raw', 'comments', 'replay_gain');
+ foreach ($maybe_copy_keys as $maybe_copy_key) {
+ if (!empty($getid3_temp->info['ogg'][$maybe_copy_key])) {
+ $info['ogg'][$maybe_copy_key] = $getid3_temp->info['ogg'][$maybe_copy_key];
+ }
+ }
+ if (!empty($getid3_temp->info['replay_gain'])) {
+ $info['replay_gain'] = $getid3_temp->info['replay_gain'];
+ }
+ unset($getid3_temp, $getid3_ogg);
+ break;
+
+ case 'CUESHEET': // 0x05
+ if (!getid3_flac::FLACparseCUESHEET($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'])) {
+ return false;
+ }
+ break;
+
+ case 'PICTURE': // 0x06
+ if (!getid3_flac::FLACparsePICTURE($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'])) {
+ return false;
+ }
+ break;
+
+ default:
+ $info['warning'][] = 'Unhandled METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$METAdataBlockType.') at offset '.$METAdataBlockOffset;
+ break;
+ }
+
+ } while ($METAdataLastBlockFlag === false);
+
+ if (isset($info['flac']['PICTURE'])) {
+ foreach ($info['flac']['PICTURE'] as $key => $valuearray) {
+ if (!empty($valuearray['image_mime']) && !empty($valuearray['data'])) {
+ $info['ogg']['comments']['picture'][] = array('image_mime'=>$valuearray['image_mime'], 'data'=>$valuearray['data']);
+ }
+ }
+ }
+
+ if (isset($info['flac']['STREAMINFO'])) {
+ $info['flac']['compressed_audio_bytes'] = $info['avdataend'] - $info['avdataoffset'];
+ $info['flac']['uncompressed_audio_bytes'] = $info['flac']['STREAMINFO']['samples_stream'] * $info['flac']['STREAMINFO']['channels'] * ($info['flac']['STREAMINFO']['bits_per_sample'] / 8);
+ if ($info['flac']['uncompressed_audio_bytes'] == 0) {
+ $info['error'][] = 'Corrupt FLAC file: uncompressed_audio_bytes == zero';
+ return false;
+ }
+ $info['flac']['compression_ratio'] = $info['flac']['compressed_audio_bytes'] / $info['flac']['uncompressed_audio_bytes'];
+ }
+
+ // set md5_data_source - built into flac 0.5+
+ if (isset($info['flac']['STREAMINFO']['audio_signature'])) {
+
+ if ($info['flac']['STREAMINFO']['audio_signature'] === str_repeat("\x00", 16)) {
+
+ $info['warning'][] = 'FLAC STREAMINFO.audio_signature is null (known issue with libOggFLAC)';
+
+ } else {
+
+ $info['md5_data_source'] = '';
+ $md5 = $info['flac']['STREAMINFO']['audio_signature'];
+ for ($i = 0; $i < strlen($md5); $i++) {
+ $info['md5_data_source'] .= str_pad(dechex(ord($md5{$i})), 2, '00', STR_PAD_LEFT);
+ }
+ if (!preg_match('/^[0-9a-f]{32}$/', $info['md5_data_source'])) {
+ unset($info['md5_data_source']);
+ }
+
+ }
+
+ }
+
+ $info['audio']['bits_per_sample'] = $info['flac']['STREAMINFO']['bits_per_sample'];
+ if ($info['audio']['bits_per_sample'] == 8) {
+ // special case
+ // must invert sign bit on all data bytes before MD5'ing to match FLAC's calculated value
+ // MD5sum calculates on unsigned bytes, but FLAC calculated MD5 on 8-bit audio data as signed
+ $info['warning'][] = 'FLAC calculates MD5 data strangely on 8-bit audio, so the stored md5_data_source value will not match the decoded WAV file';
+ }
+ if (!empty($info['ogg']['vendor'])) {
+ $info['audio']['encoder'] = $info['ogg']['vendor'];
+ }
+
+ return true;
+ }
+
+ static function FLACmetaBlockTypeLookup($blocktype) {
+ static $FLACmetaBlockTypeLookup = array();
+ if (empty($FLACmetaBlockTypeLookup)) {
+ $FLACmetaBlockTypeLookup[0] = 'STREAMINFO';
+ $FLACmetaBlockTypeLookup[1] = 'PADDING';
+ $FLACmetaBlockTypeLookup[2] = 'APPLICATION';
+ $FLACmetaBlockTypeLookup[3] = 'SEEKTABLE';
+ $FLACmetaBlockTypeLookup[4] = 'VORBIS_COMMENT';
+ $FLACmetaBlockTypeLookup[5] = 'CUESHEET';
+ $FLACmetaBlockTypeLookup[6] = 'PICTURE';
+ }
+ return (isset($FLACmetaBlockTypeLookup[$blocktype]) ? $FLACmetaBlockTypeLookup[$blocktype] : 'reserved');
+ }
+
+ static function FLACapplicationIDLookup($applicationid) {
+ static $FLACapplicationIDLookup = array();
+ if (empty($FLACapplicationIDLookup)) {
+ // http://flac.sourceforge.net/id.html
+ $FLACapplicationIDLookup[0x46746F6C] = 'flac-tools'; // 'Ftol'
+ $FLACapplicationIDLookup[0x46746F6C] = 'Sound Font FLAC'; // 'SFFL'
+ }
+ return (isset($FLACapplicationIDLookup[$applicationid]) ? $FLACapplicationIDLookup[$applicationid] : 'reserved');
+ }
+
+ static function FLACpictureTypeLookup($type_id) {
+ static $lookup = array (
+ 0 => 'Other',
+ 1 => '32x32 pixels \'file icon\' (PNG only)',
+ 2 => 'Other file icon',
+ 3 => 'Cover (front)',
+ 4 => 'Cover (back)',
+ 5 => 'Leaflet page',
+ 6 => 'Media (e.g. label side of CD)',
+ 7 => 'Lead artist/lead performer/soloist',
+ 8 => 'Artist/performer',
+ 9 => 'Conductor',
+ 10 => 'Band/Orchestra',
+ 11 => 'Composer',
+ 12 => 'Lyricist/text writer',
+ 13 => 'Recording Location',
+ 14 => 'During recording',
+ 15 => 'During performance',
+ 16 => 'Movie/video screen capture',
+ 17 => 'A bright coloured fish',
+ 18 => 'Illustration',
+ 19 => 'Band/artist logotype',
+ 20 => 'Publisher/Studio logotype',
+ );
+ return (isset($lookup[$type_id]) ? $lookup[$type_id] : 'reserved');
+ }
+
+ function FLACparseSTREAMINFO($METAdataBlockData) {
+ $info = &$this->getid3->info;
+
+ $offset = 0;
+ $info['flac']['STREAMINFO']['min_block_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 2));
+ $offset += 2;
+ $info['flac']['STREAMINFO']['max_block_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 2));
+ $offset += 2;
+ $info['flac']['STREAMINFO']['min_frame_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 3));
+ $offset += 3;
+ $info['flac']['STREAMINFO']['max_frame_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 3));
+ $offset += 3;
+
+ $SampleRateChannelsSampleBitsStreamSamples = getid3_lib::BigEndian2Bin(substr($METAdataBlockData, $offset, 8));
+ $info['flac']['STREAMINFO']['sample_rate'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 0, 20));
+ $info['flac']['STREAMINFO']['channels'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 20, 3)) + 1;
+ $info['flac']['STREAMINFO']['bits_per_sample'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 23, 5)) + 1;
+ $info['flac']['STREAMINFO']['samples_stream'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 28, 36));
+ $offset += 8;
+
+ $info['flac']['STREAMINFO']['audio_signature'] = substr($METAdataBlockData, $offset, 16);
+ $offset += 16;
+
+ if (!empty($info['flac']['STREAMINFO']['sample_rate'])) {
+
+ $info['audio']['bitrate_mode'] = 'vbr';
+ $info['audio']['sample_rate'] = $info['flac']['STREAMINFO']['sample_rate'];
+ $info['audio']['channels'] = $info['flac']['STREAMINFO']['channels'];
+ $info['audio']['bits_per_sample'] = $info['flac']['STREAMINFO']['bits_per_sample'];
+ $info['playtime_seconds'] = $info['flac']['STREAMINFO']['samples_stream'] / $info['flac']['STREAMINFO']['sample_rate'];
+ if ($info['playtime_seconds'] > 0) {
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+ }
+
+ } else {
+ $info['error'][] = 'Corrupt METAdata block: STREAMINFO';
+ return false;
+ }
+ unset($info['flac']['STREAMINFO']['raw']);
+ return true;
+ }
+
+
+ function FLACparseAPPLICATION($METAdataBlockData) {
+ $info = &$this->getid3->info;
+
+ $offset = 0;
+ $ApplicationID = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 4));
+ $offset += 4;
+ $info['flac']['APPLICATION'][$ApplicationID]['name'] = getid3_flac::FLACapplicationIDLookup($ApplicationID);
+ $info['flac']['APPLICATION'][$ApplicationID]['data'] = substr($METAdataBlockData, $offset);
+ $offset = $METAdataBlockLength;
+
+ unset($info['flac']['APPLICATION']['raw']);
+ return true;
+ }
+
+
+ function FLACparseSEEKTABLE($METAdataBlockData) {
+ $info = &$this->getid3->info;
+
+ $offset = 0;
+ $METAdataBlockLength = strlen($METAdataBlockData);
+ $placeholderpattern = str_repeat("\xFF", 8);
+ while ($offset < $METAdataBlockLength) {
+ $SampleNumberString = substr($METAdataBlockData, $offset, 8);
+ $offset += 8;
+ if ($SampleNumberString == $placeholderpattern) {
+
+ // placeholder point
+ getid3_lib::safe_inc($info['flac']['SEEKTABLE']['placeholders'], 1);
+ $offset += 10;
+
+ } else {
+
+ $SampleNumber = getid3_lib::BigEndian2Int($SampleNumberString);
+ $info['flac']['SEEKTABLE'][$SampleNumber]['offset'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
+ $offset += 8;
+ $info['flac']['SEEKTABLE'][$SampleNumber]['samples'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 2));
+ $offset += 2;
+
+ }
+ }
+
+ unset($info['flac']['SEEKTABLE']['raw']);
+
+ return true;
+ }
+
+ function FLACparseCUESHEET($METAdataBlockData) {
+ $info = &$this->getid3->info;
+ $offset = 0;
+ $info['flac']['CUESHEET']['media_catalog_number'] = trim(substr($METAdataBlockData, $offset, 128), "\0");
+ $offset += 128;
+ $info['flac']['CUESHEET']['lead_in_samples'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
+ $offset += 8;
+ $info['flac']['CUESHEET']['flags']['is_cd'] = (bool) (getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1)) & 0x80);
+ $offset += 1;
+
+ $offset += 258; // reserved
+
+ $info['flac']['CUESHEET']['number_tracks'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
+ $offset += 1;
+
+ for ($track = 0; $track < $info['flac']['CUESHEET']['number_tracks']; $track++) {
+ $TrackSampleOffset = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
+ $offset += 8;
+ $TrackNumber = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
+ $offset += 1;
+
+ $info['flac']['CUESHEET']['tracks'][$TrackNumber]['sample_offset'] = $TrackSampleOffset;
+
+ $info['flac']['CUESHEET']['tracks'][$TrackNumber]['isrc'] = substr($METAdataBlockData, $offset, 12);
+ $offset += 12;
+
+ $TrackFlagsRaw = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
+ $offset += 1;
+ $info['flac']['CUESHEET']['tracks'][$TrackNumber]['flags']['is_audio'] = (bool) ($TrackFlagsRaw & 0x80);
+ $info['flac']['CUESHEET']['tracks'][$TrackNumber]['flags']['pre_emphasis'] = (bool) ($TrackFlagsRaw & 0x40);
+
+ $offset += 13; // reserved
+
+ $info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
+ $offset += 1;
+
+ for ($index = 0; $index < $info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points']; $index++) {
+ $IndexSampleOffset = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
+ $offset += 8;
+ $IndexNumber = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
+ $offset += 1;
+
+ $offset += 3; // reserved
+
+ $info['flac']['CUESHEET']['tracks'][$TrackNumber]['indexes'][$IndexNumber] = $IndexSampleOffset;
+ }
+ }
+
+ unset($info['flac']['CUESHEET']['raw']);
+
+ return true;
+ }
+
+
+ function FLACparsePICTURE($meta_data_block_data) {
+ $info = &$this->getid3->info;
+ $picture = &$info['flac']['PICTURE'][sizeof($info['flac']['PICTURE']) - 1];
+ $picture['offset'] = $info['flac']['PICTURE']['raw']['offset'];
+ unset($info['flac']['PICTURE']['raw']);
+
+ $offset = 0;
+
+ $picture['typeid'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
+ $picture['type'] = getid3_flac::FLACpictureTypeLookup($picture['typeid']);
+ $offset += 4;
+
+ $length = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
+ $offset += 4;
+
+ $picture['image_mime'] = substr($meta_data_block_data, $offset, $length);
+ $offset += $length;
+
+ $length = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
+ $offset += 4;
+
+ $picture['description'] = substr($meta_data_block_data, $offset, $length);
+ $offset += $length;
+
+ $picture['width'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
+ $offset += 4;
+
+ $picture['height'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
+ $offset += 4;
+
+ $picture['color_depth'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
+ $offset += 4;
+
+ $picture['colors_indexed'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
+ $offset += 4;
+
+ $length = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
+ $offset += 4;
+
+ $picture['data'] = substr($meta_data_block_data, $offset, $length);
+ $offset += $length;
+ $picture['data_length'] = strlen($picture['data']);
+
+
+ do {
+ if ($this->inline_attachments === false) {
+ // skip entirely
+ unset($picture['data']);
+ break;
+ }
+ if ($this->inline_attachments === true) {
+ // great
+ } elseif (is_int($this->inline_attachments)) {
+ if ($this->inline_attachments < $picture['data_length']) {
+ // too big, skip
+ $info['warning'][] = 'attachment at '.$picture['offset'].' is too large to process inline ('.number_format($picture['data_length']).' bytes)';
+ unset($picture['data']);
+ break;
+ }
+ } elseif (is_string($this->inline_attachments)) {
+ $this->inline_attachments = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->inline_attachments), DIRECTORY_SEPARATOR);
+ if (!is_dir($this->inline_attachments) || !is_writable($this->inline_attachments)) {
+ // cannot write, skip
+ $info['warning'][] = 'attachment at '.$picture['offset'].' cannot be saved to "'.$this->inline_attachments.'" (not writable)';
+ unset($picture['data']);
+ break;
+ }
+ }
+ // if we get this far, must be OK
+ if (is_string($this->inline_attachments)) {
+ $destination_filename = $this->inline_attachments.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$picture['offset'];
+ if (!file_exists($destination_filename) || is_writable($destination_filename)) {
+ file_put_contents($destination_filename, $picture['data']);
+ } else {
+ $info['warning'][] = 'attachment at '.$picture['offset'].' cannot be saved to "'.$destination_filename.'" (not writable)';
+ }
+ $picture['data_filename'] = $destination_filename;
+ unset($picture['data']);
+ } else {
+ if (!isset($info['flac']['comments']['picture'])) {
+ $info['flac']['comments']['picture'] = array();
+ }
+ $info['flac']['comments']['picture'][] = array('data'=>$picture['data'], 'image_mime'=>$picture['image_mime']);
+ }
+ } while (false);
+
+
+
+ return true;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/3rdparty/getid3/module.audio.la.php b/3rdparty/getid3/module.audio.la.php
new file mode 100644
index 00000000000..98d80a6dc6c
--- /dev/null
+++ b/3rdparty/getid3/module.audio.la.php
@@ -0,0 +1,229 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.la.php //
+// module for analyzing LA (LosslessAudio) audio files //
+// dependencies: module.audio.riff.php //
+// ///
+/////////////////////////////////////////////////////////////////
+
+getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
+
+class getid3_la extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $offset = 0;
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $rawdata = fread($this->getid3->fp, $this->getid3->fread_buffer_size());
+
+ switch (substr($rawdata, $offset, 4)) {
+ case 'LA02':
+ case 'LA03':
+ case 'LA04':
+ $info['fileformat'] = 'la';
+ $info['audio']['dataformat'] = 'la';
+ $info['audio']['lossless'] = true;
+
+ $info['la']['version_major'] = (int) substr($rawdata, $offset + 2, 1);
+ $info['la']['version_minor'] = (int) substr($rawdata, $offset + 3, 1);
+ $info['la']['version'] = (float) $info['la']['version_major'] + ($info['la']['version_minor'] / 10);
+ $offset += 4;
+
+ $info['la']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
+ $offset += 4;
+ if ($info['la']['uncompressed_size'] == 0) {
+ $info['error'][] = 'Corrupt LA file: uncompressed_size == zero';
+ return false;
+ }
+
+ $WAVEchunk = substr($rawdata, $offset, 4);
+ if ($WAVEchunk !== 'WAVE') {
+ $info['error'][] = 'Expected "WAVE" ('.getid3_lib::PrintHexBytes('WAVE').') at offset '.$offset.', found "'.$WAVEchunk.'" ('.getid3_lib::PrintHexBytes($WAVEchunk).') instead.';
+ return false;
+ }
+ $offset += 4;
+
+ $info['la']['fmt_size'] = 24;
+ if ($info['la']['version'] >= 0.3) {
+
+ $info['la']['fmt_size'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
+ $info['la']['header_size'] = 49 + $info['la']['fmt_size'] - 24;
+ $offset += 4;
+
+ } else {
+
+ // version 0.2 didn't support additional data blocks
+ $info['la']['header_size'] = 41;
+
+ }
+
+ $fmt_chunk = substr($rawdata, $offset, 4);
+ if ($fmt_chunk !== 'fmt ') {
+ $info['error'][] = 'Expected "fmt " ('.getid3_lib::PrintHexBytes('fmt ').') at offset '.$offset.', found "'.$fmt_chunk.'" ('.getid3_lib::PrintHexBytes($fmt_chunk).') instead.';
+ return false;
+ }
+ $offset += 4;
+ $fmt_size = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
+ $offset += 4;
+
+ $info['la']['raw']['format'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));
+ $offset += 2;
+
+ $info['la']['channels'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));
+ $offset += 2;
+ if ($info['la']['channels'] == 0) {
+ $info['error'][] = 'Corrupt LA file: channels == zero';
+ return false;
+ }
+
+ $info['la']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
+ $offset += 4;
+ if ($info['la']['sample_rate'] == 0) {
+ $info['error'][] = 'Corrupt LA file: sample_rate == zero';
+ return false;
+ }
+
+ $info['la']['bytes_per_second'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
+ $offset += 4;
+ $info['la']['bytes_per_sample'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));
+ $offset += 2;
+ $info['la']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));
+ $offset += 2;
+
+ $info['la']['samples'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
+ $offset += 4;
+
+ $info['la']['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 1));
+ $offset += 1;
+ $info['la']['flags']['seekable'] = (bool) ($info['la']['raw']['flags'] & 0x01);
+ if ($info['la']['version'] >= 0.4) {
+ $info['la']['flags']['high_compression'] = (bool) ($info['la']['raw']['flags'] & 0x02);
+ }
+
+ $info['la']['original_crc'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
+ $offset += 4;
+
+ // mikeØbevin*de
+ // Basically, the blocksize/seekevery are 61440/19 in La0.4 and 73728/16
+ // in earlier versions. A seekpoint is added every blocksize * seekevery
+ // samples, so 4 * int(totalSamples / (blockSize * seekEvery)) should
+ // give the number of bytes used for the seekpoints. Of course, if seeking
+ // is disabled, there are no seekpoints stored.
+ if ($info['la']['version'] >= 0.4) {
+ $info['la']['blocksize'] = 61440;
+ $info['la']['seekevery'] = 19;
+ } else {
+ $info['la']['blocksize'] = 73728;
+ $info['la']['seekevery'] = 16;
+ }
+
+ $info['la']['seekpoint_count'] = 0;
+ if ($info['la']['flags']['seekable']) {
+ $info['la']['seekpoint_count'] = floor($info['la']['samples'] / ($info['la']['blocksize'] * $info['la']['seekevery']));
+
+ for ($i = 0; $i < $info['la']['seekpoint_count']; $i++) {
+ $info['la']['seekpoints'][] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
+ $offset += 4;
+ }
+ }
+
+ if ($info['la']['version'] >= 0.3) {
+
+ // Following the main header information, the program outputs all of the
+ // seekpoints. Following these is what I called the 'footer start',
+ // i.e. the position immediately after the La audio data is finished.
+ $info['la']['footerstart'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
+ $offset += 4;
+
+ if ($info['la']['footerstart'] > $info['filesize']) {
+ $info['warning'][] = 'FooterStart value points to offset '.$info['la']['footerstart'].' which is beyond end-of-file ('.$info['filesize'].')';
+ $info['la']['footerstart'] = $info['filesize'];
+ }
+
+ } else {
+
+ // La v0.2 didn't have FooterStart value
+ $info['la']['footerstart'] = $info['avdataend'];
+
+ }
+
+ if ($info['la']['footerstart'] < $info['avdataend']) {
+ if ($RIFFtempfilename = tempnam(GETID3_TEMP_DIR, 'id3')) {
+ if ($RIFF_fp = fopen($RIFFtempfilename, 'w+b')) {
+ $RIFFdata = 'WAVE';
+ if ($info['la']['version'] == 0.2) {
+ $RIFFdata .= substr($rawdata, 12, 24);
+ } else {
+ $RIFFdata .= substr($rawdata, 16, 24);
+ }
+ if ($info['la']['footerstart'] < $info['avdataend']) {
+ fseek($this->getid3->fp, $info['la']['footerstart'], SEEK_SET);
+ $RIFFdata .= fread($this->getid3->fp, $info['avdataend'] - $info['la']['footerstart']);
+ }
+ $RIFFdata = 'RIFF'.getid3_lib::LittleEndian2String(strlen($RIFFdata), 4, false).$RIFFdata;
+ fwrite($RIFF_fp, $RIFFdata, strlen($RIFFdata));
+ fclose($RIFF_fp);
+
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($RIFFtempfilename);
+ $getid3_riff = new getid3_riff($getid3_temp);
+ $getid3_riff->Analyze();
+
+ if (empty($getid3_temp->info['error'])) {
+ $info['riff'] = $getid3_temp->info['riff'];
+ } else {
+ $info['warning'][] = 'Error parsing RIFF portion of La file: '.implode($getid3_temp->info['error']);
+ }
+ unset($getid3_temp, $getid3_riff);
+ }
+ unlink($RIFFtempfilename);
+ }
+ }
+
+ // $info['avdataoffset'] should be zero to begin with, but just in case it's not, include the addition anyway
+ $info['avdataend'] = $info['avdataoffset'] + $info['la']['footerstart'];
+ $info['avdataoffset'] = $info['avdataoffset'] + $offset;
+
+ //$info['la']['codec'] = RIFFwFormatTagLookup($info['la']['raw']['format']);
+ $info['la']['compression_ratio'] = (float) (($info['avdataend'] - $info['avdataoffset']) / $info['la']['uncompressed_size']);
+ $info['playtime_seconds'] = (float) ($info['la']['samples'] / $info['la']['sample_rate']) / $info['la']['channels'];
+ if ($info['playtime_seconds'] == 0) {
+ $info['error'][] = 'Corrupt LA file: playtime_seconds == zero';
+ return false;
+ }
+
+ $info['audio']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
+ //$info['audio']['codec'] = $info['la']['codec'];
+ $info['audio']['bits_per_sample'] = $info['la']['bits_per_sample'];
+ break;
+
+ default:
+ if (substr($rawdata, $offset, 2) == 'LA') {
+ $info['error'][] = 'This version of getID3() ['.$this->getid3->version().'] does not support LA version '.substr($rawdata, $offset + 2, 1).'.'.substr($rawdata, $offset + 3, 1).' which this appears to be - check http://getid3.sourceforge.net for updates.';
+ } else {
+ $info['error'][] = 'Not a LA (Lossless-Audio) file';
+ }
+ return false;
+ break;
+ }
+
+ $info['audio']['channels'] = $info['la']['channels'];
+ $info['audio']['sample_rate'] = (int) $info['la']['sample_rate'];
+ $info['audio']['encoder'] = 'LA v'.$info['la']['version'];
+
+ return true;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/3rdparty/getid3/module.audio.lpac.php b/3rdparty/getid3/module.audio.lpac.php
new file mode 100644
index 00000000000..6ef0fb8acd0
--- /dev/null
+++ b/3rdparty/getid3/module.audio.lpac.php
@@ -0,0 +1,130 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.lpac.php //
+// module for analyzing LPAC Audio files //
+// dependencies: module.audio-video.riff.php //
+// ///
+/////////////////////////////////////////////////////////////////
+
+getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
+
+class getid3_lpac extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $LPACheader = fread($this->getid3->fp, 14);
+ if (substr($LPACheader, 0, 4) != 'LPAC') {
+ $info['error'][] = 'Expected "LPAC" at offset '.$info['avdataoffset'].', found "'.$StreamMarker.'"';
+ return false;
+ }
+ $info['avdataoffset'] += 14;
+
+ $info['fileformat'] = 'lpac';
+ $info['audio']['dataformat'] = 'lpac';
+ $info['audio']['lossless'] = true;
+ $info['audio']['bitrate_mode'] = 'vbr';
+
+ $info['lpac']['file_version'] = getid3_lib::BigEndian2Int(substr($LPACheader, 4, 1));
+ $flags['audio_type'] = getid3_lib::BigEndian2Int(substr($LPACheader, 5, 1));
+ $info['lpac']['total_samples']= getid3_lib::BigEndian2Int(substr($LPACheader, 6, 4));
+ $flags['parameters'] = getid3_lib::BigEndian2Int(substr($LPACheader, 10, 4));
+
+ $info['lpac']['flags']['is_wave'] = (bool) ($flags['audio_type'] & 0x40);
+ $info['lpac']['flags']['stereo'] = (bool) ($flags['audio_type'] & 0x04);
+ $info['lpac']['flags']['24_bit'] = (bool) ($flags['audio_type'] & 0x02);
+ $info['lpac']['flags']['16_bit'] = (bool) ($flags['audio_type'] & 0x01);
+
+ if ($info['lpac']['flags']['24_bit'] && $info['lpac']['flags']['16_bit']) {
+ $info['warning'][] = '24-bit and 16-bit flags cannot both be set';
+ }
+
+ $info['lpac']['flags']['fast_compress'] = (bool) ($flags['parameters'] & 0x40000000);
+ $info['lpac']['flags']['random_access'] = (bool) ($flags['parameters'] & 0x08000000);
+ $info['lpac']['block_length'] = pow(2, (($flags['parameters'] & 0x07000000) >> 24)) * 256;
+ $info['lpac']['flags']['adaptive_prediction_order'] = (bool) ($flags['parameters'] & 0x00800000);
+ $info['lpac']['flags']['adaptive_quantization'] = (bool) ($flags['parameters'] & 0x00400000);
+ $info['lpac']['flags']['joint_stereo'] = (bool) ($flags['parameters'] & 0x00040000);
+ $info['lpac']['quantization'] = ($flags['parameters'] & 0x00001F00) >> 8;
+ $info['lpac']['max_prediction_order'] = ($flags['parameters'] & 0x0000003F);
+
+ if ($info['lpac']['flags']['fast_compress'] && ($info['lpac']['max_prediction_order'] != 3)) {
+ $info['warning'][] = 'max_prediction_order expected to be "3" if fast_compress is true, actual value is "'.$info['lpac']['max_prediction_order'].'"';
+ }
+ switch ($info['lpac']['file_version']) {
+ case 6:
+ if ($info['lpac']['flags']['adaptive_quantization']) {
+ $info['warning'][] = 'adaptive_quantization expected to be false in LPAC file stucture v6, actually true';
+ }
+ if ($info['lpac']['quantization'] != 20) {
+ $info['warning'][] = 'Quantization expected to be 20 in LPAC file stucture v6, actually '.$info['lpac']['flags']['Q'];
+ }
+ break;
+
+ default:
+ //$info['warning'][] = 'This version of getID3() ['.$this->getid3->version().'] only supports LPAC file format version 6, this file is version '.$info['lpac']['file_version'].' - please report to info@getid3.org';
+ break;
+ }
+
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info = $info;
+ $getid3_riff = new getid3_riff($getid3_temp);
+ $getid3_riff->Analyze();
+ $info['avdataoffset'] = $getid3_temp->info['avdataoffset'];
+ $info['riff'] = $getid3_temp->info['riff'];
+ $info['error'] = $getid3_temp->info['error'];
+ $info['warning'] = $getid3_temp->info['warning'];
+ $info['lpac']['comments']['comment'] = $getid3_temp->info['comments'];
+ $info['audio']['sample_rate'] = $getid3_temp->info['audio']['sample_rate'];
+ unset($getid3_temp, $getid3_riff);
+
+ $info['audio']['channels'] = ($info['lpac']['flags']['stereo'] ? 2 : 1);
+
+ if ($info['lpac']['flags']['24_bit']) {
+ $info['audio']['bits_per_sample'] = $info['riff']['audio'][0]['bits_per_sample'];
+ } elseif ($info['lpac']['flags']['16_bit']) {
+ $info['audio']['bits_per_sample'] = 16;
+ } else {
+ $info['audio']['bits_per_sample'] = 8;
+ }
+
+ if ($info['lpac']['flags']['fast_compress']) {
+ // fast
+ $info['audio']['encoder_options'] = '-1';
+ } else {
+ switch ($info['lpac']['max_prediction_order']) {
+ case 20: // simple
+ $info['audio']['encoder_options'] = '-2';
+ break;
+ case 30: // medium
+ $info['audio']['encoder_options'] = '-3';
+ break;
+ case 40: // high
+ $info['audio']['encoder_options'] = '-4';
+ break;
+ case 60: // extrahigh
+ $info['audio']['encoder_options'] = '-5';
+ break;
+ }
+ }
+
+ $info['playtime_seconds'] = $info['lpac']['total_samples'] / $info['audio']['sample_rate'];
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+
+ return true;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.midi.php b/3rdparty/getid3/module.audio.midi.php
index 0fd7c9bdbfd..7b839cf1404 100644
--- a/apps/media/getID3/getid3/module.audio.midi.php
+++ b/3rdparty/getid3/module.audio.midi.php
@@ -13,27 +13,31 @@
// ///
/////////////////////////////////////////////////////////////////
+define('GETID3_MIDI_MAGIC_MTHD', 'MThd'); // MIDI file header magic
+define('GETID3_MIDI_MAGIC_MTRK', 'MTrk'); // MIDI track header magic
-class getid3_midi
+class getid3_midi extends getid3_handler
{
+ var $scanwholefile = true;
- function getid3_midi(&$fd, &$ThisFileInfo, $scanwholefile=true) {
+ function Analyze() {
+ $info = &$this->getid3->info;
// shortcut
- $ThisFileInfo['midi']['raw'] = array();
- $thisfile_midi = &$ThisFileInfo['midi'];
+ $info['midi']['raw'] = array();
+ $thisfile_midi = &$info['midi'];
$thisfile_midi_raw = &$thisfile_midi['raw'];
- $ThisFileInfo['fileformat'] = 'midi';
- $ThisFileInfo['audio']['dataformat'] = 'midi';
+ $info['fileformat'] = 'midi';
+ $info['audio']['dataformat'] = 'midi';
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $MIDIdata = fread($fd, GETID3_FREAD_BUFFER_SIZE);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $MIDIdata = fread($this->getid3->fp, $this->getid3->fread_buffer_size());
$offset = 0;
$MIDIheaderID = substr($MIDIdata, $offset, 4); // 'MThd'
- if ($MIDIheaderID != 'MThd') {
- $ThisFileInfo['error'][] = 'Expecting "MThd" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$MIDIheaderID.'"';
- unset($ThisFileInfo['fileformat']);
+ if ($MIDIheaderID != GETID3_MIDI_MAGIC_MTHD) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes(GETID3_MIDI_MAGIC_MTHD).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($MIDIheaderID).'"';
+ unset($info['fileformat']);
return false;
}
$offset += 4;
@@ -47,33 +51,33 @@ class getid3_midi
$offset += 2;
for ($i = 0; $i < $thisfile_midi_raw['tracks']; $i++) {
- if ((strlen($MIDIdata) - $offset) < 8) {
- $MIDIdata .= fread($fd, GETID3_FREAD_BUFFER_SIZE);
+ while ((strlen($MIDIdata) - $offset) < 8) {
+ $MIDIdata .= fread($this->getid3->fp, $this->getid3->fread_buffer_size());
}
$trackID = substr($MIDIdata, $offset, 4);
$offset += 4;
- if ($trackID == 'MTrk') {
+ if ($trackID == GETID3_MIDI_MAGIC_MTRK) {
$tracksize = getid3_lib::BigEndian2Int(substr($MIDIdata, $offset, 4));
$offset += 4;
// $thisfile_midi['tracks'][$i]['size'] = $tracksize;
$trackdataarray[$i] = substr($MIDIdata, $offset, $tracksize);
$offset += $tracksize;
} else {
- $ThisFileInfo['error'][] = 'Expecting "MTrk" at '.$offset.', found '.$trackID.' instead';
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes(GETID3_MIDI_MAGIC_MTRK).'" at '.($offset - 4).', found "'.getid3_lib::PrintHexBytes($trackID).'" instead';
return false;
}
}
if (!isset($trackdataarray) || !is_array($trackdataarray)) {
- $ThisFileInfo['error'][] = 'Cannot find MIDI track information';
+ $info['error'][] = 'Cannot find MIDI track information';
unset($thisfile_midi);
- unset($ThisFileInfo['fileformat']);
+ unset($info['fileformat']);
return false;
}
- if ($scanwholefile) { // this can take quite a long time, so have the option to bypass it if speed is very important
+ if ($this->scanwholefile) { // this can take quite a long time, so have the option to bypass it if speed is very important
$thisfile_midi['totalticks'] = 0;
- $ThisFileInfo['playtime_seconds'] = 0;
+ $info['playtime_seconds'] = 0;
$CurrentMicroSecondsPerBeat = 500000; // 120 beats per minute; 60,000,000 microseconds per minute -> 500,000 microseconds per beat
$CurrentBeatsPerMinute = 120; // 120 beats per minute; 60,000,000 microseconds per minute -> 500,000 microseconds per beat
$MicroSecondsPerQuarterNoteAfter = array ();
@@ -215,7 +219,7 @@ class getid3_midi
case 0x51: // Tempo: microseconds / quarter note
$CurrentMicroSecondsPerBeat = getid3_lib::BigEndian2Int(substr($METAeventData, 0, $METAeventLength));
if ($CurrentMicroSecondsPerBeat == 0) {
- $ThisFileInfo['error'][] = 'Corrupt MIDI file: CurrentMicroSecondsPerBeat == zero';
+ $info['error'][] = 'Corrupt MIDI file: CurrentMicroSecondsPerBeat == zero';
return false;
}
$thisfile_midi_raw['events'][$tracknumber][$CumulativeDeltaTime]['us_qnote'] = $CurrentMicroSecondsPerBeat;
@@ -258,13 +262,13 @@ class getid3_midi
break;
default:
- $ThisFileInfo['warning'][] = 'Unhandled META Event Command: '.$METAeventCommand;
+ $info['warning'][] = 'Unhandled META Event Command: '.$METAeventCommand;
break;
}
} else {
- $ThisFileInfo['warning'][] = 'Unhandled MIDI Event ID: '.$MIDIevents[$tracknumber][$eventid]['eventid'].' + Channel ID: '.$MIDIevents[$tracknumber][$eventid]['channel'];
+ $info['warning'][] = 'Unhandled MIDI Event ID: '.$MIDIevents[$tracknumber][$eventid]['eventid'].' + Channel ID: '.$MIDIevents[$tracknumber][$eventid]['channel'];
}
}
@@ -284,11 +288,11 @@ class getid3_midi
if ($thisfile_midi['totalticks'] > $tickoffset) {
if ($thisfile_midi_raw['ticksperqnote'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt MIDI file: ticksperqnote == zero';
+ $info['error'][] = 'Corrupt MIDI file: ticksperqnote == zero';
return false;
}
- $ThisFileInfo['playtime_seconds'] += (($tickoffset - $previoustickoffset) / $thisfile_midi_raw['ticksperqnote']) * ($prevmicrosecondsperbeat / 1000000);
+ $info['playtime_seconds'] += (($tickoffset - $previoustickoffset) / $thisfile_midi_raw['ticksperqnote']) * ($prevmicrosecondsperbeat / 1000000);
$prevmicrosecondsperbeat = $microsecondsperbeat;
$previoustickoffset = $tickoffset;
@@ -297,18 +301,18 @@ class getid3_midi
if ($thisfile_midi['totalticks'] > $previoustickoffset) {
if ($thisfile_midi_raw['ticksperqnote'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt MIDI file: ticksperqnote == zero';
+ $info['error'][] = 'Corrupt MIDI file: ticksperqnote == zero';
return false;
}
- $ThisFileInfo['playtime_seconds'] += (($thisfile_midi['totalticks'] - $previoustickoffset) / $thisfile_midi_raw['ticksperqnote']) * ($microsecondsperbeat / 1000000);
+ $info['playtime_seconds'] += (($thisfile_midi['totalticks'] - $previoustickoffset) / $thisfile_midi_raw['ticksperqnote']) * ($microsecondsperbeat / 1000000);
}
}
-
- if (@$ThisFileInfo['playtime_seconds'] > 0) {
- $ThisFileInfo['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
+
+ if (!empty($info['playtime_seconds'])) {
+ $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
}
if (!empty($thisfile_midi['lyrics'])) {
diff --git a/3rdparty/getid3/module.audio.mod.php b/3rdparty/getid3/module.audio.mod.php
new file mode 100644
index 00000000000..b8817694261
--- /dev/null
+++ b/3rdparty/getid3/module.audio.mod.php
@@ -0,0 +1,101 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.mod.php //
+// module for analyzing MOD Audio files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_mod extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $fileheader = fread($this->getid3->fp, 1088);
+ if (preg_match('#^IMPM#', $fileheader)) {
+ return $this->getITheaderFilepointer();
+ } elseif (preg_match('#^Extended Module#', $fileheader)) {
+ return $this->getXMheaderFilepointer();
+ } elseif (preg_match('#^.{44}SCRM#', $fileheader)) {
+ return $this->getS3MheaderFilepointer();
+ } elseif (preg_match('#^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)#', $fileheader)) {
+ return $this->getMODheaderFilepointer();
+ }
+ $info['error'][] = 'This is not a known type of MOD file';
+ return false;
+ }
+
+
+ function getMODheaderFilepointer() {
+ $info = &$this->getid3->info;
+ fseek($this->getid3->fp, $info['avdataoffset'] + 1080);
+ $FormatID = fread($this->getid3->fp, 4);
+ if (!preg_match('#^(M.K.|[5-9]CHN|[1-3][0-9]CH)$#', $FormatID)) {
+ $info['error'][] = 'This is not a known type of MOD file';
+ return false;
+ }
+
+ $info['fileformat'] = 'mod';
+
+ $info['error'][] = 'MOD parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
+ return false;
+ }
+
+ function getXMheaderFilepointer() {
+ $info = &$this->getid3->info;
+ fseek($this->getid3->fp, $info['avdataoffset']);
+ $FormatID = fread($this->getid3->fp, 15);
+ if (!preg_match('#^Extended Module$#', $FormatID)) {
+ $info['error'][] = 'This is not a known type of XM-MOD file';
+ return false;
+ }
+
+ $info['fileformat'] = 'xm';
+
+ $info['error'][] = 'XM-MOD parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
+ return false;
+ }
+
+ function getS3MheaderFilepointer() {
+ $info = &$this->getid3->info;
+ fseek($this->getid3->fp, $info['avdataoffset'] + 44);
+ $FormatID = fread($this->getid3->fp, 4);
+ if (!preg_match('#^SCRM$#', $FormatID)) {
+ $info['error'][] = 'This is not a ScreamTracker MOD file';
+ return false;
+ }
+
+ $info['fileformat'] = 's3m';
+
+ $info['error'][] = 'ScreamTracker parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
+ return false;
+ }
+
+ function getITheaderFilepointer() {
+ $info = &$this->getid3->info;
+ fseek($this->getid3->fp, $info['avdataoffset']);
+ $FormatID = fread($this->getid3->fp, 4);
+ if (!preg_match('#^IMPM$#', $FormatID)) {
+ $info['error'][] = 'This is not an ImpulseTracker MOD file';
+ return false;
+ }
+
+ $info['fileformat'] = 'it';
+
+ $info['error'][] = 'ImpulseTracker parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
+ return false;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.monkey.php b/3rdparty/getid3/module.audio.monkey.php
index 42382ad15e6..ffaeae9f07b 100644
--- a/apps/media/getID3/getid3/module.audio.monkey.php
+++ b/3rdparty/getid3/module.audio.monkey.php
@@ -14,29 +14,32 @@
/////////////////////////////////////////////////////////////////
-class getid3_monkey
+class getid3_monkey extends getid3_handler
{
- function getid3_monkey(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
+
// based loosely on code from TMonkey by Jurgen Faul <jfaulØgmx*de>
// http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
- $ThisFileInfo['fileformat'] = 'mac';
- $ThisFileInfo['audio']['dataformat'] = 'mac';
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
- $ThisFileInfo['audio']['lossless'] = true;
+ $info['fileformat'] = 'mac';
+ $info['audio']['dataformat'] = 'mac';
+ $info['audio']['bitrate_mode'] = 'vbr';
+ $info['audio']['lossless'] = true;
- $ThisFileInfo['monkeys_audio']['raw'] = array();
- $thisfile_monkeysaudio = &$ThisFileInfo['monkeys_audio'];
+ $info['monkeys_audio']['raw'] = array();
+ $thisfile_monkeysaudio = &$info['monkeys_audio'];
$thisfile_monkeysaudio_raw = &$thisfile_monkeysaudio['raw'];
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $MACheaderData = fread($fd, 74);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $MACheaderData = fread($this->getid3->fp, 74);
$thisfile_monkeysaudio_raw['magic'] = substr($MACheaderData, 0, 4);
- if ($thisfile_monkeysaudio_raw['magic'] != 'MAC ') {
- $ThisFileInfo['error'][] = 'Expecting "MAC" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$thisfile_monkeysaudio_raw['magic'].'"';
- unset($ThisFileInfo['fileformat']);
+ $magic = 'MAC ';
+ if ($thisfile_monkeysaudio_raw['magic'] != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($thisfile_monkeysaudio_raw['magic']).'"';
+ unset($info['fileformat']);
return false;
}
$thisfile_monkeysaudio_raw['nVersion'] = getid3_lib::LittleEndian2Int(substr($MACheaderData, 4, 2)); // appears to be uint32 in 3.98+
@@ -105,13 +108,13 @@ class getid3_monkey
}
$thisfile_monkeysaudio['bits_per_sample'] = ($thisfile_monkeysaudio['flags']['24-bit'] ? 24 : ($thisfile_monkeysaudio['flags']['8-bit'] ? 8 : 16));
$thisfile_monkeysaudio['channels'] = $thisfile_monkeysaudio_raw['nChannels'];
- $ThisFileInfo['audio']['channels'] = $thisfile_monkeysaudio['channels'];
+ $info['audio']['channels'] = $thisfile_monkeysaudio['channels'];
$thisfile_monkeysaudio['sample_rate'] = $thisfile_monkeysaudio_raw['nSampleRate'];
if ($thisfile_monkeysaudio['sample_rate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt MAC file: frequency == zero';
+ $info['error'][] = 'Corrupt MAC file: frequency == zero';
return false;
}
- $ThisFileInfo['audio']['sample_rate'] = $thisfile_monkeysaudio['sample_rate'];
+ $info['audio']['sample_rate'] = $thisfile_monkeysaudio['sample_rate'];
if ($thisfile_monkeysaudio['flags']['peak_level']) {
$thisfile_monkeysaudio['peak_level'] = $thisfile_monkeysaudio_raw['nPeakLevel'];
$thisfile_monkeysaudio['peak_ratio'] = $thisfile_monkeysaudio['peak_level'] / pow(2, $thisfile_monkeysaudio['bits_per_sample'] - 1);
@@ -123,52 +126,52 @@ class getid3_monkey
}
$thisfile_monkeysaudio['playtime'] = $thisfile_monkeysaudio['samples'] / $thisfile_monkeysaudio['sample_rate'];
if ($thisfile_monkeysaudio['playtime'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt MAC file: playtime == zero';
+ $info['error'][] = 'Corrupt MAC file: playtime == zero';
return false;
}
- $ThisFileInfo['playtime_seconds'] = $thisfile_monkeysaudio['playtime'];
- $thisfile_monkeysaudio['compressed_size'] = $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'];
+ $info['playtime_seconds'] = $thisfile_monkeysaudio['playtime'];
+ $thisfile_monkeysaudio['compressed_size'] = $info['avdataend'] - $info['avdataoffset'];
$thisfile_monkeysaudio['uncompressed_size'] = $thisfile_monkeysaudio['samples'] * $thisfile_monkeysaudio['channels'] * ($thisfile_monkeysaudio['bits_per_sample'] / 8);
if ($thisfile_monkeysaudio['uncompressed_size'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt MAC file: uncompressed_size == zero';
+ $info['error'][] = 'Corrupt MAC file: uncompressed_size == zero';
return false;
}
$thisfile_monkeysaudio['compression_ratio'] = $thisfile_monkeysaudio['compressed_size'] / ($thisfile_monkeysaudio['uncompressed_size'] + $thisfile_monkeysaudio_raw['nHeaderDataBytes']);
$thisfile_monkeysaudio['bitrate'] = (($thisfile_monkeysaudio['samples'] * $thisfile_monkeysaudio['channels'] * $thisfile_monkeysaudio['bits_per_sample']) / $thisfile_monkeysaudio['playtime']) * $thisfile_monkeysaudio['compression_ratio'];
- $ThisFileInfo['audio']['bitrate'] = $thisfile_monkeysaudio['bitrate'];
+ $info['audio']['bitrate'] = $thisfile_monkeysaudio['bitrate'];
// add size of MAC header to avdataoffset
if ($thisfile_monkeysaudio_raw['nVersion'] >= 3980) {
- $ThisFileInfo['avdataoffset'] += $thisfile_monkeysaudio_raw['nDescriptorBytes'];
- $ThisFileInfo['avdataoffset'] += $thisfile_monkeysaudio_raw['nHeaderBytes'];
- $ThisFileInfo['avdataoffset'] += $thisfile_monkeysaudio_raw['nSeekTableBytes'];
- $ThisFileInfo['avdataoffset'] += $thisfile_monkeysaudio_raw['nHeaderDataBytes'];
+ $info['avdataoffset'] += $thisfile_monkeysaudio_raw['nDescriptorBytes'];
+ $info['avdataoffset'] += $thisfile_monkeysaudio_raw['nHeaderBytes'];
+ $info['avdataoffset'] += $thisfile_monkeysaudio_raw['nSeekTableBytes'];
+ $info['avdataoffset'] += $thisfile_monkeysaudio_raw['nHeaderDataBytes'];
- $ThisFileInfo['avdataend'] -= $thisfile_monkeysaudio_raw['nTerminatingDataBytes'];
+ $info['avdataend'] -= $thisfile_monkeysaudio_raw['nTerminatingDataBytes'];
} else {
- $ThisFileInfo['avdataoffset'] += $offset;
+ $info['avdataoffset'] += $offset;
}
if ($thisfile_monkeysaudio_raw['nVersion'] >= 3980) {
if ($thisfile_monkeysaudio_raw['cFileMD5'] === str_repeat("\x00", 16)) {
- //$ThisFileInfo['warning'][] = 'cFileMD5 is null';
+ //$info['warning'][] = 'cFileMD5 is null';
} else {
- $ThisFileInfo['md5_data_source'] = '';
+ $info['md5_data_source'] = '';
$md5 = $thisfile_monkeysaudio_raw['cFileMD5'];
for ($i = 0; $i < strlen($md5); $i++) {
- $ThisFileInfo['md5_data_source'] .= str_pad(dechex(ord($md5{$i})), 2, '00', STR_PAD_LEFT);
+ $info['md5_data_source'] .= str_pad(dechex(ord($md5{$i})), 2, '00', STR_PAD_LEFT);
}
- if (!preg_match('/^[0-9a-f]{32}$/', $ThisFileInfo['md5_data_source'])) {
- unset($ThisFileInfo['md5_data_source']);
+ if (!preg_match('/^[0-9a-f]{32}$/', $info['md5_data_source'])) {
+ unset($info['md5_data_source']);
}
}
}
- $ThisFileInfo['audio']['bits_per_sample'] = $thisfile_monkeysaudio['bits_per_sample'];
- $ThisFileInfo['audio']['encoder'] = 'MAC v'.number_format($thisfile_monkeysaudio['version'], 2);
- $ThisFileInfo['audio']['encoder_options'] = ucfirst($thisfile_monkeysaudio['compression']).' compression';
+ $info['audio']['bits_per_sample'] = $thisfile_monkeysaudio['bits_per_sample'];
+ $info['audio']['encoder'] = 'MAC v'.number_format($thisfile_monkeysaudio['version'], 2);
+ $info['audio']['encoder_options'] = ucfirst($thisfile_monkeysaudio['compression']).' compression';
return true;
}
diff --git a/apps/media/getID3/getid3/module.audio.mp3.php b/3rdparty/getid3/module.audio.mp3.php
index ac9a27380e4..909646e1a1e 100644
--- a/apps/media/getID3/getid3/module.audio.mp3.php
+++ b/3rdparty/getid3/module.audio.mp3.php
@@ -21,65 +21,70 @@
define('GETID3_MP3_VALID_CHECK_FRAMES', 35);
-class getid3_mp3
+class getid3_mp3 extends getid3_handler
{
var $allow_bruteforce = false; // forces getID3() to scan the file byte-by-byte and log all the valid audio frame headers - extremely slow, unrecommended, but may provide data from otherwise-unusuable files
- function getid3_mp3(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- if (!$this->getOnlyMPEGaudioInfo($fd, $ThisFileInfo, $ThisFileInfo['avdataoffset'])) {
+ $initialOffset = $info['avdataoffset'];
+
+ if (!$this->getOnlyMPEGaudioInfo($info['avdataoffset'])) {
if ($this->allow_bruteforce) {
- $ThisFileInfo['error'][] = 'Rescanning file in BruteForce mode';
- $this->getOnlyMPEGaudioInfoBruteForce($fd, $ThisFileInfo);
+ $info['error'][] = 'Rescanning file in BruteForce mode';
+ $this->getOnlyMPEGaudioInfoBruteForce($this->getid3->fp, $info);
}
}
- if (isset($ThisFileInfo['mpeg']['audio']['bitrate_mode'])) {
- $ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
+ if (isset($info['mpeg']['audio']['bitrate_mode'])) {
+ $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
}
- if (((isset($ThisFileInfo['id3v2']['headerlength']) && ($ThisFileInfo['avdataoffset'] > $ThisFileInfo['id3v2']['headerlength'])) || (!isset($ThisFileInfo['id3v2']) && ($ThisFileInfo['avdataoffset'] > 0)))) {
+ if (((isset($info['id3v2']['headerlength']) && ($info['avdataoffset'] > $info['id3v2']['headerlength'])) || (!isset($info['id3v2']) && ($info['avdataoffset'] > 0) && ($info['avdataoffset'] != $initialOffset)))) {
$synchoffsetwarning = 'Unknown data before synch ';
- if (isset($ThisFileInfo['id3v2']['headerlength'])) {
- $synchoffsetwarning .= '(ID3v2 header ends at '.$ThisFileInfo['id3v2']['headerlength'].', then '.($ThisFileInfo['avdataoffset'] - $ThisFileInfo['id3v2']['headerlength']).' bytes garbage, ';
+ if (isset($info['id3v2']['headerlength'])) {
+ $synchoffsetwarning .= '(ID3v2 header ends at '.$info['id3v2']['headerlength'].', then '.($info['avdataoffset'] - $info['id3v2']['headerlength']).' bytes garbage, ';
+ } elseif ($initialOffset > 0) {
+ $synchoffsetwarning .= '(should be at '.$initialOffset.', ';
} else {
$synchoffsetwarning .= '(should be at beginning of file, ';
}
- $synchoffsetwarning .= 'synch detected at '.$ThisFileInfo['avdataoffset'].')';
- if (@$ThisFileInfo['audio']['bitrate_mode'] == 'cbr') {
+ $synchoffsetwarning .= 'synch detected at '.$info['avdataoffset'].')';
+ if (isset($info['audio']['bitrate_mode']) && ($info['audio']['bitrate_mode'] == 'cbr')) {
- if (!empty($ThisFileInfo['id3v2']['headerlength']) && (($ThisFileInfo['avdataoffset'] - $ThisFileInfo['id3v2']['headerlength']) == $ThisFileInfo['mpeg']['audio']['framelength'])) {
+ if (!empty($info['id3v2']['headerlength']) && (($info['avdataoffset'] - $info['id3v2']['headerlength']) == $info['mpeg']['audio']['framelength'])) {
$synchoffsetwarning .= '. This is a known problem with some versions of LAME (3.90-3.92) DLL in CBR mode.';
- $ThisFileInfo['audio']['codec'] = 'LAME';
+ $info['audio']['codec'] = 'LAME';
$CurrentDataLAMEversionString = 'LAME3.';
- } elseif (empty($ThisFileInfo['id3v2']['headerlength']) && ($ThisFileInfo['avdataoffset'] == $ThisFileInfo['mpeg']['audio']['framelength'])) {
+ } elseif (empty($info['id3v2']['headerlength']) && ($info['avdataoffset'] == $info['mpeg']['audio']['framelength'])) {
$synchoffsetwarning .= '. This is a known problem with some versions of LAME (3.90 - 3.92) DLL in CBR mode.';
- $ThisFileInfo['audio']['codec'] = 'LAME';
+ $info['audio']['codec'] = 'LAME';
$CurrentDataLAMEversionString = 'LAME3.';
}
}
- $ThisFileInfo['warning'][] = $synchoffsetwarning;
+ $info['warning'][] = $synchoffsetwarning;
}
- if (isset($ThisFileInfo['mpeg']['audio']['LAME'])) {
- $ThisFileInfo['audio']['codec'] = 'LAME';
- if (!empty($ThisFileInfo['mpeg']['audio']['LAME']['long_version'])) {
- $ThisFileInfo['audio']['encoder'] = rtrim($ThisFileInfo['mpeg']['audio']['LAME']['long_version'], "\x00");
- } elseif (!empty($ThisFileInfo['mpeg']['audio']['LAME']['short_version'])) {
- $ThisFileInfo['audio']['encoder'] = rtrim($ThisFileInfo['mpeg']['audio']['LAME']['short_version'], "\x00");
+ if (isset($info['mpeg']['audio']['LAME'])) {
+ $info['audio']['codec'] = 'LAME';
+ if (!empty($info['mpeg']['audio']['LAME']['long_version'])) {
+ $info['audio']['encoder'] = rtrim($info['mpeg']['audio']['LAME']['long_version'], "\x00");
+ } elseif (!empty($info['mpeg']['audio']['LAME']['short_version'])) {
+ $info['audio']['encoder'] = rtrim($info['mpeg']['audio']['LAME']['short_version'], "\x00");
}
}
- $CurrentDataLAMEversionString = (!empty($CurrentDataLAMEversionString) ? $CurrentDataLAMEversionString : @$ThisFileInfo['audio']['encoder']);
+ $CurrentDataLAMEversionString = (!empty($CurrentDataLAMEversionString) ? $CurrentDataLAMEversionString : (isset($info['audio']['encoder']) ? $info['audio']['encoder'] : ''));
if (!empty($CurrentDataLAMEversionString) && (substr($CurrentDataLAMEversionString, 0, 6) == 'LAME3.') && !preg_match('[0-9\)]', substr($CurrentDataLAMEversionString, -1))) {
// a version number of LAME that does not end with a number like "LAME3.92"
// or with a closing parenthesis like "LAME3.88 (alpha)"
@@ -89,9 +94,9 @@ class getid3_mp3
$PossiblyLongerLAMEversion_FrameLength = 1441;
// Not sure what version of LAME this is - look in padding of last frame for longer version string
- $PossibleLAMEversionStringOffset = $ThisFileInfo['avdataend'] - $PossiblyLongerLAMEversion_FrameLength;
- fseek($fd, $PossibleLAMEversionStringOffset);
- $PossiblyLongerLAMEversion_Data = fread($fd, $PossiblyLongerLAMEversion_FrameLength);
+ $PossibleLAMEversionStringOffset = $info['avdataend'] - $PossiblyLongerLAMEversion_FrameLength;
+ fseek($this->getid3->fp, $PossibleLAMEversionStringOffset);
+ $PossiblyLongerLAMEversion_Data = fread($this->getid3->fp, $PossiblyLongerLAMEversion_FrameLength);
switch (substr($CurrentDataLAMEversionString, -1)) {
case 'a':
case 'b':
@@ -103,62 +108,63 @@ class getid3_mp3
if (($PossiblyLongerLAMEversion_String = strstr($PossiblyLongerLAMEversion_Data, $CurrentDataLAMEversionString)) !== false) {
if (substr($PossiblyLongerLAMEversion_String, 0, strlen($CurrentDataLAMEversionString)) == $CurrentDataLAMEversionString) {
$PossiblyLongerLAMEversion_NewString = substr($PossiblyLongerLAMEversion_String, 0, strspn($PossiblyLongerLAMEversion_String, 'LAME0123456789., (abcdefghijklmnopqrstuvwxyzJFSOND)')); //"LAME3.90.3" "LAME3.87 (beta 1, Sep 27 2000)" "LAME3.88 (beta)"
- if (strlen($PossiblyLongerLAMEversion_NewString) > strlen(@$ThisFileInfo['audio']['encoder'])) {
- $ThisFileInfo['audio']['encoder'] = $PossiblyLongerLAMEversion_NewString;
+ if (empty($info['audio']['encoder']) || (strlen($PossiblyLongerLAMEversion_NewString) > strlen($info['audio']['encoder']))) {
+ $info['audio']['encoder'] = $PossiblyLongerLAMEversion_NewString;
}
}
}
}
- if (!empty($ThisFileInfo['audio']['encoder'])) {
- $ThisFileInfo['audio']['encoder'] = rtrim($ThisFileInfo['audio']['encoder'], "\x00 ");
+ if (!empty($info['audio']['encoder'])) {
+ $info['audio']['encoder'] = rtrim($info['audio']['encoder'], "\x00 ");
}
- switch (@$ThisFileInfo['mpeg']['audio']['layer']) {
+ switch (isset($info['mpeg']['audio']['layer']) ? $info['mpeg']['audio']['layer'] : '') {
case 1:
case 2:
- $ThisFileInfo['audio']['dataformat'] = 'mp'.$ThisFileInfo['mpeg']['audio']['layer'];
+ $info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer'];
break;
}
- if (@$ThisFileInfo['fileformat'] == 'mp3') {
- switch ($ThisFileInfo['audio']['dataformat']) {
+ if (isset($info['fileformat']) && ($info['fileformat'] == 'mp3')) {
+ switch ($info['audio']['dataformat']) {
case 'mp1':
case 'mp2':
case 'mp3':
- $ThisFileInfo['fileformat'] = $ThisFileInfo['audio']['dataformat'];
+ $info['fileformat'] = $info['audio']['dataformat'];
break;
default:
- $ThisFileInfo['warning'][] = 'Expecting [audio][dataformat] to be mp1/mp2/mp3 when fileformat == mp3, [audio][dataformat] actually "'.$ThisFileInfo['audio']['dataformat'].'"';
+ $info['warning'][] = 'Expecting [audio][dataformat] to be mp1/mp2/mp3 when fileformat == mp3, [audio][dataformat] actually "'.$info['audio']['dataformat'].'"';
break;
}
}
- if (empty($ThisFileInfo['fileformat'])) {
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['audio']['bitrate_mode']);
- unset($ThisFileInfo['avdataoffset']);
- unset($ThisFileInfo['avdataend']);
+ if (empty($info['fileformat'])) {
+ unset($info['fileformat']);
+ unset($info['audio']['bitrate_mode']);
+ unset($info['avdataoffset']);
+ unset($info['avdataend']);
return false;
}
- $ThisFileInfo['mime_type'] = 'audio/mpeg';
- $ThisFileInfo['audio']['lossless'] = false;
+ $info['mime_type'] = 'audio/mpeg';
+ $info['audio']['lossless'] = false;
// Calculate playtime
- if (!isset($ThisFileInfo['playtime_seconds']) && isset($ThisFileInfo['audio']['bitrate']) && ($ThisFileInfo['audio']['bitrate'] > 0)) {
- $ThisFileInfo['playtime_seconds'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['audio']['bitrate'];
+ if (!isset($info['playtime_seconds']) && isset($info['audio']['bitrate']) && ($info['audio']['bitrate'] > 0)) {
+ $info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['audio']['bitrate'];
}
- $ThisFileInfo['audio']['encoder_options'] = $this->GuessEncoderOptions($ThisFileInfo);
+ $info['audio']['encoder_options'] = $this->GuessEncoderOptions();
return true;
}
- function GuessEncoderOptions(&$ThisFileInfo) {
+ function GuessEncoderOptions() {
// shortcuts
- if (!empty($ThisFileInfo['mpeg']['audio'])) {
- $thisfile_mpeg_audio = &$ThisFileInfo['mpeg']['audio'];
+ $info = &$this->getid3->info;
+ if (!empty($info['mpeg']['audio'])) {
+ $thisfile_mpeg_audio = &$info['mpeg']['audio'];
if (!empty($thisfile_mpeg_audio['LAME'])) {
$thisfile_mpeg_audio_lame = &$thisfile_mpeg_audio['LAME'];
}
@@ -167,7 +173,7 @@ class getid3_mp3
$encoder_options = '';
static $NamedPresetBitrates = array(16, 24, 40, 56, 112, 128, 160, 192, 256);
- if ((@$thisfile_mpeg_audio['VBR_method'] == 'Fraunhofer') && !empty($thisfile_mpeg_audio['VBR_quality'])) {
+ if (isset($thisfile_mpeg_audio['VBR_method']) && ($thisfile_mpeg_audio['VBR_method'] == 'Fraunhofer') && !empty($thisfile_mpeg_audio['VBR_quality'])) {
$encoder_options = 'VBR q'.$thisfile_mpeg_audio['VBR_quality'];
@@ -242,7 +248,7 @@ class getid3_mp3
$encoder_options = $KnownEncoderValues['**'][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']];
- } elseif ($ThisFileInfo['audio']['bitrate_mode'] == 'vbr') {
+ } elseif ($info['audio']['bitrate_mode'] == 'vbr') {
// http://gabriel.mp3-tech.org/mp3infotag.html
// int Quality = (100 - 10 * gfp->VBR_q - gfp->quality)h
@@ -252,13 +258,13 @@ class getid3_mp3
$LAME_q_value = 100 - $thisfile_mpeg_audio_lame['vbr_quality'] - ($LAME_V_value * 10);
$encoder_options = '-V'.$LAME_V_value.' -q'.$LAME_q_value;
- } elseif ($ThisFileInfo['audio']['bitrate_mode'] == 'cbr') {
+ } elseif ($info['audio']['bitrate_mode'] == 'cbr') {
- $encoder_options = strtoupper($ThisFileInfo['audio']['bitrate_mode']).ceil($ThisFileInfo['audio']['bitrate'] / 1000);
+ $encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000);
} else {
- $encoder_options = strtoupper($ThisFileInfo['audio']['bitrate_mode']);
+ $encoder_options = strtoupper($info['audio']['bitrate_mode']);
}
@@ -266,12 +272,12 @@ class getid3_mp3
$encoder_options = 'ABR'.$thisfile_mpeg_audio_lame['bitrate_abr'];
- } elseif (!empty($ThisFileInfo['audio']['bitrate'])) {
+ } elseif (!empty($info['audio']['bitrate'])) {
- if ($ThisFileInfo['audio']['bitrate_mode'] == 'cbr') {
- $encoder_options = strtoupper($ThisFileInfo['audio']['bitrate_mode']).ceil($ThisFileInfo['audio']['bitrate'] / 1000);
+ if ($info['audio']['bitrate_mode'] == 'cbr') {
+ $encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000);
} else {
- $encoder_options = strtoupper($ThisFileInfo['audio']['bitrate_mode']);
+ $encoder_options = strtoupper($info['audio']['bitrate_mode']);
}
}
@@ -279,7 +285,7 @@ class getid3_mp3
$encoder_options .= ' -b'.$thisfile_mpeg_audio_lame['bitrate_min'];
}
- if (@$thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev'] || @$thisfile_mpeg_audio_lame['encoding_flags']['nogap_next']) {
+ if (!empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev']) || !empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_next'])) {
$encoder_options .= ' --nogap';
}
@@ -389,17 +395,16 @@ class getid3_mp3
}
}
}
- if (empty($encoder_options) && !empty($ThisFileInfo['audio']['bitrate']) && !empty($ThisFileInfo['audio']['bitrate_mode'])) {
- //$encoder_options = strtoupper($ThisFileInfo['audio']['bitrate_mode']).ceil($ThisFileInfo['audio']['bitrate'] / 1000);
- $encoder_options = strtoupper($ThisFileInfo['audio']['bitrate_mode']);
+ if (empty($encoder_options) && !empty($info['audio']['bitrate']) && !empty($info['audio']['bitrate_mode'])) {
+ //$encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000);
+ $encoder_options = strtoupper($info['audio']['bitrate_mode']);
}
return $encoder_options;
}
- function decodeMPEGaudioHeader($fd, $offset, &$ThisFileInfo, $recursivesearch=true, $ScanAsCBR=false, $FastMPEGheaderScan=false) {
-
+ function decodeMPEGaudioHeader($offset, &$info, $recursivesearch=true, $ScanAsCBR=false, $FastMPEGheaderScan=false) {
static $MPEGaudioVersionLookup;
static $MPEGaudioLayerLookup;
static $MPEGaudioBitrateLookup;
@@ -417,13 +422,12 @@ class getid3_mp3
$MPEGaudioEmphasisLookup = getid3_mp3::MPEGaudioEmphasisArray();
}
- if ($offset >= $ThisFileInfo['avdataend']) {
- $ThisFileInfo['error'][] = 'end of file encounter looking for MPEG synch';
+ if (fseek($this->getid3->fp, $offset, SEEK_SET) != 0) {
+ $info['error'][] = 'decodeMPEGaudioHeader() failed to seek to next offset at '.$offset;
return false;
}
- fseek($fd, $offset, SEEK_SET);
- //$headerstring = fread($fd, 1441); // worst-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame
- $headerstring = fread($fd, 226); // LAME header at offset 36 + 190 bytes of Xing/LAME data
+ //$headerstring = fread($this->getid3->fp, 1441); // worst-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame
+ $headerstring = fread($this->getid3->fp, 226); // LAME header at offset 36 + 190 bytes of Xing/LAME data
// MP3 audio frame structure:
// $aa $aa $aa $aa [$bb $bb] $cc...
@@ -442,29 +446,26 @@ class getid3_mp3
}
static $MPEGaudioHeaderValidCache = array();
-
- // Not in cache
- if (!isset($MPEGaudioHeaderValidCache[$head4])) {
+ if (!isset($MPEGaudioHeaderValidCache[$head4])) { // Not in cache
//$MPEGaudioHeaderValidCache[$head4] = getid3_mp3::MPEGaudioHeaderValid($MPEGheaderRawArray, false, true); // allow badly-formatted freeformat (from LAME 3.90 - 3.93.1)
$MPEGaudioHeaderValidCache[$head4] = getid3_mp3::MPEGaudioHeaderValid($MPEGheaderRawArray, false, false);
}
// shortcut
- if (!isset($ThisFileInfo['mpeg']['audio'])) {
- $ThisFileInfo['mpeg']['audio'] = array();
+ if (!isset($info['mpeg']['audio'])) {
+ $info['mpeg']['audio'] = array();
}
- $thisfile_mpeg_audio = &$ThisFileInfo['mpeg']['audio'];
+ $thisfile_mpeg_audio = &$info['mpeg']['audio'];
if ($MPEGaudioHeaderValidCache[$head4]) {
$thisfile_mpeg_audio['raw'] = $MPEGheaderRawArray;
} else {
- $ThisFileInfo['error'][] = 'Invalid MPEG audio header at offset '.$offset;
+ $info['error'][] = 'Invalid MPEG audio header ('.getid3_lib::PrintHexBytes($head4).') at offset '.$offset;
return false;
}
if (!$FastMPEGheaderScan) {
-
$thisfile_mpeg_audio['version'] = $MPEGaudioVersionLookup[$thisfile_mpeg_audio['raw']['version']];
$thisfile_mpeg_audio['layer'] = $MPEGaudioLayerLookup[$thisfile_mpeg_audio['raw']['layer']];
@@ -478,24 +479,23 @@ class getid3_mp3
$thisfile_mpeg_audio['original'] = (bool) $thisfile_mpeg_audio['raw']['original'];
$thisfile_mpeg_audio['emphasis'] = $MPEGaudioEmphasisLookup[$thisfile_mpeg_audio['raw']['emphasis']];
- $ThisFileInfo['audio']['channels'] = $thisfile_mpeg_audio['channels'];
- $ThisFileInfo['audio']['sample_rate'] = $thisfile_mpeg_audio['sample_rate'];
+ $info['audio']['channels'] = $thisfile_mpeg_audio['channels'];
+ $info['audio']['sample_rate'] = $thisfile_mpeg_audio['sample_rate'];
if ($thisfile_mpeg_audio['protection']) {
$thisfile_mpeg_audio['crc'] = getid3_lib::BigEndian2Int(substr($headerstring, 4, 2));
}
-
}
if ($thisfile_mpeg_audio['raw']['bitrate'] == 15) {
// http://www.hydrogenaudio.org/?act=ST&f=16&t=9682&st=0
- $ThisFileInfo['warning'][] = 'Invalid bitrate index (15), this is a known bug in free-format MP3s encoded by LAME v3.90 - 3.93.1';
+ $info['warning'][] = 'Invalid bitrate index (15), this is a known bug in free-format MP3s encoded by LAME v3.90 - 3.93.1';
$thisfile_mpeg_audio['raw']['bitrate'] = 0;
}
$thisfile_mpeg_audio['padding'] = (bool) $thisfile_mpeg_audio['raw']['padding'];
$thisfile_mpeg_audio['bitrate'] = $MPEGaudioBitrateLookup[$thisfile_mpeg_audio['version']][$thisfile_mpeg_audio['layer']][$thisfile_mpeg_audio['raw']['bitrate']];
- if (($thisfile_mpeg_audio['bitrate'] == 'free') && ($offset == $ThisFileInfo['avdataoffset'])) {
+ if (($thisfile_mpeg_audio['bitrate'] == 'free') && ($offset == $info['avdataoffset'])) {
// only skip multiple frame check if free-format bitstream found at beginning of file
// otherwise is quite possibly simply corrupted data
$recursivesearch = false;
@@ -504,14 +504,14 @@ class getid3_mp3
// For Layer 2 there are some combinations of bitrate and mode which are not allowed.
if (!$FastMPEGheaderScan && ($thisfile_mpeg_audio['layer'] == '2')) {
- $ThisFileInfo['audio']['dataformat'] = 'mp2';
+ $info['audio']['dataformat'] = 'mp2';
switch ($thisfile_mpeg_audio['channelmode']) {
case 'mono':
if (($thisfile_mpeg_audio['bitrate'] == 'free') || ($thisfile_mpeg_audio['bitrate'] <= 192000)) {
// these are ok
} else {
- $ThisFileInfo['error'][] = $thisfile_mpeg_audio['bitrate'].'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio['channelmode'].'.';
+ $info['error'][] = $thisfile_mpeg_audio['bitrate'].'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio['channelmode'].'.';
return false;
}
break;
@@ -522,7 +522,7 @@ class getid3_mp3
if (($thisfile_mpeg_audio['bitrate'] == 'free') || ($thisfile_mpeg_audio['bitrate'] == 64000) || ($thisfile_mpeg_audio['bitrate'] >= 96000)) {
// these are ok
} else {
- $ThisFileInfo['error'][] = intval(round($thisfile_mpeg_audio['bitrate'] / 1000)).'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio['channelmode'].'.';
+ $info['error'][] = intval(round($thisfile_mpeg_audio['bitrate'] / 1000)).'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio['channelmode'].'.';
return false;
}
break;
@@ -532,19 +532,19 @@ class getid3_mp3
}
- if ($ThisFileInfo['audio']['sample_rate'] > 0) {
- $thisfile_mpeg_audio['framelength'] = getid3_mp3::MPEGaudioFrameLength($thisfile_mpeg_audio['bitrate'], $thisfile_mpeg_audio['version'], $thisfile_mpeg_audio['layer'], (int) $thisfile_mpeg_audio['padding'], $ThisFileInfo['audio']['sample_rate']);
+ if ($info['audio']['sample_rate'] > 0) {
+ $thisfile_mpeg_audio['framelength'] = getid3_mp3::MPEGaudioFrameLength($thisfile_mpeg_audio['bitrate'], $thisfile_mpeg_audio['version'], $thisfile_mpeg_audio['layer'], (int) $thisfile_mpeg_audio['padding'], $info['audio']['sample_rate']);
}
$nextframetestoffset = $offset + 1;
if ($thisfile_mpeg_audio['bitrate'] != 'free') {
- $ThisFileInfo['audio']['bitrate'] = $thisfile_mpeg_audio['bitrate'];
+ $info['audio']['bitrate'] = $thisfile_mpeg_audio['bitrate'];
if (isset($thisfile_mpeg_audio['framelength'])) {
$nextframetestoffset = $offset + $thisfile_mpeg_audio['framelength'];
} else {
- $ThisFileInfo['error'][] = 'Frame at offset('.$offset.') is has an invalid frame length.';
+ $info['error'][] = 'Frame at offset('.$offset.') is has an invalid frame length.';
return false;
}
@@ -561,7 +561,7 @@ class getid3_mp3
$thisfile_mpeg_audio['bitrate_mode'] = 'vbr';
$thisfile_mpeg_audio['VBR_method'] = 'Fraunhofer';
- $ThisFileInfo['audio']['codec'] = 'Fraunhofer';
+ $info['audio']['codec'] = 'Fraunhofer';
$SideInfoData = substr($headerstring, 4 + 2, 32);
@@ -653,12 +653,12 @@ class getid3_mp3
if ($thisfile_mpeg_audio['layer'] == '1') {
// BitRate = (((FrameLengthInBytes / 4) - Padding) * SampleRate) / 12
- //$ThisFileInfo['audio']['bitrate'] = ((($framelengthfloat / 4) - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 12;
- $ThisFileInfo['audio']['bitrate'] = ($framelengthfloat / 4) * $thisfile_mpeg_audio['sample_rate'] * (2 / $ThisFileInfo['audio']['channels']) / 12;
+ //$info['audio']['bitrate'] = ((($framelengthfloat / 4) - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 12;
+ $info['audio']['bitrate'] = ($framelengthfloat / 4) * $thisfile_mpeg_audio['sample_rate'] * (2 / $info['audio']['channels']) / 12;
} else {
// Bitrate = ((FrameLengthInBytes - Padding) * SampleRate) / 144
- //$ThisFileInfo['audio']['bitrate'] = (($framelengthfloat - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 144;
- $ThisFileInfo['audio']['bitrate'] = $framelengthfloat * $thisfile_mpeg_audio['sample_rate'] * (2 / $ThisFileInfo['audio']['channels']) / 144;
+ //$info['audio']['bitrate'] = (($framelengthfloat - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 144;
+ $info['audio']['bitrate'] = $framelengthfloat * $thisfile_mpeg_audio['sample_rate'] * (2 / $info['audio']['channels']) / 144;
}
$thisfile_mpeg_audio['framelength'] = floor($framelengthfloat);
}
@@ -759,10 +759,10 @@ class getid3_mp3
$thisfile_mpeg_audio_lame_RGAD_track['gain_db'] = getid3_lib::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_track['raw']['gain_adjust'], $thisfile_mpeg_audio_lame_RGAD_track['raw']['sign_bit']);
if (!empty($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'])) {
- $ThisFileInfo['replay_gain']['track']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude'];
+ $info['replay_gain']['track']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude'];
}
- $ThisFileInfo['replay_gain']['track']['originator'] = $thisfile_mpeg_audio_lame_RGAD_track['originator'];
- $ThisFileInfo['replay_gain']['track']['adjustment'] = $thisfile_mpeg_audio_lame_RGAD_track['gain_db'];
+ $info['replay_gain']['track']['originator'] = $thisfile_mpeg_audio_lame_RGAD_track['originator'];
+ $info['replay_gain']['track']['adjustment'] = $thisfile_mpeg_audio_lame_RGAD_track['gain_db'];
} else {
unset($thisfile_mpeg_audio_lame_RGAD['track']);
}
@@ -777,10 +777,10 @@ class getid3_mp3
$thisfile_mpeg_audio_lame_RGAD_album['gain_db'] = getid3_lib::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_album['raw']['gain_adjust'], $thisfile_mpeg_audio_lame_RGAD_album['raw']['sign_bit']);
if (!empty($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'])) {
- $ThisFileInfo['replay_gain']['album']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude'];
+ $info['replay_gain']['album']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude'];
}
- $ThisFileInfo['replay_gain']['album']['originator'] = $thisfile_mpeg_audio_lame_RGAD_album['originator'];
- $ThisFileInfo['replay_gain']['album']['adjustment'] = $thisfile_mpeg_audio_lame_RGAD_album['gain_db'];
+ $info['replay_gain']['album']['originator'] = $thisfile_mpeg_audio_lame_RGAD_album['originator'];
+ $info['replay_gain']['album']['adjustment'] = $thisfile_mpeg_audio_lame_RGAD_album['gain_db'];
} else {
unset($thisfile_mpeg_audio_lame_RGAD['album']);
}
@@ -836,7 +836,7 @@ class getid3_mp3
$thisfile_mpeg_audio_lame['preset_used_id'] = ($PresetSurroundBytes & 0x07FF);
$thisfile_mpeg_audio_lame['preset_used'] = getid3_mp3::LAMEpresetUsedLookup($thisfile_mpeg_audio_lame);
if (!empty($thisfile_mpeg_audio_lame['preset_used_id']) && empty($thisfile_mpeg_audio_lame['preset_used'])) {
- $ThisFileInfo['warning'][] = 'Unknown LAME preset used ('.$thisfile_mpeg_audio_lame['preset_used_id'].') - please report to info@getid3.org';
+ $info['warning'][] = 'Unknown LAME preset used ('.$thisfile_mpeg_audio_lame['preset_used_id'].') - please report to info@getid3.org';
}
if (($thisfile_mpeg_audio_lame['short_version'] == 'LAME3.90.') && !empty($thisfile_mpeg_audio_lame['preset_used_id'])) {
// this may change if 3.90.4 ever comes out
@@ -859,7 +859,7 @@ class getid3_mp3
$thisfile_mpeg_audio['bitrate_mode'] = 'cbr';
$thisfile_mpeg_audio['bitrate'] = getid3_mp3::ClosestStandardMP3Bitrate($thisfile_mpeg_audio['bitrate']);
- $ThisFileInfo['audio']['bitrate'] = $thisfile_mpeg_audio['bitrate'];
+ $info['audio']['bitrate'] = $thisfile_mpeg_audio['bitrate'];
//if (empty($thisfile_mpeg_audio['bitrate']) || (!empty($thisfile_mpeg_audio_lame['bitrate_min']) && ($thisfile_mpeg_audio_lame['bitrate_min'] != 255))) {
// $thisfile_mpeg_audio['bitrate'] = $thisfile_mpeg_audio_lame['bitrate_min'];
//}
@@ -875,12 +875,12 @@ class getid3_mp3
$thisfile_mpeg_audio['bitrate_mode'] = 'cbr';
if ($recursivesearch) {
$thisfile_mpeg_audio['bitrate_mode'] = 'vbr';
- if (getid3_mp3::RecursiveFrameScanning($fd, $ThisFileInfo, $offset, $nextframetestoffset, true)) {
+ if ($this->RecursiveFrameScanning($offset, $nextframetestoffset, true)) {
$recursivesearch = false;
$thisfile_mpeg_audio['bitrate_mode'] = 'cbr';
}
if ($thisfile_mpeg_audio['bitrate_mode'] == 'vbr') {
- $ThisFileInfo['warning'][] = 'VBR file with no VBR header. Bitrate values calculated from actual frame bitrates.';
+ $info['warning'][] = 'VBR file with no VBR header. Bitrate values calculated from actual frame bitrates.';
}
}
@@ -888,64 +888,64 @@ class getid3_mp3
}
- if (($ExpectedNumberOfAudioBytes > 0) && ($ExpectedNumberOfAudioBytes != ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']))) {
- if ($ExpectedNumberOfAudioBytes > ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'])) {
- if (@$ThisFileInfo['fileformat'] == 'riff') {
+ if (($ExpectedNumberOfAudioBytes > 0) && ($ExpectedNumberOfAudioBytes != ($info['avdataend'] - $info['avdataoffset']))) {
+ if ($ExpectedNumberOfAudioBytes > ($info['avdataend'] - $info['avdataoffset'])) {
+ if (isset($info['fileformat']) && ($info['fileformat'] == 'riff')) {
// ignore, audio data is broken into chunks so will always be data "missing"
- } elseif (($ExpectedNumberOfAudioBytes - ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'])) == 1) {
- $ThisFileInfo['warning'][] = 'Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)';
+ } elseif (($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])) == 1) {
+ $info['warning'][] = 'Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)';
} else {
- $ThisFileInfo['warning'][] = 'Probable truncated file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, only found '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']).' (short by '.($ExpectedNumberOfAudioBytes - ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'])).' bytes)';
+ $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)';
}
} else {
- if ((($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) - $ExpectedNumberOfAudioBytes) == 1) {
- // $prenullbytefileoffset = ftell($fd);
- // fseek($fd, $ThisFileInfo['avdataend'], SEEK_SET);
- // $PossibleNullByte = fread($fd, 1);
- // fseek($fd, $prenullbytefileoffset, SEEK_SET);
+ if ((($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes) == 1) {
+ // $prenullbytefileoffset = ftell($this->getid3->fp);
+ // fseek($this->getid3->fp, $info['avdataend'], SEEK_SET);
+ // $PossibleNullByte = fread($this->getid3->fp, 1);
+ // fseek($this->getid3->fp, $prenullbytefileoffset, SEEK_SET);
// if ($PossibleNullByte === "\x00") {
- $ThisFileInfo['avdataend']--;
- // $ThisFileInfo['warning'][] = 'Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored';
+ $info['avdataend']--;
+ // $info['warning'][] = 'Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored';
// } else {
- // $ThisFileInfo['warning'][] = 'Too much data in file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, found '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']).' ('.(($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) - $ExpectedNumberOfAudioBytes).' bytes too many)';
+ // $info['warning'][] = 'Too much data in file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, found '.($info['avdataend'] - $info['avdataoffset']).' ('.(($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes).' bytes too many)';
// }
} else {
- $ThisFileInfo['warning'][] = 'Too much data in file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, found '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']).' ('.(($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) - $ExpectedNumberOfAudioBytes).' bytes too many)';
+ $info['warning'][] = 'Too much data in file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, found '.($info['avdataend'] - $info['avdataoffset']).' ('.(($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes).' bytes too many)';
}
}
}
- if (($thisfile_mpeg_audio['bitrate'] == 'free') && empty($ThisFileInfo['audio']['bitrate'])) {
- if (($offset == $ThisFileInfo['avdataoffset']) && empty($thisfile_mpeg_audio['VBR_frames'])) {
- $framebytelength = getid3_mp3::FreeFormatFrameLength($fd, $offset, $ThisFileInfo, true);
+ if (($thisfile_mpeg_audio['bitrate'] == 'free') && empty($info['audio']['bitrate'])) {
+ if (($offset == $info['avdataoffset']) && empty($thisfile_mpeg_audio['VBR_frames'])) {
+ $framebytelength = $this->FreeFormatFrameLength($offset, true);
if ($framebytelength > 0) {
$thisfile_mpeg_audio['framelength'] = $framebytelength;
if ($thisfile_mpeg_audio['layer'] == '1') {
// BitRate = (((FrameLengthInBytes / 4) - Padding) * SampleRate) / 12
- $ThisFileInfo['audio']['bitrate'] = ((($framebytelength / 4) - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 12;
+ $info['audio']['bitrate'] = ((($framebytelength / 4) - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 12;
} else {
// Bitrate = ((FrameLengthInBytes - Padding) * SampleRate) / 144
- $ThisFileInfo['audio']['bitrate'] = (($framebytelength - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 144;
+ $info['audio']['bitrate'] = (($framebytelength - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 144;
}
} else {
- $ThisFileInfo['error'][] = 'Error calculating frame length of free-format MP3 without Xing/LAME header';
+ $info['error'][] = 'Error calculating frame length of free-format MP3 without Xing/LAME header';
}
}
}
- if (@$thisfile_mpeg_audio['VBR_frames']) {
+ if (isset($thisfile_mpeg_audio['VBR_frames']) ? $thisfile_mpeg_audio['VBR_frames'] : '') {
switch ($thisfile_mpeg_audio['bitrate_mode']) {
case 'vbr':
case 'abr':
+ $bytes_per_frame = 1152;
if (($thisfile_mpeg_audio['version'] == '1') && ($thisfile_mpeg_audio['layer'] == 1)) {
- $thisfile_mpeg_audio['VBR_bitrate'] = ((@$thisfile_mpeg_audio['VBR_bytes'] / $thisfile_mpeg_audio['VBR_frames']) * 8) * ($ThisFileInfo['audio']['sample_rate'] / 384);
+ $bytes_per_frame = 384;
} elseif ((($thisfile_mpeg_audio['version'] == '2') || ($thisfile_mpeg_audio['version'] == '2.5')) && ($thisfile_mpeg_audio['layer'] == 3)) {
- $thisfile_mpeg_audio['VBR_bitrate'] = ((@$thisfile_mpeg_audio['VBR_bytes'] / $thisfile_mpeg_audio['VBR_frames']) * 8) * ($ThisFileInfo['audio']['sample_rate'] / 576);
- } else {
- $thisfile_mpeg_audio['VBR_bitrate'] = ((@$thisfile_mpeg_audio['VBR_bytes'] / $thisfile_mpeg_audio['VBR_frames']) * 8) * ($ThisFileInfo['audio']['sample_rate'] / 1152);
+ $bytes_per_frame = 576;
}
+ $thisfile_mpeg_audio['VBR_bitrate'] = (isset($thisfile_mpeg_audio['VBR_bytes']) ? (($thisfile_mpeg_audio['VBR_bytes'] / $thisfile_mpeg_audio['VBR_frames']) * 8) * ($info['audio']['sample_rate'] / $bytes_per_frame) : 0);
if ($thisfile_mpeg_audio['VBR_bitrate'] > 0) {
- $ThisFileInfo['audio']['bitrate'] = $thisfile_mpeg_audio['VBR_bitrate'];
+ $info['audio']['bitrate'] = $thisfile_mpeg_audio['VBR_bitrate'];
$thisfile_mpeg_audio['bitrate'] = $thisfile_mpeg_audio['VBR_bitrate']; // to avoid confusion
}
break;
@@ -957,7 +957,7 @@ class getid3_mp3
if ($recursivesearch) {
- if (!getid3_mp3::RecursiveFrameScanning($fd, $ThisFileInfo, $offset, $nextframetestoffset, $ScanAsCBR)) {
+ if (!$this->RecursiveFrameScanning($offset, $nextframetestoffset, $ScanAsCBR)) {
return false;
}
@@ -997,7 +997,7 @@ class getid3_mp3
// }
//
// if ($thisfile_mpeg_audio['version'] == '1') {
- // for ($channel = 0; $channel < $ThisFileInfo['audio']['channels']; $channel++) {
+ // for ($channel = 0; $channel < $info['audio']['channels']; $channel++) {
// for ($scfsi_band = 0; $scfsi_band < 4; $scfsi_band++) {
// $thisfile_mpeg_audio['scfsi'][$channel][$scfsi_band] = substr($SideInfoBitstream, $SideInfoOffset, 1);
// $SideInfoOffset += 2;
@@ -1005,7 +1005,7 @@ class getid3_mp3
// }
// }
// for ($granule = 0; $granule < (($thisfile_mpeg_audio['version'] == '1') ? 2 : 1); $granule++) {
- // for ($channel = 0; $channel < $ThisFileInfo['audio']['channels']; $channel++) {
+ // for ($channel = 0; $channel < $info['audio']['channels']; $channel++) {
// $thisfile_mpeg_audio['part2_3_length'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 12);
// $SideInfoOffset += 12;
// $thisfile_mpeg_audio['big_values'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 9);
@@ -1069,20 +1069,23 @@ class getid3_mp3
return true;
}
- function RecursiveFrameScanning(&$fd, &$ThisFileInfo, &$offset, &$nextframetestoffset, $ScanAsCBR) {
+ function RecursiveFrameScanning(&$offset, &$nextframetestoffset, $ScanAsCBR) {
+ $info = &$this->getid3->info;
+ $firstframetestarray = array('error'=>'', 'warning'=>'', 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']);
+ $this->decodeMPEGaudioHeader($offset, $firstframetestarray, false);
+
for ($i = 0; $i < GETID3_MP3_VALID_CHECK_FRAMES; $i++) {
// check next GETID3_MP3_VALID_CHECK_FRAMES frames for validity, to make sure we haven't run across a false synch
- if (($nextframetestoffset + 4) >= $ThisFileInfo['avdataend']) {
+ if (($nextframetestoffset + 4) >= $info['avdataend']) {
// end of file
return true;
}
- $nextframetestarray = array('error'=>'', 'warning'=>'', 'avdataend'=>$ThisFileInfo['avdataend'], 'avdataoffset'=>$ThisFileInfo['avdataoffset']);
- if (getid3_mp3::decodeMPEGaudioHeader($fd, $nextframetestoffset, $nextframetestarray, false)) {
+ $nextframetestarray = array('error'=>'', 'warning'=>'', 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']);
+ if ($this->decodeMPEGaudioHeader($nextframetestoffset, $nextframetestarray, false)) {
if ($ScanAsCBR) {
- // force CBR mode, used for trying to pick out invalid audio streams with
- // valid(?) VBR headers, or VBR streams with no VBR header
- if (!isset($nextframetestarray['mpeg']['audio']['bitrate']) || !isset($ThisFileInfo['mpeg']['audio']['bitrate']) || ($nextframetestarray['mpeg']['audio']['bitrate'] != $ThisFileInfo['mpeg']['audio']['bitrate'])) {
+ // force CBR mode, used for trying to pick out invalid audio streams with valid(?) VBR headers, or VBR streams with no VBR header
+ if (!isset($nextframetestarray['mpeg']['audio']['bitrate']) || !isset($firstframetestarray['mpeg']['audio']['bitrate']) || ($nextframetestarray['mpeg']['audio']['bitrate'] != $firstframetestarray['mpeg']['audio']['bitrate'])) {
return false;
}
}
@@ -1092,14 +1095,19 @@ class getid3_mp3
if (isset($nextframetestarray['mpeg']['audio']['framelength']) && ($nextframetestarray['mpeg']['audio']['framelength'] > 0)) {
$nextframetestoffset += $nextframetestarray['mpeg']['audio']['framelength'];
} else {
- $ThisFileInfo['error'][] = 'Frame at offset ('.$offset.') is has an invalid frame length.';
+ $info['error'][] = 'Frame at offset ('.$offset.') is has an invalid frame length.';
return false;
}
+ } elseif (!empty($firstframetestarray['mpeg']['audio']['framelength']) && (($nextframetestoffset + $firstframetestarray['mpeg']['audio']['framelength']) > $info['avdataend'])) {
+
+ // it's not the end of the file, but there's not enough data left for another frame, so assume it's garbage/padding and return OK
+ return true;
+
} else {
// next frame is not valid, note the error and fail, so scanning can contiue for a valid frame sequence
- $ThisFileInfo['error'][] = 'Frame at offset ('.$offset.') is valid, but the next one at ('.$nextframetestoffset.') is not.';
+ $info['warning'][] = 'Frame at offset ('.$offset.') is valid, but the next one at ('.$nextframetestoffset.') is not.';
return false;
}
@@ -1107,9 +1115,11 @@ class getid3_mp3
return true;
}
- function FreeFormatFrameLength($fd, $offset, &$ThisFileInfo, $deepscan=false) {
- fseek($fd, $offset, SEEK_SET);
- $MPEGaudioData = fread($fd, 32768);
+ function FreeFormatFrameLength($offset, $deepscan=false) {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $offset, SEEK_SET);
+ $MPEGaudioData = fread($this->getid3->fp, 32768);
$SyncPattern1 = substr($MPEGaudioData, 0, 4);
// may be different pattern due to padding
@@ -1140,12 +1150,12 @@ class getid3_mp3
$framelength = $framelength2;
}
if (!$framelength) {
- $ThisFileInfo['error'][] = 'Cannot find next free-format synch pattern ('.getid3_lib::PrintHexBytes($SyncPattern1).' or '.getid3_lib::PrintHexBytes($SyncPattern2).') after offset '.$offset;
+ $info['error'][] = 'Cannot find next free-format synch pattern ('.getid3_lib::PrintHexBytes($SyncPattern1).' or '.getid3_lib::PrintHexBytes($SyncPattern2).') after offset '.$offset;
return false;
} else {
- $ThisFileInfo['warning'][] = 'ModeExtension varies between first frame and other frames (known free-format issue in LAME 3.88)';
- $ThisFileInfo['audio']['codec'] = 'LAME';
- $ThisFileInfo['audio']['encoder'] = 'LAME3.88';
+ $info['warning'][] = 'ModeExtension varies between first frame and other frames (known free-format issue in LAME 3.88)';
+ $info['audio']['codec'] = 'LAME';
+ $info['audio']['encoder'] = 'LAME3.88';
$SyncPattern1 = substr($SyncPattern1, 0, 3);
$SyncPattern2 = substr($SyncPattern2, 0, 3);
}
@@ -1155,9 +1165,9 @@ class getid3_mp3
$ActualFrameLengthValues = array();
$nextoffset = $offset + $framelength;
- while ($nextoffset < ($ThisFileInfo['avdataend'] - 6)) {
- fseek($fd, $nextoffset - 1, SEEK_SET);
- $NextSyncPattern = fread($fd, 6);
+ while ($nextoffset < ($info['avdataend'] - 6)) {
+ fseek($this->getid3->fp, $nextoffset - 1, SEEK_SET);
+ $NextSyncPattern = fread($this->getid3->fp, 6);
if ((substr($NextSyncPattern, 1, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 1, strlen($SyncPattern2)) == $SyncPattern2)) {
// good - found where expected
$ActualFrameLengthValues[] = $framelength;
@@ -1170,7 +1180,7 @@ class getid3_mp3
$ActualFrameLengthValues[] = ($framelength + 1);
$nextoffset++;
} else {
- $ThisFileInfo['error'][] = 'Did not find expected free-format sync pattern at offset '.$nextoffset;
+ $info['error'][] = 'Did not find expected free-format sync pattern at offset '.$nextoffset;
return false;
}
$nextoffset += $framelength;
@@ -1182,11 +1192,10 @@ class getid3_mp3
return $framelength;
}
- function getOnlyMPEGaudioInfoBruteForce($fd, &$ThisFileInfo) {
-
- $MPEGaudioHeaderDecodeCache = array();
- $MPEGaudioHeaderValidCache = array();
- $MPEGaudioHeaderLengthCache = array();
+ function getOnlyMPEGaudioInfoBruteForce() {
+ $MPEGaudioHeaderDecodeCache = array();
+ $MPEGaudioHeaderValidCache = array();
+ $MPEGaudioHeaderLengthCache = array();
$MPEGaudioVersionLookup = getid3_mp3::MPEGaudioVersionArray();
$MPEGaudioLayerLookup = getid3_mp3::MPEGaudioLayerArray();
$MPEGaudioBitrateLookup = getid3_mp3::MPEGaudioBitrateArray();
@@ -1194,34 +1203,34 @@ class getid3_mp3
$MPEGaudioChannelModeLookup = getid3_mp3::MPEGaudioChannelModeArray();
$MPEGaudioModeExtensionLookup = getid3_mp3::MPEGaudioModeExtensionArray();
$MPEGaudioEmphasisLookup = getid3_mp3::MPEGaudioEmphasisArray();
- $LongMPEGversionLookup = array();
- $LongMPEGlayerLookup = array();
- $LongMPEGbitrateLookup = array();
- $LongMPEGpaddingLookup = array();
- $LongMPEGfrequencyLookup = array();
-
- $Distribution['bitrate'] = array();
- $Distribution['frequency'] = array();
- $Distribution['layer'] = array();
- $Distribution['version'] = array();
- $Distribution['padding'] = array();
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
+ $LongMPEGversionLookup = array();
+ $LongMPEGlayerLookup = array();
+ $LongMPEGbitrateLookup = array();
+ $LongMPEGpaddingLookup = array();
+ $LongMPEGfrequencyLookup = array();
+ $Distribution['bitrate'] = array();
+ $Distribution['frequency'] = array();
+ $Distribution['layer'] = array();
+ $Distribution['version'] = array();
+ $Distribution['padding'] = array();
+
+ $info = &$this->getid3->info;
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$max_frames_scan = 5000;
$frames_scanned = 0;
- $previousvalidframe = $ThisFileInfo['avdataoffset'];
- while (ftell($fd) < $ThisFileInfo['avdataend']) {
+ $previousvalidframe = $info['avdataoffset'];
+ while (ftell($this->getid3->fp) < $info['avdataend']) {
set_time_limit(30);
- $head4 = fread($fd, 4);
+ $head4 = fread($this->getid3->fp, 4);
if (strlen($head4) < 4) {
break;
}
if ($head4{0} != "\xFF") {
for ($i = 1; $i < 4; $i++) {
if ($head4{$i} == "\xFF") {
- fseek($fd, $i - 4, SEEK_CUR);
+ fseek($this->getid3->fp, $i - 4, SEEK_CUR);
continue 2;
}
}
@@ -1249,9 +1258,9 @@ class getid3_mp3
$LongMPEGfrequencyLookup[$head4]);
}
if ($MPEGaudioHeaderLengthCache[$head4] > 4) {
- $WhereWeWere = ftell($fd);
- fseek($fd, $MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR);
- $next4 = fread($fd, 4);
+ $WhereWeWere = ftell($this->getid3->fp);
+ fseek($this->getid3->fp, $MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR);
+ $next4 = fread($this->getid3->fp, 4);
if ($next4{0} == "\xFF") {
if (!isset($MPEGaudioHeaderDecodeCache[$next4])) {
$MPEGaudioHeaderDecodeCache[$next4] = getid3_mp3::MPEGaudioHeaderDecode($next4);
@@ -1260,16 +1269,16 @@ class getid3_mp3
$MPEGaudioHeaderValidCache[$next4] = getid3_mp3::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false);
}
if ($MPEGaudioHeaderValidCache[$next4]) {
- fseek($fd, -4, SEEK_CUR);
+ fseek($this->getid3->fp, -4, SEEK_CUR);
- @$Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]++;
- @$Distribution['layer'][$LongMPEGlayerLookup[$head4]]++;
- @$Distribution['version'][$LongMPEGversionLookup[$head4]]++;
- @$Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]++;
- @$Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]++;
+ getid3_lib::safe_inc($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]);
+ getid3_lib::safe_inc($Distribution['layer'][$LongMPEGlayerLookup[$head4]]);
+ getid3_lib::safe_inc($Distribution['version'][$LongMPEGversionLookup[$head4]]);
+ getid3_lib::safe_inc($Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]);
+ getid3_lib::safe_inc($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]);
if ($max_frames_scan && (++$frames_scanned >= $max_frames_scan)) {
- $pct_data_scanned = (ftell($fd) - $ThisFileInfo['avdataoffset']) / ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']);
- $ThisFileInfo['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.';
+ $pct_data_scanned = (ftell($this->getid3->fp) - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']);
+ $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.';
foreach ($Distribution as $key1 => $value1) {
foreach ($value1 as $key2 => $value2) {
$Distribution[$key1][$key2] = round($value2 / $pct_data_scanned);
@@ -1281,7 +1290,7 @@ class getid3_mp3
}
}
unset($next4);
- fseek($fd, $WhereWeWere - 3, SEEK_SET);
+ fseek($this->getid3->fp, $WhereWeWere - 3, SEEK_SET);
}
}
@@ -1290,19 +1299,19 @@ class getid3_mp3
ksort($Distribution[$key], SORT_NUMERIC);
}
ksort($Distribution['version'], SORT_STRING);
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = $Distribution['bitrate'];
- $ThisFileInfo['mpeg']['audio']['frequency_distribution'] = $Distribution['frequency'];
- $ThisFileInfo['mpeg']['audio']['layer_distribution'] = $Distribution['layer'];
- $ThisFileInfo['mpeg']['audio']['version_distribution'] = $Distribution['version'];
- $ThisFileInfo['mpeg']['audio']['padding_distribution'] = $Distribution['padding'];
+ $info['mpeg']['audio']['bitrate_distribution'] = $Distribution['bitrate'];
+ $info['mpeg']['audio']['frequency_distribution'] = $Distribution['frequency'];
+ $info['mpeg']['audio']['layer_distribution'] = $Distribution['layer'];
+ $info['mpeg']['audio']['version_distribution'] = $Distribution['version'];
+ $info['mpeg']['audio']['padding_distribution'] = $Distribution['padding'];
if (count($Distribution['version']) > 1) {
- $ThisFileInfo['error'][] = 'Corrupt file - more than one MPEG version detected';
+ $info['error'][] = 'Corrupt file - more than one MPEG version detected';
}
if (count($Distribution['layer']) > 1) {
- $ThisFileInfo['error'][] = 'Corrupt file - more than one MPEG layer detected';
+ $info['error'][] = 'Corrupt file - more than one MPEG layer detected';
}
if (count($Distribution['frequency']) > 1) {
- $ThisFileInfo['error'][] = 'Corrupt file - more than one MPEG sample rate detected';
+ $info['error'][] = 'Corrupt file - more than one MPEG sample rate detected';
}
@@ -1312,29 +1321,30 @@ class getid3_mp3
$bittotal += ($bitratevalue * $bitratecount);
}
}
- $ThisFileInfo['mpeg']['audio']['frame_count'] = array_sum($Distribution['bitrate']);
- if ($ThisFileInfo['mpeg']['audio']['frame_count'] == 0) {
- $ThisFileInfo['error'][] = 'no MPEG audio frames found';
+ $info['mpeg']['audio']['frame_count'] = array_sum($Distribution['bitrate']);
+ if ($info['mpeg']['audio']['frame_count'] == 0) {
+ $info['error'][] = 'no MPEG audio frames found';
return false;
}
- $ThisFileInfo['mpeg']['audio']['bitrate'] = ($bittotal / $ThisFileInfo['mpeg']['audio']['frame_count']);
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = ((count($Distribution['bitrate']) > 0) ? 'vbr' : 'cbr');
- $ThisFileInfo['mpeg']['audio']['sample_rate'] = getid3_lib::array_max($Distribution['frequency'], true);
+ $info['mpeg']['audio']['bitrate'] = ($bittotal / $info['mpeg']['audio']['frame_count']);
+ $info['mpeg']['audio']['bitrate_mode'] = ((count($Distribution['bitrate']) > 0) ? 'vbr' : 'cbr');
+ $info['mpeg']['audio']['sample_rate'] = getid3_lib::array_max($Distribution['frequency'], true);
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
- $ThisFileInfo['audio']['bitrate_mode'] = $ThisFileInfo['mpeg']['audio']['bitrate_mode'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
- $ThisFileInfo['audio']['dataformat'] = 'mp'.getid3_lib::array_max($Distribution['layer'], true);
- $ThisFileInfo['fileformat'] = $ThisFileInfo['audio']['dataformat'];
+ $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
+ $info['audio']['bitrate_mode'] = $info['mpeg']['audio']['bitrate_mode'];
+ $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
+ $info['audio']['dataformat'] = 'mp'.getid3_lib::array_max($Distribution['layer'], true);
+ $info['fileformat'] = $info['audio']['dataformat'];
return true;
}
- function getOnlyMPEGaudioInfo($fd, &$ThisFileInfo, $avdataoffset, $BitrateHistogram=false) {
-
+ function getOnlyMPEGaudioInfo($avdataoffset, $BitrateHistogram=false) {
// looks for synch, decodes MPEG audio header
+ $info = &$this->getid3->info;
+
static $MPEGaudioVersionLookup;
static $MPEGaudioLayerLookup;
static $MPEGaudioBitrateLookup;
@@ -1345,131 +1355,125 @@ class getid3_mp3
}
- fseek($fd, $avdataoffset, SEEK_SET);
- $sync_seek_buffer_size = min(128 * 1024, $ThisFileInfo['avdataend'] - $avdataoffset);
+ fseek($this->getid3->fp, $avdataoffset, SEEK_SET);
+ $sync_seek_buffer_size = min(128 * 1024, $info['avdataend'] - $avdataoffset);
if ($sync_seek_buffer_size <= 0) {
- $ThisFileInfo['error'][] = 'Invalid $sync_seek_buffer_size at offset '.$avdataoffset;
+ $info['error'][] = 'Invalid $sync_seek_buffer_size at offset '.$avdataoffset;
return false;
}
- $header = fread($fd, $sync_seek_buffer_size);
+ $header = fread($this->getid3->fp, $sync_seek_buffer_size);
$sync_seek_buffer_size = strlen($header);
$SynchSeekOffset = 0;
while ($SynchSeekOffset < $sync_seek_buffer_size) {
-
- if ((($avdataoffset + $SynchSeekOffset) < $ThisFileInfo['avdataend']) && !feof($fd)) {
+ if ((($avdataoffset + $SynchSeekOffset) < $info['avdataend']) && !feof($this->getid3->fp)) {
if ($SynchSeekOffset > $sync_seek_buffer_size) {
// if a synch's not found within the first 128k bytes, then give up
- $ThisFileInfo['error'][] = 'Could not find valid MPEG audio synch within the first '.round($sync_seek_buffer_size / 1024).'kB';
- if (isset($ThisFileInfo['audio']['bitrate'])) {
- unset($ThisFileInfo['audio']['bitrate']);
+ $info['error'][] = 'Could not find valid MPEG audio synch within the first '.round($sync_seek_buffer_size / 1024).'kB';
+ if (isset($info['audio']['bitrate'])) {
+ unset($info['audio']['bitrate']);
}
- if (isset($ThisFileInfo['mpeg']['audio'])) {
- unset($ThisFileInfo['mpeg']['audio']);
+ if (isset($info['mpeg']['audio'])) {
+ unset($info['mpeg']['audio']);
}
- if (empty($ThisFileInfo['mpeg'])) {
- unset($ThisFileInfo['mpeg']);
+ if (empty($info['mpeg'])) {
+ unset($info['mpeg']);
}
return false;
- } elseif (feof($fd)) {
+ } elseif (feof($this->getid3->fp)) {
- $ThisFileInfo['error'][] = 'Could not find valid MPEG audio synch before end of file';
- if (isset($ThisFileInfo['audio']['bitrate'])) {
- unset($ThisFileInfo['audio']['bitrate']);
+ $info['error'][] = 'Could not find valid MPEG audio synch before end of file';
+ if (isset($info['audio']['bitrate'])) {
+ unset($info['audio']['bitrate']);
}
- if (isset($ThisFileInfo['mpeg']['audio'])) {
- unset($ThisFileInfo['mpeg']['audio']);
+ if (isset($info['mpeg']['audio'])) {
+ unset($info['mpeg']['audio']);
}
- if (isset($ThisFileInfo['mpeg']) && (!is_array($ThisFileInfo['mpeg']) || (count($ThisFileInfo['mpeg']) == 0))) {
- unset($ThisFileInfo['mpeg']);
+ if (isset($info['mpeg']) && (!is_array($info['mpeg']) || (count($info['mpeg']) == 0))) {
+ unset($info['mpeg']);
}
return false;
}
}
if (($SynchSeekOffset + 1) >= strlen($header)) {
- $ThisFileInfo['error'][] = 'Could not find valid MPEG synch before end of file';
+ $info['error'][] = 'Could not find valid MPEG synch before end of file';
return false;
}
if (($header{$SynchSeekOffset} == "\xFF") && ($header{($SynchSeekOffset + 1)} > "\xE0")) { // synch detected
-
- if (!isset($FirstFrameThisfileInfo) && !isset($ThisFileInfo['mpeg']['audio'])) {
- $FirstFrameThisfileInfo = $ThisFileInfo;
+ if (!isset($FirstFrameThisfileInfo) && !isset($info['mpeg']['audio'])) {
+ $FirstFrameThisfileInfo = $info;
$FirstFrameAVDataOffset = $avdataoffset + $SynchSeekOffset;
- if (!getid3_mp3::decodeMPEGaudioHeader($fd, $avdataoffset + $SynchSeekOffset, $FirstFrameThisfileInfo, false)) {
+ if (!$this->decodeMPEGaudioHeader($FirstFrameAVDataOffset, $FirstFrameThisfileInfo, false)) {
// if this is the first valid MPEG-audio frame, save it in case it's a VBR header frame and there's
// garbage between this frame and a valid sequence of MPEG-audio frames, to be restored below
unset($FirstFrameThisfileInfo);
}
}
- $dummy = $ThisFileInfo; // only overwrite real data if valid header found
- if (getid3_mp3::decodeMPEGaudioHeader($fd, $avdataoffset + $SynchSeekOffset, $dummy, true)) {
- $ThisFileInfo = $dummy;
- $ThisFileInfo['avdataoffset'] = $avdataoffset + $SynchSeekOffset;
- switch (@$ThisFileInfo['fileformat']) {
+ $dummy = $info; // only overwrite real data if valid header found
+ if ($this->decodeMPEGaudioHeader($avdataoffset + $SynchSeekOffset, $dummy, true)) {
+ $info = $dummy;
+ $info['avdataoffset'] = $avdataoffset + $SynchSeekOffset;
+ switch (isset($info['fileformat']) ? $info['fileformat'] : '') {
case '':
case 'id3':
case 'ape':
case 'mp3':
- $ThisFileInfo['fileformat'] = 'mp3';
- $ThisFileInfo['audio']['dataformat'] = 'mp3';
+ $info['fileformat'] = 'mp3';
+ $info['audio']['dataformat'] = 'mp3';
break;
}
if (isset($FirstFrameThisfileInfo['mpeg']['audio']['bitrate_mode']) && ($FirstFrameThisfileInfo['mpeg']['audio']['bitrate_mode'] == 'vbr')) {
- if (!(abs($ThisFileInfo['audio']['bitrate'] - $FirstFrameThisfileInfo['audio']['bitrate']) <= 1)) {
+ if (!(abs($info['audio']['bitrate'] - $FirstFrameThisfileInfo['audio']['bitrate']) <= 1)) {
// If there is garbage data between a valid VBR header frame and a sequence
// of valid MPEG-audio frames the VBR data is no longer discarded.
- $ThisFileInfo = $FirstFrameThisfileInfo;
- $ThisFileInfo['avdataoffset'] = $FirstFrameAVDataOffset;
- $ThisFileInfo['fileformat'] = 'mp3';
- $ThisFileInfo['audio']['dataformat'] = 'mp3';
- $dummy = $ThisFileInfo;
+ $info = $FirstFrameThisfileInfo;
+ $info['avdataoffset'] = $FirstFrameAVDataOffset;
+ $info['fileformat'] = 'mp3';
+ $info['audio']['dataformat'] = 'mp3';
+ $dummy = $info;
unset($dummy['mpeg']['audio']);
$GarbageOffsetStart = $FirstFrameAVDataOffset + $FirstFrameThisfileInfo['mpeg']['audio']['framelength'];
$GarbageOffsetEnd = $avdataoffset + $SynchSeekOffset;
- if (getid3_mp3::decodeMPEGaudioHeader($fd, $GarbageOffsetEnd, $dummy, true, true)) {
-
- $ThisFileInfo = $dummy;
- $ThisFileInfo['avdataoffset'] = $GarbageOffsetEnd;
- $ThisFileInfo['warning'][] = 'apparently-valid VBR header not used because could not find '.GETID3_MP3_VALID_CHECK_FRAMES.' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).' bytes between '.$GarbageOffsetStart.' and '.$GarbageOffsetEnd.'), but did find valid CBR stream starting at '.$GarbageOffsetEnd;
-
+ if ($this->decodeMPEGaudioHeader($GarbageOffsetEnd, $dummy, true, true)) {
+ $info = $dummy;
+ $info['avdataoffset'] = $GarbageOffsetEnd;
+ $info['warning'][] = 'apparently-valid VBR header not used because could not find '.GETID3_MP3_VALID_CHECK_FRAMES.' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).' bytes between '.$GarbageOffsetStart.' and '.$GarbageOffsetEnd.'), but did find valid CBR stream starting at '.$GarbageOffsetEnd;
} else {
-
- $ThisFileInfo['warning'][] = 'using data from VBR header even though could not find '.GETID3_MP3_VALID_CHECK_FRAMES.' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).' bytes between '.$GarbageOffsetStart.' and '.$GarbageOffsetEnd.')';
-
+ $info['warning'][] = 'using data from VBR header even though could not find '.GETID3_MP3_VALID_CHECK_FRAMES.' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).' bytes between '.$GarbageOffsetStart.' and '.$GarbageOffsetEnd.')';
}
}
}
- if (isset($ThisFileInfo['mpeg']['audio']['bitrate_mode']) && ($ThisFileInfo['mpeg']['audio']['bitrate_mode'] == 'vbr') && !isset($ThisFileInfo['mpeg']['audio']['VBR_method'])) {
+ if (isset($info['mpeg']['audio']['bitrate_mode']) && ($info['mpeg']['audio']['bitrate_mode'] == 'vbr') && !isset($info['mpeg']['audio']['VBR_method'])) {
// VBR file with no VBR header
$BitrateHistogram = true;
}
if ($BitrateHistogram) {
- $ThisFileInfo['mpeg']['audio']['stereo_distribution'] = array('stereo'=>0, 'joint stereo'=>0, 'dual channel'=>0, 'mono'=>0);
- $ThisFileInfo['mpeg']['audio']['version_distribution'] = array('1'=>0, '2'=>0, '2.5'=>0);
+ $info['mpeg']['audio']['stereo_distribution'] = array('stereo'=>0, 'joint stereo'=>0, 'dual channel'=>0, 'mono'=>0);
+ $info['mpeg']['audio']['version_distribution'] = array('1'=>0, '2'=>0, '2.5'=>0);
- if ($ThisFileInfo['mpeg']['audio']['version'] == '1') {
- if ($ThisFileInfo['mpeg']['audio']['layer'] == 3) {
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 40000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 320000=>0);
- } elseif ($ThisFileInfo['mpeg']['audio']['layer'] == 2) {
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 320000=>0, 384000=>0);
- } elseif ($ThisFileInfo['mpeg']['audio']['layer'] == 1) {
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 64000=>0, 96000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 288000=>0, 320000=>0, 352000=>0, 384000=>0, 416000=>0, 448000=>0);
+ if ($info['mpeg']['audio']['version'] == '1') {
+ if ($info['mpeg']['audio']['layer'] == 3) {
+ $info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 40000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 320000=>0);
+ } elseif ($info['mpeg']['audio']['layer'] == 2) {
+ $info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 320000=>0, 384000=>0);
+ } elseif ($info['mpeg']['audio']['layer'] == 1) {
+ $info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 64000=>0, 96000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 288000=>0, 320000=>0, 352000=>0, 384000=>0, 416000=>0, 448000=>0);
}
- } elseif ($ThisFileInfo['mpeg']['audio']['layer'] == 1) {
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 144000=>0, 160000=>0, 176000=>0, 192000=>0, 224000=>0, 256000=>0);
+ } elseif ($info['mpeg']['audio']['layer'] == 1) {
+ $info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 144000=>0, 160000=>0, 176000=>0, 192000=>0, 224000=>0, 256000=>0);
} else {
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 8000=>0, 16000=>0, 24000=>0, 32000=>0, 40000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 144000=>0, 160000=>0);
+ $info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 8000=>0, 16000=>0, 24000=>0, 32000=>0, 40000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 144000=>0, 160000=>0);
}
- $dummy = array('error'=>$ThisFileInfo['error'], 'warning'=>$ThisFileInfo['warning'], 'avdataend'=>$ThisFileInfo['avdataend'], 'avdataoffset'=>$ThisFileInfo['avdataoffset']);
- $synchstartoffset = $ThisFileInfo['avdataoffset'];
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
+ $dummy = array('error'=>$info['error'], 'warning'=>$info['warning'], 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']);
+ $synchstartoffset = $info['avdataoffset'];
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
// you can play with these numbers:
$max_frames_scan = 50000;
@@ -1483,116 +1487,102 @@ class getid3_mp3
$frames_scan_per_segment = ceil($max_frames_scan / $max_scan_segments);
$pct_data_scanned = 0;
for ($current_segment = 0; $current_segment < $max_scan_segments; $current_segment++) {
-//echo 'was at '.ftell($fd).'<br>';
$frames_scanned_this_segment = 0;
- if (ftell($fd) >= $ThisFileInfo['avdataend']) {
-//echo 'breaking because current position ('.ftell($fd).') is >= $ThisFileInfo[avdataend] ('.$ThisFileInfo['avdataend'].')<br>';
+ if (ftell($this->getid3->fp) >= $info['avdataend']) {
break;
}
- $scan_start_offset[$current_segment] = max(ftell($fd), $ThisFileInfo['avdataoffset'] + round($current_segment * (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) / $max_scan_segments)));
-//echo 'start at '.$scan_start_offset[$current_segment].'<br>';
+ $scan_start_offset[$current_segment] = max(ftell($this->getid3->fp), $info['avdataoffset'] + round($current_segment * (($info['avdataend'] - $info['avdataoffset']) / $max_scan_segments)));
if ($current_segment > 0) {
- fseek($fd, $scan_start_offset[$current_segment], SEEK_SET);
- $buffer_4k = fread($fd, 4096);
+ fseek($this->getid3->fp, $scan_start_offset[$current_segment], SEEK_SET);
+ $buffer_4k = fread($this->getid3->fp, 4096);
for ($j = 0; $j < (strlen($buffer_4k) - 4); $j++) {
if (($buffer_4k{$j} == "\xFF") && ($buffer_4k{($j + 1)} > "\xE0")) { // synch detected
- if (getid3_mp3::decodeMPEGaudioHeader($fd, $scan_start_offset[$current_segment] + $j, $dummy, false, false, $FastMode)) {
+ if ($this->decodeMPEGaudioHeader($scan_start_offset[$current_segment] + $j, $dummy, false, false, $FastMode)) {
$calculated_next_offset = $scan_start_offset[$current_segment] + $j + $dummy['mpeg']['audio']['framelength'];
- if (getid3_mp3::decodeMPEGaudioHeader($fd, $calculated_next_offset, $dummy, false, false, $FastMode)) {
+ if ($this->decodeMPEGaudioHeader($calculated_next_offset, $dummy, false, false, $FastMode)) {
$scan_start_offset[$current_segment] += $j;
break;
- } else {
-//echo 'header['.__LINE__.'] at '.($calculated_next_offset).' invalid<br>';
}
- } else {
-//echo 'header['.__LINE__.'] at '.($scan_start_offset[$current_segment] + $j).' invalid<br>';
}
}
}
}
-//echo 'actually start at '.$scan_start_offset[$current_segment].'<br>';
$synchstartoffset = $scan_start_offset[$current_segment];
- while (getid3_mp3::decodeMPEGaudioHeader($fd, $synchstartoffset, $dummy, false, false, $FastMode)) {
+ while ($this->decodeMPEGaudioHeader($synchstartoffset, $dummy, false, false, $FastMode)) {
$FastMode = true;
$thisframebitrate = $MPEGaudioBitrateLookup[$MPEGaudioVersionLookup[$dummy['mpeg']['audio']['raw']['version']]][$MPEGaudioLayerLookup[$dummy['mpeg']['audio']['raw']['layer']]][$dummy['mpeg']['audio']['raw']['bitrate']];
if (empty($dummy['mpeg']['audio']['framelength'])) {
$SynchErrorsFound++;
$synchstartoffset++;
-//echo ' [Ø] ';
} else {
-//echo ' . ';
- @$ThisFileInfo['mpeg']['audio']['bitrate_distribution'][$thisframebitrate]++;
- @$ThisFileInfo['mpeg']['audio']['stereo_distribution'][$dummy['mpeg']['audio']['channelmode']]++;
- @$ThisFileInfo['mpeg']['audio']['version_distribution'][$dummy['mpeg']['audio']['version']]++;
-
+ getid3_lib::safe_inc($info['mpeg']['audio']['bitrate_distribution'][$thisframebitrate]);
+ getid3_lib::safe_inc($info['mpeg']['audio']['stereo_distribution'][$dummy['mpeg']['audio']['channelmode']]);
+ getid3_lib::safe_inc($info['mpeg']['audio']['version_distribution'][$dummy['mpeg']['audio']['version']]);
$synchstartoffset += $dummy['mpeg']['audio']['framelength'];
}
$frames_scanned++;
if ($frames_scan_per_segment && (++$frames_scanned_this_segment >= $frames_scan_per_segment)) {
- $this_pct_scanned = (ftell($fd) - $scan_start_offset[$current_segment]) / ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']);
+ $this_pct_scanned = (ftell($this->getid3->fp) - $scan_start_offset[$current_segment]) / ($info['avdataend'] - $info['avdataoffset']);
if (($current_segment == 0) && (($this_pct_scanned * $max_scan_segments) >= 1)) {
// file likely contains < $max_frames_scan, just scan as one segment
$max_scan_segments = 1;
$frames_scan_per_segment = $max_frames_scan;
} else {
$pct_data_scanned += $this_pct_scanned;
-//var_dump($pct_data_scanned);
-//exit;
break;
}
}
}
-//echo '<hr>';
}
if ($pct_data_scanned > 0) {
- $ThisFileInfo['warning'][] = 'too many MPEG audio frames to scan, only scanned '.$frames_scanned.' frames in '.$max_scan_segments.' segments ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.';
- foreach ($ThisFileInfo['mpeg']['audio'] as $key1 => $value1) {
- if (!eregi('_distribution$', $key1)) {
+ $info['warning'][] = 'too many MPEG audio frames to scan, only scanned '.$frames_scanned.' frames in '.$max_scan_segments.' segments ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.';
+ foreach ($info['mpeg']['audio'] as $key1 => $value1) {
+ if (!preg_match('#_distribution$#i', $key1)) {
continue;
}
foreach ($value1 as $key2 => $value2) {
- $ThisFileInfo['mpeg']['audio'][$key1][$key2] = round($value2 / $pct_data_scanned);
+ $info['mpeg']['audio'][$key1][$key2] = round($value2 / $pct_data_scanned);
}
}
}
if ($SynchErrorsFound > 0) {
- $ThisFileInfo['warning'][] = 'Found '.$SynchErrorsFound.' synch errors in histogram analysis';
+ $info['warning'][] = 'Found '.$SynchErrorsFound.' synch errors in histogram analysis';
//return false;
}
$bittotal = 0;
$framecounter = 0;
- foreach ($ThisFileInfo['mpeg']['audio']['bitrate_distribution'] as $bitratevalue => $bitratecount) {
+ foreach ($info['mpeg']['audio']['bitrate_distribution'] as $bitratevalue => $bitratecount) {
$framecounter += $bitratecount;
if ($bitratevalue != 'free') {
$bittotal += ($bitratevalue * $bitratecount);
}
}
if ($framecounter == 0) {
- $ThisFileInfo['error'][] = 'Corrupt MP3 file: framecounter == zero';
+ $info['error'][] = 'Corrupt MP3 file: framecounter == zero';
return false;
}
- $ThisFileInfo['mpeg']['audio']['frame_count'] = getid3_lib::CastAsInt($framecounter);
- $ThisFileInfo['mpeg']['audio']['bitrate'] = ($bittotal / $framecounter);
+ $info['mpeg']['audio']['frame_count'] = getid3_lib::CastAsInt($framecounter);
+ $info['mpeg']['audio']['bitrate'] = ($bittotal / $framecounter);
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
+ $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
// Definitively set VBR vs CBR, even if the Xing/LAME/VBRI header says differently
$distinct_bitrates = 0;
- foreach ($ThisFileInfo['mpeg']['audio']['bitrate_distribution'] as $bitrate_value => $bitrate_count) {
+ foreach ($info['mpeg']['audio']['bitrate_distribution'] as $bitrate_value => $bitrate_count) {
if ($bitrate_count > 0) {
$distinct_bitrates++;
}
}
if ($distinct_bitrates > 1) {
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = 'vbr';
+ $info['mpeg']['audio']['bitrate_mode'] = 'vbr';
} else {
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = 'cbr';
+ $info['mpeg']['audio']['bitrate_mode'] = 'cbr';
}
- $ThisFileInfo['audio']['bitrate_mode'] = $ThisFileInfo['mpeg']['audio']['bitrate_mode'];
+ $info['audio']['bitrate_mode'] = $info['mpeg']['audio']['bitrate_mode'];
}
@@ -1601,20 +1591,20 @@ class getid3_mp3
}
$SynchSeekOffset++;
- if (($avdataoffset + $SynchSeekOffset) >= $ThisFileInfo['avdataend']) {
+ if (($avdataoffset + $SynchSeekOffset) >= $info['avdataend']) {
// end of file/data
- if (empty($ThisFileInfo['mpeg']['audio'])) {
+ if (empty($info['mpeg']['audio'])) {
- $ThisFileInfo['error'][] = 'could not find valid MPEG synch before end of file';
- if (isset($ThisFileInfo['audio']['bitrate'])) {
- unset($ThisFileInfo['audio']['bitrate']);
+ $info['error'][] = 'could not find valid MPEG synch before end of file';
+ if (isset($info['audio']['bitrate'])) {
+ unset($info['audio']['bitrate']);
}
- if (isset($ThisFileInfo['mpeg']['audio'])) {
- unset($ThisFileInfo['mpeg']['audio']);
+ if (isset($info['mpeg']['audio'])) {
+ unset($info['mpeg']['audio']);
}
- if (isset($ThisFileInfo['mpeg']) && (!is_array($ThisFileInfo['mpeg']) || empty($ThisFileInfo['mpeg']))) {
- unset($ThisFileInfo['mpeg']);
+ if (isset($info['mpeg']) && (!is_array($info['mpeg']) || empty($info['mpeg']))) {
+ unset($info['mpeg']);
}
return false;
@@ -1623,24 +1613,24 @@ class getid3_mp3
}
}
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
- $ThisFileInfo['audio']['channelmode'] = $ThisFileInfo['mpeg']['audio']['channelmode'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
+ $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
+ $info['audio']['channelmode'] = $info['mpeg']['audio']['channelmode'];
+ $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
return true;
}
- function MPEGaudioVersionArray() {
+ static function MPEGaudioVersionArray() {
static $MPEGaudioVersion = array('2.5', false, '2', '1');
return $MPEGaudioVersion;
}
- function MPEGaudioLayerArray() {
+ static function MPEGaudioLayerArray() {
static $MPEGaudioLayer = array(false, 3, 2, 1);
return $MPEGaudioLayer;
}
- function MPEGaudioBitrateArray() {
+ static function MPEGaudioBitrateArray() {
static $MPEGaudioBitrate;
if (empty($MPEGaudioBitrate)) {
$MPEGaudioBitrate = array (
@@ -1659,7 +1649,7 @@ class getid3_mp3
return $MPEGaudioBitrate;
}
- function MPEGaudioFrequencyArray() {
+ static function MPEGaudioFrequencyArray() {
static $MPEGaudioFrequency;
if (empty($MPEGaudioFrequency)) {
$MPEGaudioFrequency = array (
@@ -1671,12 +1661,12 @@ class getid3_mp3
return $MPEGaudioFrequency;
}
- function MPEGaudioChannelModeArray() {
+ static function MPEGaudioChannelModeArray() {
static $MPEGaudioChannelMode = array('stereo', 'joint stereo', 'dual channel', 'mono');
return $MPEGaudioChannelMode;
}
- function MPEGaudioModeExtensionArray() {
+ static function MPEGaudioModeExtensionArray() {
static $MPEGaudioModeExtension;
if (empty($MPEGaudioModeExtension)) {
$MPEGaudioModeExtension = array (
@@ -1688,16 +1678,16 @@ class getid3_mp3
return $MPEGaudioModeExtension;
}
- function MPEGaudioEmphasisArray() {
+ static function MPEGaudioEmphasisArray() {
static $MPEGaudioEmphasis = array('none', '50/15ms', false, 'CCIT J.17');
return $MPEGaudioEmphasis;
}
- function MPEGaudioHeaderBytesValid($head4, $allowBitrate15=false) {
+ static function MPEGaudioHeaderBytesValid($head4, $allowBitrate15=false) {
return getid3_mp3::MPEGaudioHeaderValid(getid3_mp3::MPEGaudioHeaderDecode($head4), false, $allowBitrate15);
}
- function MPEGaudioHeaderValid($rawarray, $echoerrors=false, $allowBitrate15=false) {
+ static function MPEGaudioHeaderValid($rawarray, $echoerrors=false, $allowBitrate15=false) {
if (($rawarray['synch'] & 0x0FFE) != 0x0FFE) {
return false;
}
@@ -1769,7 +1759,7 @@ class getid3_mp3
return true;
}
- function MPEGaudioHeaderDecode($Header4Bytes) {
+ static function MPEGaudioHeaderDecode($Header4Bytes) {
// AAAA AAAA AAAB BCCD EEEE FFGH IIJJ KLMM
// A - Frame sync (all bits set)
// B - MPEG Audio version ID
@@ -1806,7 +1796,7 @@ class getid3_mp3
return $MPEGrawHeader;
}
- function MPEGaudioFrameLength(&$bitrate, &$version, &$layer, $padding, &$samplerate) {
+ static function MPEGaudioFrameLength(&$bitrate, &$version, &$layer, $padding, &$samplerate) {
static $AudioFrameLengthCache = array();
if (!isset($AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate])) {
@@ -1867,28 +1857,27 @@ class getid3_mp3
return $AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate];
}
- function ClosestStandardMP3Bitrate($bitrate) {
- static $StandardBitrates = array(320000, 256000, 224000, 192000, 160000, 128000, 112000, 96000, 80000, 64000, 56000, 48000, 40000, 32000, 24000, 16000, 8000);
- static $BitrateTable = array(0=>'-');
- $roundbitrate = intval(round($bitrate, -3));
- if (!isset($BitrateTable[$roundbitrate])) {
- if ($roundbitrate > 320000) {
- $BitrateTable[$roundbitrate] = round($bitrate, -4);
+ static function ClosestStandardMP3Bitrate($bit_rate) {
+ static $standard_bit_rates = array (320000, 256000, 224000, 192000, 160000, 128000, 112000, 96000, 80000, 64000, 56000, 48000, 40000, 32000, 24000, 16000, 8000);
+ static $bit_rate_table = array (0=>'-');
+ $round_bit_rate = intval(round($bit_rate, -3));
+ if (!isset($bit_rate_table[$round_bit_rate])) {
+ if ($round_bit_rate > max($standard_bit_rates)) {
+ $bit_rate_table[$round_bit_rate] = round($bit_rate, 2 - strlen($bit_rate));
} else {
- $LastBitrate = 320000;
- foreach ($StandardBitrates as $StandardBitrate) {
- $BitrateTable[$roundbitrate] = $StandardBitrate;
- if ($roundbitrate >= $StandardBitrate - (($LastBitrate - $StandardBitrate) / 2)) {
+ $bit_rate_table[$round_bit_rate] = max($standard_bit_rates);
+ foreach ($standard_bit_rates as $standard_bit_rate) {
+ if ($round_bit_rate >= $standard_bit_rate + (($bit_rate_table[$round_bit_rate] - $standard_bit_rate) / 2)) {
break;
}
- $LastBitrate = $StandardBitrate;
+ $bit_rate_table[$round_bit_rate] = $standard_bit_rate;
}
}
}
- return $BitrateTable[$roundbitrate];
+ return $bit_rate_table[$round_bit_rate];
}
- function XingVBRidOffset($version, $channelmode) {
+ static function XingVBRidOffset($version, $channelmode) {
static $XingVBRidOffsetCache = array();
if (empty($XingVBRidOffset)) {
$XingVBRidOffset = array (
@@ -1914,7 +1903,7 @@ class getid3_mp3
return $XingVBRidOffset[$version][$channelmode];
}
- function LAMEvbrMethodLookup($VBRmethodID) {
+ static function LAMEvbrMethodLookup($VBRmethodID) {
static $LAMEvbrMethodLookup = array(
0x00 => 'unknown',
0x01 => 'cbr',
@@ -1930,7 +1919,7 @@ class getid3_mp3
return (isset($LAMEvbrMethodLookup[$VBRmethodID]) ? $LAMEvbrMethodLookup[$VBRmethodID] : '');
}
- function LAMEmiscStereoModeLookup($StereoModeID) {
+ static function LAMEmiscStereoModeLookup($StereoModeID) {
static $LAMEmiscStereoModeLookup = array(
0 => 'mono',
1 => 'stereo',
@@ -1944,7 +1933,7 @@ class getid3_mp3
return (isset($LAMEmiscStereoModeLookup[$StereoModeID]) ? $LAMEmiscStereoModeLookup[$StereoModeID] : '');
}
- function LAMEmiscSourceSampleFrequencyLookup($SourceSampleFrequencyID) {
+ static function LAMEmiscSourceSampleFrequencyLookup($SourceSampleFrequencyID) {
static $LAMEmiscSourceSampleFrequencyLookup = array(
0 => '<= 32 kHz',
1 => '44.1 kHz',
@@ -1954,7 +1943,7 @@ class getid3_mp3
return (isset($LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID]) ? $LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID] : '');
}
- function LAMEsurroundInfoLookup($SurroundInfoID) {
+ static function LAMEsurroundInfoLookup($SurroundInfoID) {
static $LAMEsurroundInfoLookup = array(
0 => 'no surround info',
1 => 'DPL encoding',
@@ -1964,7 +1953,7 @@ class getid3_mp3
return (isset($LAMEsurroundInfoLookup[$SurroundInfoID]) ? $LAMEsurroundInfoLookup[$SurroundInfoID] : 'reserved');
}
- function LAMEpresetUsedLookup($LAMEtag) {
+ static function LAMEpresetUsedLookup($LAMEtag) {
if ($LAMEtag['preset_used_id'] == 0) {
// no preset used (LAME >=3.93)
diff --git a/apps/media/getID3/getid3/module.audio.mpc.php b/3rdparty/getid3/module.audio.mpc.php
index 66200ad02a7..9a0b16d9abc 100644
--- a/apps/media/getID3/getid3/module.audio.mpc.php
+++ b/3rdparty/getid3/module.audio.mpc.php
@@ -14,42 +14,44 @@
/////////////////////////////////////////////////////////////////
-class getid3_mpc
+class getid3_mpc extends getid3_handler
{
- function getid3_mpc(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['mpc']['header'] = array();
- $thisfile_mpc_header = &$ThisFileInfo['mpc']['header'];
+ function Analyze() {
+ $info = &$this->getid3->info;
- $ThisFileInfo['fileformat'] = 'mpc';
- $ThisFileInfo['audio']['dataformat'] = 'mpc';
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
- $ThisFileInfo['audio']['channels'] = 2; // up to SV7 the format appears to have been hardcoded for stereo only
- $ThisFileInfo['audio']['lossless'] = false;
+ $info['mpc']['header'] = array();
+ $thisfile_mpc_header = &$info['mpc']['header'];
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $MPCheaderData = fread($fd, 4);
- $ThisFileInfo['mpc']['header']['preamble'] = substr($MPCheaderData, 0, 4); // should be 'MPCK' (SV8) or 'MP+' (SV7), otherwise possible stream data (SV4-SV6)
- if (ereg('^MPCK', $ThisFileInfo['mpc']['header']['preamble'])) {
+ $info['fileformat'] = 'mpc';
+ $info['audio']['dataformat'] = 'mpc';
+ $info['audio']['bitrate_mode'] = 'vbr';
+ $info['audio']['channels'] = 2; // up to SV7 the format appears to have been hardcoded for stereo only
+ $info['audio']['lossless'] = false;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $MPCheaderData = fread($this->getid3->fp, 4);
+ $info['mpc']['header']['preamble'] = substr($MPCheaderData, 0, 4); // should be 'MPCK' (SV8) or 'MP+' (SV7), otherwise possible stream data (SV4-SV6)
+ if (preg_match('#^MPCK#', $info['mpc']['header']['preamble'])) {
// this is SV8
- return $this->ParseMPCsv8($fd, $ThisFileInfo);
+ return $this->ParseMPCsv8();
- } elseif (ereg('^MP\+', $ThisFileInfo['mpc']['header']['preamble'])) {
+ } elseif (preg_match('#^MP\+#', $info['mpc']['header']['preamble'])) {
// this is SV7
- return $this->ParseMPCsv7($fd, $ThisFileInfo);
+ return $this->ParseMPCsv7();
} elseif (preg_match('/^[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0]/s', $MPCheaderData)) {
// this is SV4 - SV6, handle seperately
- return $this->ParseMPCsv6($fd, $ThisFileInfo);
+ return $this->ParseMPCsv6();
} else {
- $ThisFileInfo['error'][] = 'Expecting "MP+" or "MPCK" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($MPCheaderData, 0, 4).'"';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['mpc']);
+ $info['error'][] = 'Expecting "MP+" or "MPCK" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($MPCheaderData, 0, 4)).'"';
+ unset($info['fileformat']);
+ unset($info['mpc']);
return false;
}
@@ -57,35 +59,36 @@ class getid3_mpc
}
- function ParseMPCsv8(&$fd, &$ThisFileInfo) {
+ function ParseMPCsv8() {
// this is SV8
// http://trac.musepack.net/trac/wiki/SV8Specification
- $thisfile_mpc_header = &$ThisFileInfo['mpc']['header'];
+ $info = &$this->getid3->info;
+ $thisfile_mpc_header = &$info['mpc']['header'];
$keyNameSize = 2;
$maxHandledPacketLength = 9; // specs say: "n*8; 0 < n < 10"
- $offset = ftell($fd);
- while ($offset < $ThisFileInfo['avdataend']) {
+ $offset = ftell($this->getid3->fp);
+ while ($offset < $info['avdataend']) {
$thisPacket = array();
$thisPacket['offset'] = $offset;
$packet_offset = 0;
// Size is a variable-size field, could be 1-4 bytes (possibly more?)
// read enough data in and figure out the exact size later
- $MPCheaderData = fread($fd, $keyNameSize + $maxHandledPacketLength);
+ $MPCheaderData = fread($this->getid3->fp, $keyNameSize + $maxHandledPacketLength);
$packet_offset += $keyNameSize;
$thisPacket['key'] = substr($MPCheaderData, 0, $keyNameSize);
$thisPacket['key_name'] = $this->MPCsv8PacketName($thisPacket['key']);
if ($thisPacket['key'] == $thisPacket['key_name']) {
- $ThisFileInfo['error'][] = 'Found unexpected key value "'.$thisPacket['key'].'" at offset '.$thisPacket['offset'];
+ $info['error'][] = 'Found unexpected key value "'.$thisPacket['key'].'" at offset '.$thisPacket['offset'];
return false;
}
$packetLength = 0;
$thisPacket['packet_size'] = $this->SV8variableLengthInteger(substr($MPCheaderData, $keyNameSize), $packetLength); // includes keyname and packet_size field
if ($thisPacket['packet_size'] === false) {
- $ThisFileInfo['error'][] = 'Did not find expected packet length within '.$maxHandledPacketLength.' bytes at offset '.($thisPacket['offset'] + $keyNameSize);
+ $info['error'][] = 'Did not find expected packet length within '.$maxHandledPacketLength.' bytes at offset '.($thisPacket['offset'] + $keyNameSize);
return false;
}
$packet_offset += $packetLength;
@@ -95,7 +98,7 @@ class getid3_mpc
case 'SH': // Stream Header
$moreBytesToRead = $thisPacket['packet_size'] - $keyNameSize - $maxHandledPacketLength;
if ($moreBytesToRead > 0) {
- $MPCheaderData .= fread($fd, $moreBytesToRead);
+ $MPCheaderData .= fread($this->getid3->fp, $moreBytesToRead);
}
$thisPacket['crc'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 4));
$packet_offset += 4;
@@ -124,16 +127,16 @@ class getid3_mpc
$thisfile_mpc_header['samples'] = $thisPacket['sample_count'];
$thisfile_mpc_header['stream_version_major'] = $thisPacket['stream_version'];
- $ThisFileInfo['audio']['channels'] = $thisPacket['channels'];
- $ThisFileInfo['audio']['sample_rate'] = $thisPacket['sample_frequency'];
- $ThisFileInfo['playtime_seconds'] = $thisPacket['sample_count'] / $thisPacket['sample_frequency'];
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
+ $info['audio']['channels'] = $thisPacket['channels'];
+ $info['audio']['sample_rate'] = $thisPacket['sample_frequency'];
+ $info['playtime_seconds'] = $thisPacket['sample_count'] / $thisPacket['sample_frequency'];
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
break;
case 'RG': // Replay Gain
$moreBytesToRead = $thisPacket['packet_size'] - $keyNameSize - $maxHandledPacketLength;
if ($moreBytesToRead > 0) {
- $MPCheaderData .= fread($fd, $moreBytesToRead);
+ $MPCheaderData .= fread($this->getid3->fp, $moreBytesToRead);
}
$thisPacket['replaygain_version'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 1));
$packet_offset += 1;
@@ -146,16 +149,16 @@ class getid3_mpc
$thisPacket['replaygain_album_peak'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 2));
$packet_offset += 2;
- if ($thisPacket['replaygain_title_gain']) { $ThisFileInfo['replay_gain']['title']['gain'] = $thisPacket['replaygain_title_gain']; }
- if ($thisPacket['replaygain_title_peak']) { $ThisFileInfo['replay_gain']['title']['peak'] = $thisPacket['replaygain_title_peak']; }
- if ($thisPacket['replaygain_album_gain']) { $ThisFileInfo['replay_gain']['album']['gain'] = $thisPacket['replaygain_album_gain']; }
- if ($thisPacket['replaygain_album_peak']) { $ThisFileInfo['replay_gain']['album']['peak'] = $thisPacket['replaygain_album_peak']; }
+ if ($thisPacket['replaygain_title_gain']) { $info['replay_gain']['title']['gain'] = $thisPacket['replaygain_title_gain']; }
+ if ($thisPacket['replaygain_title_peak']) { $info['replay_gain']['title']['peak'] = $thisPacket['replaygain_title_peak']; }
+ if ($thisPacket['replaygain_album_gain']) { $info['replay_gain']['album']['gain'] = $thisPacket['replaygain_album_gain']; }
+ if ($thisPacket['replaygain_album_peak']) { $info['replay_gain']['album']['peak'] = $thisPacket['replaygain_album_peak']; }
break;
case 'EI': // Encoder Info
$moreBytesToRead = $thisPacket['packet_size'] - $keyNameSize - $maxHandledPacketLength;
if ($moreBytesToRead > 0) {
- $MPCheaderData .= fread($fd, $moreBytesToRead);
+ $MPCheaderData .= fread($this->getid3->fp, $moreBytesToRead);
}
$profile_pns = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 1));
$packet_offset += 1;
@@ -171,8 +174,8 @@ class getid3_mpc
$packet_offset += 1;
$thisPacket['version'] = $thisPacket['version_major'].'.'.$thisPacket['version_minor'].'.'.$thisPacket['version_build'];
- $ThisFileInfo['audio']['encoder'] = 'MPC v'.$thisPacket['version'].' ('.(($thisPacket['version_minor'] % 2) ? 'unstable' : 'stable').')';
- $thisfile_mpc_header['encoder_version'] = $ThisFileInfo['audio']['encoder'];
+ $info['audio']['encoder'] = 'MPC v'.$thisPacket['version'].' ('.(($thisPacket['version_minor'] % 2) ? 'unstable' : 'stable').')';
+ $thisfile_mpc_header['encoder_version'] = $info['audio']['encoder'];
//$thisfile_mpc_header['quality'] = (float) ($thisPacket['quality'] / 1.5875); // values can range from 0.000 to 15.875, mapped to qualities of 0.0 to 10.0
$thisfile_mpc_header['quality'] = (float) ($thisPacket['quality'] - 5); // values can range from 0.000 to 15.875, of which 0..4 are "reserved/experimental", and 5..15 are mapped to qualities of 0.0 to 10.0
break;
@@ -191,28 +194,30 @@ class getid3_mpc
break;
default:
- $ThisFileInfo['error'][] = 'Found unhandled key type "'.$thisPacket['key'].'" at offset '.$thisPacket['offset'];
+ $info['error'][] = 'Found unhandled key type "'.$thisPacket['key'].'" at offset '.$thisPacket['offset'];
return false;
break;
}
if (!empty($thisPacket)) {
- $ThisFileInfo['mpc']['packets'][] = $thisPacket;
+ $info['mpc']['packets'][] = $thisPacket;
}
- fseek($fd, $offset);
+ fseek($this->getid3->fp, $offset);
}
$thisfile_mpc_header['size'] = $offset;
return true;
}
- function ParseMPCsv7(&$fd, &$ThisFileInfo) {
+ function ParseMPCsv7() {
// this is SV7
// http://www.uni-jena.de/~pfk/mpp/sv8/header.html
- $thisfile_mpc_header = &$ThisFileInfo['mpc']['header'];
+
+ $info = &$this->getid3->info;
+ $thisfile_mpc_header = &$info['mpc']['header'];
$offset = 0;
$thisfile_mpc_header['size'] = 28;
- $MPCheaderData = $ThisFileInfo['mpc']['header']['preamble'];
- $MPCheaderData .= fread($fd, $thisfile_mpc_header['size'] - strlen($ThisFileInfo['mpc']['header']['preamble']));
+ $MPCheaderData = $info['mpc']['header']['preamble'];
+ $MPCheaderData .= fread($this->getid3->fp, $thisfile_mpc_header['size'] - strlen($info['mpc']['header']['preamble']));
$offset = strlen('MP+');
$StreamVersionByte = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
@@ -223,7 +228,7 @@ class getid3_mpc
$offset += 4;
if ($thisfile_mpc_header['stream_version_major'] != 7) {
- $ThisFileInfo['error'][] = 'Only Musepack SV7 supported (this file claims to be v'.$thisfile_mpc_header['stream_version_major'].')';
+ $info['error'][] = 'Only Musepack SV7 supported (this file claims to be v'.$thisfile_mpc_header['stream_version_major'].')';
return false;
}
@@ -262,22 +267,22 @@ class getid3_mpc
$thisfile_mpc_header['profile'] = $this->MPCprofileNameLookup($thisfile_mpc_header['raw']['profile']);
$thisfile_mpc_header['sample_rate'] = $this->MPCfrequencyLookup($thisfile_mpc_header['raw']['sample_rate']);
if ($thisfile_mpc_header['sample_rate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt MPC file: frequency == zero';
+ $info['error'][] = 'Corrupt MPC file: frequency == zero';
return false;
}
- $ThisFileInfo['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
- $thisfile_mpc_header['samples'] = ((($thisfile_mpc_header['frame_count'] - 1) * 1152) + $thisfile_mpc_header['last_frame_length']) * $ThisFileInfo['audio']['channels'];
+ $info['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
+ $thisfile_mpc_header['samples'] = ((($thisfile_mpc_header['frame_count'] - 1) * 1152) + $thisfile_mpc_header['last_frame_length']) * $info['audio']['channels'];
- $ThisFileInfo['playtime_seconds'] = ($thisfile_mpc_header['samples'] / $ThisFileInfo['audio']['channels']) / $ThisFileInfo['audio']['sample_rate'];
- if ($ThisFileInfo['playtime_seconds'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt MPC file: playtime_seconds == zero';
+ $info['playtime_seconds'] = ($thisfile_mpc_header['samples'] / $info['audio']['channels']) / $info['audio']['sample_rate'];
+ if ($info['playtime_seconds'] == 0) {
+ $info['error'][] = 'Corrupt MPC file: playtime_seconds == zero';
return false;
}
// add size of file header to avdataoffset - calc bitrate correctly + MD5 data
- $ThisFileInfo['avdataoffset'] += $thisfile_mpc_header['size'];
+ $info['avdataoffset'] += $thisfile_mpc_header['size'];
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
$thisfile_mpc_header['title_peak'] = $thisfile_mpc_header['raw']['title_peak'];
$thisfile_mpc_header['title_peak_db'] = $this->MPCpeakDBLookup($thisfile_mpc_header['title_peak']);
@@ -296,37 +301,39 @@ class getid3_mpc
}
$thisfile_mpc_header['encoder_version'] = $this->MPCencoderVersionLookup($thisfile_mpc_header['raw']['encoder_version']);
- $ThisFileInfo['replay_gain']['track']['adjustment'] = $thisfile_mpc_header['title_gain_db'];
- $ThisFileInfo['replay_gain']['album']['adjustment'] = $thisfile_mpc_header['album_gain_db'];
+ $info['replay_gain']['track']['adjustment'] = $thisfile_mpc_header['title_gain_db'];
+ $info['replay_gain']['album']['adjustment'] = $thisfile_mpc_header['album_gain_db'];
if ($thisfile_mpc_header['title_peak'] > 0) {
- $ThisFileInfo['replay_gain']['track']['peak'] = $thisfile_mpc_header['title_peak'];
+ $info['replay_gain']['track']['peak'] = $thisfile_mpc_header['title_peak'];
} elseif (round($thisfile_mpc_header['max_level'] * 1.18) > 0) {
- $ThisFileInfo['replay_gain']['track']['peak'] = getid3_lib::CastAsInt(round($thisfile_mpc_header['max_level'] * 1.18)); // why? I don't know - see mppdec.c
+ $info['replay_gain']['track']['peak'] = getid3_lib::CastAsInt(round($thisfile_mpc_header['max_level'] * 1.18)); // why? I don't know - see mppdec.c
}
if ($thisfile_mpc_header['album_peak'] > 0) {
- $ThisFileInfo['replay_gain']['album']['peak'] = $thisfile_mpc_header['album_peak'];
+ $info['replay_gain']['album']['peak'] = $thisfile_mpc_header['album_peak'];
}
- //$ThisFileInfo['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_version_major'].'.'.$thisfile_mpc_header['stream_version_minor'].', '.$thisfile_mpc_header['encoder_version'];
- $ThisFileInfo['audio']['encoder'] = $thisfile_mpc_header['encoder_version'];
- $ThisFileInfo['audio']['encoder_options'] = $thisfile_mpc_header['profile'];
+ //$info['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_version_major'].'.'.$thisfile_mpc_header['stream_version_minor'].', '.$thisfile_mpc_header['encoder_version'];
+ $info['audio']['encoder'] = $thisfile_mpc_header['encoder_version'];
+ $info['audio']['encoder_options'] = $thisfile_mpc_header['profile'];
$thisfile_mpc_header['quality'] = (float) ($thisfile_mpc_header['raw']['profile'] - 5); // values can range from 0 to 15, of which 0..4 are "reserved/experimental", and 5..15 are mapped to qualities of 0.0 to 10.0
return true;
}
- function ParseMPCsv6(&$fd, &$ThisFileInfo) {
+ function ParseMPCsv6() {
// this is SV4 - SV6
- $thisfile_mpc_header = &$ThisFileInfo['mpc']['header'];
+
+ $info = &$this->getid3->info;
+ $thisfile_mpc_header = &$info['mpc']['header'];
$offset = 0;
- $thisfile_mpc_header['size'] = 8;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $MPCheaderData = fread($fd, $thisfile_mpc_header['size']);
+ $thisfile_mpc_header['size'] = 8;
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $MPCheaderData = fread($this->getid3->fp, $thisfile_mpc_header['size']);
- // add size of file header to avdataoffset - calc bitrate correctly + MD5 data
- $ThisFileInfo['avdataoffset'] += $thisfile_mpc_header['size'];
+ // add size of file header to avdataoffset - calc bitrate correctly + MD5 data
+ $info['avdataoffset'] += $thisfile_mpc_header['size'];
// Most of this code adapted from Jurgen Faul's MPEGplus source code - thanks Jurgen! :)
$HeaderDWORD[0] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, 0, 4));
@@ -362,29 +369,29 @@ class getid3_mpc
break;
default:
- $ThisFileInfo['error'] = 'Expecting 4, 5 or 6 in version field, found '.$thisfile_mpc_header['stream_version_major'].' instead';
- unset($ThisFileInfo['mpc']);
+ $info['error'] = 'Expecting 4, 5 or 6 in version field, found '.$thisfile_mpc_header['stream_version_major'].' instead';
+ unset($info['mpc']);
return false;
break;
}
if (($thisfile_mpc_header['stream_version_major'] > 4) && ($thisfile_mpc_header['block_size'] != 1)) {
- $ThisFileInfo['warning'][] = 'Block size expected to be 1, actual value found: '.$thisfile_mpc_header['block_size'];
+ $info['warning'][] = 'Block size expected to be 1, actual value found: '.$thisfile_mpc_header['block_size'];
}
$thisfile_mpc_header['sample_rate'] = 44100; // AB: used by all files up to SV7
- $ThisFileInfo['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
- $thisfile_mpc_header['samples'] = $thisfile_mpc_header['frame_count'] * 1152 * $ThisFileInfo['audio']['channels'];
+ $info['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
+ $thisfile_mpc_header['samples'] = $thisfile_mpc_header['frame_count'] * 1152 * $info['audio']['channels'];
if ($thisfile_mpc_header['target_bitrate'] == 0) {
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
+ $info['audio']['bitrate_mode'] = 'vbr';
} else {
- $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
+ $info['audio']['bitrate_mode'] = 'cbr';
}
- $ThisFileInfo['mpc']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 * 44100 / $thisfile_mpc_header['frame_count'] / 1152;
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpc']['bitrate'];
- $ThisFileInfo['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_version_major'];
+ $info['mpc']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 * 44100 / $thisfile_mpc_header['frame_count'] / 1152;
+ $info['audio']['bitrate'] = $info['mpc']['bitrate'];
+ $info['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_version_major'];
return true;
}
diff --git a/3rdparty/getid3/module.audio.ogg.php b/3rdparty/getid3/module.audio.ogg.php
new file mode 100644
index 00000000000..c987fa67d70
--- /dev/null
+++ b/3rdparty/getid3/module.audio.ogg.php
@@ -0,0 +1,705 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.ogg.php //
+// module for analyzing Ogg Vorbis, OggFLAC and Speex files //
+// dependencies: module.audio.flac.php //
+// ///
+/////////////////////////////////////////////////////////////////
+
+getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.flac.php', __FILE__, true);
+
+class getid3_ogg extends getid3_handler
+{
+ var $inline_attachments = true; // true: return full data for all attachments; false: return no data for all attachments; integer: return data for attachments <= than this; string: save as file to this directory
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $info['fileformat'] = 'ogg';
+
+ // Warn about illegal tags - only vorbiscomments are allowed
+ if (isset($info['id3v2'])) {
+ $info['warning'][] = 'Illegal ID3v2 tag present.';
+ }
+ if (isset($info['id3v1'])) {
+ $info['warning'][] = 'Illegal ID3v1 tag present.';
+ }
+ if (isset($info['ape'])) {
+ $info['warning'][] = 'Illegal APE tag present.';
+ }
+
+
+ // Page 1 - Stream Header
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+
+ $oggpageinfo = $this->ParseOggPageHeader();
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
+
+ if (ftell($this->getid3->fp) >= $this->getid3->fread_buffer_size()) {
+ $info['error'][] = 'Could not find start of Ogg page in the first '.$this->getid3->fread_buffer_size().' bytes (this might not be an Ogg-Vorbis file?)';
+ unset($info['fileformat']);
+ unset($info['ogg']);
+ return false;
+ }
+
+ $filedata = fread($this->getid3->fp, $oggpageinfo['page_length']);
+ $filedataoffset = 0;
+
+ if (substr($filedata, 0, 4) == 'fLaC') {
+
+ $info['audio']['dataformat'] = 'flac';
+ $info['audio']['bitrate_mode'] = 'vbr';
+ $info['audio']['lossless'] = true;
+
+ } elseif (substr($filedata, 1, 6) == 'vorbis') {
+
+ $this->ParseVorbisPageHeader($filedata, $filedataoffset, $oggpageinfo);
+
+ } elseif (substr($filedata, 0, 8) == 'Speex ') {
+
+ // http://www.speex.org/manual/node10.html
+
+ $info['audio']['dataformat'] = 'speex';
+ $info['mime_type'] = 'audio/speex';
+ $info['audio']['bitrate_mode'] = 'abr';
+ $info['audio']['lossless'] = false;
+
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_string'] = substr($filedata, $filedataoffset, 8); // hard-coded to 'Speex '
+ $filedataoffset += 8;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version'] = substr($filedata, $filedataoffset, 20);
+ $filedataoffset += 20;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version_id'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['header_size'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode_bitstream_version'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['bitrate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['framesize'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['vbr'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['frames_per_packet'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['extra_headers'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['reserved1'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['reserved2'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+
+ $info['speex']['speex_version'] = trim($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version']);
+ $info['speex']['sample_rate'] = $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate'];
+ $info['speex']['channels'] = $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels'];
+ $info['speex']['vbr'] = (bool) $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['vbr'];
+ $info['speex']['band_type'] = $this->SpeexBandModeLookup($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode']);
+
+ $info['audio']['sample_rate'] = $info['speex']['sample_rate'];
+ $info['audio']['channels'] = $info['speex']['channels'];
+ if ($info['speex']['vbr']) {
+ $info['audio']['bitrate_mode'] = 'vbr';
+ }
+
+
+ } elseif (substr($filedata, 0, 8) == "fishead\x00") {
+
+ // Ogg Skeleton version 3.0 Format Specification
+ // http://xiph.org/ogg/doc/skeleton.html
+ $filedataoffset += 8;
+ $info['ogg']['skeleton']['fishead']['raw']['version_major'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2));
+ $filedataoffset += 2;
+ $info['ogg']['skeleton']['fishead']['raw']['version_minor'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2));
+ $filedataoffset += 2;
+ $info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
+ $filedataoffset += 8;
+ $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
+ $filedataoffset += 8;
+ $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
+ $filedataoffset += 8;
+ $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
+ $filedataoffset += 8;
+ $info['ogg']['skeleton']['fishead']['raw']['utc'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 20));
+ $filedataoffset += 20;
+
+ $info['ogg']['skeleton']['fishead']['version'] = $info['ogg']['skeleton']['fishead']['raw']['version_major'].'.'.$info['ogg']['skeleton']['fishead']['raw']['version_minor'];
+ $info['ogg']['skeleton']['fishead']['presentationtime'] = $info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'];
+ $info['ogg']['skeleton']['fishead']['basetime'] = $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator'];
+ $info['ogg']['skeleton']['fishead']['utc'] = $info['ogg']['skeleton']['fishead']['raw']['utc'];
+
+
+ $counter = 0;
+ do {
+ $oggpageinfo = $this->ParseOggPageHeader();
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno'].'.'.$counter++] = $oggpageinfo;
+ $filedata = fread($this->getid3->fp, $oggpageinfo['page_length']);
+ fseek($this->getid3->fp, $oggpageinfo['page_end_offset'], SEEK_SET);
+
+ if (substr($filedata, 0, 8) == "fisbone\x00") {
+
+ $filedataoffset = 8;
+ $info['ogg']['skeleton']['fisbone']['raw']['message_header_offset'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['skeleton']['fisbone']['raw']['serial_number'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['skeleton']['fisbone']['raw']['number_header_packets'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['skeleton']['fisbone']['raw']['granulerate_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
+ $filedataoffset += 8;
+ $info['ogg']['skeleton']['fisbone']['raw']['granulerate_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
+ $filedataoffset += 8;
+ $info['ogg']['skeleton']['fisbone']['raw']['basegranule'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
+ $filedataoffset += 8;
+ $info['ogg']['skeleton']['fisbone']['raw']['preroll'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['skeleton']['fisbone']['raw']['granuleshift'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
+ $filedataoffset += 1;
+ $info['ogg']['skeleton']['fisbone']['raw']['padding'] = substr($filedata, $filedataoffset, 3);
+ $filedataoffset += 3;
+
+ } elseif (substr($filedata, 1, 6) == 'theora') {
+
+ $info['video']['dataformat'] = 'theora';
+$info['error'][] = 'Ogg Theora not correctly handled in this version of getID3 ['.$this->getid3->version().']';
+//break;
+
+ } elseif (substr($filedata, 1, 6) == 'vorbis') {
+
+ $this->ParseVorbisPageHeader($filedata, $filedataoffset, $oggpageinfo);
+
+ } else {
+$info['error'][] = 'unexpected';
+//break;
+ }
+ //} while ($oggpageinfo['page_seqno'] == 0);
+ } while (($oggpageinfo['page_seqno'] == 0) && (substr($filedata, 0, 8) != "fisbone\x00"));
+ fseek($this->getid3->fp, $oggpageinfo['page_start_offset'], SEEK_SET);
+
+
+$info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3 ['.$this->getid3->version().']';
+//return false;
+
+
+ } else {
+
+ $info['error'][] = 'Expecting either "Speex " or "vorbis" identifier strings, found "'.substr($filedata, 0, 8).'"';
+ unset($info['ogg']);
+ unset($info['mime_type']);
+ return false;
+
+ }
+
+ // Page 2 - Comment Header
+ $oggpageinfo = $this->ParseOggPageHeader();
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
+
+ switch ($info['audio']['dataformat']) {
+ case 'vorbis':
+ $filedata = fread($this->getid3->fp, $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, 0, 1));
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 1, 6); // hard-coded to 'vorbis'
+
+ $this->ParseVorbisCommentsFilepointer();
+ break;
+
+ case 'flac':
+ $getid3_flac = new getid3_flac($this->getid3);
+ if (!$getid3_flac->FLACparseMETAdata()) {
+ $info['error'][] = 'Failed to parse FLAC headers';
+ return false;
+ }
+ unset($getid3_flac);
+ break;
+
+ case 'speex':
+ fseek($this->getid3->fp, $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length'], SEEK_CUR);
+ $this->ParseVorbisCommentsFilepointer();
+ break;
+
+ }
+
+
+
+ // Last Page - Number of Samples
+
+ if (!getid3_lib::intValueSupported($info['avdataend'])) {
+
+ $info['warning'][] = 'Unable to parse Ogg end chunk file (PHP does not support file operations beyond '.round(PHP_INT_MAX / 1073741824).'GB)';
+
+ } else {
+
+ fseek($this->getid3->fp, max($info['avdataend'] - $this->getid3->fread_buffer_size(), 0), SEEK_SET);
+ $LastChunkOfOgg = strrev(fread($this->getid3->fp, $this->getid3->fread_buffer_size()));
+ if ($LastOggSpostion = strpos($LastChunkOfOgg, 'SggO')) {
+ fseek($this->getid3->fp, $info['avdataend'] - ($LastOggSpostion + strlen('SggO')), SEEK_SET);
+ $info['avdataend'] = ftell($this->getid3->fp);
+ $info['ogg']['pageheader']['eos'] = $this->ParseOggPageHeader();
+ $info['ogg']['samples'] = $info['ogg']['pageheader']['eos']['pcm_abs_position'];
+ if ($info['ogg']['samples'] == 0) {
+ $info['error'][] = 'Corrupt Ogg file: eos.number of samples == zero';
+ return false;
+ }
+ if (!empty($info['audio']['sample_rate'])) {
+ $info['ogg']['bitrate_average'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['ogg']['samples'] / $info['audio']['sample_rate']);
+ }
+ }
+
+ }
+
+ if (!empty($info['ogg']['bitrate_average'])) {
+ $info['audio']['bitrate'] = $info['ogg']['bitrate_average'];
+ } elseif (!empty($info['ogg']['bitrate_nominal'])) {
+ $info['audio']['bitrate'] = $info['ogg']['bitrate_nominal'];
+ } elseif (!empty($info['ogg']['bitrate_min']) && !empty($info['ogg']['bitrate_max'])) {
+ $info['audio']['bitrate'] = ($info['ogg']['bitrate_min'] + $info['ogg']['bitrate_max']) / 2;
+ }
+ if (isset($info['audio']['bitrate']) && !isset($info['playtime_seconds'])) {
+ if ($info['audio']['bitrate'] == 0) {
+ $info['error'][] = 'Corrupt Ogg file: bitrate_audio == zero';
+ return false;
+ }
+ $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $info['audio']['bitrate']);
+ }
+
+ if (isset($info['ogg']['vendor'])) {
+ $info['audio']['encoder'] = preg_replace('/^Encoded with /', '', $info['ogg']['vendor']);
+
+ // Vorbis only
+ if ($info['audio']['dataformat'] == 'vorbis') {
+
+ // Vorbis 1.0 starts with Xiph.Org
+ if (preg_match('/^Xiph.Org/', $info['audio']['encoder'])) {
+
+ if ($info['audio']['bitrate_mode'] == 'abr') {
+
+ // Set -b 128 on abr files
+ $info['audio']['encoder_options'] = '-b '.round($info['ogg']['bitrate_nominal'] / 1000);
+
+ } elseif (($info['audio']['bitrate_mode'] == 'vbr') && ($info['audio']['channels'] == 2) && ($info['audio']['sample_rate'] >= 44100) && ($info['audio']['sample_rate'] <= 48000)) {
+ // Set -q N on vbr files
+ $info['audio']['encoder_options'] = '-q '.$this->get_quality_from_nominal_bitrate($info['ogg']['bitrate_nominal']);
+
+ }
+ }
+
+ if (empty($info['audio']['encoder_options']) && !empty($info['ogg']['bitrate_nominal'])) {
+ $info['audio']['encoder_options'] = 'Nominal bitrate: '.intval(round($info['ogg']['bitrate_nominal'] / 1000)).'kbps';
+ }
+ }
+ }
+
+ return true;
+ }
+
+ function ParseVorbisPageHeader(&$filedata, &$filedataoffset, &$oggpageinfo) {
+ $info = &$this->getid3->info;
+ $info['audio']['dataformat'] = 'vorbis';
+ $info['audio']['lossless'] = false;
+
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
+ $filedataoffset += 1;
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, $filedataoffset, 6); // hard-coded to 'vorbis'
+ $filedataoffset += 6;
+ $info['ogg']['bitstreamversion'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['numberofchannels'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
+ $filedataoffset += 1;
+ $info['audio']['channels'] = $info['ogg']['numberofchannels'];
+ $info['ogg']['samplerate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ if ($info['ogg']['samplerate'] == 0) {
+ $info['error'][] = 'Corrupt Ogg file: sample rate == zero';
+ return false;
+ }
+ $info['audio']['sample_rate'] = $info['ogg']['samplerate'];
+ $info['ogg']['samples'] = 0; // filled in later
+ $info['ogg']['bitrate_average'] = 0; // filled in later
+ $info['ogg']['bitrate_max'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['bitrate_nominal'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['bitrate_min'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $info['ogg']['blocksize_small'] = pow(2, getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0x0F);
+ $info['ogg']['blocksize_large'] = pow(2, (getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0xF0) >> 4);
+ $info['ogg']['stop_bit'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); // must be 1, marks end of packet
+
+ $info['audio']['bitrate_mode'] = 'vbr'; // overridden if actually abr
+ if ($info['ogg']['bitrate_max'] == 0xFFFFFFFF) {
+ unset($info['ogg']['bitrate_max']);
+ $info['audio']['bitrate_mode'] = 'abr';
+ }
+ if ($info['ogg']['bitrate_nominal'] == 0xFFFFFFFF) {
+ unset($info['ogg']['bitrate_nominal']);
+ }
+ if ($info['ogg']['bitrate_min'] == 0xFFFFFFFF) {
+ unset($info['ogg']['bitrate_min']);
+ $info['audio']['bitrate_mode'] = 'abr';
+ }
+ return true;
+ }
+
+ function ParseOggPageHeader() {
+ // http://xiph.org/ogg/vorbis/doc/framing.html
+ $oggheader['page_start_offset'] = ftell($this->getid3->fp); // where we started from in the file
+
+ $filedata = fread($this->getid3->fp, $this->getid3->fread_buffer_size());
+ $filedataoffset = 0;
+ while ((substr($filedata, $filedataoffset++, 4) != 'OggS')) {
+ if ((ftell($this->getid3->fp) - $oggheader['page_start_offset']) >= $this->getid3->fread_buffer_size()) {
+ // should be found before here
+ return false;
+ }
+ if ((($filedataoffset + 28) > strlen($filedata)) || (strlen($filedata) < 28)) {
+ if (feof($this->getid3->fp) || (($filedata .= fread($this->getid3->fp, $this->getid3->fread_buffer_size())) === false)) {
+ // get some more data, unless eof, in which case fail
+ return false;
+ }
+ }
+ }
+ $filedataoffset += strlen('OggS') - 1; // page, delimited by 'OggS'
+
+ $oggheader['stream_structver'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
+ $filedataoffset += 1;
+ $oggheader['flags_raw'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
+ $filedataoffset += 1;
+ $oggheader['flags']['fresh'] = (bool) ($oggheader['flags_raw'] & 0x01); // fresh packet
+ $oggheader['flags']['bos'] = (bool) ($oggheader['flags_raw'] & 0x02); // first page of logical bitstream (bos)
+ $oggheader['flags']['eos'] = (bool) ($oggheader['flags_raw'] & 0x04); // last page of logical bitstream (eos)
+
+ $oggheader['pcm_abs_position'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
+ $filedataoffset += 8;
+ $oggheader['stream_serialno'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $oggheader['page_seqno'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $oggheader['page_checksum'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
+ $filedataoffset += 4;
+ $oggheader['page_segments'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
+ $filedataoffset += 1;
+ $oggheader['page_length'] = 0;
+ for ($i = 0; $i < $oggheader['page_segments']; $i++) {
+ $oggheader['segment_table'][$i] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
+ $filedataoffset += 1;
+ $oggheader['page_length'] += $oggheader['segment_table'][$i];
+ }
+ $oggheader['header_end_offset'] = $oggheader['page_start_offset'] + $filedataoffset;
+ $oggheader['page_end_offset'] = $oggheader['header_end_offset'] + $oggheader['page_length'];
+ fseek($this->getid3->fp, $oggheader['header_end_offset'], SEEK_SET);
+
+ return $oggheader;
+ }
+
+
+ function ParseVorbisCommentsFilepointer() {
+ $info = &$this->getid3->info;
+
+ $OriginalOffset = ftell($this->getid3->fp);
+ $commentdataoffset = 0;
+ $VorbisCommentPage = 1;
+
+ switch ($info['audio']['dataformat']) {
+ case 'vorbis':
+ $CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block
+ fseek($this->getid3->fp, $CommentStartOffset, SEEK_SET);
+ $commentdataoffset = 27 + $info['ogg']['pageheader'][$VorbisCommentPage]['page_segments'];
+ $commentdata = fread($this->getid3->fp, getid3_ogg::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset);
+
+ $commentdataoffset += (strlen('vorbis') + 1);
+ break;
+
+ case 'flac':
+ $CommentStartOffset = $info['flac']['VORBIS_COMMENT']['raw']['offset'] + 4;
+ fseek($this->getid3->fp, $CommentStartOffset, SEEK_SET);
+ $commentdata = fread($this->getid3->fp, $info['flac']['VORBIS_COMMENT']['raw']['block_length']);
+ break;
+
+ case 'speex':
+ $CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block
+ fseek($this->getid3->fp, $CommentStartOffset, SEEK_SET);
+ $commentdataoffset = 27 + $info['ogg']['pageheader'][$VorbisCommentPage]['page_segments'];
+ $commentdata = fread($this->getid3->fp, getid3_ogg::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset);
+ break;
+
+ default:
+ return false;
+ break;
+ }
+
+ $VendorSize = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
+ $commentdataoffset += 4;
+
+ $info['ogg']['vendor'] = substr($commentdata, $commentdataoffset, $VendorSize);
+ $commentdataoffset += $VendorSize;
+
+ $CommentsCount = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
+ $commentdataoffset += 4;
+ $info['avdataoffset'] = $CommentStartOffset + $commentdataoffset;
+
+ $basicfields = array('TITLE', 'ARTIST', 'ALBUM', 'TRACKNUMBER', 'GENRE', 'DATE', 'DESCRIPTION', 'COMMENT');
+ $ThisFileInfo_ogg_comments_raw = &$info['ogg']['comments_raw'];
+ for ($i = 0; $i < $CommentsCount; $i++) {
+
+ $ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] = $CommentStartOffset + $commentdataoffset;
+
+ if (ftell($this->getid3->fp) < ($ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + 4)) {
+ if ($oggpageinfo = $this->ParseOggPageHeader()) {
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
+
+ $VorbisCommentPage++;
+
+ // First, save what we haven't read yet
+ $AsYetUnusedData = substr($commentdata, $commentdataoffset);
+
+ // Then take that data off the end
+ $commentdata = substr($commentdata, 0, $commentdataoffset);
+
+ // Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct
+ $commentdata .= str_repeat("\x00", 27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
+ $commentdataoffset += (27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
+
+ // Finally, stick the unused data back on the end
+ $commentdata .= $AsYetUnusedData;
+
+ //$commentdata .= fread($this->getid3->fp, $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
+ $commentdata .= fread($this->getid3->fp, $this->OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1));
+ }
+
+ }
+ $ThisFileInfo_ogg_comments_raw[$i]['size'] = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
+
+ // replace avdataoffset with position just after the last vorbiscomment
+ $info['avdataoffset'] = $ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + $ThisFileInfo_ogg_comments_raw[$i]['size'] + 4;
+
+ $commentdataoffset += 4;
+ while ((strlen($commentdata) - $commentdataoffset) < $ThisFileInfo_ogg_comments_raw[$i]['size']) {
+ if (($ThisFileInfo_ogg_comments_raw[$i]['size'] > $info['avdataend']) || ($ThisFileInfo_ogg_comments_raw[$i]['size'] < 0)) {
+ $info['warning'][] = 'Invalid Ogg comment size (comment #'.$i.', claims to be '.number_format($ThisFileInfo_ogg_comments_raw[$i]['size']).' bytes) - aborting reading comments';
+ break 2;
+ }
+
+ $VorbisCommentPage++;
+
+ $oggpageinfo = $this->ParseOggPageHeader();
+ $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
+
+ // First, save what we haven't read yet
+ $AsYetUnusedData = substr($commentdata, $commentdataoffset);
+
+ // Then take that data off the end
+ $commentdata = substr($commentdata, 0, $commentdataoffset);
+
+ // Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct
+ $commentdata .= str_repeat("\x00", 27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
+ $commentdataoffset += (27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
+
+ // Finally, stick the unused data back on the end
+ $commentdata .= $AsYetUnusedData;
+
+ //$commentdata .= fread($this->getid3->fp, $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
+ if (!isset($info['ogg']['pageheader'][$VorbisCommentPage])) {
+ $info['warning'][] = 'undefined Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.ftell($this->getid3->fp);
+ break;
+ }
+ $readlength = getid3_ogg::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1);
+ if ($readlength <= 0) {
+ $info['warning'][] = 'invalid length Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.ftell($this->getid3->fp);
+ break;
+ }
+ $commentdata .= fread($this->getid3->fp, $readlength);
+
+ //$filebaseoffset += $oggpageinfo['header_end_offset'] - $oggpageinfo['page_start_offset'];
+ }
+ $ThisFileInfo_ogg_comments_raw[$i]['offset'] = $commentdataoffset;
+ $commentstring = substr($commentdata, $commentdataoffset, $ThisFileInfo_ogg_comments_raw[$i]['size']);
+ $commentdataoffset += $ThisFileInfo_ogg_comments_raw[$i]['size'];
+
+ if (!$commentstring) {
+
+ // no comment?
+ $info['warning'][] = 'Blank Ogg comment ['.$i.']';
+
+ } elseif (strstr($commentstring, '=')) {
+
+ $commentexploded = explode('=', $commentstring, 2);
+ $ThisFileInfo_ogg_comments_raw[$i]['key'] = strtoupper($commentexploded[0]);
+ $ThisFileInfo_ogg_comments_raw[$i]['value'] = (isset($commentexploded[1]) ? $commentexploded[1] : '');
+ $ThisFileInfo_ogg_comments_raw[$i]['data'] = base64_decode($ThisFileInfo_ogg_comments_raw[$i]['value']);
+ $ThisFileInfo_ogg_comments_raw[$i]['data_length'] = strlen($ThisFileInfo_ogg_comments_raw[$i]['data']);
+
+ if (preg_match('#^(BM|GIF|\xFF\xD8\xFF|\x89\x50\x4E\x47\x0D\x0A\x1A\x0A|II\x2A\x00|MM\x00\x2A)#s', $ThisFileInfo_ogg_comments_raw[$i]['data'])) {
+ $imageinfo = array();
+ $imagechunkcheck = getid3_lib::GetDataImageSize($ThisFileInfo_ogg_comments_raw[$i]['data'], $imageinfo);
+ unset($imageinfo);
+ if (!empty($imagechunkcheck)) {
+ $ThisFileInfo_ogg_comments_raw[$i]['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
+ if ($ThisFileInfo_ogg_comments_raw[$i]['image_mime'] && ($ThisFileInfo_ogg_comments_raw[$i]['image_mime'] != 'application/octet-stream')) {
+ unset($ThisFileInfo_ogg_comments_raw[$i]['value']);
+ }
+ }
+ }
+
+ if (isset($ThisFileInfo_ogg_comments_raw[$i]['value'])) {
+ unset($ThisFileInfo_ogg_comments_raw[$i]['data']);
+ $info['ogg']['comments'][strtolower($ThisFileInfo_ogg_comments_raw[$i]['key'])][] = $ThisFileInfo_ogg_comments_raw[$i]['value'];
+ } else {
+ do {
+ if ($this->inline_attachments === false) {
+ // skip entirely
+ unset($ThisFileInfo_ogg_comments_raw[$i]['data']);
+ break;
+ }
+ if ($this->inline_attachments === true) {
+ // great
+ } elseif (is_int($this->inline_attachments)) {
+ if ($this->inline_attachments < $ThisFileInfo_ogg_comments_raw[$i]['data_length']) {
+ // too big, skip
+ $info['warning'][] = 'attachment at '.$ThisFileInfo_ogg_comments_raw[$i]['offset'].' is too large to process inline ('.number_format($ThisFileInfo_ogg_comments_raw[$i]['data_length']).' bytes)';
+ unset($ThisFileInfo_ogg_comments_raw[$i]['data']);
+ break;
+ }
+ } elseif (is_string($this->inline_attachments)) {
+ $this->inline_attachments = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->inline_attachments), DIRECTORY_SEPARATOR);
+ if (!is_dir($this->inline_attachments) || !is_writable($this->inline_attachments)) {
+ // cannot write, skip
+ $info['warning'][] = 'attachment at '.$ThisFileInfo_ogg_comments_raw[$i]['offset'].' cannot be saved to "'.$this->inline_attachments.'" (not writable)';
+ unset($ThisFileInfo_ogg_comments_raw[$i]['data']);
+ break;
+ }
+ }
+ // if we get this far, must be OK
+ if (is_string($this->inline_attachments)) {
+ $destination_filename = $this->inline_attachments.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$ThisFileInfo_ogg_comments_raw[$i]['offset'];
+ if (!file_exists($destination_filename) || is_writable($destination_filename)) {
+ file_put_contents($destination_filename, $ThisFileInfo_ogg_comments_raw[$i]['data']);
+ } else {
+ $info['warning'][] = 'attachment at '.$ThisFileInfo_ogg_comments_raw[$i]['offset'].' cannot be saved to "'.$destination_filename.'" (not writable)';
+ }
+ $ThisFileInfo_ogg_comments_raw[$i]['data_filename'] = $destination_filename;
+ unset($ThisFileInfo_ogg_comments_raw[$i]['data']);
+ } else {
+ $info['ogg']['comments']['picture'][] = array('data'=>$ThisFileInfo_ogg_comments_raw[$i]['data'], 'image_mime'=>$ThisFileInfo_ogg_comments_raw[$i]['image_mime']);
+ }
+ } while (false);
+
+ }
+
+
+ } else {
+
+ $info['warning'][] = '[known problem with CDex >= v1.40, < v1.50b7] Invalid Ogg comment name/value pair ['.$i.']: '.$commentstring;
+
+ }
+ }
+
+
+ // Replay Gain Adjustment
+ // http://privatewww.essex.ac.uk/~djmrob/replaygain/
+ if (isset($info['ogg']['comments']) && is_array($info['ogg']['comments'])) {
+ foreach ($info['ogg']['comments'] as $index => $commentvalue) {
+ switch ($index) {
+ case 'rg_audiophile':
+ case 'replaygain_album_gain':
+ $info['replay_gain']['album']['adjustment'] = (double) $commentvalue[0];
+ unset($info['ogg']['comments'][$index]);
+ break;
+
+ case 'rg_radio':
+ case 'replaygain_track_gain':
+ $info['replay_gain']['track']['adjustment'] = (double) $commentvalue[0];
+ unset($info['ogg']['comments'][$index]);
+ break;
+
+ case 'replaygain_album_peak':
+ $info['replay_gain']['album']['peak'] = (double) $commentvalue[0];
+ unset($info['ogg']['comments'][$index]);
+ break;
+
+ case 'rg_peak':
+ case 'replaygain_track_peak':
+ $info['replay_gain']['track']['peak'] = (double) $commentvalue[0];
+ unset($info['ogg']['comments'][$index]);
+ break;
+
+ case 'replaygain_reference_loudness':
+ $info['replay_gain']['reference_volume'] = (double) $commentvalue[0];
+ unset($info['ogg']['comments'][$index]);
+ break;
+
+ default:
+ // do nothing
+ break;
+ }
+ }
+ }
+
+ fseek($this->getid3->fp, $OriginalOffset, SEEK_SET);
+
+ return true;
+ }
+
+ static function SpeexBandModeLookup($mode) {
+ static $SpeexBandModeLookup = array();
+ if (empty($SpeexBandModeLookup)) {
+ $SpeexBandModeLookup[0] = 'narrow';
+ $SpeexBandModeLookup[1] = 'wide';
+ $SpeexBandModeLookup[2] = 'ultra-wide';
+ }
+ return (isset($SpeexBandModeLookup[$mode]) ? $SpeexBandModeLookup[$mode] : null);
+ }
+
+
+ static function OggPageSegmentLength($OggInfoArray, $SegmentNumber=1) {
+ for ($i = 0; $i < $SegmentNumber; $i++) {
+ $segmentlength = 0;
+ foreach ($OggInfoArray['segment_table'] as $key => $value) {
+ $segmentlength += $value;
+ if ($value < 255) {
+ break;
+ }
+ }
+ }
+ return $segmentlength;
+ }
+
+
+ static function get_quality_from_nominal_bitrate($nominal_bitrate) {
+
+ // decrease precision
+ $nominal_bitrate = $nominal_bitrate / 1000;
+
+ if ($nominal_bitrate < 128) {
+ // q-1 to q4
+ $qval = ($nominal_bitrate - 64) / 16;
+ } elseif ($nominal_bitrate < 256) {
+ // q4 to q8
+ $qval = $nominal_bitrate / 32;
+ } elseif ($nominal_bitrate < 320) {
+ // q8 to q9
+ $qval = ($nominal_bitrate + 256) / 64;
+ } else {
+ // q9 to q10
+ $qval = ($nominal_bitrate + 1300) / 180;
+ }
+ //return $qval; // 5.031324
+ //return intval($qval); // 5
+ return round($qval, 1); // 5 or 4.9
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.optimfrog.php b/3rdparty/getid3/module.audio.optimfrog.php
index 3c2dfb0bd2d..c1c89638376 100644
--- a/apps/media/getID3/getid3/module.audio.optimfrog.php
+++ b/3rdparty/getid3/module.audio.optimfrog.php
@@ -15,39 +15,42 @@
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
-class getid3_optimfrog
+class getid3_optimfrog extends getid3_handler
{
- function getid3_optimfrog(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'ofr';
- $ThisFileInfo['audio']['dataformat'] = 'ofr';
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
- $ThisFileInfo['audio']['lossless'] = true;
+ function Analyze() {
+ $info = &$this->getid3->info;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $OFRheader = fread($fd, 8);
+ $info['fileformat'] = 'ofr';
+ $info['audio']['dataformat'] = 'ofr';
+ $info['audio']['bitrate_mode'] = 'vbr';
+ $info['audio']['lossless'] = true;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $OFRheader = fread($this->getid3->fp, 8);
if (substr($OFRheader, 0, 5) == '*RIFF') {
- return $this->ParseOptimFROGheader42($fd, $ThisFileInfo);
+ return $this->ParseOptimFROGheader42();
} elseif (substr($OFRheader, 0, 3) == 'OFR') {
- return $this->ParseOptimFROGheader45($fd, $ThisFileInfo);
+ return $this->ParseOptimFROGheader45();
}
- $ThisFileInfo['error'][] = 'Expecting "*RIFF" or "OFR " at offset '.$ThisFileInfo['avdataoffset'].', found "'.$OFRheader.'"';
- unset($ThisFileInfo['fileformat']);
+ $info['error'][] = 'Expecting "*RIFF" or "OFR " at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($OFRheader).'"';
+ unset($info['fileformat']);
return false;
}
- function ParseOptimFROGheader42(&$fd, &$ThisFileInfo) {
+ function ParseOptimFROGheader42() {
// for fileformat of v4.21 and older
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $OptimFROGheaderData = fread($fd, 45);
- $ThisFileInfo['avdataoffset'] = 45;
+ $info = &$this->getid3->info;
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $OptimFROGheaderData = fread($this->getid3->fp, 45);
+ $info['avdataoffset'] = 45;
$OptimFROGencoderVersion_raw = getid3_lib::LittleEndian2Int(substr($OptimFROGheaderData, 0, 1));
$OptimFROGencoderVersion_major = floor($OptimFROGencoderVersion_raw / 10);
@@ -57,36 +60,46 @@ class getid3_optimfrog
$OrignalRIFFdataSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 40, 4)) + 44;
if ($OrignalRIFFheaderSize > $OrignalRIFFdataSize) {
- $ThisFileInfo['avdataend'] -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
- fseek($fd, $ThisFileInfo['avdataend'], SEEK_SET);
- $RIFFdata .= fread($fd, $OrignalRIFFheaderSize - $OrignalRIFFdataSize);
+ $info['avdataend'] -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
+ fseek($this->getid3->fp, $info['avdataend'], SEEK_SET);
+ $RIFFdata .= fread($this->getid3->fp, $OrignalRIFFheaderSize - $OrignalRIFFdataSize);
}
// move the data chunk after all other chunks (if any)
// so that the RIFF parser doesn't see EOF when trying
// to skip over the data chunk
$RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8);
- getid3_riff::ParseRIFFdata($RIFFdata, $ThisFileInfo);
- $ThisFileInfo['audio']['encoder'] = 'OptimFROG '.$OptimFROGencoderVersion_major.'.'.$OptimFROGencoderVersion_minor;
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['riff']['audio'][0]['channels'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['riff']['audio'][0]['sample_rate'];
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['riff']['audio'][0]['bits_per_sample'];
- $ThisFileInfo['playtime_seconds'] = $OrignalRIFFdataSize / ($ThisFileInfo['audio']['channels'] * $ThisFileInfo['audio']['sample_rate'] * ($ThisFileInfo['audio']['bits_per_sample'] / 8));
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
+ $getid3_temp->info['avdataend'] = $info['avdataend'];
+ $getid3_riff = new getid3_riff($getid3_temp);
+ $getid3_riff->ParseRIFFdata($RIFFdata);
+ $info['riff'] = $getid3_temp->info['riff'];
+
+ $info['audio']['encoder'] = 'OptimFROG '.$OptimFROGencoderVersion_major.'.'.$OptimFROGencoderVersion_minor;
+ $info['audio']['channels'] = $info['riff']['audio'][0]['channels'];
+ $info['audio']['sample_rate'] = $info['riff']['audio'][0]['sample_rate'];
+ $info['audio']['bits_per_sample'] = $info['riff']['audio'][0]['bits_per_sample'];
+ $info['playtime_seconds'] = $OrignalRIFFdataSize / ($info['audio']['channels'] * $info['audio']['sample_rate'] * ($info['audio']['bits_per_sample'] / 8));
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+
+ unset($getid3_riff, $getid3_temp, $RIFFdata);
return true;
}
- function ParseOptimFROGheader45(&$fd, &$ThisFileInfo) {
+ function ParseOptimFROGheader45() {
// for fileformat of v4.50a and higher
+ $info = &$this->getid3->info;
$RIFFdata = '';
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- while (!feof($fd) && (ftell($fd) < $ThisFileInfo['avdataend'])) {
- $BlockOffset = ftell($fd);
- $BlockData = fread($fd, 8);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ while (!feof($this->getid3->fp) && (ftell($this->getid3->fp) < $info['avdataend'])) {
+ $BlockOffset = ftell($this->getid3->fp);
+ $BlockData = fread($this->getid3->fp, 8);
$offset = 8;
$BlockName = substr($BlockData, 0, 4);
$BlockSize = getid3_lib::LittleEndian2Int(substr($BlockData, 4, 4));
@@ -94,10 +107,10 @@ class getid3_optimfrog
if ($BlockName == 'OFRX') {
$BlockName = 'OFR ';
}
- if (!isset($ThisFileInfo['ofr'][$BlockName])) {
- $ThisFileInfo['ofr'][$BlockName] = array();
+ if (!isset($info['ofr'][$BlockName])) {
+ $info['ofr'][$BlockName] = array();
}
- $thisfile_ofr_thisblock = &$ThisFileInfo['ofr'][$BlockName];
+ $thisfile_ofr_thisblock = &$info['ofr'][$BlockName];
switch ($BlockName) {
case 'OFR ':
@@ -106,7 +119,7 @@ class getid3_optimfrog
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
- $ThisFileInfo['audio']['encoder'] = 'OptimFROG 4.50 alpha';
+ $info['audio']['encoder'] = 'OptimFROG 4.50 alpha';
switch ($BlockSize) {
case 12:
case 15:
@@ -114,10 +127,10 @@ class getid3_optimfrog
break;
default:
- $ThisFileInfo['warning'][] = '"'.$BlockName.'" contains more data than expected (expected 12 or 15 bytes, found '.$BlockSize.' bytes)';
+ $info['warning'][] = '"'.$BlockName.'" contains more data than expected (expected 12 or 15 bytes, found '.$BlockSize.' bytes)';
break;
}
- $BlockData .= fread($fd, $BlockSize);
+ $BlockData .= fread($this->getid3->fp, $BlockSize);
$thisfile_ofr_thisblock['total_samples'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 6));
$offset += 6;
@@ -142,23 +155,23 @@ class getid3_optimfrog
$thisfile_ofr_thisblock['speedup'] = $this->OptimFROGspeedupLookup($thisfile_ofr_thisblock['raw']['compression']);
$offset += 1;
- $ThisFileInfo['audio']['encoder'] = 'OptimFROG '.$thisfile_ofr_thisblock['encoder'];
- $ThisFileInfo['audio']['encoder_options'] = '--mode '.$thisfile_ofr_thisblock['compression'];
+ $info['audio']['encoder'] = 'OptimFROG '.$thisfile_ofr_thisblock['encoder'];
+ $info['audio']['encoder_options'] = '--mode '.$thisfile_ofr_thisblock['compression'];
if ((($thisfile_ofr_thisblock['raw']['encoder_id'] & 0xF0) >> 4) == 7) { // v4.507
- if (strtolower(getid3_lib::fileextension($ThisFileInfo['filename'])) == 'ofs') {
+ if (strtolower(getid3_lib::fileextension($info['filename'])) == 'ofs') {
// OptimFROG DualStream format is lossy, but as of v4.507 there is no way to tell the difference
// between lossless and lossy other than the file extension.
- $ThisFileInfo['audio']['dataformat'] = 'ofs';
- $ThisFileInfo['audio']['lossless'] = true;
+ $info['audio']['dataformat'] = 'ofs';
+ $info['audio']['lossless'] = true;
}
}
}
- $ThisFileInfo['audio']['channels'] = $thisfile_ofr_thisblock['channels'];
- $ThisFileInfo['audio']['sample_rate'] = $thisfile_ofr_thisblock['sample_rate'];
- $ThisFileInfo['audio']['bits_per_sample'] = $this->OptimFROGbitsPerSampleTypeLookup($thisfile_ofr_thisblock['raw']['sample_type']);
+ $info['audio']['channels'] = $thisfile_ofr_thisblock['channels'];
+ $info['audio']['sample_rate'] = $thisfile_ofr_thisblock['sample_rate'];
+ $info['audio']['bits_per_sample'] = $this->OptimFROGbitsPerSampleTypeLookup($thisfile_ofr_thisblock['raw']['sample_type']);
break;
@@ -168,13 +181,13 @@ class getid3_optimfrog
$COMPdata['offset'] = $BlockOffset;
$COMPdata['size'] = $BlockSize;
- if ($ThisFileInfo['avdataoffset'] == 0) {
- $ThisFileInfo['avdataoffset'] = $BlockOffset;
+ if ($info['avdataoffset'] == 0) {
+ $info['avdataoffset'] = $BlockOffset;
}
// Only interested in first 14 bytes (only first 12 needed for v4.50 alpha), not actual audio data
- $BlockData .= fread($fd, 14);
- fseek($fd, $BlockSize - 14, SEEK_CUR);
+ $BlockData .= fread($this->getid3->fp, 14);
+ fseek($this->getid3->fp, $BlockSize - 14, SEEK_CUR);
$COMPdata['crc_32'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 4));
$offset += 4;
@@ -190,7 +203,7 @@ class getid3_optimfrog
//$COMPdata['algorithm'] = OptimFROGalgorithmNameLookup($COMPdata['raw']['algorithm_id']);
$offset += 2;
- if ($ThisFileInfo['ofr']['OFR ']['size'] > 12) {
+ if ($info['ofr']['OFR ']['size'] > 12) {
// OFR 4.504b or higher
$COMPdata['raw']['encoder_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 2));
@@ -211,7 +224,7 @@ class getid3_optimfrog
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
- $RIFFdata .= fread($fd, $BlockSize);
+ $RIFFdata .= fread($this->getid3->fp, $BlockSize);
break;
case 'TAIL':
@@ -219,7 +232,7 @@ class getid3_optimfrog
$thisfile_ofr_thisblock['size'] = $BlockSize;
if ($BlockSize > 0) {
- $RIFFdata .= fread($fd, $BlockSize);
+ $RIFFdata .= fread($this->getid3->fp, $BlockSize);
}
break;
@@ -229,7 +242,7 @@ class getid3_optimfrog
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
- fseek($fd, $BlockSize, SEEK_CUR);
+ fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
break;
@@ -238,9 +251,9 @@ class getid3_optimfrog
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
- $ThisFileInfo['warning'][] = 'APEtag processing inside OptimFROG not supported in this version ('.GETID3_VERSION.') of getID3()';
+ $info['warning'][] = 'APEtag processing inside OptimFROG not supported in this version ('.$this->getid3->version().') of getID3()';
- fseek($fd, $BlockSize, SEEK_CUR);
+ fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
break;
@@ -252,14 +265,14 @@ class getid3_optimfrog
if ($BlockSize == 16) {
- $thisfile_ofr_thisblock['md5_binary'] = fread($fd, $BlockSize);
+ $thisfile_ofr_thisblock['md5_binary'] = fread($this->getid3->fp, $BlockSize);
$thisfile_ofr_thisblock['md5_string'] = getid3_lib::PrintHexBytes($thisfile_ofr_thisblock['md5_binary'], true, false, false);
- $ThisFileInfo['md5_data_source'] = $thisfile_ofr_thisblock['md5_string'];
+ $info['md5_data_source'] = $thisfile_ofr_thisblock['md5_string'];
} else {
- $ThisFileInfo['warning'][] = 'Expecting block size of 16 in "MD5 " chunk, found '.$BlockSize.' instead';
- fseek($fd, $BlockSize, SEEK_CUR);
+ $info['warning'][] = 'Expecting block size of 16 in "MD5 " chunk, found '.$BlockSize.' instead';
+ fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
}
break;
@@ -269,29 +282,38 @@ class getid3_optimfrog
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
- $ThisFileInfo['warning'][] = 'Unhandled OptimFROG block type "'.$BlockName.'" at offset '.$thisfile_ofr_thisblock['offset'];
- fseek($fd, $BlockSize, SEEK_CUR);
+ $info['warning'][] = 'Unhandled OptimFROG block type "'.$BlockName.'" at offset '.$thisfile_ofr_thisblock['offset'];
+ fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
break;
}
}
- if (isset($ThisFileInfo['ofr']['TAIL']['offset'])) {
- $ThisFileInfo['avdataend'] = $ThisFileInfo['ofr']['TAIL']['offset'];
+ if (isset($info['ofr']['TAIL']['offset'])) {
+ $info['avdataend'] = $info['ofr']['TAIL']['offset'];
}
- $ThisFileInfo['playtime_seconds'] = (float) $ThisFileInfo['ofr']['OFR ']['total_samples'] / ($ThisFileInfo['audio']['channels'] * $ThisFileInfo['audio']['sample_rate']);
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
+ $info['playtime_seconds'] = (float) $info['ofr']['OFR ']['total_samples'] / ($info['audio']['channels'] * $info['audio']['sample_rate']);
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
// move the data chunk after all other chunks (if any)
// so that the RIFF parser doesn't see EOF when trying
// to skip over the data chunk
$RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8);
- getid3_riff::ParseRIFFdata($RIFFdata, $ThisFileInfo);
+
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
+ $getid3_temp->info['avdataend'] = $info['avdataend'];
+ $getid3_riff = new getid3_riff($getid3_temp);
+ $getid3_riff->ParseRIFFdata($RIFFdata);
+ $info['riff'] = $getid3_temp->info['riff'];
+
+ unset($getid3_riff, $getid3_temp, $RIFFdata);
return true;
}
- function OptimFROGsampleTypeLookup($SampleType) {
+ static function OptimFROGsampleTypeLookup($SampleType) {
static $OptimFROGsampleTypeLookup = array(
0 => 'unsigned int (8-bit)',
1 => 'signed int (8-bit)',
@@ -308,7 +330,7 @@ class getid3_optimfrog
return (isset($OptimFROGsampleTypeLookup[$SampleType]) ? $OptimFROGsampleTypeLookup[$SampleType] : false);
}
- function OptimFROGbitsPerSampleTypeLookup($SampleType) {
+ static function OptimFROGbitsPerSampleTypeLookup($SampleType) {
static $OptimFROGbitsPerSampleTypeLookup = array(
0 => 8,
1 => 8,
@@ -325,7 +347,7 @@ class getid3_optimfrog
return (isset($OptimFROGbitsPerSampleTypeLookup[$SampleType]) ? $OptimFROGbitsPerSampleTypeLookup[$SampleType] : false);
}
- function OptimFROGchannelConfigurationLookup($ChannelConfiguration) {
+ static function OptimFROGchannelConfigurationLookup($ChannelConfiguration) {
static $OptimFROGchannelConfigurationLookup = array(
0 => 'mono',
1 => 'stereo'
@@ -333,7 +355,7 @@ class getid3_optimfrog
return (isset($OptimFROGchannelConfigurationLookup[$ChannelConfiguration]) ? $OptimFROGchannelConfigurationLookup[$ChannelConfiguration] : false);
}
- function OptimFROGchannelConfigNumChannelsLookup($ChannelConfiguration) {
+ static function OptimFROGchannelConfigNumChannelsLookup($ChannelConfiguration) {
static $OptimFROGchannelConfigNumChannelsLookup = array(
0 => 1,
1 => 2
@@ -343,13 +365,13 @@ class getid3_optimfrog
- // function OptimFROGalgorithmNameLookup($AlgorithID) {
+ // static function OptimFROGalgorithmNameLookup($AlgorithID) {
// static $OptimFROGalgorithmNameLookup = array();
// return (isset($OptimFROGalgorithmNameLookup[$AlgorithID]) ? $OptimFROGalgorithmNameLookup[$AlgorithID] : false);
// }
- function OptimFROGencoderNameLookup($EncoderID) {
+ static function OptimFROGencoderNameLookup($EncoderID) {
// version = (encoderID >> 4) + 4500
// system = encoderID & 0xF
@@ -364,7 +386,7 @@ class getid3_optimfrog
return $EncoderVersion.' ('.(isset($OptimFROGencoderSystemLookup[$EncoderSystemID]) ? $OptimFROGencoderSystemLookup[$EncoderSystemID] : 'undefined encoder type (0x'.dechex($EncoderSystemID).')').')';
}
- function OptimFROGcompressionLookup($CompressionID) {
+ static function OptimFROGcompressionLookup($CompressionID) {
// mode = compression >> 3
// speedup = compression & 0x07
@@ -386,7 +408,7 @@ class getid3_optimfrog
return (isset($OptimFROGencoderModeLookup[$CompressionModeID]) ? $OptimFROGencoderModeLookup[$CompressionModeID] : 'undefined mode (0x'.str_pad(dechex($CompressionModeID), 2, '0', STR_PAD_LEFT).')');
}
- function OptimFROGspeedupLookup($CompressionID) {
+ static function OptimFROGspeedupLookup($CompressionID) {
// mode = compression >> 3
// speedup = compression & 0x07
@@ -398,7 +420,6 @@ class getid3_optimfrog
0x01 => '2x',
0x02 => '4x'
);
-
return (isset($OptimFROGencoderSpeedupLookup[$CompressionSpeedupID]) ? $OptimFROGencoderSpeedupLookup[$CompressionSpeedupID] : 'undefined mode (0x'.dechex($CompressionSpeedupID));
}
diff --git a/3rdparty/getid3/module.audio.rkau.php b/3rdparty/getid3/module.audio.rkau.php
new file mode 100644
index 00000000000..c442076275d
--- /dev/null
+++ b/3rdparty/getid3/module.audio.rkau.php
@@ -0,0 +1,94 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.shorten.php //
+// module for analyzing Shorten Audio files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_rkau extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $RKAUHeader = fread($this->getid3->fp, 20);
+ $magic = 'RKA';
+ if (substr($RKAUHeader, 0, 3) != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($RKAUHeader, 0, 3)).'"';
+ return false;
+ }
+
+ $info['fileformat'] = 'rkau';
+ $info['audio']['dataformat'] = 'rkau';
+ $info['audio']['bitrate_mode'] = 'vbr';
+
+ $info['rkau']['raw']['version'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 3, 1));
+ $info['rkau']['version'] = '1.'.str_pad($info['rkau']['raw']['version'] & 0x0F, 2, '0', STR_PAD_LEFT);
+ if (($info['rkau']['version'] > 1.07) || ($info['rkau']['version'] < 1.06)) {
+ $info['error'][] = 'This version of getID3() ['.$this->getid3->version().'] can only parse RKAU files v1.06 and 1.07 (this file is v'.$info['rkau']['version'].')';
+ unset($info['rkau']);
+ return false;
+ }
+
+ $info['rkau']['source_bytes'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 4, 4));
+ $info['rkau']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 8, 4));
+ $info['rkau']['channels'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 12, 1));
+ $info['rkau']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 13, 1));
+
+ $info['rkau']['raw']['quality'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 14, 1));
+ $this->RKAUqualityLookup($info['rkau']);
+
+ $info['rkau']['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 15, 1));
+ $info['rkau']['flags']['joint_stereo'] = (bool) (!($info['rkau']['raw']['flags'] & 0x01));
+ $info['rkau']['flags']['streaming'] = (bool) ($info['rkau']['raw']['flags'] & 0x02);
+ $info['rkau']['flags']['vrq_lossy_mode'] = (bool) ($info['rkau']['raw']['flags'] & 0x04);
+
+ if ($info['rkau']['flags']['streaming']) {
+ $info['avdataoffset'] += 20;
+ $info['rkau']['compressed_bytes'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 16, 4));
+ } else {
+ $info['avdataoffset'] += 16;
+ $info['rkau']['compressed_bytes'] = $info['avdataend'] - $info['avdataoffset'] - 1;
+ }
+ // Note: compressed_bytes does not always equal what appears to be the actual number of compressed bytes,
+ // sometimes it's more, sometimes less. No idea why(?)
+
+ $info['audio']['lossless'] = $info['rkau']['lossless'];
+ $info['audio']['channels'] = $info['rkau']['channels'];
+ $info['audio']['bits_per_sample'] = $info['rkau']['bits_per_sample'];
+ $info['audio']['sample_rate'] = $info['rkau']['sample_rate'];
+
+ $info['playtime_seconds'] = $info['rkau']['source_bytes'] / ($info['rkau']['sample_rate'] * $info['rkau']['channels'] * ($info['rkau']['bits_per_sample'] / 8));
+ $info['audio']['bitrate'] = ($info['rkau']['compressed_bytes'] * 8) / $info['playtime_seconds'];
+
+ return true;
+
+ }
+
+
+ function RKAUqualityLookup(&$RKAUdata) {
+ $level = ($RKAUdata['raw']['quality'] & 0xF0) >> 4;
+ $quality = $RKAUdata['raw']['quality'] & 0x0F;
+
+ $RKAUdata['lossless'] = (($quality == 0) ? true : false);
+ $RKAUdata['compression_level'] = $level + 1;
+ if (!$RKAUdata['lossless']) {
+ $RKAUdata['quality_setting'] = $quality;
+ }
+
+ return true;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.shorten.php b/3rdparty/getid3/module.audio.shorten.php
index a9eb1ab1ccd..7b3d312ea28 100644
--- a/apps/media/getID3/getid3/module.audio.shorten.php
+++ b/3rdparty/getid3/module.audio.shorten.php
@@ -14,36 +14,39 @@
/////////////////////////////////////////////////////////////////
-class getid3_shorten
+class getid3_shorten extends getid3_handler
{
- function getid3_shorten(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
- $ShortenHeader = fread($fd, 8);
- if (substr($ShortenHeader, 0, 4) != 'ajkg') {
- $ThisFileInfo['error'][] = 'Expecting "ajkg" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($ShortenHeader, 0, 4).'"';
+ $ShortenHeader = fread($this->getid3->fp, 8);
+ $magic = 'ajkg';
+ if (substr($ShortenHeader, 0, 4) != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($ShortenHeader, 0, 4)).'"';
return false;
}
- $ThisFileInfo['fileformat'] = 'shn';
- $ThisFileInfo['audio']['dataformat'] = 'shn';
- $ThisFileInfo['audio']['lossless'] = true;
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
-
- $ThisFileInfo['shn']['version'] = getid3_lib::LittleEndian2Int(substr($ShortenHeader, 4, 1));
-
- fseek($fd, $ThisFileInfo['avdataend'] - 12, SEEK_SET);
- $SeekTableSignatureTest = fread($fd, 12);
- $ThisFileInfo['shn']['seektable']['present'] = (bool) (substr($SeekTableSignatureTest, 4, 8) == 'SHNAMPSK');
- if ($ThisFileInfo['shn']['seektable']['present']) {
- $ThisFileInfo['shn']['seektable']['length'] = getid3_lib::LittleEndian2Int(substr($SeekTableSignatureTest, 0, 4));
- $ThisFileInfo['shn']['seektable']['offset'] = $ThisFileInfo['avdataend'] - $ThisFileInfo['shn']['seektable']['length'];
- fseek($fd, $ThisFileInfo['shn']['seektable']['offset'], SEEK_SET);
- $SeekTableMagic = fread($fd, 4);
- if ($SeekTableMagic != 'SEEK') {
-
- $ThisFileInfo['error'][] = 'Expecting "SEEK" at offset '.$ThisFileInfo['shn']['seektable']['offset'].', found "'.$SeekTableMagic.'"';
+ $info['fileformat'] = 'shn';
+ $info['audio']['dataformat'] = 'shn';
+ $info['audio']['lossless'] = true;
+ $info['audio']['bitrate_mode'] = 'vbr';
+
+ $info['shn']['version'] = getid3_lib::LittleEndian2Int(substr($ShortenHeader, 4, 1));
+
+ fseek($this->getid3->fp, $info['avdataend'] - 12, SEEK_SET);
+ $SeekTableSignatureTest = fread($this->getid3->fp, 12);
+ $info['shn']['seektable']['present'] = (bool) (substr($SeekTableSignatureTest, 4, 8) == 'SHNAMPSK');
+ if ($info['shn']['seektable']['present']) {
+ $info['shn']['seektable']['length'] = getid3_lib::LittleEndian2Int(substr($SeekTableSignatureTest, 0, 4));
+ $info['shn']['seektable']['offset'] = $info['avdataend'] - $info['shn']['seektable']['length'];
+ fseek($this->getid3->fp, $info['shn']['seektable']['offset'], SEEK_SET);
+ $SeekTableMagic = fread($this->getid3->fp, 4);
+ $magic = 'SEEK';
+ if ($SeekTableMagic != $magic) {
+
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['shn']['seektable']['offset'].', found "'.getid3_lib::PrintHexBytes($SeekTableMagic).'"';
return false;
} else {
@@ -64,11 +67,11 @@ class getid3_shorten
// long Offset1[4];
// }TSeekEntry;
- $SeekTableData = fread($fd, $ThisFileInfo['shn']['seektable']['length'] - 16);
- $ThisFileInfo['shn']['seektable']['entry_count'] = floor(strlen($SeekTableData) / 80);
- //$ThisFileInfo['shn']['seektable']['entries'] = array();
+ $SeekTableData = fread($this->getid3->fp, $info['shn']['seektable']['length'] - 16);
+ $info['shn']['seektable']['entry_count'] = floor(strlen($SeekTableData) / 80);
+ //$info['shn']['seektable']['entries'] = array();
//$SeekTableOffset = 0;
- //for ($i = 0; $i < $ThisFileInfo['shn']['seektable']['entry_count']; $i++) {
+ //for ($i = 0; $i < $info['shn']['seektable']['entry_count']; $i++) {
// $SeekTableEntry['sample_number'] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
// $SeekTableOffset += 4;
// $SeekTableEntry['shn_file_byte_offset'] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
@@ -101,16 +104,16 @@ class getid3_shorten
// $SeekTableEntry['offset1'][$j] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
// $SeekTableOffset += 4;
// }
- //
- // $ThisFileInfo['shn']['seektable']['entries'][] = $SeekTableEntry;
+ //
+ // $info['shn']['seektable']['entries'][] = $SeekTableEntry;
//}
}
}
- if ((bool) ini_get('safe_mode')) {
- $ThisFileInfo['error'][] = 'PHP running in Safe Mode - backtick operator not available, cannot run shntool to analyze Shorten files';
+ if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
+ $info['error'][] = 'PHP running in Safe Mode - backtick operator not available, cannot run shntool to analyze Shorten files';
return false;
}
@@ -119,24 +122,24 @@ class getid3_shorten
$RequiredFiles = array('shorten.exe', 'cygwin1.dll', 'head.exe');
foreach ($RequiredFiles as $required_file) {
if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
- $ThisFileInfo['error'][] = GETID3_HELPERAPPSDIR.$required_file.' does not exist';
+ $info['error'][] = GETID3_HELPERAPPSDIR.$required_file.' does not exist';
return false;
}
}
- $commandline = GETID3_HELPERAPPSDIR.'shorten.exe -x "'.$ThisFileInfo['filenamepath'].'" - | '.GETID3_HELPERAPPSDIR.'head.exe -c 64';
+ $commandline = GETID3_HELPERAPPSDIR.'shorten.exe -x "'.$info['filenamepath'].'" - | '.GETID3_HELPERAPPSDIR.'head.exe -c 64';
$commandline = str_replace('/', '\\', $commandline);
} else {
- static $shorten_present;
- if (!isset($shorten_present)) {
- $shorten_present = file_exists('/usr/local/bin/shorten') || `which shorten`;
- }
- if (!$shorten_present) {
- $ThisFileInfo['error'][] = 'shorten binary was not found in path or /usr/local/bin';
- return false;
- }
- $commandline = (file_exists('/usr/local/bin/shorten') ? '/usr/local/bin/' : '' ) . 'shorten -x '.escapeshellarg($ThisFileInfo['filenamepath']).' - | head -c 64';
+ static $shorten_present;
+ if (!isset($shorten_present)) {
+ $shorten_present = file_exists('/usr/local/bin/shorten') || `which shorten`;
+ }
+ if (!$shorten_present) {
+ $info['error'][] = 'shorten binary was not found in path or /usr/local/bin';
+ return false;
+ }
+ $commandline = (file_exists('/usr/local/bin/shorten') ? '/usr/local/bin/' : '' ) . 'shorten -x '.escapeshellarg($info['filenamepath']).' - | head -c 64';
}
@@ -148,26 +151,26 @@ class getid3_shorten
$fmt_size = getid3_lib::LittleEndian2Int(substr($output, 16, 4));
$DecodedWAVFORMATEX = getid3_riff::RIFFparseWAVEFORMATex(substr($output, 20, $fmt_size));
- $ThisFileInfo['audio']['channels'] = $DecodedWAVFORMATEX['channels'];
- $ThisFileInfo['audio']['bits_per_sample'] = $DecodedWAVFORMATEX['bits_per_sample'];
- $ThisFileInfo['audio']['sample_rate'] = $DecodedWAVFORMATEX['sample_rate'];
+ $info['audio']['channels'] = $DecodedWAVFORMATEX['channels'];
+ $info['audio']['bits_per_sample'] = $DecodedWAVFORMATEX['bits_per_sample'];
+ $info['audio']['sample_rate'] = $DecodedWAVFORMATEX['sample_rate'];
if (substr($output, 20 + $fmt_size, 4) == 'data') {
- $ThisFileInfo['playtime_seconds'] = getid3_lib::LittleEndian2Int(substr($output, 20 + 4 + $fmt_size, 4)) / $DecodedWAVFORMATEX['raw']['nAvgBytesPerSec'];
+ $info['playtime_seconds'] = getid3_lib::LittleEndian2Int(substr($output, 20 + 4 + $fmt_size, 4)) / $DecodedWAVFORMATEX['raw']['nAvgBytesPerSec'];
} else {
- $ThisFileInfo['error'][] = 'shorten failed to decode DATA chunk to expected location, cannot determine playtime';
+ $info['error'][] = 'shorten failed to decode DATA chunk to expected location, cannot determine playtime';
return false;
}
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) / $ThisFileInfo['playtime_seconds']) * 8;
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8;
} else {
- $ThisFileInfo['error'][] = 'shorten failed to decode file to WAV for parsing';
+ $info['error'][] = 'shorten failed to decode file to WAV for parsing';
return false;
}
diff --git a/3rdparty/getid3/module.audio.tta.php b/3rdparty/getid3/module.audio.tta.php
new file mode 100644
index 00000000000..1c646ee6768
--- /dev/null
+++ b/3rdparty/getid3/module.audio.tta.php
@@ -0,0 +1,109 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.tta.php //
+// module for analyzing TTA Audio files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_tta extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $info['fileformat'] = 'tta';
+ $info['audio']['dataformat'] = 'tta';
+ $info['audio']['lossless'] = true;
+ $info['audio']['bitrate_mode'] = 'vbr';
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $ttaheader = fread($this->getid3->fp, 26);
+
+ $info['tta']['magic'] = substr($ttaheader, 0, 3);
+ $magic = 'TTA';
+ if ($info['tta']['magic'] != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['tta']['magic']).'"';
+ unset($info['fileformat']);
+ unset($info['audio']);
+ unset($info['tta']);
+ return false;
+ }
+
+ switch ($ttaheader{3}) {
+ case "\x01": // TTA v1.x
+ case "\x02": // TTA v1.x
+ case "\x03": // TTA v1.x
+ // "It was the demo-version of the TTA encoder. There is no released format with such header. TTA encoder v1 is not supported about a year."
+ $info['tta']['major_version'] = 1;
+ $info['avdataoffset'] += 16;
+
+ $info['tta']['compression_level'] = ord($ttaheader{3});
+ $info['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2));
+ $info['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
+ $info['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 4));
+ $info['tta']['samples_per_channel'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12, 4));
+
+ $info['audio']['encoder_options'] = '-e'.$info['tta']['compression_level'];
+ $info['playtime_seconds'] = $info['tta']['samples_per_channel'] / $info['tta']['sample_rate'];
+ break;
+
+ case '2': // TTA v2.x
+ // "I have hurried to release the TTA 2.0 encoder. Format documentation is removed from our site. This format still in development. Please wait the TTA2 format, encoder v4."
+ $info['tta']['major_version'] = 2;
+ $info['avdataoffset'] += 20;
+
+ $info['tta']['compression_level'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2));
+ $info['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
+ $info['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 2));
+ $info['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 10, 2));
+ $info['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12, 4));
+ $info['tta']['data_length'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 16, 4));
+
+ $info['audio']['encoder_options'] = '-e'.$info['tta']['compression_level'];
+ $info['playtime_seconds'] = $info['tta']['data_length'] / $info['tta']['sample_rate'];
+ break;
+
+ case '1': // TTA v3.x
+ // "This is a first stable release of the TTA format. It will be supported by the encoders v3 or higher."
+ $info['tta']['major_version'] = 3;
+ $info['avdataoffset'] += 26;
+
+ $info['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2)); // getid3_riff::RIFFwFormatTagLookup()
+ $info['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
+ $info['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 2));
+ $info['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 10, 4));
+ $info['tta']['data_length'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 14, 4));
+ $info['tta']['crc32_footer'] = substr($ttaheader, 18, 4);
+ $info['tta']['seek_point'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 22, 4));
+
+ $info['playtime_seconds'] = $info['tta']['data_length'] / $info['tta']['sample_rate'];
+ break;
+
+ default:
+ $info['error'][] = 'This version of getID3() ['.$this->getid3->version().'] only knows how to handle TTA v1 and v2 - it may not work correctly with this file which appears to be TTA v'.$ttaheader{3};
+ return false;
+ break;
+ }
+
+ $info['audio']['encoder'] = 'TTA v'.$info['tta']['major_version'];
+ $info['audio']['bits_per_sample'] = $info['tta']['bits_per_sample'];
+ $info['audio']['sample_rate'] = $info['tta']['sample_rate'];
+ $info['audio']['channels'] = $info['tta']['channels'];
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+
+ return true;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.voc.php b/3rdparty/getid3/module.audio.voc.php
index e93b44fa61d..1186a4cc03e 100644
--- a/apps/media/getID3/getid3/module.audio.voc.php
+++ b/3rdparty/getid3/module.audio.voc.php
@@ -14,26 +14,28 @@
/////////////////////////////////////////////////////////////////
-class getid3_voc
+class getid3_voc extends getid3_handler
{
- function getid3_voc(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- $OriginalAVdataOffset = $ThisFileInfo['avdataoffset'];
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $VOCheader = fread($fd, 26);
+ $OriginalAVdataOffset = $info['avdataoffset'];
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $VOCheader = fread($this->getid3->fp, 26);
- if (substr($VOCheader, 0, 19) != 'Creative Voice File') {
- $ThisFileInfo['error'][] = 'Expecting "Creative Voice File" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($VOCheader, 0, 19).'"';
+ $magic = 'Creative Voice File';
+ if (substr($VOCheader, 0, 19) != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($VOCheader, 0, 19)).'"';
return false;
}
// shortcuts
- $thisfile_audio = &$ThisFileInfo['audio'];
- $ThisFileInfo['voc'] = array();
- $thisfile_voc = &$ThisFileInfo['voc'];
+ $thisfile_audio = &$info['audio'];
+ $info['voc'] = array();
+ $thisfile_voc = &$info['voc'];
- $ThisFileInfo['fileformat'] = 'voc';
+ $info['fileformat'] = 'voc';
$thisfile_audio['dataformat'] = 'voc';
$thisfile_audio['bitrate_mode'] = 'cbr';
$thisfile_audio['lossless'] = true;
@@ -54,24 +56,24 @@ class getid3_voc
do {
- $BlockOffset = ftell($fd);
- $BlockData = fread($fd, 4);
+ $BlockOffset = ftell($this->getid3->fp);
+ $BlockData = fread($this->getid3->fp, 4);
$BlockType = ord($BlockData{0});
$BlockSize = getid3_lib::LittleEndian2Int(substr($BlockData, 1, 3));
$ThisBlock = array();
- @$thisfile_voc['blocktypes'][$BlockType]++;
+ getid3_lib::safe_inc($thisfile_voc['blocktypes'][$BlockType], 1);
switch ($BlockType) {
case 0: // Terminator
// do nothing, we'll break out of the loop down below
break;
case 1: // Sound data
- $BlockData .= fread($fd, 2);
- if ($ThisFileInfo['avdataoffset'] <= $OriginalAVdataOffset) {
- $ThisFileInfo['avdataoffset'] = ftell($fd);
+ $BlockData .= fread($this->getid3->fp, 2);
+ if ($info['avdataoffset'] <= $OriginalAVdataOffset) {
+ $info['avdataoffset'] = ftell($this->getid3->fp);
}
- fseek($fd, $BlockSize - 2, SEEK_CUR);
+ fseek($this->getid3->fp, $BlockSize - 2, SEEK_CUR);
$ThisBlock['sample_rate_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, 4, 1));
$ThisBlock['compression_type'] = getid3_lib::LittleEndian2Int(substr($BlockData, 5, 1));
@@ -94,11 +96,11 @@ class getid3_voc
case 6: // Repeat
case 7: // End repeat
// nothing useful, just skip
- fseek($fd, $BlockSize, SEEK_CUR);
+ fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
break;
case 8: // Extended
- $BlockData .= fread($fd, 4);
+ $BlockData .= fread($this->getid3->fp, 4);
//00-01 Time Constant:
// Mono: 65536 - (256000000 / sample_rate)
@@ -112,11 +114,11 @@ class getid3_voc
break;
case 9: // data block that supersedes blocks 1 and 8. Used for stereo, 16 bit
- $BlockData .= fread($fd, 12);
- if ($ThisFileInfo['avdataoffset'] <= $OriginalAVdataOffset) {
- $ThisFileInfo['avdataoffset'] = ftell($fd);
+ $BlockData .= fread($this->getid3->fp, 12);
+ if ($info['avdataoffset'] <= $OriginalAVdataOffset) {
+ $info['avdataoffset'] = ftell($this->getid3->fp);
}
- fseek($fd, $BlockSize - 12, SEEK_CUR);
+ fseek($this->getid3->fp, $BlockSize - 12, SEEK_CUR);
$ThisBlock['sample_rate'] = getid3_lib::LittleEndian2Int(substr($BlockData, 4, 4));
$ThisBlock['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($BlockData, 8, 1));
@@ -134,8 +136,8 @@ class getid3_voc
break;
default:
- $ThisFileInfo['warning'][] = 'Unhandled block type "'.$BlockType.'" at offset '.$BlockOffset;
- fseek($fd, $BlockSize, SEEK_CUR);
+ $info['warning'][] = 'Unhandled block type "'.$BlockType.'" at offset '.$BlockOffset;
+ fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
break;
}
@@ -146,16 +148,16 @@ class getid3_voc
$thisfile_voc['blocks'][] = $ThisBlock;
}
- } while (!feof($fd) && ($BlockType != 0));
+ } while (!feof($this->getid3->fp) && ($BlockType != 0));
// Terminator block doesn't have size field, so seek back 3 spaces
- fseek($fd, -3, SEEK_CUR);
+ fseek($this->getid3->fp, -3, SEEK_CUR);
ksort($thisfile_voc['blocktypes']);
if (!empty($thisfile_voc['compressed_bits_per_sample'])) {
- $ThisFileInfo['playtime_seconds'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / ($thisfile_voc['compressed_bits_per_sample'] * $thisfile_audio['channels'] * $thisfile_audio['sample_rate']);
- $thisfile_audio['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
+ $info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($thisfile_voc['compressed_bits_per_sample'] * $thisfile_audio['channels'] * $thisfile_audio['sample_rate']);
+ $thisfile_audio['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
}
return true;
diff --git a/apps/media/getID3/getid3/module.audio.vqf.php b/3rdparty/getid3/module.audio.vqf.php
index 49d4e8510e6..dc6ff5ecc42 100644
--- a/apps/media/getID3/getid3/module.audio.vqf.php
+++ b/3rdparty/getid3/module.audio.vqf.php
@@ -14,58 +14,61 @@
/////////////////////////////////////////////////////////////////
-class getid3_vqf
+class getid3_vqf extends getid3_handler
{
- function getid3_vqf(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
+
// based loosely on code from TTwinVQ by Jurgen Faul <jfaulØgmx*de>
// http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
- $ThisFileInfo['fileformat'] = 'vqf';
- $ThisFileInfo['audio']['dataformat'] = 'vqf';
- $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
- $ThisFileInfo['audio']['lossless'] = false;
+ $info['fileformat'] = 'vqf';
+ $info['audio']['dataformat'] = 'vqf';
+ $info['audio']['bitrate_mode'] = 'cbr';
+ $info['audio']['lossless'] = false;
// shortcut
- $ThisFileInfo['vqf']['raw'] = array();
- $thisfile_vqf = &$ThisFileInfo['vqf'];
+ $info['vqf']['raw'] = array();
+ $thisfile_vqf = &$info['vqf'];
$thisfile_vqf_raw = &$thisfile_vqf['raw'];
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $VQFheaderData = fread($fd, 16);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $VQFheaderData = fread($this->getid3->fp, 16);
$offset = 0;
- $thisfile_vqf_raw['header_tag'] = substr($VQFheaderData, $offset, 4);
- if ($thisfile_vqf_raw['header_tag'] != 'TWIN') {
- $ThisFileInfo['error'][] = 'Expecting "TWIN" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$thisfile_vqf_raw['header_tag'].'"';
- unset($ThisFileInfo['vqf']);
- unset($ThisFileInfo['fileformat']);
+ $thisfile_vqf_raw['header_tag'] = substr($VQFheaderData, $offset, 4);
+ $magic = 'TWIN';
+ if ($thisfile_vqf_raw['header_tag'] != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($thisfile_vqf_raw['header_tag']).'"';
+ unset($info['vqf']);
+ unset($info['fileformat']);
return false;
}
$offset += 4;
- $thisfile_vqf_raw['version'] = substr($VQFheaderData, $offset, 8);
+ $thisfile_vqf_raw['version'] = substr($VQFheaderData, $offset, 8);
$offset += 8;
- $thisfile_vqf_raw['size'] = getid3_lib::BigEndian2Int(substr($VQFheaderData, $offset, 4));
+ $thisfile_vqf_raw['size'] = getid3_lib::BigEndian2Int(substr($VQFheaderData, $offset, 4));
$offset += 4;
- while (ftell($fd) < $ThisFileInfo['avdataend']) {
+ while (ftell($this->getid3->fp) < $info['avdataend']) {
- $ChunkBaseOffset = ftell($fd);
+ $ChunkBaseOffset = ftell($this->getid3->fp);
$chunkoffset = 0;
- $ChunkData = fread($fd, 8);
+ $ChunkData = fread($this->getid3->fp, 8);
$ChunkName = substr($ChunkData, $chunkoffset, 4);
if ($ChunkName == 'DATA') {
- $ThisFileInfo['avdataoffset'] = $ChunkBaseOffset;
+ $info['avdataoffset'] = $ChunkBaseOffset;
break;
}
$chunkoffset += 4;
$ChunkSize = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
$chunkoffset += 4;
- if ($ChunkSize > ($ThisFileInfo['avdataend'] - ftell($fd))) {
- $ThisFileInfo['error'][] = 'Invalid chunk size ('.$ChunkSize.') for chunk "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
+ if ($ChunkSize > ($info['avdataend'] - ftell($this->getid3->fp))) {
+ $info['error'][] = 'Invalid chunk size ('.$ChunkSize.') for chunk "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
break;
}
if ($ChunkSize > 0) {
- $ChunkData .= fread($fd, $ChunkSize);
+ $ChunkData .= fread($this->getid3->fp, $ChunkSize);
}
switch ($ChunkName) {
@@ -83,13 +86,13 @@ class getid3_vqf
$thisfile_vqf_COMM['security_level'] = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
$chunkoffset += 4;
- $ThisFileInfo['audio']['channels'] = $thisfile_vqf_COMM['channel_mode'] + 1;
- $ThisFileInfo['audio']['sample_rate'] = $this->VQFchannelFrequencyLookup($thisfile_vqf_COMM['sample_rate']);
- $ThisFileInfo['audio']['bitrate'] = $thisfile_vqf_COMM['bitrate'] * 1000;
- $ThisFileInfo['audio']['encoder_options'] = 'CBR' . ceil($ThisFileInfo['audio']['bitrate']/1000);
+ $info['audio']['channels'] = $thisfile_vqf_COMM['channel_mode'] + 1;
+ $info['audio']['sample_rate'] = $this->VQFchannelFrequencyLookup($thisfile_vqf_COMM['sample_rate']);
+ $info['audio']['bitrate'] = $thisfile_vqf_COMM['bitrate'] * 1000;
+ $info['audio']['encoder_options'] = 'CBR' . ceil($info['audio']['bitrate']/1000);
- if ($ThisFileInfo['audio']['bitrate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt VQF file: bitrate_audio == zero';
+ if ($info['audio']['bitrate'] == 0) {
+ $info['error'][] = 'Corrupt VQF file: bitrate_audio == zero';
return false;
}
break;
@@ -108,23 +111,23 @@ class getid3_vqf
break;
default:
- $ThisFileInfo['warning'][] = 'Unhandled chunk type "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
+ $info['warning'][] = 'Unhandled chunk type "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
break;
}
}
- $ThisFileInfo['playtime_seconds'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['audio']['bitrate'];
+ $info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['audio']['bitrate'];
- if (isset($thisfile_vqf['DSIZ']) && (($thisfile_vqf['DSIZ'] != ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'] - strlen('DATA'))))) {
+ if (isset($thisfile_vqf['DSIZ']) && (($thisfile_vqf['DSIZ'] != ($info['avdataend'] - $info['avdataoffset'] - strlen('DATA'))))) {
switch ($thisfile_vqf['DSIZ']) {
case 0:
case 1:
- $ThisFileInfo['warning'][] = 'Invalid DSIZ value "'.$thisfile_vqf['DSIZ'].'". This is known to happen with VQF files encoded by Ahead Nero, and seems to be its way of saying this is TwinVQF v'.($thisfile_vqf['DSIZ'] + 1).'.0';
- $ThisFileInfo['audio']['encoder'] = 'Ahead Nero';
+ $info['warning'][] = 'Invalid DSIZ value "'.$thisfile_vqf['DSIZ'].'". This is known to happen with VQF files encoded by Ahead Nero, and seems to be its way of saying this is TwinVQF v'.($thisfile_vqf['DSIZ'] + 1).'.0';
+ $info['audio']['encoder'] = 'Ahead Nero';
break;
default:
- $ThisFileInfo['warning'][] = 'Probable corrupted file - should be '.$thisfile_vqf['DSIZ'].' bytes, actually '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'] - strlen('DATA'));
+ $info['warning'][] = 'Probable corrupted file - should be '.$thisfile_vqf['DSIZ'].' bytes, actually '.($info['avdataend'] - $info['avdataoffset'] - strlen('DATA'));
break;
}
}
diff --git a/3rdparty/getid3/module.audio.wavpack.php b/3rdparty/getid3/module.audio.wavpack.php
new file mode 100644
index 00000000000..6ab5b438677
--- /dev/null
+++ b/3rdparty/getid3/module.audio.wavpack.php
@@ -0,0 +1,400 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio.wavpack.php //
+// module for analyzing WavPack v4.0+ Audio files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_wavpack extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+
+ while (true) {
+
+ $wavpackheader = fread($this->getid3->fp, 32);
+
+ if (ftell($this->getid3->fp) >= $info['avdataend']) {
+ break;
+ } elseif (feof($this->getid3->fp)) {
+ break;
+ } elseif (
+ isset($info['wavpack']['blockheader']['total_samples']) &&
+ isset($info['wavpack']['blockheader']['block_samples']) &&
+ ($info['wavpack']['blockheader']['total_samples'] > 0) &&
+ ($info['wavpack']['blockheader']['block_samples'] > 0) &&
+ (!isset($info['wavpack']['riff_trailer_size']) || ($info['wavpack']['riff_trailer_size'] <= 0)) &&
+ ((isset($info['wavpack']['config_flags']['md5_checksum']) && ($info['wavpack']['config_flags']['md5_checksum'] === false)) || !empty($info['md5_data_source']))) {
+ break;
+ }
+
+ $blockheader_offset = ftell($this->getid3->fp) - 32;
+ $blockheader_magic = substr($wavpackheader, 0, 4);
+ $blockheader_size = getid3_lib::LittleEndian2Int(substr($wavpackheader, 4, 4));
+
+ $magic = 'wvpk';
+ if ($blockheader_magic != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$blockheader_offset.', found "'.getid3_lib::PrintHexBytes($blockheader_magic).'"';
+ switch (isset($info['audio']['dataformat']) ? $info['audio']['dataformat'] : '') {
+ case 'wavpack':
+ case 'wvc':
+ break;
+ default:
+ unset($info['fileformat']);
+ unset($info['audio']);
+ unset($info['wavpack']);
+ break;
+ }
+ return false;
+ }
+
+ if (empty($info['wavpack']['blockheader']['block_samples']) ||
+ empty($info['wavpack']['blockheader']['total_samples']) ||
+ ($info['wavpack']['blockheader']['block_samples'] <= 0) ||
+ ($info['wavpack']['blockheader']['total_samples'] <= 0)) {
+ // Also, it is possible that the first block might not have
+ // any samples (block_samples == 0) and in this case you should skip blocks
+ // until you find one with samples because the other information (like
+ // total_samples) are not guaranteed to be correct until (block_samples > 0)
+
+ // Finally, I have defined a format for files in which the length is not known
+ // (for example when raw files are created using pipes). In these cases
+ // total_samples will be -1 and you must seek to the final block to determine
+ // the total number of samples.
+
+
+ $info['audio']['dataformat'] = 'wavpack';
+ $info['fileformat'] = 'wavpack';
+ $info['audio']['lossless'] = true;
+ $info['audio']['bitrate_mode'] = 'vbr';
+
+ $info['wavpack']['blockheader']['offset'] = $blockheader_offset;
+ $info['wavpack']['blockheader']['magic'] = $blockheader_magic;
+ $info['wavpack']['blockheader']['size'] = $blockheader_size;
+
+ if ($info['wavpack']['blockheader']['size'] >= 0x100000) {
+ $info['error'][] = 'Expecting WavPack block size less than "0x100000", found "'.$info['wavpack']['blockheader']['size'].'" at offset '.$info['wavpack']['blockheader']['offset'];
+ switch (isset($info['audio']['dataformat']) ? $info['audio']['dataformat'] : '') {
+ case 'wavpack':
+ case 'wvc':
+ break;
+ default:
+ unset($info['fileformat']);
+ unset($info['audio']);
+ unset($info['wavpack']);
+ break;
+ }
+ return false;
+ }
+
+ $info['wavpack']['blockheader']['minor_version'] = ord($wavpackheader{8});
+ $info['wavpack']['blockheader']['major_version'] = ord($wavpackheader{9});
+
+ if (($info['wavpack']['blockheader']['major_version'] != 4) ||
+ (($info['wavpack']['blockheader']['minor_version'] < 4) &&
+ ($info['wavpack']['blockheader']['minor_version'] > 16))) {
+ $info['error'][] = 'Expecting WavPack version between "4.2" and "4.16", found version "'.$info['wavpack']['blockheader']['major_version'].'.'.$info['wavpack']['blockheader']['minor_version'].'" at offset '.$info['wavpack']['blockheader']['offset'];
+ switch (isset($info['audio']['dataformat']) ? $info['audio']['dataformat'] : '') {
+ case 'wavpack':
+ case 'wvc':
+ break;
+ default:
+ unset($info['fileformat']);
+ unset($info['audio']);
+ unset($info['wavpack']);
+ break;
+ }
+ return false;
+ }
+
+ $info['wavpack']['blockheader']['track_number'] = ord($wavpackheader{10}); // unused
+ $info['wavpack']['blockheader']['index_number'] = ord($wavpackheader{11}); // unused
+ $info['wavpack']['blockheader']['total_samples'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 12, 4));
+ $info['wavpack']['blockheader']['block_index'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 16, 4));
+ $info['wavpack']['blockheader']['block_samples'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 20, 4));
+ $info['wavpack']['blockheader']['flags_raw'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 24, 4));
+ $info['wavpack']['blockheader']['crc'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 28, 4));
+
+ $info['wavpack']['blockheader']['flags']['bytes_per_sample'] = 1 + ($info['wavpack']['blockheader']['flags_raw'] & 0x00000003);
+ $info['wavpack']['blockheader']['flags']['mono'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00000004);
+ $info['wavpack']['blockheader']['flags']['hybrid'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00000008);
+ $info['wavpack']['blockheader']['flags']['joint_stereo'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00000010);
+ $info['wavpack']['blockheader']['flags']['cross_decorrelation'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00000020);
+ $info['wavpack']['blockheader']['flags']['hybrid_noiseshape'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00000040);
+ $info['wavpack']['blockheader']['flags']['ieee_32bit_float'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00000080);
+ $info['wavpack']['blockheader']['flags']['int_32bit'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00000100);
+ $info['wavpack']['blockheader']['flags']['hybrid_bitrate_noise'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00000200);
+ $info['wavpack']['blockheader']['flags']['hybrid_balance_noise'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00000400);
+ $info['wavpack']['blockheader']['flags']['multichannel_initial'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00000800);
+ $info['wavpack']['blockheader']['flags']['multichannel_final'] = (bool) ($info['wavpack']['blockheader']['flags_raw'] & 0x00001000);
+
+ $info['audio']['lossless'] = !$info['wavpack']['blockheader']['flags']['hybrid'];
+ }
+
+ while (!feof($this->getid3->fp) && (ftell($this->getid3->fp) < ($blockheader_offset + $blockheader_size + 8))) {
+
+ $metablock = array('offset'=>ftell($this->getid3->fp));
+ $metablockheader = fread($this->getid3->fp, 2);
+ if (feof($this->getid3->fp)) {
+ break;
+ }
+ $metablock['id'] = ord($metablockheader{0});
+ $metablock['function_id'] = ($metablock['id'] & 0x3F);
+ $metablock['function_name'] = $this->WavPackMetablockNameLookup($metablock['function_id']);
+
+ // The 0x20 bit in the id of the meta subblocks (which is defined as
+ // ID_OPTIONAL_DATA) is a permanent part of the id. The idea is that
+ // if a decoder encounters an id that it does not know about, it uses
+ // that "ID_OPTIONAL_DATA" flag to determine what to do. If it is set
+ // then the decoder simply ignores the metadata, but if it is zero
+ // then the decoder should quit because it means that an understanding
+ // of the metadata is required to correctly decode the audio.
+ $metablock['non_decoder'] = (bool) ($metablock['id'] & 0x20);
+
+ $metablock['padded_data'] = (bool) ($metablock['id'] & 0x40);
+ $metablock['large_block'] = (bool) ($metablock['id'] & 0x80);
+ if ($metablock['large_block']) {
+ $metablockheader .= fread($this->getid3->fp, 2);
+ }
+ $metablock['size'] = getid3_lib::LittleEndian2Int(substr($metablockheader, 1)) * 2; // size is stored in words
+ $metablock['data'] = null;
+
+ if ($metablock['size'] > 0) {
+
+ switch ($metablock['function_id']) {
+ case 0x21: // ID_RIFF_HEADER
+ case 0x22: // ID_RIFF_TRAILER
+ case 0x23: // ID_REPLAY_GAIN
+ case 0x24: // ID_CUESHEET
+ case 0x25: // ID_CONFIG_BLOCK
+ case 0x26: // ID_MD5_CHECKSUM
+ $metablock['data'] = fread($this->getid3->fp, $metablock['size']);
+
+ if ($metablock['padded_data']) {
+ // padded to the nearest even byte
+ $metablock['size']--;
+ $metablock['data'] = substr($metablock['data'], 0, -1);
+ }
+ break;
+
+ case 0x00: // ID_DUMMY
+ case 0x01: // ID_ENCODER_INFO
+ case 0x02: // ID_DECORR_TERMS
+ case 0x03: // ID_DECORR_WEIGHTS
+ case 0x04: // ID_DECORR_SAMPLES
+ case 0x05: // ID_ENTROPY_VARS
+ case 0x06: // ID_HYBRID_PROFILE
+ case 0x07: // ID_SHAPING_WEIGHTS
+ case 0x08: // ID_FLOAT_INFO
+ case 0x09: // ID_INT32_INFO
+ case 0x0A: // ID_WV_BITSTREAM
+ case 0x0B: // ID_WVC_BITSTREAM
+ case 0x0C: // ID_WVX_BITSTREAM
+ case 0x0D: // ID_CHANNEL_INFO
+ fseek($this->getid3->fp, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
+ break;
+
+ default:
+ $info['warning'][] = 'Unexpected metablock type "0x'.str_pad(dechex($metablock['function_id']), 2, '0', STR_PAD_LEFT).'" at offset '.$metablock['offset'];
+ fseek($this->getid3->fp, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
+ break;
+ }
+
+ switch ($metablock['function_id']) {
+ case 0x21: // ID_RIFF_HEADER
+ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
+ $original_wav_filesize = getid3_lib::LittleEndian2Int(substr($metablock['data'], 4, 4));
+
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_riff = new getid3_riff($getid3_temp);
+ $getid3_riff->ParseRIFFdata($metablock['data']);
+ $metablock['riff'] = $getid3_temp->info['riff'];
+ $info['audio']['sample_rate'] = $getid3_temp->info['riff']['raw']['fmt ']['nSamplesPerSec'];
+ unset($getid3_riff, $getid3_temp);
+
+ $metablock['riff']['original_filesize'] = $original_wav_filesize;
+ $info['wavpack']['riff_trailer_size'] = $original_wav_filesize - $metablock['riff']['WAVE']['data'][0]['size'] - $metablock['riff']['header_size'];
+ $info['playtime_seconds'] = $info['wavpack']['blockheader']['total_samples'] / $info['audio']['sample_rate'];
+
+ // Safe RIFF header in case there's a RIFF footer later
+ $metablockRIFFheader = $metablock['data'];
+ break;
+
+
+ case 0x22: // ID_RIFF_TRAILER
+ $metablockRIFFfooter = $metablockRIFFheader.$metablock['data'];
+ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
+
+ $startoffset = $metablock['offset'] + ($metablock['large_block'] ? 4 : 2);
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataend'] = $info['avdataend'];
+ $getid3_temp->info['fileformat'] = 'riff';
+ $getid3_riff = new getid3_riff($getid3_temp);
+ $metablock['riff'] = $getid3_riff->ParseRIFF($startoffset, $startoffset + $metablock['size']);
+
+ if (!empty($metablock['riff']['INFO'])) {
+ $getid3_riff->RIFFcommentsParse($metablock['riff']['INFO'], $metablock['comments']);
+ $info['tags']['riff'] = $metablock['comments'];
+ }
+ unset($getid3_temp, $getid3_riff);
+ break;
+
+
+ case 0x23: // ID_REPLAY_GAIN
+ $info['warning'][] = 'WavPack "Replay Gain" contents not yet handled by getID3() in metablock at offset '.$metablock['offset'];
+ break;
+
+
+ case 0x24: // ID_CUESHEET
+ $info['warning'][] = 'WavPack "Cuesheet" contents not yet handled by getID3() in metablock at offset '.$metablock['offset'];
+ break;
+
+
+ case 0x25: // ID_CONFIG_BLOCK
+ $metablock['flags_raw'] = getid3_lib::LittleEndian2Int(substr($metablock['data'], 0, 3));
+
+ $metablock['flags']['adobe_mode'] = (bool) ($metablock['flags_raw'] & 0x000001); // "adobe" mode for 32-bit floats
+ $metablock['flags']['fast_flag'] = (bool) ($metablock['flags_raw'] & 0x000002); // fast mode
+ $metablock['flags']['very_fast_flag'] = (bool) ($metablock['flags_raw'] & 0x000004); // double fast
+ $metablock['flags']['high_flag'] = (bool) ($metablock['flags_raw'] & 0x000008); // high quality mode
+ $metablock['flags']['very_high_flag'] = (bool) ($metablock['flags_raw'] & 0x000010); // double high (not used yet)
+ $metablock['flags']['bitrate_kbps'] = (bool) ($metablock['flags_raw'] & 0x000020); // bitrate is kbps, not bits / sample
+ $metablock['flags']['auto_shaping'] = (bool) ($metablock['flags_raw'] & 0x000040); // automatic noise shaping
+ $metablock['flags']['shape_override'] = (bool) ($metablock['flags_raw'] & 0x000080); // shaping mode specified
+ $metablock['flags']['joint_override'] = (bool) ($metablock['flags_raw'] & 0x000100); // joint-stereo mode specified
+ $metablock['flags']['copy_time'] = (bool) ($metablock['flags_raw'] & 0x000200); // copy file-time from source
+ $metablock['flags']['create_exe'] = (bool) ($metablock['flags_raw'] & 0x000400); // create executable
+ $metablock['flags']['create_wvc'] = (bool) ($metablock['flags_raw'] & 0x000800); // create correction file
+ $metablock['flags']['optimize_wvc'] = (bool) ($metablock['flags_raw'] & 0x001000); // maximize bybrid compression
+ $metablock['flags']['quality_mode'] = (bool) ($metablock['flags_raw'] & 0x002000); // psychoacoustic quality mode
+ $metablock['flags']['raw_flag'] = (bool) ($metablock['flags_raw'] & 0x004000); // raw mode (not implemented yet)
+ $metablock['flags']['calc_noise'] = (bool) ($metablock['flags_raw'] & 0x008000); // calc noise in hybrid mode
+ $metablock['flags']['lossy_mode'] = (bool) ($metablock['flags_raw'] & 0x010000); // obsolete (for information)
+ $metablock['flags']['extra_mode'] = (bool) ($metablock['flags_raw'] & 0x020000); // extra processing mode
+ $metablock['flags']['skip_wvx'] = (bool) ($metablock['flags_raw'] & 0x040000); // no wvx stream w/ floats & big ints
+ $metablock['flags']['md5_checksum'] = (bool) ($metablock['flags_raw'] & 0x080000); // compute & store MD5 signature
+ $metablock['flags']['quiet_mode'] = (bool) ($metablock['flags_raw'] & 0x100000); // don't report progress %
+
+ $info['wavpack']['config_flags'] = $metablock['flags'];
+
+
+ $info['audio']['encoder_options'] = '';
+ if ($info['wavpack']['blockheader']['flags']['hybrid']) {
+ $info['audio']['encoder_options'] .= ' -b???';
+ }
+ $info['audio']['encoder_options'] .= ($metablock['flags']['adobe_mode'] ? ' -a' : '');
+ $info['audio']['encoder_options'] .= ($metablock['flags']['optimize_wvc'] ? ' -cc' : '');
+ $info['audio']['encoder_options'] .= ($metablock['flags']['create_exe'] ? ' -e' : '');
+ $info['audio']['encoder_options'] .= ($metablock['flags']['fast_flag'] ? ' -f' : '');
+ $info['audio']['encoder_options'] .= ($metablock['flags']['joint_override'] ? ' -j?' : '');
+ $info['audio']['encoder_options'] .= ($metablock['flags']['high_flag'] ? ' -h' : '');
+ $info['audio']['encoder_options'] .= ($metablock['flags']['md5_checksum'] ? ' -m' : '');
+ $info['audio']['encoder_options'] .= ($metablock['flags']['calc_noise'] ? ' -n' : '');
+ $info['audio']['encoder_options'] .= ($metablock['flags']['shape_override'] ? ' -s?' : '');
+ $info['audio']['encoder_options'] .= ($metablock['flags']['extra_mode'] ? ' -x?' : '');
+ if (!empty($info['audio']['encoder_options'])) {
+ $info['audio']['encoder_options'] = trim($info['audio']['encoder_options']);
+ } elseif (isset($info['audio']['encoder_options'])) {
+ unset($info['audio']['encoder_options']);
+ }
+ break;
+
+
+ case 0x26: // ID_MD5_CHECKSUM
+ if (strlen($metablock['data']) == 16) {
+ $info['md5_data_source'] = strtolower(getid3_lib::PrintHexBytes($metablock['data'], true, false, false));
+ } else {
+ $info['warning'][] = 'Expecting 16 bytes of WavPack "MD5 Checksum" in metablock at offset '.$metablock['offset'].', but found '.strlen($metablock['data']).' bytes';
+ }
+ break;
+
+
+ case 0x00: // ID_DUMMY
+ case 0x01: // ID_ENCODER_INFO
+ case 0x02: // ID_DECORR_TERMS
+ case 0x03: // ID_DECORR_WEIGHTS
+ case 0x04: // ID_DECORR_SAMPLES
+ case 0x05: // ID_ENTROPY_VARS
+ case 0x06: // ID_HYBRID_PROFILE
+ case 0x07: // ID_SHAPING_WEIGHTS
+ case 0x08: // ID_FLOAT_INFO
+ case 0x09: // ID_INT32_INFO
+ case 0x0A: // ID_WV_BITSTREAM
+ case 0x0B: // ID_WVC_BITSTREAM
+ case 0x0C: // ID_WVX_BITSTREAM
+ case 0x0D: // ID_CHANNEL_INFO
+ unset($metablock);
+ break;
+ }
+
+ }
+ if (!empty($metablock)) {
+ $info['wavpack']['metablocks'][] = $metablock;
+ }
+
+ }
+
+ }
+
+ $info['audio']['encoder'] = 'WavPack v'.$info['wavpack']['blockheader']['major_version'].'.'.str_pad($info['wavpack']['blockheader']['minor_version'], 2, '0', STR_PAD_LEFT);
+ $info['audio']['bits_per_sample'] = $info['wavpack']['blockheader']['flags']['bytes_per_sample'] * 8;
+ $info['audio']['channels'] = ($info['wavpack']['blockheader']['flags']['mono'] ? 1 : 2);
+
+ if (!empty($info['playtime_seconds'])) {
+
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+
+ } else {
+
+ $info['audio']['dataformat'] = 'wvc';
+
+ }
+
+ return true;
+ }
+
+
+ function WavPackMetablockNameLookup(&$id) {
+ static $WavPackMetablockNameLookup = array(
+ 0x00 => 'Dummy',
+ 0x01 => 'Encoder Info',
+ 0x02 => 'Decorrelation Terms',
+ 0x03 => 'Decorrelation Weights',
+ 0x04 => 'Decorrelation Samples',
+ 0x05 => 'Entropy Variables',
+ 0x06 => 'Hybrid Profile',
+ 0x07 => 'Shaping Weights',
+ 0x08 => 'Float Info',
+ 0x09 => 'Int32 Info',
+ 0x0A => 'WV Bitstream',
+ 0x0B => 'WVC Bitstream',
+ 0x0C => 'WVX Bitstream',
+ 0x0D => 'Channel Info',
+ 0x21 => 'RIFF header',
+ 0x22 => 'RIFF trailer',
+ 0x23 => 'Replay Gain',
+ 0x24 => 'Cuesheet',
+ 0x25 => 'Config Block',
+ 0x26 => 'MD5 Checksum',
+ );
+ return (isset($WavPackMetablockNameLookup[$id]) ? $WavPackMetablockNameLookup[$id] : '');
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.graphic.bmp.php b/3rdparty/getid3/module.graphic.bmp.php
index ea8a119b5a6..5ac671fbca0 100644
--- a/apps/media/getID3/getid3/module.graphic.bmp.php
+++ b/3rdparty/getid3/module.graphic.bmp.php
@@ -14,16 +14,19 @@
/////////////////////////////////////////////////////////////////
-class getid3_bmp
+class getid3_bmp extends getid3_handler
{
+ var $ExtractPalette = false;
+ var $ExtractData = false;
- function getid3_bmp(&$fd, &$ThisFileInfo, $ExtractPalette=false, $ExtractData=false) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- // shortcuts
- $ThisFileInfo['bmp']['header']['raw'] = array();
- $thisfile_bmp = &$ThisFileInfo['bmp'];
- $thisfile_bmp_header = &$thisfile_bmp['header'];
- $thisfile_bmp_header_raw = &$thisfile_bmp_header['raw'];
+ // shortcuts
+ $info['bmp']['header']['raw'] = array();
+ $thisfile_bmp = &$info['bmp'];
+ $thisfile_bmp_header = &$thisfile_bmp['header'];
+ $thisfile_bmp_header_raw = &$thisfile_bmp_header['raw'];
// BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
// all versions
@@ -33,17 +36,18 @@ class getid3_bmp
// WORD bfReserved2;
// DWORD bfOffBits;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$offset = 0;
- $BMPheader = fread($fd, 14 + 40);
+ $BMPheader = fread($this->getid3->fp, 14 + 40);
$thisfile_bmp_header_raw['identifier'] = substr($BMPheader, $offset, 2);
$offset += 2;
- if ($thisfile_bmp_header_raw['identifier'] != 'BM') {
- $ThisFileInfo['error'][] = 'Expecting "BM" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$thisfile_bmp_header_raw['identifier'].'"';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['bmp']);
+ $magic = 'BM';
+ if ($thisfile_bmp_header_raw['identifier'] != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($thisfile_bmp_header_raw['identifier']).'"';
+ unset($info['fileformat']);
+ unset($info['bmp']);
return false;
}
@@ -81,16 +85,16 @@ class getid3_bmp
$thisfile_bmp['type_os'] = 'Windows';
$thisfile_bmp['type_version'] = 5;
} else {
- $ThisFileInfo['error'][] = 'Unknown BMP subtype (or not a BMP file)';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['bmp']);
+ $info['error'][] = 'Unknown BMP subtype (or not a BMP file)';
+ unset($info['fileformat']);
+ unset($info['bmp']);
return false;
}
- $ThisFileInfo['fileformat'] = 'bmp';
- $ThisFileInfo['video']['dataformat'] = 'bmp';
- $ThisFileInfo['video']['lossless'] = true;
- $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
+ $info['fileformat'] = 'bmp';
+ $info['video']['dataformat'] = 'bmp';
+ $info['video']['lossless'] = true;
+ $info['video']['pixel_aspect_ratio'] = (float) 1;
if ($thisfile_bmp['type_os'] == 'OS/2') {
@@ -112,10 +116,10 @@ class getid3_bmp
$thisfile_bmp_header_raw['bits_per_pixel'] = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
- $ThisFileInfo['video']['resolution_x'] = $thisfile_bmp_header_raw['width'];
- $ThisFileInfo['video']['resolution_y'] = $thisfile_bmp_header_raw['height'];
- $ThisFileInfo['video']['codec'] = 'BI_RGB '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
- $ThisFileInfo['video']['bits_per_sample'] = $thisfile_bmp_header_raw['bits_per_pixel'];
+ $info['video']['resolution_x'] = $thisfile_bmp_header_raw['width'];
+ $info['video']['resolution_y'] = $thisfile_bmp_header_raw['height'];
+ $info['video']['codec'] = 'BI_RGB '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
+ $info['video']['bits_per_sample'] = $thisfile_bmp_header_raw['bits_per_pixel'];
if ($thisfile_bmp['type_version'] >= 2) {
// DWORD Compression; /* Bitmap compression scheme */
@@ -162,9 +166,9 @@ class getid3_bmp
$thisfile_bmp_header_raw['identifier'] = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
- $thisfile_bmp_header['compression'] = $this->BMPcompressionOS2Lookup($thisfile_bmp_header_raw['compression']);
+ $thisfile_bmp_header['compression'] = $this->BMPcompressionOS2Lookup($thisfile_bmp_header_raw['compression']);
- $ThisFileInfo['video']['codec'] = $thisfile_bmp_header['compression'].' '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
+ $info['video']['codec'] = $thisfile_bmp_header['compression'].' '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
}
} elseif ($thisfile_bmp['type_os'] == 'Windows') {
@@ -209,14 +213,14 @@ class getid3_bmp
$offset += 4;
$thisfile_bmp_header['compression'] = $this->BMPcompressionWindowsLookup($thisfile_bmp_header_raw['compression']);
- $ThisFileInfo['video']['resolution_x'] = $thisfile_bmp_header_raw['width'];
- $ThisFileInfo['video']['resolution_y'] = $thisfile_bmp_header_raw['height'];
- $ThisFileInfo['video']['codec'] = $thisfile_bmp_header['compression'].' '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
- $ThisFileInfo['video']['bits_per_sample'] = $thisfile_bmp_header_raw['bits_per_pixel'];
+ $info['video']['resolution_x'] = $thisfile_bmp_header_raw['width'];
+ $info['video']['resolution_y'] = $thisfile_bmp_header_raw['height'];
+ $info['video']['codec'] = $thisfile_bmp_header['compression'].' '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
+ $info['video']['bits_per_sample'] = $thisfile_bmp_header_raw['bits_per_pixel'];
if (($thisfile_bmp['type_version'] >= 4) || ($thisfile_bmp_header_raw['compression'] == 3)) {
// should only be v4+, but BMPs with type_version==1 and BI_BITFIELDS compression have been seen
- $BMPheader .= fread($fd, 44);
+ $BMPheader .= fread($this->getid3->fp, 44);
// BITMAPV4HEADER - [44 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_2k1e.asp
// Win95+, WinNT4.0+
@@ -258,7 +262,7 @@ class getid3_bmp
}
if ($thisfile_bmp['type_version'] >= 5) {
- $BMPheader .= fread($fd, 16);
+ $BMPheader .= fread($this->getid3->fp, 16);
// BITMAPV5HEADER - [16 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_7c36.asp
// Win98+, Win2000+
@@ -278,13 +282,13 @@ class getid3_bmp
} else {
- $ThisFileInfo['error'][] = 'Unknown BMP format in header.';
+ $info['error'][] = 'Unknown BMP format in header.';
return false;
}
- if ($ExtractPalette || $ExtractData) {
+ if ($this->ExtractPalette || $this->ExtractData) {
$PaletteEntries = 0;
if ($thisfile_bmp_header_raw['bits_per_pixel'] < 16) {
$PaletteEntries = pow(2, $thisfile_bmp_header_raw['bits_per_pixel']);
@@ -292,7 +296,7 @@ class getid3_bmp
$PaletteEntries = $thisfile_bmp_header_raw['colors_used'];
}
if ($PaletteEntries > 0) {
- $BMPpalette = fread($fd, 4 * $PaletteEntries);
+ $BMPpalette = fread($this->getid3->fp, 4 * $PaletteEntries);
$paletteoffset = 0;
for ($i = 0; $i < $PaletteEntries; $i++) {
// RGBQUAD - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_5f8y.asp
@@ -313,12 +317,13 @@ class getid3_bmp
}
}
- if ($ExtractData) {
- fseek($fd, $thisfile_bmp_header_raw['data_offset'], SEEK_SET);
+ if ($this->ExtractData) {
+ fseek($this->getid3->fp, $thisfile_bmp_header_raw['data_offset'], SEEK_SET);
$RowByteLength = ceil(($thisfile_bmp_header_raw['width'] * ($thisfile_bmp_header_raw['bits_per_pixel'] / 8)) / 4) * 4; // round up to nearest DWORD boundry
- $BMPpixelData = fread($fd, $thisfile_bmp_header_raw['height'] * $RowByteLength);
+ $BMPpixelData = fread($this->getid3->fp, $thisfile_bmp_header_raw['height'] * $RowByteLength);
$pixeldataoffset = 0;
- switch (@$thisfile_bmp_header_raw['compression']) {
+ $thisfile_bmp_header_raw['compression'] = (isset($thisfile_bmp_header_raw['compression']) ? $thisfile_bmp_header_raw['compression'] : '');
+ switch ($thisfile_bmp_header_raw['compression']) {
case 0: // BI_RGB
switch ($thisfile_bmp_header_raw['bits_per_pixel']) {
@@ -400,7 +405,7 @@ class getid3_bmp
break;
default:
- $ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
+ $info['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
break;
}
break;
@@ -475,7 +480,7 @@ class getid3_bmp
break;
default:
- $ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
+ $info['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
break;
}
break;
@@ -564,7 +569,7 @@ class getid3_bmp
break;
default:
- $ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
+ $info['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
break;
}
break;
@@ -604,14 +609,14 @@ class getid3_bmp
break;
default:
- $ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
+ $info['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
break;
}
break;
default: // unhandled compression type
- $ThisFileInfo['error'][] = 'Unknown/unhandled compression type value ('.$thisfile_bmp_header_raw['compression'].') - cannot decompress pixel data';
+ $info['error'][] = 'Unknown/unhandled compression type value ('.$thisfile_bmp_header_raw['compression'].') - cannot decompress pixel data';
break;
}
}
diff --git a/3rdparty/getid3/module.graphic.efax.php b/3rdparty/getid3/module.graphic.efax.php
new file mode 100644
index 00000000000..2a57302e158
--- /dev/null
+++ b/3rdparty/getid3/module.graphic.efax.php
@@ -0,0 +1,53 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.archive.efax.php //
+// module for analyzing eFax files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_efax extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $efaxheader = fread($this->getid3->fp, 1024);
+
+ $info['efax']['header']['magic'] = substr($efaxheader, 0, 2);
+ if ($info['efax']['header']['magic'] != "\xDC\xFE") {
+ $info['error'][] = 'Invalid eFax byte order identifier (expecting DC FE, found '.getid3_lib::PrintHexBytes($info['efax']['header']['magic']).') at offset '.$info['avdataoffset'];
+ return false;
+ }
+ $info['fileformat'] = 'efax';
+
+ $info['efax']['header']['filesize'] = getid3_lib::LittleEndian2Int(substr($efaxheader, 2, 4));
+ if ($info['efax']['header']['filesize'] != $info['filesize']) {
+ $info['error'][] = 'Probable '.(($info['efax']['header']['filesize'] > $info['filesize']) ? 'truncated' : 'corrupt').' file, expecting '.$info['efax']['header']['filesize'].' bytes, found '.$info['filesize'].' bytes';
+ }
+ $info['efax']['header']['software1'] = rtrim(substr($efaxheader, 26, 32), "\x00");
+ $info['efax']['header']['software2'] = rtrim(substr($efaxheader, 58, 32), "\x00");
+ $info['efax']['header']['software3'] = rtrim(substr($efaxheader, 90, 32), "\x00");
+
+ $info['efax']['header']['pages'] = getid3_lib::LittleEndian2Int(substr($efaxheader, 198, 2));
+ $info['efax']['header']['data_bytes'] = getid3_lib::LittleEndian2Int(substr($efaxheader, 202, 4));
+
+$info['error'][] = 'eFax parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
+return false;
+
+ return true;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/3rdparty/getid3/module.graphic.gif.php b/3rdparty/getid3/module.graphic.gif.php
new file mode 100644
index 00000000000..0b3e1379ff7
--- /dev/null
+++ b/3rdparty/getid3/module.graphic.gif.php
@@ -0,0 +1,184 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.graphic.gif.php //
+// module for analyzing GIF Image files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_gif extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $info['fileformat'] = 'gif';
+ $info['video']['dataformat'] = 'gif';
+ $info['video']['lossless'] = true;
+ $info['video']['pixel_aspect_ratio'] = (float) 1;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $GIFheader = fread($this->getid3->fp, 13);
+ $offset = 0;
+
+ $info['gif']['header']['raw']['identifier'] = substr($GIFheader, $offset, 3);
+ $offset += 3;
+
+ $magic = 'GIF';
+ if ($info['gif']['header']['raw']['identifier'] != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['gif']['header']['raw']['identifier']).'"';
+ unset($info['fileformat']);
+ unset($info['gif']);
+ return false;
+ }
+
+ $info['gif']['header']['raw']['version'] = substr($GIFheader, $offset, 3);
+ $offset += 3;
+ $info['gif']['header']['raw']['width'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 2));
+ $offset += 2;
+ $info['gif']['header']['raw']['height'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 2));
+ $offset += 2;
+ $info['gif']['header']['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 1));
+ $offset += 1;
+ $info['gif']['header']['raw']['bg_color_index'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 1));
+ $offset += 1;
+ $info['gif']['header']['raw']['aspect_ratio'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 1));
+ $offset += 1;
+
+ $info['video']['resolution_x'] = $info['gif']['header']['raw']['width'];
+ $info['video']['resolution_y'] = $info['gif']['header']['raw']['height'];
+ $info['gif']['version'] = $info['gif']['header']['raw']['version'];
+ $info['gif']['header']['flags']['global_color_table'] = (bool) ($info['gif']['header']['raw']['flags'] & 0x80);
+ if ($info['gif']['header']['raw']['flags'] & 0x80) {
+ // Number of bits per primary color available to the original image, minus 1
+ $info['gif']['header']['bits_per_pixel'] = 3 * ((($info['gif']['header']['raw']['flags'] & 0x70) >> 4) + 1);
+ } else {
+ $info['gif']['header']['bits_per_pixel'] = 0;
+ }
+ $info['gif']['header']['flags']['global_color_sorted'] = (bool) ($info['gif']['header']['raw']['flags'] & 0x40);
+ if ($info['gif']['header']['flags']['global_color_table']) {
+ // the number of bytes contained in the Global Color Table. To determine that
+ // actual size of the color table, raise 2 to [the value of the field + 1]
+ $info['gif']['header']['global_color_size'] = pow(2, ($info['gif']['header']['raw']['flags'] & 0x07) + 1);
+ $info['video']['bits_per_sample'] = ($info['gif']['header']['raw']['flags'] & 0x07) + 1;
+ } else {
+ $info['gif']['header']['global_color_size'] = 0;
+ }
+ if ($info['gif']['header']['raw']['aspect_ratio'] != 0) {
+ // Aspect Ratio = (Pixel Aspect Ratio + 15) / 64
+ $info['gif']['header']['aspect_ratio'] = ($info['gif']['header']['raw']['aspect_ratio'] + 15) / 64;
+ }
+
+// if ($info['gif']['header']['flags']['global_color_table']) {
+// $GIFcolorTable = fread($this->getid3->fp, 3 * $info['gif']['header']['global_color_size']);
+// $offset = 0;
+// for ($i = 0; $i < $info['gif']['header']['global_color_size']; $i++) {
+// $red = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
+// $green = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
+// $blue = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
+// $info['gif']['global_color_table'][$i] = (($red << 16) | ($green << 8) | ($blue));
+// }
+// }
+//
+// // Image Descriptor
+// while (!feof($this->getid3->fp)) {
+// $NextBlockTest = fread($this->getid3->fp, 1);
+// switch ($NextBlockTest) {
+//
+// case ',': // ',' - Image separator character
+//
+// $ImageDescriptorData = $NextBlockTest.fread($this->getid3->fp, 9);
+// $ImageDescriptor = array();
+// $ImageDescriptor['image_left'] = getid3_lib::LittleEndian2Int(substr($ImageDescriptorData, 1, 2));
+// $ImageDescriptor['image_top'] = getid3_lib::LittleEndian2Int(substr($ImageDescriptorData, 3, 2));
+// $ImageDescriptor['image_width'] = getid3_lib::LittleEndian2Int(substr($ImageDescriptorData, 5, 2));
+// $ImageDescriptor['image_height'] = getid3_lib::LittleEndian2Int(substr($ImageDescriptorData, 7, 2));
+// $ImageDescriptor['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ImageDescriptorData, 9, 1));
+// $ImageDescriptor['flags']['use_local_color_map'] = (bool) ($ImageDescriptor['flags_raw'] & 0x80);
+// $ImageDescriptor['flags']['image_interlaced'] = (bool) ($ImageDescriptor['flags_raw'] & 0x40);
+// $info['gif']['image_descriptor'][] = $ImageDescriptor;
+//
+// if ($ImageDescriptor['flags']['use_local_color_map']) {
+//
+// $info['warning'][] = 'This version of getID3() cannot parse local color maps for GIFs';
+// return true;
+//
+// }
+//echo 'Start of raster data: '.ftell($this->getid3->fp).'<BR>';
+// $RasterData = array();
+// $RasterData['code_size'] = getid3_lib::LittleEndian2Int(fread($this->getid3->fp, 1));
+// $RasterData['block_byte_count'] = getid3_lib::LittleEndian2Int(fread($this->getid3->fp, 1));
+// $info['gif']['raster_data'][count($info['gif']['image_descriptor']) - 1] = $RasterData;
+//
+// $CurrentCodeSize = $RasterData['code_size'] + 1;
+// for ($i = 0; $i < pow(2, $RasterData['code_size']); $i++) {
+// $DefaultDataLookupTable[$i] = chr($i);
+// }
+// $DefaultDataLookupTable[pow(2, $RasterData['code_size']) + 0] = ''; // Clear Code
+// $DefaultDataLookupTable[pow(2, $RasterData['code_size']) + 1] = ''; // End Of Image Code
+//
+//
+// $NextValue = $this->GetLSBits($CurrentCodeSize);
+// echo 'Clear Code: '.$NextValue.'<BR>';
+//
+// $NextValue = $this->GetLSBits($CurrentCodeSize);
+// echo 'First Color: '.$NextValue.'<BR>';
+//
+// $Prefix = $NextValue;
+//$i = 0;
+// while ($i++ < 20) {
+// $NextValue = $this->GetLSBits($CurrentCodeSize);
+// echo $NextValue.'<BR>';
+// }
+//return true;
+// break;
+//
+// case '!':
+// // GIF Extension Block
+// $ExtensionBlockData = $NextBlockTest.fread($this->getid3->fp, 2);
+// $ExtensionBlock = array();
+// $ExtensionBlock['function_code'] = getid3_lib::LittleEndian2Int(substr($ExtensionBlockData, 1, 1));
+// $ExtensionBlock['byte_length'] = getid3_lib::LittleEndian2Int(substr($ExtensionBlockData, 2, 1));
+// $ExtensionBlock['data'] = fread($this->getid3->fp, $ExtensionBlock['byte_length']);
+// $info['gif']['extension_blocks'][] = $ExtensionBlock;
+// break;
+//
+// case ';':
+// $info['gif']['terminator_offset'] = ftell($this->getid3->fp) - 1;
+// // GIF Terminator
+// break;
+//
+// default:
+// break;
+//
+//
+// }
+// }
+
+ return true;
+ }
+
+
+ function GetLSBits($bits) {
+ static $bitbuffer = '';
+ while (strlen($bitbuffer) < $bits) {
+ $bitbuffer = str_pad(decbin(ord(fread($this->getid3->fp, 1))), 8, '0', STR_PAD_LEFT).$bitbuffer;
+ }
+ $value = bindec(substr($bitbuffer, 0 - $bits));
+ $bitbuffer = substr($bitbuffer, 0, 0 - $bits);
+
+ return $value;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/3rdparty/getid3/module.graphic.jpg.php b/3rdparty/getid3/module.graphic.jpg.php
new file mode 100644
index 00000000000..153ebcd0e6f
--- /dev/null
+++ b/3rdparty/getid3/module.graphic.jpg.php
@@ -0,0 +1,338 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.graphic.jpg.php //
+// module for analyzing JPEG Image files //
+// dependencies: PHP compiled with --enable-exif (optional) //
+// module.tag.xmp.php (optional) //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_jpg extends getid3_handler
+{
+
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $info['fileformat'] = 'jpg';
+ $info['video']['dataformat'] = 'jpg';
+ $info['video']['lossless'] = false;
+ $info['video']['bits_per_sample'] = 24;
+ $info['video']['pixel_aspect_ratio'] = (float) 1;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+
+ $imageinfo = array();
+ list($width, $height, $type) = getid3_lib::GetDataImageSize(fread($this->getid3->fp, $info['filesize']), $imageinfo);
+
+
+ if (isset($imageinfo['APP13'])) {
+ // http://php.net/iptcparse
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/IPTC.html
+ $iptc_parsed = iptcparse($imageinfo['APP13']);
+ if (is_array($iptc_parsed)) {
+ foreach ($iptc_parsed as $iptc_key_raw => $iptc_values) {
+ list($iptc_record, $iptc_tagkey) = explode('#', $iptc_key_raw);
+ $iptc_tagkey = intval(ltrim($iptc_tagkey, '0'));
+ foreach ($iptc_values as $key => $value) {
+ $IPTCrecordName = $this->IPTCrecordName($iptc_record);
+ $IPTCrecordTagName = $this->IPTCrecordTagName($iptc_record, $iptc_tagkey);
+ if (isset($info['iptc'][$IPTCrecordName][$IPTCrecordTagName])) {
+ $info['iptc'][$IPTCrecordName][$IPTCrecordTagName][] = $value;
+ } else {
+ $info['iptc'][$IPTCrecordName][$IPTCrecordTagName] = array($value);
+ }
+ }
+ }
+ }
+ }
+
+ $returnOK = false;
+ switch ($type) {
+ case IMG_JPG:
+ $info['video']['resolution_x'] = $width;
+ $info['video']['resolution_y'] = $height;
+
+ if (isset($imageinfo['APP1'])) {
+ if (function_exists('exif_read_data')) {
+ if (substr($imageinfo['APP1'], 0, 4) == 'Exif') {
+ $info['jpg']['exif'] = @exif_read_data($info['filenamepath'], '', true, false);
+ } else {
+ $info['warning'][] = 'exif_read_data() cannot parse non-EXIF data in APP1 (expected "Exif", found "'.substr($imageinfo['APP1'], 0, 4).'")';
+ }
+ } else {
+ $info['warning'][] = 'EXIF parsing only available when '.(GETID3_OS_ISWINDOWS ? 'php_exif.dll enabled' : 'compiled with --enable-exif');
+ }
+ }
+ $returnOK = true;
+ break;
+
+ default:
+ break;
+ }
+
+
+ $cast_as_appropriate_keys = array('EXIF', 'IFD0', 'THUMBNAIL');
+ foreach ($cast_as_appropriate_keys as $exif_key) {
+ if (isset($info['jpg']['exif'][$exif_key])) {
+ foreach ($info['jpg']['exif'][$exif_key] as $key => $value) {
+ $info['jpg']['exif'][$exif_key][$key] = $this->CastAsAppropriate($value);
+ }
+ }
+ }
+
+
+ if (isset($info['jpg']['exif']['GPS'])) {
+
+ if (isset($info['jpg']['exif']['GPS']['GPSVersion'])) {
+ for ($i = 0; $i < 4; $i++) {
+ $version_subparts[$i] = ord(substr($info['jpg']['exif']['GPS']['GPSVersion'], $i, 1));
+ }
+ $info['jpg']['exif']['GPS']['computed']['version'] = 'v'.implode('.', $version_subparts);
+ }
+
+ if (isset($info['jpg']['exif']['GPS']['GPSDateStamp'])) {
+ $explodedGPSDateStamp = explode(':', $info['jpg']['exif']['GPS']['GPSDateStamp']);
+ $computed_time[5] = (isset($explodedGPSDateStamp[0]) ? $explodedGPSDateStamp[0] : '');
+ $computed_time[3] = (isset($explodedGPSDateStamp[1]) ? $explodedGPSDateStamp[1] : '');
+ $computed_time[4] = (isset($explodedGPSDateStamp[2]) ? $explodedGPSDateStamp[2] : '');
+
+ if (function_exists('date_default_timezone_set')) {
+ date_default_timezone_set('UTC');
+ } else {
+ ini_set('date.timezone', 'UTC');
+ }
+
+ $computed_time = array(0=>0, 1=>0, 2=>0, 3=>0, 4=>0, 5=>0);
+ if (isset($info['jpg']['exif']['GPS']['GPSTimeStamp']) && is_array($info['jpg']['exif']['GPS']['GPSTimeStamp'])) {
+ foreach ($info['jpg']['exif']['GPS']['GPSTimeStamp'] as $key => $value) {
+ $computed_time[$key] = getid3_lib::DecimalizeFraction($value);
+ }
+ }
+ $info['jpg']['exif']['GPS']['computed']['timestamp'] = mktime($computed_time[0], $computed_time[1], $computed_time[2], $computed_time[3], $computed_time[4], $computed_time[5]);
+ }
+
+ if (isset($info['jpg']['exif']['GPS']['GPSLatitude']) && is_array($info['jpg']['exif']['GPS']['GPSLatitude'])) {
+ $direction_multiplier = ((isset($info['jpg']['exif']['GPS']['GPSLatitudeRef']) && ($info['jpg']['exif']['GPS']['GPSLatitudeRef'] == 'S')) ? -1 : 1);
+ foreach ($info['jpg']['exif']['GPS']['GPSLatitude'] as $key => $value) {
+ $computed_latitude[$key] = getid3_lib::DecimalizeFraction($value);
+ }
+ $info['jpg']['exif']['GPS']['computed']['latitude'] = $direction_multiplier * ($computed_latitude[0] + ($computed_latitude[1] / 60) + ($computed_latitude[2] / 3600));
+ }
+
+ if (isset($info['jpg']['exif']['GPS']['GPSLongitude']) && is_array($info['jpg']['exif']['GPS']['GPSLongitude'])) {
+ $direction_multiplier = ((isset($info['jpg']['exif']['GPS']['GPSLongitudeRef']) && ($info['jpg']['exif']['GPS']['GPSLongitudeRef'] == 'W')) ? -1 : 1);
+ foreach ($info['jpg']['exif']['GPS']['GPSLongitude'] as $key => $value) {
+ $computed_longitude[$key] = getid3_lib::DecimalizeFraction($value);
+ }
+ $info['jpg']['exif']['GPS']['computed']['longitude'] = $direction_multiplier * ($computed_longitude[0] + ($computed_longitude[1] / 60) + ($computed_longitude[2] / 3600));
+ }
+
+ if (isset($info['jpg']['exif']['GPS']['GPSAltitude'])) {
+ $direction_multiplier = ((isset($info['jpg']['exif']['GPS']['GPSAltitudeRef']) && ($info['jpg']['exif']['GPS']['GPSAltitudeRef'] === chr(1))) ? -1 : 1);
+ $info['jpg']['exif']['GPS']['computed']['altitude'] = $direction_multiplier * getid3_lib::DecimalizeFraction($info['jpg']['exif']['GPS']['GPSAltitude']);
+ }
+
+ }
+
+
+ if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.xmp.php', __FILE__, false)) {
+ if (isset($info['filenamepath'])) {
+ $image_xmp = new Image_XMP($info['filenamepath']);
+ $xmp_raw = $image_xmp->getAllTags();
+ foreach ($xmp_raw as $key => $value) {
+ list($subsection, $tagname) = explode(':', $key);
+ $info['xmp'][$subsection][$tagname] = $this->CastAsAppropriate($value);
+ }
+ }
+ }
+
+ if (!$returnOK) {
+ unset($info['fileformat']);
+ return false;
+ }
+ return true;
+ }
+
+
+ function CastAsAppropriate($value) {
+ if (is_array($value)) {
+ return $value;
+ } elseif (preg_match('#^[0-9]+/[0-9]+$#', $value)) {
+ return getid3_lib::DecimalizeFraction($value);
+ } elseif (preg_match('#^[0-9]+$#', $value)) {
+ return getid3_lib::CastAsInt($value);
+ } elseif (preg_match('#^[0-9\.]+$#', $value)) {
+ return (float) $value;
+ }
+ return $value;
+ }
+
+
+ function IPTCrecordName($iptc_record) {
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/IPTC.html
+ static $IPTCrecordName = array();
+ if (empty($IPTCrecordName)) {
+ $IPTCrecordName = array(
+ 1 => 'IPTCEnvelope',
+ 2 => 'IPTCApplication',
+ 3 => 'IPTCNewsPhoto',
+ 7 => 'IPTCPreObjectData',
+ 8 => 'IPTCObjectData',
+ 9 => 'IPTCPostObjectData',
+ );
+ }
+ return (isset($IPTCrecordName[$iptc_record]) ? $IPTCrecordName[$iptc_record] : '');
+ }
+
+
+ function IPTCrecordTagName($iptc_record, $iptc_tagkey) {
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/IPTC.html
+ static $IPTCrecordTagName = array();
+ if (empty($IPTCrecordTagName)) {
+ $IPTCrecordTagName = array(
+ 1 => array( // IPTC EnvelopeRecord Tags
+ 0 => 'EnvelopeRecordVersion',
+ 5 => 'Destination',
+ 20 => 'FileFormat',
+ 22 => 'FileVersion',
+ 30 => 'ServiceIdentifier',
+ 40 => 'EnvelopeNumber',
+ 50 => 'ProductID',
+ 60 => 'EnvelopePriority',
+ 70 => 'DateSent',
+ 80 => 'TimeSent',
+ 90 => 'CodedCharacterSet',
+ 100 => 'UniqueObjectName',
+ 120 => 'ARMIdentifier',
+ 122 => 'ARMVersion',
+ ),
+ 2 => array( // IPTC ApplicationRecord Tags
+ 0 => 'ApplicationRecordVersion',
+ 3 => 'ObjectTypeReference',
+ 4 => 'ObjectAttributeReference',
+ 5 => 'ObjectName',
+ 7 => 'EditStatus',
+ 8 => 'EditorialUpdate',
+ 10 => 'Urgency',
+ 12 => 'SubjectReference',
+ 15 => 'Category',
+ 20 => 'SupplementalCategories',
+ 22 => 'FixtureIdentifier',
+ 25 => 'Keywords',
+ 26 => 'ContentLocationCode',
+ 27 => 'ContentLocationName',
+ 30 => 'ReleaseDate',
+ 35 => 'ReleaseTime',
+ 37 => 'ExpirationDate',
+ 38 => 'ExpirationTime',
+ 40 => 'SpecialInstructions',
+ 42 => 'ActionAdvised',
+ 45 => 'ReferenceService',
+ 47 => 'ReferenceDate',
+ 50 => 'ReferenceNumber',
+ 55 => 'DateCreated',
+ 60 => 'TimeCreated',
+ 62 => 'DigitalCreationDate',
+ 63 => 'DigitalCreationTime',
+ 65 => 'OriginatingProgram',
+ 70 => 'ProgramVersion',
+ 75 => 'ObjectCycle',
+ 80 => 'By-line',
+ 85 => 'By-lineTitle',
+ 90 => 'City',
+ 92 => 'Sub-location',
+ 95 => 'Province-State',
+ 100 => 'Country-PrimaryLocationCode',
+ 101 => 'Country-PrimaryLocationName',
+ 103 => 'OriginalTransmissionReference',
+ 105 => 'Headline',
+ 110 => 'Credit',
+ 115 => 'Source',
+ 116 => 'CopyrightNotice',
+ 118 => 'Contact',
+ 120 => 'Caption-Abstract',
+ 121 => 'LocalCaption',
+ 122 => 'Writer-Editor',
+ 125 => 'RasterizedCaption',
+ 130 => 'ImageType',
+ 131 => 'ImageOrientation',
+ 135 => 'LanguageIdentifier',
+ 150 => 'AudioType',
+ 151 => 'AudioSamplingRate',
+ 152 => 'AudioSamplingResolution',
+ 153 => 'AudioDuration',
+ 154 => 'AudioOutcue',
+ 184 => 'JobID',
+ 185 => 'MasterDocumentID',
+ 186 => 'ShortDocumentID',
+ 187 => 'UniqueDocumentID',
+ 188 => 'OwnerID',
+ 200 => 'ObjectPreviewFileFormat',
+ 201 => 'ObjectPreviewFileVersion',
+ 202 => 'ObjectPreviewData',
+ 221 => 'Prefs',
+ 225 => 'ClassifyState',
+ 228 => 'SimilarityIndex',
+ 230 => 'DocumentNotes',
+ 231 => 'DocumentHistory',
+ 232 => 'ExifCameraInfo',
+ ),
+ 3 => array( // IPTC NewsPhoto Tags
+ 0 => 'NewsPhotoVersion',
+ 10 => 'IPTCPictureNumber',
+ 20 => 'IPTCImageWidth',
+ 30 => 'IPTCImageHeight',
+ 40 => 'IPTCPixelWidth',
+ 50 => 'IPTCPixelHeight',
+ 55 => 'SupplementalType',
+ 60 => 'ColorRepresentation',
+ 64 => 'InterchangeColorSpace',
+ 65 => 'ColorSequence',
+ 66 => 'ICC_Profile',
+ 70 => 'ColorCalibrationMatrix',
+ 80 => 'LookupTable',
+ 84 => 'NumIndexEntries',
+ 85 => 'ColorPalette',
+ 86 => 'IPTCBitsPerSample',
+ 90 => 'SampleStructure',
+ 100 => 'ScanningDirection',
+ 102 => 'IPTCImageRotation',
+ 110 => 'DataCompressionMethod',
+ 120 => 'QuantizationMethod',
+ 125 => 'EndPoints',
+ 130 => 'ExcursionTolerance',
+ 135 => 'BitsPerComponent',
+ 140 => 'MaximumDensityRange',
+ 145 => 'GammaCompensatedValue',
+ ),
+ 7 => array( // IPTC PreObjectData Tags
+ 10 => 'SizeMode',
+ 20 => 'MaxSubfileSize',
+ 90 => 'ObjectSizeAnnounced',
+ 95 => 'MaximumObjectSize',
+ ),
+ 8 => array( // IPTC ObjectData Tags
+ 10 => 'SubFile',
+ ),
+ 9 => array( // IPTC PostObjectData Tags
+ 10 => 'ConfirmedObjectSize',
+ ),
+ );
+
+ }
+ return (isset($IPTCrecordTagName[$iptc_record][$iptc_tagkey]) ? $IPTCrecordTagName[$iptc_record][$iptc_tagkey] : $iptc_tagkey);
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.graphic.pcd.php b/3rdparty/getid3/module.graphic.pcd.php
index 60efabdf61f..dcbc6763630 100644
--- a/apps/media/getID3/getid3/module.graphic.pcd.php
+++ b/3rdparty/getid3/module.graphic.pcd.php
@@ -14,34 +14,38 @@
/////////////////////////////////////////////////////////////////
-class getid3_pcd
+class getid3_pcd extends getid3_handler
{
- function getid3_pcd(&$fd, &$ThisFileInfo, $ExtractData=0) {
- $ThisFileInfo['fileformat'] = 'pcd';
- $ThisFileInfo['video']['dataformat'] = 'pcd';
- $ThisFileInfo['video']['lossless'] = false;
+ var $ExtractData = 0;
+ function Analyze() {
+ $info = &$this->getid3->info;
- fseek($fd, $ThisFileInfo['avdataoffset'] + 72, SEEK_SET);
+ $info['fileformat'] = 'pcd';
+ $info['video']['dataformat'] = 'pcd';
+ $info['video']['lossless'] = false;
- $PCDflags = fread($fd, 1);
+
+ fseek($this->getid3->fp, $info['avdataoffset'] + 72, SEEK_SET);
+
+ $PCDflags = fread($this->getid3->fp, 1);
$PCDisVertical = ((ord($PCDflags) & 0x01) ? true : false);
if ($PCDisVertical) {
- $ThisFileInfo['video']['resolution_x'] = 3072;
- $ThisFileInfo['video']['resolution_y'] = 2048;
+ $info['video']['resolution_x'] = 3072;
+ $info['video']['resolution_y'] = 2048;
} else {
- $ThisFileInfo['video']['resolution_x'] = 2048;
- $ThisFileInfo['video']['resolution_y'] = 3072;
+ $info['video']['resolution_x'] = 2048;
+ $info['video']['resolution_y'] = 3072;
}
- if ($ExtractData > 3) {
+ if ($this->ExtractData > 3) {
- $ThisFileInfo['error'][] = 'Cannot extract PSD image data for detail levels above BASE (3)';
+ $info['error'][] = 'Cannot extract PSD image data for detail levels above BASE (level-3) because encrypted with Kodak-proprietary compression/encryption.';
- } elseif ($ExtractData > 0) {
+ } elseif ($this->ExtractData > 0) {
$PCD_levels[1] = array( 192, 128, 0x02000); // BASE/16
$PCD_levels[2] = array( 384, 256, 0x0B800); // BASE/4
@@ -52,7 +56,7 @@ class getid3_pcd
list($PCD_width, $PCD_height, $PCD_dataOffset) = $PCD_levels[3];
- fseek($fd, $ThisFileInfo['avdataoffset'] + $PCD_dataOffset, SEEK_SET);
+ fseek($this->getid3->fp, $info['avdataoffset'] + $PCD_dataOffset, SEEK_SET);
for ($y = 0; $y < $PCD_height; $y += 2) {
// The image-data of these subtypes start at the respective offsets of 02000h, 0b800h and 30000h.
@@ -61,18 +65,18 @@ class getid3_pcd
// the first half of the third ‘w’ bytes contain data for the first RGB-line, the second ‘w’ bytes
// and the second half of the third ‘w’ bytes contain data for a second RGB-line.
- $PCD_data_Y1 = fread($fd, $PCD_width);
- $PCD_data_Y2 = fread($fd, $PCD_width);
- $PCD_data_Cb = fread($fd, intval(round($PCD_width / 2)));
- $PCD_data_Cr = fread($fd, intval(round($PCD_width / 2)));
+ $PCD_data_Y1 = fread($this->getid3->fp, $PCD_width);
+ $PCD_data_Y2 = fread($this->getid3->fp, $PCD_width);
+ $PCD_data_Cb = fread($this->getid3->fp, intval(round($PCD_width / 2)));
+ $PCD_data_Cr = fread($this->getid3->fp, intval(round($PCD_width / 2)));
for ($x = 0; $x < $PCD_width; $x++) {
if ($PCDisVertical) {
- $ThisFileInfo['pcd']['data'][$PCD_width - $x][$y] = $this->YCbCr2RGB(ord($PCD_data_Y1{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
- $ThisFileInfo['pcd']['data'][$PCD_width - $x][$y + 1] = $this->YCbCr2RGB(ord($PCD_data_Y2{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
+ $info['pcd']['data'][$PCD_width - $x][$y] = $this->YCbCr2RGB(ord($PCD_data_Y1{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
+ $info['pcd']['data'][$PCD_width - $x][$y + 1] = $this->YCbCr2RGB(ord($PCD_data_Y2{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
} else {
- $ThisFileInfo['pcd']['data'][$y][$x] = $this->YCbCr2RGB(ord($PCD_data_Y1{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
- $ThisFileInfo['pcd']['data'][$y + 1][$x] = $this->YCbCr2RGB(ord($PCD_data_Y2{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
+ $info['pcd']['data'][$y][$x] = $this->YCbCr2RGB(ord($PCD_data_Y1{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
+ $info['pcd']['data'][$y + 1][$x] = $this->YCbCr2RGB(ord($PCD_data_Y2{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
}
}
}
@@ -86,7 +90,7 @@ class getid3_pcd
// $BMPinfo['resolution_x'] = $PCD_width;
// $BMPinfo['resolution_y'] = $PCD_height;
//}
- //$BMPinfo['bmp']['data'] = $ThisFileInfo['pcd']['data'];
+ //$BMPinfo['bmp']['data'] = $info['pcd']['data'];
//getid3_bmp::PlotBMP($BMPinfo);
//exit;
diff --git a/apps/media/getID3/getid3/module.graphic.png.php b/3rdparty/getid3/module.graphic.png.php
index b5b3d35941e..9109c43689c 100644
--- a/apps/media/getID3/getid3/module.graphic.png.php
+++ b/3rdparty/getid3/module.graphic.png.php
@@ -14,37 +14,38 @@
/////////////////////////////////////////////////////////////////
-class getid3_png
+class getid3_png extends getid3_handler
{
- function getid3_png(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- // shortcut
- $ThisFileInfo['png'] = array();
- $thisfile_png = &$ThisFileInfo['png'];
+ // shortcut
+ $info['png'] = array();
+ $thisfile_png = &$info['png'];
- $ThisFileInfo['fileformat'] = 'png';
- $ThisFileInfo['video']['dataformat'] = 'png';
- $ThisFileInfo['video']['lossless'] = false;
+ $info['fileformat'] = 'png';
+ $info['video']['dataformat'] = 'png';
+ $info['video']['lossless'] = false;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $PNGfiledata = fread($fd, GETID3_FREAD_BUFFER_SIZE);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $PNGfiledata = fread($this->getid3->fp, $this->getid3->fread_buffer_size());
$offset = 0;
$PNGidentifier = substr($PNGfiledata, $offset, 8); // $89 $50 $4E $47 $0D $0A $1A $0A
$offset += 8;
if ($PNGidentifier != "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {
- $ThisFileInfo['error'][] = 'First 8 bytes of file ('.getid3_lib::PrintHexBytes($PNGidentifier).') did not match expected PNG identifier';
- unset($ThisFileInfo['fileformat']);
+ $info['error'][] = 'First 8 bytes of file ('.getid3_lib::PrintHexBytes($PNGidentifier).') did not match expected PNG identifier';
+ unset($info['fileformat']);
return false;
}
- while (((ftell($fd) - (strlen($PNGfiledata) - $offset)) < $ThisFileInfo['filesize'])) {
+ while (((ftell($this->getid3->fp) - (strlen($PNGfiledata) - $offset)) < $info['filesize'])) {
$chunk['data_length'] = getid3_lib::BigEndian2Int(substr($PNGfiledata, $offset, 4));
$offset += 4;
- while (((strlen($PNGfiledata) - $offset) < ($chunk['data_length'] + 4)) && (ftell($fd) < $ThisFileInfo['filesize'])) {
- $PNGfiledata .= fread($fd, GETID3_FREAD_BUFFER_SIZE);
+ while (((strlen($PNGfiledata) - $offset) < ($chunk['data_length'] + 4)) && (ftell($this->getid3->fp) < $info['filesize'])) {
+ $PNGfiledata .= fread($this->getid3->fp, $this->getid3->fread_buffer_size());
}
$chunk['type_text'] = substr($PNGfiledata, $offset, 4);
$offset += 4;
@@ -80,10 +81,10 @@ class getid3_png
$thisfile_png_chunk_type_text['color_type']['true_color'] = (bool) ($thisfile_png_chunk_type_text['raw']['color_type'] & 0x02);
$thisfile_png_chunk_type_text['color_type']['alpha'] = (bool) ($thisfile_png_chunk_type_text['raw']['color_type'] & 0x04);
- $ThisFileInfo['video']['resolution_x'] = $thisfile_png_chunk_type_text['width'];
- $ThisFileInfo['video']['resolution_y'] = $thisfile_png_chunk_type_text['height'];
+ $info['video']['resolution_x'] = $thisfile_png_chunk_type_text['width'];
+ $info['video']['resolution_y'] = $thisfile_png_chunk_type_text['height'];
- $ThisFileInfo['video']['bits_per_sample'] = $this->IHDRcalculateBitsPerSample($thisfile_png_chunk_type_text['raw']['color_type'], $thisfile_png_chunk_type_text['raw']['bit_depth']);
+ $info['video']['bits_per_sample'] = $this->IHDRcalculateBitsPerSample($thisfile_png_chunk_type_text['raw']['color_type'], $thisfile_png_chunk_type_text['raw']['bit_depth']);
break;
@@ -123,10 +124,10 @@ class getid3_png
case 4:
case 6:
- $ThisFileInfo['error'][] = 'Invalid color_type in tRNS chunk: '.$thisfile_png['IHDR']['raw']['color_type'];
+ $info['error'][] = 'Invalid color_type in tRNS chunk: '.$thisfile_png['IHDR']['raw']['color_type'];
default:
- $ThisFileInfo['warning'][] = 'Unhandled color_type in tRNS chunk: '.$thisfile_png['IHDR']['raw']['color_type'];
+ $info['warning'][] = 'Unhandled color_type in tRNS chunk: '.$thisfile_png['IHDR']['raw']['color_type'];
break;
}
break;
@@ -429,7 +430,7 @@ class getid3_png
default:
//unset($chunk['data']);
$thisfile_png_chunk_type_text['header'] = $chunk;
- $ThisFileInfo['warning'][] = 'Unhandled chunk type: '.$chunk['type_text'];
+ $info['warning'][] = 'Unhandled chunk type: '.$chunk['type_text'];
break;
}
}
diff --git a/3rdparty/getid3/module.graphic.svg.php b/3rdparty/getid3/module.graphic.svg.php
new file mode 100644
index 00000000000..d9d52d74d01
--- /dev/null
+++ b/3rdparty/getid3/module.graphic.svg.php
@@ -0,0 +1,104 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.graphic.svg.php //
+// module for analyzing SVG Image files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_svg extends getid3_handler
+{
+
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+
+ $SVGheader = fread($this->getid3->fp, 4096);
+ if (preg_match('#\<\?xml([^\>]+)\?\>#i', $SVGheader, $matches)) {
+ $info['svg']['xml']['raw'] = $matches;
+ }
+ if (preg_match('#\<\!DOCTYPE([^\>]+)\>#i', $SVGheader, $matches)) {
+ $info['svg']['doctype']['raw'] = $matches;
+ }
+ if (preg_match('#\<svg([^\>]+)\>#i', $SVGheader, $matches)) {
+ $info['svg']['svg']['raw'] = $matches;
+ }
+ if (isset($info['svg']['svg']['raw'])) {
+
+ $sections_to_fix = array('xml', 'doctype', 'svg');
+ foreach ($sections_to_fix as $section_to_fix) {
+ if (!isset($info['svg'][$section_to_fix])) {
+ continue;
+ }
+ $section_data = array();
+ while (preg_match('/ "([^"]+)"/', $info['svg'][$section_to_fix]['raw'][1], $matches)) {
+ $section_data[] = $matches[1];
+ $info['svg'][$section_to_fix]['raw'][1] = str_replace($matches[0], '', $info['svg'][$section_to_fix]['raw'][1]);
+ }
+ while (preg_match('/([^\s]+)="([^"]+)"/', $info['svg'][$section_to_fix]['raw'][1], $matches)) {
+ $section_data[] = $matches[0];
+ $info['svg'][$section_to_fix]['raw'][1] = str_replace($matches[0], '', $info['svg'][$section_to_fix]['raw'][1]);
+ }
+ $section_data = array_merge($section_data, preg_split('/[\s,]+/', $info['svg'][$section_to_fix]['raw'][1]));
+ foreach ($section_data as $keyvaluepair) {
+ $keyvaluepair = trim($keyvaluepair);
+ if ($keyvaluepair) {
+ $keyvalueexploded = explode('=', $keyvaluepair);
+ $key = (isset($keyvalueexploded[0]) ? $keyvalueexploded[0] : '');
+ $value = (isset($keyvalueexploded[1]) ? $keyvalueexploded[1] : '');
+ $info['svg'][$section_to_fix]['sections'][$key] = trim($value, '"');
+ }
+ }
+ }
+
+ $info['fileformat'] = 'svg';
+ $info['video']['dataformat'] = 'svg';
+ $info['video']['lossless'] = true;
+ //$info['video']['bits_per_sample'] = 24;
+ $info['video']['pixel_aspect_ratio'] = (float) 1;
+
+ if (!empty($info['svg']['svg']['sections']['width'])) {
+ $info['svg']['width'] = intval($info['svg']['svg']['sections']['width']);
+ }
+ if (!empty($info['svg']['svg']['sections']['height'])) {
+ $info['svg']['height'] = intval($info['svg']['svg']['sections']['height']);
+ }
+ if (!empty($info['svg']['svg']['sections']['version'])) {
+ $info['svg']['version'] = $info['svg']['svg']['sections']['version'];
+ }
+ if (!isset($info['svg']['version']) && isset($info['svg']['doctype']['sections'])) {
+ foreach ($info['svg']['doctype']['sections'] as $key => $value) {
+ if (preg_match('#//W3C//DTD SVG ([0-9\.]+)//#i', $key, $matches)) {
+ $info['svg']['version'] = $matches[1];
+ break;
+ }
+ }
+ }
+
+ if (!empty($info['svg']['width'])) {
+ $info['video']['resolution_x'] = $info['svg']['width'];
+ }
+ if (!empty($info['svg']['height'])) {
+ $info['video']['resolution_y'] = $info['svg']['height'];
+ }
+
+ return true;
+ }
+ $info['error'][] = 'Did not find expected <svg> tag';
+ return false;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.graphic.tiff.php b/3rdparty/getid3/module.graphic.tiff.php
index ae57cd6ad2c..e977124216a 100644
--- a/apps/media/getID3/getid3/module.graphic.tiff.php
+++ b/3rdparty/getid3/module.graphic.tiff.php
@@ -14,56 +14,57 @@
/////////////////////////////////////////////////////////////////
-class getid3_tiff
+class getid3_tiff extends getid3_handler
{
- function getid3_tiff(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $TIFFheader = fread($fd, 4);
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $TIFFheader = fread($this->getid3->fp, 4);
switch (substr($TIFFheader, 0, 2)) {
case 'II':
- $ThisFileInfo['tiff']['byte_order'] = 'Intel';
+ $info['tiff']['byte_order'] = 'Intel';
break;
case 'MM':
- $ThisFileInfo['tiff']['byte_order'] = 'Motorola';
+ $info['tiff']['byte_order'] = 'Motorola';
break;
default:
- $ThisFileInfo['error'][] = 'Invalid TIFF byte order identifier ('.substr($TIFFheader, 0, 2).') at offset '.$ThisFileInfo['avdataoffset'];
+ $info['error'][] = 'Invalid TIFF byte order identifier ('.substr($TIFFheader, 0, 2).') at offset '.$info['avdataoffset'];
return false;
break;
}
- $ThisFileInfo['fileformat'] = 'tiff';
- $ThisFileInfo['video']['dataformat'] = 'tiff';
- $ThisFileInfo['video']['lossless'] = true;
- $ThisFileInfo['tiff']['ifd'] = array();
+ $info['fileformat'] = 'tiff';
+ $info['video']['dataformat'] = 'tiff';
+ $info['video']['lossless'] = true;
+ $info['tiff']['ifd'] = array();
$CurrentIFD = array();
$FieldTypeByteLength = array(1=>1, 2=>1, 3=>2, 4=>4, 5=>8);
- $nextIFDoffset = $this->TIFFendian2Int(fread($fd, 4), $ThisFileInfo['tiff']['byte_order']);
+ $nextIFDoffset = $this->TIFFendian2Int(fread($this->getid3->fp, 4), $info['tiff']['byte_order']);
while ($nextIFDoffset > 0) {
$CurrentIFD['offset'] = $nextIFDoffset;
- fseek($fd, $ThisFileInfo['avdataoffset'] + $nextIFDoffset, SEEK_SET);
- $CurrentIFD['fieldcount'] = $this->TIFFendian2Int(fread($fd, 2), $ThisFileInfo['tiff']['byte_order']);
+ fseek($this->getid3->fp, $info['avdataoffset'] + $nextIFDoffset, SEEK_SET);
+ $CurrentIFD['fieldcount'] = $this->TIFFendian2Int(fread($this->getid3->fp, 2), $info['tiff']['byte_order']);
for ($i = 0; $i < $CurrentIFD['fieldcount']; $i++) {
- $CurrentIFD['fields'][$i]['raw']['tag'] = $this->TIFFendian2Int(fread($fd, 2), $ThisFileInfo['tiff']['byte_order']);
- $CurrentIFD['fields'][$i]['raw']['type'] = $this->TIFFendian2Int(fread($fd, 2), $ThisFileInfo['tiff']['byte_order']);
- $CurrentIFD['fields'][$i]['raw']['length'] = $this->TIFFendian2Int(fread($fd, 4), $ThisFileInfo['tiff']['byte_order']);
- $CurrentIFD['fields'][$i]['raw']['offset'] = fread($fd, 4);
+ $CurrentIFD['fields'][$i]['raw']['tag'] = $this->TIFFendian2Int(fread($this->getid3->fp, 2), $info['tiff']['byte_order']);
+ $CurrentIFD['fields'][$i]['raw']['type'] = $this->TIFFendian2Int(fread($this->getid3->fp, 2), $info['tiff']['byte_order']);
+ $CurrentIFD['fields'][$i]['raw']['length'] = $this->TIFFendian2Int(fread($this->getid3->fp, 4), $info['tiff']['byte_order']);
+ $CurrentIFD['fields'][$i]['raw']['offset'] = fread($this->getid3->fp, 4);
switch ($CurrentIFD['fields'][$i]['raw']['type']) {
case 1: // BYTE An 8-bit unsigned integer.
if ($CurrentIFD['fields'][$i]['raw']['length'] <= 4) {
- $CurrentIFD['fields'][$i]['value'] = $this->TIFFendian2Int(substr($CurrentIFD['fields'][$i]['raw']['offset'], 0, 1), $ThisFileInfo['tiff']['byte_order']);
+ $CurrentIFD['fields'][$i]['value'] = $this->TIFFendian2Int(substr($CurrentIFD['fields'][$i]['raw']['offset'], 0, 1), $info['tiff']['byte_order']);
} else {
- $CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $ThisFileInfo['tiff']['byte_order']);
+ $CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $info['tiff']['byte_order']);
}
break;
@@ -71,23 +72,23 @@ class getid3_tiff
if ($CurrentIFD['fields'][$i]['raw']['length'] <= 4) {
$CurrentIFD['fields'][$i]['value'] = substr($CurrentIFD['fields'][$i]['raw']['offset'], 3);
} else {
- $CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $ThisFileInfo['tiff']['byte_order']);
+ $CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $info['tiff']['byte_order']);
}
break;
case 3: // SHORT A 16-bit (2-byte) unsigned integer.
if ($CurrentIFD['fields'][$i]['raw']['length'] <= 2) {
- $CurrentIFD['fields'][$i]['value'] = $this->TIFFendian2Int(substr($CurrentIFD['fields'][$i]['raw']['offset'], 0, 2), $ThisFileInfo['tiff']['byte_order']);
+ $CurrentIFD['fields'][$i]['value'] = $this->TIFFendian2Int(substr($CurrentIFD['fields'][$i]['raw']['offset'], 0, 2), $info['tiff']['byte_order']);
} else {
- $CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $ThisFileInfo['tiff']['byte_order']);
+ $CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $info['tiff']['byte_order']);
}
break;
case 4: // LONG A 32-bit (4-byte) unsigned integer.
if ($CurrentIFD['fields'][$i]['raw']['length'] <= 1) {
- $CurrentIFD['fields'][$i]['value'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $ThisFileInfo['tiff']['byte_order']);
+ $CurrentIFD['fields'][$i]['value'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $info['tiff']['byte_order']);
} else {
- $CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $ThisFileInfo['tiff']['byte_order']);
+ $CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $info['tiff']['byte_order']);
}
break;
@@ -96,13 +97,13 @@ class getid3_tiff
}
}
- $ThisFileInfo['tiff']['ifd'][] = $CurrentIFD;
+ $info['tiff']['ifd'][] = $CurrentIFD;
$CurrentIFD = array();
- $nextIFDoffset = $this->TIFFendian2Int(fread($fd, 4), $ThisFileInfo['tiff']['byte_order']);
+ $nextIFDoffset = $this->TIFFendian2Int(fread($this->getid3->fp, 4), $info['tiff']['byte_order']);
}
- foreach ($ThisFileInfo['tiff']['ifd'] as $IFDid => $IFDarray) {
+ foreach ($info['tiff']['ifd'] as $IFDid => $IFDarray) {
foreach ($IFDarray['fields'] as $key => $fieldarray) {
switch ($fieldarray['raw']['tag']) {
case 256: // ImageWidth
@@ -110,8 +111,8 @@ class getid3_tiff
case 258: // BitsPerSample
case 259: // Compression
if (!isset($fieldarray['value'])) {
- fseek($fd, $fieldarray['offset'], SEEK_SET);
- $ThisFileInfo['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = fread($fd, $fieldarray['raw']['length'] * $FieldTypeByteLength[$fieldarray['raw']['type']]);
+ fseek($this->getid3->fp, $fieldarray['offset'], SEEK_SET);
+ $info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = fread($this->getid3->fp, $fieldarray['raw']['length'] * $FieldTypeByteLength[$fieldarray['raw']['type']]);
}
break;
@@ -124,36 +125,36 @@ class getid3_tiff
case 315: // Artist
case 316: // HostComputer
if (isset($fieldarray['value'])) {
- $ThisFileInfo['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = $fieldarray['value'];
+ $info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = $fieldarray['value'];
} else {
- fseek($fd, $fieldarray['offset'], SEEK_SET);
- $ThisFileInfo['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = fread($fd, $fieldarray['raw']['length'] * $FieldTypeByteLength[$fieldarray['raw']['type']]);
+ fseek($this->getid3->fp, $fieldarray['offset'], SEEK_SET);
+ $info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = fread($this->getid3->fp, $fieldarray['raw']['length'] * $FieldTypeByteLength[$fieldarray['raw']['type']]);
}
break;
}
switch ($fieldarray['raw']['tag']) {
case 256: // ImageWidth
- $ThisFileInfo['video']['resolution_x'] = $fieldarray['value'];
+ $info['video']['resolution_x'] = $fieldarray['value'];
break;
case 257: // ImageLength
- $ThisFileInfo['video']['resolution_y'] = $fieldarray['value'];
+ $info['video']['resolution_y'] = $fieldarray['value'];
break;
case 258: // BitsPerSample
if (isset($fieldarray['value'])) {
- $ThisFileInfo['video']['bits_per_sample'] = $fieldarray['value'];
+ $info['video']['bits_per_sample'] = $fieldarray['value'];
} else {
- $ThisFileInfo['video']['bits_per_sample'] = 0;
+ $info['video']['bits_per_sample'] = 0;
for ($i = 0; $i < $fieldarray['raw']['length']; $i++) {
- $ThisFileInfo['video']['bits_per_sample'] += $this->TIFFendian2Int(substr($ThisFileInfo['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'], $i * $FieldTypeByteLength[$fieldarray['raw']['type']], $FieldTypeByteLength[$fieldarray['raw']['type']]), $ThisFileInfo['tiff']['byte_order']);
+ $info['video']['bits_per_sample'] += $this->TIFFendian2Int(substr($info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'], $i * $FieldTypeByteLength[$fieldarray['raw']['type']], $FieldTypeByteLength[$fieldarray['raw']['type']]), $info['tiff']['byte_order']);
}
}
break;
case 259: // Compression
- $ThisFileInfo['video']['codec'] = $this->TIFFcompressionMethod($fieldarray['value']);
+ $info['video']['codec'] = $this->TIFFcompressionMethod($fieldarray['value']);
break;
case 270: // ImageDescription
@@ -163,7 +164,12 @@ class getid3_tiff
case 306: // DateTime
case 315: // Artist
case 316: // HostComputer
- @$ThisFileInfo['tiff']['comments'][$this->TIFFcommentName($fieldarray['raw']['tag'])][] = $ThisFileInfo['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'];
+ $TIFFcommentName = $this->TIFFcommentName($fieldarray['raw']['tag']);
+ if (isset($info['tiff']['comments'][$TIFFcommentName])) {
+ $info['tiff']['comments'][$TIFFcommentName][] = $info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'];
+ } else {
+ $info['tiff']['comments'][$TIFFcommentName] = array($info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data']);
+ }
break;
default:
diff --git a/3rdparty/getid3/module.misc.cue.php b/3rdparty/getid3/module.misc.cue.php
new file mode 100644
index 00000000000..c99ce247984
--- /dev/null
+++ b/3rdparty/getid3/module.misc.cue.php
@@ -0,0 +1,312 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.misc.cue.php //
+// module for analyzing CUEsheet files //
+// dependencies: NONE //
+// //
+/////////////////////////////////////////////////////////////////
+// //
+// Module originally written [2009-Mar-25] by //
+// Nigel Barnes <ngbarnesØhotmail*com> //
+// Minor reformatting and similar small changes to integrate //
+// into getID3 by James Heinrich <info@getid3.org> //
+// ///
+/////////////////////////////////////////////////////////////////
+
+/*
+ * CueSheet parser by Nigel Barnes.
+ *
+ * This is a PHP conversion of CueSharp 0.5 by Wyatt O'Day (wyday.com/cuesharp)
+ */
+
+/**
+ * A CueSheet class used to open and parse cuesheets.
+ *
+ */
+class getid3_cue extends getid3_handler
+{
+ var $cuesheet = array();
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $info['fileformat'] = 'cue';
+ $this->readCueSheetFilename($info['filenamepath']);
+ $info['cue'] = $this->cuesheet;
+ return true;
+ }
+
+
+
+ function readCueSheetFilename($filename)
+ {
+ $filedata = file_get_contents($filename);
+ return $this->readCueSheet($filedata);
+ }
+ /**
+ * Parses a cue sheet file.
+ *
+ * @param string $filename - The filename for the cue sheet to open.
+ */
+ function readCueSheet(&$filedata)
+ {
+ $cue_lines = array();
+ foreach (explode("\n", str_replace("\r", null, $filedata)) as $line)
+ {
+ if ( (strlen($line) > 0) && ($line[0] != '#'))
+ {
+ $cue_lines[] = trim($line);
+ }
+ }
+ $this->parseCueSheet($cue_lines);
+
+ return $this->cuesheet;
+ }
+
+ /**
+ * Parses the cue sheet array.
+ *
+ * @param array $file - The cuesheet as an array of each line.
+ */
+ function parseCueSheet($file)
+ {
+ //-1 means still global, all others are track specific
+ $track_on = -1;
+
+ for ($i=0; $i < count($file); $i++)
+ {
+ list($key) = explode(' ', strtolower($file[$i]), 2);
+ switch ($key)
+ {
+ case 'catalog':
+ case 'cdtextfile':
+ case 'isrc':
+ case 'performer':
+ case 'songwriter':
+ case 'title':
+ $this->parseString($file[$i], $track_on);
+ break;
+ case 'file':
+ $currentFile = $this->parseFile($file[$i]);
+ break;
+ case 'flags':
+ $this->parseFlags($file[$i], $track_on);
+ break;
+ case 'index':
+ case 'postgap':
+ case 'pregap':
+ $this->parseIndex($file[$i], $track_on);
+ break;
+ case 'rem':
+ $this->parseComment($file[$i], $track_on);
+ break;
+ case 'track':
+ $track_on++;
+ $this->parseTrack($file[$i], $track_on);
+ if (isset($currentFile)) // if there's a file
+ {
+ $this->cuesheet['tracks'][$track_on]['datafile'] = $currentFile;
+ }
+ break;
+ default:
+ //save discarded junk and place string[] with track it was found in
+ $this->parseGarbage($file[$i], $track_on);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Parses the REM command.
+ *
+ * @param string $line - The line in the cue file that contains the TRACK command.
+ * @param integer $track_on - The track currently processing.
+ */
+ function parseComment($line, $track_on)
+ {
+ $explodedline = explode(' ', $line, 3);
+ $comment_REM = (isset($explodedline[0]) ? $explodedline[0] : '');
+ $comment_type = (isset($explodedline[1]) ? $explodedline[1] : '');
+ $comment_data = (isset($explodedline[2]) ? $explodedline[2] : '');
+ if (($comment_REM == 'REM') && $comment_type) {
+ $comment_type = strtolower($comment_type);
+ $commment_data = trim($comment_data, ' "');
+ if ($track_on != -1) {
+ $this->cuesheet['tracks'][$track_on]['comments'][$comment_type][] = $comment_data;
+ } else {
+ $this->cuesheet['comments'][$comment_type][] = $comment_data;
+ }
+ }
+ }
+
+ /**
+ * Parses the FILE command.
+ *
+ * @param string $line - The line in the cue file that contains the FILE command.
+ * @return array - Array of FILENAME and TYPE of file..
+ */
+ function parseFile($line)
+ {
+ $line = substr($line, strpos($line, ' ') + 1);
+ $type = strtolower(substr($line, strrpos($line, ' ')));
+
+ //remove type
+ $line = substr($line, 0, strrpos($line, ' ') - 1);
+
+ //if quotes around it, remove them.
+ $line = trim($line, '"');
+
+ return array('filename'=>$line, 'type'=>$type);
+ }
+
+ /**
+ * Parses the FLAG command.
+ *
+ * @param string $line - The line in the cue file that contains the TRACK command.
+ * @param integer $track_on - The track currently processing.
+ */
+ function parseFlags($line, $track_on)
+ {
+ if ($track_on != -1)
+ {
+ foreach (explode(' ', strtolower($line)) as $type)
+ {
+ switch ($type)
+ {
+ case 'flags':
+ // first entry in this line
+ $this->cuesheet['tracks'][$track_on]['flags'] = array(
+ '4ch' => false,
+ 'data' => false,
+ 'dcp' => false,
+ 'pre' => false,
+ 'scms' => false,
+ );
+ break;
+ case 'data':
+ case 'dcp':
+ case '4ch':
+ case 'pre':
+ case 'scms':
+ $this->cuesheet['tracks'][$track_on]['flags'][$type] = true;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Collect any unidentified data.
+ *
+ * @param string $line - The line in the cue file that contains the TRACK command.
+ * @param integer $track_on - The track currently processing.
+ */
+ function parseGarbage($line, $track_on)
+ {
+ if ( strlen($line) > 0 )
+ {
+ if ($track_on == -1)
+ {
+ $this->cuesheet['garbage'][] = $line;
+ }
+ else
+ {
+ $this->cuesheet['tracks'][$track_on]['garbage'][] = $line;
+ }
+ }
+ }
+
+ /**
+ * Parses the INDEX command of a TRACK.
+ *
+ * @param string $line - The line in the cue file that contains the TRACK command.
+ * @param integer $track_on - The track currently processing.
+ */
+ function parseIndex($line, $track_on)
+ {
+ $type = strtolower(substr($line, 0, strpos($line, ' ')));
+ $line = substr($line, strpos($line, ' ') + 1);
+
+ if ($type == 'index')
+ {
+ //read the index number
+ $number = intval(substr($line, 0, strpos($line, ' ')));
+ $line = substr($line, strpos($line, ' ') + 1);
+ }
+
+ //extract the minutes, seconds, and frames
+ $explodedline = explode(':', $line);
+ $minutes = (isset($explodedline[0]) ? $explodedline[0] : '');
+ $seconds = (isset($explodedline[1]) ? $explodedline[1] : '');
+ $frames = (isset($explodedline[2]) ? $explodedline[2] : '');
+
+ switch ($type) {
+ case 'index':
+ $this->cuesheet['tracks'][$track_on][$type][$number] = array('minutes'=>intval($minutes), 'seconds'=>intval($seconds), 'frames'=>intval($frames));
+ break;
+ case 'pregap':
+ case 'postgap':
+ $this->cuesheet['tracks'][$track_on][$type] = array('minutes'=>intval($minutes), 'seconds'=>intval($seconds), 'frames'=>intval($frames));
+ break;
+ }
+ }
+
+ function parseString($line, $track_on)
+ {
+ $category = strtolower(substr($line, 0, strpos($line, ' ')));
+ $line = substr($line, strpos($line, ' ') + 1);
+
+ //get rid of the quotes
+ $line = trim($line, '"');
+
+ switch ($category)
+ {
+ case 'catalog':
+ case 'cdtextfile':
+ case 'isrc':
+ case 'performer':
+ case 'songwriter':
+ case 'title':
+ if ($track_on == -1)
+ {
+ $this->cuesheet[$category] = $line;
+ }
+ else
+ {
+ $this->cuesheet['tracks'][$track_on][$category] = $line;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Parses the TRACK command.
+ *
+ * @param string $line - The line in the cue file that contains the TRACK command.
+ * @param integer $track_on - The track currently processing.
+ */
+ function parseTrack($line, $track_on)
+ {
+ $line = substr($line, strpos($line, ' ') + 1);
+ $track = ltrim(substr($line, 0, strpos($line, ' ')), '0');
+
+ //find the data type.
+ $datatype = strtolower(substr($line, strpos($line, ' ') + 1));
+
+ $this->cuesheet['tracks'][$track_on] = array('track_number'=>$track, 'datatype'=>$datatype);
+ }
+
+}
+
+?>
diff --git a/3rdparty/getid3/module.misc.exe.php b/3rdparty/getid3/module.misc.exe.php
new file mode 100644
index 00000000000..108e62ecd7b
--- /dev/null
+++ b/3rdparty/getid3/module.misc.exe.php
@@ -0,0 +1,61 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.misc.exe.php //
+// module for analyzing EXE files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_exe extends getid3_handler
+{
+
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $EXEheader = fread($this->getid3->fp, 28);
+
+ $magic = 'MZ';
+ if (substr($EXEheader, 0, 2) != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($EXEheader, 0, 2)).'"';
+ return false;
+ }
+
+ $info['fileformat'] = 'exe';
+ $info['exe']['mz']['magic'] = 'MZ';
+
+ $info['exe']['mz']['raw']['last_page_size'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 2, 2));
+ $info['exe']['mz']['raw']['page_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 4, 2));
+ $info['exe']['mz']['raw']['relocation_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 6, 2));
+ $info['exe']['mz']['raw']['header_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 8, 2));
+ $info['exe']['mz']['raw']['min_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 10, 2));
+ $info['exe']['mz']['raw']['max_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 12, 2));
+ $info['exe']['mz']['raw']['initial_ss'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 14, 2));
+ $info['exe']['mz']['raw']['initial_sp'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 16, 2));
+ $info['exe']['mz']['raw']['checksum'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 18, 2));
+ $info['exe']['mz']['raw']['cs_ip'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 20, 4));
+ $info['exe']['mz']['raw']['relocation_table_offset'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 24, 2));
+ $info['exe']['mz']['raw']['overlay_number'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 26, 2));
+
+ $info['exe']['mz']['byte_size'] = (($info['exe']['mz']['raw']['page_count'] - 1)) * 512 + $info['exe']['mz']['raw']['last_page_size'];
+ $info['exe']['mz']['header_size'] = $info['exe']['mz']['raw']['header_paragraphs'] * 16;
+ $info['exe']['mz']['memory_minimum'] = $info['exe']['mz']['raw']['min_memory_paragraphs'] * 16;
+ $info['exe']['mz']['memory_recommended'] = $info['exe']['mz']['raw']['max_memory_paragraphs'] * 16;
+
+$info['error'][] = 'EXE parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
+return false;
+
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.misc.iso.php b/3rdparty/getid3/module.misc.iso.php
index 94df9294f4e..727fdf8701c 100644
--- a/apps/media/getID3/getid3/module.misc.iso.php
+++ b/3rdparty/getid3/module.misc.iso.php
@@ -14,25 +14,27 @@
/////////////////////////////////////////////////////////////////
-class getid3_iso
+class getid3_iso extends getid3_handler
{
- function getid3_iso($fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'iso';
+ function Analyze() {
+ $info = &$this->getid3->info;
+
+ $info['fileformat'] = 'iso';
for ($i = 16; $i <= 19; $i++) {
- fseek($fd, 2048 * $i, SEEK_SET);
- $ISOheader = fread($fd, 2048);
+ fseek($this->getid3->fp, 2048 * $i, SEEK_SET);
+ $ISOheader = fread($this->getid3->fp, 2048);
if (substr($ISOheader, 1, 5) == 'CD001') {
switch (ord($ISOheader{0})) {
case 1:
- $ThisFileInfo['iso']['primary_volume_descriptor']['offset'] = 2048 * $i;
- $this->ParsePrimaryVolumeDescriptor($ISOheader, $ThisFileInfo);
+ $info['iso']['primary_volume_descriptor']['offset'] = 2048 * $i;
+ $this->ParsePrimaryVolumeDescriptor($ISOheader);
break;
case 2:
- $ThisFileInfo['iso']['supplementary_volume_descriptor']['offset'] = 2048 * $i;
- $this->ParseSupplementaryVolumeDescriptor($ISOheader, $ThisFileInfo);
+ $info['iso']['supplementary_volume_descriptor']['offset'] = 2048 * $i;
+ $this->ParseSupplementaryVolumeDescriptor($ISOheader);
break;
default:
@@ -42,35 +44,33 @@ class getid3_iso
}
}
- $this->ParsePathTable($fd, $ThisFileInfo);
-
- $ThisFileInfo['iso']['files'] = array();
- foreach ($ThisFileInfo['iso']['path_table']['directories'] as $directorynum => $directorydata) {
-
- $ThisFileInfo['iso']['directories'][$directorynum] = $this->ParseDirectoryRecord($fd, $directorydata, $ThisFileInfo);
+ $this->ParsePathTable();
+ $info['iso']['files'] = array();
+ foreach ($info['iso']['path_table']['directories'] as $directorynum => $directorydata) {
+ $info['iso']['directories'][$directorynum] = $this->ParseDirectoryRecord($directorydata);
}
return true;
-
}
- function ParsePrimaryVolumeDescriptor(&$ISOheader, &$ThisFileInfo) {
+ function ParsePrimaryVolumeDescriptor(&$ISOheader) {
// ISO integer values are stored *BOTH* Little-Endian AND Big-Endian format!!
// ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field
// shortcuts
- $ThisFileInfo['iso']['primary_volume_descriptor']['raw'] = array();
- $thisfile_iso_primaryVD = &$ThisFileInfo['iso']['primary_volume_descriptor'];
+ $info = &$this->getid3->info;
+ $info['iso']['primary_volume_descriptor']['raw'] = array();
+ $thisfile_iso_primaryVD = &$info['iso']['primary_volume_descriptor'];
$thisfile_iso_primaryVD_raw = &$thisfile_iso_primaryVD['raw'];
$thisfile_iso_primaryVD_raw['volume_descriptor_type'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 0, 1));
$thisfile_iso_primaryVD_raw['standard_identifier'] = substr($ISOheader, 1, 5);
if ($thisfile_iso_primaryVD_raw['standard_identifier'] != 'CD001') {
- $ThisFileInfo['error'][] = 'Expected "CD001" at offset ('.($thisfile_iso_primaryVD['offset'] + 1).'), found "'.$thisfile_iso_primaryVD_raw['standard_identifier'].'" instead';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['iso']);
+ $info['error'][] = 'Expected "CD001" at offset ('.($thisfile_iso_primaryVD['offset'] + 1).'), found "'.$thisfile_iso_primaryVD_raw['standard_identifier'].'" instead';
+ unset($info['fileformat']);
+ unset($info['iso']);
return false;
}
@@ -121,29 +121,30 @@ class getid3_iso
$thisfile_iso_primaryVD['volume_expiration_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw['volume_expiration_date_time']);
$thisfile_iso_primaryVD['volume_effective_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw['volume_effective_date_time']);
- if (($thisfile_iso_primaryVD_raw['volume_space_size'] * 2048) > $ThisFileInfo['filesize']) {
- $ThisFileInfo['error'][] = 'Volume Space Size ('.($thisfile_iso_primaryVD_raw['volume_space_size'] * 2048).' bytes) is larger than the file size ('.$ThisFileInfo['filesize'].' bytes) (truncated file?)';
+ if (($thisfile_iso_primaryVD_raw['volume_space_size'] * 2048) > $info['filesize']) {
+ $info['error'][] = 'Volume Space Size ('.($thisfile_iso_primaryVD_raw['volume_space_size'] * 2048).' bytes) is larger than the file size ('.$info['filesize'].' bytes) (truncated file?)';
}
return true;
}
- function ParseSupplementaryVolumeDescriptor(&$ISOheader, &$ThisFileInfo) {
+ function ParseSupplementaryVolumeDescriptor(&$ISOheader) {
// ISO integer values are stored Both-Endian format!!
// ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field
// shortcuts
- $ThisFileInfo['iso']['supplementary_volume_descriptor']['raw'] = array();
- $thisfile_iso_supplementaryVD = &$ThisFileInfo['iso']['supplementary_volume_descriptor'];
+ $info = &$this->getid3->info;
+ $info['iso']['supplementary_volume_descriptor']['raw'] = array();
+ $thisfile_iso_supplementaryVD = &$info['iso']['supplementary_volume_descriptor'];
$thisfile_iso_supplementaryVD_raw = &$thisfile_iso_supplementaryVD['raw'];
$thisfile_iso_supplementaryVD_raw['volume_descriptor_type'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 0, 1));
$thisfile_iso_supplementaryVD_raw['standard_identifier'] = substr($ISOheader, 1, 5);
if ($thisfile_iso_supplementaryVD_raw['standard_identifier'] != 'CD001') {
- $ThisFileInfo['error'][] = 'Expected "CD001" at offset ('.($thisfile_iso_supplementaryVD['offset'] + 1).'), found "'.$thisfile_iso_supplementaryVD_raw['standard_identifier'].'" instead';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['iso']);
+ $info['error'][] = 'Expected "CD001" at offset ('.($thisfile_iso_supplementaryVD['offset'] + 1).'), found "'.$thisfile_iso_supplementaryVD_raw['standard_identifier'].'" instead';
+ unset($info['fileformat']);
+ unset($info['iso']);
return false;
}
@@ -199,62 +200,63 @@ class getid3_iso
$thisfile_iso_supplementaryVD['volume_expiration_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw['volume_expiration_date_time']);
$thisfile_iso_supplementaryVD['volume_effective_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw['volume_effective_date_time']);
- if (($thisfile_iso_supplementaryVD_raw['volume_space_size'] * $thisfile_iso_supplementaryVD_raw['logical_block_size']) > $ThisFileInfo['filesize']) {
- $ThisFileInfo['error'][] = 'Volume Space Size ('.($thisfile_iso_supplementaryVD_raw['volume_space_size'] * $thisfile_iso_supplementaryVD_raw['logical_block_size']).' bytes) is larger than the file size ('.$ThisFileInfo['filesize'].' bytes) (truncated file?)';
+ if (($thisfile_iso_supplementaryVD_raw['volume_space_size'] * $thisfile_iso_supplementaryVD_raw['logical_block_size']) > $info['filesize']) {
+ $info['error'][] = 'Volume Space Size ('.($thisfile_iso_supplementaryVD_raw['volume_space_size'] * $thisfile_iso_supplementaryVD_raw['logical_block_size']).' bytes) is larger than the file size ('.$info['filesize'].' bytes) (truncated file?)';
}
return true;
}
- function ParsePathTable($fd, &$ThisFileInfo) {
- if (!isset($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location']) && !isset($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_l_location'])) {
+ function ParsePathTable() {
+ $info = &$this->getid3->info;
+ if (!isset($info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location']) && !isset($info['iso']['primary_volume_descriptor']['raw']['path_table_l_location'])) {
return false;
}
- if (isset($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'])) {
- $PathTableLocation = $ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'];
- $PathTableSize = $ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_size'];
+ if (isset($info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'])) {
+ $PathTableLocation = $info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'];
+ $PathTableSize = $info['iso']['supplementary_volume_descriptor']['raw']['path_table_size'];
$TextEncoding = 'UTF-16BE'; // Big-Endian Unicode
} else {
- $PathTableLocation = $ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_l_location'];
- $PathTableSize = $ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_size'];
+ $PathTableLocation = $info['iso']['primary_volume_descriptor']['raw']['path_table_l_location'];
+ $PathTableSize = $info['iso']['primary_volume_descriptor']['raw']['path_table_size'];
$TextEncoding = 'ISO-8859-1'; // Latin-1
}
- if (($PathTableLocation * 2048) > $ThisFileInfo['filesize']) {
- $ThisFileInfo['error'][] = 'Path Table Location specifies an offset ('.($PathTableLocation * 2048).') beyond the end-of-file ('.$ThisFileInfo['filesize'].')';
+ if (($PathTableLocation * 2048) > $info['filesize']) {
+ $info['error'][] = 'Path Table Location specifies an offset ('.($PathTableLocation * 2048).') beyond the end-of-file ('.$info['filesize'].')';
return false;
}
- $ThisFileInfo['iso']['path_table']['offset'] = $PathTableLocation * 2048;
- fseek($fd, $ThisFileInfo['iso']['path_table']['offset'], SEEK_SET);
- $ThisFileInfo['iso']['path_table']['raw'] = fread($fd, $PathTableSize);
+ $info['iso']['path_table']['offset'] = $PathTableLocation * 2048;
+ fseek($this->getid3->fp, $info['iso']['path_table']['offset'], SEEK_SET);
+ $info['iso']['path_table']['raw'] = fread($this->getid3->fp, $PathTableSize);
$offset = 0;
$pathcounter = 1;
while ($offset < $PathTableSize) {
// shortcut
- $ThisFileInfo['iso']['path_table']['directories'][$pathcounter] = array();
- $thisfile_iso_pathtable_directories_current = &$ThisFileInfo['iso']['path_table']['directories'][$pathcounter];
+ $info['iso']['path_table']['directories'][$pathcounter] = array();
+ $thisfile_iso_pathtable_directories_current = &$info['iso']['path_table']['directories'][$pathcounter];
- $thisfile_iso_pathtable_directories_current['length'] = getid3_lib::LittleEndian2Int(substr($ThisFileInfo['iso']['path_table']['raw'], $offset, 1));
+ $thisfile_iso_pathtable_directories_current['length'] = getid3_lib::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 1));
$offset += 1;
- $thisfile_iso_pathtable_directories_current['extended_length'] = getid3_lib::LittleEndian2Int(substr($ThisFileInfo['iso']['path_table']['raw'], $offset, 1));
+ $thisfile_iso_pathtable_directories_current['extended_length'] = getid3_lib::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 1));
$offset += 1;
- $thisfile_iso_pathtable_directories_current['location_logical'] = getid3_lib::LittleEndian2Int(substr($ThisFileInfo['iso']['path_table']['raw'], $offset, 4));
+ $thisfile_iso_pathtable_directories_current['location_logical'] = getid3_lib::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 4));
$offset += 4;
- $thisfile_iso_pathtable_directories_current['parent_directory'] = getid3_lib::LittleEndian2Int(substr($ThisFileInfo['iso']['path_table']['raw'], $offset, 2));
+ $thisfile_iso_pathtable_directories_current['parent_directory'] = getid3_lib::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 2));
$offset += 2;
- $thisfile_iso_pathtable_directories_current['name'] = substr($ThisFileInfo['iso']['path_table']['raw'], $offset, $thisfile_iso_pathtable_directories_current['length']);
+ $thisfile_iso_pathtable_directories_current['name'] = substr($info['iso']['path_table']['raw'], $offset, $thisfile_iso_pathtable_directories_current['length']);
$offset += $thisfile_iso_pathtable_directories_current['length'] + ($thisfile_iso_pathtable_directories_current['length'] % 2);
- $thisfile_iso_pathtable_directories_current['name_ascii'] = getid3_lib::iconv_fallback($TextEncoding, $ThisFileInfo['encoding'], $thisfile_iso_pathtable_directories_current['name']);
+ $thisfile_iso_pathtable_directories_current['name_ascii'] = getid3_lib::iconv_fallback($TextEncoding, $info['encoding'], $thisfile_iso_pathtable_directories_current['name']);
$thisfile_iso_pathtable_directories_current['location_bytes'] = $thisfile_iso_pathtable_directories_current['location_logical'] * 2048;
if ($pathcounter == 1) {
$thisfile_iso_pathtable_directories_current['full_path'] = '/';
} else {
- $thisfile_iso_pathtable_directories_current['full_path'] = $ThisFileInfo['iso']['path_table']['directories'][$thisfile_iso_pathtable_directories_current['parent_directory']]['full_path'].$thisfile_iso_pathtable_directories_current['name_ascii'].'/';
+ $thisfile_iso_pathtable_directories_current['full_path'] = $info['iso']['path_table']['directories'][$thisfile_iso_pathtable_directories_current['parent_directory']]['full_path'].$thisfile_iso_pathtable_directories_current['name_ascii'].'/';
}
$FullPathArray[] = $thisfile_iso_pathtable_directories_current['full_path'];
@@ -265,19 +267,20 @@ class getid3_iso
}
- function ParseDirectoryRecord(&$fd, $directorydata, &$ThisFileInfo) {
- if (isset($ThisFileInfo['iso']['supplementary_volume_descriptor'])) {
+ function ParseDirectoryRecord($directorydata) {
+ $info = &$this->getid3->info;
+ if (isset($info['iso']['supplementary_volume_descriptor'])) {
$TextEncoding = 'UTF-16BE'; // Big-Endian Unicode
} else {
$TextEncoding = 'ISO-8859-1'; // Latin-1
}
- fseek($fd, $directorydata['location_bytes'], SEEK_SET);
- $DirectoryRecordData = fread($fd, 1);
+ fseek($this->getid3->fp, $directorydata['location_bytes'], SEEK_SET);
+ $DirectoryRecordData = fread($this->getid3->fp, 1);
while (ord($DirectoryRecordData{0}) > 33) {
- $DirectoryRecordData .= fread($fd, ord($DirectoryRecordData{0}) - 1);
+ $DirectoryRecordData .= fread($this->getid3->fp, ord($DirectoryRecordData{0}) - 1);
$ThisDirectoryRecord['raw']['length'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 0, 1));
$ThisDirectoryRecord['raw']['extended_attribute_length'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 1, 1));
@@ -291,7 +294,7 @@ class getid3_iso
$ThisDirectoryRecord['raw']['file_identifier_length'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 32, 1));
$ThisDirectoryRecord['raw']['file_identifier'] = substr($DirectoryRecordData, 33, $ThisDirectoryRecord['raw']['file_identifier_length']);
- $ThisDirectoryRecord['file_identifier_ascii'] = getid3_lib::iconv_fallback($TextEncoding, $ThisFileInfo['encoding'], $ThisDirectoryRecord['raw']['file_identifier']);
+ $ThisDirectoryRecord['file_identifier_ascii'] = getid3_lib::iconv_fallback($TextEncoding, $info['encoding'], $ThisDirectoryRecord['raw']['file_identifier']);
$ThisDirectoryRecord['filesize'] = $ThisDirectoryRecord['raw']['filesize'];
$ThisDirectoryRecord['offset_bytes'] = $ThisDirectoryRecord['raw']['offset_logical'] * 2048;
@@ -307,11 +310,11 @@ class getid3_iso
$ThisDirectoryRecord['filename'] = $directorydata['full_path'];
} else {
$ThisDirectoryRecord['filename'] = $directorydata['full_path'].$this->ISOstripFilenameVersion($ThisDirectoryRecord['file_identifier_ascii']);
- $ThisFileInfo['iso']['files'] = getid3_lib::array_merge_clobber($ThisFileInfo['iso']['files'], getid3_lib::CreateDeepArray($ThisDirectoryRecord['filename'], '/', $ThisDirectoryRecord['filesize']));
+ $info['iso']['files'] = getid3_lib::array_merge_clobber($info['iso']['files'], getid3_lib::CreateDeepArray($ThisDirectoryRecord['filename'], '/', $ThisDirectoryRecord['filesize']));
}
$DirectoryRecord[] = $ThisDirectoryRecord;
- $DirectoryRecordData = fread($fd, 1);
+ $DirectoryRecordData = fread($this->getid3->fp, 1);
}
return $DirectoryRecord;
diff --git a/apps/media/getID3/getid3/module.misc.msoffice.php b/3rdparty/getid3/module.misc.msoffice.php
index cb65abf2237..8fea108534a 100644
--- a/apps/media/getID3/getid3/module.misc.msoffice.php
+++ b/3rdparty/getid3/module.misc.msoffice.php
@@ -14,15 +14,23 @@
/////////////////////////////////////////////////////////////////
-class getid3_doc
+class getid3_msoffice extends getid3_handler
{
- function getid3_doc(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- $ThisFileInfo['fileformat'] = 'doc';
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $DOCFILEheader = fread($this->getid3->fp, 8);
+ $magic = "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1";
+ if (substr($DOCFILEheader, 0, 8) != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at '.$info['avdataoffset'].', found '.getid3_lib::PrintHexBytes(substr($DOCFILEheader, 0, 8)).' instead.';
+ return false;
+ }
+ $info['fileformat'] = 'msoffice';
- $ThisFileInfo['error'][] = 'MS Office (.doc, .xls, etc) parsing not enabled in this version of getID3()';
- return false;
+$info['error'][] = 'MS Office (.doc, .xls, etc) parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
+return false;
}
diff --git a/apps/media/getID3/getid3/module.misc.par2.php b/3rdparty/getid3/module.misc.par2.php
index 9f0e22180f8..d8b0a388b74 100644
--- a/apps/media/getID3/getid3/module.misc.par2.php
+++ b/3rdparty/getid3/module.misc.par2.php
@@ -14,14 +14,15 @@
/////////////////////////////////////////////////////////////////
-class getid3_par2
+class getid3_par2 extends getid3_handler
{
- function getid3_par2(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- $ThisFileInfo['fileformat'] = 'par2';
+ $info['fileformat'] = 'par2';
- $ThisFileInfo['error'][] = 'PAR2 parsing not enabled in this version of getID3()';
+ $info['error'][] = 'PAR2 parsing not enabled in this version of getID3()';
return false;
}
diff --git a/apps/media/getID3/getid3/module.misc.pdf.php b/3rdparty/getid3/module.misc.pdf.php
index c6e3294b695..38ed646a9e0 100644
--- a/apps/media/getID3/getid3/module.misc.pdf.php
+++ b/3rdparty/getid3/module.misc.pdf.php
@@ -14,14 +14,15 @@
/////////////////////////////////////////////////////////////////
-class getid3_pdf
+class getid3_pdf extends getid3_handler
{
- function getid3_pdf(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- $ThisFileInfo['fileformat'] = 'pdf';
+ $info['fileformat'] = 'pdf';
- $ThisFileInfo['error'][] = 'PDF parsing not enabled in this version of getID3()';
+ $info['error'][] = 'PDF parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
return false;
}
diff --git a/apps/media/getID3/getid3/module.tag.apetag.php b/3rdparty/getid3/module.tag.apetag.php
index 2b67e14b4ac..6522475f516 100644
--- a/apps/media/getID3/getid3/module.tag.apetag.php
+++ b/3rdparty/getid3/module.tag.apetag.php
@@ -13,13 +13,16 @@
// ///
/////////////////////////////////////////////////////////////////
-class getid3_apetag
+class getid3_apetag extends getid3_handler
{
+ var $inline_attachments = true; // true: return full data for all attachments; false: return no data for all attachments; integer: return data for attachments <= than this; string: save as file to this directory
+ var $overrideendoffset = 0;
- function getid3_apetag(&$fd, &$ThisFileInfo, $overrideendoffset=0) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- if ($ThisFileInfo['filesize'] >= pow(2, 31)) {
- $ThisFileInfo['warning'][] = 'Unable to check for APEtags because file is larger than 2GB';
+ if (!getid3_lib::intValueSupported($info['filesize'])) {
+ $info['warning'][] = 'Unable to check for APEtags because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
return false;
}
@@ -27,69 +30,69 @@ class getid3_apetag
$apetagheadersize = 32;
$lyrics3tagsize = 10;
- if ($overrideendoffset == 0) {
+ if ($this->overrideendoffset == 0) {
- fseek($fd, 0 - $id3v1tagsize - $apetagheadersize - $lyrics3tagsize, SEEK_END);
- $APEfooterID3v1 = fread($fd, $id3v1tagsize + $apetagheadersize + $lyrics3tagsize);
+ fseek($this->getid3->fp, 0 - $id3v1tagsize - $apetagheadersize - $lyrics3tagsize, SEEK_END);
+ $APEfooterID3v1 = fread($this->getid3->fp, $id3v1tagsize + $apetagheadersize + $lyrics3tagsize);
//if (preg_match('/APETAGEX.{24}TAG.{125}$/i', $APEfooterID3v1)) {
if (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $id3v1tagsize - $apetagheadersize, 8) == 'APETAGEX') {
// APE tag found before ID3v1
- $ThisFileInfo['ape']['tag_offset_end'] = $ThisFileInfo['filesize'] - $id3v1tagsize;
+ $info['ape']['tag_offset_end'] = $info['filesize'] - $id3v1tagsize;
//} elseif (preg_match('/APETAGEX.{24}$/i', $APEfooterID3v1)) {
} elseif (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $apetagheadersize, 8) == 'APETAGEX') {
// APE tag found, no ID3v1
- $ThisFileInfo['ape']['tag_offset_end'] = $ThisFileInfo['filesize'];
+ $info['ape']['tag_offset_end'] = $info['filesize'];
}
} else {
- fseek($fd, $overrideendoffset - $apetagheadersize, SEEK_SET);
- if (fread($fd, 8) == 'APETAGEX') {
- $ThisFileInfo['ape']['tag_offset_end'] = $overrideendoffset;
+ fseek($this->getid3->fp, $this->overrideendoffset - $apetagheadersize, SEEK_SET);
+ if (fread($this->getid3->fp, 8) == 'APETAGEX') {
+ $info['ape']['tag_offset_end'] = $this->overrideendoffset;
}
}
- if (!isset($ThisFileInfo['ape']['tag_offset_end'])) {
+ if (!isset($info['ape']['tag_offset_end'])) {
// APE tag not found
- unset($ThisFileInfo['ape']);
+ unset($info['ape']);
return false;
}
// shortcut
- $thisfile_ape = &$ThisFileInfo['ape'];
+ $thisfile_ape = &$info['ape'];
- fseek($fd, $thisfile_ape['tag_offset_end'] - $apetagheadersize, SEEK_SET);
- $APEfooterData = fread($fd, 32);
+ fseek($this->getid3->fp, $thisfile_ape['tag_offset_end'] - $apetagheadersize, SEEK_SET);
+ $APEfooterData = fread($this->getid3->fp, 32);
if (!($thisfile_ape['footer'] = $this->parseAPEheaderFooter($APEfooterData))) {
- $ThisFileInfo['error'][] = 'Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end'];
+ $info['error'][] = 'Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end'];
return false;
}
if (isset($thisfile_ape['footer']['flags']['header']) && $thisfile_ape['footer']['flags']['header']) {
- fseek($fd, $thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'] - $apetagheadersize, SEEK_SET);
- $thisfile_ape['tag_offset_start'] = ftell($fd);
- $APEtagData = fread($fd, $thisfile_ape['footer']['raw']['tagsize'] + $apetagheadersize);
+ fseek($this->getid3->fp, $thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'] - $apetagheadersize, SEEK_SET);
+ $thisfile_ape['tag_offset_start'] = ftell($this->getid3->fp);
+ $APEtagData = fread($this->getid3->fp, $thisfile_ape['footer']['raw']['tagsize'] + $apetagheadersize);
} else {
$thisfile_ape['tag_offset_start'] = $thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'];
- fseek($fd, $thisfile_ape['tag_offset_start'], SEEK_SET);
- $APEtagData = fread($fd, $thisfile_ape['footer']['raw']['tagsize']);
+ fseek($this->getid3->fp, $thisfile_ape['tag_offset_start'], SEEK_SET);
+ $APEtagData = fread($this->getid3->fp, $thisfile_ape['footer']['raw']['tagsize']);
}
- $ThisFileInfo['avdataend'] = $thisfile_ape['tag_offset_start'];
+ $info['avdataend'] = $thisfile_ape['tag_offset_start'];
- if (isset($ThisFileInfo['id3v1']['tag_offset_start']) && ($ThisFileInfo['id3v1']['tag_offset_start'] < $thisfile_ape['tag_offset_end'])) {
- $ThisFileInfo['warning'][] = 'ID3v1 tag information ignored since it appears to be a false synch in APEtag data';
- unset($ThisFileInfo['id3v1']);
- foreach ($ThisFileInfo['warning'] as $key => $value) {
+ if (isset($info['id3v1']['tag_offset_start']) && ($info['id3v1']['tag_offset_start'] < $thisfile_ape['tag_offset_end'])) {
+ $info['warning'][] = 'ID3v1 tag information ignored since it appears to be a false synch in APEtag data';
+ unset($info['id3v1']);
+ foreach ($info['warning'] as $key => $value) {
if ($value == 'Some ID3v1 fields do not use NULL characters for padding') {
- unset($ThisFileInfo['warning'][$key]);
- sort($ThisFileInfo['warning']);
+ unset($info['warning'][$key]);
+ sort($info['warning']);
break;
}
}
@@ -100,14 +103,14 @@ class getid3_apetag
if ($thisfile_ape['header'] = $this->parseAPEheaderFooter(substr($APEtagData, 0, $apetagheadersize))) {
$offset += $apetagheadersize;
} else {
- $ThisFileInfo['error'][] = 'Error parsing APE header at offset '.$thisfile_ape['tag_offset_start'];
+ $info['error'][] = 'Error parsing APE header at offset '.$thisfile_ape['tag_offset_start'];
return false;
}
}
// shortcut
- $ThisFileInfo['replay_gain'] = array();
- $thisfile_replaygain = &$ThisFileInfo['replay_gain'];
+ $info['replay_gain'] = array();
+ $thisfile_replaygain = &$info['replay_gain'];
for ($i = 0; $i < $thisfile_ape['footer']['raw']['tag_items']; $i++) {
$value_size = getid3_lib::LittleEndian2Int(substr($APEtagData, $offset, 4));
@@ -115,7 +118,7 @@ class getid3_apetag
$item_flags = getid3_lib::LittleEndian2Int(substr($APEtagData, $offset, 4));
$offset += 4;
if (strstr(substr($APEtagData, $offset), "\x00") === false) {
- $ThisFileInfo['error'][] = 'Cannot find null-byte (0x00) seperator between ItemKey #'.$i.' and value. ItemKey starts '.$offset.' bytes into the APE tag, at file offset '.($thisfile_ape['tag_offset_start'] + $offset);
+ $info['error'][] = 'Cannot find null-byte (0x00) seperator between ItemKey #'.$i.' and value. ItemKey starts '.$offset.' bytes into the APE tag, at file offset '.($thisfile_ape['tag_offset_start'] + $offset);
return false;
}
$ItemKeyLength = strpos($APEtagData, "\x00", $offset) - $offset;
@@ -125,6 +128,8 @@ class getid3_apetag
$thisfile_ape['items'][$item_key] = array();
$thisfile_ape_items_current = &$thisfile_ape['items'][$item_key];
+ $thisfile_ape_items_current['offset'] = $thisfile_ape['tag_offset_start'] + $offset;
+
$offset += ($ItemKeyLength + 1); // skip 0x00 terminator
$thisfile_ape_items_current['data'] = substr($APEtagData, $offset, $value_size);
$offset += $value_size;
@@ -150,7 +155,7 @@ class getid3_apetag
$thisfile_replaygain['track']['peak'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero!
$thisfile_replaygain['track']['originator'] = 'unspecified';
if ($thisfile_replaygain['track']['peak'] <= 0) {
- $ThisFileInfo['warning'][] = 'ReplayGain Track peak from APEtag appears invalid: '.$thisfile_replaygain['track']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")';
+ $info['warning'][] = 'ReplayGain Track peak from APEtag appears invalid: '.$thisfile_replaygain['track']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")';
}
break;
@@ -163,7 +168,7 @@ class getid3_apetag
$thisfile_replaygain['album']['peak'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero!
$thisfile_replaygain['album']['originator'] = 'unspecified';
if ($thisfile_replaygain['album']['peak'] <= 0) {
- $ThisFileInfo['warning'][] = 'ReplayGain Album peak from APEtag appears invalid: '.$thisfile_replaygain['album']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")';
+ $info['warning'][] = 'ReplayGain Album peak from APEtag appears invalid: '.$thisfile_replaygain['album']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")';
}
break;
@@ -187,23 +192,100 @@ class getid3_apetag
break;
case 'tracknumber':
- foreach ($thisfile_ape_items_current['data'] as $comment) {
- $thisfile_ape['comments']['track'][] = $comment;
+ if (is_array($thisfile_ape_items_current['data'])) {
+ foreach ($thisfile_ape_items_current['data'] as $comment) {
+ $thisfile_ape['comments']['track'][] = $comment;
+ }
}
break;
+ case 'cover art (artist)':
+ case 'cover art (back)':
+ case 'cover art (band logo)':
+ case 'cover art (band)':
+ case 'cover art (colored fish)':
+ case 'cover art (composer)':
+ case 'cover art (conductor)':
+ case 'cover art (front)':
+ case 'cover art (icon)':
+ case 'cover art (illustration)':
+ case 'cover art (lead)':
+ case 'cover art (leaflet)':
+ case 'cover art (lyricist)':
+ case 'cover art (media)':
+ case 'cover art (movie scene)':
+ case 'cover art (other icon)':
+ case 'cover art (other)':
+ case 'cover art (performance)':
+ case 'cover art (publisher logo)':
+ case 'cover art (recording)':
+ case 'cover art (studio)':
+ // list of possible cover arts from http://taglib-sharp.sourcearchive.com/documentation/2.0.3.0-2/Ape_2Tag_8cs-source.html
+ list($thisfile_ape_items_current['filename'], $thisfile_ape_items_current['data']) = explode("\x00", $thisfile_ape_items_current['data'], 2);
+ $thisfile_ape_items_current['data_offset'] = $thisfile_ape_items_current['offset'] + strlen($thisfile_ape_items_current['filename']."\x00");
+ $thisfile_ape_items_current['data_length'] = strlen($thisfile_ape_items_current['data']);
+
+ $thisfile_ape_items_current['image_mime'] = '';
+ $imageinfo = array();
+ $imagechunkcheck = getid3_lib::GetDataImageSize($thisfile_ape_items_current['data'], $imageinfo);
+ $thisfile_ape_items_current['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
+
+ do {
+ if ($this->inline_attachments === false) {
+ // skip entirely
+ unset($thisfile_ape_items_current['data']);
+ break;
+ }
+ if ($this->inline_attachments === true) {
+ // great
+ } elseif (is_int($this->inline_attachments)) {
+ if ($this->inline_attachments < $thisfile_ape_items_current['data_length']) {
+ // too big, skip
+ $info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' is too large to process inline ('.number_format($thisfile_ape_items_current['data_length']).' bytes)';
+ unset($thisfile_ape_items_current['data']);
+ break;
+ }
+ } elseif (is_string($this->inline_attachments)) {
+ $this->inline_attachments = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->inline_attachments), DIRECTORY_SEPARATOR);
+ if (!is_dir($this->inline_attachments) || !is_writable($this->inline_attachments)) {
+ // cannot write, skip
+ $info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$this->inline_attachments.'" (not writable)';
+ unset($thisfile_ape_items_current['data']);
+ break;
+ }
+ }
+ // if we get this far, must be OK
+ if (is_string($this->inline_attachments)) {
+ $destination_filename = $this->inline_attachments.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$thisfile_ape_items_current['data_offset'];
+ if (!file_exists($destination_filename) || is_writable($destination_filename)) {
+ file_put_contents($destination_filename, $thisfile_ape_items_current['data']);
+ } else {
+ $info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$destination_filename.'" (not writable)';
+ }
+ $thisfile_ape_items_current['data_filename'] = $destination_filename;
+ unset($thisfile_ape_items_current['data']);
+ } else {
+ if (!isset($info['ape']['comments']['picture'])) {
+ $info['ape']['comments']['picture'] = array();
+ }
+ $info['ape']['comments']['picture'][] = array('data'=>$thisfile_ape_items_current['data'], 'image_mime'=>$thisfile_ape_items_current['image_mime']);
+ }
+ } while (false);
+ break;
+
default:
- foreach ($thisfile_ape_items_current['data'] as $comment) {
- $thisfile_ape['comments'][strtolower($item_key)][] = $comment;
+ if (is_array($thisfile_ape_items_current['data'])) {
+ foreach ($thisfile_ape_items_current['data'] as $comment) {
+ $thisfile_ape['comments'][strtolower($item_key)][] = $comment;
+ }
}
break;
}
}
if (empty($thisfile_replaygain)) {
- unset($ThisFileInfo['replay_gain']);
+ unset($info['replay_gain']);
}
-
return true;
}
diff --git a/apps/media/getID3/getid3/module.tag.id3v1.php b/3rdparty/getid3/module.tag.id3v1.php
index 6fd2dd84a7b..a9932d13f32 100644
--- a/apps/media/getID3/getid3/module.tag.id3v1.php
+++ b/3rdparty/getid3/module.tag.id3v1.php
@@ -14,23 +14,24 @@
/////////////////////////////////////////////////////////////////
-class getid3_id3v1
+class getid3_id3v1 extends getid3_handler
{
- function getid3_id3v1(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
- if ($ThisFileInfo['filesize'] >= pow(2, 31)) {
- $ThisFileInfo['warning'][] = 'Unable to check for ID3v1 because file is larger than 2GB';
+ if (!getid3_lib::intValueSupported($info['filesize'])) {
+ $info['warning'][] = 'Unable to check for ID3v1 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
return false;
}
- fseek($fd, -256, SEEK_END);
- $preid3v1 = fread($fd, 128);
- $id3v1tag = fread($fd, 128);
+ fseek($this->getid3->fp, -256, SEEK_END);
+ $preid3v1 = fread($this->getid3->fp, 128);
+ $id3v1tag = fread($this->getid3->fp, 128);
if (substr($id3v1tag, 0, 3) == 'TAG') {
- $ThisFileInfo['avdataend'] = $ThisFileInfo['filesize'] - 128;
+ $info['avdataend'] = $info['filesize'] - 128;
$ParsedID3v1['title'] = $this->cutfield(substr($id3v1tag, 3, 30));
$ParsedID3v1['artist'] = $this->cutfield(substr($id3v1tag, 33, 30));
@@ -51,7 +52,7 @@ class getid3_id3v1
if (!empty($ParsedID3v1['genre'])) {
unset($ParsedID3v1['genreid']);
}
- if (empty($ParsedID3v1['genre']) || (@$ParsedID3v1['genre'] == 'Unknown')) {
+ if (isset($ParsedID3v1['genre']) && (empty($ParsedID3v1['genre']) || ($ParsedID3v1['genre'] == 'Unknown'))) {
unset($ParsedID3v1['genre']);
}
@@ -67,17 +68,17 @@ class getid3_id3v1
$ParsedID3v1['year'],
(isset($ParsedID3v1['genre']) ? $this->LookupGenreID($ParsedID3v1['genre']) : false),
$ParsedID3v1['comment'],
- @$ParsedID3v1['track']);
+ (!empty($ParsedID3v1['track']) ? $ParsedID3v1['track'] : ''));
$ParsedID3v1['padding_valid'] = true;
if ($id3v1tag !== $GoodFormatID3v1tag) {
$ParsedID3v1['padding_valid'] = false;
- $ThisFileInfo['warning'][] = 'Some ID3v1 fields do not use NULL characters for padding';
+ $info['warning'][] = 'Some ID3v1 fields do not use NULL characters for padding';
}
- $ParsedID3v1['tag_offset_end'] = $ThisFileInfo['filesize'];
+ $ParsedID3v1['tag_offset_end'] = $info['filesize'];
$ParsedID3v1['tag_offset_start'] = $ParsedID3v1['tag_offset_end'] - 128;
- $ThisFileInfo['id3v1'] = $ParsedID3v1;
+ $info['id3v1'] = $ParsedID3v1;
}
if (substr($preid3v1, 0, 3) == 'TAG') {
@@ -93,19 +94,19 @@ class getid3_id3v1
// a Lyrics3 tag footer was found before the last ID3v1, assume false "TAG" synch
} else {
// APE and Lyrics3 footers not found - assume double ID3v1
- $ThisFileInfo['warning'][] = 'Duplicate ID3v1 tag detected - this has been known to happen with iTunes';
- $ThisFileInfo['avdataend'] -= 128;
+ $info['warning'][] = 'Duplicate ID3v1 tag detected - this has been known to happen with iTunes';
+ $info['avdataend'] -= 128;
}
}
return true;
}
- function cutfield($str) {
+ static function cutfield($str) {
return trim(substr($str, 0, strcspn($str, "\x00")));
}
- function ArrayOfGenres($allowSCMPXextended=false) {
+ static function ArrayOfGenres($allowSCMPXextended=false) {
static $GenreLookup = array(
0 => 'Blues',
1 => 'Classic Rock',
@@ -251,7 +252,7 @@ class getid3_id3v1
141 => 'Christian Rock',
142 => 'Merengue',
143 => 'Salsa',
- 144 => 'Trash Metal',
+ 144 => 'Thrash Metal',
145 => 'Anime',
146 => 'JPop',
147 => 'Synthpop',
@@ -289,12 +290,15 @@ class getid3_id3v1
return ($allowSCMPXextended ? $GenreLookupSCMPX : $GenreLookup);
}
- function LookupGenreName($genreid, $allowSCMPXextended=true) {
+ static function LookupGenreName($genreid, $allowSCMPXextended=true) {
switch ($genreid) {
case 'RX':
case 'CR':
break;
default:
+ if (!is_numeric($genreid)) {
+ return false;
+ }
$genreid = intval($genreid); // to handle 3 or '3' or '03'
break;
}
@@ -302,28 +306,25 @@ class getid3_id3v1
return (isset($GenreLookup[$genreid]) ? $GenreLookup[$genreid] : false);
}
- function LookupGenreID($genre, $allowSCMPXextended=false) {
+ static function LookupGenreID($genre, $allowSCMPXextended=false) {
$GenreLookup = getid3_id3v1::ArrayOfGenres($allowSCMPXextended);
$LowerCaseNoSpaceSearchTerm = strtolower(str_replace(' ', '', $genre));
foreach ($GenreLookup as $key => $value) {
- foreach ($GenreLookup as $key => $value) {
- if (strtolower(str_replace(' ', '', $value)) == $LowerCaseNoSpaceSearchTerm) {
- return $key;
- }
+ if (strtolower(str_replace(' ', '', $value)) == $LowerCaseNoSpaceSearchTerm) {
+ return $key;
}
- return false;
}
- return (isset($GenreLookup[$genreid]) ? $GenreLookup[$genreid] : false);
+ return false;
}
- function StandardiseID3v1GenreName($OriginalGenre) {
+ static function StandardiseID3v1GenreName($OriginalGenre) {
if (($GenreID = getid3_id3v1::LookupGenreID($OriginalGenre)) !== false) {
return getid3_id3v1::LookupGenreName($GenreID);
}
return $OriginalGenre;
}
- function GenerateID3v1Tag($title, $artist, $album, $year, $genreid, $comment, $track='') {
+ static function GenerateID3v1Tag($title, $artist, $album, $year, $genreid, $comment, $track='') {
$ID3v1Tag = 'TAG';
$ID3v1Tag .= str_pad(trim(substr($title, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
$ID3v1Tag .= str_pad(trim(substr($artist, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
diff --git a/apps/media/getID3/getid3/module.tag.id3v2.php b/3rdparty/getid3/module.tag.id3v2.php
index 701d72800c7..56adeb95068 100644
--- a/apps/media/getID3/getid3/module.tag.id3v2.php
+++ b/3rdparty/getid3/module.tag.id3v2.php
@@ -15,10 +15,14 @@
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE__, true);
-class getid3_id3v2
+class getid3_id3v2 extends getid3_handler
{
+ var $inline_attachments = true; // true: return full data for all attachments; false: return no data for all attachments; integer: return data for attachments <= than this; string: save as file to this directory
+ var $StartingOffset = 0;
+
+ function Analyze() {
+ $info = &$this->getid3->info;
- function getid3_id3v2(&$fd, &$ThisFileInfo, $StartingOffset=0) {
// Overall tag structure:
// +-----------------------------+
// | Header (10 bytes) |
@@ -42,14 +46,14 @@ class getid3_id3v2
// shortcuts
- $ThisFileInfo['id3v2']['header'] = true;
- $thisfile_id3v2 = &$ThisFileInfo['id3v2'];
+ $info['id3v2']['header'] = true;
+ $thisfile_id3v2 = &$info['id3v2'];
$thisfile_id3v2['flags'] = array();
$thisfile_id3v2_flags = &$thisfile_id3v2['flags'];
- fseek($fd, $StartingOffset, SEEK_SET);
- $header = fread($fd, 10);
+ fseek($this->getid3->fp, $this->StartingOffset, SEEK_SET);
+ $header = fread($this->getid3->fp, 10);
if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) {
$thisfile_id3v2['majorversion'] = ord($header{3});
@@ -60,14 +64,14 @@ class getid3_id3v2
} else {
- unset($ThisFileInfo['id3v2']);
+ unset($info['id3v2']);
return false;
}
if ($id3v2_majorversion > 4) { // this script probably won't correctly parse ID3v2.5.x and above (if it ever exists)
- $ThisFileInfo['error'][] = 'this script only parses up to ID3v2.4.x - this tag is ID3v2.'.$id3v2_majorversion.'.'.$thisfile_id3v2['minorversion'];
+ $info['error'][] = 'this script only parses up to ID3v2.4.x - this tag is ID3v2.'.$id3v2_majorversion.'.'.$thisfile_id3v2['minorversion'];
return false;
}
@@ -98,7 +102,7 @@ class getid3_id3v2
$thisfile_id3v2['headerlength'] = getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
- $thisfile_id3v2['tag_offset_start'] = $StartingOffset;
+ $thisfile_id3v2['tag_offset_start'] = $this->StartingOffset;
$thisfile_id3v2['tag_offset_end'] = $thisfile_id3v2['tag_offset_start'] + $thisfile_id3v2['headerlength'];
@@ -120,18 +124,18 @@ class getid3_id3v2
// Flags $xx xx
$sizeofframes = $thisfile_id3v2['headerlength'] - 10; // not including 10-byte initial header
- if (@$thisfile_id3v2['exthead']['length']) {
+ if (!empty($thisfile_id3v2['exthead']['length'])) {
$sizeofframes -= ($thisfile_id3v2['exthead']['length'] + 4);
}
- if (@$thisfile_id3v2_flags['isfooter']) {
+ if (!empty($thisfile_id3v2_flags['isfooter'])) {
$sizeofframes -= 10; // footer takes last 10 bytes of ID3v2 header, after frame data, before audio
}
if ($sizeofframes > 0) {
- $framedata = fread($fd, $sizeofframes); // read all frames from file into $framedata variable
+ $framedata = fread($this->getid3->fp, $sizeofframes); // read all frames from file into $framedata variable
// if entire frame data is unsynched, de-unsynch it now (ID3v2.3.x)
- if (@$thisfile_id3v2_flags['unsynch'] && ($id3v2_majorversion <= 3)) {
+ if (!empty($thisfile_id3v2_flags['unsynch']) && ($id3v2_majorversion <= 3)) {
$framedata = $this->DeUnsynchronise($framedata);
}
// [in ID3v2.4.0] Unsynchronisation [S:6.1] is done on frame level, instead
@@ -141,12 +145,12 @@ class getid3_id3v2
// the frame header [S:4.1.2] indicates unsynchronisation.
- //$framedataoffset = 10 + (@$thisfile_id3v2['exthead']['length'] ? $thisfile_id3v2['exthead']['length'] + 4 : 0); // how many bytes into the stream - start from after the 10-byte header (and extended header length+4, if present)
+ //$framedataoffset = 10 + ($thisfile_id3v2['exthead']['length'] ? $thisfile_id3v2['exthead']['length'] + 4 : 0); // how many bytes into the stream - start from after the 10-byte header (and extended header length+4, if present)
$framedataoffset = 10; // how many bytes into the stream - start from after the 10-byte header
// Extended Header
- if (@$thisfile_id3v2_flags['exthead']) {
+ if (!empty($thisfile_id3v2_flags['exthead'])) {
$extended_header_offset = 0;
if ($id3v2_majorversion == 3) {
@@ -191,33 +195,56 @@ class getid3_id3v2
// d - Tag restrictions
// Flag data length $01
- $thisfile_id3v2['exthead']['length'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 4), 1);
+ $thisfile_id3v2['exthead']['length'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 4), true);
$extended_header_offset += 4;
- $thisfile_id3v2['exthead']['flag_bytes'] = 1;
+ $thisfile_id3v2['exthead']['flag_bytes'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 1)); // should always be 1
+ $extended_header_offset += 1;
+
$thisfile_id3v2['exthead']['flag_raw'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, $thisfile_id3v2['exthead']['flag_bytes']));
$extended_header_offset += $thisfile_id3v2['exthead']['flag_bytes'];
- $thisfile_id3v2['exthead']['flags']['update'] = (bool) ($thisfile_id3v2['exthead']['flag_raw'] & 0x4000);
- $thisfile_id3v2['exthead']['flags']['crc'] = (bool) ($thisfile_id3v2['exthead']['flag_raw'] & 0x2000);
- $thisfile_id3v2['exthead']['flags']['restrictions'] = (bool) ($thisfile_id3v2['exthead']['flag_raw'] & 0x1000);
+ $thisfile_id3v2['exthead']['flags']['update'] = (bool) ($thisfile_id3v2['exthead']['flag_raw'] & 0x40);
+ $thisfile_id3v2['exthead']['flags']['crc'] = (bool) ($thisfile_id3v2['exthead']['flag_raw'] & 0x20);
+ $thisfile_id3v2['exthead']['flags']['restrictions'] = (bool) ($thisfile_id3v2['exthead']['flag_raw'] & 0x10);
+
+ if ($thisfile_id3v2['exthead']['flags']['update']) {
+ $ext_header_chunk_length = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 1)); // should be 0
+ $extended_header_offset += 1;
+ }
if ($thisfile_id3v2['exthead']['flags']['crc']) {
- $thisfile_id3v2['exthead']['flag_data']['crc'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 5), 1);
- $extended_header_offset += 5;
+ $ext_header_chunk_length = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 1)); // should be 5
+ $extended_header_offset += 1;
+ $thisfile_id3v2['exthead']['flag_data']['crc'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, $ext_header_chunk_length), true, false);
+ $extended_header_offset += $ext_header_chunk_length;
}
+
if ($thisfile_id3v2['exthead']['flags']['restrictions']) {
+ $ext_header_chunk_length = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 1)); // should be 1
+ $extended_header_offset += 1;
+
// %ppqrrstt
$restrictions_raw = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 1));
$extended_header_offset += 1;
- $thisfile_id3v2['exthead']['flags']['restrictions']['tagsize'] = ($restrictions_raw && 0xC0) >> 6; // p - Tag size restrictions
- $thisfile_id3v2['exthead']['flags']['restrictions']['textenc'] = ($restrictions_raw && 0x20) >> 5; // q - Text encoding restrictions
- $thisfile_id3v2['exthead']['flags']['restrictions']['textsize'] = ($restrictions_raw && 0x18) >> 3; // r - Text fields size restrictions
- $thisfile_id3v2['exthead']['flags']['restrictions']['imgenc'] = ($restrictions_raw && 0x04) >> 2; // s - Image encoding restrictions
- $thisfile_id3v2['exthead']['flags']['restrictions']['imgsize'] = ($restrictions_raw && 0x03) >> 0; // t - Image size restrictions
+ $thisfile_id3v2['exthead']['flags']['restrictions']['tagsize'] = ($restrictions_raw & 0xC0) >> 6; // p - Tag size restrictions
+ $thisfile_id3v2['exthead']['flags']['restrictions']['textenc'] = ($restrictions_raw & 0x20) >> 5; // q - Text encoding restrictions
+ $thisfile_id3v2['exthead']['flags']['restrictions']['textsize'] = ($restrictions_raw & 0x18) >> 3; // r - Text fields size restrictions
+ $thisfile_id3v2['exthead']['flags']['restrictions']['imgenc'] = ($restrictions_raw & 0x04) >> 2; // s - Image encoding restrictions
+ $thisfile_id3v2['exthead']['flags']['restrictions']['imgsize'] = ($restrictions_raw & 0x03) >> 0; // t - Image size restrictions
+
+ $thisfile_id3v2['exthead']['flags']['restrictions_text']['tagsize'] = $this->LookupExtendedHeaderRestrictionsTagSizeLimits($thisfile_id3v2['exthead']['flags']['restrictions']['tagsize']);
+ $thisfile_id3v2['exthead']['flags']['restrictions_text']['textenc'] = $this->LookupExtendedHeaderRestrictionsTextEncodings($thisfile_id3v2['exthead']['flags']['restrictions']['textenc']);
+ $thisfile_id3v2['exthead']['flags']['restrictions_text']['textsize'] = $this->LookupExtendedHeaderRestrictionsTextFieldSize($thisfile_id3v2['exthead']['flags']['restrictions']['textsize']);
+ $thisfile_id3v2['exthead']['flags']['restrictions_text']['imgenc'] = $this->LookupExtendedHeaderRestrictionsImageEncoding($thisfile_id3v2['exthead']['flags']['restrictions']['imgenc']);
+ $thisfile_id3v2['exthead']['flags']['restrictions_text']['imgsize'] = $this->LookupExtendedHeaderRestrictionsImageSizeSize($thisfile_id3v2['exthead']['flags']['restrictions']['imgsize']);
}
+ if ($thisfile_id3v2['exthead']['length'] != $extended_header_offset) {
+ $info['warning'][] = 'ID3v2.4 extended header length mismatch (expecting '.intval($thisfile_id3v2['exthead']['length']).', found '.intval($extended_header_offset).')';
+ }
}
+
$framedataoffset += $extended_header_offset;
$framedata = substr($framedata, $extended_header_offset);
} // end extended header
@@ -233,7 +260,7 @@ class getid3_id3v2
if ($framedata{$i} != "\x00") {
$thisfile_id3v2['padding']['valid'] = false;
$thisfile_id3v2['padding']['errorpos'] = $thisfile_id3v2['padding']['start'] + $i;
- $ThisFileInfo['warning'][] = 'Invalid ID3v2 padding found at offset '.$thisfile_id3v2['padding']['errorpos'].' (the remaining '.($thisfile_id3v2['padding']['length'] - $i).' bytes are considered invalid)';
+ $info['warning'][] = 'Invalid ID3v2 padding found at offset '.$thisfile_id3v2['padding']['errorpos'].' (the remaining '.($thisfile_id3v2['padding']['length'] - $i).' bytes are considered invalid)';
break;
}
}
@@ -273,7 +300,7 @@ class getid3_id3v2
} elseif (($frame_name == "\x00".'MP3') || ($frame_name == "\x00\x00".'MP') || ($frame_name == ' MP3') || ($frame_name == 'MP3e')) {
// MP3ext known broken frames - "ok" for the purposes of this test
} elseif (($id3v2_majorversion == 4) && ($this->IsValidID3v2FrameName(substr($framedata, getid3_lib::BigEndian2Int(substr($frame_header, 4, 4), 0), 4), 3))) {
- $ThisFileInfo['warning'][] = 'ID3v2 tag written as ID3v2.4, but with non-synchsafe integers (ID3v2.3 style). Older versions of (Helium2; iTunes) are known culprits of this. Tag has been parsed as ID3v2.3';
+ $info['warning'][] = 'ID3v2 tag written as ID3v2.4, but with non-synchsafe integers (ID3v2.3 style). Older versions of (Helium2; iTunes) are known culprits of this. Tag has been parsed as ID3v2.3';
$id3v2_majorversion = 3;
$frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 4, 4), 0); // 32-bit integer
}
@@ -295,7 +322,7 @@ class getid3_id3v2
if ($framedata{$i} != "\x00") {
$thisfile_id3v2['padding']['valid'] = false;
$thisfile_id3v2['padding']['errorpos'] = $thisfile_id3v2['padding']['start'] + $i;
- $ThisFileInfo['warning'][] = 'Invalid ID3v2 padding found at offset '.$thisfile_id3v2['padding']['errorpos'].' (the remaining '.($thisfile_id3v2['padding']['length'] - $i).' bytes are considered invalid)';
+ $info['warning'][] = 'Invalid ID3v2 padding found at offset '.$thisfile_id3v2['padding']['errorpos'].' (the remaining '.($thisfile_id3v2['padding']['length'] - $i).' bytes are considered invalid)';
break;
}
}
@@ -303,7 +330,7 @@ class getid3_id3v2
}
if ($frame_name == 'COM ') {
- $ThisFileInfo['warning'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: IsValidID3v2FrameName("'.str_replace("\x00", ' ', $frame_name).'", '.$id3v2_majorversion.'))). [Note: this particular error has been known to happen with tags edited by iTunes (versions "X v2.0.3", "v3.0.1" are known-guilty, probably others too)]';
+ $info['warning'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: IsValidID3v2FrameName("'.str_replace("\x00", ' ', $frame_name).'", '.$id3v2_majorversion.'))). [Note: this particular error has been known to happen with tags edited by iTunes (versions "X v2.0.3", "v3.0.1" are known-guilty, probably others too)]';
$frame_name = 'COMM';
}
if (($frame_size <= strlen($framedata)) && ($this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion))) {
@@ -315,7 +342,7 @@ class getid3_id3v2
$parsedFrame['datalength'] = getid3_lib::CastAsInt($frame_size);
$parsedFrame['dataoffset'] = $framedataoffset;
- $this->ParseID3v2Frame($parsedFrame, $ThisFileInfo);
+ $this->ParseID3v2Frame($parsedFrame);
$thisfile_id3v2[$frame_name][] = $parsedFrame;
$framedata = substr($framedata, $frame_size);
@@ -328,28 +355,28 @@ class getid3_id3v2
// next frame is valid, just skip the current frame
$framedata = substr($framedata, $frame_size);
- $ThisFileInfo['warning'][] = 'Next ID3v2 frame is valid, skipping current frame.';
+ $info['warning'][] = 'Next ID3v2 frame is valid, skipping current frame.';
} else {
// next frame is invalid too, abort processing
//unset($framedata);
$framedata = null;
- $ThisFileInfo['error'][] = 'Next ID3v2 frame is also invalid, aborting processing.';
+ $info['error'][] = 'Next ID3v2 frame is also invalid, aborting processing.';
}
} elseif ($frame_size == strlen($framedata)) {
// this is the last frame, just skip
- $ThisFileInfo['warning'][] = 'This was the last ID3v2 frame.';
+ $info['warning'][] = 'This was the last ID3v2 frame.';
} else {
// next frame is invalid too, abort processing
//unset($framedata);
$framedata = null;
- $ThisFileInfo['warning'][] = 'Invalid ID3v2 frame size, aborting.';
+ $info['warning'][] = 'Invalid ID3v2 frame size, aborting.';
}
if (!$this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion)) {
@@ -362,21 +389,21 @@ class getid3_id3v2
case "\x00".'MP':
case ' MP':
case 'MP3':
- $ThisFileInfo['warning'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: !IsValidID3v2FrameName("'.str_replace("\x00", ' ', $frame_name).'", '.$id3v2_majorversion.'))). [Note: this particular error has been known to happen with tags edited by "MP3ext (www.mutschler.de/mp3ext/)"]';
+ $info['warning'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: !IsValidID3v2FrameName("'.str_replace("\x00", ' ', $frame_name).'", '.$id3v2_majorversion.'))). [Note: this particular error has been known to happen with tags edited by "MP3ext (www.mutschler.de/mp3ext/)"]';
break;
default:
- $ThisFileInfo['warning'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: !IsValidID3v2FrameName("'.str_replace("\x00", ' ', $frame_name).'", '.$id3v2_majorversion.'))).';
+ $info['warning'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: !IsValidID3v2FrameName("'.str_replace("\x00", ' ', $frame_name).'", '.$id3v2_majorversion.'))).';
break;
}
- } elseif ($frame_size > strlen(@$framedata)){
+ } elseif (!isset($framedata) || ($frame_size > strlen($framedata))) {
- $ThisFileInfo['error'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: $frame_size ('.$frame_size.') > strlen($framedata) ('.strlen($framedata).')).';
+ $info['error'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: $frame_size ('.$frame_size.') > strlen($framedata) ('.(isset($framedata) ? strlen($framedata) : 'null').')).';
} else {
- $ThisFileInfo['error'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag).';
+ $info['error'][] = 'error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag).';
}
@@ -397,7 +424,7 @@ class getid3_id3v2
// ID3v2 size 4 * %0xxxxxxx
if (isset($thisfile_id3v2_flags['isfooter']) && $thisfile_id3v2_flags['isfooter']) {
- $footer = fread($fd, 10);
+ $footer = fread($this->getid3->fp, 10);
if (substr($footer, 0, 3) == '3DI') {
$thisfile_id3v2['footer'] = true;
$thisfile_id3v2['majorversion_footer'] = ord($footer{3});
@@ -417,7 +444,7 @@ class getid3_id3v2
if (isset($thisfile_id3v2['comments']['genre'])) {
foreach ($thisfile_id3v2['comments']['genre'] as $key => $value) {
unset($thisfile_id3v2['comments']['genre'][$key]);
- $thisfile_id3v2['comments'] = getid3_lib::array_merge_noclobber($thisfile_id3v2['comments'], $this->ParseID3v2GenreString($value));
+ $thisfile_id3v2['comments'] = getid3_lib::array_merge_noclobber($thisfile_id3v2['comments'], array('genre'=>$this->ParseID3v2GenreString($value)));
}
}
@@ -429,15 +456,39 @@ class getid3_id3v2
}
}
- if (!isset($thisfile_id3v2['comments']['year']) && ereg('^([0-9]{4})', trim(@$thisfile_id3v2['comments']['recording_time'][0]), $matches)) {
+ if (!isset($thisfile_id3v2['comments']['year']) && !empty($thisfile_id3v2['comments']['recording_time'][0]) && preg_match('#^([0-9]{4})#', trim($thisfile_id3v2['comments']['recording_time'][0]), $matches)) {
$thisfile_id3v2['comments']['year'] = array($matches[1]);
}
+ if (!empty($thisfile_id3v2['TXXX'])) {
+ // MediaMonkey does this, maybe others: write a blank RGAD frame, but put replay-gain adjustment values in TXXX frames
+ foreach ($thisfile_id3v2['TXXX'] as $txxx_array) {
+ switch ($txxx_array['description']) {
+ case 'replaygain_track_gain':
+ if (empty($info['replay_gain']['track']['adjustment']) && !empty($txxx_array['data'])) {
+ $info['replay_gain']['track']['adjustment'] = floatval(trim(str_replace('dB', '', $txxx_array['data'])));
+ }
+ break;
+ case 'replaygain_track_peak':
+ if (empty($info['replay_gain']['track']['peak']) && !empty($txxx_array['data'])) {
+ $info['replay_gain']['track']['peak'] = floatval($txxx_array['data']);
+ }
+ break;
+ case 'replaygain_album_gain':
+ if (empty($info['replay_gain']['album']['adjustment']) && !empty($txxx_array['data'])) {
+ $info['replay_gain']['album']['adjustment'] = floatval(trim(str_replace('dB', '', $txxx_array['data'])));
+ }
+ break;
+ }
+ }
+ }
+
+
// Set avdataoffset
- $ThisFileInfo['avdataoffset'] = $thisfile_id3v2['headerlength'];
+ $info['avdataoffset'] = $thisfile_id3v2['headerlength'];
if (isset($thisfile_id3v2['footer'])) {
- $ThisFileInfo['avdataoffset'] += 10;
+ $info['avdataoffset'] += 10;
}
return true;
@@ -448,68 +499,30 @@ class getid3_id3v2
// Parse genres into arrays of genreName and genreID
// ID3v2.2.x, ID3v2.3.x: '(21)' or '(4)Eurodisco' or '(51)(39)' or '(55)((I think...)'
// ID3v2.4.x: '21' $00 'Eurodisco' $00
-
- $genrestring = trim($genrestring);
- $returnarray = array();
- if (strpos($genrestring, "\x00") !== false) {
- $unprocessed = trim($genrestring); // trailing nulls will cause an infinite loop.
- $genrestring = '';
- while (strpos($unprocessed, "\x00") !== false) {
- // convert null-seperated v2.4-format into v2.3 ()-seperated format
- $endpos = strpos($unprocessed, "\x00");
- $genrestring .= '('.substr($unprocessed, 0, $endpos).')';
- $unprocessed = substr($unprocessed, $endpos + 1);
- }
- unset($unprocessed);
- } elseif (eregi('^([0-9]+|CR|RX)$', $genrestring)) {
- // some tagging program (including some that use TagLib) fail to include null byte after numeric genre
- $genrestring = '('.$genrestring.')';
- }
- if (getid3_id3v1::LookupGenreID($genrestring)) {
-
- $returnarray['genre'][] = $genrestring;
-
- } else {
-
- while (strpos($genrestring, '(') !== false) {
-
- $startpos = strpos($genrestring, '(');
- $endpos = strpos($genrestring, ')');
- if (substr($genrestring, $startpos + 1, 1) == '(') {
- $genrestring = substr($genrestring, 0, $startpos).substr($genrestring, $startpos + 1);
- $endpos--;
- }
- $element = substr($genrestring, $startpos + 1, $endpos - ($startpos + 1));
- $genrestring = substr($genrestring, 0, $startpos).substr($genrestring, $endpos + 1);
- if (getid3_id3v1::LookupGenreName($element)) { // $element is a valid genre id/abbreviation
-
- if (empty($returnarray['genre']) || !in_array(getid3_id3v1::LookupGenreName($element), $returnarray['genre'])) { // avoid duplicate entires
- $returnarray['genre'][] = getid3_id3v1::LookupGenreName($element);
- }
-
+ $clean_genres = array();
+ if (strpos($genrestring, "\x00") === false) {
+ $genrestring = preg_replace('#\(([0-9]{1,3})\)#', '$1'."\x00", $genrestring);
+ }
+ $genre_elements = explode("\x00", $genrestring);
+ foreach ($genre_elements as $element) {
+ $element = trim($element);
+ if ($element) {
+ if (preg_match('#^[0-9]{1,3}#', $element)) {
+ $clean_genres[] = getid3_id3v1::LookupGenreName($element);
} else {
-
- if (empty($returnarray['genre']) || !in_array($element, $returnarray['genre'])) { // avoid duplicate entires
- $returnarray['genre'][] = $element;
- }
-
+ $clean_genres[] = str_replace('((', '(', $element);
}
}
}
- if ($genrestring) {
- if (empty($returnarray['genre']) || !in_array($genrestring, $returnarray['genre'])) { // avoid duplicate entires
- $returnarray['genre'][] = $genrestring;
- }
- }
-
- return $returnarray;
+ return $clean_genres;
}
- function ParseID3v2Frame(&$parsedFrame, &$ThisFileInfo) {
+ function ParseID3v2Frame(&$parsedFrame) {
// shortcuts
- $id3v2_majorversion = $ThisFileInfo['id3v2']['majorversion'];
+ $info = &$this->getid3->info;
+ $id3v2_majorversion = $info['id3v2']['majorversion'];
$parsedFrame['framenamelong'] = $this->FrameNameLongLookup($parsedFrame['frame_name']);
if (empty($parsedFrame['framenamelong'])) {
@@ -547,21 +560,36 @@ class getid3_id3v2
if ($parsedFrame['flags']['Unsynchronisation']) {
$parsedFrame['data'] = $this->DeUnsynchronise($parsedFrame['data']);
}
+
+ if ($parsedFrame['flags']['DataLengthIndicator']) {
+ $parsedFrame['data_length_indicator'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4), 1);
+ $parsedFrame['data'] = substr($parsedFrame['data'], 4);
+ }
}
// Frame-level de-compression
if ($parsedFrame['flags']['compression']) {
$parsedFrame['decompressed_size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4));
if (!function_exists('gzuncompress')) {
- $ThisFileInfo['warning'][] = 'gzuncompress() support required to decompress ID3v2 frame "'.$parsedFrame['frame_name'].'"';
- } elseif ($decompresseddata = @gzuncompress(substr($parsedFrame['data'], 4))) {
- $parsedFrame['data'] = $decompresseddata;
+ $info['warning'][] = 'gzuncompress() support required to decompress ID3v2 frame "'.$parsedFrame['frame_name'].'"';
} else {
- $ThisFileInfo['warning'][] = 'gzuncompress() failed on compressed contents of ID3v2 frame "'.$parsedFrame['frame_name'].'"';
+ if ($decompresseddata = @gzuncompress(substr($parsedFrame['data'], 4))) {
+ //if ($decompresseddata = @gzuncompress($parsedFrame['data'])) {
+ $parsedFrame['data'] = $decompresseddata;
+ unset($decompresseddata);
+ } else {
+ $info['warning'][] = 'gzuncompress() failed on compressed contents of ID3v2 frame "'.$parsedFrame['frame_name'].'"';
+ }
}
}
}
+ if (!empty($parsedFrame['flags']['DataLengthIndicator'])) {
+ if ($parsedFrame['data_length_indicator'] != strlen($parsedFrame['data'])) {
+ $info['warning'][] = 'ID3v2 frame "'.$parsedFrame['frame_name'].'" should be '.$parsedFrame['data_length_indicator'].' bytes long according to DataLengthIndicator, but found '.strlen($parsedFrame['data']).' bytes of data';
+ }
+ }
+
if (isset($parsedFrame['datalength']) && ($parsedFrame['datalength'] == 0)) {
$warning = 'Frame "'.$parsedFrame['frame_name'].'" at offset '.$parsedFrame['dataoffset'].' has no data portion';
@@ -573,7 +601,7 @@ class getid3_id3v2
default:
break;
}
- $ThisFileInfo['warning'][] = $warning;
+ $info['warning'][] = $warning;
} elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'UFID')) || // 4.1 UFID Unique file identifier
(($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'UFI'))) { // 4.1 UFI Unique file identifier
@@ -582,13 +610,9 @@ class getid3_id3v2
// <Header for 'Unique file identifier', ID: 'UFID'>
// Owner identifier <text string> $00
// Identifier <up to 64 bytes binary data>
-
- $frame_terminatorpos = strpos($parsedFrame['data'], "\x00");
- $frame_idstring = substr($parsedFrame['data'], 0, $frame_terminatorpos);
- $parsedFrame['ownerid'] = $frame_idstring;
- $parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen("\x00"));
- unset($parsedFrame['data']);
-
+ $exploded = explode("\x00", $parsedFrame['data'], 2);
+ $parsedFrame['ownerid'] = (isset($exploded[0]) ? $exploded[0] : '');
+ $parsedFrame['data'] = (isset($exploded[1]) ? $exploded[1] : '');
} elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'TXXX')) || // 4.2.2 TXXX User defined text information frame
(($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'TXX'))) { // 4.2.2 TXX User defined text information frame
@@ -603,11 +627,11 @@ class getid3_id3v2
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
- $frame_terminatorpos = @strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
- $frame_terminatorpos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00
+ $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
}
$frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_description) === 0) {
@@ -619,9 +643,9 @@ class getid3_id3v2
$parsedFrame['description'] = $frame_description;
$parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)));
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
- $ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['data']));
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']));
}
- unset($parsedFrame['data']);
+ //unset($parsedFrame['data']); do not unset, may be needed elsewhere, e.g. for replaygain
} elseif ($parsedFrame['frame_name']{0} == 'T') { // 4.2. T??[?] Text information frame
@@ -634,7 +658,7 @@ class getid3_id3v2
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
$parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset);
@@ -643,13 +667,9 @@ class getid3_id3v2
$parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding);
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
-
- // remove possible terminating \x00 (put by encoding id or software bug)
- $string = getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['data']);
- if ($string[strlen($string) - 1] == "\x00") {
- $string = substr($string, 0, strlen($string) - 1);
- }
- $ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = $string;
+ $string = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
+ $string = rtrim($string, "\x00"); // remove possible terminating null (put by encoding id or software bug)
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $string;
unset($string);
}
@@ -665,11 +685,11 @@ class getid3_id3v2
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
- $frame_terminatorpos = @strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
- $frame_terminatorpos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00
+ $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
}
$frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
@@ -697,7 +717,7 @@ class getid3_id3v2
$parsedFrame['url'] = $frame_urldata;
$parsedFrame['description'] = $frame_description;
if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) {
- $ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['url']);
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['url']);
}
unset($parsedFrame['data']);
@@ -711,7 +731,7 @@ class getid3_id3v2
$parsedFrame['url'] = trim($parsedFrame['data']);
if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) {
- $ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['url'];
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['url'];
}
unset($parsedFrame['data']);
@@ -726,14 +746,14 @@ class getid3_id3v2
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
$parsedFrame['encodingid'] = $frame_textencoding;
$parsedFrame['encoding'] = $this->TextEncodingNameLookup($parsedFrame['encodingid']);
$parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset);
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
- $ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['data']);
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
}
@@ -744,7 +764,7 @@ class getid3_id3v2
// CD TOC <binary data>
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
- $ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['data'];
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['data'];
}
@@ -808,7 +828,7 @@ class getid3_id3v2
} elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'SYTC')) || // 4.7 SYTC Synchronised tempo codes
- (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'STC'))) { // 4.8 STC Synchronised tempo codes
+ (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'STC'))) { // 4.8 STC Synchronised tempo codes
// There may only be one 'SYTC' frame in each tag
// <Header for 'Synchronised tempo codes', ID: 'SYTC'>
// Time stamp format $xx
@@ -845,13 +865,13 @@ class getid3_id3v2
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
$frame_language = substr($parsedFrame['data'], $frame_offset, 3);
$frame_offset += 3;
- $frame_terminatorpos = @strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
- $frame_terminatorpos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00
+ $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
}
$frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_description) === 0) {
@@ -867,7 +887,7 @@ class getid3_id3v2
$parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false);
$parsedFrame['description'] = $frame_description;
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
- $ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['data']);
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
}
unset($parsedFrame['data']);
@@ -891,7 +911,7 @@ class getid3_id3v2
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
$frame_language = substr($parsedFrame['data'], $frame_offset, 3);
$frame_offset += 3;
@@ -942,20 +962,20 @@ class getid3_id3v2
if (strlen($parsedFrame['data']) < 5) {
- $ThisFileInfo['warning'][] = 'Invalid data (too short) for "'.$parsedFrame['frame_name'].'" frame at offset '.$parsedFrame['dataoffset'];
+ $info['warning'][] = 'Invalid data (too short) for "'.$parsedFrame['frame_name'].'" frame at offset '.$parsedFrame['dataoffset'];
} else {
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
$frame_language = substr($parsedFrame['data'], $frame_offset, 3);
$frame_offset += 3;
- $frame_terminatorpos = @strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
- $frame_terminatorpos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00
+ $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
}
$frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_description) === 0) {
@@ -971,7 +991,7 @@ class getid3_id3v2
$parsedFrame['description'] = $frame_description;
$parsedFrame['data'] = $frame_text;
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
- $ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['data']);
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
}
}
@@ -996,23 +1016,29 @@ class getid3_id3v2
}
$frame_remainingdata = substr($parsedFrame['data'], $frame_terminatorpos + strlen("\x00"));
$parsedFrame['description'] = $frame_idstring;
- while (strlen($frame_remainingdata)) {
+ $RVA2channelcounter = 0;
+ while (strlen($frame_remainingdata) >= 5) {
$frame_offset = 0;
$frame_channeltypeid = ord(substr($frame_remainingdata, $frame_offset++, 1));
- $parsedFrame[$frame_channeltypeid]['channeltypeid'] = $frame_channeltypeid;
- $parsedFrame[$frame_channeltypeid]['channeltype'] = $this->RVA2ChannelTypeLookup($frame_channeltypeid);
- $parsedFrame[$frame_channeltypeid]['volumeadjust'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, $frame_offset, 2), false, true); // 16-bit signed
+ $parsedFrame[$RVA2channelcounter]['channeltypeid'] = $frame_channeltypeid;
+ $parsedFrame[$RVA2channelcounter]['channeltype'] = $this->RVA2ChannelTypeLookup($frame_channeltypeid);
+ $parsedFrame[$RVA2channelcounter]['volumeadjust'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, $frame_offset, 2), false, true); // 16-bit signed
$frame_offset += 2;
- $parsedFrame[$frame_channeltypeid]['bitspeakvolume'] = ord(substr($frame_remainingdata, $frame_offset++, 1));
- $frame_bytespeakvolume = ceil($parsedFrame[$frame_channeltypeid]['bitspeakvolume'] / 8);
- $parsedFrame[$frame_channeltypeid]['peakvolume'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, $frame_offset, $frame_bytespeakvolume));
+ $parsedFrame[$RVA2channelcounter]['bitspeakvolume'] = ord(substr($frame_remainingdata, $frame_offset++, 1));
+ if (($parsedFrame[$RVA2channelcounter]['bitspeakvolume'] < 1) || ($parsedFrame[$RVA2channelcounter]['bitspeakvolume'] > 4)) {
+ $info['warning'][] = 'ID3v2::RVA2 frame['.$RVA2channelcounter.'] contains invalid '.$parsedFrame[$RVA2channelcounter]['bitspeakvolume'].'-byte bits-representing-peak value';
+ break;
+ }
+ $frame_bytespeakvolume = ceil($parsedFrame[$RVA2channelcounter]['bitspeakvolume'] / 8);
+ $parsedFrame[$RVA2channelcounter]['peakvolume'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, $frame_offset, $frame_bytespeakvolume));
$frame_remainingdata = substr($frame_remainingdata, $frame_offset + $frame_bytespeakvolume);
+ $RVA2channelcounter++;
}
unset($parsedFrame['data']);
} elseif ((($id3v2_majorversion == 3) && ($parsedFrame['frame_name'] == 'RVAD')) || // 4.12 RVAD Relative volume adjustment (ID3v2.3 only)
- (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'RVA'))) { // 4.12 RVA Relative volume adjustment (ID3v2.2 only)
+ (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'RVA'))) { // 4.12 RVA Relative volume adjustment (ID3v2.2 only)
// There may only be one 'RVA' frame in each tag
// <Header for 'Relative volume adjustment', ID: 'RVA'>
// ID3v2.2 => Increment/decrement %000000ba
@@ -1114,7 +1140,7 @@ class getid3_id3v2
$frame_offset = 0;
$frame_interpolationmethod = ord(substr($parsedFrame['data'], $frame_offset++, 1));
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_idstring = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_idstring) === 0) {
$frame_idstring = '';
@@ -1208,7 +1234,7 @@ class getid3_id3v2
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
if ($id3v2_majorversion == 2 && strlen($parsedFrame['data']) > $frame_offset) {
@@ -1216,7 +1242,7 @@ class getid3_id3v2
if (strtolower($frame_imagetype) == 'ima') {
// complete hack for mp3Rage (www.chaoticsoftware.com) that puts ID3v2.3-formatted
// MIME type instead of 3-char ID3v2.2-format image type (thanks xbhoffØpacbell*net)
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_mimetype = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_mimetype) === 0) {
$frame_mimetype = '';
@@ -1231,7 +1257,7 @@ class getid3_id3v2
}
}
if ($id3v2_majorversion > 2 && strlen($parsedFrame['data']) > $frame_offset) {
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_mimetype = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_mimetype) === 0) {
$frame_mimetype = '';
@@ -1241,40 +1267,88 @@ class getid3_id3v2
$frame_picturetype = ord(substr($parsedFrame['data'], $frame_offset++, 1));
- $frame_terminatorpos = @strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
- if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
- $frame_terminatorpos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00
- }
- $frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
- if (ord($frame_description) === 0) {
- $frame_description = '';
- }
- $parsedFrame['encodingid'] = $frame_textencoding;
- $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding);
-
- if ($id3v2_majorversion == 2) {
- $parsedFrame['imagetype'] = $frame_imagetype;
+ if ($frame_offset >= $parsedFrame['datalength']) {
+ $info['warning'][] = 'data portion of APIC frame is missing at offset '.($parsedFrame['dataoffset'] + 8 + $frame_offset);
} else {
- $parsedFrame['mime'] = $frame_mimetype;
- }
- $parsedFrame['picturetypeid'] = $frame_picturetype;
- $parsedFrame['picturetype'] = $this->APICPictureTypeLookup($frame_picturetype);
- $parsedFrame['description'] = $frame_description;
- $parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)));
-
- $imageinfo = array();
- $imagechunkcheck = getid3_lib::GetDataImageSize($parsedFrame['data'], $imageinfo);
- if (($imagechunkcheck[2] >= 1) && ($imagechunkcheck[2] <= 3)) {
- $parsedFrame['image_mime'] = 'image/'.getid3_lib::ImageTypesLookup($imagechunkcheck[2]);
- if ($imagechunkcheck[0]) {
- $parsedFrame['image_width'] = $imagechunkcheck[0];
+ $frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
+ if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
+ $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
}
- if ($imagechunkcheck[1]) {
- $parsedFrame['image_height'] = $imagechunkcheck[1];
+ $frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
+ if (ord($frame_description) === 0) {
+ $frame_description = '';
+ }
+ $parsedFrame['encodingid'] = $frame_textencoding;
+ $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding);
+
+ if ($id3v2_majorversion == 2) {
+ $parsedFrame['imagetype'] = $frame_imagetype;
+ } else {
+ $parsedFrame['mime'] = $frame_mimetype;
+ }
+ $parsedFrame['picturetypeid'] = $frame_picturetype;
+ $parsedFrame['picturetype'] = $this->APICPictureTypeLookup($frame_picturetype);
+ $parsedFrame['description'] = $frame_description;
+ $parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)));
+ $parsedFrame['datalength'] = strlen($parsedFrame['data']);
+
+ $parsedFrame['image_mime'] = '';
+ $imageinfo = array();
+ $imagechunkcheck = getid3_lib::GetDataImageSize($parsedFrame['data'], $imageinfo);
+ if (($imagechunkcheck[2] >= 1) && ($imagechunkcheck[2] <= 3)) {
+ $parsedFrame['image_mime'] = 'image/'.getid3_lib::ImageTypesLookup($imagechunkcheck[2]);
+ if ($imagechunkcheck[0]) {
+ $parsedFrame['image_width'] = $imagechunkcheck[0];
+ }
+ if ($imagechunkcheck[1]) {
+ $parsedFrame['image_height'] = $imagechunkcheck[1];
+ }
}
- $parsedFrame['image_bytes'] = strlen($parsedFrame['data']);
- }
+ do {
+ if ($this->inline_attachments === false) {
+ // skip entirely
+ unset($parsedFrame['data']);
+ break;
+ }
+ if ($this->inline_attachments === true) {
+ // great
+ } elseif (is_int($this->inline_attachments)) {
+ if ($this->inline_attachments < $parsedFrame['data_length']) {
+ // too big, skip
+ $info['warning'][] = 'attachment at '.$frame_offset.' is too large to process inline ('.number_format($parsedFrame['data_length']).' bytes)';
+ unset($parsedFrame['data']);
+ break;
+ }
+ } elseif (is_string($this->inline_attachments)) {
+ $this->inline_attachments = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->inline_attachments), DIRECTORY_SEPARATOR);
+ if (!is_dir($this->inline_attachments) || !is_writable($this->inline_attachments)) {
+ // cannot write, skip
+ $info['warning'][] = 'attachment at '.$frame_offset.' cannot be saved to "'.$this->inline_attachments.'" (not writable)';
+ unset($parsedFrame['data']);
+ break;
+ }
+ }
+ // if we get this far, must be OK
+ if (is_string($this->inline_attachments)) {
+ $destination_filename = $this->inline_attachments.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$frame_offset;
+ if (!file_exists($destination_filename) || is_writable($destination_filename)) {
+ file_put_contents($destination_filename, $parsedFrame['data']);
+ } else {
+ $info['warning'][] = 'attachment at '.$frame_offset.' cannot be saved to "'.$destination_filename.'" (not writable)';
+ }
+ $parsedFrame['data_filename'] = $destination_filename;
+ unset($parsedFrame['data']);
+ } else {
+ if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
+ if (!isset($info['id3v2']['comments']['picture'])) {
+ $info['id3v2']['comments']['picture'] = array();
+ }
+ $info['id3v2']['comments']['picture'][] = array('data'=>$parsedFrame['data'], 'image_mime'=>$parsedFrame['image_mime']);
+ }
+ }
+ } while (false);
+ }
} elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'GEOB')) || // 4.15 GEOB General encapsulated object
(($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'GEO'))) { // 4.16 GEO General encapsulated object
@@ -1290,18 +1364,18 @@ class getid3_id3v2
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_mimetype = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_mimetype) === 0) {
$frame_mimetype = '';
}
$frame_offset = $frame_terminatorpos + strlen("\x00");
- $frame_terminatorpos = @strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
- $frame_terminatorpos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00
+ $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
}
$frame_filename = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_filename) === 0) {
@@ -1309,9 +1383,9 @@ class getid3_id3v2
}
$frame_offset = $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding));
- $frame_terminatorpos = @strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
- $frame_terminatorpos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00
+ $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
}
$frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_description) === 0) {
@@ -1341,7 +1415,7 @@ class getid3_id3v2
} elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'POPM')) || // 4.17 POPM Popularimeter
- (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'POP'))) { // 4.18 POP Popularimeter
+ (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'POP'))) { // 4.18 POP Popularimeter
// There may be more than one 'POPM' frame in each tag,
// but only one with the same email address
// <Header for 'Popularimeter', ID: 'POPM'>
@@ -1350,16 +1424,16 @@ class getid3_id3v2
// Counter $xx xx xx xx (xx ...)
$frame_offset = 0;
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_emailaddress = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_emailaddress) === 0) {
$frame_emailaddress = '';
}
$frame_offset = $frame_terminatorpos + strlen("\x00");
$frame_rating = ord(substr($parsedFrame['data'], $frame_offset++, 1));
- $parsedFrame['data'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset));
- $parsedFrame['email'] = $frame_emailaddress;
- $parsedFrame['rating'] = $frame_rating;
+ $parsedFrame['counter'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset));
+ $parsedFrame['email'] = $frame_emailaddress;
+ $parsedFrame['rating'] = $frame_rating;
unset($parsedFrame['data']);
@@ -1390,11 +1464,11 @@ class getid3_id3v2
// Encrypted datablock <binary data>
$frame_offset = 0;
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
$frame_offset = $frame_terminatorpos + strlen("\x00");
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_description) === 0) {
$frame_description = '';
@@ -1418,7 +1492,7 @@ class getid3_id3v2
// Encryption info <binary data>
$frame_offset = 0;
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_ownerid) === 0) {
$frame_ownerid == '';
@@ -1452,7 +1526,7 @@ class getid3_id3v2
$frame_offset += 4;
}
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_url = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_url) === 0) {
$frame_url = '';
@@ -1462,7 +1536,7 @@ class getid3_id3v2
$parsedFrame['additionaldata'] = (string) substr($parsedFrame['data'], $frame_offset);
if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) {
- $ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = utf8_encode($parsedFrame['url']);
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = utf8_encode($parsedFrame['url']);
}
unset($parsedFrame['data']);
@@ -1490,7 +1564,7 @@ class getid3_id3v2
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
$frame_language = substr($parsedFrame['data'], $frame_offset, 3);
$frame_offset += 3;
@@ -1501,7 +1575,7 @@ class getid3_id3v2
$parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset);
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
- $ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['data']);
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
}
unset($parsedFrame['data']);
@@ -1517,12 +1591,12 @@ class getid3_id3v2
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
$parsedFrame['encodingid'] = $frame_textencoding;
$parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding);
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_pricepaid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
$frame_offset = $frame_terminatorpos + strlen("\x00");
@@ -1557,10 +1631,10 @@ class getid3_id3v2
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
- $ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+ $info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
}
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_pricestring = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
$frame_offset = $frame_terminatorpos + strlen("\x00");
$frame_rawpricearray = explode('/', $frame_pricestring);
@@ -1573,15 +1647,15 @@ class getid3_id3v2
$frame_datestring = substr($parsedFrame['data'], $frame_offset, 8);
$frame_offset += 8;
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_contacturl = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
$frame_offset = $frame_terminatorpos + strlen("\x00");
$frame_receivedasid = ord(substr($parsedFrame['data'], $frame_offset++, 1));
- $frame_terminatorpos = @strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
- $frame_terminatorpos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00
+ $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
}
$frame_sellername = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_sellername) === 0) {
@@ -1589,9 +1663,9 @@ class getid3_id3v2
}
$frame_offset = $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding));
- $frame_terminatorpos = @strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
- $frame_terminatorpos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00
+ $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
}
$frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_description) === 0) {
@@ -1599,7 +1673,7 @@ class getid3_id3v2
}
$frame_offset = $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding));
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_mimetype = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
$frame_offset = $frame_terminatorpos + strlen("\x00");
@@ -1629,7 +1703,7 @@ class getid3_id3v2
// Encryption data <binary data>
$frame_offset = 0;
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_ownerid) === 0) {
$frame_ownerid = '';
@@ -1652,7 +1726,7 @@ class getid3_id3v2
// Group dependent data <binary data>
$frame_offset = 0;
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_ownerid) === 0) {
$frame_ownerid = '';
@@ -1672,7 +1746,7 @@ class getid3_id3v2
// The private data <binary data>
$frame_offset = 0;
- $frame_terminatorpos = @strpos($parsedFrame['data'], "\x00", $frame_offset);
+ $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
$frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
if (ord($frame_ownerid) === 0) {
$frame_ownerid = '';
@@ -1763,11 +1837,11 @@ class getid3_id3v2
$parsedFrame['album']['originator'] = getid3_lib::RGADoriginatorLookup($parsedFrame['raw']['album']['originator']);
$parsedFrame['album']['adjustment'] = getid3_lib::RGADadjustmentLookup($parsedFrame['raw']['album']['adjustment'], $parsedFrame['raw']['album']['signbit']);
- $ThisFileInfo['replay_gain']['track']['peak'] = $parsedFrame['peakamplitude'];
- $ThisFileInfo['replay_gain']['track']['originator'] = $parsedFrame['track']['originator'];
- $ThisFileInfo['replay_gain']['track']['adjustment'] = $parsedFrame['track']['adjustment'];
- $ThisFileInfo['replay_gain']['album']['originator'] = $parsedFrame['album']['originator'];
- $ThisFileInfo['replay_gain']['album']['adjustment'] = $parsedFrame['album']['adjustment'];
+ $info['replay_gain']['track']['peak'] = $parsedFrame['peakamplitude'];
+ $info['replay_gain']['track']['originator'] = $parsedFrame['track']['originator'];
+ $info['replay_gain']['track']['adjustment'] = $parsedFrame['track']['adjustment'];
+ $info['replay_gain']['album']['originator'] = $parsedFrame['album']['originator'];
+ $info['replay_gain']['album']['adjustment'] = $parsedFrame['album']['adjustment'];
unset($parsedFrame['data']);
@@ -1781,6 +1855,52 @@ class getid3_id3v2
return str_replace("\xFF\x00", "\xFF", $data);
}
+ function LookupExtendedHeaderRestrictionsTagSizeLimits($index) {
+ static $LookupExtendedHeaderRestrictionsTagSizeLimits = array(
+ 0x00 => 'No more than 128 frames and 1 MB total tag size',
+ 0x01 => 'No more than 64 frames and 128 KB total tag size',
+ 0x02 => 'No more than 32 frames and 40 KB total tag size',
+ 0x03 => 'No more than 32 frames and 4 KB total tag size',
+ );
+ return (isset($LookupExtendedHeaderRestrictionsTagSizeLimits[$index]) ? $LookupExtendedHeaderRestrictionsTagSizeLimits[$index] : '');
+ }
+
+ function LookupExtendedHeaderRestrictionsTextEncodings($index) {
+ static $LookupExtendedHeaderRestrictionsTextEncodings = array(
+ 0x00 => 'No restrictions',
+ 0x01 => 'Strings are only encoded with ISO-8859-1 or UTF-8',
+ );
+ return (isset($LookupExtendedHeaderRestrictionsTextEncodings[$index]) ? $LookupExtendedHeaderRestrictionsTextEncodings[$index] : '');
+ }
+
+ function LookupExtendedHeaderRestrictionsTextFieldSize($index) {
+ static $LookupExtendedHeaderRestrictionsTextFieldSize = array(
+ 0x00 => 'No restrictions',
+ 0x01 => 'No string is longer than 1024 characters',
+ 0x02 => 'No string is longer than 128 characters',
+ 0x03 => 'No string is longer than 30 characters',
+ );
+ return (isset($LookupExtendedHeaderRestrictionsTextFieldSize[$index]) ? $LookupExtendedHeaderRestrictionsTextFieldSize[$index] : '');
+ }
+
+ function LookupExtendedHeaderRestrictionsImageEncoding($index) {
+ static $LookupExtendedHeaderRestrictionsImageEncoding = array(
+ 0x00 => 'No restrictions',
+ 0x01 => 'Images are encoded only with PNG or JPEG',
+ );
+ return (isset($LookupExtendedHeaderRestrictionsImageEncoding[$index]) ? $LookupExtendedHeaderRestrictionsImageEncoding[$index] : '');
+ }
+
+ function LookupExtendedHeaderRestrictionsImageSizeSize($index) {
+ static $LookupExtendedHeaderRestrictionsImageSizeSize = array(
+ 0x00 => 'No restrictions',
+ 0x01 => 'All images are 256x256 pixels or smaller',
+ 0x02 => 'All images are 64x64 pixels or smaller',
+ 0x03 => 'All images are exactly 64x64 pixels, unless required otherwise',
+ );
+ return (isset($LookupExtendedHeaderRestrictionsImageSizeSize[$index]) ? $LookupExtendedHeaderRestrictionsImageSizeSize[$index] : '');
+ }
+
function LookupCurrencyUnits($currencyid) {
$begin = __LINE__;
@@ -2175,7 +2295,7 @@ class getid3_id3v2
- function LanguageLookup($languagecode, $casesensitive=false) {
+ static function LanguageLookup($languagecode, $casesensitive=false) {
if (!$casesensitive) {
$languagecode = strtolower($languagecode);
@@ -2631,10 +2751,10 @@ class getid3_id3v2
}
- function ETCOEventLookup($index) {
- if (($index >= 0x17) && ($index <= 0xDF)) {
- return 'reserved for future use';
- }
+ static function ETCOEventLookup($index) {
+ if (($index >= 0x17) && ($index <= 0xDF)) {
+ return 'reserved for future use';
+ }
if (($index >= 0xE0) && ($index <= 0xEF)) {
return 'not predefined synch 0-F';
}
@@ -2674,7 +2794,7 @@ class getid3_id3v2
return (isset($EventLookup[$index]) ? $EventLookup[$index] : '');
}
- function SYTLContentTypeLookup($index) {
+ static function SYTLContentTypeLookup($index) {
static $SYTLContentTypeLookup = array(
0x00 => 'other',
0x01 => 'lyrics',
@@ -2690,7 +2810,7 @@ class getid3_id3v2
return (isset($SYTLContentTypeLookup[$index]) ? $SYTLContentTypeLookup[$index] : '');
}
- function APICPictureTypeLookup($index, $returnarray=false) {
+ static function APICPictureTypeLookup($index, $returnarray=false) {
static $APICPictureTypeLookup = array(
0x00 => 'Other',
0x01 => '32x32 pixels \'file icon\' (PNG only)',
@@ -2720,7 +2840,7 @@ class getid3_id3v2
return (isset($APICPictureTypeLookup[$index]) ? $APICPictureTypeLookup[$index] : '');
}
- function COMRReceivedAsLookup($index) {
+ static function COMRReceivedAsLookup($index) {
static $COMRReceivedAsLookup = array(
0x00 => 'Other',
0x01 => 'Standard CD album with other songs',
@@ -2736,7 +2856,7 @@ class getid3_id3v2
return (isset($COMRReceivedAsLookup[$index]) ? $COMRReceivedAsLookup[$index] : '');
}
- function RVA2ChannelTypeLookup($index) {
+ static function RVA2ChannelTypeLookup($index) {
static $RVA2ChannelTypeLookup = array(
0x00 => 'Other',
0x01 => 'Master volume',
@@ -2752,7 +2872,7 @@ class getid3_id3v2
return (isset($RVA2ChannelTypeLookup[$index]) ? $RVA2ChannelTypeLookup[$index] : '');
}
- function FrameNameLongLookup($framename) {
+ static function FrameNameLongLookup($framename) {
$begin = __LINE__;
@@ -2936,7 +3056,7 @@ class getid3_id3v2
}
- function FrameNameShortLookup($framename) {
+ static function FrameNameShortLookup($framename) {
$begin = __LINE__;
@@ -2947,8 +3067,8 @@ class getid3_id3v2
ASPI audio_seek_point_index
BUF recommended_buffer_size
CNT play_counter
- COM comments
- COMM comments
+ COM comment
+ COMM comment
COMR commercial_frame
CRA audio_encryption
CRM encrypted_meta_frame
@@ -3115,40 +3235,47 @@ class getid3_id3v2
return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_short');
}
- function TextEncodingTerminatorLookup($encoding) {
+ static function TextEncodingTerminatorLookup($encoding) {
// http://www.id3.org/id3v2.4.0-structure.txt
// Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings:
- // $00 ISO-8859-1. Terminated with $00.
- // $01 UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00.
- // $02 UTF-16BE encoded Unicode without BOM. Terminated with $00 00.
- // $03 UTF-8 encoded Unicode. Terminated with $00.
-
- static $TextEncodingTerminatorLookup = array(0=>"\x00", 1=>"\x00\x00", 2=>"\x00\x00", 3=>"\x00", 255=>"\x00\x00");
-
- return @$TextEncodingTerminatorLookup[$encoding];
+ static $TextEncodingTerminatorLookup = array(
+ 0 => "\x00", // $00 ISO-8859-1. Terminated with $00.
+ 1 => "\x00\x00", // $01 UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00.
+ 2 => "\x00\x00", // $02 UTF-16BE encoded Unicode without BOM. Terminated with $00 00.
+ 3 => "\x00", // $03 UTF-8 encoded Unicode. Terminated with $00.
+ 255 => "\x00\x00"
+ );
+ return (isset($TextEncodingTerminatorLookup[$encoding]) ? $TextEncodingTerminatorLookup[$encoding] : '');
}
- function TextEncodingNameLookup($encoding) {
+ static function TextEncodingNameLookup($encoding) {
// http://www.id3.org/id3v2.4.0-structure.txt
- static $TextEncodingNameLookup = array(0=>'ISO-8859-1', 1=>'UTF-16', 2=>'UTF-16BE', 3=>'UTF-8', 255=>'UTF-16BE');
+ // Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings:
+ static $TextEncodingNameLookup = array(
+ 0 => 'ISO-8859-1', // $00 ISO-8859-1. Terminated with $00.
+ 1 => 'UTF-16', // $01 UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00.
+ 2 => 'UTF-16BE', // $02 UTF-16BE encoded Unicode without BOM. Terminated with $00 00.
+ 3 => 'UTF-8', // $03 UTF-8 encoded Unicode. Terminated with $00.
+ 255 => 'UTF-16BE'
+ );
return (isset($TextEncodingNameLookup[$encoding]) ? $TextEncodingNameLookup[$encoding] : 'ISO-8859-1');
}
- function IsValidID3v2FrameName($framename, $id3v2majorversion) {
+ static function IsValidID3v2FrameName($framename, $id3v2majorversion) {
switch ($id3v2majorversion) {
case 2:
- return ereg('[A-Z][A-Z0-9]{2}', $framename);
+ return preg_match('#[A-Z][A-Z0-9]{2}#', $framename);
break;
case 3:
case 4:
- return ereg('[A-Z][A-Z0-9]{3}', $framename);
+ return preg_match('#[A-Z][A-Z0-9]{3}#', $framename);
break;
}
return false;
}
- function IsANumber($numberstring, $allowdecimal=false, $allownegative=false) {
+ static function IsANumber($numberstring, $allowdecimal=false, $allownegative=false) {
for ($i = 0; $i < strlen($numberstring); $i++) {
if ((chr($numberstring{$i}) < chr('0')) || (chr($numberstring{$i}) > chr('9'))) {
if (($numberstring{$i} == '.') && $allowdecimal) {
@@ -3163,11 +3290,11 @@ class getid3_id3v2
return true;
}
- function IsValidDateStampString($datestamp) {
+ static function IsValidDateStampString($datestamp) {
if (strlen($datestamp) != 8) {
return false;
}
- if (!$this->IsANumber($datestamp, false)) {
+ if (!self::IsANumber($datestamp, false)) {
return false;
}
$year = substr($datestamp, 0, 4);
@@ -3191,7 +3318,7 @@ class getid3_id3v2
return true;
}
- function ID3v2HeaderLength($majorversion) {
+ static function ID3v2HeaderLength($majorversion) {
return (($majorversion == 2) ? 6 : 10);
}
diff --git a/apps/media/getID3/getid3/module.tag.lyrics3.php b/3rdparty/getid3/module.tag.lyrics3.php
index 67dba43eb5b..aaff717891b 100644
--- a/apps/media/getID3/getid3/module.tag.lyrics3.php
+++ b/3rdparty/getid3/module.tag.lyrics3.php
@@ -14,19 +14,21 @@
/////////////////////////////////////////////////////////////////
-class getid3_lyrics3
+class getid3_lyrics3 extends getid3_handler
{
- function getid3_lyrics3(&$fd, &$ThisFileInfo) {
+ function Analyze() {
+ $info = &$this->getid3->info;
+
// http://www.volweb.cz/str/tags.htm
- if ($ThisFileInfo['filesize'] >= pow(2, 31)) {
- $ThisFileInfo['warning'][] = 'Unable to check for Lyrics3 because file is larger than 2GB';
+ if (!getid3_lib::intValueSupported($info['filesize'])) {
+ $info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
return false;
}
- fseek($fd, (0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - LYRICSEND - [Lyrics3size]
- $lyrics3_id3v1 = fread($fd, 128 + 9 + 6);
+ fseek($this->getid3->fp, (0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size]
+ $lyrics3_id3v1 = fread($this->getid3->fp, 128 + 9 + 6);
$lyrics3lsz = substr($lyrics3_id3v1, 0, 6); // Lyrics3size
$lyrics3end = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200
$id3v1tag = substr($lyrics3_id3v1, 15, 128); // ID3v1
@@ -35,7 +37,7 @@ class getid3_lyrics3
// Lyrics3v1, ID3v1, no APE
$lyrics3size = 5100;
- $lyrics3offset = $ThisFileInfo['filesize'] - 128 - $lyrics3size;
+ $lyrics3offset = $info['filesize'] - 128 - $lyrics3size;
$lyrics3version = 1;
} elseif ($lyrics3end == 'LYRICS200') {
@@ -43,49 +45,49 @@ class getid3_lyrics3
// LSZ = lyrics + 'LYRICSBEGIN'; add 6-byte size field; add 'LYRICS200'
$lyrics3size = $lyrics3lsz + 6 + strlen('LYRICS200');
- $lyrics3offset = $ThisFileInfo['filesize'] - 128 - $lyrics3size;
+ $lyrics3offset = $info['filesize'] - 128 - $lyrics3size;
$lyrics3version = 2;
} elseif (substr(strrev($lyrics3_id3v1), 0, 9) == strrev('LYRICSEND')) {
// Lyrics3v1, no ID3v1, no APE
$lyrics3size = 5100;
- $lyrics3offset = $ThisFileInfo['filesize'] - $lyrics3size;
+ $lyrics3offset = $info['filesize'] - $lyrics3size;
$lyrics3version = 1;
- $lyrics3offset = $ThisFileInfo['filesize'] - $lyrics3size;
+ $lyrics3offset = $info['filesize'] - $lyrics3size;
} elseif (substr(strrev($lyrics3_id3v1), 0, 9) == strrev('LYRICS200')) {
// Lyrics3v2, no ID3v1, no APE
$lyrics3size = strrev(substr(strrev($lyrics3_id3v1), 9, 6)) + 6 + strlen('LYRICS200'); // LSZ = lyrics + 'LYRICSBEGIN'; add 6-byte size field; add 'LYRICS200'
- $lyrics3offset = $ThisFileInfo['filesize'] - $lyrics3size;
+ $lyrics3offset = $info['filesize'] - $lyrics3size;
$lyrics3version = 2;
} else {
- if (isset($ThisFileInfo['ape']['tag_offset_start']) && ($ThisFileInfo['ape']['tag_offset_start'] > 15)) {
+ if (isset($info['ape']['tag_offset_start']) && ($info['ape']['tag_offset_start'] > 15)) {
- fseek($fd, $ThisFileInfo['ape']['tag_offset_start'] - 15, SEEK_SET);
- $lyrics3lsz = fread($fd, 6);
- $lyrics3end = fread($fd, 9);
+ fseek($this->getid3->fp, $info['ape']['tag_offset_start'] - 15, SEEK_SET);
+ $lyrics3lsz = fread($this->getid3->fp, 6);
+ $lyrics3end = fread($this->getid3->fp, 9);
if ($lyrics3end == 'LYRICSEND') {
// Lyrics3v1, APE, maybe ID3v1
$lyrics3size = 5100;
- $lyrics3offset = $ThisFileInfo['ape']['tag_offset_start'] - $lyrics3size;
- $ThisFileInfo['avdataend'] = $lyrics3offset;
+ $lyrics3offset = $info['ape']['tag_offset_start'] - $lyrics3size;
+ $info['avdataend'] = $lyrics3offset;
$lyrics3version = 1;
- $ThisFileInfo['warning'][] = 'APE tag located after Lyrics3, will probably break Lyrics3 compatability';
+ $info['warning'][] = 'APE tag located after Lyrics3, will probably break Lyrics3 compatability';
} elseif ($lyrics3end == 'LYRICS200') {
// Lyrics3v2, APE, maybe ID3v1
$lyrics3size = $lyrics3lsz + 6 + strlen('LYRICS200'); // LSZ = lyrics + 'LYRICSBEGIN'; add 6-byte size field; add 'LYRICS200'
- $lyrics3offset = $ThisFileInfo['ape']['tag_offset_start'] - $lyrics3size;
+ $lyrics3offset = $info['ape']['tag_offset_start'] - $lyrics3size;
$lyrics3version = 2;
- $ThisFileInfo['warning'][] = 'APE tag located after Lyrics3, will probably break Lyrics3 compatability';
+ $info['warning'][] = 'APE tag located after Lyrics3, will probably break Lyrics3 compatability';
}
@@ -94,14 +96,24 @@ class getid3_lyrics3
}
if (isset($lyrics3offset)) {
- $ThisFileInfo['avdataend'] = $lyrics3offset;
- $this->getLyrics3Data($ThisFileInfo, $fd, $lyrics3offset, $lyrics3version, $lyrics3size);
+ $info['avdataend'] = $lyrics3offset;
+ $this->getLyrics3Data($lyrics3offset, $lyrics3version, $lyrics3size);
- if (!isset($ThisFileInfo['ape'])) {
- $GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
+ if (!isset($info['ape'])) {
+ $GETID3_ERRORARRAY = &$info['warning'];
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, false)) {
- $tag = new getid3_apetag($fd, $ThisFileInfo, $ThisFileInfo['lyrics3']['tag_offset_start']);
- unset($tag);
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_apetag = new getid3_apetag($getid3_temp);
+ $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start'];
+ $getid3_apetag->Analyze();
+ if (!empty($getid3_temp->info['ape'])) {
+ $info['ape'] = $getid3_temp->info['ape'];
+ }
+ if (!empty($getid3_temp->info['replay_gain'])) {
+ $info['replay_gain'] = $getid3_temp->info['replay_gain'];
+ }
+ unset($getid3_temp, $getid3_apetag);
}
}
@@ -110,43 +122,46 @@ class getid3_lyrics3
return true;
}
- function getLyrics3Data(&$ThisFileInfo, &$fd, $endoffset, $version, $length) {
+ function getLyrics3Data($endoffset, $version, $length) {
// http://www.volweb.cz/str/tags.htm
- if ($endoffset >= pow(2, 31)) {
- $ThisFileInfo['warning'][] = 'Unable to check for Lyrics3 because file is larger than 2GB';
+ $info = &$this->getid3->info;
+
+ if (!getid3_lib::intValueSupported($endoffset)) {
+ $info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
return false;
}
- fseek($fd, $endoffset, SEEK_SET);
+ fseek($this->getid3->fp, $endoffset, SEEK_SET);
if ($length <= 0) {
return false;
}
- $rawdata = fread($fd, $length);
+ $rawdata = fread($this->getid3->fp, $length);
+
+ $ParsedLyrics3['raw']['lyrics3version'] = $version;
+ $ParsedLyrics3['raw']['lyrics3tagsize'] = $length;
+ $ParsedLyrics3['tag_offset_start'] = $endoffset;
+ $ParsedLyrics3['tag_offset_end'] = $endoffset + $length - 1;
if (substr($rawdata, 0, 11) != 'LYRICSBEGIN') {
if (strpos($rawdata, 'LYRICSBEGIN') !== false) {
- $ThisFileInfo['warning'][] = '"LYRICSBEGIN" expected at '.$endoffset.' but actually found at '.($endoffset + strpos($rawdata, 'LYRICSBEGIN')).' - this is invalid for Lyrics3 v'.$version;
- $ThisFileInfo['avdataend'] = $endoffset + strpos($rawdata, 'LYRICSBEGIN');
- $ParsedLyrics3['tag_offset_start'] = $ThisFileInfo['avdataend'];
+ $info['warning'][] = '"LYRICSBEGIN" expected at '.$endoffset.' but actually found at '.($endoffset + strpos($rawdata, 'LYRICSBEGIN')).' - this is invalid for Lyrics3 v'.$version;
+ $info['avdataend'] = $endoffset + strpos($rawdata, 'LYRICSBEGIN');
$rawdata = substr($rawdata, strpos($rawdata, 'LYRICSBEGIN'));
$length = strlen($rawdata);
+ $ParsedLyrics3['tag_offset_start'] = $info['avdataend'];
+ $ParsedLyrics3['raw']['lyrics3tagsize'] = $length;
} else {
- $ThisFileInfo['error'][] = '"LYRICSBEGIN" expected at '.$endoffset.' but found "'.substr($rawdata, 0, 11).'" instead';
+ $info['error'][] = '"LYRICSBEGIN" expected at '.$endoffset.' but found "'.substr($rawdata, 0, 11).'" instead';
return false;
}
}
- $ParsedLyrics3['raw']['lyrics3version'] = $version;
- $ParsedLyrics3['raw']['lyrics3tagsize'] = $length;
- $ParsedLyrics3['tag_offset_start'] = $endoffset;
- $ParsedLyrics3['tag_offset_end'] = $endoffset + $length;
-
switch ($version) {
case 1:
@@ -154,7 +169,7 @@ class getid3_lyrics3
$ParsedLyrics3['raw']['LYR'] = trim(substr($rawdata, 11, strlen($rawdata) - 11 - 9));
$this->Lyrics3LyricsTimestampParse($ParsedLyrics3);
} else {
- $ThisFileInfo['error'][] = '"LYRICSEND" expected at '.(ftell($fd) - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead';
+ $info['error'][] = '"LYRICSEND" expected at '.(ftell($this->getid3->fp) - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead';
return false;
}
break;
@@ -192,9 +207,9 @@ class getid3_lyrics3
foreach ($imagestrings as $key => $imagestring) {
if (strpos($imagestring, '||') !== false) {
$imagearray = explode('||', $imagestring);
- $ParsedLyrics3['images'][$key]['filename'] = @$imagearray[0];
- $ParsedLyrics3['images'][$key]['description'] = @$imagearray[1];
- $ParsedLyrics3['images'][$key]['timestamp'] = $this->Lyrics3Timestamp2Seconds(@$imagearray[2]);
+ $ParsedLyrics3['images'][$key]['filename'] = (isset($imagearray[0]) ? $imagearray[0] : '');
+ $ParsedLyrics3['images'][$key]['description'] = (isset($imagearray[1]) ? $imagearray[1] : '');
+ $ParsedLyrics3['images'][$key]['timestamp'] = $this->Lyrics3Timestamp2Seconds(isset($imagearray[2]) ? $imagearray[2] : '');
}
}
}
@@ -202,37 +217,37 @@ class getid3_lyrics3
$this->Lyrics3LyricsTimestampParse($ParsedLyrics3);
}
} else {
- $ThisFileInfo['error'][] = '"LYRICS200" expected at '.(ftell($fd) - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead';
+ $info['error'][] = '"LYRICS200" expected at '.(ftell($this->getid3->fp) - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead';
return false;
}
break;
default:
- $ThisFileInfo['error'][] = 'Cannot process Lyrics3 version '.$version.' (only v1 and v2)';
+ $info['error'][] = 'Cannot process Lyrics3 version '.$version.' (only v1 and v2)';
return false;
break;
}
- if (isset($ThisFileInfo['id3v1']['tag_offset_start']) && ($ThisFileInfo['id3v1']['tag_offset_start'] < $ParsedLyrics3['tag_offset_end'])) {
- $ThisFileInfo['warning'][] = 'ID3v1 tag information ignored since it appears to be a false synch in Lyrics3 tag data';
- unset($ThisFileInfo['id3v1']);
- foreach ($ThisFileInfo['warning'] as $key => $value) {
+ if (isset($info['id3v1']['tag_offset_start']) && ($info['id3v1']['tag_offset_start'] <= $ParsedLyrics3['tag_offset_end'])) {
+ $info['warning'][] = 'ID3v1 tag information ignored since it appears to be a false synch in Lyrics3 tag data';
+ unset($info['id3v1']);
+ foreach ($info['warning'] as $key => $value) {
if ($value == 'Some ID3v1 fields do not use NULL characters for padding') {
- unset($ThisFileInfo['warning'][$key]);
- sort($ThisFileInfo['warning']);
+ unset($info['warning'][$key]);
+ sort($info['warning']);
break;
}
}
}
- $ThisFileInfo['lyrics3'] = $ParsedLyrics3;
+ $info['lyrics3'] = $ParsedLyrics3;
return true;
}
function Lyrics3Timestamp2Seconds($rawtimestamp) {
- if (ereg('^\\[([0-9]{2}):([0-9]{2})\\]$', $rawtimestamp, $regs)) {
+ if (preg_match('#^\\[([0-9]{2}):([0-9]{2})\\]$#', $rawtimestamp, $regs)) {
return (int) (($regs[1] * 60) + $regs[2]);
}
return false;
@@ -243,7 +258,7 @@ class getid3_lyrics3
foreach ($lyricsarray as $key => $lyricline) {
$regs = array();
unset($thislinetimestamps);
- while (ereg('^(\\[[0-9]{2}:[0-9]{2}\\])', $lyricline, $regs)) {
+ while (preg_match('#^(\\[[0-9]{2}:[0-9]{2}\\])#', $lyricline, $regs)) {
$thislinetimestamps[] = $this->Lyrics3Timestamp2Seconds($regs[0]);
$lyricline = str_replace($regs[0], '', $lyricline);
}
diff --git a/3rdparty/getid3/module.tag.xmp.php b/3rdparty/getid3/module.tag.xmp.php
new file mode 100644
index 00000000000..141fd09d16a
--- /dev/null
+++ b/3rdparty/getid3/module.tag.xmp.php
@@ -0,0 +1,766 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.tag.xmp.php //
+// module for analyzing XMP metadata (e.g. in JPEG files) //
+// dependencies: NONE //
+// //
+/////////////////////////////////////////////////////////////////
+// //
+// Module originally written [2009-Mar-26] by //
+// Nigel Barnes <ngbarnesØhotmail*com> //
+// Bundled into getID3 with permission //
+// called by getID3 in module.graphic.jpg.php //
+// ///
+/////////////////////////////////////////////////////////////////
+
+/**************************************************************************************************
+ * SWISScenter Source Nigel Barnes
+ *
+ * Provides functions for reading information from the 'APP1' Extensible Metadata
+ * Platform (XMP) segment of JPEG format files.
+ * This XMP segment is XML based and contains the Resource Description Framework (RDF)
+ * data, which itself can contain the Dublin Core Metadata Initiative (DCMI) information.
+ *
+ * This code uses segments from the JPEG Metadata Toolkit project by Evan Hunter.
+ *************************************************************************************************/
+class Image_XMP
+{
+ /**
+ * @var string
+ * The name of the image file that contains the XMP fields to extract and modify.
+ * @see Image_XMP()
+ */
+ var $_sFilename = null;
+
+ /**
+ * @var array
+ * The XMP fields that were extracted from the image or updated by this class.
+ * @see getAllTags()
+ */
+ var $_aXMP = array();
+
+ /**
+ * @var boolean
+ * True if an APP1 segment was found to contain XMP metadata.
+ * @see isValid()
+ */
+ var $_bXMPParse = false;
+
+ /**
+ * Returns the status of XMP parsing during instantiation
+ *
+ * You'll normally want to call this method before trying to get XMP fields.
+ *
+ * @return boolean
+ * Returns true if an APP1 segment was found to contain XMP metadata.
+ */
+ function isValid()
+ {
+ return $this->_bXMPParse;
+ }
+
+ /**
+ * Get a copy of all XMP tags extracted from the image
+ *
+ * @return array - An array of XMP fields as it extracted by the XMPparse() function
+ */
+ function getAllTags()
+ {
+ return $this->_aXMP;
+ }
+
+ /**
+ * Reads all the JPEG header segments from an JPEG image file into an array
+ *
+ * @param string $filename - the filename of the JPEG file to read
+ * @return array $headerdata - Array of JPEG header segments
+ * @return boolean FALSE - if headers could not be read
+ */
+ function _get_jpeg_header_data($filename)
+ {
+ // prevent refresh from aborting file operations and hosing file
+ ignore_user_abort(true);
+
+ // Attempt to open the jpeg file - the at symbol supresses the error message about
+ // not being able to open files. The file_exists would have been used, but it
+ // does not work with files fetched over http or ftp.
+ if (is_readable($filename) && is_file($filename) && ($filehnd = fopen($filename, 'rb'))) {
+ // great
+ } else {
+ return false;
+ }
+
+ // Read the first two characters
+ $data = fread($filehnd, 2);
+
+ // Check that the first two characters are 0xFF 0xD8 (SOI - Start of image)
+ if ($data != "\xFF\xD8")
+ {
+ // No SOI (FF D8) at start of file - This probably isn't a JPEG file - close file and return;
+ echo '<p>This probably is not a JPEG file</p>'."\n";
+ fclose($filehnd);
+ return false;
+ }
+
+ // Read the third character
+ $data = fread($filehnd, 2);
+
+ // Check that the third character is 0xFF (Start of first segment header)
+ if ($data{0} != "\xFF")
+ {
+ // NO FF found - close file and return - JPEG is probably corrupted
+ fclose($filehnd);
+ return false;
+ }
+
+ // Flag that we havent yet hit the compressed image data
+ $hit_compressed_image_data = false;
+
+ // Cycle through the file until, one of: 1) an EOI (End of image) marker is hit,
+ // 2) we have hit the compressed image data (no more headers are allowed after data)
+ // 3) or end of file is hit
+
+ while (($data{1} != "\xD9") && (!$hit_compressed_image_data) && (!feof($filehnd)))
+ {
+ // Found a segment to look at.
+ // Check that the segment marker is not a Restart marker - restart markers don't have size or data after them
+ if ((ord($data{1}) < 0xD0) || (ord($data{1}) > 0xD7))
+ {
+ // Segment isn't a Restart marker
+ // Read the next two bytes (size)
+ $sizestr = fread($filehnd, 2);
+
+ // convert the size bytes to an integer
+ $decodedsize = unpack('nsize', $sizestr);
+
+ // Save the start position of the data
+ $segdatastart = ftell($filehnd);
+
+ // Read the segment data with length indicated by the previously read size
+ $segdata = fread($filehnd, $decodedsize['size'] - 2);
+
+ // Store the segment information in the output array
+ $headerdata[] = array(
+ 'SegType' => ord($data{1}),
+ 'SegName' => $GLOBALS['JPEG_Segment_Names'][ord($data{1})],
+ 'SegDataStart' => $segdatastart,
+ 'SegData' => $segdata,
+ );
+ }
+
+ // If this is a SOS (Start Of Scan) segment, then there is no more header data - the compressed image data follows
+ if ($data{1} == "\xDA")
+ {
+ // Flag that we have hit the compressed image data - exit loop as no more headers available.
+ $hit_compressed_image_data = true;
+ }
+ else
+ {
+ // Not an SOS - Read the next two bytes - should be the segment marker for the next segment
+ $data = fread($filehnd, 2);
+
+ // Check that the first byte of the two is 0xFF as it should be for a marker
+ if ($data{0} != "\xFF")
+ {
+ // NO FF found - close file and return - JPEG is probably corrupted
+ fclose($filehnd);
+ return false;
+ }
+ }
+ }
+
+ // Close File
+ fclose($filehnd);
+ // Alow the user to abort from now on
+ ignore_user_abort(false);
+
+ // Return the header data retrieved
+ return $headerdata;
+ }
+
+
+ /**
+ * Retrieves XMP information from an APP1 JPEG segment and returns the raw XML text as a string.
+ *
+ * @param string $filename - the filename of the JPEG file to read
+ * @return string $xmp_data - the string of raw XML text
+ * @return boolean FALSE - if an APP 1 XMP segment could not be found, or if an error occured
+ */
+ function _get_XMP_text($filename)
+ {
+ //Get JPEG header data
+ $jpeg_header_data = $this->_get_jpeg_header_data($filename);
+
+ //Cycle through the header segments
+ for ($i = 0; $i < count($jpeg_header_data); $i++)
+ {
+ // If we find an APP1 header,
+ if (strcmp($jpeg_header_data[$i]['SegName'], 'APP1') == 0)
+ {
+ // And if it has the Adobe XMP/RDF label (http://ns.adobe.com/xap/1.0/\x00) ,
+ if (strncmp($jpeg_header_data[$i]['SegData'], 'http://ns.adobe.com/xap/1.0/'."\x00", 29) == 0)
+ {
+ // Found a XMP/RDF block
+ // Return the XMP text
+ $xmp_data = substr($jpeg_header_data[$i]['SegData'], 29);
+
+ return trim($xmp_data); // trim() should not be neccesary, but some files found in the wild with null-terminated block (known samples from Apple Aperture) causes problems elsewhere (see http://www.getid3.org/phpBB3/viewtopic.php?f=4&t=1153)
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Parses a string containing XMP data (XML), and returns an array
+ * which contains all the XMP (XML) information.
+ *
+ * @param string $xml_text - a string containing the XMP data (XML) to be parsed
+ * @return array $xmp_array - an array containing all xmp details retrieved.
+ * @return boolean FALSE - couldn't parse the XMP data
+ */
+ function read_XMP_array_from_text($xmltext)
+ {
+ // Check if there actually is any text to parse
+ if (trim($xmltext) == '')
+ {
+ return false;
+ }
+
+ // Create an instance of a xml parser to parse the XML text
+ $xml_parser = xml_parser_create('UTF-8');
+
+ // Change: Fixed problem that caused the whitespace (especially newlines) to be destroyed when converting xml text to an xml array, as of revision 1.10
+
+ // We would like to remove unneccessary white space, but this will also
+ // remove things like newlines (&#xA;) in the XML values, so white space
+ // will have to be removed later
+ if (xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, 0) == false)
+ {
+ // Error setting case folding - destroy the parser and return
+ xml_parser_free($xml_parser);
+ return false;
+ }
+
+ // to use XML code correctly we have to turn case folding
+ // (uppercasing) off. XML is case sensitive and upper
+ // casing is in reality XML standards violation
+ if (xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0) == false)
+ {
+ // Error setting case folding - destroy the parser and return
+ xml_parser_free($xml_parser);
+ return false;
+ }
+
+ // Parse the XML text into a array structure
+ if (xml_parse_into_struct($xml_parser, $xmltext, $values, $tags) == 0)
+ {
+ // Error Parsing XML - destroy the parser and return
+ xml_parser_free($xml_parser);
+ return false;
+ }
+
+ // Destroy the xml parser
+ xml_parser_free($xml_parser);
+
+ // Clear the output array
+ $xmp_array = array();
+
+ // The XMP data has now been parsed into an array ...
+
+ // Cycle through each of the array elements
+ $current_property = ''; // current property being processed
+ $container_index = -1; // -1 = no container open, otherwise index of container content
+ foreach ($values as $xml_elem)
+ {
+ // Syntax and Class names
+ switch ($xml_elem['tag'])
+ {
+ case 'x:xmpmeta':
+ // only defined attribute is x:xmptk written by Adobe XMP Toolkit; value is the version of the toolkit
+ break;
+
+ case 'rdf:RDF':
+ // required element immediately within x:xmpmeta; no data here
+ break;
+
+ case 'rdf:Description':
+ switch ($xml_elem['type'])
+ {
+ case 'open':
+ case 'complete':
+ if (array_key_exists('attributes', $xml_elem))
+ {
+ // rdf:Description may contain wanted attributes
+ foreach (array_keys($xml_elem['attributes']) as $key)
+ {
+ // Check whether we want this details from this attribute
+ if (in_array($key, $GLOBALS['XMP_tag_captions']))
+ {
+ // Attribute wanted
+ $xmp_array[$key] = $xml_elem['attributes'][$key];
+ }
+ }
+ }
+ case 'cdata':
+ case 'close':
+ break;
+ }
+
+ case 'rdf:ID':
+ case 'rdf:nodeID':
+ // Attributes are ignored
+ break;
+
+ case 'rdf:li':
+ // Property member
+ if ($xml_elem['type'] == 'complete')
+ {
+ if (array_key_exists('attributes', $xml_elem))
+ {
+ // If Lang Alt (language alternatives) then ensure we take the default language
+ if (isset($xml_elem['attributes']['xml:lang']) && ($xml_elem['attributes']['xml:lang'] != 'x-default'))
+ {
+ break;
+ }
+ }
+ if ($current_property != '')
+ {
+ $xmp_array[$current_property][$container_index] = (isset($xml_elem['value']) ? $xml_elem['value'] : '');
+ $container_index += 1;
+ }
+ //else unidentified attribute!!
+ }
+ break;
+
+ case 'rdf:Seq':
+ case 'rdf:Bag':
+ case 'rdf:Alt':
+ // Container found
+ switch ($xml_elem['type'])
+ {
+ case 'open':
+ $container_index = 0;
+ break;
+ case 'close':
+ $container_index = -1;
+ break;
+ case 'cdata':
+ break;
+ }
+ break;
+
+ default:
+ // Check whether we want the details from this attribute
+ if (in_array($xml_elem['tag'], $GLOBALS['XMP_tag_captions']))
+ {
+ switch ($xml_elem['type'])
+ {
+ case 'open':
+ // open current element
+ $current_property = $xml_elem['tag'];
+ break;
+
+ case 'close':
+ // close current element
+ $current_property = '';
+ break;
+
+ case 'complete':
+ // store attribute value
+ $xmp_array[$xml_elem['tag']] = (isset($xml_elem['value']) ? $xml_elem['value'] : '');
+ break;
+
+ case 'cdata':
+ // ignore
+ break;
+ }
+ }
+ break;
+ }
+
+ }
+ return $xmp_array;
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param string - Name of the image file to access and extract XMP information from.
+ */
+ function Image_XMP($sFilename)
+ {
+ $this->_sFilename = $sFilename;
+
+ if (is_file($this->_sFilename))
+ {
+ // Get XMP data
+ $xmp_data = $this->_get_XMP_text($sFilename);
+ if ($xmp_data)
+ {
+ $this->_aXMP = $this->read_XMP_array_from_text($xmp_data);
+ $this->_bXMPParse = true;
+ }
+ }
+ }
+
+}
+
+/**
+* Global Variable: XMP_tag_captions
+*
+* The Property names of all known XMP fields.
+* Note: this is a full list with unrequired properties commented out.
+*/
+$GLOBALS['XMP_tag_captions'] = array(
+// IPTC Core
+ 'Iptc4xmpCore:CiAdrCity',
+ 'Iptc4xmpCore:CiAdrCtry',
+ 'Iptc4xmpCore:CiAdrExtadr',
+ 'Iptc4xmpCore:CiAdrPcode',
+ 'Iptc4xmpCore:CiAdrRegion',
+ 'Iptc4xmpCore:CiEmailWork',
+ 'Iptc4xmpCore:CiTelWork',
+ 'Iptc4xmpCore:CiUrlWork',
+ 'Iptc4xmpCore:CountryCode',
+ 'Iptc4xmpCore:CreatorContactInfo',
+ 'Iptc4xmpCore:IntellectualGenre',
+ 'Iptc4xmpCore:Location',
+ 'Iptc4xmpCore:Scene',
+ 'Iptc4xmpCore:SubjectCode',
+// Dublin Core Schema
+ 'dc:contributor',
+ 'dc:coverage',
+ 'dc:creator',
+ 'dc:date',
+ 'dc:description',
+ 'dc:format',
+ 'dc:identifier',
+ 'dc:language',
+ 'dc:publisher',
+ 'dc:relation',
+ 'dc:rights',
+ 'dc:source',
+ 'dc:subject',
+ 'dc:title',
+ 'dc:type',
+// XMP Basic Schema
+ 'xmp:Advisory',
+ 'xmp:BaseURL',
+ 'xmp:CreateDate',
+ 'xmp:CreatorTool',
+ 'xmp:Identifier',
+ 'xmp:Label',
+ 'xmp:MetadataDate',
+ 'xmp:ModifyDate',
+ 'xmp:Nickname',
+ 'xmp:Rating',
+ 'xmp:Thumbnails',
+ 'xmpidq:Scheme',
+// XMP Rights Management Schema
+ 'xmpRights:Certificate',
+ 'xmpRights:Marked',
+ 'xmpRights:Owner',
+ 'xmpRights:UsageTerms',
+ 'xmpRights:WebStatement',
+// These are not in spec but Photoshop CS seems to use them
+ 'xap:Advisory',
+ 'xap:BaseURL',
+ 'xap:CreateDate',
+ 'xap:CreatorTool',
+ 'xap:Identifier',
+ 'xap:MetadataDate',
+ 'xap:ModifyDate',
+ 'xap:Nickname',
+ 'xap:Rating',
+ 'xap:Thumbnails',
+ 'xapidq:Scheme',
+ 'xapRights:Certificate',
+ 'xapRights:Copyright',
+ 'xapRights:Marked',
+ 'xapRights:Owner',
+ 'xapRights:UsageTerms',
+ 'xapRights:WebStatement',
+// XMP Media Management Schema
+ 'xapMM:DerivedFrom',
+ 'xapMM:DocumentID',
+ 'xapMM:History',
+ 'xapMM:InstanceID',
+ 'xapMM:ManagedFrom',
+ 'xapMM:Manager',
+ 'xapMM:ManageTo',
+ 'xapMM:ManageUI',
+ 'xapMM:ManagerVariant',
+ 'xapMM:RenditionClass',
+ 'xapMM:RenditionParams',
+ 'xapMM:VersionID',
+ 'xapMM:Versions',
+ 'xapMM:LastURL',
+ 'xapMM:RenditionOf',
+ 'xapMM:SaveID',
+// XMP Basic Job Ticket Schema
+ 'xapBJ:JobRef',
+// XMP Paged-Text Schema
+ 'xmpTPg:MaxPageSize',
+ 'xmpTPg:NPages',
+ 'xmpTPg:Fonts',
+ 'xmpTPg:Colorants',
+ 'xmpTPg:PlateNames',
+// Adobe PDF Schema
+ 'pdf:Keywords',
+ 'pdf:PDFVersion',
+ 'pdf:Producer',
+// Photoshop Schema
+ 'photoshop:AuthorsPosition',
+ 'photoshop:CaptionWriter',
+ 'photoshop:Category',
+ 'photoshop:City',
+ 'photoshop:Country',
+ 'photoshop:Credit',
+ 'photoshop:DateCreated',
+ 'photoshop:Headline',
+ 'photoshop:History',
+// Not in XMP spec
+ 'photoshop:Instructions',
+ 'photoshop:Source',
+ 'photoshop:State',
+ 'photoshop:SupplementalCategories',
+ 'photoshop:TransmissionReference',
+ 'photoshop:Urgency',
+// EXIF Schemas
+ 'tiff:ImageWidth',
+ 'tiff:ImageLength',
+ 'tiff:BitsPerSample',
+ 'tiff:Compression',
+ 'tiff:PhotometricInterpretation',
+ 'tiff:Orientation',
+ 'tiff:SamplesPerPixel',
+ 'tiff:PlanarConfiguration',
+ 'tiff:YCbCrSubSampling',
+ 'tiff:YCbCrPositioning',
+ 'tiff:XResolution',
+ 'tiff:YResolution',
+ 'tiff:ResolutionUnit',
+ 'tiff:TransferFunction',
+ 'tiff:WhitePoint',
+ 'tiff:PrimaryChromaticities',
+ 'tiff:YCbCrCoefficients',
+ 'tiff:ReferenceBlackWhite',
+ 'tiff:DateTime',
+ 'tiff:ImageDescription',
+ 'tiff:Make',
+ 'tiff:Model',
+ 'tiff:Software',
+ 'tiff:Artist',
+ 'tiff:Copyright',
+ 'exif:ExifVersion',
+ 'exif:FlashpixVersion',
+ 'exif:ColorSpace',
+ 'exif:ComponentsConfiguration',
+ 'exif:CompressedBitsPerPixel',
+ 'exif:PixelXDimension',
+ 'exif:PixelYDimension',
+ 'exif:MakerNote',
+ 'exif:UserComment',
+ 'exif:RelatedSoundFile',
+ 'exif:DateTimeOriginal',
+ 'exif:DateTimeDigitized',
+ 'exif:ExposureTime',
+ 'exif:FNumber',
+ 'exif:ExposureProgram',
+ 'exif:SpectralSensitivity',
+ 'exif:ISOSpeedRatings',
+ 'exif:OECF',
+ 'exif:ShutterSpeedValue',
+ 'exif:ApertureValue',
+ 'exif:BrightnessValue',
+ 'exif:ExposureBiasValue',
+ 'exif:MaxApertureValue',
+ 'exif:SubjectDistance',
+ 'exif:MeteringMode',
+ 'exif:LightSource',
+ 'exif:Flash',
+ 'exif:FocalLength',
+ 'exif:SubjectArea',
+ 'exif:FlashEnergy',
+ 'exif:SpatialFrequencyResponse',
+ 'exif:FocalPlaneXResolution',
+ 'exif:FocalPlaneYResolution',
+ 'exif:FocalPlaneResolutionUnit',
+ 'exif:SubjectLocation',
+ 'exif:SensingMethod',
+ 'exif:FileSource',
+ 'exif:SceneType',
+ 'exif:CFAPattern',
+ 'exif:CustomRendered',
+ 'exif:ExposureMode',
+ 'exif:WhiteBalance',
+ 'exif:DigitalZoomRatio',
+ 'exif:FocalLengthIn35mmFilm',
+ 'exif:SceneCaptureType',
+ 'exif:GainControl',
+ 'exif:Contrast',
+ 'exif:Saturation',
+ 'exif:Sharpness',
+ 'exif:DeviceSettingDescription',
+ 'exif:SubjectDistanceRange',
+ 'exif:ImageUniqueID',
+ 'exif:GPSVersionID',
+ 'exif:GPSLatitude',
+ 'exif:GPSLongitude',
+ 'exif:GPSAltitudeRef',
+ 'exif:GPSAltitude',
+ 'exif:GPSTimeStamp',
+ 'exif:GPSSatellites',
+ 'exif:GPSStatus',
+ 'exif:GPSMeasureMode',
+ 'exif:GPSDOP',
+ 'exif:GPSSpeedRef',
+ 'exif:GPSSpeed',
+ 'exif:GPSTrackRef',
+ 'exif:GPSTrack',
+ 'exif:GPSImgDirectionRef',
+ 'exif:GPSImgDirection',
+ 'exif:GPSMapDatum',
+ 'exif:GPSDestLatitude',
+ 'exif:GPSDestLongitude',
+ 'exif:GPSDestBearingRef',
+ 'exif:GPSDestBearing',
+ 'exif:GPSDestDistanceRef',
+ 'exif:GPSDestDistance',
+ 'exif:GPSProcessingMethod',
+ 'exif:GPSAreaInformation',
+ 'exif:GPSDifferential',
+ 'stDim:w',
+ 'stDim:h',
+ 'stDim:unit',
+ 'xapGImg:height',
+ 'xapGImg:width',
+ 'xapGImg:format',
+ 'xapGImg:image',
+ 'stEvt:action',
+ 'stEvt:instanceID',
+ 'stEvt:parameters',
+ 'stEvt:softwareAgent',
+ 'stEvt:when',
+ 'stRef:instanceID',
+ 'stRef:documentID',
+ 'stRef:versionID',
+ 'stRef:renditionClass',
+ 'stRef:renditionParams',
+ 'stRef:manager',
+ 'stRef:managerVariant',
+ 'stRef:manageTo',
+ 'stRef:manageUI',
+ 'stVer:comments',
+ 'stVer:event',
+ 'stVer:modifyDate',
+ 'stVer:modifier',
+ 'stVer:version',
+ 'stJob:name',
+ 'stJob:id',
+ 'stJob:url',
+// Exif Flash
+ 'exif:Fired',
+ 'exif:Return',
+ 'exif:Mode',
+ 'exif:Function',
+ 'exif:RedEyeMode',
+// Exif OECF/SFR
+ 'exif:Columns',
+ 'exif:Rows',
+ 'exif:Names',
+ 'exif:Values',
+// Exif CFAPattern
+ 'exif:Columns',
+ 'exif:Rows',
+ 'exif:Values',
+// Exif DeviceSettings
+ 'exif:Columns',
+ 'exif:Rows',
+ 'exif:Settings',
+);
+
+
+/**
+* Global Variable: JPEG_Segment_Names
+*
+* The names of the JPEG segment markers, indexed by their marker number
+*/
+$GLOBALS['JPEG_Segment_Names'] = array(
+ 0x01 => 'TEM',
+ 0x02 => 'RES',
+ 0xC0 => 'SOF0',
+ 0xC1 => 'SOF1',
+ 0xC2 => 'SOF2',
+ 0xC3 => 'SOF4',
+ 0xC4 => 'DHT',
+ 0xC5 => 'SOF5',
+ 0xC6 => 'SOF6',
+ 0xC7 => 'SOF7',
+ 0xC8 => 'JPG',
+ 0xC9 => 'SOF9',
+ 0xCA => 'SOF10',
+ 0xCB => 'SOF11',
+ 0xCC => 'DAC',
+ 0xCD => 'SOF13',
+ 0xCE => 'SOF14',
+ 0xCF => 'SOF15',
+ 0xD0 => 'RST0',
+ 0xD1 => 'RST1',
+ 0xD2 => 'RST2',
+ 0xD3 => 'RST3',
+ 0xD4 => 'RST4',
+ 0xD5 => 'RST5',
+ 0xD6 => 'RST6',
+ 0xD7 => 'RST7',
+ 0xD8 => 'SOI',
+ 0xD9 => 'EOI',
+ 0xDA => 'SOS',
+ 0xDB => 'DQT',
+ 0xDC => 'DNL',
+ 0xDD => 'DRI',
+ 0xDE => 'DHP',
+ 0xDF => 'EXP',
+ 0xE0 => 'APP0',
+ 0xE1 => 'APP1',
+ 0xE2 => 'APP2',
+ 0xE3 => 'APP3',
+ 0xE4 => 'APP4',
+ 0xE5 => 'APP5',
+ 0xE6 => 'APP6',
+ 0xE7 => 'APP7',
+ 0xE8 => 'APP8',
+ 0xE9 => 'APP9',
+ 0xEA => 'APP10',
+ 0xEB => 'APP11',
+ 0xEC => 'APP12',
+ 0xED => 'APP13',
+ 0xEE => 'APP14',
+ 0xEF => 'APP15',
+ 0xF0 => 'JPG0',
+ 0xF1 => 'JPG1',
+ 0xF2 => 'JPG2',
+ 0xF3 => 'JPG3',
+ 0xF4 => 'JPG4',
+ 0xF5 => 'JPG5',
+ 0xF6 => 'JPG6',
+ 0xF7 => 'JPG7',
+ 0xF8 => 'JPG8',
+ 0xF9 => 'JPG9',
+ 0xFA => 'JPG10',
+ 0xFB => 'JPG11',
+ 0xFC => 'JPG12',
+ 0xFD => 'JPG13',
+ 0xFE => 'COM',
+);
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/write.apetag.php b/3rdparty/getid3/write.apetag.php
index 189160aff84..2b553699fd9 100644
--- a/apps/media/getID3/getid3/write.apetag.php
+++ b/3rdparty/getid3/write.apetag.php
@@ -21,9 +21,9 @@ class getid3_write_apetag
var $filename;
var $tag_data;
- var $always_preserve_replaygain = true; // ReplayGain / MP3gain tags will be copied from old tag even if not passed in data
- var $warnings = array(); // any non-critical errors will be stored here
- var $errors = array(); // any critical errors will be stored here
+ var $always_preserve_replaygain = true; // ReplayGain / MP3gain tags will be copied from old tag even if not passed in data
+ var $warnings = array(); // any non-critical errors will be stored here
+ var $errors = array(); // any critical errors will be stored here
function getid3_write_apetag() {
return true;
@@ -56,7 +56,7 @@ class getid3_write_apetag
}
if ($APEtag = $this->GenerateAPEtag()) {
- if ($fp = @fopen($this->filename, 'a+b')) {
+ if (is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
$oldignoreuserabort = ignore_user_abort(true);
flock($fp, LOCK_EX);
@@ -86,9 +86,7 @@ class getid3_write_apetag
fclose($fp);
ignore_user_abort($oldignoreuserabort);
return true;
-
}
- return false;
}
return false;
}
@@ -97,7 +95,7 @@ class getid3_write_apetag
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($this->filename);
if (isset($ThisFileInfo['ape']['tag_offset_start']) && isset($ThisFileInfo['ape']['tag_offset_end'])) {
- if ($fp = @fopen($this->filename, 'a+b')) {
+ if (is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
flock($fp, LOCK_EX);
$oldignoreuserabort = ignore_user_abort(true);
@@ -120,7 +118,6 @@ class getid3_write_apetag
ignore_user_abort($oldignoreuserabort);
return true;
-
}
return false;
}
@@ -204,7 +201,7 @@ class getid3_write_apetag
}
function CleanAPEtagItemKey($itemkey) {
- $itemkey = eregi_replace("[^\x20-\x7E]", '', $itemkey);
+ $itemkey = preg_replace("#[^\x20-\x7E]#i", '', $itemkey);
// http://www.personal.uni-jena.de/~pfk/mpp/sv8/apekey.html
switch (strtoupper($itemkey)) {
diff --git a/apps/media/getID3/getid3/write.id3v1.php b/3rdparty/getid3/write.id3v1.php
index 3c2b7a402ca..cecccd8ac54 100644
--- a/apps/media/getID3/getid3/write.id3v1.php
+++ b/3rdparty/getid3/write.id3v1.php
@@ -18,6 +18,7 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE_
class getid3_write_id3v1
{
var $filename;
+ var $filesize;
var $tag_data;
var $warnings = array(); // any non-critical errors will be stored here
var $errors = array(); // any critical errors will be stored here
@@ -27,15 +28,14 @@ class getid3_write_id3v1
}
function WriteID3v1() {
- if ((filesize($this->filename) >= (pow(2, 31) - 128)) || (filesize($this->filename) < 0)) {
- $this->errors[] = 'Unable to write ID3v1 because file is larger than 2GB';
- return false;
- }
-
// File MUST be writeable - CHMOD(646) at least
- if (is_writeable($this->filename)) {
- if ($fp_source = @fopen($this->filename, 'r+b')) {
-
+ if (!empty($this->filename) && is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename)) {
+ $this->setRealFileSize();
+ if (($this->filesize <= 0) || !getid3_lib::intValueSupported($this->filesize)) {
+ $this->errors[] = 'Unable to WriteID3v1('.$this->filename.') because filesize ('.$this->filesize.') is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
+ return false;
+ }
+ if ($fp_source = fopen($this->filename, 'r+b')) {
fseek($fp_source, -128, SEEK_END);
if (fread($fp_source, 3) == 'TAG') {
fseek($fp_source, -128, SEEK_END); // overwrite existing ID3v1 tag
@@ -45,19 +45,19 @@ class getid3_write_id3v1
$this->tag_data['track'] = (isset($this->tag_data['track']) ? $this->tag_data['track'] : (isset($this->tag_data['track_number']) ? $this->tag_data['track_number'] : (isset($this->tag_data['tracknumber']) ? $this->tag_data['tracknumber'] : '')));
$new_id3v1_tag_data = getid3_id3v1::GenerateID3v1Tag(
- @$this->tag_data['title'],
- @$this->tag_data['artist'],
- @$this->tag_data['album'],
- @$this->tag_data['year'],
- @$this->tag_data['genreid'],
- @$this->tag_data['comment'],
- @$this->tag_data['track']);
+ (isset($this->tag_data['title'] ) ? $this->tag_data['title'] : ''),
+ (isset($this->tag_data['artist'] ) ? $this->tag_data['artist'] : ''),
+ (isset($this->tag_data['album'] ) ? $this->tag_data['album'] : ''),
+ (isset($this->tag_data['year'] ) ? $this->tag_data['year'] : ''),
+ (isset($this->tag_data['genreid']) ? $this->tag_data['genreid'] : ''),
+ (isset($this->tag_data['comment']) ? $this->tag_data['comment'] : ''),
+ (isset($this->tag_data['track'] ) ? $this->tag_data['track'] : ''));
fwrite($fp_source, $new_id3v1_tag_data, 128);
fclose($fp_source);
return true;
} else {
- $this->errors[] = 'Could not open '.$this->filename.' mode "r+b"';
+ $this->errors[] = 'Could not fopen('.$this->filename.', "r+b")';
return false;
}
}
@@ -71,11 +71,12 @@ class getid3_write_id3v1
// Initialize getID3 engine
$getID3 = new getID3;
+ $getID3->option_tag_id3v2 = false;
+ $getID3->option_tag_apetag = false;
+ $getID3->option_tags_html = false;
+ $getID3->option_extra_info = false;
+ $getID3->option_tag_id3v1 = true;
$ThisFileInfo = $getID3->analyze($this->filename);
- if ($ThisFileInfo['filesize'] >= (pow(2, 31) - 128)) {
- // cannot write tags on files > 2GB
- return false;
- }
if (isset($ThisFileInfo['tags']['id3v1'])) {
foreach ($ThisFileInfo['tags']['id3v1'] as $key => $value) {
$id3v1data[$key] = implode(',', $value);
@@ -87,18 +88,18 @@ class getid3_write_id3v1
}
function RemoveID3v1() {
- if ($ThisFileInfo['filesize'] >= pow(2, 31)) {
- $this->errors[] = 'Unable to write ID3v1 because file is larger than 2GB';
- return false;
- }
-
// File MUST be writeable - CHMOD(646) at least
- if (is_writeable($this->filename)) {
- if ($fp_source = @fopen($this->filename, 'r+b')) {
+ if (!empty($this->filename) && is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename)) {
+ $this->setRealFileSize();
+ if (($this->filesize <= 0) || !getid3_lib::intValueSupported($this->filesize)) {
+ $this->errors[] = 'Unable to RemoveID3v1('.$this->filename.') because filesize ('.$this->filesize.') is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
+ return false;
+ }
+ if ($fp_source = fopen($this->filename, 'r+b')) {
fseek($fp_source, -128, SEEK_END);
if (fread($fp_source, 3) == 'TAG') {
- ftruncate($fp_source, filesize($this->filename) - 128);
+ ftruncate($fp_source, $this->filesize - 128);
} else {
// no ID3v1 tag to begin with - do nothing
}
@@ -106,7 +107,7 @@ class getid3_write_id3v1
return true;
} else {
- $this->errors[] = 'Could not open '.$this->filename.' mode "r+b"';
+ $this->errors[] = 'Could not fopen('.$this->filename.', "r+b")';
}
} else {
$this->errors[] = $this->filename.' is not writeable';
@@ -114,6 +115,24 @@ class getid3_write_id3v1
return false;
}
+ function setRealFileSize() {
+ if (PHP_INT_MAX > 2147483647) {
+ $this->filesize = filesize($this->filename);
+ return true;
+ }
+ // 32-bit PHP will not return correct values for filesize() if file is >=2GB
+ // but getID3->analyze() has workarounds to get actual filesize
+ $getID3 = new getID3;
+ $getID3->option_tag_id3v1 = false;
+ $getID3->option_tag_id3v2 = false;
+ $getID3->option_tag_apetag = false;
+ $getID3->option_tags_html = false;
+ $getID3->option_extra_info = false;
+ $ThisFileInfo = $getID3->analyze($this->filename);
+ $this->filesize = $ThisFileInfo['filesize'];
+ return true;
+ }
+
}
?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/write.id3v2.php b/3rdparty/getid3/write.id3v2.php
index 32546d18af9..ee7c5de2df5 100644
--- a/apps/media/getID3/getid3/write.id3v2.php
+++ b/3rdparty/getid3/write.id3v2.php
@@ -19,6 +19,7 @@ class getid3_write_id3v2
{
var $filename;
var $tag_data;
+ var $fread_buffer_size = 32768; // read buffer size in bytes
var $paddedlength = 4096; // minimum length of ID3v2 tag in bytes
var $majorversion = 3; // ID3v2 major version (2, 3 (recommended), 4)
var $minorversion = 0; // ID3v2 minor version - always 0
@@ -36,12 +37,12 @@ class getid3_write_id3v2
// File MUST be writeable - CHMOD(646) at least. It's best if the
// directory is also writeable, because that method is both faster and less susceptible to errors.
- if (is_writeable($this->filename) || (!file_exists($this->filename) && is_writeable(dirname($this->filename)))) {
+ if (!empty($this->filename) && (is_writeable($this->filename) || (!file_exists($this->filename) && is_writeable(dirname($this->filename))))) {
// Initialize getID3 engine
$getID3 = new getID3;
$OldThisFileInfo = $getID3->analyze($this->filename);
- if ($OldThisFileInfo['filesize'] >= pow(2, 31)) {
- $this->errors[] = 'Unable to write ID3v2 because file is larger than 2GB';
+ if (!getid3_lib::intValueSupported($OldThisFileInfo['filesize'])) {
+ $this->errors[] = 'Unable to write ID3v2 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
fclose($fp_source);
return false;
}
@@ -51,7 +52,7 @@ class getid3_write_id3v2
$this->tag_data = $this->array_join_merge($OldThisFileInfo['id3v2'], $this->tag_data);
}
}
- $this->paddedlength = max(@$OldThisFileInfo['id3v2']['headerlength'], $this->paddedlength);
+ $this->paddedlength = (isset($OldThisFileInfo['id3v2']['headerlength']) ? max($OldThisFileInfo['id3v2']['headerlength'], $this->paddedlength) : $this->paddedlength);
if ($NewID3v2Tag = $this->GenerateID3v2Tag()) {
@@ -60,36 +61,31 @@ class getid3_write_id3v2
// best and fastest method - insert-overwrite existing tag (padded to length of old tag if neccesary)
if (file_exists($this->filename)) {
- ob_start();
- if ($fp = fopen($this->filename, 'r+b')) {
+ if (is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'r+b'))) {
rewind($fp);
fwrite($fp, $NewID3v2Tag, strlen($NewID3v2Tag));
fclose($fp);
} else {
- $this->errors[] = 'Could not open '.$this->filename.' mode "r+b" - '.strip_tags(ob_get_contents());
+ $this->errors[] = 'Could not fopen("'.$this->filename.'", "r+b")';
}
- @ob_end_clean();
} else {
- ob_start();
- if ($fp = fopen($this->filename, 'wb')) {
+ if (is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'wb'))) {
rewind($fp);
fwrite($fp, $NewID3v2Tag, strlen($NewID3v2Tag));
fclose($fp);
} else {
- $this->errors[] = 'Could not open '.$this->filename.' mode "wb" - '.strip_tags(ob_get_contents());
+ $this->errors[] = 'Could not fopen("'.$this->filename.'", "wb")';
}
- @ob_end_clean();
}
} else {
- if ($tempfilename = tempnam('*', 'getID3')) {
- ob_start();
- if ($fp_source = fopen($this->filename, 'rb')) {
- if ($fp_temp = fopen($tempfilename, 'wb')) {
+ if ($tempfilename = tempnam(GETID3_TEMP_DIR, 'getID3')) {
+ if (is_readable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'rb'))) {
+ if (is_writable($tempfilename) && is_file($tempfilename) && ($fp_temp = fopen($tempfilename, 'wb'))) {
fwrite($fp_temp, $NewID3v2Tag, strlen($NewID3v2Tag));
@@ -98,7 +94,7 @@ class getid3_write_id3v2
fseek($fp_source, $OldThisFileInfo['avdataoffset'], SEEK_SET);
}
- while ($buffer = fread($fp_source, GETID3_FREAD_BUFFER_SIZE)) {
+ while ($buffer = fread($fp_source, $this->fread_buffer_size)) {
fwrite($fp_temp, $buffer, strlen($buffer));
}
@@ -106,22 +102,16 @@ class getid3_write_id3v2
fclose($fp_source);
copy($tempfilename, $this->filename);
unlink($tempfilename);
- @ob_end_clean();
return true;
} else {
-
- $this->errors[] = 'Could not open '.$tempfilename.' mode "wb" - '.strip_tags(ob_get_contents());
-
+ $this->errors[] = 'Could not fopen("'.$tempfilename.'", "wb")';
}
fclose($fp_source);
} else {
-
- $this->errors[] = 'Could not open '.$this->filename.' mode "rb" - '.strip_tags(ob_get_contents());
-
+ $this->errors[] = 'Could not fopen("'.$this->filename.'", "rb")';
}
- @ob_end_clean();
}
return false;
@@ -138,7 +128,7 @@ class getid3_write_id3v2
}
return true;
} else {
- $this->errors[] = '!is_writeable('.$this->filename.')';
+ $this->errors[] = 'WriteID3v2() failed: !is_writeable('.$this->filename.')';
}
return false;
}
@@ -150,12 +140,13 @@ class getid3_write_id3v2
// preferred method - only one copying operation, minimal chance of corrupting
// original file if script is interrupted, but required directory to be writeable
- if ($fp_source = @fopen($this->filename, 'rb')) {
+ if (is_readable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'rb'))) {
+
// Initialize getID3 engine
$getID3 = new getID3;
$OldThisFileInfo = $getID3->analyze($this->filename);
- if ($OldThisFileInfo['filesize'] >= pow(2, 31)) {
- $this->errors[] = 'Unable to remove ID3v2 because file is larger than 2GB';
+ if (!getid3_lib::intValueSupported($OldThisFileInfo['filesize'])) {
+ $this->errors[] = 'Unable to remove ID3v2 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
fclose($fp_source);
return false;
}
@@ -163,17 +154,17 @@ class getid3_write_id3v2
if ($OldThisFileInfo['avdataoffset'] !== false) {
fseek($fp_source, $OldThisFileInfo['avdataoffset'], SEEK_SET);
}
- if ($fp_temp = @fopen($this->filename.'getid3tmp', 'w+b')) {
- while ($buffer = fread($fp_source, GETID3_FREAD_BUFFER_SIZE)) {
+ if (is_writable($this->filename) && is_file($this->filename) && ($fp_temp = fopen($this->filename.'getid3tmp', 'w+b'))) {
+ while ($buffer = fread($fp_source, $this->fread_buffer_size)) {
fwrite($fp_temp, $buffer, strlen($buffer));
}
fclose($fp_temp);
} else {
- $this->errors[] = 'Could not open '.$this->filename.'getid3tmp mode "w+b"';
+ $this->errors[] = 'Could not fopen("'.$this->filename.'getid3tmp", "w+b")';
}
fclose($fp_source);
} else {
- $this->errors[] = 'Could not open '.$this->filename.' mode "rb"';
+ $this->errors[] = 'Could not fopen("'.$this->filename.'", "rb")';
}
if (file_exists($this->filename)) {
unlink($this->filename);
@@ -184,12 +175,13 @@ class getid3_write_id3v2
// less desirable alternate method - double-copies the file, overwrites original file
// and could corrupt source file if the script is interrupted or an error occurs.
- if ($fp_source = @fopen($this->filename, 'rb')) {
+ if (is_readable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'rb'))) {
+
// Initialize getID3 engine
$getID3 = new getID3;
$OldThisFileInfo = $getID3->analyze($this->filename);
- if ($OldThisFileInfo['filesize'] >= pow(2, 31)) {
- $this->errors[] = 'Unable to remove ID3v2 because file is larger than 2GB';
+ if (!getid3_lib::intValueSupported($OldThisFileInfo['filesize'])) {
+ $this->errors[] = 'Unable to remove ID3v2 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
fclose($fp_source);
return false;
}
@@ -198,26 +190,26 @@ class getid3_write_id3v2
fseek($fp_source, $OldThisFileInfo['avdataoffset'], SEEK_SET);
}
if ($fp_temp = tmpfile()) {
- while ($buffer = fread($fp_source, GETID3_FREAD_BUFFER_SIZE)) {
+ while ($buffer = fread($fp_source, $this->fread_buffer_size)) {
fwrite($fp_temp, $buffer, strlen($buffer));
}
fclose($fp_source);
- if ($fp_source = @fopen($this->filename, 'wb')) {
+ if (is_writable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'wb'))) {
rewind($fp_temp);
- while ($buffer = fread($fp_temp, GETID3_FREAD_BUFFER_SIZE)) {
+ while ($buffer = fread($fp_temp, $this->fread_buffer_size)) {
fwrite($fp_source, $buffer, strlen($buffer));
}
fseek($fp_temp, -128, SEEK_END);
fclose($fp_source);
} else {
- $this->errors[] = 'Could not open '.$this->filename.' mode "wb"';
+ $this->errors[] = 'Could not fopen("'.$this->filename.'", "wb")';
}
fclose($fp_temp);
} else {
$this->errors[] = 'Could not create tmpfile()';
}
} else {
- $this->errors[] = 'Could not open '.$this->filename.' mode "rb"';
+ $this->errors[] = 'Could not fopen("'.$this->filename.'", "rb")';
}
} else {
@@ -237,25 +229,25 @@ class getid3_write_id3v2
switch ($this->majorversion) {
case 4:
// %abcd0000
- $flag = (@$flags['unsynchronisation'] ? '1' : '0'); // a - Unsynchronisation
- $flag .= (@$flags['extendedheader'] ? '1' : '0'); // b - Extended header
- $flag .= (@$flags['experimental'] ? '1' : '0'); // c - Experimental indicator
- $flag .= (@$flags['footer'] ? '1' : '0'); // d - Footer present
+ $flag = (!empty($flags['unsynchronisation']) ? '1' : '0'); // a - Unsynchronisation
+ $flag .= (!empty($flags['extendedheader'] ) ? '1' : '0'); // b - Extended header
+ $flag .= (!empty($flags['experimental'] ) ? '1' : '0'); // c - Experimental indicator
+ $flag .= (!empty($flags['footer'] ) ? '1' : '0'); // d - Footer present
$flag .= '0000';
break;
case 3:
// %abc00000
- $flag = (@$flags['unsynchronisation'] ? '1' : '0'); // a - Unsynchronisation
- $flag .= (@$flags['extendedheader'] ? '1' : '0'); // b - Extended header
- $flag .= (@$flags['experimental'] ? '1' : '0'); // c - Experimental indicator
+ $flag = (!empty($flags['unsynchronisation']) ? '1' : '0'); // a - Unsynchronisation
+ $flag .= (!empty($flags['extendedheader'] ) ? '1' : '0'); // b - Extended header
+ $flag .= (!empty($flags['experimental'] ) ? '1' : '0'); // c - Experimental indicator
$flag .= '00000';
break;
case 2:
// %ab000000
- $flag = (@$flags['unsynchronisation'] ? '1' : '0'); // a - Unsynchronisation
- $flag .= (@$flags['compression'] ? '1' : '0'); // b - Compression
+ $flag = (!empty($flags['unsynchronisation']) ? '1' : '0'); // a - Unsynchronisation
+ $flag .= (!empty($flags['compression'] ) ? '1' : '0'); // b - Compression
$flag .= '000000';
break;
@@ -777,7 +769,7 @@ class getid3_write_id3v2
$framedata .= chr($source_data_array['encodingid']);
$framedata .= str_replace("\x00", '', $source_data_array['mime'])."\x00";
$framedata .= chr($source_data_array['picturetypeid']);
- $framedata .= @$source_data_array['description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
+ $framedata .= (!empty($source_data_array['description']) ? $source_data_array['description'] : '').getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
$framedata .= $source_data_array['data'];
}
break;
@@ -1146,7 +1138,9 @@ class getid3_write_id3v2
break;
default:
- if ($frame_name{0} == 'T') {
+ if ((($this->majorversion == 2) && (strlen($frame_name) != 3)) || (($this->majorversion > 2) && (strlen($frame_name) != 4))) {
+ $this->errors[] = 'Invalid frame name "'.$frame_name.'" for ID3v2.'.$this->majorversion;
+ } elseif ($frame_name{0} == 'T') {
// 4.2. T??? Text information frames
// Text encoding $xx
// Information <text string(s) according to encoding>
@@ -1624,7 +1618,9 @@ class getid3_write_id3v2
if (!$footer && ($this->paddedlength > (strlen($tagstring) + getid3_id3v2::ID3v2HeaderLength($this->majorversion)))) {
// pad up to $paddedlength bytes if unpadded tag is shorter than $paddedlength
// "Furthermore it MUST NOT have any padding when a tag footer is added to the tag."
- $tagstring .= @str_repeat("\x00", $this->paddedlength - strlen($tagstring) - getid3_id3v2::ID3v2HeaderLength($this->majorversion));
+ if (($this->paddedlength - strlen($tagstring) - getid3_id3v2::ID3v2HeaderLength($this->majorversion)) > 0) {
+ $tagstring .= str_repeat("\x00", $this->paddedlength - strlen($tagstring) - getid3_id3v2::ID3v2HeaderLength($this->majorversion));
+ }
}
if ($this->id3v2_use_unsynchronisation && (substr($tagstring, strlen($tagstring) - 1, 1) == "\xFF")) {
// special unsynchronisation case:
@@ -1822,7 +1818,7 @@ class getid3_write_id3v2
// hashes -> merge based on keys
$keys = array_merge(array_keys($arr1), array_keys($arr2));
foreach ($keys as $key) {
- $new_array[$key] = $this->array_join_merge(@$arr1[$key], @$arr2[$key]);
+ $new_array[$key] = $this->array_join_merge((isset($arr1[$key]) ? $arr1[$key] : ''), (isset($arr2[$key]) ? $arr2[$key] : ''));
}
} else {
// two real arrays -> merge
@@ -1880,15 +1876,15 @@ class getid3_write_id3v2
if ($parts = $this->safe_parse_url($url)) {
if (($parts['scheme'] != 'http') && ($parts['scheme'] != 'https') && ($parts['scheme'] != 'ftp') && ($parts['scheme'] != 'gopher')) {
return false;
- } elseif (!eregi("^[[:alnum:]]([-.]?[0-9a-z])*\.[a-z]{2,3}$", $parts['host'], $regs) && !IsValidDottedIP($parts['host'])) {
+ } elseif (!preg_match('#^[[:alnum:]]([-.]?[0-9a-z])*\\.[a-z]{2,3}$#i', $parts['host'], $regs) && !preg_match('#^[0-9]{1,3}(\\.[0-9]{1,3}){3}$#', $parts['host'])) {
return false;
- } elseif (!eregi("^([[:alnum:]-]|[\_])*$", $parts['user'], $regs)) {
+ } elseif (!preg_match('#^([[:alnum:]-]|[\\_])*$#i', $parts['user'], $regs)) {
return false;
- } elseif (!eregi("^([[:alnum:]-]|[\_])*$", $parts['pass'], $regs)) {
+ } elseif (!preg_match('#^([[:alnum:]-]|[\\_])*$#i', $parts['pass'], $regs)) {
return false;
- } elseif (!eregi("^[[:alnum:]/_\.@~-]*$", $parts['path'], $regs)) {
+ } elseif (!preg_match('#^[[:alnum:]/_\\.@~-]*$#i', $parts['path'], $regs)) {
return false;
- } elseif (!eregi("^[[:alnum:]?&=+:;_()%#/,\.-]*$", $parts['query'], $regs)) {
+ } elseif (!empty($parts['query']) && !preg_match('#^[[:alnum:]?&=+:;_()%\\#/,\\.-]*$#i', $parts['query'], $regs)) {
return false;
} else {
return true;
@@ -1897,7 +1893,7 @@ class getid3_write_id3v2
return false;
}
- function ID3v2ShortFrameNameLookup($majorversion, $long_description) {
+ static function ID3v2ShortFrameNameLookup($majorversion, $long_description) {
$long_description = str_replace(' ', '_', strtolower(trim($long_description)));
static $ID3v2ShortFrameNameLookup = array();
if (empty($ID3v2ShortFrameNameLookup)) {
@@ -2045,7 +2041,7 @@ class getid3_write_id3v2
$ID3v2ShortFrameNameLookup[4]['title_sort_order'] = 'TSOT';
$ID3v2ShortFrameNameLookup[4]['set_subtitle'] = 'TSST';
}
- return @$ID3v2ShortFrameNameLookup[$majorversion][strtolower($long_description)];
+ return (isset($ID3v2ShortFrameNameLookup[$majorversion][strtolower($long_description)]) ? $ID3v2ShortFrameNameLookup[$majorversion][strtolower($long_description)] : '');
}
diff --git a/apps/media/getID3/getid3/write.lyrics3.php b/3rdparty/getid3/write.lyrics3.php
index 6b8a47d6a19..fa49cd16eab 100644
--- a/apps/media/getID3/getid3/write.lyrics3.php
+++ b/3rdparty/getid3/write.lyrics3.php
@@ -30,13 +30,12 @@ class getid3_write_lyrics3
$this->errors[] = 'WriteLyrics3() not yet functional - cannot write Lyrics3';
return false;
}
-
function DeleteLyrics3() {
// Initialize getID3 engine
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($this->filename);
if (isset($ThisFileInfo['lyrics3']['tag_offset_start']) && isset($ThisFileInfo['lyrics3']['tag_offset_end'])) {
- if ($fp = @fopen($this->filename, 'a+b')) {
+ if (is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
flock($fp, LOCK_EX);
$oldignoreuserabort = ignore_user_abort(true);
@@ -61,18 +60,14 @@ class getid3_write_lyrics3
return true;
} else {
-
- $this->errors[] = 'Cannot open "'.$this->filename.'" in "a+b" mode';
+ $this->errors[] = 'Cannot fopen('.$this->filename.', "a+b")';
return false;
-
}
}
// no Lyrics3 present
return true;
}
-
-
}
?> \ No newline at end of file
diff --git a/3rdparty/getid3/write.metaflac.php b/3rdparty/getid3/write.metaflac.php
new file mode 100644
index 00000000000..dfd6950aa70
--- /dev/null
+++ b/3rdparty/getid3/write.metaflac.php
@@ -0,0 +1,163 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// write.metaflac.php //
+// module for writing metaflac tags //
+// dependencies: /helperapps/metaflac.exe //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_write_metaflac
+{
+
+ var $filename;
+ var $tag_data;
+ var $warnings = array(); // any non-critical errors will be stored here
+ var $errors = array(); // any critical errors will be stored here
+
+ function getid3_write_metaflac() {
+ return true;
+ }
+
+ function WriteMetaFLAC() {
+
+ if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
+ $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not written';
+ return false;
+ }
+
+ // Create file with new comments
+ $tempcommentsfilename = tempnam(GETID3_TEMP_DIR, 'getID3');
+ if (is_writable($tempcommentsfilename) && is_file($tempcommentsfilename) && ($fpcomments = fopen($tempcommentsfilename, 'wb'))) {
+ foreach ($this->tag_data as $key => $value) {
+ foreach ($value as $commentdata) {
+ fwrite($fpcomments, $this->CleanmetaflacName($key).'='.$commentdata."\n");
+ }
+ }
+ fclose($fpcomments);
+
+ } else {
+ $this->errors[] = 'failed to open temporary tags file, tags not written - fopen("'.$tempcommentsfilename.'", "wb")';
+ return false;
+ }
+
+ $oldignoreuserabort = ignore_user_abort(true);
+ if (GETID3_OS_ISWINDOWS) {
+
+ if (file_exists(GETID3_HELPERAPPSDIR.'metaflac.exe')) {
+ //$commandline = '"'.GETID3_HELPERAPPSDIR.'metaflac.exe" --no-utf8-convert --remove-all-tags --import-tags-from="'.$tempcommentsfilename.'" "'.str_replace('/', '\\', $this->filename).'"';
+ // metaflac works fine if you copy-paste the above commandline into a command prompt,
+ // but refuses to work with `backtick` if there are "doublequotes" present around BOTH
+ // the metaflac pathname and the target filename. For whatever reason...??
+ // The solution is simply ensure that the metaflac pathname has no spaces,
+ // and therefore does not need to be quoted
+
+ // On top of that, if error messages are not always captured properly under Windows
+ // To at least see if there was a problem, compare file modification timestamps before and after writing
+ clearstatcache();
+ $timestampbeforewriting = filemtime($this->filename);
+
+ $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --no-utf8-convert --remove-all-tags --import-tags-from='.escapeshellarg($tempcommentsfilename).' '.escapeshellarg($this->filename).' 2>&1';
+ $metaflacError = `$commandline`;
+
+ if (empty($metaflacError)) {
+ clearstatcache();
+ if ($timestampbeforewriting == filemtime($this->filename)) {
+ $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not written';
+ }
+ }
+ } else {
+ $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
+ }
+
+ } else {
+
+ // It's simpler on *nix
+ $commandline = 'metaflac --no-utf8-convert --remove-all-tags --import-tags-from='.escapeshellarg($tempcommentsfilename).' '.escapeshellarg($this->filename).' 2>&1';
+ $metaflacError = `$commandline`;
+
+ }
+
+ // Remove temporary comments file
+ unlink($tempcommentsfilename);
+ ignore_user_abort($oldignoreuserabort);
+
+ if (!empty($metaflacError)) {
+
+ $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
+ return false;
+
+ }
+
+ return true;
+ }
+
+
+ function DeleteMetaFLAC() {
+
+ if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
+ $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not deleted';
+ return false;
+ }
+
+ $oldignoreuserabort = ignore_user_abort(true);
+ if (GETID3_OS_ISWINDOWS) {
+
+ if (file_exists(GETID3_HELPERAPPSDIR.'metaflac.exe')) {
+ // To at least see if there was a problem, compare file modification timestamps before and after writing
+ clearstatcache();
+ $timestampbeforewriting = filemtime($this->filename);
+
+ $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --remove-all-tags "'.$this->filename.'" 2>&1';
+ $metaflacError = `$commandline`;
+
+ if (empty($metaflacError)) {
+ clearstatcache();
+ if ($timestampbeforewriting == filemtime($this->filename)) {
+ $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not deleted';
+ }
+ }
+ } else {
+ $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
+ }
+
+ } else {
+
+ // It's simpler on *nix
+ $commandline = 'metaflac --remove-all-tags "'.$this->filename.'" 2>&1';
+ $metaflacError = `$commandline`;
+
+ }
+
+ ignore_user_abort($oldignoreuserabort);
+
+ if (!empty($metaflacError)) {
+ $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
+ return false;
+ }
+ return true;
+ }
+
+
+ function CleanmetaflacName($originalcommentname) {
+ // A case-insensitive field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
+ // ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through
+ // 0x7A inclusive (a-z).
+
+ // replace invalid chars with a space, return uppercase text
+ // Thanks Chris Bolt <chris-getid3Øbolt*cx> for improving this function
+ // note: *reg_replace() replaces nulls with empty string (not space)
+ return strtoupper(preg_replace('#[^ -<>-}]#', ' ', str_replace("\x00", ' ', $originalcommentname)));
+
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/write.php b/3rdparty/getid3/write.php
index 73e261036f2..16b19c7d73b 100644
--- a/apps/media/getID3/getid3/write.php
+++ b/3rdparty/getid3/write.php
@@ -20,10 +20,10 @@
/////////////////////////////////////////////////////////////////
if (!defined('GETID3_INCLUDEPATH')) {
- die('getid3.php MUST be included before calling getid3_writetags');
+ throw new Exception('getid3.php MUST be included before calling getid3_writetags');
}
if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
- die('write.php depends on getid3.lib.php, which is missing.');
+ throw new Exception('write.php depends on getid3.lib.php, which is missing.');
}
@@ -51,7 +51,7 @@ class getid3_writetags
var $tagformats = array(); // array of tag formats to write ('id3v1', 'id3v2.2', 'id2v2.3', 'id3v2.4', 'ape', 'vorbiscomment', 'metaflac', 'real')
var $tag_data = array(array()); // 2-dimensional array of tag data (ex: $data['ARTIST'][0] = 'Elvis')
var $tag_encoding = 'ISO-8859-1'; // text encoding used for tag data ('ISO-8859-1', 'UTF-8', 'UTF-16', 'UTF-16LE', 'UTF-16BE', )
- var $overwrite_tags = true; // if true will erase existing tag data and write only passed data; if false will merge passed data with existing tag data
+ var $overwrite_tags = true; // if true will erase existing tag data and write only passed data; if false will merge passed data with existing tag data
var $remove_other_tags = false; // if true will erase remove all existing tags and only write those passed in $tagformats; if false will ignore any tags not mentioned in $tagformats
var $id3v2_tag_language = 'eng'; // ISO-639-2 3-character language code needed for some ID3v2 frames (http://www.id3.org/iso639-2.html)
@@ -98,7 +98,7 @@ class getid3_writetags
$this->ThisFileInfo = $getID3->analyze($this->filename);
// check for what file types are allowed on this fileformat
- switch (@$this->ThisFileInfo['fileformat']) {
+ switch (isset($this->ThisFileInfo['fileformat']) ? $this->ThisFileInfo['fileformat'] : '') {
case 'mp3':
case 'mp2':
case 'mp1':
@@ -119,7 +119,7 @@ class getid3_writetags
break;
case 'ogg':
- switch (@$this->ThisFileInfo['audio']['dataformat']) {
+ switch (isset($this->ThisFileInfo['audio']['dataformat']) ? $this->ThisFileInfo['audio']['dataformat'] : '') {
case 'flac':
//$AllowedTagFormats = array('metaflac');
$this->errors[] = 'metaflac is not (yet) compatible with OggFLAC files';
@@ -141,10 +141,8 @@ class getid3_writetags
}
foreach ($this->tagformats as $requested_tag_format) {
if (!in_array($requested_tag_format, $AllowedTagFormats)) {
- $errormessage = 'Tag format "'.$requested_tag_format.'" is not allowed on "'.@$this->ThisFileInfo['fileformat'];
- if (@$this->ThisFileInfo['fileformat'] != @$this->ThisFileInfo['audio']['dataformat']) {
- $errormessage .= '.'.@$this->ThisFileInfo['audio']['dataformat'];
- }
+ $errormessage = 'Tag format "'.$requested_tag_format.'" is not allowed on "'.(isset($this->ThisFileInfo['fileformat']) ? $this->ThisFileInfo['fileformat'] : '');
+ $errormessage .= (isset($this->ThisFileInfo['audio']['dataformat']) ? '.'.$this->ThisFileInfo['audio']['dataformat'] : '');
$errormessage .= '" files';
$this->errors[] = $errormessage;
return false;
@@ -216,7 +214,7 @@ class getid3_writetags
// Validation of supplied data
if (!is_array($this->tag_data)) {
- $this->errors[] = '$tag_data is not an array in WriteTags()';
+ $this->errors[] = '$this->tag_data is not an array in WriteTags()';
return false;
}
// convert supplied data array keys to upper case, if they're not already
@@ -258,7 +256,7 @@ class getid3_writetags
if (($ape_writer->tag_data = $this->FormatDataForAPE()) !== false) {
$ape_writer->filename = $this->filename;
if (($success = $ape_writer->WriteAPEtag()) === false) {
- $this->errors[] = 'WriteAPEtag() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $ape_writer->errors)).'</LI></UL></PRE>';
+ $this->errors[] = 'WriteAPEtag() failed with message(s):<pre><ul><li>'.str_replace("\n", '</li><li>', htmlentities(trim(implode("\n", $ape_writer->errors)))).'</li></ul></pre>';
}
} else {
$this->errors[] = 'FormatDataForAPE() failed';
@@ -270,7 +268,7 @@ class getid3_writetags
if (($id3v1_writer->tag_data = $this->FormatDataForID3v1()) !== false) {
$id3v1_writer->filename = $this->filename;
if (($success = $id3v1_writer->WriteID3v1()) === false) {
- $this->errors[] = 'WriteID3v1() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $id3v1_writer->errors)).'</LI></UL></PRE>';
+ $this->errors[] = 'WriteID3v1() failed with message(s):<pre><ul><li>'.str_replace("\n", '</li><li>', htmlentities(trim(implode("\n", $id3v1_writer->errors)))).'</li></ul></pre>';
}
} else {
$this->errors[] = 'FormatDataForID3v1() failed';
@@ -286,7 +284,7 @@ class getid3_writetags
if (($id3v2_writer->tag_data = $this->FormatDataForID3v2($id3v2_writer->majorversion)) !== false) {
$id3v2_writer->filename = $this->filename;
if (($success = $id3v2_writer->WriteID3v2()) === false) {
- $this->errors[] = 'WriteID3v2() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $id3v2_writer->errors)).'</LI></UL></PRE>';
+ $this->errors[] = 'WriteID3v2() failed with message(s):<pre><ul><li>'.str_replace("\n", '</li><li>', htmlentities(trim(implode("\n", $id3v2_writer->errors)))).'</li></ul></pre>';
}
} else {
$this->errors[] = 'FormatDataForID3v2() failed';
@@ -298,7 +296,7 @@ class getid3_writetags
if (($vorbiscomment_writer->tag_data = $this->FormatDataForVorbisComment()) !== false) {
$vorbiscomment_writer->filename = $this->filename;
if (($success = $vorbiscomment_writer->WriteVorbisComment()) === false) {
- $this->errors[] = 'WriteVorbisComment() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $vorbiscomment_writer->errors)).'</LI></UL></PRE>';
+ $this->errors[] = 'WriteVorbisComment() failed with message(s):<pre><ul><li>'.str_replace("\n", '</li><li>', htmlentities(trim(implode("\n", $vorbiscomment_writer->errors)))).'</li></ul></pre>';
}
} else {
$this->errors[] = 'FormatDataForVorbisComment() failed';
@@ -310,7 +308,7 @@ class getid3_writetags
if (($metaflac_writer->tag_data = $this->FormatDataForMetaFLAC()) !== false) {
$metaflac_writer->filename = $this->filename;
if (($success = $metaflac_writer->WriteMetaFLAC()) === false) {
- $this->errors[] = 'WriteMetaFLAC() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $metaflac_writer->errors)).'</LI></UL></PRE>';
+ $this->errors[] = 'WriteMetaFLAC() failed with message(s):<pre><ul><li>'.str_replace("\n", '</li><li>', htmlentities(trim(implode("\n", $metaflac_writer->errors)))).'</li></ul></pre>';
}
} else {
$this->errors[] = 'FormatDataForMetaFLAC() failed';
@@ -322,7 +320,7 @@ class getid3_writetags
if (($real_writer->tag_data = $this->FormatDataForReal()) !== false) {
$real_writer->filename = $this->filename;
if (($success = $real_writer->WriteReal()) === false) {
- $this->errors[] = 'WriteReal() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $real_writer->errors)).'</LI></UL></PRE>';
+ $this->errors[] = 'WriteReal() failed with message(s):<pre><ul><li>'.str_replace("\n", '</li><li>', htmlentities(trim(implode("\n", $real_writer->errors)))).'</li></ul></pre>';
}
} else {
$this->errors[] = 'FormatDataForReal() failed';
@@ -421,6 +419,7 @@ class getid3_writetags
if ($this->overwrite_tags) {
// do nothing - ignore previous data
} else {
+throw new Exception('$this->overwrite_tags=false is known to be buggy in this version of getID3. Will be fixed in the near future, check www.getid3.org for a newer version.');
if (!isset($this->ThisFileInfo['tags'][$TagFormat])) {
return false;
}
@@ -466,14 +465,12 @@ class getid3_writetags
}
}
}
-
- $tag_data_id3v1['title'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['TITLE']));
- $tag_data_id3v1['artist'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['ARTIST']));
- $tag_data_id3v1['album'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['ALBUM']));
- $tag_data_id3v1['year'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['YEAR']));
- $tag_data_id3v1['comment'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['COMMENT']));
-
- $tag_data_id3v1['track'] = intval(getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['TRACKNUMBER'])));
+ $tag_data_id3v1['title'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', implode(' ', (isset($this->tag_data['TITLE'] ) ? $this->tag_data['TITLE'] : array())));
+ $tag_data_id3v1['artist'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', implode(' ', (isset($this->tag_data['ARTIST'] ) ? $this->tag_data['ARTIST'] : array())));
+ $tag_data_id3v1['album'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', implode(' ', (isset($this->tag_data['ALBUM'] ) ? $this->tag_data['ALBUM'] : array())));
+ $tag_data_id3v1['year'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', implode(' ', (isset($this->tag_data['YEAR'] ) ? $this->tag_data['YEAR'] : array())));
+ $tag_data_id3v1['comment'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', implode(' ', (isset($this->tag_data['COMMENT'] ) ? $this->tag_data['COMMENT'] : array())));
+ $tag_data_id3v1['track'] = intval(getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', implode(' ', (isset($this->tag_data['TRACKNUMBER']) ? $this->tag_data['TRACKNUMBER'] : array()))));
if ($tag_data_id3v1['track'] <= 0) {
$tag_data_id3v1['track'] = '';
}
@@ -520,9 +517,35 @@ class getid3_writetags
} else {
// source encoding is NOT valid in ID3v2 - convert it to an ID3v2-valid encoding first
if ($id3v2_majorversion < 4) {
- // convert data from other encoding to UTF-16
- $tag_data_id3v2[$ID3v2_framename][$key]['encodingid'] = 1;
- $tag_data_id3v2[$ID3v2_framename][$key]['data'] = getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-16', $value);
+ // convert data from other encoding to UTF-16 (with BOM)
+ // note: some software, notably Windows Media Player and iTunes are broken and treat files tagged with UTF-16BE (with BOM) as corrupt
+ // therefore we force data to UTF-16LE and manually prepend the BOM
+ $ID3v2_tag_data_converted = false;
+ if (!$ID3v2_tag_data_converted && ($this->tag_encoding == 'ISO-8859-1')) {
+ // great, leave data as-is for minimum compatability problems
+ $tag_data_id3v2[$ID3v2_framename][$key]['encodingid'] = 0;
+ $tag_data_id3v2[$ID3v2_framename][$key]['data'] = $value;
+ $ID3v2_tag_data_converted = true;
+ }
+ if (!$ID3v2_tag_data_converted && ($this->tag_encoding == 'UTF-8')) {
+ do {
+ // if UTF-8 string does not include any characters above chr(127) then it is identical to ISO-8859-1
+ for ($i = 0; $i < strlen($value); $i++) {
+ if (ord($value{$i}) > 127) {
+ break 2;
+ }
+ }
+ $tag_data_id3v2[$ID3v2_framename][$key]['encodingid'] = 0;
+ $tag_data_id3v2[$ID3v2_framename][$key]['data'] = $value;
+ $ID3v2_tag_data_converted = true;
+ } while (false);
+ }
+ if (!$ID3v2_tag_data_converted) {
+ $tag_data_id3v2[$ID3v2_framename][$key]['encodingid'] = 1;
+ //$tag_data_id3v2[$ID3v2_framename][$key]['data'] = getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-16', $value); // output is UTF-16LE+BOM or UTF-16BE+BOM depending on system architecture
+ $tag_data_id3v2[$ID3v2_framename][$key]['data'] = "\xFF\xFE".getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-16LE', $value); // force LittleEndian order version of UTF-16
+ $ID3v2_tag_data_converted = true;
+ }
} else {
// convert data from other encoding to UTF-8
@@ -578,10 +601,10 @@ class getid3_writetags
}
function FormatDataForReal() {
- $tag_data_real['title'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['TITLE']));
- $tag_data_real['artist'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['ARTIST']));
- $tag_data_real['copyright'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['COPYRIGHT']));
- $tag_data_real['comment'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['COMMENT']));
+ $tag_data_real['title'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', implode(' ', (isset($this->tag_data['TITLE'] ) ? $this->tag_data['TITLE'] : array())));
+ $tag_data_real['artist'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', implode(' ', (isset($this->tag_data['ARTIST'] ) ? $this->tag_data['ARTIST'] : array())));
+ $tag_data_real['copyright'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', implode(' ', (isset($this->tag_data['COPYRIGHT']) ? $this->tag_data['COPYRIGHT'] : array())));
+ $tag_data_real['comment'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', implode(' ', (isset($this->tag_data['COMMENT'] ) ? $this->tag_data['COMMENT'] : array())));
$this->MergeExistingTagData('real', $tag_data_real);
return $tag_data_real;
diff --git a/3rdparty/getid3/write.real.php b/3rdparty/getid3/write.real.php
new file mode 100644
index 00000000000..ad37e74adbe
--- /dev/null
+++ b/3rdparty/getid3/write.real.php
@@ -0,0 +1,275 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// write.real.php //
+// module for writing RealAudio/RealVideo tags //
+// dependencies: module.tag.real.php //
+// ///
+/////////////////////////////////////////////////////////////////
+
+class getid3_write_real
+{
+ var $filename;
+ var $tag_data = array();
+ var $fread_buffer_size = 32768; // read buffer size in bytes
+ var $warnings = array(); // any non-critical errors will be stored here
+ var $errors = array(); // any critical errors will be stored here
+ var $paddedlength = 512; // minimum length of CONT tag in bytes
+
+ function getid3_write_real() {
+ return true;
+ }
+
+ function WriteReal() {
+ // File MUST be writeable - CHMOD(646) at least
+ if (is_writeable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'r+b'))) {
+
+ // Initialize getID3 engine
+ $getID3 = new getID3;
+ $OldThisFileInfo = $getID3->analyze($this->filename);
+ if (empty($OldThisFileInfo['real']['chunks']) && !empty($OldThisFileInfo['real']['old_ra_header'])) {
+ $this->errors[] = 'Cannot write Real tags on old-style file format';
+ fclose($fp_source);
+ return false;
+ }
+
+ if (empty($OldThisFileInfo['real']['chunks'])) {
+ $this->errors[] = 'Cannot write Real tags because cannot find DATA chunk in file';
+ fclose($fp_source);
+ return false;
+ }
+ foreach ($OldThisFileInfo['real']['chunks'] as $chunknumber => $chunkarray) {
+ $oldChunkInfo[$chunkarray['name']] = $chunkarray;
+ }
+ if (!empty($oldChunkInfo['CONT']['length'])) {
+ $this->paddedlength = max($oldChunkInfo['CONT']['length'], $this->paddedlength);
+ }
+
+ $new_CONT_tag_data = $this->GenerateCONTchunk();
+ $new_PROP_tag_data = $this->GeneratePROPchunk($OldThisFileInfo['real']['chunks'], $new_CONT_tag_data);
+ $new__RMF_tag_data = $this->GenerateRMFchunk($OldThisFileInfo['real']['chunks']);
+
+ if (isset($oldChunkInfo['.RMF']['length']) && ($oldChunkInfo['.RMF']['length'] == strlen($new__RMF_tag_data))) {
+ fseek($fp_source, $oldChunkInfo['.RMF']['offset'], SEEK_SET);
+ fwrite($fp_source, $new__RMF_tag_data);
+ } else {
+ $this->errors[] = 'new .RMF tag ('.strlen($new__RMF_tag_data).' bytes) different length than old .RMF tag ('.$oldChunkInfo['.RMF']['length'].' bytes)';
+ fclose($fp_source);
+ return false;
+ }
+
+ if (isset($oldChunkInfo['PROP']['length']) && ($oldChunkInfo['PROP']['length'] == strlen($new_PROP_tag_data))) {
+ fseek($fp_source, $oldChunkInfo['PROP']['offset'], SEEK_SET);
+ fwrite($fp_source, $new_PROP_tag_data);
+ } else {
+ $this->errors[] = 'new PROP tag ('.strlen($new_PROP_tag_data).' bytes) different length than old PROP tag ('.$oldChunkInfo['PROP']['length'].' bytes)';
+ fclose($fp_source);
+ return false;
+ }
+
+ if (isset($oldChunkInfo['CONT']['length']) && ($oldChunkInfo['CONT']['length'] == strlen($new_CONT_tag_data))) {
+
+ // new data length is same as old data length - just overwrite
+ fseek($fp_source, $oldChunkInfo['CONT']['offset'], SEEK_SET);
+ fwrite($fp_source, $new_CONT_tag_data);
+ fclose($fp_source);
+ return true;
+
+ } else {
+
+ if (empty($oldChunkInfo['CONT'])) {
+ // no existing CONT chunk
+ $BeforeOffset = $oldChunkInfo['DATA']['offset'];
+ $AfterOffset = $oldChunkInfo['DATA']['offset'];
+ } else {
+ // new data is longer than old data
+ $BeforeOffset = $oldChunkInfo['CONT']['offset'];
+ $AfterOffset = $oldChunkInfo['CONT']['offset'] + $oldChunkInfo['CONT']['length'];
+ }
+ if ($tempfilename = tempnam(GETID3_TEMP_DIR, 'getID3')) {
+ if (is_writable($tempfilename) && is_file($tempfilename) && ($fp_temp = fopen($tempfilename, 'wb'))) {
+
+ rewind($fp_source);
+ fwrite($fp_temp, fread($fp_source, $BeforeOffset));
+ fwrite($fp_temp, $new_CONT_tag_data);
+ fseek($fp_source, $AfterOffset, SEEK_SET);
+ while ($buffer = fread($fp_source, $this->fread_buffer_size)) {
+ fwrite($fp_temp, $buffer, strlen($buffer));
+ }
+ fclose($fp_temp);
+
+ if (copy($tempfilename, $this->filename)) {
+ unlink($tempfilename);
+ fclose($fp_source);
+ return true;
+ }
+ unlink($tempfilename);
+ $this->errors[] = 'FAILED: copy('.$tempfilename.', '.$this->filename.')';
+
+ } else {
+ $this->errors[] = 'Could not fopen("'.$tempfilename.'", "wb")';
+ }
+ }
+ fclose($fp_source);
+ return false;
+
+ }
+
+ }
+ $this->errors[] = 'Could not fopen("'.$this->filename.'", "r+b")';
+ return false;
+ }
+
+ function GenerateRMFchunk(&$chunks) {
+ $oldCONTexists = false;
+ foreach ($chunks as $key => $chunk) {
+ $chunkNameKeys[$chunk['name']] = $key;
+ if ($chunk['name'] == 'CONT') {
+ $oldCONTexists = true;
+ }
+ }
+ $newHeadersCount = $chunks[$chunkNameKeys['.RMF']]['headers_count'] + ($oldCONTexists ? 0 : 1);
+
+ $RMFchunk = "\x00\x00"; // object version
+ $RMFchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['.RMF']]['file_version'], 4);
+ $RMFchunk .= getid3_lib::BigEndian2String($newHeadersCount, 4);
+
+ $RMFchunk = '.RMF'.getid3_lib::BigEndian2String(strlen($RMFchunk) + 8, 4).$RMFchunk; // .RMF chunk identifier + chunk length
+ return $RMFchunk;
+ }
+
+ function GeneratePROPchunk(&$chunks, &$new_CONT_tag_data) {
+ $old_CONT_length = 0;
+ $old_DATA_offset = 0;
+ $old_INDX_offset = 0;
+ foreach ($chunks as $key => $chunk) {
+ $chunkNameKeys[$chunk['name']] = $key;
+ if ($chunk['name'] == 'CONT') {
+ $old_CONT_length = $chunk['length'];
+ } elseif ($chunk['name'] == 'DATA') {
+ if (!$old_DATA_offset) {
+ $old_DATA_offset = $chunk['offset'];
+ }
+ } elseif ($chunk['name'] == 'INDX') {
+ if (!$old_INDX_offset) {
+ $old_INDX_offset = $chunk['offset'];
+ }
+ }
+ }
+ $CONTdelta = strlen($new_CONT_tag_data) - $old_CONT_length;
+
+ $PROPchunk = "\x00\x00"; // object version
+ $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['max_bit_rate'], 4);
+ $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['avg_bit_rate'], 4);
+ $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['max_packet_size'], 4);
+ $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['avg_packet_size'], 4);
+ $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['num_packets'], 4);
+ $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['duration'], 4);
+ $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['preroll'], 4);
+ $PROPchunk .= getid3_lib::BigEndian2String(max(0, $old_INDX_offset + $CONTdelta), 4);
+ $PROPchunk .= getid3_lib::BigEndian2String(max(0, $old_DATA_offset + $CONTdelta), 4);
+ $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['num_streams'], 2);
+ $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['flags_raw'], 2);
+
+ $PROPchunk = 'PROP'.getid3_lib::BigEndian2String(strlen($PROPchunk) + 8, 4).$PROPchunk; // PROP chunk identifier + chunk length
+ return $PROPchunk;
+ }
+
+ function GenerateCONTchunk() {
+ foreach ($this->tag_data as $key => $value) {
+ // limit each value to 0xFFFF bytes
+ $this->tag_data[$key] = substr($value, 0, 65535);
+ }
+
+ $CONTchunk = "\x00\x00"; // object version
+
+ $CONTchunk .= getid3_lib::BigEndian2String((!empty($this->tag_data['title']) ? strlen($this->tag_data['title']) : 0), 2);
+ $CONTchunk .= (!empty($this->tag_data['title']) ? strlen($this->tag_data['title']) : '');
+
+ $CONTchunk .= getid3_lib::BigEndian2String((!empty($this->tag_data['artist']) ? strlen($this->tag_data['artist']) : 0), 2);
+ $CONTchunk .= (!empty($this->tag_data['artist']) ? strlen($this->tag_data['artist']) : '');
+
+ $CONTchunk .= getid3_lib::BigEndian2String((!empty($this->tag_data['copyright']) ? strlen($this->tag_data['copyright']) : 0), 2);
+ $CONTchunk .= (!empty($this->tag_data['copyright']) ? strlen($this->tag_data['copyright']) : '');
+
+ $CONTchunk .= getid3_lib::BigEndian2String((!empty($this->tag_data['comment']) ? strlen($this->tag_data['comment']) : 0), 2);
+ $CONTchunk .= (!empty($this->tag_data['comment']) ? strlen($this->tag_data['comment']) : '');
+
+ if ($this->paddedlength > (strlen($CONTchunk) + 8)) {
+ $CONTchunk .= str_repeat("\x00", $this->paddedlength - strlen($CONTchunk) - 8);
+ }
+
+ $CONTchunk = 'CONT'.getid3_lib::BigEndian2String(strlen($CONTchunk) + 8, 4).$CONTchunk; // CONT chunk identifier + chunk length
+
+ return $CONTchunk;
+ }
+
+ function RemoveReal() {
+ // File MUST be writeable - CHMOD(646) at least
+ if (is_writeable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'r+b'))) {
+
+ // Initialize getID3 engine
+ $getID3 = new getID3;
+ $OldThisFileInfo = $getID3->analyze($this->filename);
+ if (empty($OldThisFileInfo['real']['chunks']) && !empty($OldThisFileInfo['real']['old_ra_header'])) {
+ $this->errors[] = 'Cannot remove Real tags from old-style file format';
+ fclose($fp_source);
+ return false;
+ }
+
+ if (empty($OldThisFileInfo['real']['chunks'])) {
+ $this->errors[] = 'Cannot remove Real tags because cannot find DATA chunk in file';
+ fclose($fp_source);
+ return false;
+ }
+ foreach ($OldThisFileInfo['real']['chunks'] as $chunknumber => $chunkarray) {
+ $oldChunkInfo[$chunkarray['name']] = $chunkarray;
+ }
+
+ if (empty($oldChunkInfo['CONT'])) {
+ // no existing CONT chunk
+ fclose($fp_source);
+ return true;
+ }
+
+ $BeforeOffset = $oldChunkInfo['CONT']['offset'];
+ $AfterOffset = $oldChunkInfo['CONT']['offset'] + $oldChunkInfo['CONT']['length'];
+ if ($tempfilename = tempnam(GETID3_TEMP_DIR, 'getID3')) {
+ if (is_writable($tempfilename) && is_file($tempfilename) && ($fp_temp = fopen($tempfilename, 'wb'))) {
+
+ rewind($fp_source);
+ fwrite($fp_temp, fread($fp_source, $BeforeOffset));
+ fseek($fp_source, $AfterOffset, SEEK_SET);
+ while ($buffer = fread($fp_source, $this->fread_buffer_size)) {
+ fwrite($fp_temp, $buffer, strlen($buffer));
+ }
+ fclose($fp_temp);
+
+ if (copy($tempfilename, $this->filename)) {
+ unlink($tempfilename);
+ fclose($fp_source);
+ return true;
+ }
+ unlink($tempfilename);
+ $this->errors[] = 'FAILED: copy('.$tempfilename.', '.$this->filename.')';
+
+ } else {
+ $this->errors[] = 'Could not fopen("'.$tempfilename.'", "wb")';
+ }
+ }
+ fclose($fp_source);
+ return false;
+ }
+ $this->errors[] = 'Could not fopen("'.$this->filename.'", "r+b")';
+ return false;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/3rdparty/getid3/write.vorbiscomment.php b/3rdparty/getid3/write.vorbiscomment.php
new file mode 100644
index 00000000000..ac8dc693430
--- /dev/null
+++ b/3rdparty/getid3/write.vorbiscomment.php
@@ -0,0 +1,121 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// write.vorbiscomment.php //
+// module for writing VorbisComment tags //
+// dependencies: /helperapps/vorbiscomment.exe //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_write_vorbiscomment
+{
+
+ var $filename;
+ var $tag_data;
+ var $warnings = array(); // any non-critical errors will be stored here
+ var $errors = array(); // any critical errors will be stored here
+
+ function getid3_write_vorbiscomment() {
+ return true;
+ }
+
+ function WriteVorbisComment() {
+
+ if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
+ $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call vorbiscomment, tags not written';
+ return false;
+ }
+
+ // Create file with new comments
+ $tempcommentsfilename = tempnam(GETID3_TEMP_DIR, 'getID3');
+ if (is_writable($tempcommentsfilename) && is_file($tempcommentsfilename) && ($fpcomments = fopen($tempcommentsfilename, 'wb'))) {
+
+ foreach ($this->tag_data as $key => $value) {
+ foreach ($value as $commentdata) {
+ fwrite($fpcomments, $this->CleanVorbisCommentName($key).'='.$commentdata."\n");
+ }
+ }
+ fclose($fpcomments);
+
+ } else {
+ $this->errors[] = 'failed to open temporary tags file "'.$tempcommentsfilename.'", tags not written';
+ return false;
+ }
+
+ $oldignoreuserabort = ignore_user_abort(true);
+ if (GETID3_OS_ISWINDOWS) {
+
+ if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
+ //$commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w --raw -c "'.$tempcommentsfilename.'" "'.str_replace('/', '\\', $this->filename).'"';
+ // vorbiscomment works fine if you copy-paste the above commandline into a command prompt,
+ // but refuses to work with `backtick` if there are "doublequotes" present around BOTH
+ // the metaflac pathname and the target filename. For whatever reason...??
+ // The solution is simply ensure that the metaflac pathname has no spaces,
+ // and therefore does not need to be quoted
+
+ // On top of that, if error messages are not always captured properly under Windows
+ // To at least see if there was a problem, compare file modification timestamps before and after writing
+ clearstatcache();
+ $timestampbeforewriting = filemtime($this->filename);
+
+ $commandline = GETID3_HELPERAPPSDIR.'vorbiscomment.exe -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
+ $VorbiscommentError = `$commandline`;
+
+ if (empty($VorbiscommentError)) {
+ clearstatcache();
+ if ($timestampbeforewriting == filemtime($this->filename)) {
+ $VorbiscommentError = 'File modification timestamp has not changed - it looks like the tags were not written';
+ }
+ }
+ } else {
+ $VorbiscommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
+ }
+
+ } else {
+
+ $commandline = 'vorbiscomment -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
+ $VorbiscommentError = `$commandline`;
+
+ }
+
+ // Remove temporary comments file
+ unlink($tempcommentsfilename);
+ ignore_user_abort($oldignoreuserabort);
+
+ if (!empty($VorbiscommentError)) {
+
+ $this->errors[] = 'system call to vorbiscomment failed with message: '."\n\n".$VorbiscommentError;
+ return false;
+
+ }
+
+ return true;
+ }
+
+ function DeleteVorbisComment() {
+ $this->tag_data = array(array());
+ return $this->WriteVorbisComment();
+ }
+
+ function CleanVorbisCommentName($originalcommentname) {
+ // A case-insensitive field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
+ // ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through
+ // 0x7A inclusive (a-z).
+
+ // replace invalid chars with a space, return uppercase text
+ // Thanks Chris Bolt <chris-getid3Øbolt*cx> for improving this function
+ // note: *reg_replace() replaces nulls with empty string (not space)
+ return strtoupper(preg_replace('#[^ -<>-}]#', ' ', str_replace("\x00", ' ', $originalcommentname)));
+
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/apps/admin_dependencies_chk/appinfo/info.xml b/apps/admin_dependencies_chk/appinfo/info.xml
index 10721ece15b..a9c1c68c5d4 100644
--- a/apps/admin_dependencies_chk/appinfo/info.xml
+++ b/apps/admin_dependencies_chk/appinfo/info.xml
@@ -7,5 +7,4 @@
<author>Brice Maron (eMerzh)</author>
<require>2</require>
<description>Display OwnCloud's dependencies informations (missings modules, ...)</description>
- <default_enable/>
</info>
diff --git a/apps/calendar/ajax/categories/rescan.php b/apps/calendar/ajax/categories/rescan.php
new file mode 100644
index 00000000000..0fd878ed8f9
--- /dev/null
+++ b/apps/calendar/ajax/categories/rescan.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+require_once('../../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
+
+foreach ($_POST as $key=>$element) {
+ debug('_POST: '.$key.'=>'.print_r($element, true));
+}
+
+function bailOut($msg) {
+ OC_JSON::error(array('data' => array('message' => $msg)));
+ OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG);
+ exit();
+}
+function debug($msg) {
+ OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG);
+}
+
+$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+if(count($calendars) == 0) {
+ bailOut(OC_Calendar_App::$l10n->t('No calendars found.'));
+}
+$events = array();
+foreach($calendars as $calendar) {
+ $calendar_events = OC_Calendar_Object::all($calendar['id']);
+ $events = $events + $calendar_events;
+}
+if(count($events) == 0) {
+ bailOut(OC_Calendar_App::$l10n->t('No events found.'));
+}
+
+OC_Calendar_App::scanCategories($events);
+$categories = OC_Calendar_App::getCategoryOptions();
+
+OC_JSON::success(array('data' => array('categories'=>$categories)));
diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php
index 986ab65ed03..6582496577b 100644
--- a/apps/calendar/ajax/event/edit.form.php
+++ b/apps/calendar/ajax/event/edit.form.php
@@ -47,13 +47,8 @@ switch($dtstart->getDateType()) {
$summary = $vevent->getAsString('SUMMARY');
$location = $vevent->getAsString('LOCATION');
-$categories = $vevent->getAsArray('CATEGORIES');
+$categories = $vevent->getAsString('CATEGORIES');
$description = $vevent->getAsString('DESCRIPTION');
-foreach($categories as $category){
- if (!in_array($category, $category_options)){
- array_unshift($category_options, $category);
- }
-}
$last_modified = $vevent->__get('LAST-MODIFIED');
if ($last_modified){
$lastmodified = $last_modified->getDateTime()->format('U');
@@ -220,7 +215,6 @@ $tmpl->assign('eventid', $id);
$tmpl->assign('access', $access);
$tmpl->assign('lastmodified', $lastmodified);
$tmpl->assign('calendar_options', $calendar_options);
-$tmpl->assign('category_options', $category_options);
$tmpl->assign('repeat_options', $repeat_options);
$tmpl->assign('repeat_month_options', $repeat_month_options);
$tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
@@ -257,7 +251,14 @@ if($repeat['repeat'] != 'doesnotrepeat'){
$tmpl->assign('repeat_bymonthday', $repeat['bymonthday']);
$tmpl->assign('repeat_bymonth', $repeat['bymonth']);
$tmpl->assign('repeat_byweekno', $repeat['byweekno']);
+} else {
+ $tmpl->assign('repeat_month', 'monthday');
+ $tmpl->assign('repeat_weekdays', array());
+ $tmpl->assign('repeat_interval', 1);
+ $tmpl->assign('repeat_end', 'never');
+ $tmpl->assign('repeat_count', '10');
+ $tmpl->assign('repeat_weekofmonth', 'auto');
+ $tmpl->assign('repeat_date', '');
+ $tmpl->assign('repeat_year', 'bydate');
}
-$tmpl->printpage();
-
-?> \ No newline at end of file
+$tmpl->printpage(); \ No newline at end of file
diff --git a/apps/calendar/ajax/event/new.form.php b/apps/calendar/ajax/event/new.form.php
index 69d1dc3f08b..91b95546569 100644
--- a/apps/calendar/ajax/event/new.form.php
+++ b/apps/calendar/ajax/event/new.form.php
@@ -32,7 +32,6 @@ $start->setTimezone(new DateTimeZone($timezone));
$end->setTimezone(new DateTimeZone($timezone));
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
-$category_options = OC_Calendar_App::getCategoryOptions();
$repeat_options = OC_Calendar_App::getRepeatOptions();
$repeat_end_options = OC_Calendar_App::getEndOptions();
$repeat_month_options = OC_Calendar_App::getMonthOptions();
@@ -47,7 +46,6 @@ $repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
$tmpl = new OC_Template('calendar', 'part.newevent');
$tmpl->assign('access', 'owner');
$tmpl->assign('calendar_options', $calendar_options);
-$tmpl->assign('category_options', $category_options);
$tmpl->assign('repeat_options', $repeat_options);
$tmpl->assign('repeat_month_options', $repeat_month_options);
$tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
@@ -74,4 +72,3 @@ $tmpl->assign('repeat_weekofmonth', 'auto');
$tmpl->assign('repeat_date', '');
$tmpl->assign('repeat_year', 'bydate');
$tmpl->printpage();
-?>
diff --git a/apps/calendar/index.php b/apps/calendar/index.php
index 280b0a18867..c44de7f07df 100644
--- a/apps/calendar/index.php
+++ b/apps/calendar/index.php
@@ -26,6 +26,7 @@ $eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_rw', 'backg
$eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_r', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false');
OC_Hook::emit('OC_Calendar', 'getSources', array('sources' => &$eventSources));
+$categories = OC_Calendar_App::getCategoryOptions();
//Fix currentview for fullcalendar
if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){
@@ -49,9 +50,12 @@ OC_Util::addScript('calendar', 'calendar');
OC_Util::addStyle('calendar', 'style');
OC_Util::addScript('', 'jquery.multiselect');
OC_Util::addStyle('', 'jquery.multiselect');
+OC_Util::addScript('contacts','jquery.multi-autocomplete');
+OC_Util::addScript('','oc-vcategories');
OC_App::setActiveNavigationEntry('calendar_index');
$tmpl = new OC_Template('calendar', 'calendar', 'user');
$tmpl->assign('eventSources', $eventSources);
+$tmpl->assign('categories', $categories);
if(array_key_exists('showevent', $_GET)){
$tmpl->assign('showevent', $_GET['showevent']);
}
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index 84829695eee..a267f15f781 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -32,13 +32,7 @@ Calendar={
$('#totime').timepicker({
showPeriodLabels: false
});
- $('#category').multiselect({
- header: false,
- noneSelectedText: $('#category').attr('title'),
- selectedList: 2,
- minWidth:'auto',
- classes: 'category',
- });
+ $('#category').multiple_autocomplete({source: categories});
Calendar.UI.repeat('init');
$('#end').change(function(){
Calendar.UI.repeat('end');
@@ -371,6 +365,11 @@ Calendar={
}
$('#'+id).addClass('active');
},
+ categoriesChanged:function(newcategories){
+ categories = $.map(newcategories, function(v) {return v;});
+ console.log('Calendar categories changed to: ' + categories);
+ $('#category').multiple_autocomplete('option', 'source', categories);
+ },
Calendar:{
overview:function(){
if($('#choosecalendar_dialog').dialog('isOpen') == true){
@@ -833,6 +832,8 @@ $(document).ready(function(){
loading: Calendar.UI.loading,
eventSources: eventSources
});
+ OCCategories.changed = Calendar.UI.categoriesChanged;
+ OCCategories.app = 'calendar';
$('#oneweekview_radio').click(function(){
$('#calendar_holder').fullCalendar('changeView', 'agendaWeek');
});
diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php
index 58cc34658c6..ee1d39bc662 100644
--- a/apps/calendar/lib/app.php
+++ b/apps/calendar/lib/app.php
@@ -17,6 +17,7 @@ class OC_Calendar_App{
* @brief language object for calendar app
*/
public static $l10n;
+ protected static $categories = null;
/*
* @brief timezone of the user
@@ -106,19 +107,76 @@ class OC_Calendar_App{
}
return true;
}
- /*
- * THIS FUNCTION IS DEPRECATED AND WILL BE REMOVED SOON
- * @brief returns the valid categories
- * @return array - categories
+
+ protected static function getDefaultCategories()
+ {
+ return array(
+ self::$l10n->t('Birthday'),
+ self::$l10n->t('Business'),
+ self::$l10n->t('Call'),
+ self::$l10n->t('Clients'),
+ self::$l10n->t('Deliverer'),
+ self::$l10n->t('Holidays'),
+ self::$l10n->t('Ideas'),
+ self::$l10n->t('Journey'),
+ self::$l10n->t('Jubilee'),
+ self::$l10n->t('Meeting'),
+ self::$l10n->t('Other'),
+ self::$l10n->t('Personal'),
+ self::$l10n->t('Projects'),
+ self::$l10n->t('Questions'),
+ self::$l10n->t('Work'),
+ );
+ }
+
+ protected static function getVCategories() {
+ if (is_null(self::$categories)) {
+ self::$categories = new OC_VCategories('calendar', null, self::getDefaultCategories());
+ }
+ return self::$categories;
+ }
+
+ public static function getCategoryOptions()
+ {
+ $categories = self::getVCategories()->categories();
+ return $categories;
+ }
+
+ /**
+ * scan events for categories.
+ * @param $events VEVENTs to scan. null to check all events for the current user.
*/
- public static function getCategoryOptions(){
- return OC_Calendar_Object::getCategoryOptions(self::$l10n);
+ public static function scanCategories($events = null) {
+ if (is_null($events)) {
+ $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+ if(count($calendars) > 0) {
+ $events = array();
+ foreach($calendars as $calendar) {
+ $calendar_events = OC_Calendar_Object::all($calendar['id']);
+ $events = $events + $calendar_events;
+ }
+ }
+ }
+ if(is_array($events) && count($events) > 0) {
+ $vcategories = self::getVCategories();
+ $vcategories->delete($vcategories->categories());
+ foreach($events as $event) {
+ $vobject = OC_VObject::parse($event['calendardata']);
+ if(!is_null($vobject)) {
+ $vcategories->loadFromVObject($vobject->VEVENT, true);
+ }
+ }
+ }
}
-
- /*
- * @brief returns the options for an repeating event
- * @return array - valid inputs for repeating events
+
+ /**
+ * check VEvent for new categories.
+ * @see OC_VCategories::loadFromVObject
*/
+ public static function loadCategoriesFromVCalendar(OC_VObject $calendar) {
+ self::getVCategories()->loadFromVObject($calendar->VEVENT, true);
+ }
+
public static function getRepeatOptions(){
return OC_Calendar_Object::getRepeatOptions(self::$l10n);
}
@@ -244,7 +302,6 @@ class OC_Calendar_App{
* @return (array) $events
*/
public static function getrequestedEvents($calendarid, $start, $end){
-
$events = array();
if($calendarid == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){
$calendars = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::CALENDAR, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r');
diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php
index 7eeb004d181..321f4c73ba0 100644
--- a/apps/calendar/lib/calendar.php
+++ b/apps/calendar/lib/calendar.php
@@ -44,10 +44,8 @@ class OC_Calendar_Calendar{
/**
* @brief Returns the list of calendars for a specific user.
* @param string $uid User ID
- * @param boolean $active
+ * @param boolean $active Only return calendars with this $active state, default(=null) is don't care
* @return array
- *
- * TODO: what is active for?
*/
public static function allCalendars($uid, $active=null){
$values = array($uid);
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index ab005bd4a4a..825977c17c5 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -93,6 +93,7 @@ class OC_Calendar_Object{
*/
public static function add($id,$data){
$object = OC_VObject::parse($data);
+ OC_Calendar_App::loadCategoriesFromVCalendar($object);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
if(is_null($uid)){
@@ -139,6 +140,7 @@ class OC_Calendar_Object{
$oldobject = self::find($id);
$object = OC_VObject::parse($data);
+ OC_Calendar_App::loadCategoriesFromVCalendar($object);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' );
@@ -320,27 +322,6 @@ class OC_Calendar_Object{
return $dtend;
}
- public static function getCategoryOptions($l10n)
- {
- return array(
- $l10n->t('Birthday'),
- $l10n->t('Business'),
- $l10n->t('Call'),
- $l10n->t('Clients'),
- $l10n->t('Deliverer'),
- $l10n->t('Holidays'),
- $l10n->t('Ideas'),
- $l10n->t('Journey'),
- $l10n->t('Jubilee'),
- $l10n->t('Meeting'),
- $l10n->t('Other'),
- $l10n->t('Personal'),
- $l10n->t('Projects'),
- $l10n->t('Questions'),
- $l10n->t('Work'),
- );
- }
-
public static function getRepeatOptions($l10n)
{
return array(
@@ -452,10 +433,6 @@ class OC_Calendar_Object{
$errnum++;
}
- if(isset($request['categories']) && !is_array($request['categories'])){
- $errarr['categories'] = $l10n->t('Not an array');
- }
-
$fromday = substr($request['from'], 0, 2);
$frommonth = substr($request['from'], 3, 2);
$fromyear = substr($request['from'], 6, 4);
@@ -623,7 +600,7 @@ class OC_Calendar_Object{
{
$title = $request["title"];
$location = $request["location"];
- $categories = isset($request["categories"]) ? $request["categories"] : array();
+ $categories = $request["categories"];
$allday = isset($request["allday"]);
$from = $request["from"];
$to = $request["to"];
@@ -795,7 +772,7 @@ class OC_Calendar_Object{
$vevent->setString('LOCATION', $location);
$vevent->setString('DESCRIPTION', $description);
- $vevent->setString('CATEGORIES', join(',', $categories));
+ $vevent->setString('CATEGORIES', $categories);
/*if($repeat == "true"){
$vevent->RRULE = $repeat;
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php
index 63c3b500296..ba9423a66f1 100755
--- a/apps/calendar/templates/calendar.php
+++ b/apps/calendar/templates/calendar.php
@@ -1,6 +1,7 @@
<script type='text/javascript'>
var defaultView = '<?php echo OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') ?>';
var eventSources = <?php echo json_encode($_['eventSources']) ?>;
+ var categories = <?php echo json_encode($_['categories']); ?>;
var dayNames = <?php echo json_encode($l->tA(array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'))) ?>;
var dayNamesShort = <?php echo json_encode($l->tA(array('Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'))) ?>;
var monthNames = <?php echo json_encode($l->tA(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'))) ?>;
diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php
index 3e12f2973e2..c63630a5a05 100644
--- a/apps/calendar/templates/part.eventform.php
+++ b/apps/calendar/templates/part.eventform.php
@@ -26,12 +26,8 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid
<tr>
<th width="75px"><?php echo $l->t("Category");?>:</th>
<td>
- <select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>">
- <?php
- if (!isset($_['categories'])) {$_['categories'] = array();}
- echo html_select_options($_['category_options'], $_['categories'], array('combine'=>true));
- ?>
- </select>
+ <input id="category" name="categories" type="text" placeholder="<?php echo $l->t('Separate categories with commas'); ?>" value="<?php echo isset($_['categories']) ? htmlspecialchars($_['categories']) : '' ?>">
+ <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"><img alt="<?php echo $l->t('Edit categories'); ?>" src="<?php echo image_path('core','actions/rename.svg')?>" class="svg action" style="width: 16px; height: 16px;"></a>
</td>
<?php if(count($_['calendar_options']) > 1) { ?>
<th width="75px">&nbsp;&nbsp;&nbsp;<?php echo $l->t("Calendar");?>:</th>
@@ -253,4 +249,4 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid
<div id="tabs-5">
<?php echo $this->inc('share.dropdown'); ?>
</div>
-<?php } ?> \ No newline at end of file
+<?php } ?>
diff --git a/apps/contacts/ajax/categories/list.php b/apps/contacts/ajax/categories/list.php
index 3b41b7bfa95..64d74c82e69 100644
--- a/apps/contacts/ajax/categories/list.php
+++ b/apps/contacts/ajax/categories/list.php
@@ -10,7 +10,7 @@ require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$categories = OC_Contacts_App::$categories->categories();
+$categories = OC_Contacts_App::getCategories();
OC_JSON::success(array('data' => array('categories'=>$categories)));
diff --git a/apps/contacts/ajax/categories/rescan.php b/apps/contacts/ajax/categories/rescan.php
index dd27192baa0..5f1057bab44 100644
--- a/apps/contacts/ajax/categories/rescan.php
+++ b/apps/contacts/ajax/categories/rescan.php
@@ -36,13 +36,8 @@ if(count($contacts) == 0) {
bailOut(OC_Contacts_App::$l10n->t('No contacts found.'));
}
-$cards = array();
-foreach($contacts as $contact) {
- $cards[] = $contact['carddata'];
-}
-
-OC_Contacts_App::$categories->rescan($cards);
-$categories = OC_Contacts_App::$categories->categories();
+OC_Contacts_App::scanCategories($contacts);
+$categories = OC_Contacts_App::getCategories();
OC_JSON::success(array('data' => array('categories'=>$categories)));
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index 776c57ca605..4039b8afd3d 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -35,25 +35,6 @@ if(!is_null($id)) {
$property_types = OC_Contacts_App::getAddPropertyOptions();
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
$categories = OC_Contacts_App::getCategories();
-if(count($categories) == 0) {
- $vcaddressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
- if(count($vcaddressbooks) > 0) {
- $vcaddressbookids = array();
- foreach($vcaddressbooks as $vcaddressbook) {
- $vcaddressbookids[] = $vcaddressbook['id'];
- }
- $vccontacts = OC_Contacts_VCard::all($vcaddressbookids);
- if(count($vccontacts) > 0) {
- $cards = array();
- foreach($vccontacts as $vccontact) {
- $cards[] = $vccontact['carddata'];
- }
-
- OC_Contacts_App::$categories->rescan($cards);
- $categories = OC_Contacts_App::$categories->categories();
- }
- }
-}
$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
@@ -71,7 +52,6 @@ OC_Util::addScript('contacts','jquery.inview');
OC_Util::addScript('contacts','jquery.Jcrop');
OC_Util::addScript('contacts','jquery.multi-autocomplete');
OC_Util::addStyle('','jquery.multiselect');
-OC_Util::addStyle('','oc-vcategories');
OC_Util::addStyle('contacts','jquery.combobox');
OC_Util::addStyle('contacts','jquery.Jcrop');
OC_Util::addStyle('contacts','contacts');
@@ -79,9 +59,9 @@ OC_Util::addStyle('contacts','contacts');
$tmpl = new OC_Template( "contacts", "index", "user" );
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
-$tmpl->assign('property_types',$property_types);
-$tmpl->assign('phone_types',$phone_types);
-$tmpl->assign('categories',$categories);
+$tmpl->assign('property_types', $property_types);
+$tmpl->assign('phone_types', $phone_types);
+$tmpl->assign('categories', $categories);
$tmpl->assign('addressbooks', $addressbooks);
$tmpl->assign('contacts', $contacts);
$tmpl->assign('details', $details );
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 6f34a42a73f..5f2bd6e9df9 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -504,8 +504,9 @@ Contacts={
return false;
},
categoriesChanged:function(newcategories) { // Categories added/deleted.
- console.log('categoriesChanged for ' + Contacts.UI.Card.id + ' : ' + newcategories);
- categories = newcategories;
+ categories = $.map(newcategories, function(v) {return v;});
+ console.log('categoriesChanged for ' + Contacts.UI.Card.id + ' : ' + categories);
+ $('#categories').multiple_autocomplete('option', 'source', categories);
var categorylist = $('#categories_value').find('input');
$.getJSON(OC.filePath('contacts', 'ajax', 'categories/categoriesfor.php'),{'id':Contacts.UI.Card.id},function(jsondata){
if(jsondata.status == 'success'){
diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php
index cc33c733007..78fdfe6a10a 100644
--- a/apps/contacts/lib/app.php
+++ b/apps/contacts/lib/app.php
@@ -53,11 +53,12 @@ class OC_Contacts_App {
if( $addressbook === false || $addressbook['userid'] != OC_User::getUser()) {
if ($addressbook === false) {
OC_Log::write('contacts', 'Addressbook not found: '. $id, OC_Log::ERROR);
+ OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.'))));
}
else {
OC_Log::write('contacts', 'Addressbook('.$id.') is not from '.OC_User::getUser(), OC_Log::ERROR);
+ OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.'))));
}
- OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.')))); // Same here (as with the contact error). Could this error be improved?
exit();
}
return $addressbook;
@@ -156,7 +157,45 @@ class OC_Contacts_App {
}
public static function getCategories() {
- return self::$categories->categories();
+ $categories = self::$categories->categories();
+ if(count($categories) == 0) {
+ self::scanCategories();
+ $categories = self::$categories->categories();
+ }
+ return $categories;
+ }
+
+ /**
+ * scan vcards for categories.
+ * @param $vccontacts VCards to scan. null to check all vcards for the current user.
+ */
+ public static function scanCategories($vccontacts = null) {
+ if (is_null($vccontacts)) {
+ $vcaddressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
+ if(count($vcaddressbooks) > 0) {
+ $vcaddressbookids = array();
+ foreach($vcaddressbooks as $vcaddressbook) {
+ $vcaddressbookids[] = $vcaddressbook['id'];
+ }
+ $vccontacts = OC_Contacts_VCard::all($vcaddressbookids);
+ }
+ }
+ if(is_array($vccontacts) && count($vccontacts) > 0) {
+ $cards = array();
+ foreach($vccontacts as $vccontact) {
+ $cards[] = $vccontact['carddata'];
+ }
+
+ self::$categories->rescan($cards);
+ }
+ }
+
+ /**
+ * check VCard for new categories.
+ * @see OC_VCategories::loadFromVObject
+ */
+ public static function loadCategoriesFromVCard(OC_VObject $contact) {
+ self::$categories->loadFromVObject($contact, true);
}
public static function setLastModifiedHeader($contact) {
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index 15a6176d40c..90b037f76ee 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -148,7 +148,7 @@ class OC_Contacts_VCard{
$stringprops = array('N', 'FN', 'ORG', 'NICK', 'ADR', 'NOTE');
$typeprops = array('ADR', 'TEL', 'EMAIL');
$upgrade = false;
- $fn = $n = $uid = $email = null;
+ $fn = $n = $uid = $email = $org = null;
$version = $vcard->getAsString('VERSION');
// Add version if needed
if($version && $version < '3.0') {
@@ -234,7 +234,7 @@ class OC_Contacts_VCard{
return null;
};
- OC_Contacts_App::$categories->loadFromVObject($card);
+ OC_Contacts_App::loadCategoriesFromVCard($card);
self::updateValuesFromAdd($card);
@@ -306,7 +306,7 @@ class OC_Contacts_VCard{
return false;
}
- OC_Contacts_App::$categories->loadFromVObject($card);
+ OC_Contacts_App::loadCategoriesFromVCard($card);
$fn = $card->getAsString('FN');
if (empty($fn)) {
diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php
index d68dd68f605..b14a35e19ed 100644
--- a/apps/contacts/templates/index.php
+++ b/apps/contacts/templates/index.php
@@ -1,6 +1,6 @@
<script type='text/javascript'>
var totalurl = '<?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/addressbooks';
- var categories = <?php sort($_['categories']); echo json_encode($_['categories']); ?>;
+ var categories = <?php echo json_encode($_['categories']); ?>;
var lang = '<?php echo OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang', 'en'); ?>';
</script>
<div id="controls">
diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php
index ff1f081c4d4..c09c20fd4e4 100644
--- a/apps/contacts/templates/part.contact.php
+++ b/apps/contacts/templates/part.contact.php
@@ -14,7 +14,7 @@ $id = isset($_['id']) ? $_['id'] : '';
<li><a data-type="EMAIL"><?php echo $l->t('Email'); ?></a></li>
<li><a data-type="ADR"><?php echo $l->t('Address'); ?></a></li>
<li><a data-type="NOTE"><?php echo $l->t('Note'); ?></a></li>
- <li><a data-type="CATEGORIES"><?php echo $l->t('Categories'); ?></a></li>
+ <li><a data-type="CATEGORIES"><?php echo $l->t('Groups'); ?></a></li>
</ul>
</div>
<img onclick="Contacts.UI.Card.doExport();" class="svg action" id="contacts_downloadcard" src="<?php echo image_path('', 'actions/download.svg'); ?>" title="<?php echo $l->t('Download contact');?>" />
@@ -58,7 +58,7 @@ $id = isset($_['id']) ? $_['id'] : '';
<dd style="display:none;" class="propertycontainer" id="bday_value" data-element="BDAY"><input id="bday" required="required" name="value" type="text" class="contacts_property big" value="" placeholder="<?php echo $l->t('dd-mm-yyyy'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dt style="display:none;" id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Groups'); ?></label></dt>
<dd style="display:none;" class="propertycontainer" id="categories_value" data-element="CATEGORIES"><input id="categories" required="required" name="value[CATEGORIES]" type="text" class="contacts_property bold" name="value" value="" placeholder="
-<?php echo $l->t('Separate groups with commas'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a><a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a></dd>
+<?php echo $l->t('Separate groups with commas'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a><a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit groups'); ?>"></a></dd>
</dl>
</fieldset>
</form>
diff --git a/apps/files_external/tests/config.php b/apps/files_external/tests/config.php
index 9b40d2b98cf..fa4c74a6e26 100644
--- a/apps/files_external/tests/config.php
+++ b/apps/files_external/tests/config.php
@@ -1,18 +1,21 @@
<?php
return array(
'ftp'=>array(
+ 'run'=>false,
'host'=>'localhost',
'user'=>'test',
'password'=>'test',
'root'=>'/test',
),
'webdav'=>array(
+ 'run'=>false,
'host'=>'localhost',
'user'=>'test',
'password'=>'test',
'root'=>'/owncloud/files/webdav.php',
),
'google'=>array(
+ 'run'=>false,
'consumer_key'=>'anonymous',
'consumer_secret'=>'anonymous',
'token'=>'test',
diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php
index aa565751ba3..e30fb9a1c38 100644
--- a/apps/files_external/tests/ftp.php
+++ b/apps/files_external/tests/ftp.php
@@ -5,19 +5,26 @@
* later.
* See the COPYING-README file.
*/
+
+$config=include('apps/files_external/tests/config.php');
+if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']){
+ abstract class Test_Filestorage_FTP extends Test_FileStorage{}
+ return;
+}else{
+ class Test_Filestorage_FTP extends Test_FileStorage {
+ private $config;
+ private $id;
-class Test_Filestorage_FTP extends Test_FileStorage {
- private $config;
- private $id;
+ public function setUp(){
+ $id=uniqid();
+ $this->config=include('apps/files_external/tests/config.php');
+ $this->config['ftp']['root'].='/'.$id;//make sure we have an new empty folder to work in
+ $this->instance=new OC_Filestorage_FTP($this->config['ftp']);
+ }
- public function setUp(){
- $id=uniqid();
- $this->config=include('apps/files_external/tests/config.php');
- $this->config['ftp']['root'].='/'.$id;//make sure we have an new empty folder to work in
- $this->instance=new OC_Filestorage_FTP($this->config['ftp']);
- }
-
- public function tearDown(){
- OC_Helper::rmdirr($this->instance->constructUrl(''));
+ public function tearDown(){
+ OC_Helper::rmdirr($this->instance->constructUrl(''));
+ }
}
}
+
diff --git a/apps/files_external/tests/google.php b/apps/files_external/tests/google.php
index 1c028945228..08116f0e748 100644
--- a/apps/files_external/tests/google.php
+++ b/apps/files_external/tests/google.php
@@ -20,19 +20,26 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-class Test_Filestorage_Google extends Test_FileStorage {
-
- private $config;
- private $id;
+$config=include('apps/files_external/tests/config.php');
+if(!is_array($config) or !isset($config['google']) or !$config['google']['run']){
+ abstract class Test_Filestorage_Google extends Test_FileStorage{}
+ return;
+}else{
+ class Test_Filestorage_Google extends Test_FileStorage {
+
+ private $config;
+ private $id;
- public function setUp(){
- $id=uniqid();
- $this->config=include('apps/files_external/tests/config.php');
- $this->config['google']['root'].='/'.$id;//make sure we have an new empty folder to work in
- $this->instance=new OC_Filestorage_Google($this->config['google']);
- }
+ public function setUp(){
+ $id=uniqid();
+ $this->config=include('apps/files_external/tests/config.php');
+ $this->config['google']['root'].='/'.$id;//make sure we have an new empty folder to work in
+ $this->instance=new OC_Filestorage_Google($this->config['google']);
+ }
- public function tearDown(){
- $this->instance->rmdir('/');
+ public function tearDown(){
+ $this->instance->rmdir('/');
+ }
}
}
+
diff --git a/apps/files_external/tests/webdav.php b/apps/files_external/tests/webdav.php
index 51799290540..144659819b6 100644
--- a/apps/files_external/tests/webdav.php
+++ b/apps/files_external/tests/webdav.php
@@ -6,18 +6,25 @@
* See the COPYING-README file.
*/
-class Test_Filestorage_DAV extends Test_FileStorage {
- private $config;
- private $id;
+$config=include('apps/files_external/tests/config.php');
+if(!is_array($config) or !isset($config['webdav']) or !$config['webdav']['run']){
+ abstract class Test_Filestorage_DAV extends Test_FileStorage{}
+ return;
+}else{
+ class Test_Filestorage_DAV extends Test_FileStorage {
+ private $config;
+ private $id;
- public function setUp(){
- $id=uniqid();
- $this->config=include('apps/files_external/tests/config.php');
- $this->config['webdav']['root'].='/'.$id;//make sure we have an new empty folder to work in
- $this->instance=new OC_Filestorage_DAV($this->config['webdav']);
- }
+ public function setUp(){
+ $id=uniqid();
+ $this->config=include('apps/files_external/tests/config.php');
+ $this->config['webdav']['root'].='/'.$id;//make sure we have an new empty folder to work in
+ $this->instance=new OC_Filestorage_DAV($this->config['webdav']);
+ }
- public function tearDown(){
- $this->instance->rmdir('/');
+ public function tearDown(){
+ $this->instance->rmdir('/');
+ }
}
}
+
diff --git a/apps/media/appinfo/database.xml b/apps/media/appinfo/database.xml
index 223682fcfcd..702ae9c28b4 100644
--- a/apps/media/appinfo/database.xml
+++ b/apps/media/appinfo/database.xml
@@ -45,6 +45,30 @@
<notnull>true</notnull>
<length>200</length>
</field>
+
+ <index>
+ <name>album_index</name>
+ <field>
+ <name>album_id</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
+
+ <index>
+ <name>album_name_index</name>
+ <field>
+ <name>album_name</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
+
+ <index>
+ <name>album_artist_index</name>
+ <field>
+ <name>album_artist</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
</declaration>
@@ -81,6 +105,21 @@
<sorting>ascending</sorting>
</field>
</index>
+
+ <index>
+ <name>artist_index</name>
+ <field>
+ <name>artist_id</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
+ <index>
+ <name>artist_name_index</name>
+ <field>
+ <name>artist_name</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
</declaration>
@@ -223,6 +262,36 @@
<notnull>true</notnull>
<length>4</length>
</field>
+
+ <index>
+ <name>song_index</name>
+ <field>
+ <name>song_id</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
+ <index>
+ <name>song_album_index</name>
+ <field>
+ <name>song_album</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
+ <index>
+ <name>song_artist_index</name>
+ <field>
+ <name>song_artist</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
+ <index>
+ <name>song_name_index</name>
+ <field>
+ <name>song_name</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
+
</declaration>
diff --git a/apps/media/appinfo/info.xml b/apps/media/appinfo/info.xml
index 795c9a4dd71..4a642bf889d 100644
--- a/apps/media/appinfo/info.xml
+++ b/apps/media/appinfo/info.xml
@@ -3,7 +3,7 @@
<id>media</id>
<name>Media</name>
<description>Media player and server for ownCloud</description>
- <version>0.2</version>
+ <version>0.3</version>
<licence>AGPL</licence>
<author>Robin Appelman</author>
<require>2</require>
diff --git a/apps/media/getID3/changelog.txt b/apps/media/getID3/changelog.txt
deleted file mode 100644
index e1a3d6fcf5a..00000000000
--- a/apps/media/getID3/changelog.txt
+++ /dev/null
@@ -1,2435 +0,0 @@
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// changelog.txt - part of getID3() //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
- » denotes a major feature addition/change
- ¤ denotes a change in the returned structure
- ! denotes a cry for help from developers
-* Bugfix: denotes a fixed bug
-
-Version History
-===============
-
-1.7.9: [2009-03-08] James Heinrich
- » Added DSS (Digital Speech Standard) support
- new file: module.audio.dss.php
- (thanks luke*wilkinsØdtsam*com)
- » Added MPC (Musepack) SV8 support
- (thanks WaldoMonster)
- ¤ some MPC [header] keys renamed to be the same between SV7/SV8
- ¤ start aligning demos CSS styling with v2.x styles
- new file: demos/getid3.css
- ¤ JPEG now returns parsed IPTC tags in [iptc]
- ¤ getid3_lib::GetDataImageSize now requires $imageinfo parameter
- ¤ better support for Matroska files with AC3/DTS/MP3/OGG audio
- (support still lacking for AAC)
- ¤ standardize ID3v2 TCMP key to 'part_of_a_set' between reading
- and writing (thanks aaron_stormØyahoo*com)
- ¤ added ID3v2 keys 'TCMP','TCP' to for writing iTunes-style tags
- (thanks aaron_stormØyahoo*com)
- ¤ back-ported PICTURE tag handling in FLAC tags
- (thanks WaldoMonster)
- ¤ added alternate method to get [video][frame_rate] from QuickTime
- * added partial support for "TCMP"/"TCP" ID3v2 frames (iTunes
- non-standard part-of-a-compilation tag)
- (thanks aaron_stormØyahoo*com)
- * slightly improved scanning through FLV files speed
- (thanks franki)
- * faster Matroska scanning by stopping at cluster chunks once
- needed header chunks are found (much faster for large files)
- * added workaround for broken tagging programs that miss terminating
- null byte for numeric ID3v2.4 genres
- (thanks yam655Øgmail*com)
- * Bugfix: MultiByteCharString2HTML() did not escape common HTML
- special characters like & and ?
- * Bugfix: cleaned up some malformed HTML errors in demo.browse.php
- * Bugfix: under Windows files >2GB might not be processed due to
- "dir" command not finding file with double directory slashes
- * Bugfix: "MODule (assorted sub-formats)" was falsely matching
- some random files (e.g. JPEGs) (thanks qwertywin)
- * Bugfix: suppress PHP_notice on failed SWF-compressed
- decompression failure (thanks mkron)
-
-
-1.7.8b3: [2008-07-13] James Heinrich
- » Experimental partial support for files > 2GB (gets filesize
- from shell call to "dir" or "ls", parse files with PHP only
- up to 2GB limit). See readme.txt for details on what formats
- work properly and other limitations
- » Initial support for Matroska. Has only been tested with a
- limited number of sample files, please report any bugs
- » Experimental support for PHP-RAR reading. Known buggy, disabled
- by default, enable with care
- ¤ getid3_lib::CastAsInt() now returns ints up to 2^31 (not 2^30)
- ¤ Quicktime: [video] now returns [frame_rate] and [fourcc] for MP4
- video files
- * MP3: headerless VBR files now only have up to 10 blocks of 5000
- frames each scanned by default and bitrate extrapolated from that
- distribution for speed (thanks glau*stuffØridiculousprods*com)
- * Quicktime: support "co64" atom
- * SWF: lower memory use when compressed SWF files processed
- (thanks doughammondØblueyonder*co*uk)
- * Bugfix: FLV height and width was calculated incorrectly
- (thanks moysevichØgmail*com)
- * Bugfix: FLV GETID3_FLV_TAG_META parsed incorrectly
- (thanks moysevichØgmail*com)
- * Bugfix: Quicktime: 'tkhd' matrix_v and matrix_d were switched
- (thanks rjjmoroØhotmail*com)
- * Bugfix: Quicktime: frame_rate was often incorrect for MP4 video
- * Bugfix: getid3_lib::CastAsInt returned -2147483648 when passed
- 2147483648 (0x80000000)
-
-
-1.7.8b2: [2007-10-15] James Heinrich, Allan Hansen
- * Video bitrate now calculated even if not explicitly stated in
- file metadata, but if overall and audio bitrates are known
- * Bugfix: 'comments_html' missing last letter in id3v2 tags.
- * Bugfix: module objects (e.g. getid3_riff) that are instantiated
- in other modules are explicitly disposed once no longer needed.
- * Bugfix: some AVI files were not returning audio information
- because "strh" chunk was not being read in
- * Bugfix: asf [audio][<streamnumber>][dataformat] should be set
- to "wma" but wasn't
- * Bugfix: [mpeg][audio][bitrate_mode] should always be one of
- ("cbr", "vbr", "abr") but wasn't for some values in
- LAMEvbrMethodLookup()
- * Bugfix: MP3 audio in AVI files could show "cbr" instead of
- correct audio bitrate_mode, and audio bitrate could be slightly
- incorrect if multiple files were scanned in a loop (scanning
- single files produced correct values).
- * Bugfix: remove [audio/video][bitrate] key if falsely set to zero
- * Bugfix: PlaytimeString returned non-matching value for negative
- playtimes (which shouldn't happen either, but now they're at
- least shown correctly, if they happen due to other bugs)
- * Bugfix: Several ASF header values are invalid if the broadcast
- flag is set, getID3() now calculates these values in other
- ways if the broadcast flag is set (thanks fletchØpobox*com)
- * Bugfix: lyrics3-flags-lyrics field was always false, and there
- never was a lyrics3-flags-timestamp field present even though
- the lyrics3-raw-IND field consisted of "10" (lyrics present,
- timestamp not present). (thanks i*f*schulzØweb*de)
- * Bugfix: TAR.GZ files produce PHP errors when
- option_gzip_parse_contents == true in module.archive.gzip.php
- (thanks alan*harderØsun*com)
-
-
-1.7.8b1: [2007-01-08] Allan Hansen
- » Major update to readme.txt
- » PHP 4.2.0 required
- » Tagwriter requires metaflac 1.1.1+ in order to write FLAC tags.
- » Removed broken and non-fixable tagwriting module for real format.
- ! Developers please help fix the above module:
- http://www.getid3.org/phpBB2/viewtopic.php?t=677
- » Avoided security issues with demo.browse.php, demo.write.php and
- demo.mysql.php. These demos are now disabled by default and has
- to be enabled in the source.
- * Bugfix: id3v2 genre broken since 1.7.7.
- » Added DTS module (module.audio.dts.php)
- ¤ ASF/WMV files now return largest video stream dimensions in
- [video][resolution_x] and [video][resolution_y]
- * Bugfix: Minor issues with midi module (avoid PHP_NOTICE).
- * Bugfix: Minor issues with lyrics3 (avoid PHP_NOTICE).
- * Bugfix: PHP_NOTICE issues in MultiByteCharString2HTML()
- * Bugfix: PHP_NOTICE issue in BigEndian2Float()
- * Bugfix: fread() zero bytes issue in real module.
- * Bugfix: ASF module returned mime type video/x-ms-wma instead of
- video/x-ms-wmv for certain FourCCs.
- * Bugfix: PHP_NOTICE issues with broken ID3v2 tag/garbage.
- * Bugfix: PNG module broken in regards to gIFg and gIFx chunks.
- » Removed detection of short filenames 8dot3 under windows, as
- it only worked for English versions of windows and has other
- problems.
- * Bugfix: Some CBR MP3 files detected as VBR with plenty of warnings.
- * Bugfix: PHP_NOTICE issues in MP3 module.
- * Bugfix: Quicktime returned incorrect frame rate.
- * Bugfix: DivByZero on zero length FLV files.
- * Bugfix: PHP_NOTICE one some FLV files.
- * Bugfix: ID3v2 UTF-8/16 encoded frames terminated by \x00
- * Bugfix: ID3v2 LINK frames iconv error.
- * Bugfix: ID3v2 padding length calculated incorrectly.
- * Bugfix: ID3v2.3 extended headers non-conformance
- » SVG file detection.
- » Added SVG user module (user_modules/module.graphic.svg.php).
- Thanks to Roan Horning.
- » PAR2 file detection (no parsing)
- * Bugfix: Wave files being detected as MP3.
- * Bugfix: ASF padding offset bug.
- * Bugfix: Shorten module not working for wav files with fmt
- chunks <> 16 bytes.
- ¤ RIFF: Zero sized chunk invokes warning instead of error.
- ¤ FLAC: Removed some ['raw'] keys.
- ¤ MPC: Mime type returned: audio/x-musepack
-
-1.7.7: [2006-06-25] Allan Hansen
- * Bugfix: AAC static bitrate cache wrong result when parsing
- several files.
- * Bugfix: Do not return NULL video bitrate for ASF v3.
- * Bugfix: getid3_lib::GetImageSize() broken => JPG module broken.
- * Bugfix: Encoder options should now be returned with correct
- "--alt-preset n" / "--alt-preset cbr n" when scanning more files.
- * Bugfix: Shorten module not escapeshellarg() filenames (UNIX only).
- * Bugfix: Filenames not escapeshellarg() for md5_data and
- sha1_data (UNIX only).
- * Bugfix: UNIX: head and tail called with -cNNN instead of "-c NNN".
- » Added detection support for PDF and MS Office documents
- (*.doc, *.xls, *.pps, etc) (thanks zeromassmediaØgmail*com)
- ¤ Bugfix: ID3v2 "TDRC" frame now used as "year" in comments if TYER
- unavailable (TYER is deprecated in ID3v2.4)
- (thanks matthiasØpanczyk*org)
- ¤ Removed GETID3_OS_DIRSLASH, replaced with DIRECTORY_SEPARATOR
- * Bugfix: added LAME preset guessing for presets 410,420,440,490
- (thanks adminØlogbud*com)
- * Bugfix: Added escapeshellarg() call in getid3_lib::hash_data
- (thanks towbØgmx*net)
- » TAR module no longer reads entire file into memory
- » FLV module no longer reads entire file into memory
- * Bugfix: added LAME preset guessing for presets 410,420,440,490
- (thanks adminØlogbud*com)
- * Bugfix: Added escapeshellarg() call in getid3_lib::hash_data
- (thanks towbØgmx*net)
- * Bugfix: Error message when padding in FLAC files were used up.
- * Bugfix: Shorten module not working under windows.
- ¤ Bugfix: gmmktime() instead of mktime().
- ¤ Using gmmktime() instead of mktime() in ISO, ZIP, PNG and RIFF
- modules to avoid E_STRICT notices with PHP5.1+.
- * Bugfix: ['comments_html'] and ['comments'] contains different
- value when having multiple tags (one of them ID3v1) and the
- long field names.
-
-1.7.6: [2006-03-12] James Heinrich
- * Rewrote getid3_lib::GetDataImageSize() to use GetImageSize()
- instead of using code by filØrezox*com
- * Bugfix: incorrect dimensions from disabled Quicktime tracks
- (thanks m-1Øgmx*net)
- * Bugfix: ['codec'] key warning in module.audio-video.asf.php
- (thanks niel*archerØblueyonder*co*uk)
- * Bugfix: undefined array in write.php
- (thanks drewishØkatherinehouse*com)
- * Bugfix: DeleteAPEtag() incorrectly failing when no tag present
- (thanks drewishØkatherinehouse*com)
- * Bugfix: ID3v2 writing frames with URL fields failing when URL
- is not in ISO-8859-1 (thanks drewishØkatherinehouse*com)
- * Bugfix: PHP notices on bad ID3v2 frames
- (thanks cw264701Øohiou*edu)
- * Bugfix: audio & video bitrates sometimes wrong in ASF files
- (thanks kris_kauperØexcite*com)
-
-1.7.5: [2005-12-29] James Heinrich
- » Added FLV (FLash Video) support -- new file:
- module.audio-video.flv.php
- (thanks Seth Kaufman <seth@whirl-i-gig.com> for code)
- » Real tags can now be written (previous Real tag writing
- code was not supposed to be in public releases, as it
- was not complete)
- » GETID3_HELPERAPPSDIR now autodetected under Windows
- ¤ ASF lyrics now returned under [comments][lyrics]
- * Bugfix: removed "--lowpass xxxxx" info from guessed
- LAME presets when source frequency <= 32kHz
- * Bugfix: ID3v2 extended header errors
- * Bugfix: missing ob_end_clean() in write.id3v2.php
- (thanks rasherØgmail*com)
-
-1.7.4: [2005-05-04] James Heinrich
- ¤ Added ['quicktime']['hinting'] key (boolean)
- (thanks jonØwebignition*net)
- * Bugfix: major UTF-8 to UTF-16/ISO-8859-1 conversion
- bug (empty string returned) when using iconv_fallback
- (thanks chrisØfmgp*com)
- * Bugfix: Missing 'lossless' key in RIFF-WAV
- (thanks bobbfwedØcomcast*net)
-
-1.7.3: [2005-04-22] James Heinrich
- » Added TAR support -- new file: module.archive.tar.php
- (thanks Mike Mozolin <teddybearØmail*ru> for code!)
- » Added GZIP support -- new file: module.archive.gzip.php
- (thanks Mike Mozolin <teddybearØmail*ru> for code!)
- * Bugfix: demo.browse.php now displays embedded images
- internally instead of passing local filename as IMG
- SRC (should allow demo.browse.php to correctly show
- embedded images over a network)
- (thanks patpowermanØhotmail*com)
- * Bugfix: minor UTF-8 display issues in demo.browse.php
- * Bugfix: demo.browse.php now works even if the evil
- setting magic_quotes_gpc is turned on
- (thanks patpowermanØhotmail*com)
- * Bugfix: incorrect MIDI playtime for some files
- (thanks joelØoneporpoise*com)
- * Bugfix: 'url_source' typo in module.tag.id3v2.php
- (thanks richardlynchØusers*sourceforge*net)
- * Bugfix: Quicktime 'mvhd' matrix values were wrong
- (thanks webØbobbymac*net)
- ¤ ID3v2 now returns xx/yy for ['track'] (if
- available), with xx in ['tracknum'] and yy in
- ['totaltracks']. Previously ['tracknum'] was not
- available and ['track'] had only xx.
- Bugfixes and improvements to /demo/demo.mysql.php:
- - remix/version parsed from tags and stored in
- database, can be used when renaming files
- - track number can be used for renaming files
-
-
-1.7.2: [2004-10-18] Allan Hansen
- » Added support for WavPack v4.0+
- (thanks ahØartemis*dk)
- » Removed code for parsing EXE files
- (thanks ahØartemis*dk)
- Removed file: module.misc.exe.php
- * Bugfix: Large ID3v2 tags inside ASF not parsed
- properly under PHP5.
- * Bugfix: Certain Wavpack3 files failed under PHP5 due
- to new undocumented tmpfile() limit (same problem as
- above).
- * Bugfix: New iTunes crashes PHP - temp fix - no tags
- on those files.
- * Bugfix: ['nsv']['NSVs']['framerate_index'] might be
- wrong (thanks ahØartemis*dk)
- * Bugfix: transparent color was wrong from truecolor
- PNG (thanks ahØartemis*dk)
- * Bugfix: Changed MPC SV7 header size from 30 to 28,
- this will change hash values for MPC files
- (thanks ahØartemis*dk)
- * Bugfix: Changed MPC SV4-6 header size from 28 to 8,
- this will change hash values for MPC files
- (thanks ahØartemis*dk)
- ¤ Trim/unset wavpack encoder_options to match 2.0.0b2
- output.
- ¤ Commented-out unknown/unused values in NSV and ISO
- modules (thanks ahØartemis*dk)
-
-
-1.7.1b1: [July-26-2004] James Heinrich
- » Added support for Apple Lossless Audio Codec
- » Added support for RealAudio Lossless
- » Added support for TTA v3
- » Added support for TIFF
- New file: /getid3/module.graphic.tiff.php
- » Modified iconv_fallback to work with UTF-8, UTF-16, UTF-16LE,
- UTF-16BE and ISO-8859-1 even if iconv() and/or XML support is
- not available. This means that iconv() is no longer required
- for most users of getID3()
- (thanks Jeremia, khleeØbitpass*com)
- » Added support for Monkey's Audio v3.98+ (thanks ahØartemis*dk)
- » Included new demo showing most-basic getID3() usage
- New file: /demos/demo.basic.php
- * Bugfix: LAME3.94+ presets cached incorrectly if multiple files
- are scanned in one batch and first file is LAME3.93 or earlier
- (thanks enoyandØyahoo*com)
- * Bugfix: Added warning if compressed ID3v2 frame decompression
- fails. (thanks Mike Billings)
- * Bugfix: Assorted small fixes to ensure compatability with PHP5
- * Bugfix: ID3v1 genre "Blues" could not be written
- (thanks Jeremia)
- * Bugfix: ['bitrate_mode'] typo in module.audio-video.real.php
- (thanks asukakenjiØusers*sourceforge*net)
- * Bugfix: ['zip']['files'] is now populated with filenames even
- if End Of Central Directory couldn't be parsed
- * Bugfix: ['audio']['lossless'] was incorrect for FLAC
- (thanks WaldoMonster)
- * Bugfix: MD5 File was incorrect in directory browse mode for
- /demo/getid3.browse.php
- * Bugfix: PHP v5 compatability changes (float array keys, fread()
- calls with zero data length)
- (thanks getid3Øjsc*pp*ru)
- * Bugfix: was dying if on compressed ID3v2 frames if
- gzuncompress() function was unavailable
- * Bugfix: ['vqf']['COMM'] was always empty
- * Bugfix: MIDI playtime was missing for single-track MIDI files
- * Bugfix: removed &#0; characters from ['comments_html']
- (thanks p*quaedackersØplanet*nl)
- * Bugfix: improved MIDI playtime accuracy
- (thanks joelØoneporpoise*com)
- * Bugfix: BMP subtypes 4 and 5 were not being identified
- * Bugfix: frame_rate in AVI was incorrectly truncated to integer
- * Bugfix: FLAC cuesheet track index was incorrect
- (thanks tetsuo*yokozukaØoperamail*com)
- ¤ ['quicktime']['display_scale'] now contains the playback scale
- multiplier for QuickTime movies - a movie set to playback at
- double-size will have "2" here. Other values are "1" and "0.5"
- ¤ Added LAME preset guessing for --preset medium with v3.90.3
- (thanks phwipØfish*co*uk)
- ¤ Added $encoding_id3v1 to allow for ID3v1 encodings other than
- the standard ISO-8859-1
- ¤ Default AVI video bitrate_mode is now 'vbr'
- (thanks eltoderØpisem*net)
- Force getID3() to abort if Shorten files have ID3 or APE tags
- (thanks ahØartemis*dk)
- Editable textbox for parent directory in demo.browse.php
- (thanks eltoderØpisem*net)
-
-
-1.7.0-hotfix [2004-03-17] Allan Hansen
- (hotfix version released by Allan Hansen)
- * Bugfix: PHP 4.1.x compatiblity - fgets($fp) => fgets($fp, 1024)
- * Bugfix: Added default charset to TextEncodingNameLookup() in
- module.tag.id3v2.php
- Ø Removed option_no_iconv
- iconv() support is only a requirement for WMA/WMW/ASF, and for
- destination encodings other than ISO-8859-1 and UTF-8, iconv is
- not needed otherwise. New 'iconv_req' in GetFileFormatArray()
- only set for WMA/WMV/ASF. analyze() now refuses to analyse
- WMA/ASF file if iconv is not present.
- iconv_fallback() only dies on internal errors not missing iconv()
-
-
-1.7.0: [January-19-2004] James Heinrich
- » Added support for RIFF/CDXA files (MPEG video in RIFF container
- format (thanks chrisØdigitekdesign*com)
- » Added support for TTA v2 (thanks ahØartemis*dk)
- ¤ ID3v2 unsynchronisation scheme disabled by default because most
- tag-reading programs cannot read unsynchronised tags. Can be
- overridden by setting id3v2_use_unsynchronisation to true.
- (thanks mikeØdelusion*org)
- ¤ extention.*.php renamed to extension.*.php
- (thanks tp62Øcornell*edu)
- ¤ /demo/demo.check.php renamed to /demo/demo.browse.php
- ¤ Added id3v2_paddedlength configuration parameter to WriteTags()
- and renamed tag_language to id3v2_tag_language
- ¤ MPEG audio layers are now represented as 1, 2 or 3 instead of
- 'I', 'II', or 'III'
- ¤ Added [audio][wformattag] and [video][fourcc] for WAV and AVI
- ¤ Added [audio][streams] which contains one entry for each audio
- stream present in the file (usually only one). The data is a
- copy of what is usually found in [audio]. If there are multiple
- audio streams then [audio] will contain a sum of the bitrates
- of all audio streams, and the data format of the first stream
- (if streams are of different data types)
- ¤ Added BruteForce mode to mp3 scanning. Disabled by default as
- it is extremely slow and only files that are broken enough to
- not really play will gain any benefit from this.
- ¤ Suppress '--resample xxxxx' appended to encoder options for mp3
- with low-quality presets for default sampling frequencies
- ¤ Enhanced LAME preset guessing for pre-3.93 with a better lookup
- table, --resample/--lowpass guessing (thanks phwipØfish*co*uk)
- ¤ RIFF files with non-MP3 contents no longer have
- [audio][encoder_options] set
- ¤ Added [audio][encoder_options] to audio formats where possible
- (including LiteWave, LPAC, OptimFROG, TTA)
- ¤ Moved [quantization] and [max_prediction_order] from
- [lpac][flags] to just [lpac]
- ¤ WavPack flags are now parsed into [wavpack][flags]
- * Bugfix: APEtags with ReplayGain information stored with comma-
- seperated decimal values (ie "0,95" instead of "0.95") were
- giving wrong peak and gain values
- * Bugfix: Filesize > 2GB not always detected correctly
- * Bugfix: Some ID3v2 frames had data key unset incorrectly
- (thanks chrisØdigitekdesign*com)
- * Bugfix: Warnings on empty-strings-only comments
- * Bugfix: ID3v2 tag writing may have had incorrect padding length
- if padded length less than current ID3v2 tag length and
- merge_existing_data is false (thanks mikeØdelusion*org)
- * Bugfix: hash_data() for SHA1 was broken under Windows
- * Bugfix: BigEndian2Float()/LittleEndian2Float() were broken
- * Bugfix: LAME header calculated track peaks were incorrect for
- LAME3.94a15 and earlier
- * Bugfix: AVIs with VBR MP3 audio data reported incorrect bitrate
- and bitrate_mode
- * Bugfix: AVIs sometimes had incorrect or missing video and total
- bitrates
- * Bugifx: AVIs sometimes had incorrect ['avdataend'] and
- therefore also incorrect data hashes (md5_data, sha1_data)
- * Bugfix: ID3v1 genreid no longer returned for Unknown genre
- * Bugfix: ID3v1 SCMPX genres were broken
- Modified LAME header parsing to correctly process peak track
- value for LAME3.94a16+ (thanks Gabriel)
- md5_file() and sha1_file() now work under Windows in PHP < 4.2.0
- and 4.3.0 respectively with helper apps
- Default md5_data() tempfile location is now system temp directory
- instead of same directory as file (thanks towbØtiscali*de)
- Improved list of RIFF ['INFO'] comment key translations
- More helpful error message when GETID3_HELPERAPPSDIR has spaces
- /demo/demo.browse.php now autogets both MD5 and SHA1 hashes for
- files < 50MB
- Replaced PHP_OS comparisons with GETID3_OS_ISWINDOWS define
- (thanks necroticØusers*sourceforge*net)
-
-
-1.7.0b5: [December-29-2003] James Heinrich
- » Windows only: Various binary files are now required for some
- file formats, especially for tag writing, as well as md5sum
- (and other) calculations. These binaries are now stored in the
- directory defined as GETID3_HELPERAPPSDIR in getid3.php
- (default is /helperapps/ parallel to /getid3/).
- Note: This directory must not have any spaces in the pathname.
- All neccesary files are available as a seperate download.
- See /helperapps/readme.txt for more information
- New file: /helperapps/readme.txt
- » Unified tag-writing interface for all tag formats
- New file: /getid3/write.php
- /getid3/write.apetag.php
- /getid3/write.id3v1.php
- /getid3/write.id3v2.php
- /getid3/write.lyrics3.php
- /getid3/write.metaflac.php
- /getid3/write.vorbiscomment.php
- » Added support for Shorten - requires shorten binary (head.exe
- is also required under Windows).
- New file: /getid3/module.audio.shorten.php
- » Added support for RKAU
- New file: /getid3/module.audio.rkau.php
- » Added (minimal) support for SZIP
- New file: /getid3/module.archive.szip.php
- » Added MySQL caching extention (thanks ahØartemis*dk)
- New file: /getid3/extention.cache.mysql.php
- » Added DBM caching extention (thanks ahØartemis*dk)
- New file: /getid3/extention.cache.dbm.php
- » Added sha1_data hash option (thanks ahØartemis*dk)
- » Added option to allow getID3() to skip ID3v2 without parsing it
- for faster scanning when ID3v2 data is not required. If you
- want to enable this feature delete /getid3/module.tag.id3v2.php
- (thanks ahØartemis*dk)
- ¤ 8-bit WAV data now calculates MD5 checksums as normal, not
- converting to signed data as before, so stored md5_data_source
- in FLAC files will no longer match md5_data for the equivalent
- decoded 8-bit WAV. A warning will be generated for 8-bit FLAC
- files
- ¤ Added option_no_iconv option to allow getID3() to work
- partially without iconv() support enabled in PHP
- (thanks ahØartemis*dk)
- ¤ All '*_ascii' keys removed for ASF/WMA/WMV files
- ¤ All 'ascii*' keys removed for ID3v2 tags
- ¤ Ogg filetypes now return MIME of "application/ogg" instead of
- the previous "application/x-ogg"
- (thanks blakewattersØusers*sourceforge*net)
- ¤ Force contents of ['id3v2']['comments'] to UTF-8 format from
- whatever encoding each frame may have (text encoding can vary
- from frame to frame in ID3v2)
- ¤ MP3Gain information from APE tags suppressed from ['tags'] and
- parsed into ['replay_gain']
- ¤ ReplayGain information (all formats) changed from "Radio" and
- "Audiophile" to "Track" and "Album" respectively
- ¤ ['volume'] and ['max_noclip_gain'] are now available in both
- ['replay_gain']['track'] and ['replay_gain']['album'] for all
- formats that calculate ReplayGain.
- ¤ ['video']['total_frames'] is available for AVIs
- ¤ All parsed ID3v2 frame data is now in ['id3v2'][XXXX][#]
- (previously some frame types would have numeric array keys if
- multiple instances of that frame type were allowed and other
- frame types would not)
- ¤ ASF/WMA "WM/Picture" images are now parsed in the same manner
- as ID3v2 with the image (ex JPEG) data returned in [data]
- rather than [value]
- * Bugfix: Optional tag processing options were being ignored (ie
- ID3v1 still processed even if option_tag_id3v1 == false)
- (thanks ahØartemis*dk)
- * Bugfix: fixed MultiByteCharString2HTML() for UTF-8
- * Bugfix: Quicktime files not always reporting video frame_rate
- * Bugfix: False ID3v1 synch patterns in APE or Lyrics3 tags are
- now detected and incorrect ID3v1 data not returned
- (thanks sebastian_maresØusers*sourceforge*net for the idea)
- * Bugfix: WMA9 Lossless now reported as lossless
- * Bugfix: two typos in ID3v1 genre list
- * Bugfix: MPEG-2/2.5 ABR/VBR MP3 files had doubled playtime
- * Bugfix: MPEG-2/2.5 LayerII (ie MP2: 24/22.05/16kHz) files were
- not detected due to incorrect frame length calculation
- * Bugfix: MPEG LayerI files were not detected due to incorrect
- frame length calculation (must be multiple of slot length)
- Added alternative md5_data via system call - twice as fast. Needs
- "getID3()-WindowsSupport" to work under Windows.
- (thanks ahØartemis*dk)
- ID3v2.4 compressed frames are now supported
- php_uname() calls changed to use PHP_OS constant
- Added SCMPX extensions to ID3v1 genres (0xF0-0xFE)
- Obfuscated contributor email address in changelog and sourcecode
- Added memory-saving EmbeddedLookup() function for lookup tables
- in RIFF and ID3v2 modules (thanks ahØartemis*dk)
- Major memory patches to many modules by using
- $var = &$INFO_ARRAY_AT_SOME_INDEX
- in place of large multi-dimensional array declarations.
- Memory saved: RIFF: ~200kB; ID3v2: ~475kB; ASF: ~50kB etc.
- (thanks ahØartemis*dk)
-
-
-1.7.0b4: [November-19-2003] James Heinrich
- » Support added for MPC files with old SV4-SV6 structure
- » RealVideo now properly supported with resolution, framerate, etc
- (thanks jcsston)
- » RealAudio files with old-style file format (v2-v4) are now
- fully supported
- » Support added for DolbyDigital WAV files (thanks ahØartemis*dk)
- ¤ ['RIFF'] is now ['riff'] to conform to make all root key names
- lowercase
- ¤ ['OFR'] is now ['ofr'] to conform to make all root key names
- lowercase
- ¤ ['tags_html'] is now available as a copy of ['tags'] but
- with all text replaced with an HTML version of all characters
- above chr(127), translated according to whatever the encoding
- of the source tag is, in the HTML form &#1234;
- ¤ CopyTagsToComments() is now available in getid3_lib
- ¤ QuicktimeVR files now return a ['video']['dataformat'] of
- 'quicktimevr' instead of 'quicktime' (thanks gtsØtsu*biz)
- ¤ Quicktime video files with DivX, Xvid, 3ivx or MPEG4 video
- streams now return those names as ['video']['dataformat']
- ¤ MPEG video files are now identified with ['video']['codec'] set
- to either 'MPEG-1' or 'MPEG-2' (rather than just 'MPEG'). If you
- see a file wrongly identified, please report it!
- (thanks fccHandler)
- ¤ All bitrate values in ['mpeg']['audio'] is now reported in bps
- rather than kbps (ie 128000 instead of 128) for consistancy
- ¤ AVIs with MP2 audio now report ['audio']['dataformat'] as 'mp2'
- rather than 'wav' (thanks metalbrainØnetian*com)
- ¤ Added ['md5_data_source'] for OptimFROG
- ¤ AC3 in RIFF-WAV now identified with ['audio']['dataformat']
- returning 'ac3'
- ¤ WavPack ['extra_bc'] now returned as integer
- ¤ WavPack ['extras'] now returned as 3-element array of integers
- ¤ MP3 ['audio']['encoder options'] now returns 'VBR' or 'CBR' only
- (no bitrate) if no LAME preset is used, or 'VBR q??' where ?? is
- a number 0-100 for Fraunhofer-encoded VBR MP3s
- * Bugfix: VBR MP3s could have incorrect bitrate reported
- * Bugfix: Quicktime files with MP4 audio were not returning
- ['video']['dataformat'] (thanks robØmassive-interactive*nl)
- * Bugfix: strpad vs str_pad typo in module.riff.php
- (thanks nicojunØusers*sourceforge*net)
- * Bugfix: ReplayGain information was often wrong for MPC files
- * Bugfix: MD5 and other post-TAIL chunks were not being processed
- in module.audio.optimfrog.php
- * Bugfix: Undefined variable in table_var_dump() in demo/check.php
- * Bugfix: QuickTime files now only return information in [audio]
- or [video] if those exist in the file
- * Bugfix: WavPack no longer tries to read entire compressed data
- chunk
- * Bugfix: Properly handle VBR MP3s with "Info" (rather than
- "Xing") header frame. foobar2000 adds this to MP3 files when
- "Fix MP3 Header" function is used (thanks ahØartemis*dk)
- * Bugfix: Fraunhofer VBRI headers for MP3s were assuming 2-byte
- entries for TOC rather than using stride, and were ignoring the
- scaling value. (thanks sebastianØmaresweb*net)
- Several QuickTime atoms have been added to an exclusion list
- because they have been observed, but I have no idea what they
- are supposed to do so I can't add real support for them, but
- they should not generate warnings (robØmassive-interactive*nl)
- Old MPC encoder (before v1.06) was return as v0.00, now returned
- as 'Buschmann v1.7.0-v1.7.9 or Klemm v0.90-v1.05'
- (thanks ahØartemis*dk)
- Added check for magic_quotes_runtime and code to disable it if
- neccesary (thanks stefan*kischkelØt-online*de)
- Added 3ivx fourCCs to module.audio-video.quicktime.php
- MP3 and AC3 streams are now parsed when contained inside RIFF-WAV
- or RIFF-AVI container formats
- Better detection of named presets in LAME 3.93/3.94
-
-
-1.7.0b3: [October-17-2003] James Heinrich
- » AC-3 (aka Dolby Digital) is now supported.
- New file: /getid3/module.audio.ac3.php
- * Bugfix: ID3v2-writing function Unsynchronise() was broken, which
- made ID3v2 tag containing binary data (typically pictures) get
- corrupted. (thanks t*coombesØbendigo*vic*gov*au,
- i*kuehlbornØndh*net, mikeØdelusion*org, mikeØftl*com)
- * Bugfix: Zip comments now returned as array instead of string,
- as they're supposed to be.
- * Bugfix: Quicktime/MP4 files may have reported extremely low
- bitrates (thanks spunkØdasspunk*com)
- Improved double-ID3v1 check to prevent false detection when string
- "TAG" is present in APE or Lyrics3
- Fixed /demo/simple.php
- Fixed /demo/joinmp3.php
- Fixed /demo/mimeonly.php
- Fixed /demo/write.php
-
-
-1.7.0b2: [October-15-2003] James Heinrich
- » TTA Lossless Audio Compressor format now supported.
- (http://tta.iszf.irk.ru)
- New file: /getid3/module.graphic.tta.php
- » PhotoCD (PCD) format now supported. Image data for the three
- lowest resolutions (192x128, 384x256, 768x512) can be optionally
- extracted.
- New file: /getid3/module.graphic.pcd.php
- ¤ RIFF-MP3 files now should return the same ['md5_data'] as the
- identical MP3 file outside the RIFF container
- ¤ Name of LAME preset used (if available, needs LAME v3.90+)
- returned in ['mpeg']['audio']['LAME']['preset_used'] and also as
- part of ['audio']['encoder_options']
- ¤ VQF module now sets ['audio']['encoder_options'] to i.e. CBR96
- ¤ MP3 module now sets ['audio']['encoder_options'] on CBR files
- and all LAME-encoded files
- ¤ MPC module now sets ['audio']['encoder_options']
- ¤ Monkey module now sets ['audio']['encoder_options']
- ¤ AAC module now sets ['audio']['encoder_options'] to profile name
- ¤ ASF module now sets ['audio']['encoder_options']
- ¤ Ogg module adds ['audio']['encoder_options'] -b 128 on
- Ogg Vorbis 1.0+ ABR files
- ¤ Ogg module adds ['audio']['encoder_options'] -q N on
- Ogg Vorbis 1.0+ VBR files 44k/48k sample rate/stereo files only.
- ¤ Ogg module ['audio']['encoder_options'] "Nominal birate: 80k" to
- other Ogg Vorbis files.
- ¤ ID3v2 track number now returned as string (with leading zeros,
- if present in data) rather than integer (thanks Plamen)
- ¤ ASF module returns ['asf']['comments']['encoding_time_unix'] if
- available (from WM/EncodingTime)
- ¤ Fixed /demo/mysql.php and added some new features:
- - encoder options
- - ID3v2 "Encoded By"
- - non-empty comments
- - total entries in database summary (totals & averages)
- - database version update
- * Bugfix: 'UNICODE' iconv() charset changed to 'UTF-16LE' or
- 'UTF-16BE' as appropriate
- * Bugfix: iconv_fallback() function created in case iconv() fails
- * Bugfix: fixed MD5 calls in demo/check.php
- * Bugfix: reenabled detection of APE + Lyrics3 tags in same file
- * Bugfix: ASF module now returns ID3v1 genre as string instead of
- number - patch from Eugene Toder.
- * Bugfix: ASF module now reads non-standard field names,
- i.e. "date" as well as WM/Year - patch from Eugene Toder.
- * Bugfix: ASF module now returns genre as-is if it is not a
- standard ID3v1 genre (thanks wonderboy)
- * Bugfix: Eliminated false-synch problem in MP3 module
- * Bugfix: Fixed missing root ['bitrate'] for most formats
- * Bugfix: ['audio']['compression_ration'] missing for MPC
- (thanks WaldoMonster)
- * Bugfix: NSV module died in 1.7.0b1
- * Bugfix: ASF module died in 1.7.0b1 when WM/Picture preset
- * Bugfix: ASF tracknumber incorrect when specified by WM/Track
- rather than WM/TrackNumber (thanks jgriffiniiiØhotmail*com)
- * Bugfix: MPEG audio+video playtime should now be pretty accurate
- (ie within 0.1% variation at most)
- (thanks mgrimmØhealthtvchannel*org)
- * Bugfix: ID3v2 not being copied to ['tags'] in some cases
- * Bugfix: LAME CBR files with Info tag were being incorrectly
- flagged as VBR (thanks Jojo)
- * Bugfix: LAME tag not being detected for LAME 3.90 (original)
- Changed regex pattern match for MP3 to include 3rd byte for more
- reliable/accurate pattern matching
- Added duplicate-ID3v1 tag checking (two ID3v1 tags, one after the
- other) that has been known to occur with iTunes
- (thanks towbØtiscali*de)
- Added instructions for enabling iconv() support under Windows
- Removed some unneccesary debugging code
- Suppressed duplicate PHP warnings for missing include files
- Included some missing dependencies in various files
- /demo/audioinfo.class.php now copies ['audio']['encoder_options']
-
-
-1.7.0b1: [2003-09-28] Allan Hansen
- This beta version was not made by James Heinrich. It was made by
- Allan Hansen <ahØartemis*dk> - please send bug reports on this
- beta directly to me.
-
- James Heinrich will release 1.7.0 final, but it may take some time
- to work out the bugs from the major rewrite.
-
- This version could be called getID3lite. It makes a lot of checks
- optional and makes it easy to remove support for undesired formats
-
- It also is more library-like. Older versions of getID3() declared
- an incredible amount of global scope functions and defined several
- constants. 1.7.0beta1 still declares constants, but they are all
- prepended by GETID3_. It declares no global scope functions - they
- are all wrapped into classes.
-
- » Made getID3() depend on iconv library: compile PHP --with-iconv
- » Created new directory structure
- Moved all demos to demos/
- Moved all getID3() files to getid3/
- Renamed most files to module.something
- Changed header in all module.something to explain what they do
- Simply remove all modules you don't need
- Wrapped all modules into classes
- * Bugfix: Implemented misc patches from Eugene Toder
- * Bugfix: Implemented misc patches from "six"
- ¤ Added root key 'encoding'
- ¤ Added prefix GETID3_ to all defined constants.
- ¤ Wrapped getid3.php into getid3 class
- ¤ Wrapped getid3.functions.php into getid3_lib class
- Removed unused functions
- Moved several functions away from getid3.functions.php and
- into the files where they are actually used.
- Renamed getid3.functions.php to getid3.lib.php
- Moved getid3.rgad.php functions into getid3_lib
- Moved getid3.getimagesize.php funcitons ingo getid3_lib
- ¤ Moved getid3.ogginfo.php into ogg module
- ¤ Combined GetTagOnly() and GetAllFileInfo() in method analyze
- ¤ Removed redundant and unuseful root keys
- 'file_modified_time' == filemtime($filename)
- 'md5_file' == md5_file($filename)
- 'exist' == file_exists($filename)
- ¤ Changed root key ['tags'] from array of string to array of array
- of comments.
- Simplified code for detecting base path.
- Removed ob_ from InitializeFilepointerArray(). That was really a
- ugly HACK to get output from fopen. If user want the reason,
- he should open the file himself!
- Checking for APE tags before lyrics3 - makes Lyrics3 not depend
- on APE tag. It seems to work on my test file.
- Changed ['error'] and ['warning'] in multiple files to append to
- array instead of appending to string. That simplified code in
- getid3.php too.
- Simplified clean-up procedure: simply remove all empty root keys
- Setting tags in individual modules instead of main getid3.php
- Made Bonk and ASF modules non-dependent on id3 modules - id3
- optional.
- Rewrote HandleAllTags() - simplified and convert comments to
- desired encoding.
- Replaced all calls to RoughTranslateUnicodeToASCII() in ASF module
- with a TrimConvert() method. This uses iconv() for conversion.
- It also converts from UNICODE instead of UTF-16BE, as the spec
- says it should.
- Replaced all calls to RoughTranslateUnicodeToASCII() in id3v2
- module with iconv(). id3v2 module also reads
- $ThisFileInfo['encoding'] and converts all comments to this
- format. All other formats just add their comments in their
- native charset, but every comment field in id3v2 can have a
- different encoding, so this is needed.
- Did same thing as above with ISO module. However - it does not
- work. I need to find out how to specify big-endian unicode !=
- UNICODING encoding name given to iconv().
- Built-in assume mp3 format in getid3.php
- Temporarily nuked root key ['comments'] and CopyCommentsToRoot()
- Updated demo/audioinfo.class.php
- Updated demo/check.php - some thing don't work!
- Other demos are out of order!
-
-
-1.6.5: [October-06-2003] James Heinrich
- » Added support for LiteWave (thanks supportØclearjump*com)
- Ø Split out speedup info from ['OFR']['OFR']['compression'] into
- ['OFR']['OFR']['speedup']
- Ø If EXIF functions for JPEG not available, now warning not error
- Ø ID3v2 track number now returned as string (with leading zeros,
- if present in data) rather than integer (thanks Plamen)
- * Bugfix: now correctly parses cbSize element of WAVEFORMATEX
- structure (thanks supportØclearjump*com)
- * Bugfix: ASF module now reads non-standard field names,
- i.e. "date" as well as WM/Year - patch from Eugene Toder.
- * Bugfix: ASF module now returns genre as-is if it is not a
- standard ID3v1 genre (thanks wonderboy)
- * Bugfix: ['audio']['compression_ration'] missing for MPC
- (thanks WaldoMonster)
- Prevent infinite loop in MP3 histogram if framelength == 0
- Added wFormatTag values 0x00FF and 0x2001 - 0x2005
- (thanks steveØheadbands*com)
- Added "twos" and "sowt" FourCCs for Mac AIFC
-
-
-1.6.4: [June-30-2003] James Heinrich
- » Added support for free-format MP3s
- (thanks Sebastian Mares for the idea)
- » Compressed (Flash 6+) SWF files are now handled properly
- (thanks alan*cheungØalumni*ust*hk)
- » Added DeleteLyrics3() to getid3.lyrics3.php
- » Added FixID3v1Padding() to getid3.putid3.php
- » Added new simple MP3-splicing sample file
- (thanks tommybobØmailandnews*com for the idea)
- New file: getid3.demo.joinmp3.php
- » Moved all contents of getid3.putid3.php into either
- getid3.id3v1.php or getid3.id3v2.php or getid3.functions.php as
- appropriate
- Removed file: getid3.putid3.php
- ¤ ['error'] and ['warning'] keys now return as arrays, not strings
- ¤ New root key for all files: ['file_modified_time'] (UNIX time)
- ¤ getid3.demo.scandir.php renamed to getid3.demo.mysql.php
- ¤ New demo file returns the MIME type only for a single file
- (thanks adminØe-tones*co*uk for the idea)
- New file: getid3.demo.mimeonly.php
- ¤ Added check for valid ID3v1 padding (strings should be padded
- with null characters but some taggers incorrectly use spaces).
- A warning will be generated if padding is invalid. New boolean
- key ['id3v1']['padding_valid'] indicates padding validity.
- ¤ CleanUpGetAllMP3info() removes more useless root keys for
- unknown-format files
- ¤ Extended LAME information in ['mpeg']['audio']['LAME'] is now
- only returned for LAME v3.90+
- ¤ LAME-encoded MP3s now return
- ['mpeg']['audio']['LAME']['long_version'] as well as
- ['mpeg']['audio']['LAME']['short_version'] - these are identical
- in LAME v3.90+ but older versions will report longer more
- detailed version information if available
- ¤ New Lyrics3 values: ['lyrics3']['raw']['offset_start'] and
- ['lyrics3']['raw']['offset_end']
- ¤ New optional parameter on getAPEtagFilepointer() to scan from a
- defined offset rather than end-of-file to allow scanning of APE
- tags before Lyrics3 tags
- ¤ ['tag_offset_start'] and ['tag_offset_end'] are now present in
- ['ape'], ['lyrics3'], ['id3v1'] and ['id3v2']
- ¤ Numerous changes to the returned structure and content for La
- files, including parsing the seektable (if applicable) and
- parsing RIFF data occuring after the end of the compressed audio
- data (notably RIFF comments)
- (thanks mikeØbevin*de)
- ¤ getSWFHeaderFilepointer() now has optional 3rd parameter
- $ReturnAllTagData (default == false) which if set to true will
- return data on all tags in ['swf']['tags']
- ¤ ['swf']['bgcolor'] now returns the 6-character string
- representing the background color in HTML hex color format
- (thanks ubergeekØubergeek*tv)
- ¤ ['swf']['header']['frame_delay'] is no longer returned
- ¤ getQuicktimeHeaderFilepointer() now has two additional optional
- parameters: $ReturnAtomData (default == true) and
- $ParseAllPossibleAtoms (default == false). Setting
- $ReturnAtomData to false will reduce the size of the returned
- data array by unsetting ['quicktime']['moov'] before returning.
- Leaving $ParseAllPossibleAtoms as false now suppresses parsing
- of several atom types that contain very large tables of data
- that are not typically useful. Atom type suppressed are:
- stts, stss, stsc, stsz, and stco
- (thanks ubergeekØubergeek*tv)
- ¤ ['fileformat'] no longer set to 'id3' if ID3v1 or ID3v2 tag
- detected but no other data format recognized
- * Bugfix: La files now return the correct values for
- ['avdataoffset'] and ['avdataend'] and therefore the correct
- values for ['md5_data'] - note that ['md5_data'] values will not
- match values from previous versions of getID3() - the previous
- versions were incorrect
- (thanks mikeØbevin*de)
- * Bugfix: A temporary file was being created in the web server's
- root directory (not DocumentRoot) each time ['md5_data'] was
- calculated, and not removed due to lack of permissions. Temp
- file is now created (as it was supposed to be) in the directory
- of the file being examined, or the system temp directory, and
- properly removed when done.
- * Bugfix: Several incorrect values were being returned inside
- ['mpeg']['audio']['LAME'] (thanks bouvigneØmp3-tech*org)
- * Bugfix: SWF frame rates values were usually incorrect.
- (thanks alan.cheungØalumni*ust*hk and ubergeekØubergeek*tv)
- * Bugfix: ID3v2.2 files always flagged 4 bytes of invalid padding
- (thanks marcaØmac*com)
- * Bugfix: Lyrics3 without ID3v1 was not working properly
- * Bugfix: Lyrics3, APE & ID3v1 can all now exist in the same file.
- A warning is issued if APE comes after Lyrics3 (because Lyrics3-
- aware taggers probably are not APE-aware and therefore won't be
- able to find the Lyrics3 tag) (thanks mp3gainØhotmail*com)
- * Bugfix: WriteAPEtag() now writes the APE tag before any Lyrics3
- tags (if present) and removes any incorrect ones that are after
- existing Lyrics3 tags (thanks mp3gainØhotmail*com)
- * Bugfix: RIFF-WAVE file with incorrect NumberOfSamples values in
- the 'fact' chunk no longer cause incorrect playtime calculation
- (thanks stprasadØindusnetworks*com)
- * Bugfix: getid3.demo.simple.php had undefined variables if the
- file needed to be deep-scanned with assumeFormat
- * Bugfix: fixed previously-incorrect ['avdataend'] values for APE
- and Lyrics3 tags in some cases, which in some cases means that
- ['md5_data'] is different than previously (now correct)
- Much-improved detection of AAC-ADTS, which also means MP3
- format detection should now be nearly twice as fast
- Truncated AVIs and WAVs are now reported
- Number of new features and bugfixes in getid3.demo.mysql.php
- Quicktime 'meta' atoms now parsed, so Quicktime MP4 files can now
- return artist, title, album, etc (thanks spunkØdasspunk*com)
- Consolidated all comments processing functions (processing the
- ['comments'] and ['tags'] keys) into HandleAllTags() which now
- also checks to ensure that APE tags are really better than ID3v2
- before using them in ['comments']
- Known issue with Meracl ID3 Tag Writer v1.3.4 truncating last byte
- of MP3 file when appending new ID3v1 tag now specifically noted
- (rather than generic Probably Truncated File message)
- getid3.demo.mysql.php now stores last-modified time for each file
- getid3.demo.mysql.php is now case-sensitive for filenames
- getid3.demo.mysql.php can generate M3U playlists of any of the
- groups of files it can select (duplicate filenames, tag types,
- etc.)
- getid3.demo.mysql.php can now find mismatched tag contents and
- filenames
- getid3.demo.check.php now shows total number of errors & warnings
- GetFileFormatArray() now matches actual patterns for MP3 files
- based on the first two bytes of the file, rather than just the
- first one
- Simplified DeleteAPEtag() and made it work properly with Lyrics3
-
-
-1.6.3: [May-17-2003] James Heinrich
- » Added support for Bonk (thanks ahØartemis*dk)
- New file: getid3.bonk.php
- » Added support for AVR (thanks ahØartemis*dk)
- New file: getid3.avr.php
- ¤ Contents of getid3.id3.php moved to getid3.id3v1.php
- Removed file: getid3.id3.php
- ¤ Contents of getid3.frames.php moved to getid3.id3v2.php
- Removed file: getid3.frames.php
- ¤ Returned data structure documentation improved and updated and
- now stored in getid3.structure.txt rather than getid3.readme.txt
- New file: getid3.structure.txt
- ¤ Now including the GNU General Public License in the distribution
- as getid3.license.txt
- New file: getid3.license.txt
- ¤ Added new, optional, parameter to WriteAPEtag() (and also
- GenerateAPEtag()) which must be set to TRUE if the values you
- are passing are already UTF8-encoded, otherwise all data is
- encoded to UTF8 by default. For all ASCII/ANSI data this value
- should be left at the defaul value of FALSE.
- ¤ Added third, optional, parameter to getID3v2Filepointer() -
- $StartingOffset (default == 0) which can parse an ID3v2 tag
- in a file at a position other than the start-of-file.
- ¤ ['video']['pixel_aspect_ratio'] now returned when known
- ¤ AVI files with WMA audio now return ['audio']['dataformat']
- of 'wma' rather than 'wav'
- ¤ ASF-WMA files now return the artist value from WM/AlbumArtist
- in ['comments']['artist'] (thanks msibbaldØsaebauld*com)
- ¤ ASF-WMA files now return the 'author' value from
- ['asf']['content_description'] in ['comments']['artist']
- instead of ['comments']['author']
- ¤ ASF-WMA files now return the 'description' value from
- ['asf']['content_description'] in ['comments']['comment']
- instead of ['comments']['description']
- * Bugfix: APE tag writing with multiple values for a tag (more
- than one ARTIST for example) was not being correctly written
- (thanks ahØartemis*dk)
- * Bugfix: CreateDeepArray() was returning an empty-string key as
- the top-level returned value - ['iso']['files'] now directly
- contains the file listing without an empty array in between.
- * Bugfix: ID3v2 genreid was not being returned in some cases.
- * Bugfix: APEv1 tags would generate error messages
- * Bugfix: APE tags would sometimes show phantom second entry for
- each item (title, artist, etc) with no data
- * Bugfix: APE tag writing was not UTF8-encoding the data -
- non-ASCII characters (above chr(127)) were being incorrectly
- stored (thanks ahØartemis*dk)
- * Bugfix: getid3.demo.scandir.php had undefined function error
- * Bugfix: getid3.demo.scandir.php would not display list of files
- with no tags
- Added link to getid3.demo.check.php from list of specific-tags
- files in getid3.demo.scandir.php
-
-
-1.6.2: [May-04-2003] James Heinrich
- » New official mirror site for getID3() - http://www.getid3.org
- » Added basic support for SWF (Flash) (thanks n8n8Øyahoo*com)
- New file: getid3.swf.php
- » Added experimental support for parsing the audio portion of
- MPEG-video files. I don't have any actual documentation for
- this, so this part is experimental and not guaranteed accurate,
- but it seems to be working OK as far as I have been able to test
- it. Bug reports (or even better - documentation!) are welcome at
- info@getid3.org
- » Added new simple directory-scanning sample file
- New file: getid3.demo.simple.php
- » getid3.demo.write.php now writes APE tags as well.
- ¤ Renamed getid3.write.php to getid3.demo.write.php
- ¤ Renamed audioinfo.class.php to getid3.demo.audioinfo.class.php
- ¤ getid3.php now automatically includes the getid3.functions.php
- function library file, no need to include it seperately.
- ¤ getLyrics3Filepointer() has been changed to be consistant with
- all the other similar function structures - the parameters have
- changed. The old function has been renamed to getLyrics3Data()
- ¤ Added DeleteAPEtag() function to getid3.ape.php
- ¤ HandleID3v1Tag() now only handles ID3v1. Lyrics3 processing is
- now done by HandleLyrics3Tag()
- ¤ If BitrateHistogram is enabled in getOnlyMPEGaudioInfo() it now
- also returns ['mpeg']['audio']['version_distribution'] showing
- the number of frames of each MPEG version (1, 2 or 2.5) - all
- frames *should* be of the same MPEG version
- ¤ getID3v1Filepointer() always returns TRUE now, even if it didn't
- find a valid ID3v1 tag
- ¤ getOnlyMPEGaudioInfo() now looks for MPEG sync in the first 128k
- bytes rather than the first 64k bytes
- ¤ Added dummy function GetAllMP3info() to generate warning not to
- use that deprecated function.
- ¤ ['video']['codec'] is now 'MPEG' for all MPEG video files (this
- will change to 'MPEG-1' or 'MPEG-2' as soon as I figure out how
- to determine that) (thanks jigalØspill*nl)
- ¤ ['mpeg']['audio']['LAME']['mp3_gain'] renamed to
- ['mpeg']['audio']['LAME']['mp3_gain_db'] (gain in dB)
- ¤ Added ['mpeg']['audio']['LAME']['mp3_gain_factor'] (gain as a
- multiplication factor)
- ¤ Added support for Preset and Surround Info bytes from LAME VBR
- tag (http://gabriel.mp3-tech.org/mp3infotag.html)
- * Bugfix: APE tag writing would put the string 'Array' for all
- values rather than the actual data (thanks ahØartemis*dk)
- * Bugfix: Warning now generated for VBR MPEG-video files because
- getID3() cannot determine average bitrate. If you know of
- documentation that would tell me how to do this, please email
- info@getid3.org
- * Bugfix: Replay Gain values from Vorbis comments are now
- returned in ['replay_gain'] (and not in ['comments'])
- (thanks ahØartemis*dk)
- * Bugfix: Replay Gain values from APE comments are now correctly
- returned in ['replay_gain'] (thanks ahØartemis*dk)
- * Bugfix: getid3.demo.check.php is now case-insensitive when
- assuming a format for a corrupted file if standard detection
- does not identify the file type.
- * Bugfix: RIFF comments were overwriting/suppressing ID3 comments
- for RIFF-MP3 files (thanks wmØwofuer*com)
- * Bugfix: RIFF-MP3 files with 'RMP3' chunks instead of 'WAVE' were
- not being correctly identified.
- * Bugfix: ID3v2 padding shorter than the length of an ID3v2 frame
- header was not correctly detected
- * Bugfix: getid3.demo.check.php now does in-depth scanning for MP2
- and MP1 files the same as for MP3 files based on file extension
- if a MPEG-audio structure isn't found immediately at the start
- of the file
- * Bugfix: removed condition where RIFF-WAV was being scanned for
- MPEG-audio signature when it shouldn't be present (non-MP3 WAV)
- * Bugfix: ASF files were not always showing correct audio datatype
- * Bugfix: array_merge_clobber() and array_merge_noclobber() were
- not being conditionally defined in getid3.functions.php
- (thanks rich.martinØreden-anders*com)
- * Bugfix: stream_numbers was not being correctly returned in
- bitrate_mutual_exclusion_object chunks of ASF files
- * Bugfix: Added support for 24kHz and 12kHz audio in ASF files
- * Bugfix: Removed possible undefined offset error in MP3s where
- cannot find synch before end of file
- * Bugfix: Removed potential out-of-memory crash situation when
- parsing Real files with chunks larger than the available memory
- (thanks jigalØspill*nl)
- * Bugfix: ID3v1 was incorrectly taking precedence over ID3v2 in
- the ['comments'] array (thanks lionelflØwanadoo*fr)
- * Bugfix: No longer calculates overall bitrate and playtime for
- VBR MPEG video files based on the audio bitrate.
- * Bugfix: AssumeFormat was not working properly
- Added summary footer line to getid3.demo.check.php
- Added '.mpeg' to the list of assume-format-from-filenames list in
- getid3.demo.check.php
- MPEG-video files now more reliably detected
- A number of additional features have been added to
- getid3.demo.scandir.php
- Added many RIFF-AVI audio types and fourcc video types to the
- lookup functions in getid3.riff.php
- Now identifes files with Lyrics3 v1 tags that are of incorrect
- length (v1 Lyrics3 is supposed to be 5100 bytes long, but
- [unknown program] writes variable-length tags (which is illegal
- for Lyrics3 v1)). getID3() now correctly parses these tags and
- issues a warning.
- Split GetFileFormat() to GetFileFormat() and GetFileFormatArray()
- HTML colors in getid3.demo.check.php are now defined as constant
- variables at the top of the file (if you want to change them)
- Added support for OptimFROG v4.50x (non-alpha) (new header fields)
- (thanks floringhidoØyahoo*com)
- Added support for Lossless Audio v0.4 (thanks mikeØbevin*de)
-
-
-1.6.1: [March-03-2003] James Heinrich
- » Added support for writing APE v2.
- WriteAPEtag() in getid3.ape.php
- NOTE: APE v1 writing support will *not* be added to future
- versions of getID3()
- (thanks ahØartemis*dk and adamØphysco*com for the idea)
- » Added support for AIFF (Audio Interchange File Format) including
- AIFF, AIFC and 8SVX (thanks ahØartemis*dk for the idea)
- Removed file: getid3.aiff.php
- » Added support for OptimFROG (v4.50a and v4.2x)
- (thanks ahØartemis*dk for the idea)
- New file: getid3.optimfrog.php
- » Added support for WavPack (thanks ahØartemis*dk for the idea)
- » Added support for LPAC (thanks ahØartemis*dk for the idea)
- » Added support for NeXT/Sun .au format
- New file: getid3.au.php
- » Added support for Creative SoundBlaster VOC format
- New file: getid3.voc.php
- » Added support for the BWF (Broadcast Wave File) RIFF chunks
- "bext" and "MEXT" (thanks Ryan and njhØsurgeradio*co*uk)
- » Added support for the CART (Broadcast Wave File) RIFF chunks
- (thanks Ryan)
- » Added getid3.demo.scandir.php - a sample recursive scanning demo
- that scans every file in a given directory, and all sub-
- directories, and stores the resulting data in MySQL database,
- and then displays a list of duplicate files based on md5_data
- ¤ ['md5_data_source'] now contains the MD5 value for the original
- uncompressed data for formats that store that information
- (currently only FLAC v0.5+). ['md5_data'] (if chosen to be
- calculated) will contain the calculated MD5 value for the
- compressed file. To check if 2 files are identical in every way,
- including all comments: compare ['md5_file']. To check if two
- files were compressed from the same source file: compare
- ['md5_data_source']. To check if the compressed audio/video data
- of two files is identical, even if comments or even the
- container file format is different (MP3 in RIFF container,
- FLAC in Ogg container, etc): compare ['md5_data'].
- ¤ ['md5_data'] for 8-bit WAV files is now calculated based on a
- converted version of the data from unsigned to signed (MSB
- inverted) to match the MD5 value calculated by FLAC
- ¤ New optional parameter added to GetAllFileInfo() -
- $MD5dataIfMD5SourceKnown (default: false). If false the md5_data
- value will NOT be calculated for files (such as FLAC) that have
- ['md5_data_source'] set, even if $MD5data == true.
- (thanks ahØartemis*dk)
- ¤ getid3.check.php renamed to getid3.demo.check.php
- ¤ Added GetTagOnly() function to getid3.php - similar to
- GetAllFileInfo() except only takes a filename as a parameter and
- only returns ID3v2, APE, Lyrics3 and ID3v1 tag information - no
- attempt is made to parse the data contents of the file at all.
- (thanks Phil for the idea)
- ¤ Added ['audio']['lossless'] and ['video']['lossless'] for all
- formats (when known). Both are boolean values - true means the
- data is lossless-compressed, false means the data is lossy-
- compressed.
- ¤ Added ['audio']['compression_ratio'] and/or
- ['video']['compression_ratio'] for all formats. Returns a number
- (usually) less than 1, where 1 represents no compression and 0.5
- represents a compressed file half the size of the original file
- ¤ Added ['video']['bits_per_sample'] to all video formats (when
- known)
- ¤ Added ['video']['frame_rate'] to all video formats (when known)
- ¤ ['fileformat'] set to 'mp1' or 'mp2' instead of 'mp3' when
- ['audio']['dataformat'] is one of those (thanks ahØartemis*dk)
- ¤ Added 4th parameter to md5_data(), $invertsign, which will invert
- the MSB of each byte before MD5'ing. This is needed for 8-bit
- WAV files because FLAC calculates the stored MD5 value on
- signed data rather than the original byte values. ['md5_data']
- of an 8-bit WAV will now match the ['md5_data_source'] value
- (thanks lichvarmØphoenix*inf*upol*cz)
- ¤ ['ape']['items']['data'] and ['ape']['items']['data_ascii'] now
- contains an array of values, if the tag contains UTF-8 text (as
- opposed to binary data)
- ¤ ['mpeg']['audio']['bitratemode'] renamed to
- ['mpeg']['audio']['bitrate_mode']
- * Bugfix: Removed potential bug that could replace all MP3 file
- contents with only the new ID3v2 tag in getid3.putid3.php
- * Bugfix: md5_data values calculated for RIFF (WAV, AVI) files
- were incorrect (thanks ahØartemis*dk)
- * Bugfix: MP3 data in an MP4 wrapper fileformat could not identify
- bitrate (thanks ahØartemis*dk)
- * Bugfix: ['audio'] and/or ['video'] keys would sometimes get
- removed even if not empty
- * Bugfix: Prevented creation of null entries in
- ['RIFF']['WAVE']['INFO'] if a comment entry was not present
- * Bugfix: Potential infinite-loop condition in getid3.ogg.php
- (thanks afshin.behniaØsbcglobal*net)
- * Bugfix: Ogg files with illegal ID3v1 (and/or APE or Lyrics3)
- tags were not finding the last Ogg page
- (thanks afshin.behniaØsbcglobal*net)
- * Bugfix: replay-gain values not properly set from LAME tag
- * Bugfix: RIFF-MP3 had incorrect md5_data
- * Bugfix: the LAME DLL CBR problem of not re-writing the LAME
- frame at the beginning of the data is now detected for MP3s
- with ID3v2 tags as well
- * Bugfix: APE tags with multiple values (ie multiple entries in
- the "artist" tag) are now shown properly in ['ape']['items']
- * Bugfix: fixed condition where APE tag with no ID3v1 tag could be
- mistaken for APE tag with ID3v1 (and incorrectly parsed)
- * Bugfix: added warning if ID3v2 frame has zero-length data
- (thanks cmassetØclubinternet*fr)
- * Bugfix: getid3.frames.php looking for non-existant key in USER
- frames
- Improved detection of RIFF-MP3 data. [unknown program] encodes
- RIFF-WAV data with a chunk name of 'RMP3' instead of the
- standard 'RIFF'
- Encoder now returned in both ['comments'] and ['audio']['encoder']
- for RIFF-WAV files with an INFO.ISFT chunk
- Generate a warning for FLAC files encoded with v0.3 or v0.4
- because audio_signature is not calculated during encoding
- (thanks ahØartemis*dk)
- Modified getid3.check.php to display md5_data_source as well as
- md5_file and md5_data if display-MD5 mode is selected
- Modified getid3.check.php to assume-format based on file extension
- in browse mode if fileformat is found to be 'id3' (formerly only
- if the fileformat was null)
- Changed scaling of BitrateColor() from representing 1-256kbps to
- representing 1-768kbps for better display of high-bitrate files,
- specifically lossless-compressed CD-audio (FLAC, LA, etc)
-
-
-1.6.0: [January-30-2003] James Heinrich
- » Added support for OggFLAC (FLAC data stored in an Ogg container)
- (thanks ahØartemis*dk for the idea)
- » Added support for Speex (the data stored in an Ogg container)
- » Comments are now available in the root 2-dimensional array
- ['comments'] - each entry in this array will contain one or more
- strings. For example, if there are two artists then
- ['comments']['artist'][0] will contain the first one and
- ['comments']['artist'][1] the other. All keys are forced
- lowercase. Comments will be stored in the ['comments'] array in
- this order of precedence:
- 1) Native format tags (ASF, VQF, NSV, RIFF, Quicktime, Vorbis)
- 2) APE tags
- 3) ID3v2
- 4) Lyrics3
- 5) ID3v1
- Lower-priority tags will not overwrite or append existing values
- of higher-priority tags (for example, 'artist' in ID3v1 will be
- ignored if already specified in APE), but missing values will be
- filled in (for example, if 'album' is specified in ID3v2 but not
- in APE, it will be included in the ['comments'] array).
- Note: Root keys (['title'], ['artist'], etc) are NOT available
- in this or future versions of getID3().
- (thanks ahØartemis*dk)
- » MD5 hashes are now available for all formats for both the entire
- file (['md5_file']) and the portion of the file containing only
- the audio/video data, stripped of all prepended/appended tags
- like ID3v2, ID3v1, APE, etc - ['md5_data']
- (thanks ahØartemis*dk for alternate md5_file() function that
- runs on UNIX system running PHP < 4.2.0)
- NOTE: Ogg files require the use of vorbiscomment to obtain the
- md5_data value. vorbiscomment must be downloaded from
- http://www.vorbis.com/download.psp and placed in the getID3()
- directory. All Ogg formats (Vorbis, OggFLAC, Speex) are affected
- by this problem, but only OggVorbis files can be processed with
- vorbiscomment. OggFLAC and Speex files will be processed by
- getID3(), but this may result in an incorrect value for md5_data
- in the event that VorbisComments are larger than 1 page (4-8kB).
- NOTE: md5_data for Ogg will not work if PHP is running in Safe
- Mode
- » There is now a wrapper class available, written by Allan Hansen,
- which should simplify extracting most common basic information
- (such as format, bitrate, comments).
- New file: audioinfo.class.php
- » OggWrite() in getid3.ogginfo.php has been replaced with a new
- version that uses vorbiscomment to write the comments, because
- of a reported bug that can corrupt OggVorbis files such they
- cannot be played.
- NOTE: Ogg comment writing now requires the use of vorbiscomment
- which must be downloaded from http://www.vorbis.com/download.psp
- and placed in the getID3() directory.
- NOTE: Ogg comment writing will not work if PHP is running in
- Safe Mode
- ¤ New root key ['tags'] is now always returned for all formats.
- It is an array that may contain any of:
- * Native format tags: 'vqf', 'riff', 'vorbiscomment', 'asf',
- 'nsv', 'real', 'midi', 'zip', 'quicktime'
- * Appended data tags: 'ape', 'lyrics3', 'id3v2', 'id3v1'
- ¤ New root key ['audio'] is an array containing any or all of:
- codec, channels, channelmode, bitrate, bits_per_sample,
- dataformat, bitrate_mode, sample_rate, encoder
- Note: This replaces several root keys, including:
- bitrate_audio, bits_per_sample, frequency, channels
- ¤ New root key ['video'] is an array containing any or all of:
- bitrate_mode, bitrate, codec, resolution_x, resolution_y,
- resolution_y, frame_rate, encoder
- Note: This replaces several root keys, including:
- bitrate_video, resolution_x, resolution_y, frame_rate
- ¤ ['id3']['id3v1'] has moved to ['id3v1']
- ¤ ['id3']['id3v2'] has moved to ['id3v2']
- ¤ ['audiodataoffset'] and ['audiodataend'] have been renamed to
- ['avdataoffset'] and ['avdataend'] respectively
- ¤ GetAllMP3info() has been changed to GetAllFileInfo() with a
- different parameter list ($allowedFormats is no longer a
- parameter). Check your code where you're calling
- GetAllMP3Info() - you will need to change both the function
- name and the parameter list if you pass more than 2 parameters
- ¤ All formats now return ['audio']['dataformat'] and/or
- ['video']['dataformat'] where appropriate - this goes along with
- ['fileformat'] - ['fileformat'] will return the actual structure
- of the file, whereas ['dataformat'] will return the format of
- the data inside that structure. For example, an Ogg file can
- contain Vobis data (normal), or it can contain FLAC data in the
- Ogg container format. In that case, ['fileformat'] would be
- 'ogg', but ['dataformat'] would be 'flac'.
- Note: this means that WAV and AVI files now return a
- ['fileformat'] of 'riff' rather than 'wav' or 'avi'.
- ¤ ['filesize'] is no longer returned for files larger than 2GB
- because PHP does not support large file access. Attempting to
- parse a file larger than 2GB will result in a message stored in
- ['error'] and ['filesize'] not set.
- ¤ APEtag, ID3v1, and ID3v2 are now supported on ALL multimedia
- files - even if illegal by format. Ogg will return warning if
- ID3/APE tags are present. (thanks ahØartemis*dk)
- ¤ All files: non-critical errors are now returned in the root key
- ['warning'] rather than ['error'] (only critical errors that
- prevent getID3() from correctly parsing the file are returned in
- ['error'] (thanks ahØartemis*dk)
- ¤ Renamed all references to $MP3fileInfo to $ThisFileInfo
- ¤ Joliet now supported for ISO-9660.
- ['iso']['supplementary_volume_descriptor'] is now returned, if
- available, and ['iso']['files'] will contain ASCII equivalents
- of the Unicode directory structure & filenames stored.
- ¤ Moved Monkey's Audio code from getid3.ape.php to seperate file.
- New file: getid3.monkey.php
- ¤ Added new keys for ISO-9660: ['name_ascii'] for directories,
- ['file_identifier_ascii'] for files
- ¤ Added root key ['track'] for CD-audio files
- ¤ Ogg/Vorbis-comment files now have comments returned inside
- ['ogg']['comments_common'] as an array of strings, rather than
- simple strings in ['ogg']
- ¤ Quicktime files now have comments returned inside
- ['quicktime']['comments'] as an array of strings, rather than
- simple strings in ['quicktime']
- ¤ ['mime_type'] is a new root key returned for all supported
- formats (thanks ahØartemis*dk)
- ¤ ['fileformat'] now returns 'mp1' instead of 'mp3' for MPEG-1
- layer-I audio files (thanks ahØartemis*dk)
- ¤ ['mpeg']['audio']['bitratemode'] now returns lowercase
- ¤ MPEG-4 audio files which consist of MP3 data wrapped in a
- Quicktime fileformat will now return the usual data in
- ['mpeg']['audio']
- ¤ Type-1 DV AVIs are now supported
- ¤ DV AVIs will return 1 or 2 in ['RIFF']['video'][x]['dv_type']
- ¤ Changed ['fileformat'] from 'mpg' to 'mpeg' for MPEG video files
- ¤ ASF comments are now stored in ['asf']['comments'] instead of
- ['asf']
- ¤ RealMedia chunk data is now returned inside ['real']['chunks']
- instead of ['real']
- ¤ ['replay_gain'] now properly populated from APE tags
- ¤ Added support for ASF_Old_ASF_Index_Object in ASF files
- (thanks ahØartemis*dk)
- ¤ AAC-ADTS files now return ['aac']['bitrate_distribution']
- ¤ ParseVorbisComments() has been replaced with
- ParseVorbisCommentsFilepointer() (with different parameters)
- ¤ All references to any key ['frequency'] are now ['sample_rate']
- ¤ Moved ID3v2 comments from ['id3v2'] into common root
- ['comments'] structure, and now returns more values than before
- * Bugfix: ['iso']['files'] and ['zip']['files'] could potentially
- contain duplicate entries (in a numeric-indexed array) for files
- if the directory structure specifies files multiple times.
- Entries are now guaranteed unique, with the last entry for the
- file overwriting any former ones.
- * Bugfix: RIFF parsing had numerous issues, including:
- - large AVIs would take a very very long time to parse
- - chunks with odd (not even) sizes would cause the parser fail
- - video and/or audio codecs not always identified
- The ParseRIFF() function has been completely rewritten and fixes
- all known issues with RIFF parsing. Users are, however,
- encouraged to double-check output of any parsed (AVI/WAV/CDDA)
- files.
- * Bugfix: Modified getid3.riff.php to return correct total
- bitrates for AVIs with multiple audio streams
- * Bugfix: GetFileFormat() was not creating array structure
- correctly (thanks ahØartemis*dk)
- * Bugfix: LAME tag for MP3s can only specify up to 255kbps, so any
- files with actual CBR bitrate of >=256 were reported incorrectly
- * Bugfix: Lyrics3 synched lyrics were not being correctly returned
- * Bugfix: CreateDeepArray() was broken for non-nested cases, which
- meant ZIP and ISO ['files'] structures were broken
- * Bugfix: Incorrect pattern matching for ZIP files meant no zip
- files were being detected as such
- * Bugfix: AAC-ADIF was returning an incorrect number of channels
- (too few) in some cases (thanks ahØartemis*dk)
- * Bugfix: Vorbis comments were returning an incorrect value for
- ['dataoffset'] in some cases
- * Bugfix: MPEG video ['marker_bit'] and ['vbv_buffer_size'] were
- incorrect
- * Bugfix: ['playtime_string'] could potentially have a value of
- x minutes and 60 seconds (ie 3:60 instead of 4:00)
- Added support for FLAC cuesheets (FLAC 1.1.0+)
- (thanks ahØartemis*dk)
- Improved parsing speed in MP3, MP2 and AAC (thanks ahØartemis*dk)
- Extra error-checking added to try and identify corrupt files for
- most audio formats (thanks ahØartemis*dk)
- More accurate playtime calculation for RealMedia
- (thanks ahØartemis*dk)
- Changed all relevant files to use ['audiodataoffset'] and
- ['audiodataend'] rather than ['filesize'] where appropriate
- (thanks ahØartemis*dk)
- Added text encoding type 255 as a duplicate of UTF-16BE but with
- Big-Endian rather than Little-Endian byte order
- Added many RIFF-AVI audio types and fourcc video types to the
- lookup functions in getid3.riff.php
- Added numerous new known GUIDs to getid3.asf.php
- Added PoweredBygetID3() function to easily get a "powered by"
- string with the current getID3() version.
- Added "Morgan Multimedia Motion JPEG2000" (MJ2C), "DivX v5" (DX50)
- and "XviD" (XVID) codecs to list of known codecs in
- getid3.riff.php
- Changed GETID3_INCLUDEPATH path seperators to forced /
- (from \ for Windows)
- Modified getid3.check.php to only change \ directory seperators to
- / on Windows operating systems
- Modified getid3.check.php to handle larger-than-2GB files (which
- now do not return a filesize)
- Modified getid3.check.php to handle ['dataformat_audio'] and
- ['dataformat_video']
- Modified getid3.check.php to show a list of present tags in one
- column rather than one column for each of ID3v1, ID3v2, etc
- Modified getid3.check.php to show MD5 values. Initially disabled
- but can be enabled for a directory with a click. md5_file is
- always calculated when displaying detailed info about a single
- file; md5_data is calculated if the file is < 50MB
- Modified getid3.check.php to show errors and warnings. Details are
- visible with a mouseover or a click.
- Changed getid3.check.php to use SafeStripSlashes instead of a
- manual conditional directory name replacement for special
- characters
- Added sample recursive scanning sample code to getid3.readme.txt
- (thanks lipisinØmail*ru for the idea)
-
-
-1.5.7: [January-10-2003] James Heinrich
- » Added support for ISO 9660 (CD-ROM image) format. Most-useful
- data is directory structure returned under ['iso']['files']
- Note: Only ISO-9660 supported, not (yet) Joliet extension
- (thanks nebula_djØsofthome*net for the idea)
- New file: getid3.iso.php
- ¤ ZIP files are now parsed by getID3() itself without relying on
- built-in PHP functions and/or ZZipLib support.
- (thanks Vince for the idea)
- ¤ ZIP files now return a simple directory listing with filename
- and filesize info only under ['zip']['files'].
- Note: empty subdirectories will note appear in here, only files
- and non-empty subdirectories. Information for all entries,
- including empty subdirectories, is available under
- ['zip']['central_directory'] (or under ['zip']['entries'] if the
- Central Directory cannot be located (usually due to a trucated
- file).
- ¤ RIFF-WAV files with MP3 data (or MP3s with RIFF headers, if you
- want to think of it that way) now have the MPEG audio portion
- scanned and the usual data returned in ['mpeg']['audio'] if the
- RIFF audio codec has wFormatTag of "85" (identified by getID3()
- as "MPEG Layer 3")
- (thanks ahØartemis*dk for the idea)
- ¤ EXIF data (if present) is returned for JPEG files under
- ['jpg']['exif'] (thanks nebula_djØsofthome*net)
- ¤ ['filepath'] now returned for all files with the directory part
- of the full filename.
- ¤ ['filenamepath'] is now returned for all files (equivalent to
- ['filepath'].'/'.['filename'])
- * Bugfix: ['id3']['id3v2'][<framename>]['dataoffset'] was wrong
- * Bugfix: MP3s tagged with iTunes have an invalid comment field
- frame name ('COM ' - should be 'COMM') but the data is valid
- otherwise; the frame is now renamed to 'COMM' and parsed
- normally (with the error noted in ['error'])
- (thanks kheller2Ømac*com for the sample file)
- * Bugfix: Some ASF/WMA audio files were not being identified as
- any format (thanks ahØartemis*dk)
- * Bugfix: Warning now generated and ASCII format assumed for
- invalid text encoding values in ID3v2
- * Bugfix: Changed ZIP detection pattern from 'PK' to 'PK\x04\x03'
- * Bugfix: Ogg/FLAC files with large Vorbis comments were dying in
- an infinite loop with lots of error messages due to missing $fd
- parameter on ParseVorbisComments() (thanks ahØartemis*dk)
- * Bugfix: ['data'] and ['image_mime'] were being returned for all
- Ogg comments even if they were not images for versions of PHP
- that have image_type_to_mime_type() built in (ie PHP 4.3.0+)
-
-
-1.5.6: [December-31-2002] James Heinrich
- » Added support for NSV (Nullsoft Streaming Video)
- (www.nullsoft.com/nsv/)
- (thanks demonØsoundplanet*com for the idea)
- New file: getid3.nsv.php
- » Added support for CD-audio track files (track01.cda etc)
- ¤ Added standard ['frame_rate'] root value when known (AVI, NSV,
- MPEG-video)
- ¤ ASF files now report ['fileformat'] of:
- 'wmv' when Windows Media Video codec v7/v8/v9 is used;
- 'wma' when any 'Windows Media Audio' named audio codec is used
- and no video stream is present;
- 'asf' in all other cases (audio-only, video-only, or both)
- ¤ Removed support for ZIP functions (will be rewritten to not
- require ZZIPlib support in future versions)
- ¤ Added function SafeStripSlashes() as a drop-in replacement for
- stripslashes(), but that only strips slashes if magic_quotes_gpc
- is set
- ¤ Removed support for remote file scanning (HTTP / FTP)
- ¤ Added ['aac']['frames'] (number of AAC frames in file)
- ¤ Added ['mpeg']['audio']['frame_count'] when a bitrate histogram
- is created
- ¤ Average bitrate for VBR MP3/MP2 is calculated from actual counts
- of frames of various bitrates (rather than relying on the header
- values or filesize) when a bitrate histogram is created
- ¤ RecursiveFrameScanning() split out into seperate function
- (getid3.mp3.php)
- ¤ Removed old function getMP3header() from getid3.mp3.php
- ¤ Changed default MPEG_VALID_CHECK_FRAMES (number of mp3 frames
- scanned to ensure a valid audio sequence has been located) from
- 10 to 25. This means scanning will be slightly slower, but more
- reliable/accurate
- * Bugfix: ID3v2.2 - valid frame names not correctly detected
- (thanks maeckerØweb*de for the sample file)
- * Bugfix: ID3v2.2 - valid padding not correctly detected
- (thanks maeckerØweb*de for the sample file)
- * Bugfix: MIDI files with flat key signatures were not being
- correctly reported (thanks alexleeisØshaw*ca for sample file)
- * Bugfix: now returns message in ['error'] if file does not exist
- * Bugfix: ['RIFF']['video'][x]['codec'] wasn't always being
- correctly populated
- * Bugfix: ['bitrate'] was incorrect for multi-stream RealMedia
- * Bugfix: ['playtime_seconds'] was sometimes null or incorrect
- for multi-stream RealMedia
- * Bugfix: ChannelTypeID was incorrect in RVA2 ID3v2.4 frames
- * Bugfix: Fixed potential divide-by-zero error for corrupt FLAC
- files (thanks ahØartemis*dk)
- * Bugfix: AAC-ADTS was not returning ['bitrate_mode'] unless
- $ReturnExtendedInfo was TRUE (thanks ahØartemis*dk)
- * Bugfix: LAME-encoded CBR MP3s now properly identified as CBR
- with correct bitrate (thanks ahØartemis*dk)
- * Bugfix: VBR MP2 (or headerless MP3) is now identified as VBR
- rather than CBR. Note: to obtain VBR bitrate for headerless
- files, the entire file is scanned and a histogram distribution
- of bitrates is created, and the average bitrate calculated from
- that. (thanks ahØartemis*dk for sample file)
- Added support for DSIZ chunks in VQF, and checks to make sure size
- of audio data matches DSIZ value, if present
- (thanks ahØartemis*dk for sample file)
- Rewrote GetAllMP3info() - removed some unneccesary code, changed
- format-detection routine from ParseAsThisFormat() to
- GetFileFormat() to allow for more flexible format parsing
- (needed for ISO CD-ROM images, helpful for Quicktime and others)
- Changed references in all files from string-cast indexes: ["$i"]
- to non-cast indexes: [$i] where appropriate
- Put a sans-serif 9pt style on all text in getid3.check.php
- getAACADTSheaderFilepointer() now return TRUE if synch is lost
- after the first frame has been successfully parsed (previously
- it would return FALSE if synch was lost at any time, meaning the
- file is most likely MP3, which was incorrect)
- (thanks ahØartemis*dk for sample file)
- Speed improvement code changes to getid3.mp3.php (up to 24% faster
- in some cases) (thanks ahØartemis*dk for the code)
- Changed all include_once() to require_once()
-
-
-1.5.5: [November-25-2002] James Heinrich
- » Added support for La (Lossless Audio - www.lossless-audio.com)
- (thanks ahØartemis*dk for the idea)
- New file: getid3.la.php
- ¤ Moved lookup functions from getid3.lookup.php to the files where
- they are used.
- New file: getid3.id3.php
- New file: getid3.rgad.php
- Removed file: getid3.lookup.php
- ¤ getID3v1Filepointer() returns FALSE if ID3v1 tag not found
- ¤ Added new paramter "ReturnExtendedInfo" to the function
- getAACADTSheaderFilepointer() in getid3.aac.php which now
- defaults to FALSE - if TRUE then the data for every frame is
- returned (containing aac_frame_length, adts_buffer_fullness and
- num_raw_data_blocks, which aren't usually very useful). Speed
- improvement with FALSE is about 35%.
- ¤ Now returns fopen() errors in ['error'], for example if a remote
- file is not accessible.
- ¤ Changed default number of MP3 audio frames to scan to determine
- if a valid stream has been found from 5 to 10, now also defined
- as a constant at the top of getid3.mp3.php This will result in
- slightly slower MP3 parsing, but greater reliability in
- detecting false/invalid/corrupted VBR headers.
- ¤ fopen() errors now displayed in getid3.putid3.php
- (thanks miguel.dieckmannØhamburg*de)
- ¤ Added 4th parameter to decodeMPEGaudioHeader() $ScanAsCBR which
- will force an MP3 audio frame sequence to be force-scanned in
- CBR mode. You should never need to call this directly, it's only
- used internally to scan for MP3 files that have an illegal VBR
- header with CBR data. (thanks fletchØpobox*com)
- * Bugfix: ASF_Marker_Object in getid3.asf.php was always returning
- an error in non-existant "reserved_1" and failing
- * Bugfix: VBR bitrate calculations in getid3.mp3.php only occur if
- ['mpeg']['audio']['VBR_frames'] is defined.
- (thanks fletchØpobox*com)
- * Bugfix: getid3.putid3.php no longer deletes original MP3 if
- ID3v2 tag writing fails (thanks miguel*dieckmannØhamburg*de)
- * Bugfix: incorrect order of if-statement error messages in
- getid3.putid3.php (thanks miguel*dieckmannØhamburg*de)
- getid3.asf.php now notes the error and continues parsing rather
- than failing when it encounters an error parsing a chunk
- Now actually scan 1000 frames for AAC ADTS as reported in the
- v1.5.4 changelog, rather than 100. (thanks ahØartemis*dk)
- Improved scanning speed in getAACADTSheaderFilepointer() by ~30%
- (thanks ahØartemis*dk for the fix)
- Added FileSizeNiceDisplay() function to getid3.functions.php for
- formatting filesize output in kB, MB, GB, etc.
-
-
-1.5.4: [October-07-2002] James Heinrich
- » Added support for Quicktime.
- New file: getid3.quicktime.php
- » Added support for AAC files, both ADTS and ADIF header formats.
- ADIF format is a pain because it's very similar to standard MP3
- header format, and it's hard to distinguish between the two. I
- have tried to make the detection accurate, but I have a limited
- number of AAC test files to play with so if you have an AAC file
- that gets detected as MP3/MP2 (or vice-versa), please send me
- the details via email at getid3Øsilisoftware*com
- ADTS format is very slow to parse because to get the bitrate of
- VBR files the whole file has to be stepped through frame by
- frame (getID3() scans up to the first 1000 frames and assumes
- that to be close enough).
- Note: I would suggest commenting out support for AAC (see top of
- GetAllMP3info() function in getid3.php) unless you need it.
- (thanks jfaulØgmx*de for the idea and sample Delphi source code)
- New file: getid3.aac.php
- » Added bitrate distribution analysis option for MP3 VBR files. A
- new boolean parameter for getOnlyMPEGaudioInfo() enabled this
- feature which steps through the MP3 file frame by frame and
- counts how many frames of each bitrate exist. This information
- is returned in ['mpeg']['audio']['bitrate_distribution']
- Caution: this feature is very inefficient for large files and
- takes a very long time and does lots of disk I/O. Use with care.
- ¤ Changed layout of allowedFormats in GetAllMP3info() function in
- getid3.php to allow easy removal of support for any of the
- supported format. As stated above, I recommend commenting out
- AAC unless needed.
- ¤ Added ['flac']['compressed_audio_bytes'],
- ['flac']['uncompressed_audio_bytes'], and
- ['flac']['compression_ratio']
- ¤ Replaced FXPT2DOT30toFloat() function with FixedPoint2_30()
- * Bugfix: getid3.mpc.php was slightly miscalculating the number of
- samples, therefore also bitrate and playtime
- (thanks ahØartemis*dk for the fix)
- * Bugfix: MonkeyCompressionLevelNameLookup() didn't know about
- 'insane' compression (thanks ahØartemis*dk for the fix)
- * Bugfix: MonkeySamplesPerFrame() was incorrect for MAC v3.95+
- (thanks ahØartemis*dk for the fix)
- * Bugfix: getid3.check.php wasn't processing the assumeFormat
- directive when (register_globals == off)
- * Bugfix: detecting of synch pattern for MP3 files with invalid
- data at the beginning wasn't always correct, also meant possible
- incorrect bitrate/duration/etc info for such corrupt files.
- getid3.functions.php now includes a replacement utf8_decode()
- function for those PHP installations that are not configured
- with the --with-xml option. (thanks stephaneØtekartists*com)
-
-
-1.5.3: [September-30-2002] James Heinrich
- » Added support for VQF. (thanks mtØmansonthomas*com for the idea)
- New file: getid3.vqf.php
- » Added support for FLAC. Comments, if present, are returned under
- ['ogg'] because they follow the Ogg Vorbis structure standard.
- New file: getid3.flac.php
- ¤ OS/2-format bitmaps are now correctly interpreted. The format of
- the bitmap is now returned in ['bmp']['type_os'] and
- ['bmp']['type_version']. OS/2 bitmaps can be v1 or v2, Windows
- can be v1, v4 or v5
-
-
-1.5.2: [September-25-2002] James Heinrich
- » Support for RealMedia (audio & video) added
- Note: only tested on G2 and v5 audio and video files - if anyone
- has older and/or newer sample files, please test it and/or send
- me the sample files.
- (thanks stephaneØtekartists*com for idea)
- New file: getid3.real.php
- » Support for BMP added. Palette and pixel data can optionally be
- extracted as well - this is slow and generally unneccesary, but
- the option is there if you need it. Also includes PlotBMP()
- which will take the extracted pixel data and output it as a true
- color PNG. This function requires GD v2.0+
- Note: Untested on 16-bit and 32-bit BMPs because I couldn't find
- any sample files - if you know of a program that can create such
- files, please email getid3Øsilisoftware*com
- Note: Support for RGB (uncompressed), RLE8 and RLE4 is included
- and tested. BITFIELDS support is also included for 16- & 32-bit
- formats, but it's untested, so if anybody has any test files
- please send them to getid3Øsilisoftware*com
- Note: Support currently only for Windows-format BMPs, and trying
- to parse an OS/2-format bitmap leads to unpredictable/invalid
- results.
- New file: getid3.bmp.php
- » PNG now fully parsed, including all information chunks
- New file: getid3.png.php
- ¤ Support for GIF/JPG/PNG moved to seperate files and expanded,
- including standard ['resolution_x'] and ['resolution_y'] as well
- as more thorough parsing of header information
- New file: getid3.gif.php
- New file: getid3.jpg.php
- table_var_dump() simplified and now outputs &#123;-style character
- entities for characters outside the normal alphanumeric range
- CleanOggCommentName() changed to a regular expression
- (thanks chris-getid3Øbolt*cx for rewriting the function)
-
-
-1.5.1: [September-20-2002] James Heinrich
- » Added support for MPEGplus/Musepack SV7. ['fileformat'] is 'SV7'
- for version 7 files (versions 4, 5 ,6 and 8 are not supported
- yet, but will be of ['fileformat'] SV4, SV5, SV6 and SV8) when
- they are supported (thanks Christian Fritz for the idea)
- New file: getid3.mpc.php
- ¤ ['bitrate_audio'], ['bitrate_video'], ['bitrate_mode'],
- ['channels'], ['resolution_x'], and ['resolution_y'] keys added
- for all appropriate formats
- ¤ Ogg files with a COVERART comment now save and display the
- attached image the same way as is done with ID3v2 APICs
- ¤ ['ogg']['comments'][n]['data'] and
- ['ogg']['comments'][n]['dataoffset'] is now returned for all
- comments. ['ogg']['comments'][n]['data'] is only useful if
- the field is supposed to contain binary data. It is a
- base64_decode()'d version of ['value'].
- ['ogg']['comments'][n]['dataoffset'] is the byte offset in the
- file at which the 'COMMENTNAME=value string' starts, not the
- start of just 'value'
- ¤ ['ogg']['comments'][n]['image_mime'] is now returned if
- ['ogg']['comments'][n]['data'] contains valid image data.
- ¤ More than 3 Ogg pages may now be read in, if the comment data
- is longer than 1 page (usually about 4kB)
- ¤ ['fileformat'] is now 'mp2' rather than 'mp3' if it's MPEG-1,
- Layer-II audio
- ¤ ASF bitrates now calculated even if stream_bitrate_properties
- object not present
- ¤ ['asf']['stream_properties_object'] is now a numeric-key array
- with one entry for each stream - the key being the stream number
- ¤ ['replay_gain'] is returned for all audio formats that support
- it (MP3-LAME, ID3v2, Ogg) (thanks Christian Fritz for the idea)
- ¤ ['mpeg']['audio']['LAME']['RGAD']['radio_replay_gain'] is now
- ['mpeg']['audio']['LAME']['RGAD']['radio'] (same for audiophile)
- ¤ ASF/WMA files now use WM/Track to get track number from if
- WM/TrackNumber is not available (thanks stephaneØtekartists*com)
- ¤ ASF/WMV files now returns ['year'] and ['asf']['year']
- ¤ ASV/WMV files now use ['content_description']['description'] for
- the ['comment'] field (thanks stephaneØtekartists*com)
- ¤ ['track'] is now always returned as an integer
- * Bugfix: Ogg comments that are larger than one data page (usually
- about 4kB) are now correctly parsed (thanks Christian Fritz)
- * Bugfix: Ogg comment data is now UTF8-decoded
- * Bugfix: Ogg comment writing now UTF8-encodes the data
- * Bugfix: playtime for ASF files was off by <preroll> (usually
- between 3 and 12 seconds)
- * Bugfix: ['asf']['stream_properties_objects']['flags'] data was
- possibly incorrect
- * Bugfix: ASF Padding Object was overwriting
- Stream Bitrate Properties Object data (now returned correctly in
- ['asf']['padding_object']
- * Bugfix: ASF Marker Object Reserved_2 field was incorrect
- * Bugfix: ASF Bitrate Mutual Exclusion Object had incorrect stream
- numbers
- Warning displayed if incorrectly-formatted Ogg comment is present
- (known to be an issue with CDex v1.40, but fixed by v1.50b7)
- (thanks Christian Fritz)
- Ogg comment writing now checks for valid comment names
- Added bitrate column in getid3.check.php, and added some formatting
- (font, colour)
- Performance tweaks using bitwise math instead of binary string
- operations
-
-
-1.5.0: [September-18-2002] James Heinrich
- » Ogg comment writing support added. getid3.write.php has been
- updated to allow for writing comment tags to both MP3 and Ogg.
- Big thanks to Chris Bolt <chris-getid3Øbolt*cx> for writing the
- OggWrite() function and offering it for inclusion in getID3()
- New file: getid3.ogginfo.php
- » Support for Monkey's Audio and APE tag added.
- (thanks Christian Fritz for the idea)
- New file: getid3.ape.php
- ['fileformat'] now returns 'mac' for Monkey's Audio files, or
- 'ape' for files with an APE tag (Monkey's Audio or other format)
- » getid3.thumbnail.php has been removed from the distribution and
- the table_var_dump() function now outputs APICs as seperate
- files in the same directory as the analyzed file. This should
- make the image-displaying more reliable as well as reduce
- complexity. The naming convention for the images is
- filename.ext.[byte offset of APIC data].[jpg|gif|png]
- If anybody still has any problems with corrupted images please
- let me know at getid3Øsilisoftware*com
- » Support for extended Xing/LAME tag
- (see http://users.belgacom.net/gc247244/extra/tag.html)
- Data is returned in ['mpeg']['audio']['LAME']
- ¤ ['ogg']['tracknumber'] has been renamed to ['ogg']['track'] and
- ['track'] is now returned in the root of the array
- ¤ ['ogg']['pageheader'][n]['flag'] has been renamed to
- ['ogg']['pageheader'][n]['flags'] and the unprocessed flag byte
- is available in ['ogg']['pageheader'][n]['flags_raw']
- ¤ ['frequency'] is now returned for WAVE files in the root of the
- array (thanks danielØelectroteque*org)
- ¤ ASF files now return codec, bitrate, resolution, etc information
- under ['asf']['video_media'] or ['asf']['audio_media']
- * Bugfix: RVA2 and EQU2 writing in getid3.putid3.php were
- incorrectly writing Volume Adjustment field
- * Bugfix: EQU2 in getid3.frames.php was reading Volume Adjustment
- as unsigned integer instead of signed integer
- * Bugfix: handling of remote files over HTTP & FTP was broken
- (thanks Vince)
- * Bugfix: incorrect handling of some ASF packets
- ASF/Windows Media format now more fully parsed, including Index
- Objects
- Added several new fourCC video codecs
-
-
-1.4.3: [September-15-2002] James Heinrich
- » Now parses ASF / WMV / WMA files
- ¤ New file: getid3.asf.php
- * Bugfix: RoughTranslateUnicodeToASCII() would return nothing
- if didn't find a terminator it was expecting
- Added FILETIMEtoUNIXtime() function (for converting 64-bit
- Microsoft FILETIME timestamps, used in ASF files and elsewhere,
- to UNIX Epoch timestamps)
- Added GUIDtoBytestring() and BytestringToGUID() functions
-
-
-1.4.2: [September-12-2002] James Heinrich
- » getID3() now requires PHP v4.1.0 or higher because it now is
- designed to work with register_globals = off and the new auto-
- globals ($_GET, $_SERVER, etc).
- * Bugfix: VBR MP3 files with Fraunhofer-style VBR header were not
- being correctly detected in most cases
- (thanks dkushnerØoddcast*com and mikeØftl*com for sample files)
- * Bugfix: IsValidTextEncoding() was broken
- * Bugfix: Add stripslashes($EditorFilename) to getid3.write.php
- (writing was broken for files with ' or " in the filename)
- (thanks mikeØftl*com and kthejoker)
- * Bugfix: If there is garbage data between a valid VBR header
- frame and a sequence of valid MPEG-audio frames the VBR data is
- no longer discarded. (thanks to mikeØftl*com for sample
- Fraunhofer-style VBR file produced with MusicMatch v7.2)
- ¤ Changed variable system to work with (register_globals = off)
- ¤ Moved relevant code into seperate PlaytimeString() function
- ¤ Added nl2br() to table_var_dump() for cleaner output
- ¤ Now returns the following keys from Fraunhofer-VBR files:
- ['VBR_seek_offsets'], ['VBR_seek_offsets_stride'],
- ['VBR_offsets_relative'] and ['VBR_offsets_absolute']
- ¤ Added ID3v1matchesID3v2() function and implemented in
- getid3.check.php (thanks to "Guest" in the forums for the idea)
- Changed amount of data read in getid3.getimagesize.php from 10kB
- to entire file. (thanks mikeØftl*com)
- Wrapped function_exists() checks around function definitions in
- getid3.functions.php
- Fixed a lot of E_WARNING and E_NOTICE situations, especially in
- ID3-writing code (getid3.putid3.php, etc)
- Added checks to make sure all needed data is available for writing
- ID3v2 tags
-
-
-1.4.1b5: [May-30-2002] James Heinrich
- * Bugfix: Unsynchronise() was broken, now fixed
- (thanks mikeØftl*com)
- * Bugfix: GenerateID3v2Tag() now correctly uses non-synchsafe
- integers for frame size descriptors in ID3v2.3 and ID3v2.2
- (thanks mikeØftl*com)
- ¤ Added ['artist'], ['title'], etc keys to root of returned
- array to provide a common place to access any returned info
- from any file type. Currently gets info from ID3v1, ID3v2,
- Ogg, and RIFF/WAVE. Possible returned keys are:
- title, artist, album, year, genre, comment, track
- ¤ Modified LookupGenre() function to search for either genre based
- on numeric ID, or now reverse lookup as well
- ¤ Added ['artist'], ['title'], etc keys to ['RIFF'] information
- if info tags are present
- Added functionality to attach a picture to the ID3v2 tag in
- getid3.write.php
- Sorted genres into alphabetical order (special 3 at end of list)
- in getid3.write.php
- Changed the comment-edit field in getid3.write.php to a multi-line
- <textarea> from a single-line <input>
- getid3.write.php now only writes ID3v2 frames that have data
- Added default TXXX field to getid3.write.php to put a tagger info
- field when writing ID3v2 tags. Description is "ID3v2-tagged by"
- and data is "getID3() v[version] (www.silisoftware.com)"
- Changed getid3.check.php to use the new common info keys
- Improved file-format detection in getid3.check.php - if the auto-
- detect based on the first few bytes of the file doesn't find a
- known format (for example if the header is corrupt), a more
- thorough scan is done based on the file extension
- Added 'Edit ID3' link from getid3.check.php to getid3.write.php for
- MP3 files (thanks maxØgutalin*com for the idea)
- Added 'Delete file' link from getid3.check.php to getid3.write.php
- allowing you to permanently delete a file (be careful with this!!)
- (thanks maxØgutalin*com for the idea)
- Added some mouse-over titles for links in getid3.check.php
-
-
-1.4.1b4: [May-15-2002] James Heinrich
- * Bugfix: getid3.check.php wasn't parsing MP3s with invalid headers
- or padding at the beginning of the file - added 'assumeFormat'
- parameter and 'Parse this file as:' options to force parsing in a
- particular format (thanks Alcohol for the sample file)
- * Bugfix: unset(['fileformat']) and ['error'] added in cases where
- file cannot be parsed in the assumed or forced format
-
-
-1.4.1b3: [May-01-2002] James Heinrich
- ¤ For Ogg files, now calculates the real average bitrate (returned
- in ['ogg']['bitrate_average']) and so the playtime of the file is
- calculated on actual average bitrate, not nominal bitrate, so it
- should be accurate now (thanks to stephaneØtekartists*com for
- telling me it was wrong)
- * Bugfix: ID3v2FrameIsAllowed() wasn't behaving properly if the
- writing functions were called for more than one file, because of
- the static array not being cleared between uses. This is an
- updated fix because the one in 1.4.1b2 didn't work :o)
- (thanks soulcatcherØevilsoft*org and yoyo)
- Added rawurlencode() to the filename parameter in table_var_dump()
- for images (wouldn't work with path/file names containing special
- characters (#, &, ", +) (thanks Christian Fritz)
- getid3.check.php no longer attempts to scan all MIDI tracks in
- directory-browse mode, since this can take a long time. Detailed
- single-file view is still fully scanned (new third parameter for
- getMIDIHeaderFilepointer() controls this)
- Small improvements to MoreNaturalSort()
-
-
-1.4.1b2: [April-18-2002] James Heinrich
- ¤ GetAllMP3Info()'s 2nd parameter has changed from boolean to string
- (now specifying the parse-this-file-as-this format, like 'mp3',
- but also can be FALSE to mean don't assume any format, auto-detect
- only), and a third parameter (array containing allowed formats)
- has been added. The assumedFormat parameter allows a file to be
- forced to be parsed as a certain format rather than relying on the
- auto-detection of getID3() (ex: an MP3 wrapped in a RIFF/WAV
- header will be auto-detected as RIFF/WAV, but if forced to parse
- as MP3 will extract the original MP3 information)
- (thanks reel_tazØusers*sourceforge*net)
- * Bugfix: ID3v2FrameIsAllowed() wasn't behaving properly if the
- writing functions were called for more than one file, because of
- the static array not being cleared between uses (thanks yoyo)
- * Bugfix: Lyrics3 data wasn't being properly copied from the ['raw']
- keys to the easy keys (['title'], etc.) (thanks Christian Fritz)
- * Bugfix: some testing code was accidentally left in
- getid3.thumbnail.php (thanks Christian Fritz)
- * Bugfix: RIFF/WAVE files are now more likely to have all their
- chunks parsed.
- * Bugfix: RIFF/WAVE bitrate & playtime now better calculated
- * Bugfix: MP3 scanning for synch doesn't go beyond 64k now, to stop
- intensive scanning through large file that don't have a synch
- (thanks soulcatcherØevilsoft*org for a weird sample file)
- Improved performance when scanning for MP3 synch (about 600% faster
- if the synch is never found)
- ZIP files no longer return the contents of each compressed file, as
- that would very easily be more data than PHP could handle.
- (thanks davidbullockØtech-center*com)
- getid3.check.php now displays entries in a more natural sort order:
- case insensitive, ignores most punctuation, treats accented chars
- the same as their unaccent equivalent (thanks mikeØftl*com)
- Added support for SmartSound-format RIFF files (which are regular
- RIFF/WAVE files with the first 4 chars changed from RIFF to SDSS)
- All instances of while(list() = each()) replaced with foreach()
-
-
-1.4.1b1: [April-11-2002] James Heinrich
- » Parses MIDI files.
- NOTE: very slow at parsing, much slower than any other file type
- NOTE: playtime is generally mostly accurate, but not always 100%
- » Parses ZIP files (if ZZIPlib available, and only in PHP 4.0.7RC1
- and later (see http://www.php.net/manual/en/ref.zip.php)
- NOTE: currently untested as I'm unable to find php_zip.dll for
- PHP/Win32 - if someone has a copy of this file, please email me:
- getid3Øsilisoftware*com
- » Parses JPEG files (requires GD installed)
- » Parses PNG files (requires GD v1.6+ installed)
- » Parses GIF files (requires GD < v1.6 installed)
- » For MP3s, once a valid synch is detected, the next 5 frames are
- also scanned for valid synch signatures, to prevent false
- identification of synch. For corrupt MP3 files this will be a bit
- slower, but hopefully produce more reliable results.
- (Thanks to mpdjØbtinternet*com for bringing this to my attention,
- and xbhoffØpacbell*net for explaining what was happening)
- (Thanks also to macik for helping me with MP3 frame lengths:
- http://66.96.216.160/cgi-bin/YaBB.pl
- ?board=c&action=display&num=1018474068)
- » The actual image data is now displayed (for JPEG, PNG and GIF
- images only) rather than a binary text dump in getid3.check.php
- (specifically table_var_dump()) for APIC frames. Made possible
- by the inclusion of (a modified version of) GetURLImageSize() by
- Filipe Laborde-Basto (www.rezox.com). You can right-click, save-as
- to extract the image to a file.
- NOTE: The actual image data is still returned in ['data']
- ¤ ['image_mime'], ['image_width'], ['image_height'], ['image_bytes']
- are now returned for APICs
- ¤ split parsing functions out into seperate files: lyrics3, id3v1,
- id3v2, mp3, ogg, riff, mpeg, midi, zip
- ¤ ['ogg']['bitrate_ave'] -> ['ogg']['bitrate_nominal'] (thanks to
- stephaneØtekartists*com for pointing out that "nominal" bitrate
- may actually differ significantly from the "average" bitrate)
- The real average bitrate seems to be only extractable by parsing
- the entire file and calculating the average bitrate. This is not
- yet an option, but hopefully in a future version of getID3()
- ¤ ['filename'] now returned for all files
- ¤ ['ogg']['date'] and ['ogg']['description'] now returned when
- available (thanks stephaneØtekartists*com)
- ¤ ['mpeg']['audio']['crc'] now contains the CRC (if present)
- ¤ ['bitrate'] is now returned as a double instead of an int
- ¤ ['dataoffset'] is now returned for all ID3v2 frames
- * Bugfix: MP3 CRC presence ['mpeg']['audio']['protection'] was being
- reported as opposite of what it actually should be
- * Bugfix: MPEG videos weren't being detected (they were being
- parsed as MP3), and even if they were, there was a typo in
- getMPEGHeaderFilepointer() (thanks Christian Fritz)
- * Bugfix: getid3.functions.php wasn't being included in
- getid3.write.php (thanks mikeØftl*com)
- * Bugfix: Browse:___ directory name in getid3.check.php wasn't
- correct with directory names with ' and other strange characters
- (thanks Christian Fritz)
- ID3v2FrameProcessing() now checks to see if the next frame is valid
- after it encounters an invalid FrameID, and if the next frameID
- appears valid, it will just skip the current (invalid) frame and
- continue processing (it would previously abort at the first sign
- of incorrect structure) (thanks stephaneØtekartists*com)
- getid3.check.php now scans filetypes based on content, not filename
- extension, and shows the filetype in the displayed output. Files
- are only scanned as MP3 if ID3v2 or MPEG-audio signatures are at
- the immediate beginning of the file (MP3 used to be the default
- format), so a corrupt file may not show up as MP3 format in the
- browse screen, but in detail it will scan in-depth
- getid3.check.php now has columns to show the presence of ID3v1,
- ID3v2 and Lyrics3 content
- Helium2 (www.helium2.com) has been known to write ID3v2.4 tags with
- non-synchsafe-integer framesizes, getID3() now checks for this and
- will override and parse the tag as ID3v2.3 if the tag would parse
- fine as ID3v2.3 when it's really specified as ID3v2.4 (thanks
- Christian Fritz for the test files)
-
-
-1.4.0b9: [April-05-2002] James Heinrich
- » Ogg files now return bitrate and playtime (playtime calculated
- from nominal bitrate and filesize, so it's only approximately
- accurate). (thanks stephaneØtekartists*com for the idea)
- * Bugfix: ID3v1 tags were not properly being parsed - track, genre
- and comment fields were incorrect. (thanks Christian Fritz)
- * Bugfix: getid3.check.php would not browse directories with single
- quotes (') or double quotes (") in the directory name.
- (thanks Christian Fritz)
- * Bugfix: Improved detection of MPEG-video files (a sample MP3 file
- had a false MPEG video signature at the beginning), and the MPEG-
- video parsing function now only looks for the MPEG-video header
- in the first 100k bytes of the file, to prevent needlessly
- scanning very large files. Also will not infinitely loop if it
- does not find what it's looking for. (thanks Christian Fritz)
- ['error'] now returned if MP3 synch doesn't occur at beginning of
- file if ID3v2 not used (ie there's some kind of padding there that
- should not be)
- Reduced use of fread() in getMPEGHeaderFilepointer() (now faster)
- Added "file parsed in x.xxx seconds" to getid3.check.php
- Added "browse: <directory>" link to getid3.check.php
- Changed default ID3v2 majorversion from 2.4 to 2.3 in
- getid3.write.php because Winamp (and probably many other
- ID3v2-aware tools) can only read up to ID3v2.3
- (thanks mikeØftl*com)
-
-
-1.4.0b8: [April-04-2002] James Heinrich
- » Lyrics3 support added (thanks Christian Fritz for the idea)
- ¤ check.php renamed to getid3.check.php
- ¤ write.php renamed to getid3.write.php
- ¤ ['id3']['id3v2']['error'] (if present) now reported in ['error']
- ¤ ['mpeg']['audio']['error'] (if present) now reported in ['error']
- * Bugfix: RoughTranslateUnicodeToASCII() was completely mangling
- UTF-16/UTF-16BE encoded text
- * Bugfix: The warning about MP3ext wasn't always showing up
- (thanks davidbullockØtech-center*com)
- getID3v1Filepointer() cleaned up & shortened
- Moved the include_once() statements around so that a minimum of code
- is included
-
-
-1.4.0b7: [April-03-2002] James Heinrich
- » RIFFs (specifically AVIs) are now more completely parsed,
- almost everything in the returned ['RIFF'] array has been moved
- around and/or restructured. A lot of new data is in there too -
- codecs, frame size, etc.
- ¤ Better recursive parsing of RIFFs (sub-arrays are now in the right
- place)
- * Bugfix: the isset() idea introduced in beta 5 was incorrectly
- implemented, such that ['asciidata'] and ['asciidescription'] were
- never returned - this had the side effect that ID3v2 comments were
- not copied to ['id3']['id3v2']['comment'] (thanks mikeØftl*com)
- * Bugfix: MPEG audio synch wasn't being detected, and therefore MPEG
- audio data not parsed, if no ID3v2 header present in an MP3
- ID3v1 track number only returned if greater than zero
- Removed !== FALSE (introduced in 1.4.0b6) from while(fread()) loops,
- some users were reporting problems with that syntax.
- Changed substr($string, 0, 1) to $string{0} syntax in most files
- Reformatted changelog.txt to 72-column width
-
-
-1.4.0b6: [April-01-2002] James Heinrich
- * Bugfix: 1.4.0b5 introduced a bug where any RIFF file other than
- PCM WAVE (this includes any compressed WAV, as well as all AVIs)
- would crash getID3()
- Reduced use of fread() in getOggHeaderFilepointer() for increased
- speed
- Added constant FREAD_BUFFER_SIZE for many fread() operations
- Added !== FALSE check to while(fread()) loops
- (thanks davidbullockØtech-center*com)
- Added more entries to RIFFwFormatTagLookup()
- (still looking for a good complete list)
- Converted use of hexdec() in getid3.lookup.php to 0x1234 notation
-
-
-1.4.0b5: [March-28-2002] James Heinrich
- ¤ Renamed decodeheader() to decodeMPEGaudioHeader()
- * Bugfix: Fixed infinite loop problem for RIFF/WAV files with
- unknown chunks
- * Bugfix: WXXX frames were incorrectly writing from ['URL'] instead
- of ['url']
- * Bugfix: RoughTranslateUnicodeToASCII() wasn't properly decoding
- UTF-16/UTF-16BE
- Changed all quoted strings from " to ' to hopefully improve speed
- (although benchmarks have not yet shown any significant
- improvement in speed) (thanks davidbullockØtech-center*com)
- Improved code in check.php for dealing with symbolic links
- (thanks davidbullockØtech-center*com)
- Changed '<?' tags to '<?php' (thanks davidbullockØtech-center*com)
- Added processing time indicator in check.php
- (ie 'directory scanned in 2.45 seconds')
- Replaced all instances of feof() to prevent infinite loop conditions
- Moved lookup portions of decodeMPEGaudioHeader() to
- getid3.lookup.php
- Replaced $arrayname[$index] with $arrayname["$index"] to avoid PHP
- E_NOTICEs (thanks davidbullockØtech-center*com)
- Wrapped isset() around many if statements, to avoid PHP E_NOTICEs,
- hence improve speed (up to 30x speed improvement reported in some
- cases :)
-
-
-1.4.0b4: [March-26-2002] James Heinrich
- ¤ RIFF/WAV file format now parsed, returned under ['riff']
- ¤ Support for Relative Gain Adjustment in RIFF/WAV files
- ¤ ['channels'] (1 or 2) now returned for MP3 and WAV files
- ¤ ['bitrate'] now returned (in bits-per-second) at root level for
- MP3 and WAV files
- Added support for RGAD (Relative Gain ADjustment) ID3v2 frames, both
- reading & writing
- (see http://privatewww.essex.ac.uk/~djmrob/replaygain/ for details
- on RGAD) (thanks Christian Fritz for the idea)
- Removed some test data-dumping from the ID3v2 writing functions
- Language code 'XXX' now returns descriptive string 'unknown' instead
- of NULL
- Seperated out comments from top of getid3.php into getid3.readme.txt
- and changelog.txt
- Split out non-lookup functions from getid3.lookup.php to
- getid3.functions.php
-
-
-1.4.0b3: [March-25-2002] James Heinrich
- ¤ ['asciidata'] for WXXX frames now returns correct information, but
- under ['asciidescription'] (thanks Christian Fritz)
- ¤ Added ['framenamelong'] to all returned frame data arrays with
- text description of that frame (ie 'RVA2' would return 'Relative
- volume adjustment (2)') (thanks Christian Fritz)
- ¤ ['datalength'] is now ['indexeddatalength'] in ASPI frames (was
- confliciting with the all-frames ['datalength'] as introduced in
- v1.4.0b1
- ¤ ['datalength'] now returned as integer (rather than double) where
- possible
-
-
-1.4.0b2: [March-21-2002] James Heinrich
- ¤ ['mpeg']['audio']['bitrate'] now returned as int rather than
- double for VBR files
- * Bugfix: MPEG audio information wasn't being parsed on files that
- had neither ID3v1 or ID3v2
- * Bugfix: COMM/WXXX frames weren't returning 'asciidata' in
- ID3v2.2, which also meant the ['id3']['id3v2']['comment'] field
- wasn't being returned (thanks stephaneØtekartists*com)
- * Bugfix: file might not be found if filename actually contains
- escaped chars or %xx-formatted characters
- (thanks reel_tazØusers*sourceforge*net)
- Added support for running with Register Globals turned off
- (thanks reel_tazØusers*sourceforge*net)
- Added urlencode() where needed in check.php
- (thanks reel_tazØusers*sourceforge*net)
- Fixed IE buffering/display problem in progress counter in check.php
-
-
-1.4.0b1: [March-11-2002] James Heinrich
- » ID3v2 writing support via WriteID3v2() in putid3.php
- RemoveID3v2() and RemoveID3v1() functions now available in
- putid3.php All ID3v1 and ID3v2 writing functions have been moved
- to putid3.php and example file write.php has been added to the
- distribution
- ¤ MPEG audio frame information (bitrate, frequency, etc) now
- returned inside ['mpeg']['audio'] instead of just ['mpeg']
- ¤ MPEG video information now parsed, returned in ['mpeg']['video']
- Note: audio portion of video system files is not yet being parsed
- ¤ All flag bits are now returned as boolean rather than int or
- string
- ¤ RVA2 data now returned as an array (multiple RVA2 tags are
- allowed)
- ¤ RVA2/EQU2 description returned under ['description'] rather than
- ['identification']
- ¤ RVAD/EQUA adjustments now returned as signed integers, rather than
- absolute values which required you to check flag bytes
- ¤ RVRB/REV data no longer returns under ['reverb'] array
- ¤ WXXX/W???/LINK frames now return ['url'] instead of ['URL']
- ¤ USER now properly returns both ['language'] and ['languagename']
- ¤ OWNE now returns ['purchasedateunix'] as a UNIX timestamp
- (only if ['purchasedate'] is a valid date)
- ¤ ['id3']['id3v2']['padding'] now returned with information on padding
- ¤ ['headerlength'] now includes the initial 6 or 10 bytes of the
- ID3v2 header
- ¤ ['artist'], ['title'], ['album'], ['tracknumber'], ['genre'] now
- returned for easier access for Ogg files
- ¤ added ['datalength'] to all ID3v2 frames: length of frame data,
- not including frame header
- ¤ ['fileformat'] now returns 'id3' if there are ID3v1 or ID3v2 tags
- but no audio data
- ¤ ['fileformat'] now returns 'mpg' if it's an MPEG system (video +
- audio) file
- * Bugfix: RVAD was being parsed incorrectly
- * Bugfix: ['currency'] and ['purchasedate'] now correctly returned
- in OWNE
- * Bugfix: Frequncies in 'EQU2' frames were incorrectly double
- * Bugfix: ['bytedeviation'] and ['msdeviation'] now properly
- returned as integer rather than binary string for 'MLLT' frames
- * Bugfix: ['filename'] now properly returned for 'GEOB' frames
- * Bugfix: ['imagetype'] now properly returned for 'PIC' frames in
- ID3v2.2
- * Bugfix: Genre not being written if not set in WriteID3v1()
- (thanks reel_tazØusers*sourceforge*net)
- * Bugfix: Changed write mode to 'r+b' from 'a+' because ID3v1 tags
- were being appended instead of overwritten if they already existed
- (thanks reel_tazØusers*sourceforge*net)
- * Bugfix: open would fail on filenames containing quotes
- (thanks javierØcrackdealer*com)
- * Bugfix: various values were incorrectly returned (unneeded ord())
- in these frames: COMR, USER, ENCR, GRID, PRIV, SIGN
- * Bugfix: ASPI ['bitsperpoint'] was not correctly returned
- * Bugfix: RoughTranslateUnicodeToASCII() was not returning the last
- char for UTF-16
- * Bugfix: ['audiobytes'] now correctly 0 if no synch found
- * Bugfix: GenreLookup was incorrectly returning 'Remix' instead of
- 'Blues' for GenreID 0
- Added sample directory browser to check.php
- Seperated out MPEGaudio-parsing functionality into
- getOnlyMPEGaudioInfo() which may be called directly if you don't
- need any ID3 parsing (thanks djpretzelØcox*rr*com for idea)
- Reduced use of fread() for increased performance in
- getID3v1Filepointer()
- Added clearstatcache() before checking filesize - size after writing
- tag now correct
- Added hack for mp3Rage (www.chaoticsoftware.com) that puts
- ID3v2.3-formatted MIME type instead of 3-char ID3v2.2-format image
- type (thanks xbhoffØpacbell*net for test file)
-
-
-1.3.2: [February-15-2002] James Heinrich
- ¤ UFID/UFI, USLT/ULT, COMM/COM, APIC/PIC, GEOB/GEO, CRM, RVA2, EQU2,
- POPM/POP, AENC/CRA, ENCR and GRID frame data now returned under
- numeric array index rather than by ownerID
- ¤ RVA2 frame data is now returned keyed by $channeltypeid instead of
- $frame_idstring
- ¤ WXXX/WXX frame description now returned under ['description']
- instead of ['data']
- Trailing null bytes now trimmed from frame (W??? & T???) text data
- (it shouldn't be there to begin with, but a sample file encoded by
- [unknown program] had data padded to 50 chars with null bytes,
- which caused ParseID3v2GenreString() to freeze).
-
-
-1.3.1: [February-13-2002] James Heinrich
- * Bugfix: ['playtime_seconds'] and ['playtime_string'] were not
- being returned
- * Bugfix: ['fileformat'] was incorrectly being returned as a
- 2-element array
- * Bugfix: USLT wasn't being correctly parsed
- Improved RoughTranslateUnicodeToASCII()
- (thanks reel_tazØusers*sourceforge*net for Unicode test file)
-
-
-1.3.0: [February-13-2002] James Heinrich
- » ID3v1 writing support via WriteID3v1()
- ¤ MPEG audio frame information (bitrate, frequency, etc) now
- returned inside ['mpeg']
- ¤ ['mpeg']['raw'] returns the integer values of the bits for MPEG
- audio information as returned in ['mpeg'] by decodeheader()
- (thanks reel_tazØusers*sourceforge*net)
- ¤ 'protection', 'padding', 'private', 'copyright' and 'original' now
- return as boolean
- ¤ 'bitrate' and 'frequency' now return as int (except in special
- case of 'free')
- Language name as well as code retured where appropriate
- (ie 'English' and 'eng')
- Text frames with invalid TextEncoding value are now passed through
- anyway
- ID3v1 data (title, artist, album, year, comment) is now trimmed
- (no more nulls)
- RoughTranslateUnicodeToASCII() now uses utf8_decode() for UTF-8
-
-
-1.2.5: [January-30-2002] James Heinrich
- * Bugfix: Playtime calculations for VBR files were off slightly
- (rounding error)
- * Bugfix: Extended header length was incorrectly calculated
- * Bugfix: Genre strings such as '03' weren't being handled correctly
- More complete support for ID3v2.3 FrameIDs
- Split out getid3.frames.php (FrameID-specific parsing function)
- Split out getid3.lookup.php (assorted lookup-table functions)
- Searches for what directory getid3.*.php support files are in (must
- be same as getid3.php, but doesn't have to be same as main file -
- for example your main file could be /index.php, but including
- /lib/getid3/getid3.php)
- Simplified, tweaked, changed and/or eliminated several functions.
-
-
-1.2.4: [January-26-2002] James Heinrich
- » Basic support for reading Ogg-Vorbis comment tags
-
-
-1.2.3: [January-24-2002] James Heinrich
- » ID3v2.2.x 3-char FrameIDs are now fully parsed
- Note: While I've included support for 22 FrameIDs as defined in
- the specs, I don't have test files for all of them. If anyone
- knows of programs that generate any of the untested tags, please
- email getid3Øsilisoftware*com ! Here's what's tested and not:
- Tested: T??, COM
- Untested: UFI, TXX, W??, WXX, IPL, MCI, ETC, MLL, STC, ULT, SLT,
- RVA, EQU, REV, PIC, GEO, CNT, POP, BUF, CRM, CRA, LNK
- table_var_dump() now displays boolean variables as TRUE or FALSE
- table_var_dump() now uses htmlspecialchars() to avoid broken-table
- problems
-
-
-1.2.2: [January-18-2002] James Heinrich
- ¤ Parses ID3v2 genres into ['id3']['id3v2']['genreid'] and
- ['id3']['id3v2']['genrelist'] where appropriate
- (thanks stephaneØtekartists*com for the idea)
- Added ID3v2 genre abbreviations 'RX' (remix) and 'CR' (cover)
-
-
-1.2.1: [January-17-2002] James Heinrich
- * Bugfix: 'mp3' was being returned in ['format'], but 'zip' was
- being returned in ['fileformat'], both are now returned in
- ['fileformat']
- ¤ Splits ['id3']['id3v2']['track'] in the format '5/12' into
- ['track'] = '5' and ['totaltracks'] = '12'
- ¤ Enabled ['id3']['id3v2']['title'] etc for ID3v2.2.x
- (3-char frame names) (thanks stephaneØtekartists*com)
- ¤ Changed v1.?? version number format to v1.?.?
- Scans through the file until it finds the MPEG synch (start of audio
- frame) - some files encoded by LAME 3.91 had undocumented padding
- after the ID3v2 header; getMP3headerFilepointer() now scans until
- it finds synch (or EOF) (thanks adamØtrekjapan*com)
- Improved Unicode conversion in RoughTranslateUnicodeToASCII()
-
-
-1.20: [January-15-2002] James Heinrich
- » Support for variable-bitrate (VBR) files, both Xing and Fraunhofer
- headers
- » All 4-character FrameIDs are now fully parsed according to the
- specs at http://www.id3.org/id3v2.4.0-frames.txt
- ¤ This means that most no longer return ['flags'] and ['data']
- Note: While I've included support for 30 FrameIDs as defined in
- the specs, I don't have test files for all of them. If anyone
- knows of programs that generate any of the untested tags, please
- email getid3Øsilisoftware*com ! Here's what's tested and not:
- Tested: UFID, T???, WXXX, USLT, SYLT, COMM, APIC, GEOB
- Untested: TXXX, W???, MCDI, ETCO, MLLT, SYTC, RVA2, EQU2, RVRB,
- PCNT, POPM, RBUF, AENC, USER, OWNE, COMR, ENCR, GRID,
- PRIV, SIGN, SEEK, ASPI
- ¤ Added 'title', 'artist', etc names to ID3v2 data (easier to access
- than the 4-character FrameIDs of the ID3v2 standard)
- (thanks jaksonØgmx.net)
- * Bugfix: added fclose() at end of GetAllMP3Info()
- (thanks stephaneØtekartists*com)
- * Bugfix: ID3v1 wasn't being parsed if ID3v2 wasn't present
- (thanks jaksonØgmx.net)
- * Bugfix: several flags were being parsed incorrectly (the structure
- had changed from ID3v2.3 to ID3v2.4) - v2.3 flags were being
- incorrectly parsed
- Much more compact implementation of decodeheader()
- (thanks jaksonØgmx.net for the idea)
- ID3v1 genres 126 through 147 (thanks jaksonØgmx.net)
- New table_var_dump() function in check.php
- (based partially on idea by jaksonØgmx.net)
- Seperated ID3v1 retrieval into seperate function
-
-
-1.11: [December-23-2001] James Heinrich
- All functions merged into file getid3.php
- Updated documentation to reflect new returned information
-
-
-1.10: [December-20-2001] James Heinrich
- * Bugfix: ID3v1 Track# was incorrectly being parsed whether it
- existed or not
- Changed calling procedure to recommend using
- GetAllMP3info($filename) from getmp3header.php
- Now includes check.php - example file
- ¤ Checks to see if file is in ZIP or MP3 format
- (returned in ['format'])
- [Ed. Note: ['fileformat'] as of v1.2.1]
-
-
-1.06: [November-05-2001] James Heinrich
- * Bugfix: ID3v2.2.x frames weren't being parsed since they use
- 6-byte rather than 10-byte headers as v2.3+ does
- (thanks spunkØmac*com for pointing that out)
-
-
-1.05: [September-06-2001] James Heinrich
- * Bugfix: ID3v2 was being parsed even if it didn't exist
-
-
-1.04: [July-16-2001] James Heinrich
- * Bugfix: typo in Extended Header section (strpad() should be
- str_pad()) (thanks jurroonØyahoo*com)
-
-
-1.03: [May-07-2001] James Heinrich
- * Bugfix: Added missing ['id3']['id3v1']['genreid'] and
- ['id3']['id3v1']['genre']
-
-
-1.02: [May-05-2001] James Heinrich
- ¤ Added ['getID3version']
-
-
-1.01: [May-04-2001] James Heinrich
- » Added support for frame-level de-unsynchronisation (as per
- ID3v2.4.0 specs) in addition to ID3v2.3.x tag-level
- de-unsynchronisation
-
-
-1.00: [May-04-2001] James Heinrich
- » Initial public release
-
diff --git a/apps/media/getID3/dependencies.txt b/apps/media/getID3/dependencies.txt
deleted file mode 100644
index 34a72ba8652..00000000000
--- a/apps/media/getID3/dependencies.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// dependencies.txt - part of getID3() //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-lyrics3 depends on apetag (optional)
-ogg depends on flac
-id3v2 depends on id3v1
-apetag depends on id3v1 (optional, writing only)
-bonk depends on id3v2 (optional)
-riff depends on mp3
-mpeg depends on mp3
-quicktime depends on mp3
-flac depends on ogg
-optimfrog depends on riff
-la depends on riff
-lpac depends on riff
-asf depends on riff, id3v1 (optional)
diff --git a/apps/media/getID3/getid3/module.audio-video.bink.php b/apps/media/getID3/getid3/module.audio-video.bink.php
deleted file mode 100644
index 2ebc6fe797c..00000000000
--- a/apps/media/getID3/getid3/module.audio-video.bink.php
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.bink.php //
-// module for analyzing Bink or Smacker audio-video files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_bink
-{
-
- function getid3_bink(&$fd, &$ThisFileInfo) {
-
-$ThisFileInfo['error'][] = 'Bink / Smacker files not properly processed by this version of getID3()';
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $fileTypeID = fread($fd, 3);
- switch ($fileTypeID) {
- case 'BIK':
- return $this->ParseBink($fd, $ThisFileInfo);
- break;
-
- case 'SMK':
- return $this->ParseSmacker($fd, $ThisFileInfo);
- break;
-
- default:
- $ThisFileInfo['error'][] = 'Expecting "BIK" or "SMK" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$fileTypeID.'"';
- return false;
- break;
- }
-
- return true;
-
- }
-
- function ParseBink(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'bink';
- $ThisFileInfo['video']['dataformat'] = 'bink';
-
- $fileData = 'BIK'.fread($fd, 13);
-
- $ThisFileInfo['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
- $ThisFileInfo['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
-
- if (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) != ($ThisFileInfo['bink']['data_size'] + 8)) {
- $ThisFileInfo['error'][] = 'Probably truncated file: expecting '.$ThisFileInfo['bink']['data_size'].' bytes, found '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']);
- }
-
- return true;
- }
-
- function ParseSmacker(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'smacker';
- $ThisFileInfo['video']['dataformat'] = 'smacker';
-
- return false;
- }
-
-}
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio-video.flv.php b/apps/media/getID3/getid3/module.audio-video.flv.php
deleted file mode 100644
index 69c48c1b31f..00000000000
--- a/apps/media/getID3/getid3/module.audio-video.flv.php
+++ /dev/null
@@ -1,505 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-// //
-// FLV module by Seth Kaufman <seth@whirl-i-gig.com> //
-// //
-// * version 0.1 (26 June 2005) //
-// //
-// minor modifications by James Heinrich <info@getid3.org> //
-// * version 0.1.1 (15 July 2005) //
-// //
-// Support for On2 VP6 codec and meta information //
-// by Steve Webster <steve.webster@featurecreep.com> //
-// * version 0.2 (22 February 2006) //
-// //
-// Modified to not read entire file into memory //
-// by James Heinrich <info@getid3.org> //
-// * version 0.3 (15 June 2006) //
-// //
-// Bugfixes for incorrectly parsed FLV dimensions //
-// and incorrect parsing of onMetaTag //
-// by Evgeny Moysevich <moysevich@gmail.com> //
-// * version 0.4 (07 December 2007) //
-// //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio-video.flv.php //
-// module for analyzing Shockwave Flash Video files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-define('GETID3_FLV_TAG_AUDIO', 8);
-define('GETID3_FLV_TAG_VIDEO', 9);
-define('GETID3_FLV_TAG_META', 18);
-
-define('GETID3_FLV_VIDEO_H263', 2);
-define('GETID3_FLV_VIDEO_SCREEN', 3);
-define('GETID3_FLV_VIDEO_VP6', 4);
-
-class getid3_flv
-{
-
- function getid3_flv(&$fd, &$ThisFileInfo, $ReturnAllTagData=false) {
-//$start_time = microtime(true);
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
-
- $FLVdataLength = $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'];
- $FLVheader = fread($fd, 5);
-
- $ThisFileInfo['fileformat'] = 'flv';
- $ThisFileInfo['flv']['header']['signature'] = substr($FLVheader, 0, 3);
- $ThisFileInfo['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
- $TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));
-
- if ($ThisFileInfo['flv']['header']['signature'] != 'FLV') {
- $ThisFileInfo['error'][] = 'Expecting "FLV" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$ThisFileInfo['flv']['header']['signature'].'"';
- unset($ThisFileInfo['flv']);
- unset($ThisFileInfo['fileformat']);
- return false;
- }
-
- $ThisFileInfo['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04);
- $ThisFileInfo['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01);
-
- $FrameSizeDataLength = getid3_lib::BigEndian2Int(fread($fd, 4));
- $FLVheaderFrameLength = 9;
- if ($FrameSizeDataLength > $FLVheaderFrameLength) {
- fseek($fd, $FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
- }
-//echo __LINE__.'='.number_format(microtime(true) - $start_time, 3).'<br>';
-
- $Duration = 0;
- $found_video = false;
- $found_audio = false;
- $found_meta = false;
- while ((ftell($fd) + 16) < $ThisFileInfo['avdataend']) {
- $ThisTagHeader = fread($fd, 16);
-
- $PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4));
- $TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1));
- $DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3));
- $Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3));
- $LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1));
- $NextOffset = ftell($fd) - 1 + $DataLength;
- if ($Timestamp > $Duration) {
- $Duration = $Timestamp;
- }
-
-//echo __LINE__.'['.ftell($fd).']=('.$TagType.')='.number_format(microtime(true) - $start_time, 3).'<br>';
-
- switch ($TagType) {
- case GETID3_FLV_TAG_AUDIO:
- if (!$found_audio) {
- $found_audio = true;
- $ThisFileInfo['flv']['audio']['audioFormat'] = $LastHeaderByte & 0x07;
- $ThisFileInfo['flv']['audio']['audioRate'] = ($LastHeaderByte & 0x30) / 0x10;
- $ThisFileInfo['flv']['audio']['audioSampleSize'] = ($LastHeaderByte & 0x40) / 0x40;
- $ThisFileInfo['flv']['audio']['audioType'] = ($LastHeaderByte & 0x80) / 0x80;
- }
- break;
-
- case GETID3_FLV_TAG_VIDEO:
- if (!$found_video) {
- $found_video = true;
- $ThisFileInfo['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07;
-
- $FLVvideoHeader = fread($fd, 11);
-
- if ($ThisFileInfo['flv']['video']['videoCodec'] != GETID3_FLV_VIDEO_VP6) {
-
- $PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 3, 2))) >> 7;
- $PictureSizeType = $PictureSizeType & 0x0007;
- $ThisFileInfo['flv']['header']['videoSizeType'] = $PictureSizeType;
- switch ($PictureSizeType) {
- case 0:
- //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
- //$PictureSizeEnc <<= 1;
- //$ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8;
- //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
- //$PictureSizeEnc <<= 1;
- //$ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8;
-
- $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 2));
- $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
- $PictureSizeEnc['x'] >>= 7;
- $PictureSizeEnc['y'] >>= 7;
- $ThisFileInfo['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFF;
- $ThisFileInfo['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFF;
- break;
-
- case 1:
- $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 3));
- $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 3));
- $PictureSizeEnc['x'] >>= 7;
- $PictureSizeEnc['y'] >>= 7;
- $ThisFileInfo['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFFFF;
- $ThisFileInfo['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFFFF;
- break;
-
- case 2:
- $ThisFileInfo['video']['resolution_x'] = 352;
- $ThisFileInfo['video']['resolution_y'] = 288;
- break;
-
- case 3:
- $ThisFileInfo['video']['resolution_x'] = 176;
- $ThisFileInfo['video']['resolution_y'] = 144;
- break;
-
- case 4:
- $ThisFileInfo['video']['resolution_x'] = 128;
- $ThisFileInfo['video']['resolution_y'] = 96;
- break;
-
- case 5:
- $ThisFileInfo['video']['resolution_x'] = 320;
- $ThisFileInfo['video']['resolution_y'] = 240;
- break;
-
- case 6:
- $ThisFileInfo['video']['resolution_x'] = 160;
- $ThisFileInfo['video']['resolution_y'] = 120;
- break;
-
- default:
- $ThisFileInfo['video']['resolution_x'] = 0;
- $ThisFileInfo['video']['resolution_y'] = 0;
- break;
-
- }
- }
- }
- break;
-
- // Meta tag
- case GETID3_FLV_TAG_META:
- if (!$found_meta) {
- $found_meta = true;
- fseek($fd, -1, SEEK_CUR);
- $reader = new AMFReader(new AMFStream(fread($fd, $DataLength)));
- $eventName = $reader->readData();
- $ThisFileInfo['meta'][$eventName] = $reader->readData();
- unset($reader);
-
- $ThisFileInfo['video']['frame_rate'] = @$ThisFileInfo['meta']['onMetaData']['framerate'];
- $ThisFileInfo['video']['resolution_x'] = @$ThisFileInfo['meta']['onMetaData']['width'];
- $ThisFileInfo['video']['resolution_y'] = @$ThisFileInfo['meta']['onMetaData']['height'];
- }
- break;
-
- default:
- // noop
- break;
- }
-
- fseek($fd, $NextOffset, SEEK_SET);
- }
-
- if ($ThisFileInfo['playtime_seconds'] = $Duration / 1000) {
- $ThisFileInfo['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) / $ThisFileInfo['playtime_seconds'];
- }
-
- if ($ThisFileInfo['flv']['header']['hasAudio']) {
- $ThisFileInfo['audio']['codec'] = $this->FLVaudioFormat($ThisFileInfo['flv']['audio']['audioFormat']);
- $ThisFileInfo['audio']['sample_rate'] = $this->FLVaudioRate($ThisFileInfo['flv']['audio']['audioRate']);
- $ThisFileInfo['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($ThisFileInfo['flv']['audio']['audioSampleSize']);
-
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['flv']['audio']['audioType'] + 1; // 0=mono,1=stereo
- $ThisFileInfo['audio']['lossless'] = ($ThisFileInfo['flv']['audio']['audioFormat'] ? false : true); // 0=uncompressed
- $ThisFileInfo['audio']['dataformat'] = 'flv';
- }
- if (@$ThisFileInfo['flv']['header']['hasVideo']) {
- $ThisFileInfo['video']['codec'] = $this->FLVvideoCodec($ThisFileInfo['flv']['video']['videoCodec']);
- $ThisFileInfo['video']['dataformat'] = 'flv';
- $ThisFileInfo['video']['lossless'] = false;
- }
-
- return true;
- }
-
-
- function FLVaudioFormat($id) {
- $FLVaudioFormat = array(
- 0 => 'uncompressed',
- 1 => 'ADPCM',
- 2 => 'mp3',
- 5 => 'Nellymoser 8kHz mono',
- 6 => 'Nellymoser',
- );
- return (@$FLVaudioFormat[$id] ? @$FLVaudioFormat[$id] : false);
- }
-
- function FLVaudioRate($id) {
- $FLVaudioRate = array(
- 0 => 5500,
- 1 => 11025,
- 2 => 22050,
- 3 => 44100,
- );
- return (@$FLVaudioRate[$id] ? @$FLVaudioRate[$id] : false);
- }
-
- function FLVaudioBitDepth($id) {
- $FLVaudioBitDepth = array(
- 0 => 8,
- 1 => 16,
- );
- return (@$FLVaudioBitDepth[$id] ? @$FLVaudioBitDepth[$id] : false);
- }
-
- function FLVvideoCodec($id) {
- $FLVvideoCodec = array(
- GETID3_FLV_VIDEO_H263 => 'Sorenson H.263',
- GETID3_FLV_VIDEO_SCREEN => 'Screen video',
- GETID3_FLV_VIDEO_VP6 => 'On2 VP6',
- );
- return (@$FLVvideoCodec[$id] ? @$FLVvideoCodec[$id] : false);
- }
-}
-
-class AMFStream {
- var $bytes;
- var $pos;
-
- function AMFStream(&$bytes) {
- $this->bytes =& $bytes;
- $this->pos = 0;
- }
-
- function readByte() {
- return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
- }
-
- function readInt() {
- return ($this->readByte() << 8) + $this->readByte();
- }
-
- function readLong() {
- return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
- }
-
- function readDouble() {
- return getid3_lib::BigEndian2Float($this->read(8));
- }
-
- function readUTF() {
- $length = $this->readInt();
- return $this->read($length);
- }
-
- function readLongUTF() {
- $length = $this->readLong();
- return $this->read($length);
- }
-
- function read($length) {
- $val = substr($this->bytes, $this->pos, $length);
- $this->pos += $length;
- return $val;
- }
-
- function peekByte() {
- $pos = $this->pos;
- $val = $this->readByte();
- $this->pos = $pos;
- return $val;
- }
-
- function peekInt() {
- $pos = $this->pos;
- $val = $this->readInt();
- $this->pos = $pos;
- return $val;
- }
-
- function peekLong() {
- $pos = $this->pos;
- $val = $this->readLong();
- $this->pos = $pos;
- return $val;
- }
-
- function peekDouble() {
- $pos = $this->pos;
- $val = $this->readDouble();
- $this->pos = $pos;
- return $val;
- }
-
- function peekUTF() {
- $pos = $this->pos;
- $val = $this->readUTF();
- $this->pos = $pos;
- return $val;
- }
-
- function peekLongUTF() {
- $pos = $this->pos;
- $val = $this->readLongUTF();
- $this->pos = $pos;
- return $val;
- }
-}
-
-class AMFReader {
- var $stream;
-
- function AMFReader(&$stream) {
- $this->stream =& $stream;
- }
-
- function readData() {
- $value = null;
-
- $type = $this->stream->readByte();
- switch ($type) {
-
- // Double
- case 0:
- $value = $this->readDouble();
- break;
-
- // Boolean
- case 1:
- $value = $this->readBoolean();
- break;
-
- // String
- case 2:
- $value = $this->readString();
- break;
-
- // Object
- case 3:
- $value = $this->readObject();
- break;
-
- // null
- case 6:
- return null;
- break;
-
- // Mixed array
- case 8:
- $value = $this->readMixedArray();
- break;
-
- // Array
- case 10:
- $value = $this->readArray();
- break;
-
- // Date
- case 11:
- $value = $this->readDate();
- break;
-
- // Long string
- case 13:
- $value = $this->readLongString();
- break;
-
- // XML (handled as string)
- case 15:
- $value = $this->readXML();
- break;
-
- // Typed object (handled as object)
- case 16:
- $value = $this->readTypedObject();
- break;
-
- // Long string
- default:
- $value = '(unknown or unsupported data type)';
- break;
- }
-
- return $value;
- }
-
- function readDouble() {
- return $this->stream->readDouble();
- }
-
- function readBoolean() {
- return $this->stream->readByte() == 1;
- }
-
- function readString() {
- return $this->stream->readUTF();
- }
-
- function readObject() {
- // Get highest numerical index - ignored
-// $highestIndex = $this->stream->readLong();
-
- $data = array();
-
- while ($key = $this->stream->readUTF()) {
- $data[$key] = $this->readData();
- }
- // Mixed array record ends with empty string (0x00 0x00) and 0x09
- if (($key == '') && ($this->stream->peekByte() == 0x09)) {
- // Consume byte
- $this->stream->readByte();
- }
- return $data;
- }
-
- function readMixedArray() {
- // Get highest numerical index - ignored
- $highestIndex = $this->stream->readLong();
-
- $data = array();
-
- while ($key = $this->stream->readUTF()) {
- if (is_numeric($key)) {
- $key = (float) $key;
- }
- $data[$key] = $this->readData();
- }
- // Mixed array record ends with empty string (0x00 0x00) and 0x09
- if (($key == '') && ($this->stream->peekByte() == 0x09)) {
- // Consume byte
- $this->stream->readByte();
- }
-
- return $data;
- }
-
- function readArray() {
- $length = $this->stream->readLong();
- $data = array();
-
- for ($i = 0; $i < $length; $i++) {
- $data[] = $this->readData();
- }
- return $data;
- }
-
- function readDate() {
- $timestamp = $this->stream->readDouble();
- $timezone = $this->stream->readInt();
- return $timestamp;
- }
-
- function readLongString() {
- return $this->stream->readLongUTF();
- }
-
- function readXML() {
- return $this->stream->readLongUTF();
- }
-
- function readTypedObject() {
- $className = $this->stream->readUTF();
- return $this->readObject();
- }
-}
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio-video.nsv.php b/apps/media/getID3/getid3/module.audio-video.nsv.php
deleted file mode 100644
index dab03389b57..00000000000
--- a/apps/media/getID3/getid3/module.audio-video.nsv.php
+++ /dev/null
@@ -1,224 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.nsv.php //
-// module for analyzing Nullsoft NSV files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_nsv
-{
-
- function getid3_nsv(&$fd, &$ThisFileInfo) {
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $NSVheader = fread($fd, 4);
-
- switch ($NSVheader) {
- case 'NSVs':
- if ($this->getNSVsHeaderFilepointer($fd, $ThisFileInfo, 0)) {
- $ThisFileInfo['fileformat'] = 'nsv';
- $ThisFileInfo['audio']['dataformat'] = 'nsv';
- $ThisFileInfo['video']['dataformat'] = 'nsv';
- $ThisFileInfo['audio']['lossless'] = false;
- $ThisFileInfo['video']['lossless'] = false;
- }
- break;
-
- case 'NSVf':
- if ($this->getNSVfHeaderFilepointer($fd, $ThisFileInfo, 0)) {
- $ThisFileInfo['fileformat'] = 'nsv';
- $ThisFileInfo['audio']['dataformat'] = 'nsv';
- $ThisFileInfo['video']['dataformat'] = 'nsv';
- $ThisFileInfo['audio']['lossless'] = false;
- $ThisFileInfo['video']['lossless'] = false;
- $this->getNSVsHeaderFilepointer($fd, $ThisFileInfo, $ThisFileInfo['nsv']['NSVf']['header_length']);
- }
- break;
-
- default:
- $ThisFileInfo['error'][] = 'Expecting "NSVs" or "NSVf" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$NSVheader.'"';
- return false;
- break;
- }
-
- if (!isset($ThisFileInfo['nsv']['NSVf'])) {
- $ThisFileInfo['warning'][] = 'NSVf header not present - cannot calculate playtime or bitrate';
- }
-
- return true;
- }
-
- function getNSVsHeaderFilepointer(&$fd, &$ThisFileInfo, $fileoffset) {
- fseek($fd, $fileoffset, SEEK_SET);
- $NSVsheader = fread($fd, 28);
- $offset = 0;
-
- $ThisFileInfo['nsv']['NSVs']['identifier'] = substr($NSVsheader, $offset, 4);
- $offset += 4;
-
- if ($ThisFileInfo['nsv']['NSVs']['identifier'] != 'NSVs') {
- $ThisFileInfo['error'][] = 'expected "NSVs" at offset ('.$fileoffset.'), found "'.$ThisFileInfo['nsv']['NSVs']['identifier'].'" instead';
- unset($ThisFileInfo['nsv']['NSVs']);
- return false;
- }
-
- $ThisFileInfo['nsv']['NSVs']['offset'] = $fileoffset;
-
- $ThisFileInfo['nsv']['NSVs']['video_codec'] = substr($NSVsheader, $offset, 4);
- $offset += 4;
- $ThisFileInfo['nsv']['NSVs']['audio_codec'] = substr($NSVsheader, $offset, 4);
- $offset += 4;
- $ThisFileInfo['nsv']['NSVs']['resolution_x'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
- $offset += 2;
- $ThisFileInfo['nsv']['NSVs']['resolution_y'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
- $offset += 2;
-
- $ThisFileInfo['nsv']['NSVs']['framerate_index'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$ThisFileInfo['nsv']['NSVs']['unknown1b'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$ThisFileInfo['nsv']['NSVs']['unknown1c'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$ThisFileInfo['nsv']['NSVs']['unknown1d'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$ThisFileInfo['nsv']['NSVs']['unknown2a'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$ThisFileInfo['nsv']['NSVs']['unknown2b'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$ThisFileInfo['nsv']['NSVs']['unknown2c'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$ThisFileInfo['nsv']['NSVs']['unknown2d'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
-
- switch ($ThisFileInfo['nsv']['NSVs']['audio_codec']) {
- case 'PCM ':
- $ThisFileInfo['nsv']['NSVs']['bits_channel'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- $ThisFileInfo['nsv']['NSVs']['channels'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- $ThisFileInfo['nsv']['NSVs']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
- $offset += 2;
-
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['nsv']['NSVs']['sample_rate'];
- break;
-
- case 'MP3 ':
- case 'NONE':
- default:
- //$ThisFileInfo['nsv']['NSVs']['unknown3'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 4));
- $offset += 4;
- break;
- }
-
- $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['nsv']['NSVs']['resolution_x'];
- $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['nsv']['NSVs']['resolution_y'];
- $ThisFileInfo['nsv']['NSVs']['frame_rate'] = $this->NSVframerateLookup($ThisFileInfo['nsv']['NSVs']['framerate_index']);
- $ThisFileInfo['video']['frame_rate'] = $ThisFileInfo['nsv']['NSVs']['frame_rate'];
- $ThisFileInfo['video']['bits_per_sample'] = 24;
- $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
-
- return true;
- }
-
- function getNSVfHeaderFilepointer(&$fd, &$ThisFileInfo, $fileoffset, $getTOCoffsets=false) {
- fseek($fd, $fileoffset, SEEK_SET);
- $NSVfheader = fread($fd, 28);
- $offset = 0;
-
- $ThisFileInfo['nsv']['NSVf']['identifier'] = substr($NSVfheader, $offset, 4);
- $offset += 4;
-
- if ($ThisFileInfo['nsv']['NSVf']['identifier'] != 'NSVf') {
- $ThisFileInfo['error'][] = 'expected "NSVf" at offset ('.$fileoffset.'), found "'.$ThisFileInfo['nsv']['NSVf']['identifier'].'" instead';
- unset($ThisFileInfo['nsv']['NSVf']);
- return false;
- }
-
- $ThisFileInfo['nsv']['NSVs']['offset'] = $fileoffset;
-
- $ThisFileInfo['nsv']['NSVf']['header_length'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
- $ThisFileInfo['nsv']['NSVf']['file_size'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
-
- if ($ThisFileInfo['nsv']['NSVf']['file_size'] > $ThisFileInfo['avdataend']) {
- $ThisFileInfo['warning'][] = 'truncated file - NSVf header indicates '.$ThisFileInfo['nsv']['NSVf']['file_size'].' bytes, file actually '.$ThisFileInfo['avdataend'].' bytes';
- }
-
- $ThisFileInfo['nsv']['NSVf']['playtime_ms'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
- $ThisFileInfo['nsv']['NSVf']['meta_size'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
- $ThisFileInfo['nsv']['NSVf']['TOC_entries_1'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
- $ThisFileInfo['nsv']['NSVf']['TOC_entries_2'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
-
- if ($ThisFileInfo['nsv']['NSVf']['playtime_ms'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt NSV file: NSVf.playtime_ms == zero';
- return false;
- }
-
- $NSVfheader .= fread($fd, $ThisFileInfo['nsv']['NSVf']['meta_size'] + (4 * $ThisFileInfo['nsv']['NSVf']['TOC_entries_1']) + (4 * $ThisFileInfo['nsv']['NSVf']['TOC_entries_2']));
- $NSVfheaderlength = strlen($NSVfheader);
- $ThisFileInfo['nsv']['NSVf']['metadata'] = substr($NSVfheader, $offset, $ThisFileInfo['nsv']['NSVf']['meta_size']);
- $offset += $ThisFileInfo['nsv']['NSVf']['meta_size'];
-
- if ($getTOCoffsets) {
- $TOCcounter = 0;
- while ($TOCcounter < $ThisFileInfo['nsv']['NSVf']['TOC_entries_1']) {
- if ($TOCcounter < $ThisFileInfo['nsv']['NSVf']['TOC_entries_1']) {
- $ThisFileInfo['nsv']['NSVf']['TOC_1'][$TOCcounter] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
- $TOCcounter++;
- }
- }
- }
-
- if (trim($ThisFileInfo['nsv']['NSVf']['metadata']) != '') {
- $ThisFileInfo['nsv']['NSVf']['metadata'] = str_replace('`', "\x01", $ThisFileInfo['nsv']['NSVf']['metadata']);
- $CommentPairArray = explode("\x01".' ', $ThisFileInfo['nsv']['NSVf']['metadata']);
- foreach ($CommentPairArray as $CommentPair) {
- if (strstr($CommentPair, '='."\x01")) {
- list($key, $value) = explode('='."\x01", $CommentPair, 2);
- $ThisFileInfo['nsv']['comments'][strtolower($key)][] = trim(str_replace("\x01", '', $value));
- }
- }
- }
-
- $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['nsv']['NSVf']['playtime_ms'] / 1000;
- $ThisFileInfo['bitrate'] = ($ThisFileInfo['nsv']['NSVf']['file_size'] * 8) / $ThisFileInfo['playtime_seconds'];
-
- return true;
- }
-
-
- function NSVframerateLookup($framerateindex) {
- if ($framerateindex <= 127) {
- return (float) $framerateindex;
- }
-
- static $NSVframerateLookup = array();
- if (empty($NSVframerateLookup)) {
- $NSVframerateLookup[129] = (float) 29.970;
- $NSVframerateLookup[131] = (float) 23.976;
- $NSVframerateLookup[133] = (float) 14.985;
- $NSVframerateLookup[197] = (float) 59.940;
- $NSVframerateLookup[199] = (float) 47.952;
- }
- return (isset($NSVframerateLookup[$framerateindex]) ? $NSVframerateLookup[$framerateindex] : false);
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio-video.quicktime.php b/apps/media/getID3/getid3/module.audio-video.quicktime.php
deleted file mode 100644
index 681daf7ec29..00000000000
--- a/apps/media/getID3/getid3/module.audio-video.quicktime.php
+++ /dev/null
@@ -1,1382 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio-video.quicktime.php //
-// module for analyzing Quicktime and MP3-in-MP4 files //
-// dependencies: module.audio.mp3.php //
-// ///
-/////////////////////////////////////////////////////////////////
-
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
-
-class getid3_quicktime
-{
-
- function getid3_quicktime(&$fd, &$ThisFileInfo, $ReturnAtomData=true, $ParseAllPossibleAtoms=false) {
-
- $ThisFileInfo['fileformat'] = 'quicktime';
- $ThisFileInfo['quicktime']['hinting'] = false;
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
-
- $offset = 0;
- $atomcounter = 0;
-
- while ($offset < $ThisFileInfo['avdataend']) {
- if ($offset >= pow(2, 31)) {
- $ThisFileInfo['error'][] = 'Unable to parse atom at offset '.$offset.' because beyond 2GB limit of PHP filesystem functions';
- break;
- }
- fseek($fd, $offset, SEEK_SET);
- $AtomHeader = fread($fd, 8);
-
- $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
- $atomname = substr($AtomHeader, 4, 4);
-
- // 64-bit MOV patch by jlegateØktnc*com
- if ($atomsize == 1) {
- $atomsize = getid3_lib::BigEndian2Int(fread($fd, 8));
- }
-
- $ThisFileInfo['quicktime'][$atomname]['name'] = $atomname;
- $ThisFileInfo['quicktime'][$atomname]['size'] = $atomsize;
- $ThisFileInfo['quicktime'][$atomname]['offset'] = $offset;
-
- if (($offset + $atomsize) > $ThisFileInfo['avdataend']) {
- $ThisFileInfo['error'][] = 'Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)';
- return false;
- }
-
- if ($atomsize == 0) {
- // Furthermore, for historical reasons the list of atoms is optionally
- // terminated by a 32-bit integer set to 0. If you are writing a program
- // to read user data atoms, you should allow for the terminating 0.
- break;
- }
- switch ($atomname) {
- case 'mdat': // Media DATa atom
- // 'mdat' contains the actual data for the audio/video
- if (($atomsize > 8) && (!isset($ThisFileInfo['avdataend_tmp']) || ($ThisFileInfo['quicktime'][$atomname]['size'] > ($ThisFileInfo['avdataend_tmp'] - $ThisFileInfo['avdataoffset'])))) {
-
- $ThisFileInfo['avdataoffset'] = $ThisFileInfo['quicktime'][$atomname]['offset'] + 8;
- $OldAVDataEnd = $ThisFileInfo['avdataend'];
- $ThisFileInfo['avdataend'] = $ThisFileInfo['quicktime'][$atomname]['offset'] + $ThisFileInfo['quicktime'][$atomname]['size'];
-
- if (getid3_mp3::MPEGaudioHeaderValid(getid3_mp3::MPEGaudioHeaderDecode(fread($fd, 4)))) {
- getid3_mp3::getOnlyMPEGaudioInfo($fd, $ThisFileInfo, $ThisFileInfo['avdataoffset'], false);
- if (isset($ThisFileInfo['mpeg']['audio'])) {
- $ThisFileInfo['audio']['dataformat'] = 'mp3';
- $ThisFileInfo['audio']['codec'] = (!empty($ThisFileInfo['mpeg']['audio']['encoder']) ? $ThisFileInfo['mpeg']['audio']['encoder'] : (!empty($ThisFileInfo['mpeg']['audio']['codec']) ? $ThisFileInfo['mpeg']['audio']['codec'] : (!empty($ThisFileInfo['mpeg']['audio']['LAME']) ? 'LAME' :'mp3')));
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
- $ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
- $ThisFileInfo['bitrate'] = $ThisFileInfo['audio']['bitrate'];
- }
- }
- $ThisFileInfo['avdataend'] = $OldAVDataEnd;
- unset($OldAVDataEnd);
-
- }
- break;
-
- case 'free': // FREE space atom
- case 'skip': // SKIP atom
- case 'wide': // 64-bit expansion placeholder atom
- // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
- break;
-
- default:
- $atomHierarchy = array();
- $ThisFileInfo['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($fd, $atomsize), $ThisFileInfo, $offset, $atomHierarchy, $ParseAllPossibleAtoms);
- break;
- }
-
- $offset += $atomsize;
- $atomcounter++;
- }
-
- if (!empty($ThisFileInfo['avdataend_tmp'])) {
- // this value is assigned to a temp value and then erased because
- // otherwise any atoms beyond the 'mdat' atom would not get parsed
- $ThisFileInfo['avdataend'] = $ThisFileInfo['avdataend_tmp'];
- unset($ThisFileInfo['avdataend_tmp']);
- }
-
- if (!isset($ThisFileInfo['bitrate']) && isset($ThisFileInfo['playtime_seconds'])) {
- $ThisFileInfo['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
- }
- if (isset($ThisFileInfo['bitrate']) && !isset($ThisFileInfo['audio']['bitrate']) && !isset($ThisFileInfo['quicktime']['video'])) {
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['bitrate'];
- }
- if (@$ThisFileInfo['playtime_seconds'] && !isset($ThisFileInfo['video']['frame_rate']) && !empty($ThisFileInfo['quicktime']['stts_framecount'])) {
- foreach ($ThisFileInfo['quicktime']['stts_framecount'] as $key => $samples_count) {
- $samples_per_second = $samples_count / $ThisFileInfo['playtime_seconds'];
- if ($samples_per_second > 240) {
- // has to be audio samples
- } else {
- $ThisFileInfo['video']['frame_rate'] = $samples_per_second;
- break;
- }
- }
- }
- if (($ThisFileInfo['audio']['dataformat'] == 'mp4') && empty($ThisFileInfo['video']['resolution_x'])) {
- $ThisFileInfo['fileformat'] = 'mp4';
- $ThisFileInfo['mime_type'] = 'audio/mp4';
- unset($ThisFileInfo['video']['dataformat']);
- }
-
- if (!$ReturnAtomData) {
- unset($ThisFileInfo['quicktime']['moov']);
- }
-
- if (empty($ThisFileInfo['audio']['dataformat']) && !empty($ThisFileInfo['quicktime']['audio'])) {
- $ThisFileInfo['audio']['dataformat'] = 'quicktime';
- }
- if (empty($ThisFileInfo['video']['dataformat']) && !empty($ThisFileInfo['quicktime']['video'])) {
- $ThisFileInfo['video']['dataformat'] = 'quicktime';
- }
-
- return true;
- }
-
- function QuicktimeParseAtom($atomname, $atomsize, $atomdata, &$ThisFileInfo, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
- // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm
-
- array_push($atomHierarchy, $atomname);
- $atomstructure['hierarchy'] = implode(' ', $atomHierarchy);
- $atomstructure['name'] = $atomname;
- $atomstructure['size'] = $atomsize;
- $atomstructure['offset'] = $baseoffset;
-
- switch ($atomname) {
- case 'moov': // MOVie container atom
- case 'trak': // TRAcK container atom
- case 'clip': // CLIPping container atom
- case 'matt': // track MATTe container atom
- case 'edts': // EDiTS container atom
- case 'tref': // Track REFerence container atom
- case 'mdia': // MeDIA container atom
- case 'minf': // Media INFormation container atom
- case 'dinf': // Data INFormation container atom
- case 'udta': // User DaTA container atom
- case 'cmov': // Compressed MOVie container atom
- case 'rmra': // Reference Movie Record Atom
- case 'rmda': // Reference Movie Descriptor Atom
- case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR)
- $atomstructure['subatoms'] = $this->QuicktimeParseContainerAtom($atomdata, $ThisFileInfo, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
- break;
-
- case 'stbl': // Sample TaBLe container atom
- $atomstructure['subatoms'] = $this->QuicktimeParseContainerAtom($atomdata, $ThisFileInfo, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
- $isVideo = false;
- $framerate = 0;
- $framecount = 0;
- foreach ($atomstructure['subatoms'] as $key => $value_array) {
- if (isset($value_array['sample_description_table'])) {
- foreach ($value_array['sample_description_table'] as $key2 => $value_array2) {
- if (isset($value_array2['data_format'])) {
- switch ($value_array2['data_format']) {
- case 'avc1':
- case 'mp4v':
- // video data
- $isVideo = true;
- break;
- case 'mp4a':
- // audio data
- break;
- }
- }
- }
- } elseif (isset($value_array['time_to_sample_table'])) {
- foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) {
- if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration'])) {
- $framerate = round($ThisFileInfo['quicktime']['time_scale'] / $value_array2['sample_duration'], 3);
- $framecount = $value_array2['sample_count'];
- }
- }
- }
- }
- if ($isVideo && $framerate) {
- $ThisFileInfo['quicktime']['video']['frame_rate'] = $framerate;
- $ThisFileInfo['video']['frame_rate'] = $ThisFileInfo['quicktime']['video']['frame_rate'];
- }
- if ($isVideo && $framecount) {
- $ThisFileInfo['quicktime']['video']['frame_count'] = $framecount;
- }
- break;
-
-
- case '©cpy':
- case '©day':
- case '©dir':
- case '©ed1':
- case '©ed2':
- case '©ed3':
- case '©ed4':
- case '©ed5':
- case '©ed6':
- case '©ed7':
- case '©ed8':
- case '©ed9':
- case '©fmt':
- case '©inf':
- case '©prd':
- case '©prf':
- case '©req':
- case '©src':
- case '©wrt':
- case '©nam':
- case '©cmt':
- case '©wrn':
- case '©hst':
- case '©mak':
- case '©mod':
- case '©PRD':
- case '©swr':
- case '©aut':
- case '©ART':
- case '©trk':
- case '©alb':
- case '©com':
- case '©gen':
- case '©ope':
- case '©url':
- case '©enc':
- $atomstructure['data_length'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 2));
- $atomstructure['language_id'] = getid3_lib::BigEndian2Int(substr($atomdata, 2, 2));
- $atomstructure['data'] = substr($atomdata, 4);
-
- $atomstructure['language'] = $this->QuicktimeLanguageLookup($atomstructure['language_id']);
- if (empty($ThisFileInfo['comments']['language']) || (!in_array($atomstructure['language'], $ThisFileInfo['comments']['language']))) {
- $ThisFileInfo['comments']['language'][] = $atomstructure['language'];
- }
- $this->CopyToAppropriateCommentsSection($atomname, $atomstructure['data'], $ThisFileInfo);
- break;
-
-
- case 'play': // auto-PLAY atom
- $atomstructure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
-
- $ThisFileInfo['quicktime']['autoplay'] = $atomstructure['autoplay'];
- break;
-
-
- case 'WLOC': // Window LOCation atom
- $atomstructure['location_x'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 2));
- $atomstructure['location_y'] = getid3_lib::BigEndian2Int(substr($atomdata, 2, 2));
- break;
-
-
- case 'LOOP': // LOOPing atom
- case 'SelO': // play SELection Only atom
- case 'AllF': // play ALL Frames atom
- $atomstructure['data'] = getid3_lib::BigEndian2Int($atomdata);
- break;
-
-
- case 'name': //
- case 'MCPS': // Media Cleaner PRo
- case '@PRM': // adobe PReMiere version
- case '@PRQ': // adobe PRemiere Quicktime version
- $atomstructure['data'] = $atomdata;
- break;
-
-
- case 'cmvd': // Compressed MooV Data atom
- // Code by ubergeekØubergeek*tv based on information from
- // http://developer.apple.com/quicktime/icefloe/dispatch012.html
- $atomstructure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4));
-
- $CompressedFileData = substr($atomdata, 4);
- if ($UncompressedHeader = @gzuncompress($CompressedFileData)) {
- $atomstructure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, $ThisFileInfo, 0, $atomHierarchy, $ParseAllPossibleAtoms);
- } else {
- $ThisFileInfo['warning'][] = 'Error decompressing compressed MOV atom at offset '.$atomstructure['offset'];
- }
- break;
-
-
- case 'dcom': // Data COMpression atom
- $atomstructure['compression_id'] = $atomdata;
- $atomstructure['compression_text'] = $this->QuicktimeDCOMLookup($atomdata);
- break;
-
-
- case 'rdrf': // Reference movie Data ReFerence atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3));
- $atomstructure['flags']['internal_data'] = (bool) ($atomstructure['flags_raw'] & 0x000001);
-
- $atomstructure['reference_type_name'] = substr($atomdata, 4, 4);
- $atomstructure['reference_length'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
- switch ($atomstructure['reference_type_name']) {
- case 'url ':
- $atomstructure['url'] = $this->NoNullString(substr($atomdata, 12));
- break;
-
- case 'alis':
- $atomstructure['file_alias'] = substr($atomdata, 12);
- break;
-
- case 'rsrc':
- $atomstructure['resource_alias'] = substr($atomdata, 12);
- break;
-
- default:
- $atomstructure['data'] = substr($atomdata, 12);
- break;
- }
- break;
-
-
- case 'rmqu': // Reference Movie QUality atom
- $atomstructure['movie_quality'] = getid3_lib::BigEndian2Int($atomdata);
- break;
-
-
- case 'rmcs': // Reference Movie Cpu Speed atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
- break;
-
-
- case 'rmvc': // Reference Movie Version Check atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['gestalt_selector'] = substr($atomdata, 4, 4);
- $atomstructure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
- $atomstructure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
- $atomstructure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atomdata, 14, 2));
- break;
-
-
- case 'rmcd': // Reference Movie Component check atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['component_type'] = substr($atomdata, 4, 4);
- $atomstructure['component_subtype'] = substr($atomdata, 8, 4);
- $atomstructure['component_manufacturer'] = substr($atomdata, 12, 4);
- $atomstructure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 16, 4));
- $atomstructure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atomdata, 20, 4));
- $atomstructure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atomdata, 24, 4));
- break;
-
-
- case 'rmdr': // Reference Movie Data Rate atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['data_rate'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
-
- $atomstructure['data_rate_bps'] = $atomstructure['data_rate'] * 10;
- break;
-
-
- case 'rmla': // Reference Movie Language Atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['language_id'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
-
- $atomstructure['language'] = $this->QuicktimeLanguageLookup($atomstructure['language_id']);
- if (empty($ThisFileInfo['comments']['language']) || (!in_array($atomstructure['language'], $ThisFileInfo['comments']['language']))) {
- $ThisFileInfo['comments']['language'][] = $atomstructure['language'];
- }
- break;
-
-
- case 'rmla': // Reference Movie Language Atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['track_id'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
- break;
-
-
- case 'ptv ': // Print To Video - defines a movie's full screen mode
- // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm
- $atomstructure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 2));
- $atomstructure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atomdata, 2, 2)); // hardcoded: 0x0000
- $atomstructure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2)); // hardcoded: 0x0000
- $atomstructure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atomdata, 6, 1));
- $atomstructure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atomdata, 7, 1));
-
- $atomstructure['flags']['play_on_open'] = (bool) $atomstructure['play_on_open_flag'];
- $atomstructure['flags']['slide_show'] = (bool) $atomstructure['slide_show_flag'];
-
- $ptv_lookup[0] = 'normal';
- $ptv_lookup[1] = 'double';
- $ptv_lookup[2] = 'half';
- $ptv_lookup[3] = 'full';
- $ptv_lookup[4] = 'current';
- if (isset($ptv_lookup[$atomstructure['display_size_raw']])) {
- $atomstructure['display_size'] = $ptv_lookup[$atomstructure['display_size_raw']];
- } else {
- $ThisFileInfo['warning'][] = 'unknown "ptv " display constant ('.$atomstructure['display_size_raw'].')';
- }
- break;
-
-
- case 'stsd': // Sample Table Sample Description atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $stsdEntriesDataOffset = 8;
- for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
- $atomstructure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atomdata, $stsdEntriesDataOffset, 4));
- $stsdEntriesDataOffset += 4;
- $atomstructure['sample_description_table'][$i]['data_format'] = substr($atomdata, $stsdEntriesDataOffset, 4);
- $stsdEntriesDataOffset += 4;
- $atomstructure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atomdata, $stsdEntriesDataOffset, 6));
- $stsdEntriesDataOffset += 6;
- $atomstructure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atomdata, $stsdEntriesDataOffset, 2));
- $stsdEntriesDataOffset += 2;
- $atomstructure['sample_description_table'][$i]['data'] = substr($atomdata, $stsdEntriesDataOffset, ($atomstructure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));
- $stsdEntriesDataOffset += ($atomstructure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);
-
- $atomstructure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 0, 2));
- $atomstructure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 2, 2));
- $atomstructure['sample_description_table'][$i]['encoder_vendor'] = substr($atomstructure['sample_description_table'][$i]['data'], 4, 4);
-
- switch ($atomstructure['sample_description_table'][$i]['encoder_vendor']) {
-
- case "\x00\x00\x00\x00":
- // audio atom
- $atomstructure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 8, 2));
- $atomstructure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 10, 2));
- $atomstructure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 12, 2));
- $atomstructure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 14, 2));
- $atomstructure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atomstructure['sample_description_table'][$i]['data'], 16, 4));
-
- switch ($atomstructure['sample_description_table'][$i]['data_format']) {
- case 'avc1':
- case 'mp4v':
- $ThisFileInfo['fileformat'] = 'mp4';
- $ThisFileInfo['video']['fourcc'] = $atomstructure['sample_description_table'][$i]['data_format'];
- $ThisFileInfo['warning'][] = 'This version ('.GETID3_VERSION.') of getID3() does not fully support MPEG-4 audio/video streams';
- break;
-
- case 'qtvr':
- $ThisFileInfo['video']['dataformat'] = 'quicktimevr';
- break;
-
- case 'mp4a':
- default:
- $ThisFileInfo['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atomstructure['sample_description_table'][$i]['data_format']);
- $ThisFileInfo['quicktime']['audio']['sample_rate'] = $atomstructure['sample_description_table'][$i]['audio_sample_rate'];
- $ThisFileInfo['quicktime']['audio']['channels'] = $atomstructure['sample_description_table'][$i]['audio_channels'];
- $ThisFileInfo['quicktime']['audio']['bit_depth'] = $atomstructure['sample_description_table'][$i]['audio_bit_depth'];
- $ThisFileInfo['audio']['codec'] = $ThisFileInfo['quicktime']['audio']['codec'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['quicktime']['audio']['sample_rate'];
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['quicktime']['audio']['channels'];
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['quicktime']['audio']['bit_depth'];
- switch ($atomstructure['sample_description_table'][$i]['data_format']) {
- case 'raw ': // PCM
- case 'alac': // Apple Lossless Audio Codec
- $ThisFileInfo['audio']['lossless'] = true;
- break;
- default:
- $ThisFileInfo['audio']['lossless'] = false;
- break;
- }
- break;
- }
- break;
-
- default:
- switch ($atomstructure['sample_description_table'][$i]['data_format']) {
- case 'mp4s':
- $ThisFileInfo['fileformat'] = 'mp4';
- break;
-
- default:
- // video atom
- $atomstructure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 8, 4));
- $atomstructure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 12, 4));
- $atomstructure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 16, 2));
- $atomstructure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 18, 2));
- $atomstructure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atomstructure['sample_description_table'][$i]['data'], 20, 4));
- $atomstructure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atomstructure['sample_description_table'][$i]['data'], 24, 4));
- $atomstructure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 28, 4));
- $atomstructure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 32, 2));
- $atomstructure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 34, 1));
- $atomstructure['sample_description_table'][$i]['video_encoder_name'] = substr($atomstructure['sample_description_table'][$i]['data'], 35, $atomstructure['sample_description_table'][$i]['video_encoder_name_len']);
- $atomstructure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 66, 2));
- $atomstructure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atomstructure['sample_description_table'][$i]['data'], 68, 2));
-
- $atomstructure['sample_description_table'][$i]['video_pixel_color_type'] = (($atomstructure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color');
- $atomstructure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atomstructure['sample_description_table'][$i]['video_pixel_color_depth']);
-
- if ($atomstructure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') {
- $ThisFileInfo['quicktime']['video']['codec_fourcc'] = $atomstructure['sample_description_table'][$i]['data_format'];
- $ThisFileInfo['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atomstructure['sample_description_table'][$i]['data_format']);
- $ThisFileInfo['quicktime']['video']['codec'] = $atomstructure['sample_description_table'][$i]['video_encoder_name'];
- $ThisFileInfo['quicktime']['video']['color_depth'] = $atomstructure['sample_description_table'][$i]['video_pixel_color_depth'];
- $ThisFileInfo['quicktime']['video']['color_depth_name'] = $atomstructure['sample_description_table'][$i]['video_pixel_color_name'];
-
- $ThisFileInfo['video']['codec'] = $ThisFileInfo['quicktime']['video']['codec'];
- $ThisFileInfo['video']['bits_per_sample'] = $ThisFileInfo['quicktime']['video']['color_depth'];
- }
- $ThisFileInfo['video']['lossless'] = false;
- $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
- break;
- }
- break;
- }
- switch (strtolower($atomstructure['sample_description_table'][$i]['data_format'])) {
- case 'mp4a':
- $ThisFileInfo['audio']['dataformat'] = 'mp4';
- $ThisFileInfo['quicktime']['audio']['codec'] = 'mp4';
- break;
-
- case '3ivx':
- case '3iv1':
- case '3iv2':
- $ThisFileInfo['video']['dataformat'] = '3ivx';
- break;
-
- case 'xvid':
- $ThisFileInfo['video']['dataformat'] = 'xvid';
- break;
-
- case 'mp4v':
- $ThisFileInfo['video']['dataformat'] = 'mpeg4';
- break;
-
- case 'divx':
- case 'div1':
- case 'div2':
- case 'div3':
- case 'div4':
- case 'div5':
- case 'div6':
- $TDIVXileInfo['video']['dataformat'] = 'divx';
- break;
-
- default:
- // do nothing
- break;
- }
- unset($atomstructure['sample_description_table'][$i]['data']);
- }
- break;
-
-
- case 'stts': // Sample Table Time-to-Sample atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $sttsEntriesDataOffset = 8;
- //$FrameRateCalculatorArray = array();
- $frames_count = 0;
- for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
- $atomstructure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atomdata, $sttsEntriesDataOffset, 4));
- $sttsEntriesDataOffset += 4;
- $atomstructure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, $sttsEntriesDataOffset, 4));
- $sttsEntriesDataOffset += 4;
-
- $frames_count += $atomstructure['time_to_sample_table'][$i]['sample_count'];
-
- // THIS SECTION REPLACED WITH CODE IN "stbl" ATOM
- //if (!empty($ThisFileInfo['quicktime']['time_scale']) && (@$atomstructure['time_to_sample_table'][$i]['sample_duration'] > 0)) {
- // $stts_new_framerate = $ThisFileInfo['quicktime']['time_scale'] / $atomstructure['time_to_sample_table'][$i]['sample_duration'];
- // if ($stts_new_framerate <= 60) {
- // // some atoms have durations of "1" giving a very large framerate, which probably is not right
- // $ThisFileInfo['video']['frame_rate'] = max(@$ThisFileInfo['video']['frame_rate'], $stts_new_framerate);
- // }
- //}
- //
- //@$FrameRateCalculatorArray[($ThisFileInfo['quicktime']['time_scale'] / $atomstructure['time_to_sample_table'][$i]['sample_duration'])] += $atomstructure['time_to_sample_table'][$i]['sample_count'];
- }
- $ThisFileInfo['quicktime']['stts_framecount'][] = $frames_count;
- //$sttsFramesTotal = 0;
- //$sttsSecondsTotal = 0;
- //foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) {
- // if (($frames_per_second > 60) || ($frames_per_second < 1)) {
- // // not video FPS information, probably audio information
- // $sttsFramesTotal = 0;
- // $sttsSecondsTotal = 0;
- // break;
- // }
- // $sttsFramesTotal += $frame_count;
- // $sttsSecondsTotal += $frame_count / $frames_per_second;
- //}
- //if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) {
- // if (($sttsFramesTotal / $sttsSecondsTotal) > @$ThisFileInfo['video']['frame_rate']) {
- // $ThisFileInfo['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal;
- // }
- //}
- break;
-
-
- case 'stss': // Sample Table Sync Sample (key frames) atom
- if ($ParseAllPossibleAtoms) {
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $stssEntriesDataOffset = 8;
- for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
- $atomstructure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atomdata, $stssEntriesDataOffset, 4));
- $stssEntriesDataOffset += 4;
- }
- }
- break;
-
-
- case 'stsc': // Sample Table Sample-to-Chunk atom
- if ($ParseAllPossibleAtoms) {
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $stscEntriesDataOffset = 8;
- for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
- $atomstructure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atomdata, $stscEntriesDataOffset, 4));
- $stscEntriesDataOffset += 4;
- $atomstructure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atomdata, $stscEntriesDataOffset, 4));
- $stscEntriesDataOffset += 4;
- $atomstructure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atomdata, $stscEntriesDataOffset, 4));
- $stscEntriesDataOffset += 4;
- }
- }
- break;
-
-
- case 'stsz': // Sample Table SiZe atom
- if ($ParseAllPossibleAtoms) {
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['sample_size'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
- $stszEntriesDataOffset = 12;
- if ($atomstructure['sample_size'] == 0) {
- for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
- $atomstructure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atomdata, $stszEntriesDataOffset, 4));
- $stszEntriesDataOffset += 4;
- }
- }
- }
- break;
-
-
- case 'stco': // Sample Table Chunk Offset atom
- if ($ParseAllPossibleAtoms) {
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $stcoEntriesDataOffset = 8;
- for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
- $atomstructure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atomdata, $stcoEntriesDataOffset, 4));
- $stcoEntriesDataOffset += 4;
- }
- }
- break;
-
-
- case 'co64': // Chunk Offset 64-bit (version of "stco" that supports > 2GB files)
- if ($ParseAllPossibleAtoms) {
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $stcoEntriesDataOffset = 8;
- for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
- $atomstructure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atomdata, $stcoEntriesDataOffset, 8));
- $stcoEntriesDataOffset += 8;
- }
- }
- break;
-
-
- case 'dref': // Data REFerence atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $drefDataOffset = 8;
- for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
- $atomstructure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atomdata, $drefDataOffset, 4));
- $drefDataOffset += 4;
- $atomstructure['data_references'][$i]['type'] = substr($atomdata, $drefDataOffset, 4);
- $drefDataOffset += 4;
- $atomstructure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atomdata, $drefDataOffset, 1));
- $drefDataOffset += 1;
- $atomstructure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, $drefDataOffset, 3)); // hardcoded: 0x0000
- $drefDataOffset += 3;
- $atomstructure['data_references'][$i]['data'] = substr($atomdata, $drefDataOffset, ($atomstructure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));
- $drefDataOffset += ($atomstructure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);
-
- $atomstructure['data_references'][$i]['flags']['self_reference'] = (bool) ($atomstructure['data_references'][$i]['flags_raw'] & 0x001);
- }
- break;
-
-
- case 'gmin': // base Media INformation atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
- $atomstructure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atomdata, 6, 2));
- $atomstructure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 2));
- $atomstructure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atomdata, 10, 2));
- $atomstructure['balance'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 2));
- $atomstructure['reserved'] = getid3_lib::BigEndian2Int(substr($atomdata, 14, 2));
- break;
-
-
- case 'smhd': // Sound Media information HeaDer atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['balance'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
- $atomstructure['reserved'] = getid3_lib::BigEndian2Int(substr($atomdata, 6, 2));
- break;
-
-
- case 'vmhd': // Video Media information HeaDer atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3));
- $atomstructure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2));
- $atomstructure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atomdata, 6, 2));
- $atomstructure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 2));
- $atomstructure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atomdata, 10, 2));
-
- $atomstructure['flags']['no_lean_ahead'] = (bool) ($atomstructure['flags_raw'] & 0x001);
- break;
-
-
- case 'hdlr': // HanDLeR reference atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['component_type'] = substr($atomdata, 4, 4);
- $atomstructure['component_subtype'] = substr($atomdata, 8, 4);
- $atomstructure['component_manufacturer'] = substr($atomdata, 12, 4);
- $atomstructure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 16, 4));
- $atomstructure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atomdata, 20, 4));
- $atomstructure['component_name'] = $this->Pascal2String(substr($atomdata, 24));
-
- if (($atomstructure['component_subtype'] == 'STpn') && ($atomstructure['component_manufacturer'] == 'zzzz')) {
- $ThisFileInfo['video']['dataformat'] = 'quicktimevr';
- }
- break;
-
-
- case 'mdhd': // MeDia HeaDer atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['creation_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $atomstructure['modify_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
- $atomstructure['time_scale'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
- $atomstructure['duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 16, 4));
- $atomstructure['language_id'] = getid3_lib::BigEndian2Int(substr($atomdata, 20, 2));
- $atomstructure['quality'] = getid3_lib::BigEndian2Int(substr($atomdata, 22, 2));
-
- if ($atomstructure['time_scale'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt Quicktime file: mdhd.time_scale == zero';
- return false;
- }
- $ThisFileInfo['quicktime']['time_scale'] = max(@$ThisFileInfo['quicktime']['time_scale'], $atomstructure['time_scale']);
-
- $atomstructure['creation_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['creation_time']);
- $atomstructure['modify_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['modify_time']);
- $atomstructure['playtime_seconds'] = $atomstructure['duration'] / $atomstructure['time_scale'];
- $atomstructure['language'] = $this->QuicktimeLanguageLookup($atomstructure['language_id']);
- if (empty($ThisFileInfo['comments']['language']) || (!in_array($atomstructure['language'], $ThisFileInfo['comments']['language']))) {
- $ThisFileInfo['comments']['language'][] = $atomstructure['language'];
- }
- break;
-
-
- case 'pnot': // Preview atom
- $atomstructure['modification_date'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4)); // "standard Macintosh format"
- $atomstructure['version_number'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2)); // hardcoded: 0x00
- $atomstructure['atom_type'] = substr($atomdata, 6, 4); // usually: 'PICT'
- $atomstructure['atom_index'] = getid3_lib::BigEndian2Int(substr($atomdata, 10, 2)); // usually: 0x01
-
- $atomstructure['modification_date_unix'] = getid3_lib::DateMac2Unix($atomstructure['modification_date']);
- break;
-
-
- case 'crgn': // Clipping ReGioN atom
- $atomstructure['region_size'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 2)); // The Region size, Region boundary box,
- $atomstructure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atomdata, 2, 8)); // and Clipping region data fields
- $atomstructure['clipping_data'] = substr($atomdata, 10); // constitute a QuickDraw region.
- break;
-
-
- case 'load': // track LOAD settings atom
- $atomstructure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4));
- $atomstructure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $atomstructure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
- $atomstructure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
-
- $atomstructure['default_hints']['double_buffer'] = (bool) ($atomstructure['default_hints_raw'] & 0x0020);
- $atomstructure['default_hints']['high_quality'] = (bool) ($atomstructure['default_hints_raw'] & 0x0100);
- break;
-
-
- case 'tmcd': // TiMe CoDe atom
- case 'chap': // CHAPter list atom
- case 'sync': // SYNChronization atom
- case 'scpt': // tranSCriPT atom
- case 'ssrc': // non-primary SouRCe atom
- for ($i = 0; $i < (strlen($atomdata) % 4); $i++) {
- $atomstructure['track_id'][$i] = getid3_lib::BigEndian2Int(substr($atomdata, $i * 4, 4));
- }
- break;
-
-
- case 'elst': // Edit LiST atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- for ($i = 0; $i < $atomstructure['number_entries']; $i++ ) {
- $atomstructure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($i * 12) + 0, 4));
- $atomstructure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($i * 12) + 4, 4));
- $atomstructure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atomdata, 8 + ($i * 12) + 8, 4));
- }
- break;
-
-
- case 'kmat': // compressed MATte atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3)); // hardcoded: 0x0000
- $atomstructure['matte_data_raw'] = substr($atomdata, 4);
- break;
-
-
- case 'ctab': // Color TABle atom
- $atomstructure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4)); // hardcoded: 0x00000000
- $atomstructure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2)); // hardcoded: 0x8000
- $atomstructure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atomdata, 6, 2)) + 1;
- for ($colortableentry = 0; $colortableentry < $atomstructure['color_table_size']; $colortableentry++) {
- $atomstructure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($colortableentry * 8) + 0, 2));
- $atomstructure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($colortableentry * 8) + 2, 2));
- $atomstructure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($colortableentry * 8) + 4, 2));
- $atomstructure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($colortableentry * 8) + 6, 2));
- }
- break;
-
-
- case 'mvhd': // MoVie HeaDer atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3));
- $atomstructure['creation_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $atomstructure['modify_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
- $atomstructure['time_scale'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
- $atomstructure['duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 16, 4));
- $atomstructure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atomdata, 20, 4));
- $atomstructure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atomdata, 24, 2));
- $atomstructure['reserved'] = substr($atomdata, 26, 10);
- $atomstructure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atomdata, 36, 4));
- $atomstructure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atomdata, 40, 4));
- $atomstructure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atomdata, 44, 4));
- $atomstructure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atomdata, 48, 4));
- $atomstructure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atomdata, 52, 4));
- $atomstructure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atomdata, 56, 4));
- $atomstructure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atomdata, 60, 4));
- $atomstructure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atomdata, 64, 4));
- $atomstructure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atomdata, 68, 4));
- $atomstructure['preview_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 72, 4));
- $atomstructure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 76, 4));
- $atomstructure['poster_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 80, 4));
- $atomstructure['selection_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 84, 4));
- $atomstructure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 88, 4));
- $atomstructure['current_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 92, 4));
- $atomstructure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atomdata, 96, 4));
-
- if ($atomstructure['time_scale'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt Quicktime file: mvhd.time_scale == zero';
- return false;
- }
- $atomstructure['creation_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['creation_time']);
- $atomstructure['modify_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['modify_time']);
- $ThisFileInfo['quicktime']['time_scale'] = max(@$ThisFileInfo['quicktime']['time_scale'], $atomstructure['time_scale']);
- $ThisFileInfo['quicktime']['display_scale'] = $atomstructure['matrix_a'];
- $ThisFileInfo['playtime_seconds'] = $atomstructure['duration'] / $atomstructure['time_scale'];
- break;
-
-
- case 'tkhd': // TracK HeaDer atom
- $atomstructure['version'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 1));
- $atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata, 1, 3));
- $atomstructure['creation_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $atomstructure['modify_time'] = getid3_lib::BigEndian2Int(substr($atomdata, 8, 4));
- $atomstructure['trackid'] = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
- $atomstructure['reserved1'] = getid3_lib::BigEndian2Int(substr($atomdata, 16, 4));
- $atomstructure['duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 20, 4));
- $atomstructure['reserved2'] = getid3_lib::BigEndian2Int(substr($atomdata, 24, 8));
- $atomstructure['layer'] = getid3_lib::BigEndian2Int(substr($atomdata, 32, 2));
- $atomstructure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atomdata, 34, 2));
- $atomstructure['volume'] = getid3_lib::FixedPoint8_8(substr($atomdata, 36, 2));
- $atomstructure['reserved3'] = getid3_lib::BigEndian2Int(substr($atomdata, 38, 2));
- $atomstructure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atomdata, 40, 4));
- $atomstructure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atomdata, 44, 4));
- $atomstructure['matrix_u'] = getid3_lib::FixedPoint16_16(substr($atomdata, 48, 4));
- $atomstructure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atomdata, 52, 4));
- $atomstructure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atomdata, 56, 4));
- $atomstructure['matrix_v'] = getid3_lib::FixedPoint16_16(substr($atomdata, 60, 4));
- $atomstructure['matrix_x'] = getid3_lib::FixedPoint2_30(substr($atomdata, 64, 4));
- $atomstructure['matrix_y'] = getid3_lib::FixedPoint2_30(substr($atomdata, 68, 4));
- $atomstructure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atomdata, 72, 4));
- $atomstructure['width'] = getid3_lib::FixedPoint16_16(substr($atomdata, 76, 4));
- $atomstructure['height'] = getid3_lib::FixedPoint16_16(substr($atomdata, 80, 4));
-
- $atomstructure['flags']['enabled'] = (bool) ($atomstructure['flags_raw'] & 0x0001);
- $atomstructure['flags']['in_movie'] = (bool) ($atomstructure['flags_raw'] & 0x0002);
- $atomstructure['flags']['in_preview'] = (bool) ($atomstructure['flags_raw'] & 0x0004);
- $atomstructure['flags']['in_poster'] = (bool) ($atomstructure['flags_raw'] & 0x0008);
- $atomstructure['creation_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['creation_time']);
- $atomstructure['modify_time_unix'] = getid3_lib::DateMac2Unix($atomstructure['modify_time']);
-
- if (!isset($ThisFileInfo['video']['resolution_x']) || !isset($ThisFileInfo['video']['resolution_y'])) {
- $ThisFileInfo['video']['resolution_x'] = $atomstructure['width'];
- $ThisFileInfo['video']['resolution_y'] = $atomstructure['height'];
- }
- if ($atomstructure['flags']['enabled'] == 1) {
- $ThisFileInfo['video']['resolution_x'] = max($ThisFileInfo['video']['resolution_x'], $atomstructure['width']);
- $ThisFileInfo['video']['resolution_y'] = max($ThisFileInfo['video']['resolution_y'], $atomstructure['height']);
- }
- if (!empty($ThisFileInfo['video']['resolution_x']) && !empty($ThisFileInfo['video']['resolution_y'])) {
- $ThisFileInfo['quicktime']['video']['resolution_x'] = $ThisFileInfo['video']['resolution_x'];
- $ThisFileInfo['quicktime']['video']['resolution_y'] = $ThisFileInfo['video']['resolution_y'];
- } else {
- unset($ThisFileInfo['video']['resolution_x']);
- unset($ThisFileInfo['video']['resolution_y']);
- unset($ThisFileInfo['quicktime']['video']);
- }
- break;
-
-
- case 'meta': // METAdata atom
- // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
- $NextTagPosition = strpos($atomdata, '©');
- while ($NextTagPosition < strlen($atomdata)) {
- $metaItemSize = getid3_lib::BigEndian2Int(substr($atomdata, $NextTagPosition - 4, 4)) - 4;
- if ($metaItemSize == -4) {
- break;
- }
- $metaItemRaw = substr($atomdata, $NextTagPosition, $metaItemSize);
- $metaItemKey = substr($metaItemRaw, 0, 4);
- $metaItemData = substr($metaItemRaw, 20);
- $NextTagPosition += $metaItemSize + 4;
-
- $this->CopyToAppropriateCommentsSection($metaItemKey, $metaItemData, $ThisFileInfo);
- }
- break;
-
- case 'ftyp': // FileTYPe (?) atom (for MP4 it seems)
- $atomstructure['signature'] = substr($atomdata, 0, 4);
- $atomstructure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atomdata, 4, 4));
- $atomstructure['fourcc'] = substr($atomdata, 8, 4);
- break;
-
- case 'mdat': // Media DATa atom
- case 'free': // FREE space atom
- case 'skip': // SKIP atom
- case 'wide': // 64-bit expansion placeholder atom
- // 'mdat' data is too big to deal with, contains no useful metadata
- // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
-
- // When writing QuickTime files, it is sometimes necessary to update an atom's size.
- // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom
- // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime
- // puts an 8-byte placeholder atom before any atoms it may have to update the size of.
- // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the
- // placeholder atom can be overwritten to obtain the necessary 8 extra bytes.
- // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ).
- break;
-
-
- case 'nsav': // NoSAVe atom
- // http://developer.apple.com/technotes/tn/tn2038.html
- $atomstructure['data'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4));
- break;
-
- case 'ctyp': // Controller TYPe atom (seen on QTVR)
- // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt
- // some controller names are:
- // 0x00 + 'std' for linear movie
- // 'none' for no controls
- $atomstructure['ctyp'] = substr($atomdata, 0, 4);
- switch ($atomstructure['ctyp']) {
- case 'qtvr':
- $ThisFileInfo['video']['dataformat'] = 'quicktimevr';
- break;
- }
- break;
-
- case 'pano': // PANOrama track (seen on QTVR)
- $atomstructure['pano'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4));
- break;
-
- case 'hint': // HINT track
- case 'hinf': //
- case 'hinv': //
- case 'hnti': //
- $ThisFileInfo['quicktime']['hinting'] = true;
- break;
-
- case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR)
- for ($i = 0; $i < ($atomstructure['size'] - 8); $i += 4) {
- $atomstructure['imgt'][] = getid3_lib::BigEndian2Int(substr($atomdata, $i, 4));
- }
- break;
-
- case 'FXTC': // Something to do with Adobe After Effects (?)
- case 'PrmA':
- case 'code':
- case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
- // Observed-but-not-handled atom types are just listed here
- // to prevent warnings being generated
- $atomstructure['data'] = $atomdata;
- break;
-
- default:
- $ThisFileInfo['warning'][] = 'Unknown QuickTime atom type: "'.$atomname.'" at offset '.$baseoffset;
- $atomstructure['data'] = $atomdata;
- break;
- }
- array_pop($atomHierarchy);
- return $atomstructure;
- }
-
- function QuicktimeParseContainerAtom($atomdata, &$ThisFileInfo, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
- $atomstructure = false;
- $subatomoffset = 0;
- $subatomcounter = 0;
- if ((strlen($atomdata) == 4) && (getid3_lib::BigEndian2Int($atomdata) == 0x00000000)) {
- return false;
- }
- while ($subatomoffset < strlen($atomdata)) {
- $subatomsize = getid3_lib::BigEndian2Int(substr($atomdata, $subatomoffset + 0, 4));
- $subatomname = substr($atomdata, $subatomoffset + 4, 4);
- $subatomdata = substr($atomdata, $subatomoffset + 8, $subatomsize - 8);
- if ($subatomsize == 0) {
- // Furthermore, for historical reasons the list of atoms is optionally
- // terminated by a 32-bit integer set to 0. If you are writing a program
- // to read user data atoms, you should allow for the terminating 0.
- return $atomstructure;
- }
-
- $atomstructure[$subatomcounter] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $ThisFileInfo, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms);
-
- $subatomoffset += $subatomsize;
- $subatomcounter++;
- }
- return $atomstructure;
- }
-
-
- function QuicktimeLanguageLookup($languageid) {
- static $QuicktimeLanguageLookup = array();
- if (empty($QuicktimeLanguageLookup)) {
- $QuicktimeLanguageLookup[0] = 'English';
- $QuicktimeLanguageLookup[1] = 'French';
- $QuicktimeLanguageLookup[2] = 'German';
- $QuicktimeLanguageLookup[3] = 'Italian';
- $QuicktimeLanguageLookup[4] = 'Dutch';
- $QuicktimeLanguageLookup[5] = 'Swedish';
- $QuicktimeLanguageLookup[6] = 'Spanish';
- $QuicktimeLanguageLookup[7] = 'Danish';
- $QuicktimeLanguageLookup[8] = 'Portuguese';
- $QuicktimeLanguageLookup[9] = 'Norwegian';
- $QuicktimeLanguageLookup[10] = 'Hebrew';
- $QuicktimeLanguageLookup[11] = 'Japanese';
- $QuicktimeLanguageLookup[12] = 'Arabic';
- $QuicktimeLanguageLookup[13] = 'Finnish';
- $QuicktimeLanguageLookup[14] = 'Greek';
- $QuicktimeLanguageLookup[15] = 'Icelandic';
- $QuicktimeLanguageLookup[16] = 'Maltese';
- $QuicktimeLanguageLookup[17] = 'Turkish';
- $QuicktimeLanguageLookup[18] = 'Croatian';
- $QuicktimeLanguageLookup[19] = 'Chinese (Traditional)';
- $QuicktimeLanguageLookup[20] = 'Urdu';
- $QuicktimeLanguageLookup[21] = 'Hindi';
- $QuicktimeLanguageLookup[22] = 'Thai';
- $QuicktimeLanguageLookup[23] = 'Korean';
- $QuicktimeLanguageLookup[24] = 'Lithuanian';
- $QuicktimeLanguageLookup[25] = 'Polish';
- $QuicktimeLanguageLookup[26] = 'Hungarian';
- $QuicktimeLanguageLookup[27] = 'Estonian';
- $QuicktimeLanguageLookup[28] = 'Lettish';
- $QuicktimeLanguageLookup[28] = 'Latvian';
- $QuicktimeLanguageLookup[29] = 'Saamisk';
- $QuicktimeLanguageLookup[29] = 'Lappish';
- $QuicktimeLanguageLookup[30] = 'Faeroese';
- $QuicktimeLanguageLookup[31] = 'Farsi';
- $QuicktimeLanguageLookup[31] = 'Persian';
- $QuicktimeLanguageLookup[32] = 'Russian';
- $QuicktimeLanguageLookup[33] = 'Chinese (Simplified)';
- $QuicktimeLanguageLookup[34] = 'Flemish';
- $QuicktimeLanguageLookup[35] = 'Irish';
- $QuicktimeLanguageLookup[36] = 'Albanian';
- $QuicktimeLanguageLookup[37] = 'Romanian';
- $QuicktimeLanguageLookup[38] = 'Czech';
- $QuicktimeLanguageLookup[39] = 'Slovak';
- $QuicktimeLanguageLookup[40] = 'Slovenian';
- $QuicktimeLanguageLookup[41] = 'Yiddish';
- $QuicktimeLanguageLookup[42] = 'Serbian';
- $QuicktimeLanguageLookup[43] = 'Macedonian';
- $QuicktimeLanguageLookup[44] = 'Bulgarian';
- $QuicktimeLanguageLookup[45] = 'Ukrainian';
- $QuicktimeLanguageLookup[46] = 'Byelorussian';
- $QuicktimeLanguageLookup[47] = 'Uzbek';
- $QuicktimeLanguageLookup[48] = 'Kazakh';
- $QuicktimeLanguageLookup[49] = 'Azerbaijani';
- $QuicktimeLanguageLookup[50] = 'AzerbaijanAr';
- $QuicktimeLanguageLookup[51] = 'Armenian';
- $QuicktimeLanguageLookup[52] = 'Georgian';
- $QuicktimeLanguageLookup[53] = 'Moldavian';
- $QuicktimeLanguageLookup[54] = 'Kirghiz';
- $QuicktimeLanguageLookup[55] = 'Tajiki';
- $QuicktimeLanguageLookup[56] = 'Turkmen';
- $QuicktimeLanguageLookup[57] = 'Mongolian';
- $QuicktimeLanguageLookup[58] = 'MongolianCyr';
- $QuicktimeLanguageLookup[59] = 'Pashto';
- $QuicktimeLanguageLookup[60] = 'Kurdish';
- $QuicktimeLanguageLookup[61] = 'Kashmiri';
- $QuicktimeLanguageLookup[62] = 'Sindhi';
- $QuicktimeLanguageLookup[63] = 'Tibetan';
- $QuicktimeLanguageLookup[64] = 'Nepali';
- $QuicktimeLanguageLookup[65] = 'Sanskrit';
- $QuicktimeLanguageLookup[66] = 'Marathi';
- $QuicktimeLanguageLookup[67] = 'Bengali';
- $QuicktimeLanguageLookup[68] = 'Assamese';
- $QuicktimeLanguageLookup[69] = 'Gujarati';
- $QuicktimeLanguageLookup[70] = 'Punjabi';
- $QuicktimeLanguageLookup[71] = 'Oriya';
- $QuicktimeLanguageLookup[72] = 'Malayalam';
- $QuicktimeLanguageLookup[73] = 'Kannada';
- $QuicktimeLanguageLookup[74] = 'Tamil';
- $QuicktimeLanguageLookup[75] = 'Telugu';
- $QuicktimeLanguageLookup[76] = 'Sinhalese';
- $QuicktimeLanguageLookup[77] = 'Burmese';
- $QuicktimeLanguageLookup[78] = 'Khmer';
- $QuicktimeLanguageLookup[79] = 'Lao';
- $QuicktimeLanguageLookup[80] = 'Vietnamese';
- $QuicktimeLanguageLookup[81] = 'Indonesian';
- $QuicktimeLanguageLookup[82] = 'Tagalog';
- $QuicktimeLanguageLookup[83] = 'MalayRoman';
- $QuicktimeLanguageLookup[84] = 'MalayArabic';
- $QuicktimeLanguageLookup[85] = 'Amharic';
- $QuicktimeLanguageLookup[86] = 'Tigrinya';
- $QuicktimeLanguageLookup[87] = 'Galla';
- $QuicktimeLanguageLookup[87] = 'Oromo';
- $QuicktimeLanguageLookup[88] = 'Somali';
- $QuicktimeLanguageLookup[89] = 'Swahili';
- $QuicktimeLanguageLookup[90] = 'Ruanda';
- $QuicktimeLanguageLookup[91] = 'Rundi';
- $QuicktimeLanguageLookup[92] = 'Chewa';
- $QuicktimeLanguageLookup[93] = 'Malagasy';
- $QuicktimeLanguageLookup[94] = 'Esperanto';
- $QuicktimeLanguageLookup[128] = 'Welsh';
- $QuicktimeLanguageLookup[129] = 'Basque';
- $QuicktimeLanguageLookup[130] = 'Catalan';
- $QuicktimeLanguageLookup[131] = 'Latin';
- $QuicktimeLanguageLookup[132] = 'Quechua';
- $QuicktimeLanguageLookup[133] = 'Guarani';
- $QuicktimeLanguageLookup[134] = 'Aymara';
- $QuicktimeLanguageLookup[135] = 'Tatar';
- $QuicktimeLanguageLookup[136] = 'Uighur';
- $QuicktimeLanguageLookup[137] = 'Dzongkha';
- $QuicktimeLanguageLookup[138] = 'JavaneseRom';
- }
- return (isset($QuicktimeLanguageLookup[$languageid]) ? $QuicktimeLanguageLookup[$languageid] : 'invalid');
- }
-
- function QuicktimeVideoCodecLookup($codecid) {
- static $QuicktimeVideoCodecLookup = array();
- if (empty($QuicktimeVideoCodecLookup)) {
- $QuicktimeVideoCodecLookup['3IVX'] = '3ivx MPEG-4';
- $QuicktimeVideoCodecLookup['3IV1'] = '3ivx MPEG-4 v1';
- $QuicktimeVideoCodecLookup['3IV2'] = '3ivx MPEG-4 v2';
- $QuicktimeVideoCodecLookup['avr '] = 'AVR-JPEG';
- $QuicktimeVideoCodecLookup['base'] = 'Base';
- $QuicktimeVideoCodecLookup['WRLE'] = 'BMP';
- $QuicktimeVideoCodecLookup['cvid'] = 'Cinepak';
- $QuicktimeVideoCodecLookup['clou'] = 'Cloud';
- $QuicktimeVideoCodecLookup['cmyk'] = 'CMYK';
- $QuicktimeVideoCodecLookup['yuv2'] = 'ComponentVideo';
- $QuicktimeVideoCodecLookup['yuvu'] = 'ComponentVideoSigned';
- $QuicktimeVideoCodecLookup['yuvs'] = 'ComponentVideoUnsigned';
- $QuicktimeVideoCodecLookup['dvc '] = 'DVC-NTSC';
- $QuicktimeVideoCodecLookup['dvcp'] = 'DVC-PAL';
- $QuicktimeVideoCodecLookup['dvpn'] = 'DVCPro-NTSC';
- $QuicktimeVideoCodecLookup['dvpp'] = 'DVCPro-PAL';
- $QuicktimeVideoCodecLookup['fire'] = 'Fire';
- $QuicktimeVideoCodecLookup['flic'] = 'FLC';
- $QuicktimeVideoCodecLookup['b48r'] = '48RGB';
- $QuicktimeVideoCodecLookup['gif '] = 'GIF';
- $QuicktimeVideoCodecLookup['smc '] = 'Graphics';
- $QuicktimeVideoCodecLookup['h261'] = 'H261';
- $QuicktimeVideoCodecLookup['h263'] = 'H263';
- $QuicktimeVideoCodecLookup['IV41'] = 'Indeo4';
- $QuicktimeVideoCodecLookup['jpeg'] = 'JPEG';
- $QuicktimeVideoCodecLookup['PNTG'] = 'MacPaint';
- $QuicktimeVideoCodecLookup['msvc'] = 'Microsoft Video1';
- $QuicktimeVideoCodecLookup['mjpa'] = 'Motion JPEG-A';
- $QuicktimeVideoCodecLookup['mjpb'] = 'Motion JPEG-B';
- $QuicktimeVideoCodecLookup['myuv'] = 'MPEG YUV420';
- $QuicktimeVideoCodecLookup['dmb1'] = 'OpenDML JPEG';
- $QuicktimeVideoCodecLookup['kpcd'] = 'PhotoCD';
- $QuicktimeVideoCodecLookup['8BPS'] = 'Planar RGB';
- $QuicktimeVideoCodecLookup['png '] = 'PNG';
- $QuicktimeVideoCodecLookup['qdrw'] = 'QuickDraw';
- $QuicktimeVideoCodecLookup['qdgx'] = 'QuickDrawGX';
- $QuicktimeVideoCodecLookup['raw '] = 'RAW';
- $QuicktimeVideoCodecLookup['.SGI'] = 'SGI';
- $QuicktimeVideoCodecLookup['b16g'] = '16Gray';
- $QuicktimeVideoCodecLookup['b64a'] = '64ARGB';
- $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 1';
- $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 3';
- $QuicktimeVideoCodecLookup['syv9'] = 'Sorenson YUV9';
- $QuicktimeVideoCodecLookup['tga '] = 'Targa';
- $QuicktimeVideoCodecLookup['b32a'] = '32AlphaGray';
- $QuicktimeVideoCodecLookup['tiff'] = 'TIFF';
- $QuicktimeVideoCodecLookup['path'] = 'Vector';
- $QuicktimeVideoCodecLookup['rpza'] = 'Video';
- $QuicktimeVideoCodecLookup['ripl'] = 'WaterRipple';
- $QuicktimeVideoCodecLookup['WRAW'] = 'Windows RAW';
- $QuicktimeVideoCodecLookup['y420'] = 'YUV420';
- }
- return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : '');
- }
-
- function QuicktimeAudioCodecLookup($codecid) {
- static $QuicktimeAudioCodecLookup = array();
- if (empty($QuicktimeAudioCodecLookup)) {
- $QuicktimeAudioCodecLookup['.mp3'] = 'Fraunhofer MPEG Layer-III alias';
- $QuicktimeAudioCodecLookup['aac '] = 'ISO/IEC 14496-3 AAC';
- $QuicktimeAudioCodecLookup['agsm'] = 'Apple GSM 10:1';
- $QuicktimeAudioCodecLookup['alac'] = 'Apple Lossless Audio Codec';
- $QuicktimeAudioCodecLookup['alaw'] = 'A-law 2:1';
- $QuicktimeAudioCodecLookup['conv'] = 'Sample Format';
- $QuicktimeAudioCodecLookup['dvca'] = 'DV';
- $QuicktimeAudioCodecLookup['dvi '] = 'DV 4:1';
- $QuicktimeAudioCodecLookup['eqal'] = 'Frequency Equalizer';
- $QuicktimeAudioCodecLookup['fl32'] = '32-bit Floating Point';
- $QuicktimeAudioCodecLookup['fl64'] = '64-bit Floating Point';
- $QuicktimeAudioCodecLookup['ima4'] = 'Interactive Multimedia Association 4:1';
- $QuicktimeAudioCodecLookup['in24'] = '24-bit Integer';
- $QuicktimeAudioCodecLookup['in32'] = '32-bit Integer';
- $QuicktimeAudioCodecLookup['lpc '] = 'LPC 23:1';
- $QuicktimeAudioCodecLookup['MAC3'] = 'Macintosh Audio Compression/Expansion (MACE) 3:1';
- $QuicktimeAudioCodecLookup['MAC6'] = 'Macintosh Audio Compression/Expansion (MACE) 6:1';
- $QuicktimeAudioCodecLookup['mixb'] = '8-bit Mixer';
- $QuicktimeAudioCodecLookup['mixw'] = '16-bit Mixer';
- $QuicktimeAudioCodecLookup['mp4a'] = 'ISO/IEC 14496-3 AAC';
- $QuicktimeAudioCodecLookup['MS'."\x00\x02"] = 'Microsoft ADPCM';
- $QuicktimeAudioCodecLookup['MS'."\x00\x11"] = 'DV IMA';
- $QuicktimeAudioCodecLookup['MS'."\x00\x55"] = 'Fraunhofer MPEG Layer III';
- $QuicktimeAudioCodecLookup['NONE'] = 'No Encoding';
- $QuicktimeAudioCodecLookup['Qclp'] = 'Qualcomm PureVoice';
- $QuicktimeAudioCodecLookup['QDM2'] = 'QDesign Music 2';
- $QuicktimeAudioCodecLookup['QDMC'] = 'QDesign Music 1';
- $QuicktimeAudioCodecLookup['ratb'] = '8-bit Rate';
- $QuicktimeAudioCodecLookup['ratw'] = '16-bit Rate';
- $QuicktimeAudioCodecLookup['raw '] = 'raw PCM';
- $QuicktimeAudioCodecLookup['sour'] = 'Sound Source';
- $QuicktimeAudioCodecLookup['sowt'] = 'signed/two\'s complement (Little Endian)';
- $QuicktimeAudioCodecLookup['str1'] = 'Iomega MPEG layer II';
- $QuicktimeAudioCodecLookup['str2'] = 'Iomega MPEG *layer II';
- $QuicktimeAudioCodecLookup['str3'] = 'Iomega MPEG **layer II';
- $QuicktimeAudioCodecLookup['str4'] = 'Iomega MPEG ***layer II';
- $QuicktimeAudioCodecLookup['twos'] = 'signed/two\'s complement (Big Endian)';
- $QuicktimeAudioCodecLookup['ulaw'] = 'mu-law 2:1';
- }
- return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : '');
- }
-
- function QuicktimeDCOMLookup($compressionid) {
- static $QuicktimeDCOMLookup = array();
- if (empty($QuicktimeDCOMLookup)) {
- $QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate';
- $QuicktimeDCOMLookup['adec'] = 'Apple Compression';
- }
- return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : '');
- }
-
- function QuicktimeColorNameLookup($colordepthid) {
- static $QuicktimeColorNameLookup = array();
- if (empty($QuicktimeColorNameLookup)) {
- $QuicktimeColorNameLookup[1] = '2-color (monochrome)';
- $QuicktimeColorNameLookup[2] = '4-color';
- $QuicktimeColorNameLookup[4] = '16-color';
- $QuicktimeColorNameLookup[8] = '256-color';
- $QuicktimeColorNameLookup[16] = 'thousands (16-bit color)';
- $QuicktimeColorNameLookup[24] = 'millions (24-bit color)';
- $QuicktimeColorNameLookup[32] = 'millions+ (32-bit color)';
- $QuicktimeColorNameLookup[33] = 'black & white';
- $QuicktimeColorNameLookup[34] = '4-gray';
- $QuicktimeColorNameLookup[36] = '16-gray';
- $QuicktimeColorNameLookup[40] = '256-gray';
- }
- return (isset($QuicktimeColorNameLookup[$colordepthid]) ? $QuicktimeColorNameLookup[$colordepthid] : 'invalid');
- }
-
- function CopyToAppropriateCommentsSection($keyname, $data, &$ThisFileInfo) {
- static $handyatomtranslatorarray = array();
- if (empty($handyatomtranslatorarray)) {
- $handyatomtranslatorarray['©cpy'] = 'copyright';
- $handyatomtranslatorarray['©day'] = 'creation_date';
- $handyatomtranslatorarray['©dir'] = 'director';
- $handyatomtranslatorarray['©ed1'] = 'edit1';
- $handyatomtranslatorarray['©ed2'] = 'edit2';
- $handyatomtranslatorarray['©ed3'] = 'edit3';
- $handyatomtranslatorarray['©ed4'] = 'edit4';
- $handyatomtranslatorarray['©ed5'] = 'edit5';
- $handyatomtranslatorarray['©ed6'] = 'edit6';
- $handyatomtranslatorarray['©ed7'] = 'edit7';
- $handyatomtranslatorarray['©ed8'] = 'edit8';
- $handyatomtranslatorarray['©ed9'] = 'edit9';
- $handyatomtranslatorarray['©fmt'] = 'format';
- $handyatomtranslatorarray['©inf'] = 'information';
- $handyatomtranslatorarray['©prd'] = 'producer';
- $handyatomtranslatorarray['©prf'] = 'performers';
- $handyatomtranslatorarray['©req'] = 'system_requirements';
- $handyatomtranslatorarray['©src'] = 'source_credit';
- $handyatomtranslatorarray['©wrt'] = 'writer';
-
- // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt
- $handyatomtranslatorarray['©nam'] = 'title';
- $handyatomtranslatorarray['©cmt'] = 'comment';
- $handyatomtranslatorarray['©wrn'] = 'warning';
- $handyatomtranslatorarray['©hst'] = 'host_computer';
- $handyatomtranslatorarray['©mak'] = 'make';
- $handyatomtranslatorarray['©mod'] = 'model';
- $handyatomtranslatorarray['©PRD'] = 'product';
- $handyatomtranslatorarray['©swr'] = 'software';
- $handyatomtranslatorarray['©aut'] = 'author';
- $handyatomtranslatorarray['©ART'] = 'artist';
- $handyatomtranslatorarray['©trk'] = 'track';
- $handyatomtranslatorarray['©alb'] = 'album';
- $handyatomtranslatorarray['©com'] = 'comment';
- $handyatomtranslatorarray['©gen'] = 'genre';
- $handyatomtranslatorarray['©ope'] = 'composer';
- $handyatomtranslatorarray['©url'] = 'url';
- $handyatomtranslatorarray['©enc'] = 'encoder';
- }
- if (isset($handyatomtranslatorarray[$keyname])) {
- $ThisFileInfo['quicktime']['comments'][$handyatomtranslatorarray[$keyname]][] = $data;
- }
-
- return true;
- }
-
- function NoNullString($nullterminatedstring) {
- // remove the single null terminator on null terminated strings
- if (substr($nullterminatedstring, strlen($nullterminatedstring) - 1, 1) === "\x00") {
- return substr($nullterminatedstring, 0, strlen($nullterminatedstring) - 1);
- }
- return $nullterminatedstring;
- }
-
- function Pascal2String($pascalstring) {
- // Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string
- return substr($pascalstring, 1);
- }
-
-}
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.aac.php b/apps/media/getID3/getid3/module.audio.aac.php
deleted file mode 100644
index 7ab3e99f852..00000000000
--- a/apps/media/getID3/getid3/module.audio.aac.php
+++ /dev/null
@@ -1,542 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.aac.php //
-// module for analyzing AAC Audio files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_aac
-{
-
- // new combined constructor
- function getid3_aac(&$fd, &$ThisFileInfo, $option) {
-
- if ($option === 'adif') {
- $this->getAACADIFheaderFilepointer($fd, $ThisFileInfo);
- }
- elseif ($option === 'adts') {
- $this->getAACADTSheaderFilepointer($fd, $ThisFileInfo);
- }
- }
-
-
-
- function getAACADIFheaderFilepointer(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'aac';
- $ThisFileInfo['audio']['dataformat'] = 'aac';
- $ThisFileInfo['audio']['lossless'] = false;
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $AACheader = fread($fd, 1024);
- $offset = 0;
-
- if (substr($AACheader, 0, 4) == 'ADIF') {
-
- // http://faac.sourceforge.net/wiki/index.php?page=ADIF
-
- // http://libmpeg.org/mpeg4/doc/w2203tfs.pdf
- // adif_header() {
- // adif_id 32
- // copyright_id_present 1
- // if( copyright_id_present )
- // copyright_id 72
- // original_copy 1
- // home 1
- // bitstream_type 1
- // bitrate 23
- // num_program_config_elements 4
- // for (i = 0; i < num_program_config_elements + 1; i++ ) {
- // if( bitstream_type == '0' )
- // adif_buffer_fullness 20
- // program_config_element()
- // }
- // }
-
- $AACheaderBitstream = getid3_lib::BigEndian2Bin($AACheader);
- $bitoffset = 0;
-
- $ThisFileInfo['aac']['header_type'] = 'ADIF';
- $bitoffset += 32;
- $ThisFileInfo['aac']['header']['mpeg_version'] = 4;
-
- $ThisFileInfo['aac']['header']['copyright'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
- $bitoffset += 1;
- if ($ThisFileInfo['aac']['header']['copyright']) {
- $ThisFileInfo['aac']['header']['copyright_id'] = getid3_lib::Bin2String(substr($AACheaderBitstream, $bitoffset, 72));
- $bitoffset += 72;
- }
- $ThisFileInfo['aac']['header']['original_copy'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
- $bitoffset += 1;
- $ThisFileInfo['aac']['header']['home'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
- $bitoffset += 1;
- $ThisFileInfo['aac']['header']['is_vbr'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
- $bitoffset += 1;
- if ($ThisFileInfo['aac']['header']['is_vbr']) {
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
- $ThisFileInfo['aac']['header']['bitrate_max'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 23));
- $bitoffset += 23;
- } else {
- $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
- $ThisFileInfo['aac']['header']['bitrate'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 23));
- $bitoffset += 23;
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['aac']['header']['bitrate'];
- }
- if ($ThisFileInfo['audio']['bitrate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt AAC file: bitrate_audio == zero';
- return false;
- }
- $ThisFileInfo['aac']['header']['num_program_configs'] = 1 + getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
-
- for ($i = 0; $i < $ThisFileInfo['aac']['header']['num_program_configs']; $i++) {
- // http://www.audiocoding.com/wiki/index.php?page=program_config_element
-
- // buffer_fullness 20
-
- // element_instance_tag 4
- // object_type 2
- // sampling_frequency_index 4
- // num_front_channel_elements 4
- // num_side_channel_elements 4
- // num_back_channel_elements 4
- // num_lfe_channel_elements 2
- // num_assoc_data_elements 3
- // num_valid_cc_elements 4
- // mono_mixdown_present 1
- // mono_mixdown_element_number 4 if mono_mixdown_present == 1
- // stereo_mixdown_present 1
- // stereo_mixdown_element_number 4 if stereo_mixdown_present == 1
- // matrix_mixdown_idx_present 1
- // matrix_mixdown_idx 2 if matrix_mixdown_idx_present == 1
- // pseudo_surround_enable 1 if matrix_mixdown_idx_present == 1
- // for (i = 0; i < num_front_channel_elements; i++) {
- // front_element_is_cpe[i] 1
- // front_element_tag_select[i] 4
- // }
- // for (i = 0; i < num_side_channel_elements; i++) {
- // side_element_is_cpe[i] 1
- // side_element_tag_select[i] 4
- // }
- // for (i = 0; i < num_back_channel_elements; i++) {
- // back_element_is_cpe[i] 1
- // back_element_tag_select[i] 4
- // }
- // for (i = 0; i < num_lfe_channel_elements; i++) {
- // lfe_element_tag_select[i] 4
- // }
- // for (i = 0; i < num_assoc_data_elements; i++) {
- // assoc_data_element_tag_select[i] 4
- // }
- // for (i = 0; i < num_valid_cc_elements; i++) {
- // cc_element_is_ind_sw[i] 1
- // valid_cc_element_tag_select[i] 4
- // }
- // byte_alignment() VAR
- // comment_field_bytes 8
- // for (i = 0; i < comment_field_bytes; i++) {
- // comment_field_data[i] 8
- // }
-
- if (!$ThisFileInfo['aac']['header']['is_vbr']) {
- $ThisFileInfo['aac']['program_configs'][$i]['buffer_fullness'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 20));
- $bitoffset += 20;
- }
- $ThisFileInfo['aac']['program_configs'][$i]['element_instance_tag'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- $ThisFileInfo['aac']['program_configs'][$i]['object_type'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
- $bitoffset += 2;
- $ThisFileInfo['aac']['program_configs'][$i]['sampling_frequency_index'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- $ThisFileInfo['aac']['program_configs'][$i]['num_front_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- $ThisFileInfo['aac']['program_configs'][$i]['num_side_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- $ThisFileInfo['aac']['program_configs'][$i]['num_back_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- $ThisFileInfo['aac']['program_configs'][$i]['num_lfe_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
- $bitoffset += 2;
- $ThisFileInfo['aac']['program_configs'][$i]['num_assoc_data_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 3));
- $bitoffset += 3;
- $ThisFileInfo['aac']['program_configs'][$i]['num_valid_cc_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- $ThisFileInfo['aac']['program_configs'][$i]['mono_mixdown_present'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- if ($ThisFileInfo['aac']['program_configs'][$i]['mono_mixdown_present']) {
- $ThisFileInfo['aac']['program_configs'][$i]['mono_mixdown_element_number'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- }
- $ThisFileInfo['aac']['program_configs'][$i]['stereo_mixdown_present'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- if ($ThisFileInfo['aac']['program_configs'][$i]['stereo_mixdown_present']) {
- $ThisFileInfo['aac']['program_configs'][$i]['stereo_mixdown_element_number'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- }
- $ThisFileInfo['aac']['program_configs'][$i]['matrix_mixdown_idx_present'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- if ($ThisFileInfo['aac']['program_configs'][$i]['matrix_mixdown_idx_present']) {
- $ThisFileInfo['aac']['program_configs'][$i]['matrix_mixdown_idx'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
- $bitoffset += 2;
- $ThisFileInfo['aac']['program_configs'][$i]['pseudo_surround_enable'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- }
- for ($j = 0; $j < $ThisFileInfo['aac']['program_configs'][$i]['num_front_channel_elements']; $j++) {
- $ThisFileInfo['aac']['program_configs'][$i]['front_element_is_cpe'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- $ThisFileInfo['aac']['program_configs'][$i]['front_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- }
- for ($j = 0; $j < $ThisFileInfo['aac']['program_configs'][$i]['num_side_channel_elements']; $j++) {
- $ThisFileInfo['aac']['program_configs'][$i]['side_element_is_cpe'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- $ThisFileInfo['aac']['program_configs'][$i]['side_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- }
- for ($j = 0; $j < $ThisFileInfo['aac']['program_configs'][$i]['num_back_channel_elements']; $j++) {
- $ThisFileInfo['aac']['program_configs'][$i]['back_element_is_cpe'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- $ThisFileInfo['aac']['program_configs'][$i]['back_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- }
- for ($j = 0; $j < $ThisFileInfo['aac']['program_configs'][$i]['num_lfe_channel_elements']; $j++) {
- $ThisFileInfo['aac']['program_configs'][$i]['lfe_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- }
- for ($j = 0; $j < $ThisFileInfo['aac']['program_configs'][$i]['num_assoc_data_elements']; $j++) {
- $ThisFileInfo['aac']['program_configs'][$i]['assoc_data_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- }
- for ($j = 0; $j < $ThisFileInfo['aac']['program_configs'][$i]['num_valid_cc_elements']; $j++) {
- $ThisFileInfo['aac']['program_configs'][$i]['cc_element_is_ind_sw'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- $ThisFileInfo['aac']['program_configs'][$i]['valid_cc_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- }
-
- $bitoffset = ceil($bitoffset / 8) * 8;
-
- $ThisFileInfo['aac']['program_configs'][$i]['comment_field_bytes'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 8));
- $bitoffset += 8;
- $ThisFileInfo['aac']['program_configs'][$i]['comment_field'] = getid3_lib::Bin2String(substr($AACheaderBitstream, $bitoffset, 8 * $ThisFileInfo['aac']['program_configs'][$i]['comment_field_bytes']));
- $bitoffset += 8 * $ThisFileInfo['aac']['program_configs'][$i]['comment_field_bytes'];
-
-
- $ThisFileInfo['aac']['header']['profile_text'] = $this->AACprofileLookup($ThisFileInfo['aac']['program_configs'][$i]['object_type'], $ThisFileInfo['aac']['header']['mpeg_version']);
- $ThisFileInfo['aac']['program_configs'][$i]['sampling_frequency'] = $this->AACsampleRateLookup($ThisFileInfo['aac']['program_configs'][$i]['sampling_frequency_index']);
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['aac']['program_configs'][$i]['sampling_frequency'];
- $ThisFileInfo['audio']['channels'] = $this->AACchannelCountCalculate($ThisFileInfo['aac']['program_configs'][$i]);
- if ($ThisFileInfo['aac']['program_configs'][$i]['comment_field']) {
- $ThisFileInfo['aac']['comments'][] = $ThisFileInfo['aac']['program_configs'][$i]['comment_field'];
- }
- }
- $ThisFileInfo['playtime_seconds'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['audio']['bitrate'];
-
- $ThisFileInfo['audio']['encoder_options'] = $ThisFileInfo['aac']['header_type'].' '.$ThisFileInfo['aac']['header']['profile_text'];
-
-
-
- return true;
-
- } else {
-
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['aac']);
- $ThisFileInfo['error'][] = 'AAC-ADIF synch not found at offset '.$ThisFileInfo['avdataoffset'].' (expected "ADIF", found "'.substr($AACheader, 0, 4).'" instead)';
- return false;
-
- }
-
- }
-
-
- function getAACADTSheaderFilepointer(&$fd, &$ThisFileInfo, $MaxFramesToScan=1000000, $ReturnExtendedInfo=false) {
- // based loosely on code from AACfile by Jurgen Faul <jfaulØgmx.de>
- // http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
-
-
- // http://faac.sourceforge.net/wiki/index.php?page=ADTS
-
- // * ADTS Fixed Header: these don't change from frame to frame
- // syncword 12 always: '111111111111'
- // ID 1 0: MPEG-4, 1: MPEG-2
- // layer 2 always: '00'
- // protection_absent 1
- // profile 2
- // sampling_frequency_index 4
- // private_bit 1
- // channel_configuration 3
- // original/copy 1
- // home 1
- // emphasis 2 only if ID == 0 (ie MPEG-4)
-
- // * ADTS Variable Header: these can change from frame to frame
- // copyright_identification_bit 1
- // copyright_identification_start 1
- // aac_frame_length 13 length of the frame including header (in bytes)
- // adts_buffer_fullness 11 0x7FF indicates VBR
- // no_raw_data_blocks_in_frame 2
-
- // * ADTS Error check
- // crc_check 16 only if protection_absent == 0
-
- $byteoffset = 0;
- $framenumber = 0;
-
- // Init bit pattern array
- static $decbin = array();
-
- // Populate $bindec
- for ($i = 0; $i < 256; $i++) {
- $decbin[chr($i)] = str_pad(decbin($i), 8, '0', STR_PAD_LEFT);
- }
-
- // used to calculate bitrate below
- $BitrateCache = array();
-
-
- while (true) {
- // breaks out when end-of-file encountered, or invalid data found,
- // or MaxFramesToScan frames have been scanned
-
- if ($byteoffset >= pow(2, 31)) {
- $ThisFileInfo['warning'][] = 'Unable to parse AAC file beyond '.ftell($fd).' (PHP does not support file operations beyond 2GB)';
- return false;
- }
- fseek($fd, $byteoffset, SEEK_SET);
-
- // First get substring
- $substring = fread($fd, 10);
- $substringlength = strlen($substring);
- if ($substringlength != 10) {
- $ThisFileInfo['error'][] = 'Failed to read 10 bytes at offset '.(ftell($fd) - $substringlength).' (only read '.$substringlength.' bytes)';
- return false;
- }
-
- // Initialise $AACheaderBitstream
- $AACheaderBitstream = '';
-
- // Loop thru substring chars
- for ($i = 0; $i < 10; $i++) {
- $AACheaderBitstream .= $decbin[$substring{$i}];
- }
-
- $bitoffset = 0;
-
- $synctest = bindec(substr($AACheaderBitstream, $bitoffset, 12));
-
- $bitoffset += 12;
- if ($synctest != 0x0FFF) {
- $ThisFileInfo['error'][] = 'Synch pattern (0x0FFF) not found at offset '.(ftell($fd) - 10).' (found 0x0'.strtoupper(dechex($synctest)).' instead)';
- if ($ThisFileInfo['fileformat'] == 'aac') {
- return true;
- }
- return false;
- }
-
- // Gather info for first frame only - this takes time to do 1000 times!
- if ($framenumber > 0) {
-
- if (!$AACheaderBitstream[$bitoffset]) {
-
- // MPEG-4
- $bitoffset += 20;
-
- } else {
-
- // MPEG-2
- $bitoffset += 18;
-
- }
-
- } else {
-
- $ThisFileInfo['aac']['header_type'] = 'ADTS';
- $ThisFileInfo['aac']['header']['synch'] = $synctest;
- $ThisFileInfo['fileformat'] = 'aac';
- $ThisFileInfo['audio']['dataformat'] = 'aac';
-
- $ThisFileInfo['aac']['header']['mpeg_version'] = ((substr($AACheaderBitstream, $bitoffset, 1) == '0') ? 4 : 2);
- $bitoffset += 1;
- $ThisFileInfo['aac']['header']['layer'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
- $bitoffset += 2;
- if ($ThisFileInfo['aac']['header']['layer'] != 0) {
- $ThisFileInfo['error'][] = 'Layer error - expected 0x00, found 0x'.dechex($ThisFileInfo['aac']['header']['layer']).' instead';
- return false;
- }
- $ThisFileInfo['aac']['header']['crc_present'] = ((substr($AACheaderBitstream, $bitoffset, 1) == '0') ? true : false);
- $bitoffset += 1;
- $ThisFileInfo['aac']['header']['profile_id'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
- $bitoffset += 2;
- $ThisFileInfo['aac']['header']['profile_text'] = $this->AACprofileLookup($ThisFileInfo['aac']['header']['profile_id'], $ThisFileInfo['aac']['header']['mpeg_version']);
-
- $ThisFileInfo['aac']['header']['sample_frequency_index'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
- $bitoffset += 4;
- $ThisFileInfo['aac']['header']['sample_frequency'] = $this->AACsampleRateLookup($ThisFileInfo['aac']['header']['sample_frequency_index']);
- if ($ThisFileInfo['aac']['header']['sample_frequency'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt AAC file: sample_frequency == zero';
- return false;
- }
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['aac']['header']['sample_frequency'];
-
- $ThisFileInfo['aac']['header']['private'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- $ThisFileInfo['aac']['header']['channel_configuration'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 3));
- $bitoffset += 3;
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['aac']['header']['channel_configuration'];
- $ThisFileInfo['aac']['header']['original'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- $ThisFileInfo['aac']['header']['home'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
-
- if ($ThisFileInfo['aac']['header']['mpeg_version'] == 4) {
- $ThisFileInfo['aac']['header']['emphasis'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
- $bitoffset += 2;
- }
-
- if ($ReturnExtendedInfo) {
-
- $ThisFileInfo['aac'][$framenumber]['copyright_id_bit'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
- $ThisFileInfo['aac'][$framenumber]['copyright_id_start'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
- $bitoffset += 1;
-
- } else {
-
- $bitoffset += 2;
-
- }
-
- }
-
- $FrameLength = bindec(substr($AACheaderBitstream, $bitoffset, 13));
-
- if (!isset($BitrateCache[$FrameLength])) {
- $BitrateCache[$FrameLength] = ($ThisFileInfo['aac']['header']['sample_frequency'] / 1024) * $FrameLength * 8;
- }
- @$ThisFileInfo['aac']['bitrate_distribution'][$BitrateCache[$FrameLength]]++;
-
- $ThisFileInfo['aac'][$framenumber]['aac_frame_length'] = $FrameLength;
- $bitoffset += 13;
- $ThisFileInfo['aac'][$framenumber]['adts_buffer_fullness'] = bindec(substr($AACheaderBitstream, $bitoffset, 11));
- $bitoffset += 11;
- if ($ThisFileInfo['aac'][$framenumber]['adts_buffer_fullness'] == 0x07FF) {
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
- } else {
- $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
- }
- $ThisFileInfo['aac'][$framenumber]['num_raw_data_blocks'] = bindec(substr($AACheaderBitstream, $bitoffset, 2));
- $bitoffset += 2;
-
- if ($ThisFileInfo['aac']['header']['crc_present']) {
- //$ThisFileInfo['aac'][$framenumber]['crc'] = bindec(substr($AACheaderBitstream, $bitoffset, 16));
- $bitoffset += 16;
- }
-
- if (!$ReturnExtendedInfo) {
- unset($ThisFileInfo['aac'][$framenumber]);
- }
-
- $byteoffset += $FrameLength;
- if ((++$framenumber < $MaxFramesToScan) && (($byteoffset + 10) < $ThisFileInfo['avdataend'])) {
-
- // keep scanning
-
- } else {
-
- $ThisFileInfo['aac']['frames'] = $framenumber;
- $ThisFileInfo['playtime_seconds'] = ($ThisFileInfo['avdataend'] / $byteoffset) * (($framenumber * 1024) / $ThisFileInfo['aac']['header']['sample_frequency']); // (1 / % of file scanned) * (samples / (samples/sec)) = seconds
- if ($ThisFileInfo['playtime_seconds'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt AAC file: playtime_seconds == zero';
- return false;
- }
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
- ksort($ThisFileInfo['aac']['bitrate_distribution']);
-
- $ThisFileInfo['audio']['encoder_options'] = $ThisFileInfo['aac']['header_type'].' '.$ThisFileInfo['aac']['header']['profile_text'];
-
- return true;
-
- }
- }
- // should never get here.
- }
-
- function AACsampleRateLookup($samplerateid) {
- static $AACsampleRateLookup = array();
- if (empty($AACsampleRateLookup)) {
- $AACsampleRateLookup[0] = 96000;
- $AACsampleRateLookup[1] = 88200;
- $AACsampleRateLookup[2] = 64000;
- $AACsampleRateLookup[3] = 48000;
- $AACsampleRateLookup[4] = 44100;
- $AACsampleRateLookup[5] = 32000;
- $AACsampleRateLookup[6] = 24000;
- $AACsampleRateLookup[7] = 22050;
- $AACsampleRateLookup[8] = 16000;
- $AACsampleRateLookup[9] = 12000;
- $AACsampleRateLookup[10] = 11025;
- $AACsampleRateLookup[11] = 8000;
- $AACsampleRateLookup[12] = 0;
- $AACsampleRateLookup[13] = 0;
- $AACsampleRateLookup[14] = 0;
- $AACsampleRateLookup[15] = 0;
- }
- return (isset($AACsampleRateLookup[$samplerateid]) ? $AACsampleRateLookup[$samplerateid] : 'invalid');
- }
-
- function AACprofileLookup($profileid, $mpegversion) {
- static $AACprofileLookup = array();
- if (empty($AACprofileLookup)) {
- $AACprofileLookup[2][0] = 'Main profile';
- $AACprofileLookup[2][1] = 'Low Complexity profile (LC)';
- $AACprofileLookup[2][2] = 'Scalable Sample Rate profile (SSR)';
- $AACprofileLookup[2][3] = '(reserved)';
- $AACprofileLookup[4][0] = 'AAC_MAIN';
- $AACprofileLookup[4][1] = 'AAC_LC';
- $AACprofileLookup[4][2] = 'AAC_SSR';
- $AACprofileLookup[4][3] = 'AAC_LTP';
- }
- return (isset($AACprofileLookup[$mpegversion][$profileid]) ? $AACprofileLookup[$mpegversion][$profileid] : 'invalid');
- }
-
- function AACchannelCountCalculate($program_configs) {
- $channels = 0;
- for ($i = 0; $i < $program_configs['num_front_channel_elements']; $i++) {
- $channels++;
- if ($program_configs['front_element_is_cpe'][$i]) {
- // each front element is channel pair (CPE = Channel Pair Element)
- $channels++;
- }
- }
- for ($i = 0; $i < $program_configs['num_side_channel_elements']; $i++) {
- $channels++;
- if ($program_configs['side_element_is_cpe'][$i]) {
- // each side element is channel pair (CPE = Channel Pair Element)
- $channels++;
- }
- }
- for ($i = 0; $i < $program_configs['num_back_channel_elements']; $i++) {
- $channels++;
- if ($program_configs['back_element_is_cpe'][$i]) {
- // each back element is channel pair (CPE = Channel Pair Element)
- $channels++;
- }
- }
- for ($i = 0; $i < $program_configs['num_lfe_channel_elements']; $i++) {
- $channels++;
- }
- return $channels;
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.ac3.php b/apps/media/getID3/getid3/module.audio.ac3.php
deleted file mode 100644
index 9809a47c7b0..00000000000
--- a/apps/media/getID3/getid3/module.audio.ac3.php
+++ /dev/null
@@ -1,497 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.ac3.php //
-// module for analyzing AC-3 (aka Dolby Digital) audio files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_ac3
-{
-
- function getid3_ac3(&$fd, &$ThisFileInfo) {
-
- ///AH
- $ThisFileInfo['ac3']['raw']['bsi'] = array();
- $thisfile_ac3 = &$ThisFileInfo['ac3'];
- $thisfile_ac3_raw = &$thisfile_ac3['raw'];
- $thisfile_ac3_raw_bsi = &$thisfile_ac3_raw['bsi'];
-
-
- // http://www.atsc.org/standards/a_52a.pdf
-
- $ThisFileInfo['fileformat'] = 'ac3';
- $ThisFileInfo['audio']['dataformat'] = 'ac3';
- $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
- $ThisFileInfo['audio']['lossless'] = false;
-
- // An AC-3 serial coded audio bit stream is made up of a sequence of synchronization frames
- // Each synchronization frame contains 6 coded audio blocks (AB), each of which represent 256
- // new audio samples per channel. A synchronization information (SI) header at the beginning
- // of each frame contains information needed to acquire and maintain synchronization. A
- // bit stream information (BSI) header follows SI, and contains parameters describing the coded
- // audio service. The coded audio blocks may be followed by an auxiliary data (Aux) field. At the
- // end of each frame is an error check field that includes a CRC word for error detection. An
- // additional CRC word is located in the SI header, the use of which, by a decoder, is optional.
- //
- // syncinfo() | bsi() | AB0 | AB1 | AB2 | AB3 | AB4 | AB5 | Aux | CRC
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $AC3header['syncinfo'] = fread($fd, 5);
- $thisfile_ac3_raw['synchinfo']['synchword'] = substr($AC3header['syncinfo'], 0, 2);
-
- if ($thisfile_ac3_raw['synchinfo']['synchword'] != "\x0B\x77") {
-
- $ThisFileInfo['error'][] = 'Expecting "\x0B\x77" at offset '.$ThisFileInfo['avdataoffset'].', found \x'.strtoupper(dechex($AC3header['syncinfo']{0})).'\x'.strtoupper(dechex($AC3header['syncinfo']{1})).' instead';
- unset($thisfile_ac3);
- return false;
-
- } else {
-
- // syncinfo() {
- // syncword 16
- // crc1 16
- // fscod 2
- // frmsizecod 6
- // } /* end of syncinfo */
-
- $thisfile_ac3_raw['synchinfo']['crc1'] = getid3_lib::LittleEndian2Int(substr($AC3header['syncinfo'], 2, 2));
- $ac3_synchinfo_fscod_frmsizecod = getid3_lib::LittleEndian2Int(substr($AC3header['syncinfo'], 4, 1));
- $thisfile_ac3_raw['synchinfo']['fscod'] = ($ac3_synchinfo_fscod_frmsizecod & 0xC0) >> 6;
- $thisfile_ac3_raw['synchinfo']['frmsizecod'] = ($ac3_synchinfo_fscod_frmsizecod & 0x3F);
-
- $thisfile_ac3['sample_rate'] = $this->AC3sampleRateCodeLookup($thisfile_ac3_raw['synchinfo']['fscod']);
- if ($thisfile_ac3_raw['synchinfo']['fscod'] <= 3) {
- $ThisFileInfo['audio']['sample_rate'] = $thisfile_ac3['sample_rate'];
- }
-
- $thisfile_ac3['frame_length'] = $this->AC3frameSizeLookup($thisfile_ac3_raw['synchinfo']['frmsizecod'], $thisfile_ac3_raw['synchinfo']['fscod']);
- $thisfile_ac3['bitrate'] = $this->AC3bitrateLookup($thisfile_ac3_raw['synchinfo']['frmsizecod']);
- $ThisFileInfo['audio']['bitrate'] = $thisfile_ac3['bitrate'];
-
- $AC3header['bsi'] = getid3_lib::BigEndian2Bin(fread($fd, 15));
- $ac3_bsi_offset = 0;
-
- $thisfile_ac3_raw_bsi['bsid'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 5));
- $ac3_bsi_offset += 5;
- if ($thisfile_ac3_raw_bsi['bsid'] > 8) {
- // Decoders which can decode version 8 will thus be able to decode version numbers less than 8.
- // If this standard is extended by the addition of additional elements or features, a value of bsid greater than 8 will be used.
- // Decoders built to this version of the standard will not be able to decode versions with bsid greater than 8.
- $ThisFileInfo['error'][] = 'Bit stream identification is version '.$thisfile_ac3_raw_bsi['bsid'].', but getID3() only understands up to version 8';
- unset($thisfile_ac3);
- return false;
- }
-
- $thisfile_ac3_raw_bsi['bsmod'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 3));
- $ac3_bsi_offset += 3;
- $thisfile_ac3_raw_bsi['acmod'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 3));
- $ac3_bsi_offset += 3;
-
- $thisfile_ac3['service_type'] = $this->AC3serviceTypeLookup($thisfile_ac3_raw_bsi['bsmod'], $thisfile_ac3_raw_bsi['acmod']);
- $ac3_coding_mode = $this->AC3audioCodingModeLookup($thisfile_ac3_raw_bsi['acmod']);
- foreach($ac3_coding_mode as $key => $value) {
- $thisfile_ac3[$key] = $value;
- }
- switch ($thisfile_ac3_raw_bsi['acmod']) {
- case 0:
- case 1:
- $ThisFileInfo['audio']['channelmode'] = 'mono';
- break;
- case 3:
- case 4:
- $ThisFileInfo['audio']['channelmode'] = 'stereo';
- break;
- default:
- $ThisFileInfo['audio']['channelmode'] = 'surround';
- break;
- }
- $ThisFileInfo['audio']['channels'] = $thisfile_ac3['num_channels'];
-
- if ($thisfile_ac3_raw_bsi['acmod'] & 0x01) {
- // If the lsb of acmod is a 1, center channel is in use and cmixlev follows in the bit stream.
- $thisfile_ac3_raw_bsi['cmixlev'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 2));
- $ac3_bsi_offset += 2;
- $thisfile_ac3['center_mix_level'] = $this->AC3centerMixLevelLookup($thisfile_ac3_raw_bsi['cmixlev']);
- }
-
- if ($thisfile_ac3_raw_bsi['acmod'] & 0x04) {
- // If the msb of acmod is a 1, surround channels are in use and surmixlev follows in the bit stream.
- $thisfile_ac3_raw_bsi['surmixlev'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 2));
- $ac3_bsi_offset += 2;
- $thisfile_ac3['surround_mix_level'] = $this->AC3surroundMixLevelLookup($thisfile_ac3_raw_bsi['surmixlev']);
- }
-
- if ($thisfile_ac3_raw_bsi['acmod'] == 0x02) {
- // When operating in the two channel mode, this 2-bit code indicates whether or not the program has been encoded in Dolby Surround.
- $thisfile_ac3_raw_bsi['dsurmod'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 2));
- $ac3_bsi_offset += 2;
- $thisfile_ac3['dolby_surround_mode'] = $this->AC3dolbySurroundModeLookup($thisfile_ac3_raw_bsi['dsurmod']);
- }
-
- $thisfile_ac3_raw_bsi['lfeon'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
- $thisfile_ac3['lfe_enabled'] = $thisfile_ac3_raw_bsi['lfeon'];
- if ($thisfile_ac3_raw_bsi['lfeon']) {
- //$ThisFileInfo['audio']['channels']++;
- $ThisFileInfo['audio']['channels'] .= '.1';
- }
-
- $thisfile_ac3['channels_enabled'] = $this->AC3channelsEnabledLookup($thisfile_ac3_raw_bsi['acmod'], $thisfile_ac3_raw_bsi['lfeon']);
-
- // This indicates how far the average dialogue level is below digital 100 percent. Valid values are 1–31.
- // The value of 0 is reserved. The values of 1 to 31 are interpreted as -1 dB to -31 dB with respect to digital 100 percent.
- $thisfile_ac3_raw_bsi['dialnorm'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 5));
- $ac3_bsi_offset += 5;
- $thisfile_ac3['dialogue_normalization'] = '-'.$thisfile_ac3_raw_bsi['dialnorm'].'dB';
-
- $thisfile_ac3_raw_bsi['compre_flag'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
- if ($thisfile_ac3_raw_bsi['compre_flag']) {
- $thisfile_ac3_raw_bsi['compr'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 8));
- $ac3_bsi_offset += 8;
- $thisfile_ac3['heavy_compression'] = $this->AC3heavyCompression($thisfile_ac3_raw_bsi['compr']);
- }
-
- $thisfile_ac3_raw_bsi['langcode_flag'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
- if ($thisfile_ac3_raw_bsi['langcode_flag']) {
- $thisfile_ac3_raw_bsi['langcod'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 8));
- $ac3_bsi_offset += 8;
- }
-
- $thisfile_ac3_raw_bsi['audprodie'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
- if ($thisfile_ac3_raw_bsi['audprodie']) {
- $thisfile_ac3_raw_bsi['mixlevel'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 5));
- $ac3_bsi_offset += 5;
- $thisfile_ac3_raw_bsi['roomtyp'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 2));
- $ac3_bsi_offset += 2;
-
- $thisfile_ac3['mixing_level'] = (80 + $thisfile_ac3_raw_bsi['mixlevel']).'dB';
- $thisfile_ac3['room_type'] = $this->AC3roomTypeLookup($thisfile_ac3_raw_bsi['roomtyp']);
- }
-
- if ($thisfile_ac3_raw_bsi['acmod'] == 0x00) {
- // If acmod is 0, then two completely independent program channels (dual mono)
- // are encoded into the bit stream, and are referenced as Ch1, Ch2. In this case,
- // a number of additional items are present in BSI or audblk to fully describe Ch2.
-
-
- // This indicates how far the average dialogue level is below digital 100 percent. Valid values are 1–31.
- // The value of 0 is reserved. The values of 1 to 31 are interpreted as -1 dB to -31 dB with respect to digital 100 percent.
- $thisfile_ac3_raw_bsi['dialnorm2'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 5));
- $ac3_bsi_offset += 5;
- $thisfile_ac3['dialogue_normalization2'] = '-'.$thisfile_ac3_raw_bsi['dialnorm2'].'dB';
-
- $thisfile_ac3_raw_bsi['compre_flag2'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
- if ($thisfile_ac3_raw_bsi['compre_flag2']) {
- $thisfile_ac3_raw_bsi['compr2'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 8));
- $ac3_bsi_offset += 8;
- $thisfile_ac3['heavy_compression2'] = $this->AC3heavyCompression($thisfile_ac3_raw_bsi['compr2']);
- }
-
- $thisfile_ac3_raw_bsi['langcode_flag2'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
- if ($thisfile_ac3_raw_bsi['langcode_flag2']) {
- $thisfile_ac3_raw_bsi['langcod2'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 8));
- $ac3_bsi_offset += 8;
- }
-
- $thisfile_ac3_raw_bsi['audprodie2'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
- if ($thisfile_ac3_raw_bsi['audprodie2']) {
- $thisfile_ac3_raw_bsi['mixlevel2'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 5));
- $ac3_bsi_offset += 5;
- $thisfile_ac3_raw_bsi['roomtyp2'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 2));
- $ac3_bsi_offset += 2;
-
- $thisfile_ac3['mixing_level2'] = (80 + $thisfile_ac3_raw_bsi['mixlevel2']).'dB';
- $thisfile_ac3['room_type2'] = $this->AC3roomTypeLookup($thisfile_ac3_raw_bsi['roomtyp2']);
- }
-
- }
-
- $thisfile_ac3_raw_bsi['copyright'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
-
- $thisfile_ac3_raw_bsi['original'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
-
- $thisfile_ac3_raw_bsi['timecode1_flag'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
- if ($thisfile_ac3_raw_bsi['timecode1_flag']) {
- $thisfile_ac3_raw_bsi['timecode1'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 14));
- $ac3_bsi_offset += 14;
- }
-
- $thisfile_ac3_raw_bsi['timecode2_flag'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
- if ($thisfile_ac3_raw_bsi['timecode2_flag']) {
- $thisfile_ac3_raw_bsi['timecode2'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 14));
- $ac3_bsi_offset += 14;
- }
-
- $thisfile_ac3_raw_bsi['addbsi_flag'] = (bool) bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 1));
- $ac3_bsi_offset += 1;
- if ($thisfile_ac3_raw_bsi['addbsi_flag']) {
- $thisfile_ac3_raw_bsi['addbsi_length'] = bindec(substr($AC3header['bsi'], $ac3_bsi_offset, 6));
- $ac3_bsi_offset += 6;
-
- $AC3header['bsi'] .= getid3_lib::BigEndian2Bin(fread($fd, $thisfile_ac3_raw_bsi['addbsi_length']));
-
- $thisfile_ac3_raw_bsi['addbsi_data'] = substr($AC3header['bsi'], $ac3_bsi_offset, $thisfile_ac3_raw_bsi['addbsi_length'] * 8);
- $ac3_bsi_offset += $thisfile_ac3_raw_bsi['addbsi_length'] * 8;
- }
-
- }
-
- return true;
- }
-
-
- function AC3sampleRateCodeLookup($fscod) {
- static $AC3sampleRateCodeLookup = array(
- 0 => 48000,
- 1 => 44100,
- 2 => 32000,
- 3 => 'reserved' // If the reserved code is indicated, the decoder should not attempt to decode audio and should mute.
- );
- return (isset($AC3sampleRateCodeLookup[$fscod]) ? $AC3sampleRateCodeLookup[$fscod] : false);
- }
-
- function AC3serviceTypeLookup($bsmod, $acmod) {
- static $AC3serviceTypeLookup = array();
- if (empty($AC3serviceTypeLookup)) {
- for ($i = 0; $i <= 7; $i++) {
- $AC3serviceTypeLookup[0][$i] = 'main audio service: complete main (CM)';
- $AC3serviceTypeLookup[1][$i] = 'main audio service: music and effects (ME)';
- $AC3serviceTypeLookup[2][$i] = 'associated service: visually impaired (VI)';
- $AC3serviceTypeLookup[3][$i] = 'associated service: hearing impaired (HI)';
- $AC3serviceTypeLookup[4][$i] = 'associated service: dialogue (D)';
- $AC3serviceTypeLookup[5][$i] = 'associated service: commentary (C)';
- $AC3serviceTypeLookup[6][$i] = 'associated service: emergency (E)';
- }
-
- $AC3serviceTypeLookup[7][1] = 'associated service: voice over (VO)';
- for ($i = 2; $i <= 7; $i++) {
- $AC3serviceTypeLookup[7][$i] = 'main audio service: karaoke';
- }
- }
- return (isset($AC3serviceTypeLookup[$bsmod][$acmod]) ? $AC3serviceTypeLookup[$bsmod][$acmod] : false);
- }
-
- function AC3audioCodingModeLookup($acmod) {
- static $AC3audioCodingModeLookup = array();
- if (empty($AC3audioCodingModeLookup)) {
- // array(channel configuration, # channels (not incl LFE), channel order)
- $AC3audioCodingModeLookup = array (
- 0 => array('channel_config'=>'1+1', 'num_channels'=>2, 'channel_order'=>'Ch1,Ch2'),
- 1 => array('channel_config'=>'1/0', 'num_channels'=>1, 'channel_order'=>'C'),
- 2 => array('channel_config'=>'2/0', 'num_channels'=>2, 'channel_order'=>'L,R'),
- 3 => array('channel_config'=>'3/0', 'num_channels'=>3, 'channel_order'=>'L,C,R'),
- 4 => array('channel_config'=>'2/1', 'num_channels'=>3, 'channel_order'=>'L,R,S'),
- 5 => array('channel_config'=>'3/1', 'num_channels'=>4, 'channel_order'=>'L,C,R,S'),
- 6 => array('channel_config'=>'2/2', 'num_channels'=>4, 'channel_order'=>'L,R,SL,SR'),
- 7 => array('channel_config'=>'3/2', 'num_channels'=>5, 'channel_order'=>'L,C,R,SL,SR')
- );
- }
- return (isset($AC3audioCodingModeLookup[$acmod]) ? $AC3audioCodingModeLookup[$acmod] : false);
- }
-
- function AC3centerMixLevelLookup($cmixlev) {
- static $AC3centerMixLevelLookup;
- if (empty($AC3centerMixLevelLookup)) {
- $AC3centerMixLevelLookup = array(
- 0 => pow(2, -3.0 / 6), // 0.707 (–3.0 dB)
- 1 => pow(2, -4.5 / 6), // 0.595 (–4.5 dB)
- 2 => pow(2, -6.0 / 6), // 0.500 (–6.0 dB)
- 3 => 'reserved'
- );
- }
- return (isset($AC3centerMixLevelLookup[$cmixlev]) ? $AC3centerMixLevelLookup[$cmixlev] : false);
- }
-
- function AC3surroundMixLevelLookup($surmixlev) {
- static $AC3surroundMixLevelLookup;
- if (empty($AC3surroundMixLevelLookup)) {
- $AC3surroundMixLevelLookup = array(
- 0 => pow(2, -3.0 / 6),
- 1 => pow(2, -6.0 / 6),
- 2 => 0,
- 3 => 'reserved'
- );
- }
- return (isset($AC3surroundMixLevelLookup[$surmixlev]) ? $AC3surroundMixLevelLookup[$surmixlev] : false);
- }
-
- function AC3dolbySurroundModeLookup($dsurmod) {
- static $AC3dolbySurroundModeLookup = array(
- 0 => 'not indicated',
- 1 => 'Not Dolby Surround encoded',
- 2 => 'Dolby Surround encoded',
- 3 => 'reserved'
- );
- return (isset($AC3dolbySurroundModeLookup[$dsurmod]) ? $AC3dolbySurroundModeLookup[$dsurmod] : false);
- }
-
- function AC3channelsEnabledLookup($acmod, $lfeon) {
- $AC3channelsEnabledLookup = array(
- 'ch1'=>(bool) ($acmod == 0),
- 'ch2'=>(bool) ($acmod == 0),
- 'left'=>(bool) ($acmod > 1),
- 'right'=>(bool) ($acmod > 1),
- 'center'=>(bool) ($acmod & 0x01),
- 'surround_mono'=>false,
- 'surround_left'=>false,
- 'surround_right'=>false,
- 'lfe'=>$lfeon);
- switch ($acmod) {
- case 4:
- case 5:
- $AC3channelsEnabledLookup['surround_mono'] = true;
- break;
- case 6:
- case 7:
- $AC3channelsEnabledLookup['surround_left'] = true;
- $AC3channelsEnabledLookup['surround_right'] = true;
- break;
- }
- return $AC3channelsEnabledLookup;
- }
-
- function AC3heavyCompression($compre) {
- // The first four bits indicate gain changes in 6.02dB increments which can be
- // implemented with an arithmetic shift operation. The following four bits
- // indicate linear gain changes, and require a 5-bit multiply.
- // We will represent the two 4-bit fields of compr as follows:
- // X0 X1 X2 X3 . Y4 Y5 Y6 Y7
- // The meaning of the X values is most simply described by considering X to represent a 4-bit
- // signed integer with values from –8 to +7. The gain indicated by X is then (X + 1) * 6.02 dB. The
- // following table shows this in detail.
-
- // Meaning of 4 msb of compr
- // 7 +48.16 dB
- // 6 +42.14 dB
- // 5 +36.12 dB
- // 4 +30.10 dB
- // 3 +24.08 dB
- // 2 +18.06 dB
- // 1 +12.04 dB
- // 0 +6.02 dB
- // -1 0 dB
- // -2 –6.02 dB
- // -3 –12.04 dB
- // -4 –18.06 dB
- // -5 –24.08 dB
- // -6 –30.10 dB
- // -7 –36.12 dB
- // -8 –42.14 dB
-
- $fourbit = str_pad(decbin(($compre & 0xF0) >> 4), 4, '0', STR_PAD_LEFT);
- if ($fourbit{0} == '1') {
- $log_gain = -8 + bindec(substr($fourbit, 1));
- } else {
- $log_gain = bindec(substr($fourbit, 1));
- }
- $log_gain = ($log_gain + 1) * getid3_lib::RGADamplitude2dB(2);
-
- // The value of Y is a linear representation of a gain change of up to –6 dB. Y is considered to
- // be an unsigned fractional integer, with a leading value of 1, or: 0.1 Y4 Y5 Y6 Y7 (base 2). Y can
- // represent values between 0.111112 (or 31/32) and 0.100002 (or 1/2). Thus, Y can represent gain
- // changes from –0.28 dB to –6.02 dB.
-
- $lin_gain = (16 + ($compre & 0x0F)) / 32;
-
- // The combination of X and Y values allows compr to indicate gain changes from
- // 48.16 – 0.28 = +47.89 dB, to
- // –42.14 – 6.02 = –48.16 dB.
-
- return $log_gain - $lin_gain;
- }
-
- function AC3roomTypeLookup($roomtyp) {
- static $AC3roomTypeLookup = array(
- 0 => 'not indicated',
- 1 => 'large room, X curve monitor',
- 2 => 'small room, flat monitor',
- 3 => 'reserved'
- );
- return (isset($AC3roomTypeLookup[$roomtyp]) ? $AC3roomTypeLookup[$roomtyp] : false);
- }
-
- function AC3frameSizeLookup($frmsizecod, $fscod) {
- $padding = (bool) ($frmsizecod % 2);
- $framesizeid = floor($frmsizecod / 2);
-
- static $AC3frameSizeLookup = array();
- if (empty($AC3frameSizeLookup)) {
- $AC3frameSizeLookup = array (
- 0 => array(128, 138, 192),
- 1 => array(40, 160, 174, 240),
- 2 => array(48, 192, 208, 288),
- 3 => array(56, 224, 242, 336),
- 4 => array(64, 256, 278, 384),
- 5 => array(80, 320, 348, 480),
- 6 => array(96, 384, 416, 576),
- 7 => array(112, 448, 486, 672),
- 8 => array(128, 512, 556, 768),
- 9 => array(160, 640, 696, 960),
- 10 => array(192, 768, 834, 1152),
- 11 => array(224, 896, 974, 1344),
- 12 => array(256, 1024, 1114, 1536),
- 13 => array(320, 1280, 1392, 1920),
- 14 => array(384, 1536, 1670, 2304),
- 15 => array(448, 1792, 1950, 2688),
- 16 => array(512, 2048, 2228, 3072),
- 17 => array(576, 2304, 2506, 3456),
- 18 => array(640, 2560, 2786, 3840)
- );
- }
- if (($fscod == 1) && $padding) {
- // frame lengths are padded by 1 word (16 bits) at 44100
- $AC3frameSizeLookup[$frmsizecod] += 2;
- }
- return (isset($AC3frameSizeLookup[$framesizeid][$fscod]) ? $AC3frameSizeLookup[$framesizeid][$fscod] : false);
- }
-
- function AC3bitrateLookup($frmsizecod) {
- $framesizeid = floor($frmsizecod / 2);
-
- static $AC3bitrateLookup = array(
- 0 => 32000,
- 1 => 40000,
- 2 => 48000,
- 3 => 56000,
- 4 => 64000,
- 5 => 80000,
- 6 => 96000,
- 7 => 112000,
- 8 => 128000,
- 9 => 160000,
- 10 => 192000,
- 11 => 224000,
- 12 => 256000,
- 13 => 320000,
- 14 => 384000,
- 15 => 448000,
- 16 => 512000,
- 17 => 576000,
- 18 => 640000
- );
- return (isset($AC3bitrateLookup[$framesizeid]) ? $AC3bitrateLookup[$framesizeid] : false);
- }
-
-
-}
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.avr.php b/apps/media/getID3/getid3/module.audio.avr.php
deleted file mode 100644
index 60994397e3a..00000000000
--- a/apps/media/getID3/getid3/module.audio.avr.php
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.avr.php //
-// module for analyzing AVR Audio files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_avr
-{
-
- function getid3_avr(&$fd, &$ThisFileInfo) {
-
- // http://cui.unige.ch/OSG/info/AudioFormats/ap11.html
- // http://www.btinternet.com/~AnthonyJ/Atari/programming/avr_format.html
- // offset type length name comments
- // ---------------------------------------------------------------------
- // 0 char 4 ID format ID == "2BIT"
- // 4 char 8 name sample name (unused space filled with 0)
- // 12 short 1 mono/stereo 0=mono, -1 (0xFFFF)=stereo
- // With stereo, samples are alternated,
- // the first voice is the left :
- // (LRLRLRLRLRLRLRLRLR...)
- // 14 short 1 resolution 8, 12 or 16 (bits)
- // 16 short 1 signed or not 0=unsigned, -1 (0xFFFF)=signed
- // 18 short 1 loop or not 0=no loop, -1 (0xFFFF)=loop on
- // 20 short 1 MIDI note 0xFFnn, where 0 <= nn <= 127
- // 0xFFFF means "no MIDI note defined"
- // 22 byte 1 Replay speed Frequence in the Replay software
- // 0=5.485 Khz, 1=8.084 Khz, 2=10.971 Khz,
- // 3=16.168 Khz, 4=21.942 Khz, 5=32.336 Khz
- // 6=43.885 Khz, 7=47.261 Khz
- // -1 (0xFF)=no defined Frequence
- // 23 byte 3 sample rate in Hertz
- // 26 long 1 size in bytes (2 * bytes in stereo)
- // 30 long 1 loop begin 0 for no loop
- // 34 long 1 loop size equal to 'size' for no loop
- // 38 short 2 Reserved, MIDI keyboard split */
- // 40 short 2 Reserved, sample compression */
- // 42 short 2 Reserved */
- // 44 char 20; Additional filename space, used if (name[7] != 0)
- // 64 byte 64 user data
- // 128 bytes ? sample data (12 bits samples are coded on 16 bits:
- // 0000 xxxx xxxx xxxx)
- // ---------------------------------------------------------------------
-
- // Note that all values are in motorola (big-endian) format, and that long is
- // assumed to be 4 bytes, and short 2 bytes.
- // When reading the samples, you should handle both signed and unsigned data,
- // and be prepared to convert 16->8 bit, or mono->stereo if needed. To convert
- // 8-bit data between signed/unsigned just add 127 to the sample values.
- // Simularly for 16-bit data you should add 32769
-
- $ThisFileInfo['fileformat'] = 'avr';
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $AVRheader = fread($fd, 128);
-
- $ThisFileInfo['avr']['raw']['magic'] = substr($AVRheader, 0, 4);
- if ($ThisFileInfo['avr']['raw']['magic'] != '2BIT') {
- $ThisFileInfo['error'][] = 'Expecting "2BIT" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$ThisFileInfo['avr']['raw']['magic'].'"';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['avr']);
- return false;
- }
- $ThisFileInfo['avdataoffset'] += 128;
-
- $ThisFileInfo['avr']['sample_name'] = rtrim(substr($AVRheader, 4, 8));
- $ThisFileInfo['avr']['raw']['mono'] = getid3_lib::BigEndian2Int(substr($AVRheader, 12, 2));
- $ThisFileInfo['avr']['bits_per_sample'] = getid3_lib::BigEndian2Int(substr($AVRheader, 14, 2));
- $ThisFileInfo['avr']['raw']['signed'] = getid3_lib::BigEndian2Int(substr($AVRheader, 16, 2));
- $ThisFileInfo['avr']['raw']['loop'] = getid3_lib::BigEndian2Int(substr($AVRheader, 18, 2));
- $ThisFileInfo['avr']['raw']['midi'] = getid3_lib::BigEndian2Int(substr($AVRheader, 20, 2));
- $ThisFileInfo['avr']['raw']['replay_freq'] = getid3_lib::BigEndian2Int(substr($AVRheader, 22, 1));
- $ThisFileInfo['avr']['sample_rate'] = getid3_lib::BigEndian2Int(substr($AVRheader, 23, 3));
- $ThisFileInfo['avr']['sample_length'] = getid3_lib::BigEndian2Int(substr($AVRheader, 26, 4));
- $ThisFileInfo['avr']['loop_start'] = getid3_lib::BigEndian2Int(substr($AVRheader, 30, 4));
- $ThisFileInfo['avr']['loop_end'] = getid3_lib::BigEndian2Int(substr($AVRheader, 34, 4));
- $ThisFileInfo['avr']['midi_split'] = getid3_lib::BigEndian2Int(substr($AVRheader, 38, 2));
- $ThisFileInfo['avr']['sample_compression'] = getid3_lib::BigEndian2Int(substr($AVRheader, 40, 2));
- $ThisFileInfo['avr']['reserved'] = getid3_lib::BigEndian2Int(substr($AVRheader, 42, 2));
- $ThisFileInfo['avr']['sample_name_extra'] = rtrim(substr($AVRheader, 44, 20));
- $ThisFileInfo['avr']['comment'] = rtrim(substr($AVRheader, 64, 64));
-
- $ThisFileInfo['avr']['flags']['stereo'] = (($ThisFileInfo['avr']['raw']['mono'] == 0) ? false : true);
- $ThisFileInfo['avr']['flags']['signed'] = (($ThisFileInfo['avr']['raw']['signed'] == 0) ? false : true);
- $ThisFileInfo['avr']['flags']['loop'] = (($ThisFileInfo['avr']['raw']['loop'] == 0) ? false : true);
-
- $ThisFileInfo['avr']['midi_notes'] = array();
- if (($ThisFileInfo['avr']['raw']['midi'] & 0xFF00) != 0xFF00) {
- $ThisFileInfo['avr']['midi_notes'][] = ($ThisFileInfo['avr']['raw']['midi'] & 0xFF00) >> 8;
- }
- if (($ThisFileInfo['avr']['raw']['midi'] & 0x00FF) != 0x00FF) {
- $ThisFileInfo['avr']['midi_notes'][] = ($ThisFileInfo['avr']['raw']['midi'] & 0x00FF);
- }
-
- if (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) != ($ThisFileInfo['avr']['sample_length'] * (($ThisFileInfo['avr']['bits_per_sample'] == 8) ? 1 : 2))) {
- $ThisFileInfo['warning'][] = 'Probable truncated file: expecting '.($ThisFileInfo['avr']['sample_length'] * (($ThisFileInfo['avr']['bits_per_sample'] == 8) ? 1 : 2)).' bytes of audio data, found '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']);
- }
-
- $ThisFileInfo['audio']['dataformat'] = 'avr';
- $ThisFileInfo['audio']['lossless'] = true;
- $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['avr']['bits_per_sample'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['avr']['sample_rate'];
- $ThisFileInfo['audio']['channels'] = ($ThisFileInfo['avr']['flags']['stereo'] ? 2 : 1);
- $ThisFileInfo['playtime_seconds'] = ($ThisFileInfo['avr']['sample_length'] / $ThisFileInfo['audio']['channels']) / $ThisFileInfo['avr']['sample_rate'];
- $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['avr']['sample_length'] * (($ThisFileInfo['avr']['bits_per_sample'] == 8) ? 8 : 16)) / $ThisFileInfo['playtime_seconds'];
-
-
- return true;
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.dts.php b/apps/media/getID3/getid3/module.audio.dts.php
deleted file mode 100644
index 1af67fdb5ae..00000000000
--- a/apps/media/getID3/getid3/module.audio.dts.php
+++ /dev/null
@@ -1,239 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.dts.php //
-// module for analyzing DTS Audio files //
-// dependencies: NONE //
-// //
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_dts
-{
-
- function getid3_dts(&$fd, &$ThisFileInfo) {
- // Specs taken from "DTS Coherent Acoustics;Core and Extensions, ETSI TS 102 114 V1.2.1 (2002-12)"
- // (http://pda.etsi.org/pda/queryform.asp)
- // With thanks to Gambit <macteam@users.sourceforge.net> http://mac.sourceforge.net/atl/
-
- $ThisFileInfo['fileformat'] = 'dts';
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $DTSheader = fread($fd, 16);
-
- $ThisFileInfo['dts']['raw']['magic'] = getid3_lib::BigEndian2Int(substr($DTSheader, 0, 4));
- if ($ThisFileInfo['dts']['raw']['magic'] != 0x7FFE8001) {
- $ThisFileInfo['error'][] = 'Expecting "0x7FFE8001" at offset '.$ThisFileInfo['avdataoffset'].', found "0x'.str_pad(strtoupper(dechex($ThisFileInfo['dts']['raw']['magic'])), 8, '0', STR_PAD_LEFT).'"';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['dts']);
- return false;
- }
-
- $fhBS = getid3_lib::BigEndian2Bin(substr($DTSheader, 4, 12));
- $bsOffset = 0;
- $ThisFileInfo['dts']['raw']['frame_type'] = bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['raw']['deficit_samples'] = bindec(substr($fhBS, $bsOffset, 5)); $bsOffset += 5;
- $ThisFileInfo['dts']['flags']['crc_present'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['raw']['pcm_sample_blocks'] = bindec(substr($fhBS, $bsOffset, 7)); $bsOffset += 7;
- $ThisFileInfo['dts']['raw']['frame_byte_size'] = bindec(substr($fhBS, $bsOffset, 14)); $bsOffset += 14;
- $ThisFileInfo['dts']['raw']['channel_arrangement'] = bindec(substr($fhBS, $bsOffset, 6)); $bsOffset += 6;
- $ThisFileInfo['dts']['raw']['sample_frequency'] = bindec(substr($fhBS, $bsOffset, 4)); $bsOffset += 4;
- $ThisFileInfo['dts']['raw']['bitrate'] = bindec(substr($fhBS, $bsOffset, 5)); $bsOffset += 5;
- $ThisFileInfo['dts']['flags']['embedded_downmix'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['flags']['dynamicrange'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['flags']['timestamp'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['flags']['auxdata'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['flags']['hdcd'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['raw']['extension_audio'] = bindec(substr($fhBS, $bsOffset, 3)); $bsOffset += 3;
- $ThisFileInfo['dts']['flags']['extended_coding'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['flags']['audio_sync_insertion'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['raw']['lfe_effects'] = bindec(substr($fhBS, $bsOffset, 2)); $bsOffset += 2;
- $ThisFileInfo['dts']['flags']['predictor_history'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- if ($ThisFileInfo['dts']['flags']['crc_present']) {
- $ThisFileInfo['dts']['raw']['crc16'] = bindec(substr($fhBS, $bsOffset, 16)); $bsOffset += 16;
- }
- $ThisFileInfo['dts']['flags']['mri_perfect_reconst'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['raw']['encoder_soft_version'] = bindec(substr($fhBS, $bsOffset, 4)); $bsOffset += 4;
- $ThisFileInfo['dts']['raw']['copy_history'] = bindec(substr($fhBS, $bsOffset, 2)); $bsOffset += 2;
- $ThisFileInfo['dts']['raw']['bits_per_sample'] = bindec(substr($fhBS, $bsOffset, 2)); $bsOffset += 2;
- $ThisFileInfo['dts']['flags']['surround_es'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['flags']['front_sum_diff'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['flags']['surround_sum_diff'] = (bool) bindec(substr($fhBS, $bsOffset, 1)); $bsOffset += 1;
- $ThisFileInfo['dts']['raw']['dialog_normalization'] = bindec(substr($fhBS, $bsOffset, 4)); $bsOffset += 4;
-
-
- $ThisFileInfo['dts']['bitrate'] = $this->DTSbitrateLookup($ThisFileInfo['dts']['raw']['bitrate']);
- $ThisFileInfo['dts']['bits_per_sample'] = $this->DTSbitPerSampleLookup($ThisFileInfo['dts']['raw']['bits_per_sample']);
- $ThisFileInfo['dts']['sample_rate'] = $this->DTSsampleRateLookup($ThisFileInfo['dts']['raw']['sample_frequency']);
- $ThisFileInfo['dts']['dialog_normalization'] = $this->DTSdialogNormalization($ThisFileInfo['dts']['raw']['dialog_normalization'], $ThisFileInfo['dts']['raw']['encoder_soft_version']);
- $ThisFileInfo['dts']['flags']['lossless'] = (($ThisFileInfo['dts']['raw']['bitrate'] == 31) ? true : false);
- $ThisFileInfo['dts']['bitrate_mode'] = (($ThisFileInfo['dts']['raw']['bitrate'] == 30) ? 'vbr' : 'cbr');
- $ThisFileInfo['dts']['channels'] = $this->DTSnumChannelsLookup($ThisFileInfo['dts']['raw']['channel_arrangement']);
- $ThisFileInfo['dts']['channel_arrangement'] = $this->DTSchannelArrangementLookup($ThisFileInfo['dts']['raw']['channel_arrangement']);
-
- $ThisFileInfo['audio']['dataformat'] = 'dts';
- $ThisFileInfo['audio']['lossless'] = $ThisFileInfo['dts']['flags']['lossless'];
- $ThisFileInfo['audio']['bitrate_mode'] = $ThisFileInfo['dts']['bitrate_mode'];
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['dts']['bits_per_sample'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['dts']['sample_rate'];
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['dts']['channels'];
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['dts']['bitrate'];
- if (isset($ThisFileInfo['avdataend'])) {
- $ThisFileInfo['playtime_seconds'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) / ($ThisFileInfo['dts']['bitrate'] / 8);
- }
-
- return true;
- }
-
- function DTSbitrateLookup($index) {
- $DTSbitrateLookup = array(
- 0 => 32000,
- 1 => 56000,
- 2 => 64000,
- 3 => 96000,
- 4 => 112000,
- 5 => 128000,
- 6 => 192000,
- 7 => 224000,
- 8 => 256000,
- 9 => 320000,
- 10 => 384000,
- 11 => 448000,
- 12 => 512000,
- 13 => 576000,
- 14 => 640000,
- 15 => 768000,
- 16 => 960000,
- 17 => 1024000,
- 18 => 1152000,
- 19 => 1280000,
- 20 => 1344000,
- 21 => 1408000,
- 22 => 1411200,
- 23 => 1472000,
- 24 => 1536000,
- 25 => 1920000,
- 26 => 2048000,
- 27 => 3072000,
- 28 => 3840000,
- 29 => 'open',
- 30 => 'variable',
- 31 => 'lossless'
- );
- return @$DTSbitrateLookup[$index];
- }
-
- function DTSsampleRateLookup($index) {
- $DTSsampleRateLookup = array(
- 0 => 'invalid',
- 1 => 8000,
- 2 => 16000,
- 3 => 32000,
- 4 => 'invalid',
- 5 => 'invalid',
- 6 => 11025,
- 7 => 22050,
- 8 => 44100,
- 9 => 'invalid',
- 10 => 'invalid',
- 11 => 12000,
- 12 => 24000,
- 13 => 48000,
- 14 => 'invalid',
- 15 => 'invalid'
- );
- return @$DTSsampleRateLookup[$index];
- }
-
- function DTSbitPerSampleLookup($index) {
- $DTSbitPerSampleLookup = array(
- 0 => 16,
- 1 => 20,
- 2 => 24,
- 3 => 24,
- );
- return @$DTSbitPerSampleLookup[$index];
- }
-
- function DTSnumChannelsLookup($index) {
- switch ($index) {
- case 0:
- return 1;
- break;
- case 1:
- case 2:
- case 3:
- case 4:
- return 2;
- break;
- case 5:
- case 6:
- return 3;
- break;
- case 7:
- case 8:
- return 4;
- break;
- case 9:
- return 5;
- break;
- case 10:
- case 11:
- case 12:
- return 6;
- break;
- case 13:
- return 7;
- break;
- case 14:
- case 15:
- return 8;
- break;
- }
- return false;
- }
-
- function DTSchannelArrangementLookup($index) {
- $DTSchannelArrangementLookup = array(
- 0 => 'A',
- 1 => 'A + B (dual mono)',
- 2 => 'L + R (stereo)',
- 3 => '(L+R) + (L-R) (sum-difference)',
- 4 => 'LT + RT (left and right total)',
- 5 => 'C + L + R',
- 6 => 'L + R + S',
- 7 => 'C + L + R + S',
- 8 => 'L + R + SL + SR',
- 9 => 'C + L + R + SL + SR',
- 10 => 'CL + CR + L + R + SL + SR',
- 11 => 'C + L + R+ LR + RR + OV',
- 12 => 'CF + CR + LF + RF + LR + RR',
- 13 => 'CL + C + CR + L + R + SL + SR',
- 14 => 'CL + CR + L + R + SL1 + SL2 + SR1 + SR2',
- 15 => 'CL + C+ CR + L + R + SL + S + SR',
- );
- return (@$DTSchannelArrangementLookup[$index] ? @$DTSchannelArrangementLookup[$index] : 'user-defined');
- }
-
- function DTSdialogNormalization($index, $version) {
- switch ($version) {
- case 7:
- return 0 - $index;
- break;
- case 6:
- return 0 - 16 - $index;
- break;
- }
- return false;
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.flac.php b/apps/media/getID3/getid3/module.audio.flac.php
deleted file mode 100644
index 5ef431e5131..00000000000
--- a/apps/media/getID3/getid3/module.audio.flac.php
+++ /dev/null
@@ -1,397 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.flac.php //
-// module for analyzing FLAC and OggFLAC audio files //
-// dependencies: module.audio.ogg.php //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, true);
-
-class getid3_flac
-{
-
- function getid3_flac(&$fd, &$ThisFileInfo) {
- // http://flac.sourceforge.net/format.html
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $StreamMarker = fread($fd, 4);
- if ($StreamMarker != 'fLaC') {
- $ThisFileInfo['error'][] = 'Expecting "fLaC" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$StreamMarker.'"';
- return false;
- }
- $ThisFileInfo['fileformat'] = 'flac';
- $ThisFileInfo['audio']['dataformat'] = 'flac';
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
- $ThisFileInfo['audio']['lossless'] = true;
-
- return getid3_flac::FLACparseMETAdata($fd, $ThisFileInfo);
- }
-
-
- function FLACparseMETAdata(&$fd, &$ThisFileInfo) {
-
- do {
- $METAdataBlockOffset = ftell($fd);
- $METAdataBlockHeader = fread($fd, 4);
- $METAdataLastBlockFlag = (bool) (getid3_lib::BigEndian2Int(substr($METAdataBlockHeader, 0, 1)) & 0x80);
- $METAdataBlockType = getid3_lib::BigEndian2Int(substr($METAdataBlockHeader, 0, 1)) & 0x7F;
- $METAdataBlockLength = getid3_lib::BigEndian2Int(substr($METAdataBlockHeader, 1, 3));
- $METAdataBlockTypeText = getid3_flac::FLACmetaBlockTypeLookup($METAdataBlockType);
-
- if ($METAdataBlockLength < 0) {
- $ThisFileInfo['error'][] = 'corrupt or invalid METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$METAdataBlockType.') at offset '.$METAdataBlockOffset;
- break;
- }
-
- $ThisFileInfo['flac'][$METAdataBlockTypeText]['raw'] = array();
- $ThisFileInfo_flac_METAdataBlockTypeText_raw = &$ThisFileInfo['flac'][$METAdataBlockTypeText]['raw'];
-
- $ThisFileInfo_flac_METAdataBlockTypeText_raw['offset'] = $METAdataBlockOffset;
- $ThisFileInfo_flac_METAdataBlockTypeText_raw['last_meta_block'] = $METAdataLastBlockFlag;
- $ThisFileInfo_flac_METAdataBlockTypeText_raw['block_type'] = $METAdataBlockType;
- $ThisFileInfo_flac_METAdataBlockTypeText_raw['block_type_text'] = $METAdataBlockTypeText;
- $ThisFileInfo_flac_METAdataBlockTypeText_raw['block_length'] = $METAdataBlockLength;
- $ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'] = @fread($fd, $METAdataBlockLength);
- $ThisFileInfo['avdataoffset'] = ftell($fd);
-
- switch ($METAdataBlockTypeText) {
-
- case 'STREAMINFO':
- if (!getid3_flac::FLACparseSTREAMINFO($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'], $ThisFileInfo)) {
- return false;
- }
- break;
-
- case 'PADDING':
- // ignore
- break;
-
- case 'APPLICATION':
- if (!getid3_flac::FLACparseAPPLICATION($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'], $ThisFileInfo)) {
- return false;
- }
- break;
-
- case 'SEEKTABLE':
- if (!getid3_flac::FLACparseSEEKTABLE($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'], $ThisFileInfo)) {
- return false;
- }
- break;
-
- case 'VORBIS_COMMENT':
- $OldOffset = ftell($fd);
- fseek($fd, 0 - $METAdataBlockLength, SEEK_CUR);
- getid3_ogg::ParseVorbisCommentsFilepointer($fd, $ThisFileInfo);
- fseek($fd, $OldOffset, SEEK_SET);
- break;
-
- case 'CUESHEET':
- if (!getid3_flac::FLACparseCUESHEET($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'], $ThisFileInfo)) {
- return false;
- }
- break;
-
- case 'PICTURE':
- if (!$this->FLACparsePICTURE($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'], $ThisFileInfo)) {
- return false;
- }
- break;
-
- default:
- $ThisFileInfo['warning'][] = 'Unhandled METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$METAdataBlockType.') at offset '.$METAdataBlockOffset;
- break;
- }
-
- } while ($METAdataLastBlockFlag === false);
-
-
- if (isset($ThisFileInfo['flac']['STREAMINFO'])) {
- $ThisFileInfo['flac']['compressed_audio_bytes'] = $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'];
- $ThisFileInfo['flac']['uncompressed_audio_bytes'] = $ThisFileInfo['flac']['STREAMINFO']['samples_stream'] * $ThisFileInfo['flac']['STREAMINFO']['channels'] * ($ThisFileInfo['flac']['STREAMINFO']['bits_per_sample'] / 8);
- if ($ThisFileInfo['flac']['uncompressed_audio_bytes'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt FLAC file: uncompressed_audio_bytes == zero';
- return false;
- }
- $ThisFileInfo['flac']['compression_ratio'] = $ThisFileInfo['flac']['compressed_audio_bytes'] / $ThisFileInfo['flac']['uncompressed_audio_bytes'];
- }
-
- // set md5_data_source - built into flac 0.5+
- if (isset($ThisFileInfo['flac']['STREAMINFO']['audio_signature'])) {
-
- if ($ThisFileInfo['flac']['STREAMINFO']['audio_signature'] === str_repeat("\x00", 16)) {
-
- $ThisFileInfo['warning'][] = 'FLAC STREAMINFO.audio_signature is null (known issue with libOggFLAC)';
-
- } else {
-
- $ThisFileInfo['md5_data_source'] = '';
- $md5 = $ThisFileInfo['flac']['STREAMINFO']['audio_signature'];
- for ($i = 0; $i < strlen($md5); $i++) {
- $ThisFileInfo['md5_data_source'] .= str_pad(dechex(ord($md5{$i})), 2, '00', STR_PAD_LEFT);
- }
- if (!preg_match('/^[0-9a-f]{32}$/', $ThisFileInfo['md5_data_source'])) {
- unset($ThisFileInfo['md5_data_source']);
- }
-
- }
-
- }
-
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['flac']['STREAMINFO']['bits_per_sample'];
- if ($ThisFileInfo['audio']['bits_per_sample'] == 8) {
- // special case
- // must invert sign bit on all data bytes before MD5'ing to match FLAC's calculated value
- // MD5sum calculates on unsigned bytes, but FLAC calculated MD5 on 8-bit audio data as signed
- $ThisFileInfo['warning'][] = 'FLAC calculates MD5 data strangely on 8-bit audio, so the stored md5_data_source value will not match the decoded WAV file';
- }
- if (!empty($ThisFileInfo['ogg']['vendor'])) {
- $ThisFileInfo['audio']['encoder'] = $ThisFileInfo['ogg']['vendor'];
- }
-
- return true;
- }
-
- function FLACmetaBlockTypeLookup($blocktype) {
- static $FLACmetaBlockTypeLookup = array();
- if (empty($FLACmetaBlockTypeLookup)) {
- $FLACmetaBlockTypeLookup[0] = 'STREAMINFO';
- $FLACmetaBlockTypeLookup[1] = 'PADDING';
- $FLACmetaBlockTypeLookup[2] = 'APPLICATION';
- $FLACmetaBlockTypeLookup[3] = 'SEEKTABLE';
- $FLACmetaBlockTypeLookup[4] = 'VORBIS_COMMENT';
- $FLACmetaBlockTypeLookup[5] = 'CUESHEET';
- $FLACmetaBlockTypeLookup[6] = 'PICTURE';
- }
- return (isset($FLACmetaBlockTypeLookup[$blocktype]) ? $FLACmetaBlockTypeLookup[$blocktype] : 'reserved');
- }
-
- function FLACapplicationIDLookup($applicationid) {
- static $FLACapplicationIDLookup = array();
- if (empty($FLACapplicationIDLookup)) {
- // http://flac.sourceforge.net/id.html
- $FLACapplicationIDLookup[0x46746F6C] = 'flac-tools'; // 'Ftol'
- $FLACapplicationIDLookup[0x46746F6C] = 'Sound Font FLAC'; // 'SFFL'
- }
- return (isset($FLACapplicationIDLookup[$applicationid]) ? $FLACapplicationIDLookup[$applicationid] : 'reserved');
- }
-
- function FLACpictureTypeLookup($type_id) {
- static $lookup = array (
- 0 => 'Other',
- 1 => '32x32 pixels \'file icon\' (PNG only)',
- 2 => 'Other file icon',
- 3 => 'Cover (front)',
- 4 => 'Cover (back)',
- 5 => 'Leaflet page',
- 6 => 'Media (e.g. label side of CD)',
- 7 => 'Lead artist/lead performer/soloist',
- 8 => 'Artist/performer',
- 9 => 'Conductor',
- 10 => 'Band/Orchestra',
- 11 => 'Composer',
- 12 => 'Lyricist/text writer',
- 13 => 'Recording Location',
- 14 => 'During recording',
- 15 => 'During performance',
- 16 => 'Movie/video screen capture',
- 17 => 'A bright coloured fish',
- 18 => 'Illustration',
- 19 => 'Band/artist logotype',
- 20 => 'Publisher/Studio logotype',
- );
- return (isset($lookup[$type_id]) ? $lookup[$type_id] : 'reserved');
- }
-
- function FLACparseSTREAMINFO($METAdataBlockData, &$ThisFileInfo) {
- $offset = 0;
- $ThisFileInfo['flac']['STREAMINFO']['min_block_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 2));
- $offset += 2;
- $ThisFileInfo['flac']['STREAMINFO']['max_block_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 2));
- $offset += 2;
- $ThisFileInfo['flac']['STREAMINFO']['min_frame_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 3));
- $offset += 3;
- $ThisFileInfo['flac']['STREAMINFO']['max_frame_size'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 3));
- $offset += 3;
-
- $SampleRateChannelsSampleBitsStreamSamples = getid3_lib::BigEndian2Bin(substr($METAdataBlockData, $offset, 8));
- $ThisFileInfo['flac']['STREAMINFO']['sample_rate'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 0, 20));
- $ThisFileInfo['flac']['STREAMINFO']['channels'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 20, 3)) + 1;
- $ThisFileInfo['flac']['STREAMINFO']['bits_per_sample'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 23, 5)) + 1;
- $ThisFileInfo['flac']['STREAMINFO']['samples_stream'] = getid3_lib::Bin2Dec(substr($SampleRateChannelsSampleBitsStreamSamples, 28, 36));
- $offset += 8;
-
- $ThisFileInfo['flac']['STREAMINFO']['audio_signature'] = substr($METAdataBlockData, $offset, 16);
- $offset += 16;
-
- if (!empty($ThisFileInfo['flac']['STREAMINFO']['sample_rate'])) {
-
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['flac']['STREAMINFO']['sample_rate'];
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['flac']['STREAMINFO']['channels'];
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['flac']['STREAMINFO']['bits_per_sample'];
- $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['flac']['STREAMINFO']['samples_stream'] / $ThisFileInfo['flac']['STREAMINFO']['sample_rate'];
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
-
- } else {
-
- $ThisFileInfo['error'][] = 'Corrupt METAdata block: STREAMINFO';
- return false;
-
- }
-
- unset($ThisFileInfo['flac']['STREAMINFO']['raw']);
-
- return true;
- }
-
-
- function FLACparseAPPLICATION($METAdataBlockData, &$ThisFileInfo) {
- $offset = 0;
- $ApplicationID = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 4));
- $offset += 4;
- $ThisFileInfo['flac']['APPLICATION'][$ApplicationID]['name'] = getid3_flac::FLACapplicationIDLookup($ApplicationID);
- $ThisFileInfo['flac']['APPLICATION'][$ApplicationID]['data'] = substr($METAdataBlockData, $offset);
- $offset = $METAdataBlockLength;
-
- unset($ThisFileInfo['flac']['APPLICATION']['raw']);
-
- return true;
- }
-
-
- function FLACparseSEEKTABLE($METAdataBlockData, &$ThisFileInfo) {
- $offset = 0;
- $METAdataBlockLength = strlen($METAdataBlockData);
- $placeholderpattern = str_repeat("\xFF", 8);
- while ($offset < $METAdataBlockLength) {
- $SampleNumberString = substr($METAdataBlockData, $offset, 8);
- $offset += 8;
- if ($SampleNumberString == $placeholderpattern) {
-
- // placeholder point
- @$ThisFileInfo['flac']['SEEKTABLE']['placeholders']++;
- $offset += 10;
-
- } else {
-
- $SampleNumber = getid3_lib::BigEndian2Int($SampleNumberString);
- $ThisFileInfo['flac']['SEEKTABLE'][$SampleNumber]['offset'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
- $offset += 8;
- $ThisFileInfo['flac']['SEEKTABLE'][$SampleNumber]['samples'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 2));
- $offset += 2;
-
- }
- }
-
- unset($ThisFileInfo['flac']['SEEKTABLE']['raw']);
-
- return true;
- }
-
- function FLACparseCUESHEET($METAdataBlockData, &$ThisFileInfo) {
- $offset = 0;
- $ThisFileInfo['flac']['CUESHEET']['media_catalog_number'] = trim(substr($METAdataBlockData, $offset, 128), "\0");
- $offset += 128;
- $ThisFileInfo['flac']['CUESHEET']['lead_in_samples'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
- $offset += 8;
- $ThisFileInfo['flac']['CUESHEET']['flags']['is_cd'] = (bool) (getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1)) & 0x80);
- $offset += 1;
-
- $offset += 258; // reserved
-
- $ThisFileInfo['flac']['CUESHEET']['number_tracks'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
- $offset += 1;
-
- for ($track = 0; $track < $ThisFileInfo['flac']['CUESHEET']['number_tracks']; $track++) {
- $TrackSampleOffset = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
- $offset += 8;
- $TrackNumber = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
- $offset += 1;
-
- $ThisFileInfo['flac']['CUESHEET']['tracks'][$TrackNumber]['sample_offset'] = $TrackSampleOffset;
-
- $ThisFileInfo['flac']['CUESHEET']['tracks'][$TrackNumber]['isrc'] = substr($METAdataBlockData, $offset, 12);
- $offset += 12;
-
- $TrackFlagsRaw = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
- $offset += 1;
- $ThisFileInfo['flac']['CUESHEET']['tracks'][$TrackNumber]['flags']['is_audio'] = (bool) ($TrackFlagsRaw & 0x80);
- $ThisFileInfo['flac']['CUESHEET']['tracks'][$TrackNumber]['flags']['pre_emphasis'] = (bool) ($TrackFlagsRaw & 0x40);
-
- $offset += 13; // reserved
-
- $ThisFileInfo['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
- $offset += 1;
-
- for ($index = 0; $index < $ThisFileInfo['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points']; $index++) {
- $IndexSampleOffset = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
- $offset += 8;
- $IndexNumber = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
- $offset += 1;
-
- $offset += 3; // reserved
-
- $ThisFileInfo['flac']['CUESHEET']['tracks'][$TrackNumber]['indexes'][$IndexNumber] = $IndexSampleOffset;
- }
- }
-
- unset($ThisFileInfo['flac']['CUESHEET']['raw']);
-
- return true;
- }
-
-
- function FLACparsePICTURE($meta_data_block_data, &$ThisFileInfo) {
- $picture = &$ThisFileInfo['flac']['PICTURE'][sizeof($ThisFileInfo['flac']['PICTURE']) - 1];
-
- $offset = 0;
-
- $picture['type'] = $this->FLACpictureTypeLookup(getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4)));
- $offset += 4;
-
- $length = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
- $offset += 4;
-
- $picture['mime_type'] = substr($meta_data_block_data, $offset, $length);
- $offset += $length;
-
- $length = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
- $offset += 4;
-
- $picture['description'] = substr($meta_data_block_data, $offset, $length);
- $offset += $length;
-
- $picture['width'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
- $offset += 4;
-
- $picture['height'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
- $offset += 4;
-
- $picture['color_depth'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
- $offset += 4;
-
- $picture['colors_indexed'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
- $offset += 4;
-
- $length = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
- $offset += 4;
-
- $picture['image_data'] = substr($meta_data_block_data, $offset, $length);
- $offset += $length;
-
- unset($ThisFileInfo['flac']['PICTURE']['raw']);
-
- return true;
- }
-}
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.la.php b/apps/media/getID3/getid3/module.audio.la.php
deleted file mode 100644
index c1d4f52d14f..00000000000
--- a/apps/media/getID3/getid3/module.audio.la.php
+++ /dev/null
@@ -1,228 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.la.php //
-// module for analyzing LA audio files //
-// dependencies: module.audio.riff.php //
-// ///
-/////////////////////////////////////////////////////////////////
-
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
-
-class getid3_la
-{
-
- function getid3_la(&$fd, &$ThisFileInfo) {
- $offset = 0;
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $rawdata = fread($fd, GETID3_FREAD_BUFFER_SIZE);
-
- switch (substr($rawdata, $offset, 4)) {
- case 'LA02':
- case 'LA03':
- case 'LA04':
- $ThisFileInfo['fileformat'] = 'la';
- $ThisFileInfo['audio']['dataformat'] = 'la';
- $ThisFileInfo['audio']['lossless'] = true;
-
- $ThisFileInfo['la']['version_major'] = (int) substr($rawdata, $offset + 2, 1);
- $ThisFileInfo['la']['version_minor'] = (int) substr($rawdata, $offset + 3, 1);
- $ThisFileInfo['la']['version'] = (float) $ThisFileInfo['la']['version_major'] + ($ThisFileInfo['la']['version_minor'] / 10);
- $offset += 4;
-
- $ThisFileInfo['la']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
- $offset += 4;
- if ($ThisFileInfo['la']['uncompressed_size'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt LA file: uncompressed_size == zero';
- return false;
- }
-
- $WAVEchunk = substr($rawdata, $offset, 4);
- if ($WAVEchunk !== 'WAVE') {
- $ThisFileInfo['error'][] = 'Expected "WAVE" ('.getid3_lib::PrintHexBytes('WAVE').') at offset '.$offset.', found "'.$WAVEchunk.'" ('.getid3_lib::PrintHexBytes($WAVEchunk).') instead.';
- return false;
- }
- $offset += 4;
-
- $ThisFileInfo['la']['fmt_size'] = 24;
- if ($ThisFileInfo['la']['version'] >= 0.3) {
-
- $ThisFileInfo['la']['fmt_size'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
- $ThisFileInfo['la']['header_size'] = 49 + $ThisFileInfo['la']['fmt_size'] - 24;
- $offset += 4;
-
- } else {
-
- // version 0.2 didn't support additional data blocks
- $ThisFileInfo['la']['header_size'] = 41;
-
- }
-
- $fmt_chunk = substr($rawdata, $offset, 4);
- if ($fmt_chunk !== 'fmt ') {
- $ThisFileInfo['error'][] = 'Expected "fmt " ('.getid3_lib::PrintHexBytes('fmt ').') at offset '.$offset.', found "'.$fmt_chunk.'" ('.getid3_lib::PrintHexBytes($fmt_chunk).') instead.';
- return false;
- }
- $offset += 4;
- $fmt_size = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
- $offset += 4;
-
- $ThisFileInfo['la']['raw']['format'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));
- $offset += 2;
-
- $ThisFileInfo['la']['channels'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));
- $offset += 2;
- if ($ThisFileInfo['la']['channels'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt LA file: channels == zero';
- return false;
- }
-
- $ThisFileInfo['la']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
- $offset += 4;
- if ($ThisFileInfo['la']['sample_rate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt LA file: sample_rate == zero';
- return false;
- }
-
- $ThisFileInfo['la']['bytes_per_second'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
- $offset += 4;
- $ThisFileInfo['la']['bytes_per_sample'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));
- $offset += 2;
- $ThisFileInfo['la']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));
- $offset += 2;
-
- $ThisFileInfo['la']['samples'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
- $offset += 4;
-
- $ThisFileInfo['la']['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 1));
- $offset += 1;
- $ThisFileInfo['la']['flags']['seekable'] = (bool) ($ThisFileInfo['la']['raw']['flags'] & 0x01);
- if ($ThisFileInfo['la']['version'] >= 0.4) {
- $ThisFileInfo['la']['flags']['high_compression'] = (bool) ($ThisFileInfo['la']['raw']['flags'] & 0x02);
- }
-
- $ThisFileInfo['la']['original_crc'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
- $offset += 4;
-
- // mikeØbevin*de
- // Basically, the blocksize/seekevery are 61440/19 in La0.4 and 73728/16
- // in earlier versions. A seekpoint is added every blocksize * seekevery
- // samples, so 4 * int(totalSamples / (blockSize * seekEvery)) should
- // give the number of bytes used for the seekpoints. Of course, if seeking
- // is disabled, there are no seekpoints stored.
- if ($ThisFileInfo['la']['version'] >= 0.4) {
- $ThisFileInfo['la']['blocksize'] = 61440;
- $ThisFileInfo['la']['seekevery'] = 19;
- } else {
- $ThisFileInfo['la']['blocksize'] = 73728;
- $ThisFileInfo['la']['seekevery'] = 16;
- }
-
- $ThisFileInfo['la']['seekpoint_count'] = 0;
- if ($ThisFileInfo['la']['flags']['seekable']) {
- $ThisFileInfo['la']['seekpoint_count'] = floor($ThisFileInfo['la']['samples'] / ($ThisFileInfo['la']['blocksize'] * $ThisFileInfo['la']['seekevery']));
-
- for ($i = 0; $i < $ThisFileInfo['la']['seekpoint_count']; $i++) {
- $ThisFileInfo['la']['seekpoints'][] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
- $offset += 4;
- }
- }
-
- if ($ThisFileInfo['la']['version'] >= 0.3) {
-
- // Following the main header information, the program outputs all of the
- // seekpoints. Following these is what I called the 'footer start',
- // i.e. the position immediately after the La audio data is finished.
- $ThisFileInfo['la']['footerstart'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
- $offset += 4;
-
- if ($ThisFileInfo['la']['footerstart'] > $ThisFileInfo['filesize']) {
- $ThisFileInfo['warning'][] = 'FooterStart value points to offset '.$ThisFileInfo['la']['footerstart'].' which is beyond end-of-file ('.$ThisFileInfo['filesize'].')';
- $ThisFileInfo['la']['footerstart'] = $ThisFileInfo['filesize'];
- }
-
- } else {
-
- // La v0.2 didn't have FooterStart value
- $ThisFileInfo['la']['footerstart'] = $ThisFileInfo['avdataend'];
-
- }
-
- if ($ThisFileInfo['la']['footerstart'] < $ThisFileInfo['avdataend']) {
- if ($RIFFtempfilename = tempnam('*', 'id3')) {
- if ($RIFF_fp = fopen($RIFFtempfilename, 'w+b')) {
- $RIFFdata = 'WAVE';
- if ($ThisFileInfo['la']['version'] == 0.2) {
- $RIFFdata .= substr($rawdata, 12, 24);
- } else {
- $RIFFdata .= substr($rawdata, 16, 24);
- }
- if ($ThisFileInfo['la']['footerstart'] < $ThisFileInfo['avdataend']) {
- fseek($fd, $ThisFileInfo['la']['footerstart'], SEEK_SET);
- $RIFFdata .= fread($fd, $ThisFileInfo['avdataend'] - $ThisFileInfo['la']['footerstart']);
- }
- $RIFFdata = 'RIFF'.getid3_lib::LittleEndian2String(strlen($RIFFdata), 4, false).$RIFFdata;
- fwrite($RIFF_fp, $RIFFdata, strlen($RIFFdata));
- $dummy = $ThisFileInfo;
- $dummy['filesize'] = strlen($RIFFdata);
- $dummy['avdataoffset'] = 0;
- $dummy['avdataend'] = $dummy['filesize'];
-
- $riff = new getid3_riff($RIFF_fp, $dummy);
- if (empty($dummy['error'])) {
- $ThisFileInfo['riff'] = $dummy['riff'];
- } else {
- $ThisFileInfo['warning'][] = 'Error parsing RIFF portion of La file: '.implode($dummy['error']);
- }
- unset($riff);
- unset($dummy);
- fclose($RIFF_fp);
- }
- unlink($RIFFtempfilename);
- }
- }
-
- // $ThisFileInfo['avdataoffset'] should be zero to begin with, but just in case it's not, include the addition anyway
- $ThisFileInfo['avdataend'] = $ThisFileInfo['avdataoffset'] + $ThisFileInfo['la']['footerstart'];
- $ThisFileInfo['avdataoffset'] = $ThisFileInfo['avdataoffset'] + $offset;
-
- //$ThisFileInfo['la']['codec'] = RIFFwFormatTagLookup($ThisFileInfo['la']['raw']['format']);
- $ThisFileInfo['la']['compression_ratio'] = (float) (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) / $ThisFileInfo['la']['uncompressed_size']);
- $ThisFileInfo['playtime_seconds'] = (float) ($ThisFileInfo['la']['samples'] / $ThisFileInfo['la']['sample_rate']) / $ThisFileInfo['la']['channels'];
- if ($ThisFileInfo['playtime_seconds'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt LA file: playtime_seconds == zero';
- return false;
- }
-
- $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['playtime_seconds'];
- //$ThisFileInfo['audio']['codec'] = $ThisFileInfo['la']['codec'];
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['la']['bits_per_sample'];
- break;
-
- default:
- if (substr($rawdata, $offset, 2) == 'LA') {
- $ThisFileInfo['error'][] = 'This version of getID3() (v'.GETID3_VERSION.') doesn\'t support LA version '.substr($rawdata, $offset + 2, 1).'.'.substr($rawdata, $offset + 3, 1).' which this appears to be - check http://getid3.sourceforge.net for updates.';
- } else {
- $ThisFileInfo['error'][] = 'Not a LA (Lossless-Audio) file';
- }
- return false;
- break;
- }
-
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['la']['channels'];
- $ThisFileInfo['audio']['sample_rate'] = (int) $ThisFileInfo['la']['sample_rate'];
- $ThisFileInfo['audio']['encoder'] = 'LA v'.$ThisFileInfo['la']['version'];
-
- return true;
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.lpac.php b/apps/media/getID3/getid3/module.audio.lpac.php
deleted file mode 100644
index 3c04492117e..00000000000
--- a/apps/media/getID3/getid3/module.audio.lpac.php
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.lpac.php //
-// module for analyzing LPAC Audio files //
-// dependencies: module.audio-video.riff.php //
-// ///
-/////////////////////////////////////////////////////////////////
-
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
-
-class getid3_lpac
-{
-
- function getid3_lpac(&$fd, &$ThisFileInfo) {
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $LPACheader = fread($fd, 14);
- if (substr($LPACheader, 0, 4) != 'LPAC') {
- $ThisFileInfo['error'][] = 'Expected "LPAC" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$StreamMarker.'"';
- return false;
- }
- $ThisFileInfo['avdataoffset'] += 14;
-
- $ThisFileInfo['fileformat'] = 'lpac';
- $ThisFileInfo['audio']['dataformat'] = 'lpac';
- $ThisFileInfo['audio']['lossless'] = true;
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
-
- $ThisFileInfo['lpac']['file_version'] = getid3_lib::BigEndian2Int(substr($LPACheader, 4, 1));
- $flags['audio_type'] = getid3_lib::BigEndian2Int(substr($LPACheader, 5, 1));
- $ThisFileInfo['lpac']['total_samples']= getid3_lib::BigEndian2Int(substr($LPACheader, 6, 4));
- $flags['parameters'] = getid3_lib::BigEndian2Int(substr($LPACheader, 10, 4));
-
- $ThisFileInfo['lpac']['flags']['is_wave'] = (bool) ($flags['audio_type'] & 0x40);
- $ThisFileInfo['lpac']['flags']['stereo'] = (bool) ($flags['audio_type'] & 0x04);
- $ThisFileInfo['lpac']['flags']['24_bit'] = (bool) ($flags['audio_type'] & 0x02);
- $ThisFileInfo['lpac']['flags']['16_bit'] = (bool) ($flags['audio_type'] & 0x01);
-
- if ($ThisFileInfo['lpac']['flags']['24_bit'] && $ThisFileInfo['lpac']['flags']['16_bit']) {
- $ThisFileInfo['warning'][] = '24-bit and 16-bit flags cannot both be set';
- }
-
- $ThisFileInfo['lpac']['flags']['fast_compress'] = (bool) ($flags['parameters'] & 0x40000000);
- $ThisFileInfo['lpac']['flags']['random_access'] = (bool) ($flags['parameters'] & 0x08000000);
- $ThisFileInfo['lpac']['block_length'] = pow(2, (($flags['parameters'] & 0x07000000) >> 24)) * 256;
- $ThisFileInfo['lpac']['flags']['adaptive_prediction_order'] = (bool) ($flags['parameters'] & 0x00800000);
- $ThisFileInfo['lpac']['flags']['adaptive_quantization'] = (bool) ($flags['parameters'] & 0x00400000);
- $ThisFileInfo['lpac']['flags']['joint_stereo'] = (bool) ($flags['parameters'] & 0x00040000);
- $ThisFileInfo['lpac']['quantization'] = ($flags['parameters'] & 0x00001F00) >> 8;
- $ThisFileInfo['lpac']['max_prediction_order'] = ($flags['parameters'] & 0x0000003F);
-
- if ($ThisFileInfo['lpac']['flags']['fast_compress'] && ($ThisFileInfo['lpac']['max_prediction_order'] != 3)) {
- $ThisFileInfo['warning'][] = 'max_prediction_order expected to be "3" if fast_compress is true, actual value is "'.$ThisFileInfo['lpac']['max_prediction_order'].'"';
- }
- switch ($ThisFileInfo['lpac']['file_version']) {
- case 6:
- if ($ThisFileInfo['lpac']['flags']['adaptive_quantization']) {
- $ThisFileInfo['warning'][] = 'adaptive_quantization expected to be false in LPAC file stucture v6, actually true';
- }
- if ($ThisFileInfo['lpac']['quantization'] != 20) {
- $ThisFileInfo['warning'][] = 'Quantization expected to be 20 in LPAC file stucture v6, actually '.$ThisFileInfo['lpac']['flags']['Q'];
- }
- break;
-
- default:
- //$ThisFileInfo['warning'][] = 'This version of getID3() only supports LPAC file format version 6, this file is version '.$ThisFileInfo['lpac']['file_version'].' - please report to info@getid3.org';
- break;
- }
-
- $dummy = $ThisFileInfo;
- $riff = new getid3_riff($fd, $dummy);
- unset($riff);
- $ThisFileInfo['avdataoffset'] = $dummy['avdataoffset'];
- $ThisFileInfo['riff'] = $dummy['riff'];
- $ThisFileInfo['error'] = $dummy['error'];
- $ThisFileInfo['warning'] = $dummy['warning'];
- $ThisFileInfo['lpac']['comments']['comment'] = $dummy['comments'];
- $ThisFileInfo['audio']['sample_rate'] = $dummy['audio']['sample_rate'];
-
- $ThisFileInfo['audio']['channels'] = ($ThisFileInfo['lpac']['flags']['stereo'] ? 2 : 1);
-
- if ($ThisFileInfo['lpac']['flags']['24_bit']) {
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['riff']['audio'][0]['bits_per_sample'];
- } elseif ($ThisFileInfo['lpac']['flags']['16_bit']) {
- $ThisFileInfo['audio']['bits_per_sample'] = 16;
- } else {
- $ThisFileInfo['audio']['bits_per_sample'] = 8;
- }
-
- if ($ThisFileInfo['lpac']['flags']['fast_compress']) {
- // fast
- $ThisFileInfo['audio']['encoder_options'] = '-1';
- } else {
- switch ($ThisFileInfo['lpac']['max_prediction_order']) {
- case 20: // simple
- $ThisFileInfo['audio']['encoder_options'] = '-2';
- break;
- case 30: // medium
- $ThisFileInfo['audio']['encoder_options'] = '-3';
- break;
- case 40: // high
- $ThisFileInfo['audio']['encoder_options'] = '-4';
- break;
- case 60: // extrahigh
- $ThisFileInfo['audio']['encoder_options'] = '-5';
- break;
- }
- }
-
- $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['lpac']['total_samples'] / $ThisFileInfo['audio']['sample_rate'];
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
-
- return true;
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.mod.php b/apps/media/getID3/getid3/module.audio.mod.php
deleted file mode 100644
index 7f81ff360be..00000000000
--- a/apps/media/getID3/getid3/module.audio.mod.php
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.mod.php //
-// module for analyzing MOD Audio files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_mod
-{
-
- // new combined constructor
- function getid3_mod(&$fd, &$ThisFileInfo, $option) {
-
- if ($option === 'mod') {
- $this->getMODheaderFilepointer($fd, $ThisFileInfo);
- }
- elseif ($option === 'xm') {
- $this->getXMheaderFilepointer($fd, $ThisFileInfo);
- }
- elseif ($option === 'it') {
- $this->getITheaderFilepointer($fd, $ThisFileInfo);
- }
- elseif ($option === 's3m') {
- $this->getS3MheaderFilepointer($fd, $ThisFileInfo);
- }
- }
-
-
- function getMODheaderFilepointer(&$fd, &$ThisFileInfo) {
-
- fseek($fd, $ThisFileInfo['avdataoffset'] + 1080);
- $FormatID = fread($fd, 4);
- if (!ereg('^(M.K.|[5-9]CHN|[1-3][0-9]CH)$', $FormatID)) {
- $ThisFileInfo['error'][] = 'This is not a known type of MOD file';
- return false;
- }
-
- $ThisFileInfo['fileformat'] = 'mod';
-
- $ThisFileInfo['error'][] = 'MOD parsing not enabled in this version of getID3()';
- return false;
- }
-
- function getXMheaderFilepointer(&$fd, &$ThisFileInfo) {
-
- fseek($fd, $ThisFileInfo['avdataoffset']);
- $FormatID = fread($fd, 15);
- if (!ereg('^Extended Module$', $FormatID)) {
- $ThisFileInfo['error'][] = 'This is not a known type of XM-MOD file';
- return false;
- }
-
- $ThisFileInfo['fileformat'] = 'xm';
-
- $ThisFileInfo['error'][] = 'XM-MOD parsing not enabled in this version of getID3()';
- return false;
- }
-
- function getS3MheaderFilepointer(&$fd, &$ThisFileInfo) {
-
- fseek($fd, $ThisFileInfo['avdataoffset'] + 44);
- $FormatID = fread($fd, 4);
- if (!ereg('^SCRM$', $FormatID)) {
- $ThisFileInfo['error'][] = 'This is not a ScreamTracker MOD file';
- return false;
- }
-
- $ThisFileInfo['fileformat'] = 's3m';
-
- $ThisFileInfo['error'][] = 'ScreamTracker parsing not enabled in this version of getID3()';
- return false;
- }
-
- function getITheaderFilepointer(&$fd, &$ThisFileInfo) {
-
- fseek($fd, $ThisFileInfo['avdataoffset']);
- $FormatID = fread($fd, 4);
- if (!ereg('^IMPM$', $FormatID)) {
- $ThisFileInfo['error'][] = 'This is not an ImpulseTracker MOD file';
- return false;
- }
-
- $ThisFileInfo['fileformat'] = 'it';
-
- $ThisFileInfo['error'][] = 'ImpulseTracker parsing not enabled in this version of getID3()';
- return false;
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.ogg.php b/apps/media/getID3/getid3/module.audio.ogg.php
deleted file mode 100644
index 1cc6366ac5c..00000000000
--- a/apps/media/getID3/getid3/module.audio.ogg.php
+++ /dev/null
@@ -1,556 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.ogg.php //
-// module for analyzing Ogg Vorbis, OggFLAC and Speex files //
-// dependencies: module.audio.flac.php //
-// ///
-/////////////////////////////////////////////////////////////////
-
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.flac.php', __FILE__, true);
-
-class getid3_ogg
-{
-
- function getid3_ogg(&$fd, &$ThisFileInfo) {
-
- $ThisFileInfo['fileformat'] = 'ogg';
-
- // Warn about illegal tags - only vorbiscomments are allowed
- if (isset($ThisFileInfo['id3v2'])) {
- $ThisFileInfo['warning'][] = 'Illegal ID3v2 tag present.';
- }
- if (isset($ThisFileInfo['id3v1'])) {
- $ThisFileInfo['warning'][] = 'Illegal ID3v1 tag present.';
- }
- if (isset($ThisFileInfo['ape'])) {
- $ThisFileInfo['warning'][] = 'Illegal APE tag present.';
- }
-
-
- // Page 1 - Stream Header
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
-
- $oggpageinfo = getid3_ogg::ParseOggPageHeader($fd);
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
-
- if (ftell($fd) >= GETID3_FREAD_BUFFER_SIZE) {
- $ThisFileInfo['error'][] = 'Could not find start of Ogg page in the first '.GETID3_FREAD_BUFFER_SIZE.' bytes (this might not be an Ogg-Vorbis file?)';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['ogg']);
- return false;
- }
-
- $filedata = fread($fd, $oggpageinfo['page_length']);
- $filedataoffset = 0;
-
- if (substr($filedata, 0, 4) == 'fLaC') {
-
- $ThisFileInfo['audio']['dataformat'] = 'flac';
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
- $ThisFileInfo['audio']['lossless'] = true;
-
- } elseif (substr($filedata, 1, 6) == 'vorbis') {
-
- $this->ParseVorbisPageHeader($filedata, $filedataoffset, $ThisFileInfo, $oggpageinfo);
-
- } elseif (substr($filedata, 0, 8) == 'Speex ') {
-
- // http://www.speex.org/manual/node10.html
-
- $ThisFileInfo['audio']['dataformat'] = 'speex';
- $ThisFileInfo['mime_type'] = 'audio/speex';
- $ThisFileInfo['audio']['bitrate_mode'] = 'abr';
- $ThisFileInfo['audio']['lossless'] = false;
-
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_string'] = substr($filedata, $filedataoffset, 8); // hard-coded to 'Speex '
- $filedataoffset += 8;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version'] = substr($filedata, $filedataoffset, 20);
- $filedataoffset += 20;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version_id'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['header_size'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode_bitstream_version'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['bitrate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['framesize'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['vbr'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['frames_per_packet'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['extra_headers'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['reserved1'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['reserved2'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
-
- $ThisFileInfo['speex']['speex_version'] = trim($ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version']);
- $ThisFileInfo['speex']['sample_rate'] = $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate'];
- $ThisFileInfo['speex']['channels'] = $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels'];
- $ThisFileInfo['speex']['vbr'] = (bool) $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['vbr'];
- $ThisFileInfo['speex']['band_type'] = getid3_ogg::SpeexBandModeLookup($ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode']);
-
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['speex']['sample_rate'];
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['speex']['channels'];
- if ($ThisFileInfo['speex']['vbr']) {
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
- }
-
- } else {
-
- $ThisFileInfo['error'][] = 'Expecting either "Speex " or "vorbis" identifier strings, found neither';
- unset($ThisFileInfo['ogg']);
- unset($ThisFileInfo['mime_type']);
- return false;
-
- }
-
-
- // Page 2 - Comment Header
-
- $oggpageinfo = getid3_ogg::ParseOggPageHeader($fd);
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
-
- switch ($ThisFileInfo['audio']['dataformat']) {
-
- case 'vorbis':
- $filedata = fread($fd, $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, 0, 1));
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 1, 6); // hard-coded to 'vorbis'
-
- getid3_ogg::ParseVorbisCommentsFilepointer($fd, $ThisFileInfo);
- break;
-
- case 'flac':
- if (!getid3_flac::FLACparseMETAdata($fd, $ThisFileInfo)) {
- $ThisFileInfo['error'][] = 'Failed to parse FLAC headers';
- return false;
- }
- break;
-
- case 'speex':
- fseek($fd, $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length'], SEEK_CUR);
- getid3_ogg::ParseVorbisCommentsFilepointer($fd, $ThisFileInfo);
- break;
-
- }
-
-
-
- // Last Page - Number of Samples
-
- if ($ThisFileInfo['avdataend'] >= pow(2, 31)) {
-
- $ThisFileInfo['warning'][] = 'Unable to parse Ogg end chunk file (PHP does not support file operations beyond 2GB)';
-
- } else {
-
- fseek($fd, max($ThisFileInfo['avdataend'] - GETID3_FREAD_BUFFER_SIZE, 0), SEEK_SET);
- $LastChunkOfOgg = strrev(fread($fd, GETID3_FREAD_BUFFER_SIZE));
- if ($LastOggSpostion = strpos($LastChunkOfOgg, 'SggO')) {
- fseek($fd, $ThisFileInfo['avdataend'] - ($LastOggSpostion + strlen('SggO')), SEEK_SET);
- $ThisFileInfo['avdataend'] = ftell($fd);
- $ThisFileInfo['ogg']['pageheader']['eos'] = getid3_ogg::ParseOggPageHeader($fd);
- $ThisFileInfo['ogg']['samples'] = $ThisFileInfo['ogg']['pageheader']['eos']['pcm_abs_position'];
- if ($ThisFileInfo['ogg']['samples'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt Ogg file: eos.number of samples == zero';
- return false;
- }
- $ThisFileInfo['ogg']['bitrate_average'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / ($ThisFileInfo['ogg']['samples'] / $ThisFileInfo['audio']['sample_rate']);
- }
-
- }
-
- if (!empty($ThisFileInfo['ogg']['bitrate_average'])) {
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['ogg']['bitrate_average'];
- } elseif (!empty($ThisFileInfo['ogg']['bitrate_nominal'])) {
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['ogg']['bitrate_nominal'];
- } elseif (!empty($ThisFileInfo['ogg']['bitrate_min']) && !empty($ThisFileInfo['ogg']['bitrate_max'])) {
- $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['ogg']['bitrate_min'] + $ThisFileInfo['ogg']['bitrate_max']) / 2;
- }
- if (isset($ThisFileInfo['audio']['bitrate']) && !isset($ThisFileInfo['playtime_seconds'])) {
- if ($ThisFileInfo['audio']['bitrate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt Ogg file: bitrate_audio == zero';
- return false;
- }
- $ThisFileInfo['playtime_seconds'] = (float) ((($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['audio']['bitrate']);
- }
-
- if (isset($ThisFileInfo['ogg']['vendor'])) {
- $ThisFileInfo['audio']['encoder'] = preg_replace('/^Encoded with /', '', $ThisFileInfo['ogg']['vendor']);
-
- // Vorbis only
- if ($ThisFileInfo['audio']['dataformat'] == 'vorbis') {
-
- // Vorbis 1.0 starts with Xiph.Org
- if (preg_match('/^Xiph.Org/', $ThisFileInfo['audio']['encoder'])) {
-
- if ($ThisFileInfo['audio']['bitrate_mode'] == 'abr') {
-
- // Set -b 128 on abr files
- $ThisFileInfo['audio']['encoder_options'] = '-b '.round($ThisFileInfo['ogg']['bitrate_nominal'] / 1000);
-
- } elseif (($ThisFileInfo['audio']['bitrate_mode'] == 'vbr') && ($ThisFileInfo['audio']['channels'] == 2) && ($ThisFileInfo['audio']['sample_rate'] >= 44100) && ($ThisFileInfo['audio']['sample_rate'] <= 48000)) {
- // Set -q N on vbr files
- $ThisFileInfo['audio']['encoder_options'] = '-q '.$this->get_quality_from_nominal_bitrate($ThisFileInfo['ogg']['bitrate_nominal']);
-
- }
- }
-
- if (empty($ThisFileInfo['audio']['encoder_options']) && !empty($ThisFileInfo['ogg']['bitrate_nominal'])) {
- $ThisFileInfo['audio']['encoder_options'] = 'Nominal bitrate: '.intval(round($ThisFileInfo['ogg']['bitrate_nominal'] / 1000)).'kbps';
- }
- }
- }
-
- return true;
- }
-
- function ParseVorbisPageHeader(&$filedata, &$filedataoffset, &$ThisFileInfo, &$oggpageinfo) {
- $ThisFileInfo['audio']['dataformat'] = 'vorbis';
- $ThisFileInfo['audio']['lossless'] = false;
-
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
- $filedataoffset += 1;
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, $filedataoffset, 6); // hard-coded to 'vorbis'
- $filedataoffset += 6;
- $ThisFileInfo['ogg']['bitstreamversion'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['numberofchannels'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
- $filedataoffset += 1;
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['ogg']['numberofchannels'];
- $ThisFileInfo['ogg']['samplerate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- if ($ThisFileInfo['ogg']['samplerate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt Ogg file: sample rate == zero';
- return false;
- }
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['ogg']['samplerate'];
- $ThisFileInfo['ogg']['samples'] = 0; // filled in later
- $ThisFileInfo['ogg']['bitrate_average'] = 0; // filled in later
- $ThisFileInfo['ogg']['bitrate_max'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['bitrate_nominal'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['bitrate_min'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $ThisFileInfo['ogg']['blocksize_small'] = pow(2, getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0x0F);
- $ThisFileInfo['ogg']['blocksize_large'] = pow(2, (getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0xF0) >> 4);
- $ThisFileInfo['ogg']['stop_bit'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); // must be 1, marks end of packet
-
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr'; // overridden if actually abr
- if ($ThisFileInfo['ogg']['bitrate_max'] == 0xFFFFFFFF) {
- unset($ThisFileInfo['ogg']['bitrate_max']);
- $ThisFileInfo['audio']['bitrate_mode'] = 'abr';
- }
- if ($ThisFileInfo['ogg']['bitrate_nominal'] == 0xFFFFFFFF) {
- unset($ThisFileInfo['ogg']['bitrate_nominal']);
- }
- if ($ThisFileInfo['ogg']['bitrate_min'] == 0xFFFFFFFF) {
- unset($ThisFileInfo['ogg']['bitrate_min']);
- $ThisFileInfo['audio']['bitrate_mode'] = 'abr';
- }
- return true;
- }
-
- function ParseOggPageHeader(&$fd) {
- // http://xiph.org/ogg/vorbis/doc/framing.html
- $oggheader['page_start_offset'] = ftell($fd); // where we started from in the file
-
- $filedata = fread($fd, GETID3_FREAD_BUFFER_SIZE);
- $filedataoffset = 0;
- while ((substr($filedata, $filedataoffset++, 4) != 'OggS')) {
- if ((ftell($fd) - $oggheader['page_start_offset']) >= GETID3_FREAD_BUFFER_SIZE) {
- // should be found before here
- return false;
- }
- if ((($filedataoffset + 28) > strlen($filedata)) || (strlen($filedata) < 28)) {
- if (feof($fd) || (($filedata .= fread($fd, GETID3_FREAD_BUFFER_SIZE)) === false)) {
- // get some more data, unless eof, in which case fail
- return false;
- }
- }
- }
- $filedataoffset += strlen('OggS') - 1; // page, delimited by 'OggS'
-
- $oggheader['stream_structver'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
- $filedataoffset += 1;
- $oggheader['flags_raw'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
- $filedataoffset += 1;
- $oggheader['flags']['fresh'] = (bool) ($oggheader['flags_raw'] & 0x01); // fresh packet
- $oggheader['flags']['bos'] = (bool) ($oggheader['flags_raw'] & 0x02); // first page of logical bitstream (bos)
- $oggheader['flags']['eos'] = (bool) ($oggheader['flags_raw'] & 0x04); // last page of logical bitstream (eos)
-
- $oggheader['pcm_abs_position'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
- $filedataoffset += 8;
- $oggheader['stream_serialno'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $oggheader['page_seqno'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $oggheader['page_checksum'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
- $filedataoffset += 4;
- $oggheader['page_segments'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
- $filedataoffset += 1;
- $oggheader['page_length'] = 0;
- for ($i = 0; $i < $oggheader['page_segments']; $i++) {
- $oggheader['segment_table'][$i] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
- $filedataoffset += 1;
- $oggheader['page_length'] += $oggheader['segment_table'][$i];
- }
- $oggheader['header_end_offset'] = $oggheader['page_start_offset'] + $filedataoffset;
- $oggheader['page_end_offset'] = $oggheader['header_end_offset'] + $oggheader['page_length'];
- fseek($fd, $oggheader['header_end_offset'], SEEK_SET);
-
- return $oggheader;
- }
-
-
- function ParseVorbisCommentsFilepointer(&$fd, &$ThisFileInfo) {
-
- $OriginalOffset = ftell($fd);
- $CommentStartOffset = $OriginalOffset;
- $commentdataoffset = 0;
- $VorbisCommentPage = 1;
-
- switch ($ThisFileInfo['audio']['dataformat']) {
- case 'vorbis':
- $CommentStartOffset = $ThisFileInfo['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block
- fseek($fd, $CommentStartOffset, SEEK_SET);
- $commentdataoffset = 27 + $ThisFileInfo['ogg']['pageheader'][$VorbisCommentPage]['page_segments'];
- $commentdata = fread($fd, getid3_ogg::OggPageSegmentLength($ThisFileInfo['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset);
-
- $commentdataoffset += (strlen('vorbis') + 1);
- break;
-
- case 'flac':
- fseek($fd, $ThisFileInfo['flac']['VORBIS_COMMENT']['raw']['offset'] + 4, SEEK_SET);
- $commentdata = fread($fd, $ThisFileInfo['flac']['VORBIS_COMMENT']['raw']['block_length']);
- break;
-
- case 'speex':
- $CommentStartOffset = $ThisFileInfo['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block
- fseek($fd, $CommentStartOffset, SEEK_SET);
- $commentdataoffset = 27 + $ThisFileInfo['ogg']['pageheader'][$VorbisCommentPage]['page_segments'];
- $commentdata = fread($fd, getid3_ogg::OggPageSegmentLength($ThisFileInfo['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset);
- break;
-
- default:
- return false;
- break;
- }
-
- $VendorSize = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
- $commentdataoffset += 4;
-
- $ThisFileInfo['ogg']['vendor'] = substr($commentdata, $commentdataoffset, $VendorSize);
- $commentdataoffset += $VendorSize;
-
- $CommentsCount = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
- $commentdataoffset += 4;
- $ThisFileInfo['avdataoffset'] = $CommentStartOffset + $commentdataoffset;
-
- $basicfields = array('TITLE', 'ARTIST', 'ALBUM', 'TRACKNUMBER', 'GENRE', 'DATE', 'DESCRIPTION', 'COMMENT');
- for ($i = 0; $i < $CommentsCount; $i++) {
-
- $ThisFileInfo['ogg']['comments_raw'][$i]['dataoffset'] = $CommentStartOffset + $commentdataoffset;
-
- if (ftell($fd) < ($ThisFileInfo['ogg']['comments_raw'][$i]['dataoffset'] + 4)) {
- $VorbisCommentPage++;
-
- $oggpageinfo = getid3_ogg::ParseOggPageHeader($fd);
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
-
- // First, save what we haven't read yet
- $AsYetUnusedData = substr($commentdata, $commentdataoffset);
-
- // Then take that data off the end
- $commentdata = substr($commentdata, 0, $commentdataoffset);
-
- // Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct
- $commentdata .= str_repeat("\x00", 27 + $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
- $commentdataoffset += (27 + $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
-
- // Finally, stick the unused data back on the end
- $commentdata .= $AsYetUnusedData;
-
- //$commentdata .= fread($fd, $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
- $commentdata .= fread($fd, getid3_ogg::OggPageSegmentLength($ThisFileInfo['ogg']['pageheader'][$VorbisCommentPage], 1));
-
- }
- $ThisFileInfo['ogg']['comments_raw'][$i]['size'] = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
-
- // replace avdataoffset with position just after the last vorbiscomment
- $ThisFileInfo['avdataoffset'] = $ThisFileInfo['ogg']['comments_raw'][$i]['dataoffset'] + $ThisFileInfo['ogg']['comments_raw'][$i]['size'] + 4;
-
- $commentdataoffset += 4;
- while ((strlen($commentdata) - $commentdataoffset) < $ThisFileInfo['ogg']['comments_raw'][$i]['size']) {
- if (($ThisFileInfo['ogg']['comments_raw'][$i]['size'] > $ThisFileInfo['avdataend']) || ($ThisFileInfo['ogg']['comments_raw'][$i]['size'] < 0)) {
- $ThisFileInfo['error'][] = 'Invalid Ogg comment size (comment #'.$i.', claims to be '.number_format($ThisFileInfo['ogg']['comments_raw'][$i]['size']).' bytes) - aborting reading comments';
- break 2;
- }
-
- $VorbisCommentPage++;
-
- $oggpageinfo = getid3_ogg::ParseOggPageHeader($fd);
- $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
-
- // First, save what we haven't read yet
- $AsYetUnusedData = substr($commentdata, $commentdataoffset);
-
- // Then take that data off the end
- $commentdata = substr($commentdata, 0, $commentdataoffset);
-
- // Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct
- $commentdata .= str_repeat("\x00", 27 + $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
- $commentdataoffset += (27 + $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
-
- // Finally, stick the unused data back on the end
- $commentdata .= $AsYetUnusedData;
-
- //$commentdata .= fread($fd, $ThisFileInfo['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
- $commentdata .= fread($fd, getid3_ogg::OggPageSegmentLength($ThisFileInfo['ogg']['pageheader'][$VorbisCommentPage], 1));
-
- //$filebaseoffset += $oggpageinfo['header_end_offset'] - $oggpageinfo['page_start_offset'];
- }
- $commentstring = substr($commentdata, $commentdataoffset, $ThisFileInfo['ogg']['comments_raw'][$i]['size']);
- $commentdataoffset += $ThisFileInfo['ogg']['comments_raw'][$i]['size'];
-
- if (!$commentstring) {
-
- // no comment?
- $ThisFileInfo['warning'][] = 'Blank Ogg comment ['.$i.']';
-
- } elseif (strstr($commentstring, '=')) {
-
- $commentexploded = explode('=', $commentstring, 2);
- $ThisFileInfo['ogg']['comments_raw'][$i]['key'] = strtoupper($commentexploded[0]);
- $ThisFileInfo['ogg']['comments_raw'][$i]['value'] = @$commentexploded[1];
- $ThisFileInfo['ogg']['comments_raw'][$i]['data'] = base64_decode($ThisFileInfo['ogg']['comments_raw'][$i]['value']);
-
- $ThisFileInfo['ogg']['comments'][strtolower($ThisFileInfo['ogg']['comments_raw'][$i]['key'])][] = $ThisFileInfo['ogg']['comments_raw'][$i]['value'];
-
- $imageinfo = array();
- $imagechunkcheck = getid3_lib::GetDataImageSize($ThisFileInfo['ogg']['comments_raw'][$i]['data'], $imageinfo);
- $ThisFileInfo['ogg']['comments_raw'][$i]['image_mime'] = getid3_lib::image_type_to_mime_type($imagechunkcheck[2]);
- if (!$ThisFileInfo['ogg']['comments_raw'][$i]['image_mime'] || ($ThisFileInfo['ogg']['comments_raw'][$i]['image_mime'] == 'application/octet-stream')) {
- unset($ThisFileInfo['ogg']['comments_raw'][$i]['image_mime']);
- unset($ThisFileInfo['ogg']['comments_raw'][$i]['data']);
- }
-
- } else {
-
- $ThisFileInfo['warning'][] = '[known problem with CDex >= v1.40, < v1.50b7] Invalid Ogg comment name/value pair ['.$i.']: '.$commentstring;
-
- }
- }
-
-
- // Replay Gain Adjustment
- // http://privatewww.essex.ac.uk/~djmrob/replaygain/
- if (isset($ThisFileInfo['ogg']['comments']) && is_array($ThisFileInfo['ogg']['comments'])) {
- foreach ($ThisFileInfo['ogg']['comments'] as $index => $commentvalue) {
- switch ($index) {
- case 'rg_audiophile':
- case 'replaygain_album_gain':
- $ThisFileInfo['replay_gain']['album']['adjustment'] = (double) $commentvalue[0];
- unset($ThisFileInfo['ogg']['comments'][$index]);
- break;
-
- case 'rg_radio':
- case 'replaygain_track_gain':
- $ThisFileInfo['replay_gain']['track']['adjustment'] = (double) $commentvalue[0];
- unset($ThisFileInfo['ogg']['comments'][$index]);
- break;
-
- case 'replaygain_album_peak':
- $ThisFileInfo['replay_gain']['album']['peak'] = (double) $commentvalue[0];
- unset($ThisFileInfo['ogg']['comments'][$index]);
- break;
-
- case 'rg_peak':
- case 'replaygain_track_peak':
- $ThisFileInfo['replay_gain']['track']['peak'] = (double) $commentvalue[0];
- unset($ThisFileInfo['ogg']['comments'][$index]);
- break;
-
-
- default:
- // do nothing
- break;
- }
- }
- }
-
- fseek($fd, $OriginalOffset, SEEK_SET);
-
- return true;
- }
-
- function SpeexBandModeLookup($mode) {
- static $SpeexBandModeLookup = array();
- if (empty($SpeexBandModeLookup)) {
- $SpeexBandModeLookup[0] = 'narrow';
- $SpeexBandModeLookup[1] = 'wide';
- $SpeexBandModeLookup[2] = 'ultra-wide';
- }
- return (isset($SpeexBandModeLookup[$mode]) ? $SpeexBandModeLookup[$mode] : null);
- }
-
-
- function OggPageSegmentLength($OggInfoArray, $SegmentNumber=1) {
- for ($i = 0; $i < $SegmentNumber; $i++) {
- $segmentlength = 0;
- foreach ($OggInfoArray['segment_table'] as $key => $value) {
- $segmentlength += $value;
- if ($value < 255) {
- break;
- }
- }
- }
- return $segmentlength;
- }
-
-
- function get_quality_from_nominal_bitrate($nominal_bitrate) {
-
- // decrease precision
- $nominal_bitrate = $nominal_bitrate / 1000;
-
- if ($nominal_bitrate < 128) {
- // q-1 to q4
- $qval = ($nominal_bitrate - 64) / 16;
- } elseif ($nominal_bitrate < 256) {
- // q4 to q8
- $qval = $nominal_bitrate / 32;
- } elseif ($nominal_bitrate < 320) {
- // q8 to q9
- $qval = ($nominal_bitrate + 256) / 64;
- } else {
- // q9 to q10
- $qval = ($nominal_bitrate + 1300) / 180;
- }
- //return $qval; // 5.031324
- //return intval($qval); // 5
- return round($qval, 1); // 5 or 4.9
- }
-
-}
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.rkau.php b/apps/media/getID3/getid3/module.audio.rkau.php
deleted file mode 100644
index 0e344d43e65..00000000000
--- a/apps/media/getID3/getid3/module.audio.rkau.php
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.shorten.php //
-// module for analyzing Shorten Audio files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_rkau
-{
-
- function getid3_rkau(&$fd, &$ThisFileInfo) {
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $RKAUHeader = fread($fd, 20);
- if (substr($RKAUHeader, 0, 3) != 'RKA') {
- $ThisFileInfo['error'][] = 'Expecting "RKA" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($RKAUHeader, 0, 3).'"';
- return false;
- }
-
- $ThisFileInfo['fileformat'] = 'rkau';
- $ThisFileInfo['audio']['dataformat'] = 'rkau';
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
-
- $ThisFileInfo['rkau']['raw']['version'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 3, 1));
- $ThisFileInfo['rkau']['version'] = '1.'.str_pad($ThisFileInfo['rkau']['raw']['version'] & 0x0F, 2, '0', STR_PAD_LEFT);
- if (($ThisFileInfo['rkau']['version'] > 1.07) || ($ThisFileInfo['rkau']['version'] < 1.06)) {
- $ThisFileInfo['error'][] = 'This version of getID3() can only parse RKAU files v1.06 and 1.07 (this file is v'.$ThisFileInfo['rkau']['version'].')';
- unset($ThisFileInfo['rkau']);
- return false;
- }
-
- $ThisFileInfo['rkau']['source_bytes'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 4, 4));
- $ThisFileInfo['rkau']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 8, 4));
- $ThisFileInfo['rkau']['channels'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 12, 1));
- $ThisFileInfo['rkau']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 13, 1));
-
- $ThisFileInfo['rkau']['raw']['quality'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 14, 1));
- $this->RKAUqualityLookup($ThisFileInfo['rkau']);
-
- $ThisFileInfo['rkau']['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 15, 1));
- $ThisFileInfo['rkau']['flags']['joint_stereo'] = (bool) (!($ThisFileInfo['rkau']['raw']['flags'] & 0x01));
- $ThisFileInfo['rkau']['flags']['streaming'] = (bool) ($ThisFileInfo['rkau']['raw']['flags'] & 0x02);
- $ThisFileInfo['rkau']['flags']['vrq_lossy_mode'] = (bool) ($ThisFileInfo['rkau']['raw']['flags'] & 0x04);
-
- if ($ThisFileInfo['rkau']['flags']['streaming']) {
- $ThisFileInfo['avdataoffset'] += 20;
- $ThisFileInfo['rkau']['compressed_bytes'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 16, 4));
- } else {
- $ThisFileInfo['avdataoffset'] += 16;
- $ThisFileInfo['rkau']['compressed_bytes'] = $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'] - 1;
- }
- // Note: compressed_bytes does not always equal what appears to be the actual number of compressed bytes,
- // sometimes it's more, sometimes less. No idea why(?)
-
- $ThisFileInfo['audio']['lossless'] = $ThisFileInfo['rkau']['lossless'];
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['rkau']['channels'];
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['rkau']['bits_per_sample'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['rkau']['sample_rate'];
-
- $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['rkau']['source_bytes'] / ($ThisFileInfo['rkau']['sample_rate'] * $ThisFileInfo['rkau']['channels'] * ($ThisFileInfo['rkau']['bits_per_sample'] / 8));
- $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['rkau']['compressed_bytes'] * 8) / $ThisFileInfo['playtime_seconds'];
-
- return true;
-
- }
-
-
- function RKAUqualityLookup(&$RKAUdata) {
- $level = ($RKAUdata['raw']['quality'] & 0xF0) >> 4;
- $quality = $RKAUdata['raw']['quality'] & 0x0F;
-
- $RKAUdata['lossless'] = (($quality == 0) ? true : false);
- $RKAUdata['compression_level'] = $level + 1;
- if (!$RKAUdata['lossless']) {
- $RKAUdata['quality_setting'] = $quality;
- }
-
- return true;
- }
-
-}
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.tta.php b/apps/media/getID3/getid3/module.audio.tta.php
deleted file mode 100644
index 903de6bf45d..00000000000
--- a/apps/media/getID3/getid3/module.audio.tta.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.tta.php //
-// module for analyzing TTA Audio files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_tta
-{
-
- function getid3_tta(&$fd, &$ThisFileInfo) {
-
- $ThisFileInfo['fileformat'] = 'tta';
- $ThisFileInfo['audio']['dataformat'] = 'tta';
- $ThisFileInfo['audio']['lossless'] = true;
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $ttaheader = fread($fd, 26);
-
- $ThisFileInfo['tta']['magic'] = substr($ttaheader, 0, 3);
- if ($ThisFileInfo['tta']['magic'] != 'TTA') {
- $ThisFileInfo['error'][] = 'Expecting "TTA" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$ThisFileInfo['tta']['magic'].'"';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['audio']);
- unset($ThisFileInfo['tta']);
- return false;
- }
-
- switch ($ttaheader{3}) {
- case "\x01": // TTA v1.x
- case "\x02": // TTA v1.x
- case "\x03": // TTA v1.x
- // "It was the demo-version of the TTA encoder. There is no released format with such header. TTA encoder v1 is not supported about a year."
- $ThisFileInfo['tta']['major_version'] = 1;
- $ThisFileInfo['avdataoffset'] += 16;
-
- $ThisFileInfo['tta']['compression_level'] = ord($ttaheader{3});
- $ThisFileInfo['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2));
- $ThisFileInfo['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
- $ThisFileInfo['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 4));
- $ThisFileInfo['tta']['samples_per_channel'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12, 4));
-
- $ThisFileInfo['audio']['encoder_options'] = '-e'.$ThisFileInfo['tta']['compression_level'];
- $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['tta']['samples_per_channel'] / $ThisFileInfo['tta']['sample_rate'];
- break;
-
- case '2': // TTA v2.x
- // "I have hurried to release the TTA 2.0 encoder. Format documentation is removed from our site. This format still in development. Please wait the TTA2 format, encoder v4."
- $ThisFileInfo['tta']['major_version'] = 2;
- $ThisFileInfo['avdataoffset'] += 20;
-
- $ThisFileInfo['tta']['compression_level'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2));
- $ThisFileInfo['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
- $ThisFileInfo['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 2));
- $ThisFileInfo['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 10, 2));
- $ThisFileInfo['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12, 4));
- $ThisFileInfo['tta']['data_length'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 16, 4));
-
- $ThisFileInfo['audio']['encoder_options'] = '-e'.$ThisFileInfo['tta']['compression_level'];
- $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['tta']['data_length'] / $ThisFileInfo['tta']['sample_rate'];
- break;
-
- case '1': // TTA v3.x
- // "This is a first stable release of the TTA format. It will be supported by the encoders v3 or higher."
- $ThisFileInfo['tta']['major_version'] = 3;
- $ThisFileInfo['avdataoffset'] += 26;
-
- $ThisFileInfo['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2)); // getid3_riff::RIFFwFormatTagLookup()
- $ThisFileInfo['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
- $ThisFileInfo['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 2));
- $ThisFileInfo['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 10, 4));
- $ThisFileInfo['tta']['data_length'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 14, 4));
- $ThisFileInfo['tta']['crc32_footer'] = substr($ttaheader, 18, 4);
- $ThisFileInfo['tta']['seek_point'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 22, 4));
-
- $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['tta']['data_length'] / $ThisFileInfo['tta']['sample_rate'];
- break;
-
- default:
- $ThisFileInfo['error'][] = 'This version of getID3() only knows how to handle TTA v1 and v2 - it may not work correctly with this file which appears to be TTA v'.$ttaheader{3};
- return false;
- break;
- }
-
- $ThisFileInfo['audio']['encoder'] = 'TTA v'.$ThisFileInfo['tta']['major_version'];
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['tta']['bits_per_sample'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['tta']['sample_rate'];
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['tta']['channels'];
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
-
- return true;
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.audio.wavpack.php b/apps/media/getID3/getid3/module.audio.wavpack.php
deleted file mode 100644
index 589ebe28a4d..00000000000
--- a/apps/media/getID3/getid3/module.audio.wavpack.php
+++ /dev/null
@@ -1,372 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.wavpack.php //
-// module for analyzing WavPack v4.0+ Audio files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_wavpack
-{
-
- function getid3_wavpack(&$fd, &$ThisFileInfo) {
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
-
- while (true) {
-
- $wavpackheader = fread($fd, 32);
-
- if (ftell($fd) >= $ThisFileInfo['avdataend']) {
- break;
- } elseif (feof($fd)) {
- break;
- } elseif (
- (@$ThisFileInfo['wavpack']['blockheader']['total_samples'] > 0) &&
- (@$ThisFileInfo['wavpack']['blockheader']['block_samples'] > 0) &&
- (!isset($ThisFileInfo['wavpack']['riff_trailer_size']) || ($ThisFileInfo['wavpack']['riff_trailer_size'] <= 0)) &&
- ((@$ThisFileInfo['wavpack']['config_flags']['md5_checksum'] === false) || !empty($ThisFileInfo['md5_data_source']))) {
- break;
- }
-
- $blockheader_offset = ftell($fd) - 32;
- $blockheader_magic = substr($wavpackheader, 0, 4);
- $blockheader_size = getid3_lib::LittleEndian2Int(substr($wavpackheader, 4, 4));
-
- if ($blockheader_magic != 'wvpk') {
- $ThisFileInfo['error'][] = 'Expecting "wvpk" at offset '.$blockheader_offset.', found "'.$blockheader_magic.'"';
- if ((@$ThisFileInfo['audio']['dataformat'] != 'wavpack') && (@$ThisFileInfo['audio']['dataformat'] != 'wvc')) {
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['audio']);
- unset($ThisFileInfo['wavpack']);
- }
- return false;
- }
-
-
- if ((@$ThisFileInfo['wavpack']['blockheader']['block_samples'] <= 0) ||
- (@$ThisFileInfo['wavpack']['blockheader']['total_samples'] <= 0)) {
- // Also, it is possible that the first block might not have
- // any samples (block_samples == 0) and in this case you should skip blocks
- // until you find one with samples because the other information (like
- // total_samples) are not guaranteed to be correct until (block_samples > 0)
-
- // Finally, I have defined a format for files in which the length is not known
- // (for example when raw files are created using pipes). In these cases
- // total_samples will be -1 and you must seek to the final block to determine
- // the total number of samples.
-
-
- $ThisFileInfo['audio']['dataformat'] = 'wavpack';
- $ThisFileInfo['fileformat'] = 'wavpack';
- $ThisFileInfo['audio']['lossless'] = true;
- $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
-
- $ThisFileInfo['wavpack']['blockheader']['offset'] = $blockheader_offset;
- $ThisFileInfo['wavpack']['blockheader']['magic'] = $blockheader_magic;
- $ThisFileInfo['wavpack']['blockheader']['size'] = $blockheader_size;
-
- if ($ThisFileInfo['wavpack']['blockheader']['size'] >= 0x100000) {
- $ThisFileInfo['error'][] = 'Expecting WavPack block size less than "0x100000", found "'.$ThisFileInfo['wavpack']['blockheader']['size'].'" at offset '.$ThisFileInfo['wavpack']['blockheader']['offset'];
- if ((@$ThisFileInfo['audio']['dataformat'] != 'wavpack') && (@$ThisFileInfo['audio']['dataformat'] != 'wvc')) {
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['audio']);
- unset($ThisFileInfo['wavpack']);
- }
- return false;
- }
-
- $ThisFileInfo['wavpack']['blockheader']['minor_version'] = ord($wavpackheader{8});
- $ThisFileInfo['wavpack']['blockheader']['major_version'] = ord($wavpackheader{9});
-
- if (($ThisFileInfo['wavpack']['blockheader']['major_version'] != 4) ||
- (($ThisFileInfo['wavpack']['blockheader']['minor_version'] < 4) &&
- ($ThisFileInfo['wavpack']['blockheader']['minor_version'] > 16))) {
- $ThisFileInfo['error'][] = 'Expecting WavPack version between "4.2" and "4.16", found version "'.$ThisFileInfo['wavpack']['blockheader']['major_version'].'.'.$ThisFileInfo['wavpack']['blockheader']['minor_version'].'" at offset '.$ThisFileInfo['wavpack']['blockheader']['offset'];
- if ((@$ThisFileInfo['audio']['dataformat'] != 'wavpack') && (@$ThisFileInfo['audio']['dataformat'] != 'wvc')) {
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['audio']);
- unset($ThisFileInfo['wavpack']);
- }
- return false;
- }
-
- $ThisFileInfo['wavpack']['blockheader']['track_number'] = ord($wavpackheader{10}); // unused
- $ThisFileInfo['wavpack']['blockheader']['index_number'] = ord($wavpackheader{11}); // unused
- $ThisFileInfo['wavpack']['blockheader']['total_samples'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 12, 4));
- $ThisFileInfo['wavpack']['blockheader']['block_index'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 16, 4));
- $ThisFileInfo['wavpack']['blockheader']['block_samples'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 20, 4));
- $ThisFileInfo['wavpack']['blockheader']['flags_raw'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 24, 4));
- $ThisFileInfo['wavpack']['blockheader']['crc'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 28, 4));
-
- $ThisFileInfo['wavpack']['blockheader']['flags']['bytes_per_sample'] = 1 + ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000003);
- $ThisFileInfo['wavpack']['blockheader']['flags']['mono'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000004);
- $ThisFileInfo['wavpack']['blockheader']['flags']['hybrid'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000008);
- $ThisFileInfo['wavpack']['blockheader']['flags']['joint_stereo'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000010);
- $ThisFileInfo['wavpack']['blockheader']['flags']['cross_decorrelation'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000020);
- $ThisFileInfo['wavpack']['blockheader']['flags']['hybrid_noiseshape'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000040);
- $ThisFileInfo['wavpack']['blockheader']['flags']['ieee_32bit_float'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000080);
- $ThisFileInfo['wavpack']['blockheader']['flags']['int_32bit'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000100);
- $ThisFileInfo['wavpack']['blockheader']['flags']['hybrid_bitrate_noise'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000200);
- $ThisFileInfo['wavpack']['blockheader']['flags']['hybrid_balance_noise'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000400);
- $ThisFileInfo['wavpack']['blockheader']['flags']['multichannel_initial'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000800);
- $ThisFileInfo['wavpack']['blockheader']['flags']['multichannel_final'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00001000);
-
- $ThisFileInfo['audio']['lossless'] = !$ThisFileInfo['wavpack']['blockheader']['flags']['hybrid'];
- }
-
- while (!feof($fd) && (ftell($fd) < ($blockheader_offset + $blockheader_size + 8))) {
-
- $metablock = array('offset'=>ftell($fd));
- $metablockheader = fread($fd, 2);
- if (feof($fd)) {
- break;
- }
- $metablock['id'] = ord($metablockheader{0});
- $metablock['function_id'] = ($metablock['id'] & 0x3F);
- $metablock['function_name'] = $this->WavPackMetablockNameLookup($metablock['function_id']);
-
- // The 0x20 bit in the id of the meta subblocks (which is defined as
- // ID_OPTIONAL_DATA) is a permanent part of the id. The idea is that
- // if a decoder encounters an id that it does not know about, it uses
- // that "ID_OPTIONAL_DATA" flag to determine what to do. If it is set
- // then the decoder simply ignores the metadata, but if it is zero
- // then the decoder should quit because it means that an understanding
- // of the metadata is required to correctly decode the audio.
- $metablock['non_decoder'] = (bool) ($metablock['id'] & 0x20);
-
- $metablock['padded_data'] = (bool) ($metablock['id'] & 0x40);
- $metablock['large_block'] = (bool) ($metablock['id'] & 0x80);
- if ($metablock['large_block']) {
- $metablockheader .= fread($fd, 2);
- }
- $metablock['size'] = getid3_lib::LittleEndian2Int(substr($metablockheader, 1)) * 2; // size is stored in words
- $metablock['data'] = null;
-
- if ($metablock['size'] > 0) {
-
- switch ($metablock['function_id']) {
- case 0x21: // ID_RIFF_HEADER
- case 0x22: // ID_RIFF_TRAILER
- case 0x23: // ID_REPLAY_GAIN
- case 0x24: // ID_CUESHEET
- case 0x25: // ID_CONFIG_BLOCK
- case 0x26: // ID_MD5_CHECKSUM
- $metablock['data'] = fread($fd, $metablock['size']);
-
- if ($metablock['padded_data']) {
- // padded to the nearest even byte
- $metablock['size']--;
- $metablock['data'] = substr($metablock['data'], 0, -1);
- }
- break;
-
- case 0x00: // ID_DUMMY
- case 0x01: // ID_ENCODER_INFO
- case 0x02: // ID_DECORR_TERMS
- case 0x03: // ID_DECORR_WEIGHTS
- case 0x04: // ID_DECORR_SAMPLES
- case 0x05: // ID_ENTROPY_VARS
- case 0x06: // ID_HYBRID_PROFILE
- case 0x07: // ID_SHAPING_WEIGHTS
- case 0x08: // ID_FLOAT_INFO
- case 0x09: // ID_INT32_INFO
- case 0x0A: // ID_WV_BITSTREAM
- case 0x0B: // ID_WVC_BITSTREAM
- case 0x0C: // ID_WVX_BITSTREAM
- case 0x0D: // ID_CHANNEL_INFO
- fseek($fd, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
- break;
-
- default:
- $ThisFileInfo['warning'][] = 'Unexpected metablock type "0x'.str_pad(dechex($metablock['function_id']), 2, '0', STR_PAD_LEFT).'" at offset '.$metablock['offset'];
- fseek($fd, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
- break;
- }
-
- switch ($metablock['function_id']) {
- case 0x21: // ID_RIFF_HEADER
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
- $original_wav_filesize = getid3_lib::LittleEndian2Int(substr($metablock['data'], 4, 4));
- getid3_riff::ParseRIFFdata($metablock['data'], $ParsedRIFFheader);
- $metablock['riff'] = $ParsedRIFFheader['riff'];
- $metablock['riff']['original_filesize'] = $original_wav_filesize;
- $ThisFileInfo['wavpack']['riff_trailer_size'] = $original_wav_filesize - $metablock['riff']['WAVE']['data'][0]['size'] - $metablock['riff']['header_size'];
-
- $ThisFileInfo['audio']['sample_rate'] = $ParsedRIFFheader['riff']['raw']['fmt ']['nSamplesPerSec'];
- $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['wavpack']['blockheader']['total_samples'] / $ThisFileInfo['audio']['sample_rate'];
-
- // Safe RIFF header in case there's a RIFF footer later
- $metablockRIFFheader = $metablock['data'];
- break;
-
-
- case 0x22: // ID_RIFF_TRAILER
- $metablockRIFFfooter = $metablockRIFFheader.$metablock['data'];
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
-
- $ftell_old = ftell($fd);
- $startoffset = $metablock['offset'] + ($metablock['large_block'] ? 4 : 2);
- $ParsedRIFFfooter = array('avdataend'=>$ThisFileInfo['avdataend'], 'fileformat'=>'riff', 'error'=>array(), 'warning'=>array());
- $metablock['riff'] = getid3_riff::ParseRIFF($fd, $startoffset, $startoffset + $metablock['size'], $ParsedRIFFfooter);
- fseek($fd, $ftell_old, SEEK_SET);
-
- if (!empty($metablock['riff']['INFO'])) {
- getid3_riff::RIFFcommentsParse($metablock['riff']['INFO'], $metablock['comments']);
- $ThisFileInfo['tags']['riff'] = $metablock['comments'];
- }
- break;
-
-
- case 0x23: // ID_REPLAY_GAIN
- $ThisFileInfo['warning'][] = 'WavPack "Replay Gain" contents not yet handled by getID3() in metablock at offset '.$metablock['offset'];
- break;
-
-
- case 0x24: // ID_CUESHEET
- $ThisFileInfo['warning'][] = 'WavPack "Cuesheet" contents not yet handled by getID3() in metablock at offset '.$metablock['offset'];
- break;
-
-
- case 0x25: // ID_CONFIG_BLOCK
- $metablock['flags_raw'] = getid3_lib::LittleEndian2Int(substr($metablock['data'], 0, 3));
-
- $metablock['flags']['adobe_mode'] = (bool) ($metablock['flags_raw'] & 0x000001); // "adobe" mode for 32-bit floats
- $metablock['flags']['fast_flag'] = (bool) ($metablock['flags_raw'] & 0x000002); // fast mode
- $metablock['flags']['very_fast_flag'] = (bool) ($metablock['flags_raw'] & 0x000004); // double fast
- $metablock['flags']['high_flag'] = (bool) ($metablock['flags_raw'] & 0x000008); // high quality mode
- $metablock['flags']['very_high_flag'] = (bool) ($metablock['flags_raw'] & 0x000010); // double high (not used yet)
- $metablock['flags']['bitrate_kbps'] = (bool) ($metablock['flags_raw'] & 0x000020); // bitrate is kbps, not bits / sample
- $metablock['flags']['auto_shaping'] = (bool) ($metablock['flags_raw'] & 0x000040); // automatic noise shaping
- $metablock['flags']['shape_override'] = (bool) ($metablock['flags_raw'] & 0x000080); // shaping mode specified
- $metablock['flags']['joint_override'] = (bool) ($metablock['flags_raw'] & 0x000100); // joint-stereo mode specified
- $metablock['flags']['copy_time'] = (bool) ($metablock['flags_raw'] & 0x000200); // copy file-time from source
- $metablock['flags']['create_exe'] = (bool) ($metablock['flags_raw'] & 0x000400); // create executable
- $metablock['flags']['create_wvc'] = (bool) ($metablock['flags_raw'] & 0x000800); // create correction file
- $metablock['flags']['optimize_wvc'] = (bool) ($metablock['flags_raw'] & 0x001000); // maximize bybrid compression
- $metablock['flags']['quality_mode'] = (bool) ($metablock['flags_raw'] & 0x002000); // psychoacoustic quality mode
- $metablock['flags']['raw_flag'] = (bool) ($metablock['flags_raw'] & 0x004000); // raw mode (not implemented yet)
- $metablock['flags']['calc_noise'] = (bool) ($metablock['flags_raw'] & 0x008000); // calc noise in hybrid mode
- $metablock['flags']['lossy_mode'] = (bool) ($metablock['flags_raw'] & 0x010000); // obsolete (for information)
- $metablock['flags']['extra_mode'] = (bool) ($metablock['flags_raw'] & 0x020000); // extra processing mode
- $metablock['flags']['skip_wvx'] = (bool) ($metablock['flags_raw'] & 0x040000); // no wvx stream w/ floats & big ints
- $metablock['flags']['md5_checksum'] = (bool) ($metablock['flags_raw'] & 0x080000); // compute & store MD5 signature
- $metablock['flags']['quiet_mode'] = (bool) ($metablock['flags_raw'] & 0x100000); // don't report progress %
-
- $ThisFileInfo['wavpack']['config_flags'] = $metablock['flags'];
-
-
- if ($ThisFileInfo['wavpack']['blockheader']['flags']['hybrid']) {
- @$ThisFileInfo['audio']['encoder_options'] .= ' -b???';
- }
- @$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['adobe_mode'] ? ' -a' : '');
- @$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['optimize_wvc'] ? ' -cc' : '');
- @$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['create_exe'] ? ' -e' : '');
- @$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['fast_flag'] ? ' -f' : '');
- @$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['joint_override'] ? ' -j?' : '');
- @$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['high_flag'] ? ' -h' : '');
- @$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['md5_checksum'] ? ' -m' : '');
- @$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['calc_noise'] ? ' -n' : '');
- @$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['shape_override'] ? ' -s?' : '');
- @$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['extra_mode'] ? ' -x?' : '');
- if (@$ThisFileInfo['audio']['encoder_options']) {
- $ThisFileInfo['audio']['encoder_options'] = trim(@$ThisFileInfo['audio']['encoder_options']);
- }
- elseif (isset($ThisFileInfo['audio']['encoder_options'])) {
- unset($ThisFileInfo['audio']['encoder_options']);
- }
- break;
-
-
- case 0x26: // ID_MD5_CHECKSUM
- if (strlen($metablock['data']) == 16) {
- $ThisFileInfo['md5_data_source'] = strtolower(getid3_lib::PrintHexBytes($metablock['data'], true, false, false));
- } else {
- $ThisFileInfo['warning'][] = 'Expecting 16 bytes of WavPack "MD5 Checksum" in metablock at offset '.$metablock['offset'].', but found '.strlen($metablock['data']).' bytes';
- }
- break;
-
-
- case 0x00: // ID_DUMMY
- case 0x01: // ID_ENCODER_INFO
- case 0x02: // ID_DECORR_TERMS
- case 0x03: // ID_DECORR_WEIGHTS
- case 0x04: // ID_DECORR_SAMPLES
- case 0x05: // ID_ENTROPY_VARS
- case 0x06: // ID_HYBRID_PROFILE
- case 0x07: // ID_SHAPING_WEIGHTS
- case 0x08: // ID_FLOAT_INFO
- case 0x09: // ID_INT32_INFO
- case 0x0A: // ID_WV_BITSTREAM
- case 0x0B: // ID_WVC_BITSTREAM
- case 0x0C: // ID_WVX_BITSTREAM
- case 0x0D: // ID_CHANNEL_INFO
- unset($metablock);
- break;
- }
-
- }
- if (!empty($metablock)) {
- $ThisFileInfo['wavpack']['metablocks'][] = $metablock;
- }
-
- }
-
- }
-
- $ThisFileInfo['audio']['encoder'] = 'WavPack v'.$ThisFileInfo['wavpack']['blockheader']['major_version'].'.'.str_pad($ThisFileInfo['wavpack']['blockheader']['minor_version'], 2, '0', STR_PAD_LEFT);
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['wavpack']['blockheader']['flags']['bytes_per_sample'] * 8;
- $ThisFileInfo['audio']['channels'] = ($ThisFileInfo['wavpack']['blockheader']['flags']['mono'] ? 1 : 2);
-
- if (@$ThisFileInfo['playtime_seconds']) {
-
- $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
-
- } else {
-
- $ThisFileInfo['audio']['dataformat'] = 'wvc';
-
- }
-
- return true;
- }
-
-
- function WavPackMetablockNameLookup(&$id) {
- static $WavPackMetablockNameLookup = array(
- 0x00 => 'Dummy',
- 0x01 => 'Encoder Info',
- 0x02 => 'Decorrelation Terms',
- 0x03 => 'Decorrelation Weights',
- 0x04 => 'Decorrelation Samples',
- 0x05 => 'Entropy Variables',
- 0x06 => 'Hybrid Profile',
- 0x07 => 'Shaping Weights',
- 0x08 => 'Float Info',
- 0x09 => 'Int32 Info',
- 0x0A => 'WV Bitstream',
- 0x0B => 'WVC Bitstream',
- 0x0C => 'WVX Bitstream',
- 0x0D => 'Channel Info',
- 0x21 => 'RIFF header',
- 0x22 => 'RIFF trailer',
- 0x23 => 'Replay Gain',
- 0x24 => 'Cuesheet',
- 0x25 => 'Config Block',
- 0x26 => 'MD5 Checksum',
- );
- return (@$WavPackMetablockNameLookup[$id]);
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.graphic.gif.php b/apps/media/getID3/getid3/module.graphic.gif.php
deleted file mode 100644
index 986ada30a7c..00000000000
--- a/apps/media/getID3/getid3/module.graphic.gif.php
+++ /dev/null
@@ -1,183 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.graphic.gif.php //
-// module for analyzing GIF Image files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_gif
-{
-
- function getid3_gif(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'gif';
- $ThisFileInfo['video']['dataformat'] = 'gif';
- $ThisFileInfo['video']['lossless'] = true;
- $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $GIFheader = fread($fd, 13);
- $offset = 0;
-
- $ThisFileInfo['gif']['header']['raw']['identifier'] = substr($GIFheader, $offset, 3);
- $offset += 3;
-
- if ($ThisFileInfo['gif']['header']['raw']['identifier'] != 'GIF') {
- $ThisFileInfo['error'][] = 'Expecting "GIF" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$ThisFileInfo['gif']['header']['raw']['identifier'].'"';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['gif']);
- return false;
- }
-
- $ThisFileInfo['gif']['header']['raw']['version'] = substr($GIFheader, $offset, 3);
- $offset += 3;
- $ThisFileInfo['gif']['header']['raw']['width'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 2));
- $offset += 2;
- $ThisFileInfo['gif']['header']['raw']['height'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 2));
- $offset += 2;
- $ThisFileInfo['gif']['header']['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 1));
- $offset += 1;
- $ThisFileInfo['gif']['header']['raw']['bg_color_index'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 1));
- $offset += 1;
- $ThisFileInfo['gif']['header']['raw']['aspect_ratio'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 1));
- $offset += 1;
-
- $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['gif']['header']['raw']['width'];
- $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['gif']['header']['raw']['height'];
- $ThisFileInfo['gif']['version'] = $ThisFileInfo['gif']['header']['raw']['version'];
- $ThisFileInfo['gif']['header']['flags']['global_color_table'] = (bool) ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x80);
- if ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x80) {
- // Number of bits per primary color available to the original image, minus 1
- $ThisFileInfo['gif']['header']['bits_per_pixel'] = 3 * ((($ThisFileInfo['gif']['header']['raw']['flags'] & 0x70) >> 4) + 1);
- } else {
- $ThisFileInfo['gif']['header']['bits_per_pixel'] = 0;
- }
- $ThisFileInfo['gif']['header']['flags']['global_color_sorted'] = (bool) ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x40);
- if ($ThisFileInfo['gif']['header']['flags']['global_color_table']) {
- // the number of bytes contained in the Global Color Table. To determine that
- // actual size of the color table, raise 2 to [the value of the field + 1]
- $ThisFileInfo['gif']['header']['global_color_size'] = pow(2, ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x07) + 1);
- $ThisFileInfo['video']['bits_per_sample'] = ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x07) + 1;
- } else {
- $ThisFileInfo['gif']['header']['global_color_size'] = 0;
- }
- if ($ThisFileInfo['gif']['header']['raw']['aspect_ratio'] != 0) {
- // Aspect Ratio = (Pixel Aspect Ratio + 15) / 64
- $ThisFileInfo['gif']['header']['aspect_ratio'] = ($ThisFileInfo['gif']['header']['raw']['aspect_ratio'] + 15) / 64;
- }
-
-// if ($ThisFileInfo['gif']['header']['flags']['global_color_table']) {
-// $GIFcolorTable = fread($fd, 3 * $ThisFileInfo['gif']['header']['global_color_size']);
-// $offset = 0;
-// for ($i = 0; $i < $ThisFileInfo['gif']['header']['global_color_size']; $i++) {
-// $red = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
-// $green = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
-// $blue = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
-// $ThisFileInfo['gif']['global_color_table'][$i] = (($red << 16) | ($green << 8) | ($blue));
-// }
-// }
-//
-// // Image Descriptor
-// while (!feof($fd)) {
-// $NextBlockTest = fread($fd, 1);
-// switch ($NextBlockTest) {
-//
-// case ',': // ',' - Image separator character
-//
-// $ImageDescriptorData = $NextBlockTest.fread($fd, 9);
-// $ImageDescriptor = array();
-// $ImageDescriptor['image_left'] = getid3_lib::LittleEndian2Int(substr($ImageDescriptorData, 1, 2));
-// $ImageDescriptor['image_top'] = getid3_lib::LittleEndian2Int(substr($ImageDescriptorData, 3, 2));
-// $ImageDescriptor['image_width'] = getid3_lib::LittleEndian2Int(substr($ImageDescriptorData, 5, 2));
-// $ImageDescriptor['image_height'] = getid3_lib::LittleEndian2Int(substr($ImageDescriptorData, 7, 2));
-// $ImageDescriptor['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ImageDescriptorData, 9, 1));
-// $ImageDescriptor['flags']['use_local_color_map'] = (bool) ($ImageDescriptor['flags_raw'] & 0x80);
-// $ImageDescriptor['flags']['image_interlaced'] = (bool) ($ImageDescriptor['flags_raw'] & 0x40);
-// $ThisFileInfo['gif']['image_descriptor'][] = $ImageDescriptor;
-//
-// if ($ImageDescriptor['flags']['use_local_color_map']) {
-//
-// $ThisFileInfo['warning'][] = 'This version of getID3() cannot parse local color maps for GIFs';
-// return true;
-//
-// }
-//echo 'Start of raster data: '.ftell($fd).'<BR>';
-// $RasterData = array();
-// $RasterData['code_size'] = getid3_lib::LittleEndian2Int(fread($fd, 1));
-// $RasterData['block_byte_count'] = getid3_lib::LittleEndian2Int(fread($fd, 1));
-// $ThisFileInfo['gif']['raster_data'][count($ThisFileInfo['gif']['image_descriptor']) - 1] = $RasterData;
-//
-// $CurrentCodeSize = $RasterData['code_size'] + 1;
-// for ($i = 0; $i < pow(2, $RasterData['code_size']); $i++) {
-// $DefaultDataLookupTable[$i] = chr($i);
-// }
-// $DefaultDataLookupTable[pow(2, $RasterData['code_size']) + 0] = ''; // Clear Code
-// $DefaultDataLookupTable[pow(2, $RasterData['code_size']) + 1] = ''; // End Of Image Code
-//
-//
-// $NextValue = $this->GetLSBits($fd, $CurrentCodeSize);
-// echo 'Clear Code: '.$NextValue.'<BR>';
-//
-// $NextValue = $this->GetLSBits($fd, $CurrentCodeSize);
-// echo 'First Color: '.$NextValue.'<BR>';
-//
-// $Prefix = $NextValue;
-//$i = 0;
-// while ($i++ < 20) {
-// $NextValue = $this->GetLSBits($fd, $CurrentCodeSize);
-// echo $NextValue.'<BR>';
-// }
-//return true;
-// break;
-//
-// case '!':
-// // GIF Extension Block
-// $ExtensionBlockData = $NextBlockTest.fread($fd, 2);
-// $ExtensionBlock = array();
-// $ExtensionBlock['function_code'] = getid3_lib::LittleEndian2Int(substr($ExtensionBlockData, 1, 1));
-// $ExtensionBlock['byte_length'] = getid3_lib::LittleEndian2Int(substr($ExtensionBlockData, 2, 1));
-// $ExtensionBlock['data'] = fread($fd, $ExtensionBlock['byte_length']);
-// $ThisFileInfo['gif']['extension_blocks'][] = $ExtensionBlock;
-// break;
-//
-// case ';':
-// $ThisFileInfo['gif']['terminator_offset'] = ftell($fd) - 1;
-// // GIF Terminator
-// break;
-//
-// default:
-// break;
-//
-//
-// }
-// }
-
- return true;
- }
-
-
- function GetLSBits($fd, $bits) {
- static $bitbuffer = '';
- while (strlen($bitbuffer) < $bits) {
-//echo 'Read another byte: '.ftell($fd).'<BR>';
- $bitbuffer = str_pad(decbin(ord(fread($fd, 1))), 8, '0', STR_PAD_LEFT).$bitbuffer;
- }
-
- $value = bindec(substr($bitbuffer, 0 - $bits));
- $bitbuffer = substr($bitbuffer, 0, 0 - $bits);
-
- return $value;
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.graphic.jpg.php b/apps/media/getID3/getid3/module.graphic.jpg.php
deleted file mode 100644
index cd5e986543c..00000000000
--- a/apps/media/getID3/getid3/module.graphic.jpg.php
+++ /dev/null
@@ -1,249 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.graphic.jpg.php //
-// module for analyzing JPEG Image files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_jpg
-{
-
-
- function getid3_jpg(&$fd, &$ThisFileInfo) {
- $ThisFileInfo['fileformat'] = 'jpg';
- $ThisFileInfo['video']['dataformat'] = 'jpg';
- $ThisFileInfo['video']['lossless'] = false;
- $ThisFileInfo['video']['bits_per_sample'] = 24;
- $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
-
- $imageinfo = array();
- list($width, $height, $type) = getid3_lib::GetDataImageSize(fread($fd, $ThisFileInfo['filesize']), $imageinfo);
-
- if (isset($imageinfo['APP13'])) {
- // http://php.net/iptcparse
- // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/IPTC.html
- $iptc_parsed = iptcparse($imageinfo['APP13']);
- if (is_array($iptc_parsed)) {
- foreach ($iptc_parsed as $iptc_key_raw => $iptc_values) {
- list($iptc_record, $iptc_tagkey) = explode('#', $iptc_key_raw);
- $iptc_tagkey = intval(ltrim($iptc_tagkey, '0'));
- foreach ($iptc_values as $key => $value) {
- @$ThisFileInfo['iptc'][$this->IPTCrecordName($iptc_record)][$this->IPTCrecordTagName($iptc_record, $iptc_tagkey)][] = $value;
- }
- }
- }
-//echo '<pre>'.htmlentities(print_r($iptc_parsed, true)).'</pre>';
- }
-
- switch ($type) {
- case 2: // JPEG
- $ThisFileInfo['video']['resolution_x'] = $width;
- $ThisFileInfo['video']['resolution_y'] = $height;
-
- if (version_compare(phpversion(), '4.2.0', '>=')) {
-
- if (function_exists('exif_read_data')) {
-
- ob_start();
- $ThisFileInfo['jpg']['exif'] = exif_read_data($ThisFileInfo['filenamepath'], '', true, false);
- $errors = ob_get_contents();
- if ($errors) {
- $ThisFileInfo['warning'][] = strip_tags($errors);
- unset($ThisFileInfo['jpg']['exif']);
- }
- @ob_end_clean();
-
- } else {
-
- $ThisFileInfo['warning'][] = 'EXIF parsing only available when '.(GETID3_OS_ISWINDOWS ? 'php_exif.dll enabled' : 'compiled with --enable-exif');
-
- }
-
- } else {
-
- $ThisFileInfo['warning'][] = 'EXIF parsing only available in PHP v4.2.0 and higher compiled with --enable-exif (or php_exif.dll enabled for Windows). You are using PHP v'.phpversion();
-
- }
-
- return true;
- break;
-
- default:
- break;
- }
-
- unset($ThisFileInfo['fileformat']);
- return false;
- }
-
-
- function IPTCrecordName($iptc_record) {
- // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/IPTC.html
- static $IPTCrecordName = array();
- if (empty($IPTCrecordName)) {
- $IPTCrecordName = array(
- 1 => 'IPTCEnvelope',
- 2 => 'IPTCApplication',
- 3 => 'IPTCNewsPhoto',
- 7 => 'IPTCPreObjectData',
- 8 => 'IPTCObjectData',
- 9 => 'IPTCPostObjectData',
- );
- }
- return (isset($IPTCrecordName[$iptc_record]) ? $IPTCrecordName[$iptc_record] : '');
- }
-
-
- function IPTCrecordTagName($iptc_record, $iptc_tagkey) {
- // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/IPTC.html
- static $IPTCrecordTagName = array();
- if (empty($IPTCrecordTagName)) {
- $IPTCrecordTagName = array(
- 1 => array( // IPTC EnvelopeRecord Tags
- 0 => 'EnvelopeRecordVersion',
- 5 => 'Destination',
- 20 => 'FileFormat',
- 22 => 'FileVersion',
- 30 => 'ServiceIdentifier',
- 40 => 'EnvelopeNumber',
- 50 => 'ProductID',
- 60 => 'EnvelopePriority',
- 70 => 'DateSent',
- 80 => 'TimeSent',
- 90 => 'CodedCharacterSet',
- 100 => 'UniqueObjectName',
- 120 => 'ARMIdentifier',
- 122 => 'ARMVersion',
- ),
- 2 => array( // IPTC ApplicationRecord Tags
- 0 => 'ApplicationRecordVersion',
- 3 => 'ObjectTypeReference',
- 4 => 'ObjectAttributeReference',
- 5 => 'ObjectName',
- 7 => 'EditStatus',
- 8 => 'EditorialUpdate',
- 10 => 'Urgency',
- 12 => 'SubjectReference',
- 15 => 'Category',
- 20 => 'SupplementalCategories',
- 22 => 'FixtureIdentifier',
- 25 => 'Keywords',
- 26 => 'ContentLocationCode',
- 27 => 'ContentLocationName',
- 30 => 'ReleaseDate',
- 35 => 'ReleaseTime',
- 37 => 'ExpirationDate',
- 38 => 'ExpirationTime',
- 40 => 'SpecialInstructions',
- 42 => 'ActionAdvised',
- 45 => 'ReferenceService',
- 47 => 'ReferenceDate',
- 50 => 'ReferenceNumber',
- 55 => 'DateCreated',
- 60 => 'TimeCreated',
- 62 => 'DigitalCreationDate',
- 63 => 'DigitalCreationTime',
- 65 => 'OriginatingProgram',
- 70 => 'ProgramVersion',
- 75 => 'ObjectCycle',
- 80 => 'By-line',
- 85 => 'By-lineTitle',
- 90 => 'City',
- 92 => 'Sub-location',
- 95 => 'Province-State',
- 100 => 'Country-PrimaryLocationCode',
- 101 => 'Country-PrimaryLocationName',
- 103 => 'OriginalTransmissionReference',
- 105 => 'Headline',
- 110 => 'Credit',
- 115 => 'Source',
- 116 => 'CopyrightNotice',
- 118 => 'Contact',
- 120 => 'Caption-Abstract',
- 121 => 'LocalCaption',
- 122 => 'Writer-Editor',
- 125 => 'RasterizedCaption',
- 130 => 'ImageType',
- 131 => 'ImageOrientation',
- 135 => 'LanguageIdentifier',
- 150 => 'AudioType',
- 151 => 'AudioSamplingRate',
- 152 => 'AudioSamplingResolution',
- 153 => 'AudioDuration',
- 154 => 'AudioOutcue',
- 184 => 'JobID',
- 185 => 'MasterDocumentID',
- 186 => 'ShortDocumentID',
- 187 => 'UniqueDocumentID',
- 188 => 'OwnerID',
- 200 => 'ObjectPreviewFileFormat',
- 201 => 'ObjectPreviewFileVersion',
- 202 => 'ObjectPreviewData',
- 221 => 'Prefs',
- 225 => 'ClassifyState',
- 228 => 'SimilarityIndex',
- 230 => 'DocumentNotes',
- 231 => 'DocumentHistory',
- 232 => 'ExifCameraInfo',
- ),
- 3 => array( // IPTC NewsPhoto Tags
- 0 => 'NewsPhotoVersion',
- 10 => 'IPTCPictureNumber',
- 20 => 'IPTCImageWidth',
- 30 => 'IPTCImageHeight',
- 40 => 'IPTCPixelWidth',
- 50 => 'IPTCPixelHeight',
- 55 => 'SupplementalType',
- 60 => 'ColorRepresentation',
- 64 => 'InterchangeColorSpace',
- 65 => 'ColorSequence',
- 66 => 'ICC_Profile',
- 70 => 'ColorCalibrationMatrix',
- 80 => 'LookupTable',
- 84 => 'NumIndexEntries',
- 85 => 'ColorPalette',
- 86 => 'IPTCBitsPerSample',
- 90 => 'SampleStructure',
- 100 => 'ScanningDirection',
- 102 => 'IPTCImageRotation',
- 110 => 'DataCompressionMethod',
- 120 => 'QuantizationMethod',
- 125 => 'EndPoints',
- 130 => 'ExcursionTolerance',
- 135 => 'BitsPerComponent',
- 140 => 'MaximumDensityRange',
- 145 => 'GammaCompensatedValue',
- ),
- 7 => array( // IPTC PreObjectData Tags
- 10 => 'SizeMode',
- 20 => 'MaxSubfileSize',
- 90 => 'ObjectSizeAnnounced',
- 95 => 'MaximumObjectSize',
- ),
- 8 => array( // IPTC ObjectData Tags
- 10 => 'SubFile',
- ),
- 9 => array( // IPTC PostObjectData Tags
- 10 => 'ConfirmedObjectSize',
- ),
- );
-
- }
- return (isset($IPTCrecordTagName[$iptc_record][$iptc_tagkey]) ? $IPTCrecordTagName[$iptc_record][$iptc_tagkey] : $iptc_tagkey);
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.graphic.svg.php b/apps/media/getID3/getid3/module.graphic.svg.php
deleted file mode 100644
index e4471456ce9..00000000000
--- a/apps/media/getID3/getid3/module.graphic.svg.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.graphic.svg.php //
-// module for analyzing SVG Image files //
-// dependencies: NONE //
-// author: Bryce Harrington <bryceØbryceharrington*org> //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_svg
-{
-
-
- function getid3_svg(&$fd, &$ThisFileInfo) {
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
-
- // I'm making this up, please modify as appropriate
- $SVGheader = fread($fd, 32);
- $ThisFileInfo['svg']['magic'] = substr($SVGheader, 0, 4);
- if ($ThisFileInfo['svg']['magic'] == 'aBcD') {
-
- $ThisFileInfo['fileformat'] = 'svg';
- $ThisFileInfo['video']['dataformat'] = 'svg';
- $ThisFileInfo['video']['lossless'] = true;
- $ThisFileInfo['video']['bits_per_sample'] = 24;
- $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
-
- $ThisFileInfo['svg']['width'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
- $ThisFileInfo['svg']['height'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 4));
-
- $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['svg']['width'];
- $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['svg']['height'];
-
- return true;
- }
- $ThisFileInfo['error'][] = 'Did not find SVG magic bytes "aBcD" at '.$ThisFileInfo['avdataoffset'];
- unset($ThisFileInfo['fileformat']);
- return false;
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.misc.doc.php b/apps/media/getID3/getid3/module.misc.doc.php
deleted file mode 100644
index cb65abf2237..00000000000
--- a/apps/media/getID3/getid3/module.misc.doc.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.archive.doc.php //
-// module for analyzing MS Office (.doc, .xls, etc) files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_doc
-{
-
- function getid3_doc(&$fd, &$ThisFileInfo) {
-
- $ThisFileInfo['fileformat'] = 'doc';
-
- $ThisFileInfo['error'][] = 'MS Office (.doc, .xls, etc) parsing not enabled in this version of getID3()';
- return false;
-
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/module.misc.exe.php b/apps/media/getID3/getid3/module.misc.exe.php
deleted file mode 100644
index 8c6bfcf99fb..00000000000
--- a/apps/media/getID3/getid3/module.misc.exe.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.misc.exe.php //
-// module for analyzing EXE files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_exe
-{
-
- function getid3_exe(&$fd, &$ThisFileInfo) {
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $EXEheader = fread($fd, 28);
-
- if (substr($EXEheader, 0, 2) != 'MZ') {
- $ThisFileInfo['error'][] = 'Expecting "MZ" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($EXEheader, 0, 2).'" instead.';
- return false;
- }
-
- $ThisFileInfo['fileformat'] = 'exe';
- $ThisFileInfo['exe']['mz']['magic'] = 'MZ';
-
- $ThisFileInfo['exe']['mz']['raw']['last_page_size'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 2, 2));
- $ThisFileInfo['exe']['mz']['raw']['page_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 4, 2));
- $ThisFileInfo['exe']['mz']['raw']['relocation_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 6, 2));
- $ThisFileInfo['exe']['mz']['raw']['header_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 8, 2));
- $ThisFileInfo['exe']['mz']['raw']['min_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 10, 2));
- $ThisFileInfo['exe']['mz']['raw']['max_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 12, 2));
- $ThisFileInfo['exe']['mz']['raw']['initial_ss'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 14, 2));
- $ThisFileInfo['exe']['mz']['raw']['initial_sp'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 16, 2));
- $ThisFileInfo['exe']['mz']['raw']['checksum'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 18, 2));
- $ThisFileInfo['exe']['mz']['raw']['cs_ip'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 20, 4));
- $ThisFileInfo['exe']['mz']['raw']['relocation_table_offset'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 24, 2));
- $ThisFileInfo['exe']['mz']['raw']['overlay_number'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 26, 2));
-
- $ThisFileInfo['exe']['mz']['byte_size'] = (($ThisFileInfo['exe']['mz']['raw']['page_count'] - 1)) * 512 + $ThisFileInfo['exe']['mz']['raw']['last_page_size'];
- $ThisFileInfo['exe']['mz']['header_size'] = $ThisFileInfo['exe']['mz']['raw']['header_paragraphs'] * 16;
- $ThisFileInfo['exe']['mz']['memory_minimum'] = $ThisFileInfo['exe']['mz']['raw']['min_memory_paragraphs'] * 16;
- $ThisFileInfo['exe']['mz']['memory_recommended'] = $ThisFileInfo['exe']['mz']['raw']['max_memory_paragraphs'] * 16;
-
-$ThisFileInfo['error'][] = 'EXE parsing not enabled in this version of getID3()';
-return false;
-
- }
-
-}
-
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/write.metaflac.php b/apps/media/getID3/getid3/write.metaflac.php
deleted file mode 100644
index c9521c83862..00000000000
--- a/apps/media/getID3/getid3/write.metaflac.php
+++ /dev/null
@@ -1,167 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// write.metaflac.php //
-// module for writing metaflac tags //
-// dependencies: /helperapps/metaflac.exe //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_write_metaflac
-{
-
- var $filename;
- var $tag_data;
- var $warnings = array(); // any non-critical errors will be stored here
- var $errors = array(); // any critical errors will be stored here
-
- function getid3_write_metaflac() {
- return true;
- }
-
- function WriteMetaFLAC() {
-
- if (!ini_get('safe_mode')) {
-
- // Create file with new comments
- $tempcommentsfilename = tempnam('*', 'getID3');
- if ($fpcomments = @fopen($tempcommentsfilename, 'wb')) {
-
- foreach ($this->tag_data as $key => $value) {
- foreach ($value as $commentdata) {
- fwrite($fpcomments, $this->CleanmetaflacName($key).'='.$commentdata."\n");
- }
- }
- fclose($fpcomments);
-
- } else {
-
- $this->errors[] = 'failed to open temporary tags file "'.$tempcommentsfilename.'", tags not written';
- return false;
-
- }
-
- $oldignoreuserabort = ignore_user_abort(true);
- if (GETID3_OS_ISWINDOWS) {
-
- if (file_exists(GETID3_HELPERAPPSDIR.'metaflac.exe')) {
- //$commandline = '"'.GETID3_HELPERAPPSDIR.'metaflac.exe" --no-utf8-convert --remove-all-tags --import-tags-from="'.$tempcommentsfilename.'" "'.str_replace('/', '\\', $this->filename).'"';
- // metaflac works fine if you copy-paste the above commandline into a command prompt,
- // but refuses to work with `backtick` if there are "doublequotes" present around BOTH
- // the metaflac pathname and the target filename. For whatever reason...??
- // The solution is simply ensure that the metaflac pathname has no spaces,
- // and therefore does not need to be quoted
-
- // On top of that, if error messages are not always captured properly under Windows
- // To at least see if there was a problem, compare file modification timestamps before and after writing
- clearstatcache();
- $timestampbeforewriting = filemtime($this->filename);
-
- $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --no-utf8-convert --remove-all-tags --import-tags-from="'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
- $metaflacError = `$commandline`;
-
- if (empty($metaflacError)) {
- clearstatcache();
- if ($timestampbeforewriting == filemtime($this->filename)) {
- $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not written';
- }
- }
- } else {
- $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
- }
-
- } else {
-
- // It's simpler on *nix
- $commandline = 'metaflac --no-utf8-convert --remove-all-tags --import-tags-from='.$tempcommentsfilename.' "'.$this->filename.'" 2>&1';
- $metaflacError = `$commandline`;
-
- }
-
- // Remove temporary comments file
- unlink($tempcommentsfilename);
- ignore_user_abort($oldignoreuserabort);
-
- if (!empty($metaflacError)) {
-
- $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
- return false;
-
- }
-
- return true;
- }
-
- $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not written';
- return false;
- }
-
-
- function DeleteMetaFLAC() {
-
- if (!ini_get('safe_mode')) {
-
- $oldignoreuserabort = ignore_user_abort(true);
- if (GETID3_OS_ISWINDOWS) {
-
- if (file_exists(GETID3_HELPERAPPSDIR.'metaflac.exe')) {
- // To at least see if there was a problem, compare file modification timestamps before and after writing
- clearstatcache();
- $timestampbeforewriting = filemtime($this->filename);
-
- $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --remove-all-tags "'.$this->filename.'" 2>&1';
- $metaflacError = `$commandline`;
-
- if (empty($metaflacError)) {
- clearstatcache();
- if ($timestampbeforewriting == filemtime($this->filename)) {
- $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not deleted';
- }
- }
- } else {
- $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
- }
-
- } else {
-
- // It's simpler on *nix
- $commandline = 'metaflac --remove-all-tags "'.$this->filename.'" 2>&1';
- $metaflacError = `$commandline`;
-
- }
-
- ignore_user_abort($oldignoreuserabort);
-
- if (!empty($metaflacError)) {
- $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
- return false;
- }
- return true;
- }
- $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not deleted';
- return false;
- }
-
-
- function CleanmetaflacName($originalcommentname) {
- // A case-insensitive field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
- // ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through
- // 0x7A inclusive (a-z).
-
- // replace invalid chars with a space, return uppercase text
- // Thanks Chris Bolt <chris-getid3Øbolt*cx> for improving this function
- // note: ereg_replace() replaces nulls with empty string (not space)
- return strtoupper(ereg_replace('[^ -<>-}]', ' ', str_replace("\x00", ' ', $originalcommentname)));
-
- }
-
-}
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/write.real.php b/apps/media/getID3/getid3/write.real.php
deleted file mode 100644
index 14e775812fc..00000000000
--- a/apps/media/getID3/getid3/write.real.php
+++ /dev/null
@@ -1,295 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// write.real.php //
-// module for writing RealAudio/RealVideo tags //
-// dependencies: module.tag.real.php //
-// ///
-/////////////////////////////////////////////////////////////////
-
-class getid3_write_real
-{
- var $filename;
- var $tag_data = array();
- var $warnings = array(); // any non-critical errors will be stored here
- var $errors = array(); // any critical errors will be stored here
- var $paddedlength = 512; // minimum length of CONT tag in bytes
-
- function getid3_write_real() {
- return true;
- }
-
- function WriteReal() {
- // File MUST be writeable - CHMOD(646) at least
- if (is_writeable($this->filename)) {
- if ($fp_source = @fopen($this->filename, 'r+b')) {
-
- // Initialize getID3 engine
- $getID3 = new getID3;
- $OldThisFileInfo = $getID3->analyze($this->filename);
- if (empty($OldThisFileInfo['real']['chunks']) && !empty($OldThisFileInfo['real']['old_ra_header'])) {
- $this->errors[] = 'Cannot write Real tags on old-style file format';
- fclose($fp_source);
- return false;
- }
-
- if (empty($OldThisFileInfo['real']['chunks'])) {
- $this->errors[] = 'Cannot write Real tags because cannot find DATA chunk in file';
- fclose($fp_source);
- return false;
- }
- foreach ($OldThisFileInfo['real']['chunks'] as $chunknumber => $chunkarray) {
- $oldChunkInfo[$chunkarray['name']] = $chunkarray;
- }
- if (!empty($oldChunkInfo['CONT']['length'])) {
- $this->paddedlength = max($oldChunkInfo['CONT']['length'], $this->paddedlength);
- }
-
- $new_CONT_tag_data = $this->GenerateCONTchunk();
- $new_PROP_tag_data = $this->GeneratePROPchunk($OldThisFileInfo['real']['chunks'], $new_CONT_tag_data);
- $new__RMF_tag_data = $this->GenerateRMFchunk($OldThisFileInfo['real']['chunks']);
-
- if (@$oldChunkInfo['.RMF']['length'] == strlen($new__RMF_tag_data)) {
- fseek($fp_source, $oldChunkInfo['.RMF']['offset'], SEEK_SET);
- fwrite($fp_source, $new__RMF_tag_data);
- } else {
- $this->errors[] = 'new .RMF tag ('.strlen($new__RMF_tag_data).' bytes) different length than old .RMF tag ('.$oldChunkInfo['.RMF']['length'].' bytes)';
- fclose($fp_source);
- return false;
- }
-
- if (@$oldChunkInfo['PROP']['length'] == strlen($new_PROP_tag_data)) {
- fseek($fp_source, $oldChunkInfo['PROP']['offset'], SEEK_SET);
- fwrite($fp_source, $new_PROP_tag_data);
- } else {
- $this->errors[] = 'new PROP tag ('.strlen($new_PROP_tag_data).' bytes) different length than old PROP tag ('.$oldChunkInfo['PROP']['length'].' bytes)';
- fclose($fp_source);
- return false;
- }
-
- if (@$oldChunkInfo['CONT']['length'] == strlen($new_CONT_tag_data)) {
-
- // new data length is same as old data length - just overwrite
- fseek($fp_source, $oldChunkInfo['CONT']['offset'], SEEK_SET);
- fwrite($fp_source, $new_CONT_tag_data);
- fclose($fp_source);
- return true;
-
- } else {
-
- if (empty($oldChunkInfo['CONT'])) {
- // no existing CONT chunk
- $BeforeOffset = $oldChunkInfo['DATA']['offset'];
- $AfterOffset = $oldChunkInfo['DATA']['offset'];
- } else {
- // new data is longer than old data
- $BeforeOffset = $oldChunkInfo['CONT']['offset'];
- $AfterOffset = $oldChunkInfo['CONT']['offset'] + $oldChunkInfo['CONT']['length'];
- }
- if ($tempfilename = tempnam('*', 'getID3')) {
- ob_start();
- if ($fp_temp = fopen($tempfilename, 'wb')) {
-
- rewind($fp_source);
- fwrite($fp_temp, fread($fp_source, $BeforeOffset));
- fwrite($fp_temp, $new_CONT_tag_data);
- fseek($fp_source, $AfterOffset, SEEK_SET);
- while ($buffer = fread($fp_source, GETID3_FREAD_BUFFER_SIZE)) {
- fwrite($fp_temp, $buffer, strlen($buffer));
- }
- fclose($fp_temp);
-
- if (copy($tempfilename, $this->filename)) {
- unlink($tempfilename);
- fclose($fp_source);
- return true;
- }
- unlink($tempfilename);
- $this->errors[] = 'FAILED: copy('.$tempfilename.', '.$this->filename.') - '.strip_tags(ob_get_contents());
-
- } else {
-
- $this->errors[] = 'Could not open '.$tempfilename.' mode "wb" - '.strip_tags(ob_get_contents());
-
- }
- @ob_end_clean();
- }
- fclose($fp_source);
- return false;
-
- }
-
-
- } else {
- $this->errors[] = 'Could not open '.$this->filename.' mode "r+b"';
- return false;
- }
- }
- $this->errors[] = 'File is not writeable: '.$this->filename;
- return false;
- }
-
- function GenerateRMFchunk(&$chunks) {
- $oldCONTexists = false;
- foreach ($chunks as $key => $chunk) {
- $chunkNameKeys[$chunk['name']] = $key;
- if ($chunk['name'] == 'CONT') {
- $oldCONTexists = true;
- }
- }
- $newHeadersCount = $chunks[$chunkNameKeys['.RMF']]['headers_count'] + ($oldCONTexists ? 0 : 1);
-
- $RMFchunk = "\x00\x00"; // object version
- $RMFchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['.RMF']]['file_version'], 4);
- $RMFchunk .= getid3_lib::BigEndian2String($newHeadersCount, 4);
-
- $RMFchunk = '.RMF'.getid3_lib::BigEndian2String(strlen($RMFchunk) + 8, 4).$RMFchunk; // .RMF chunk identifier + chunk length
- return $RMFchunk;
- }
-
- function GeneratePROPchunk(&$chunks, &$new_CONT_tag_data) {
- $old_CONT_length = 0;
- $old_DATA_offset = 0;
- $old_INDX_offset = 0;
- foreach ($chunks as $key => $chunk) {
- $chunkNameKeys[$chunk['name']] = $key;
- if ($chunk['name'] == 'CONT') {
- $old_CONT_length = $chunk['length'];
- } elseif ($chunk['name'] == 'DATA') {
- if (!$old_DATA_offset) {
- $old_DATA_offset = $chunk['offset'];
- }
- } elseif ($chunk['name'] == 'INDX') {
- if (!$old_INDX_offset) {
- $old_INDX_offset = $chunk['offset'];
- }
- }
- }
- $CONTdelta = strlen($new_CONT_tag_data) - $old_CONT_length;
-
- $PROPchunk = "\x00\x00"; // object version
- $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['max_bit_rate'], 4);
- $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['avg_bit_rate'], 4);
- $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['max_packet_size'], 4);
- $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['avg_packet_size'], 4);
- $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['num_packets'], 4);
- $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['duration'], 4);
- $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['preroll'], 4);
- $PROPchunk .= getid3_lib::BigEndian2String(max(0, $old_INDX_offset + $CONTdelta), 4);
- $PROPchunk .= getid3_lib::BigEndian2String(max(0, $old_DATA_offset + $CONTdelta), 4);
- $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['num_streams'], 2);
- $PROPchunk .= getid3_lib::BigEndian2String($chunks[$chunkNameKeys['PROP']]['flags_raw'], 2);
-
- $PROPchunk = 'PROP'.getid3_lib::BigEndian2String(strlen($PROPchunk) + 8, 4).$PROPchunk; // PROP chunk identifier + chunk length
- return $PROPchunk;
- }
-
- function GenerateCONTchunk() {
- foreach ($this->tag_data as $key => $value) {
- // limit each value to 0xFFFF bytes
- $this->tag_data[$key] = substr($value, 0, 65535);
- }
-
- $CONTchunk = "\x00\x00"; // object version
-
- $CONTchunk .= getid3_lib::BigEndian2String(strlen(@$this->tag_data['title']), 2);
- $CONTchunk .= @$this->tag_data['title'];
-
- $CONTchunk .= getid3_lib::BigEndian2String(strlen(@$this->tag_data['artist']), 2);
- $CONTchunk .= @$this->tag_data['artist'];
-
- $CONTchunk .= getid3_lib::BigEndian2String(strlen(@$this->tag_data['copyright']), 2);
- $CONTchunk .= @$this->tag_data['copyright'];
-
- $CONTchunk .= getid3_lib::BigEndian2String(strlen(@$this->tag_data['comment']), 2);
- $CONTchunk .= @$this->tag_data['comment'];
-
- if ($this->paddedlength > (strlen($CONTchunk) + 8)) {
- $CONTchunk .= str_repeat("\x00", $this->paddedlength - strlen($CONTchunk) - 8);
- }
-
- $CONTchunk = 'CONT'.getid3_lib::BigEndian2String(strlen($CONTchunk) + 8, 4).$CONTchunk; // CONT chunk identifier + chunk length
-
- return $CONTchunk;
- }
-
- function RemoveReal() {
- // File MUST be writeable - CHMOD(646) at least
- if (is_writeable($this->filename)) {
- if ($fp_source = @fopen($this->filename, 'r+b')) {
-
- // Initialize getID3 engine
- $getID3 = new getID3;
- $OldThisFileInfo = $getID3->analyze($this->filename);
- if (empty($OldThisFileInfo['real']['chunks']) && !empty($OldThisFileInfo['real']['old_ra_header'])) {
- $this->errors[] = 'Cannot remove Real tags from old-style file format';
- fclose($fp_source);
- return false;
- }
-
- if (empty($OldThisFileInfo['real']['chunks'])) {
- $this->errors[] = 'Cannot remove Real tags because cannot find DATA chunk in file';
- fclose($fp_source);
- return false;
- }
- foreach ($OldThisFileInfo['real']['chunks'] as $chunknumber => $chunkarray) {
- $oldChunkInfo[$chunkarray['name']] = $chunkarray;
- }
-
- if (empty($oldChunkInfo['CONT'])) {
- // no existing CONT chunk
- fclose($fp_source);
- return true;
- }
-
- $BeforeOffset = $oldChunkInfo['CONT']['offset'];
- $AfterOffset = $oldChunkInfo['CONT']['offset'] + $oldChunkInfo['CONT']['length'];
- if ($tempfilename = tempnam('*', 'getID3')) {
- ob_start();
- if ($fp_temp = fopen($tempfilename, 'wb')) {
-
- rewind($fp_source);
- fwrite($fp_temp, fread($fp_source, $BeforeOffset));
- fseek($fp_source, $AfterOffset, SEEK_SET);
- while ($buffer = fread($fp_source, GETID3_FREAD_BUFFER_SIZE)) {
- fwrite($fp_temp, $buffer, strlen($buffer));
- }
- fclose($fp_temp);
-
- if (copy($tempfilename, $this->filename)) {
- unlink($tempfilename);
- fclose($fp_source);
- return true;
- }
- unlink($tempfilename);
- $this->errors[] = 'FAILED: copy('.$tempfilename.', '.$this->filename.') - '.strip_tags(ob_get_contents());
-
- } else {
-
- $this->errors[] = 'Could not open '.$tempfilename.' mode "wb" - '.strip_tags(ob_get_contents());
-
- }
- @ob_end_clean();
- }
- fclose($fp_source);
- return false;
-
-
- } else {
- $this->errors[] = 'Could not open '.$this->filename.' mode "r+b"';
- return false;
- }
- }
- $this->errors[] = 'File is not writeable: '.$this->filename;
- return false;
- }
-
-}
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/getid3/write.vorbiscomment.php b/apps/media/getID3/getid3/write.vorbiscomment.php
deleted file mode 100644
index f93b1a1cda8..00000000000
--- a/apps/media/getID3/getid3/write.vorbiscomment.php
+++ /dev/null
@@ -1,124 +0,0 @@
-<?php
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// write.vorbiscomment.php //
-// module for writing VorbisComment tags //
-// dependencies: /helperapps/vorbiscomment.exe //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_write_vorbiscomment
-{
-
- var $filename;
- var $tag_data;
- var $warnings = array(); // any non-critical errors will be stored here
- var $errors = array(); // any critical errors will be stored here
-
- function getid3_write_vorbiscomment() {
- return true;
- }
-
- function WriteVorbisComment() {
-
- if (!ini_get('safe_mode')) {
-
- // Create file with new comments
- $tempcommentsfilename = tempnam('*', 'getID3');
- if ($fpcomments = @fopen($tempcommentsfilename, 'wb')) {
-
- foreach ($this->tag_data as $key => $value) {
- foreach ($value as $commentdata) {
- fwrite($fpcomments, $this->CleanVorbisCommentName($key).'='.$commentdata."\n");
- }
- }
- fclose($fpcomments);
-
- } else {
-
- $this->errors[] = 'failed to open temporary tags file "'.$tempcommentsfilename.'", tags not written';
- return false;
-
- }
-
- $oldignoreuserabort = ignore_user_abort(true);
- if (GETID3_OS_ISWINDOWS) {
-
- if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
- //$commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w --raw -c "'.$tempcommentsfilename.'" "'.str_replace('/', '\\', $this->filename).'"';
- // vorbiscomment works fine if you copy-paste the above commandline into a command prompt,
- // but refuses to work with `backtick` if there are "doublequotes" present around BOTH
- // the metaflac pathname and the target filename. For whatever reason...??
- // The solution is simply ensure that the metaflac pathname has no spaces,
- // and therefore does not need to be quoted
-
- // On top of that, if error messages are not always captured properly under Windows
- // To at least see if there was a problem, compare file modification timestamps before and after writing
- clearstatcache();
- $timestampbeforewriting = filemtime($this->filename);
-
- $commandline = GETID3_HELPERAPPSDIR.'vorbiscomment.exe -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
- $VorbiscommentError = `$commandline`;
-
- if (empty($VorbiscommentError)) {
- clearstatcache();
- if ($timestampbeforewriting == filemtime($this->filename)) {
- $VorbiscommentError = 'File modification timestamp has not changed - it looks like the tags were not written';
- }
- }
- } else {
- $VorbiscommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
- }
-
- } else {
-
- $commandline = 'vorbiscomment -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
- $VorbiscommentError = `$commandline`;
-
- }
-
- // Remove temporary comments file
- unlink($tempcommentsfilename);
- ignore_user_abort($oldignoreuserabort);
-
- if (!empty($VorbiscommentError)) {
-
- $this->errors[] = 'system call to vorbiscomment failed with message: '."\n\n".$VorbiscommentError;
- return false;
-
- }
-
- return true;
- }
-
- $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call vorbiscomment, tags not written';
- return false;
- }
-
- function DeleteVorbisComment() {
- $this->tag_data = array(array());
- return $this->WriteVorbisComment();
- }
-
- function CleanVorbisCommentName($originalcommentname) {
- // A case-insensitive field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
- // ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through
- // 0x7A inclusive (a-z).
-
- // replace invalid chars with a space, return uppercase text
- // Thanks Chris Bolt <chris-getid3Øbolt*cx> for improving this function
- // note: ereg_replace() replaces nulls with empty string (not space)
- return strtoupper(ereg_replace('[^ -<>-}]', ' ', str_replace("\x00", ' ', $originalcommentname)));
-
- }
-
-}
-
-?> \ No newline at end of file
diff --git a/apps/media/getID3/helperapps/readme.txt b/apps/media/getID3/helperapps/readme.txt
deleted file mode 100644
index c210a598543..00000000000
--- a/apps/media/getID3/helperapps/readme.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /helperapps/readme.txt - part of getID3() //
-// List of binary files required under Windows for some //
-// features and/or file formats //
-// See /readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-This directory should contain binaries of various helper applications
-that getID3() depends on to handle some file formats under Windows.
-
-The location of this directory is configurable in /getid3/getid3.php
-as GETID3_HELPERAPPSDIR
-
-If this directory is empty, or you are missing any files, please
-download the latest version of the "getID3()-WindowsSupport" package
-from the usual download location (http://getid3.sourceforge.net)
-
-
-
-Included files:
-=====================================================
-
-Taken from http://www.cygwin.com/
-* cygwin1.dll
-
-Taken from http://unxutils.sourceforge.net/
-* head.exe
-* md5sum.exe
-* tail.exe
-
-Taken from http://ebible.org/mpj/software.htm
-* sha1sum.exe
-
-Taken from http://www.vorbis.com/download.psp
-* vorbiscomment.exe
-
-Taken from http://flac.sourceforge.net/download.html
-* metaflac.exe
-
-Taken from http://www.etree.org/shncom.html
-* shorten.exe
-
-
-/////////////////////////////////////////////////////////////////
-
-Changelog:
-
-2003.12.29:
- * Initial release \ No newline at end of file
diff --git a/apps/media/getID3/license.commercial.txt b/apps/media/getID3/license.commercial.txt
deleted file mode 100644
index 416e5a14694..00000000000
--- a/apps/media/getID3/license.commercial.txt
+++ /dev/null
@@ -1,27 +0,0 @@
- getID3() Commercial License
- ===========================
-
-getID3() is licensed under the "GNU Public License" (GPL) and/or the
-"getID3() Commercial License" (gCL). This document describes the gCL.
-
----------------------------------------------------------------------
-
-The license is non-exclusively granted to a single person or company,
-per payment of the license fee, for the lifetime of that person or
-company. The license is non-transferrable.
-
-The gCL grants the licensee the right to use getID3() in commercial
-closed-source projects. Modifications may be made to getID3() with no
-obligation to release the modified source code. getID3() (or pieces
-thereof) may be included in any number of projects authored (in whole
-or in part) by the licensee.
-
-The licensee may use any version of getID3(), past, present or future,
-as is most convenient. This license does not entitle the licensee to
-receive any technical support, updates or bugfixes, except as such are
-made publicly available to all getID3() users.
-
-The licensee may not sub-license getID3() itself, meaning that any
-commercially released product containing all or parts of getID3() must
-have added functionality beyond what is available in getID3();
-getID3() itself may not be re-licensed by the licensee.
diff --git a/apps/media/getID3/readme.txt b/apps/media/getID3/readme.txt
deleted file mode 100644
index 1a798d1dbe2..00000000000
--- a/apps/media/getID3/readme.txt
+++ /dev/null
@@ -1,549 +0,0 @@
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// changelog.txt - part of getID3() //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
- This code is released under the GNU GPL:
- http://www.gnu.org/copyleft/gpl.html
-
- +---------------------------------------------+
- | If you do use this code somewhere, send me |
- | an email and tell me how/where you used it. |
- | |
- | If you want to donate, there is a link on |
- | http://www.getid3.org for PayPal donations. |
- +---------------------------------------------+
-
-
-
-Quick Start
-===========================================================================
-
-Q: How can I check that getID3() works on my server/files?
-A: Unzip getID3() to a directory, then access /demos/demo.browse.php
-
-
-
-Sourceforge Notification
-===========================================================================
-
-It's highly recommended that you sign up for notification from
-Sourceforge for when new versions are released. Please visit:
-http://sourceforge.net/project/showfiles.php?group_id=55859
-and click the little "monitor package" icon/link. If you're
-previously signed up for the mailing list, be aware that it has
-been discontinued, only the automated Sourceforge notification
-will be used from now on.
-
-
-
-What does getID3() do?
-===========================================================================
-
-Reads & parses (to varying degrees):
- ¤ tags:
- * APE (v1 and v2)
- * ID3v1 (& ID3v1.1)
- * ID3v2 (v2.4, v2.3, v2.2)
- * Lyrics3 (v1 & v2)
-
- ¤ audio-lossy:
- * MP3/MP2/MP1
- * MPC / Musepack
- * Ogg (Vorbis, OggFLAC, Speex)
- * RealAudio
- * Speex
- * VQF
-
- ¤ audio-lossless:
- * AIFF
- * AU
- * Bonk
- * CD-audio (*.cda)
- * FLAC
- * LA (Lossless Audio)
- * LPAC
- * MIDI
- * Monkey's Audio
- * OptimFROG
- * RKAU
- * VOC
- * WAV (RIFF)
- * WavPack
-
- ¤ audio-video:
- * ASF: ASF, Windows Media Audio (WMA), Windows Media Video (WMV)
- * AVI (RIFF)
- * Flash
- * MPEG-1 / MPEG-2
- * NSV (Nullsoft Streaming Video)
- * Quicktime
- * RealVideo
-
- ¤ still image:
- * BMP
- * GIF
- * JPEG
- * PNG
-
- ¤ data:
- * ISO-9660 CD-ROM image (directory structure)
- * SZIP (limited support)
- * ZIP (directory structure)
-
-
-Writes:
- * ID3v1 (& ID3v1.1)
- * ID3v2 (v2.3 & v2.4)
- * VorbisComment on OggVorbis
- * VorbisComment on FLAC (not OggFLAC)
- * APE v2
- * Lyrics3 (delete only)
-
-
-
-Requirements
-===========================================================================
-
-* PHP 4.2.0 (or higher) for getID3() 1.7.8 (and up).
-* PHP 5.0.0 (or higher) for getID3() 2.0.0 (and up).
-* at least 4MB memory for PHP. 8MB is highly recommended.
- 12MB is required with all modules loaded.
-
-
-
-Usage
-===========================================================================
-
-See /demos/demo.basic.php for a very basic use of getID3() with no
-fancy output, just scanning one file.
-
-See structure.txt for the returned data structure.
-
-*> For an example of a complete directory-browsing, <*
-*> file-scanning implementation of getID3(), please run <*
-*> /demos/demo.browse.php <*
-
-See /demos/demo.mysql.php for a sample recursive scanning code that
-scans every file in a given directory, and all sub-directories, stores
-the results in a database and allows various analysis / maintenance
-operations
-
-To analyze remote files over HTTP or FTP you need to copy the file
-locally first before running getID3(). Your code would look something
-like this:
-
-// Copy remote file locally to scan with getID3()
-$remotefilename = 'http://www.example.com/filename.mp3';
-if ($fp_remote = fopen($remotefilename, 'rb')) {
- $localtempfilename = tempnam('/tmp', 'getID3');
- if ($fp_local = fopen($localtempfilename, 'wb')) {
- while ($buffer = fread($fp_remote, 8192)) {
- fwrite($fp_local, $buffer);
- }
- fclose($fp_local);
-
- // Initialize getID3 engine
- $getID3 = new getID3;
-
- $ThisFileInfo = $getID3->analyze($filename);
-
- // Delete temporary file
- unlink($localtempfilename);
- }
- fclose($fp_remote);
-}
-
-
-See /demos/demo.write.php for how to write tags.
-
-
-
-What does the returned data structure look like?
-===========================================================================
-
-See structure.txt
-
-It is recommended that you look at the output of
-/demos/demo.browse.php scanning the file(s) you're interested in to
-confirm what data is actually returned for any particular filetype in
-general, and your files in particular, as the actual data returned
-may vary considerably depending on what information is available in
-the file itself.
-
-
-
-Notes
-===========================================================================
-
-getID3() 1.7:
-If the format parser encounters a critical problem, it will return
-something in $fileinfo['error'], describing the encountered error. If
-a less critical error or notice is generated it will appear in
-$fileinfo['warning']. Both keys may contain more than one warning or
-error. If something is returned in ['error'] then the file was not
-correctly parsed and returned data may or may not be correct and/or
-complete. If something is returned in ['warning'] (and not ['error'])
-then the data that is returned is OK - usually getID3() is reporting
-errors in the file that have been worked around due to known bugs in
-other programs. Some warnings may indicate that the data that is
-returned is OK but that some data could not be extracted due to
-errors in the file.
-
-getID3() 2.0:
-See above except errors are thrown (so you will only get one error).
-
-
-
-Disclaimer
-===========================================================================
-
-getID3() has been tested on many systems, on many types of files,
-under many operating systems, and is generally believe to be stable
-and safe. That being said, there is still the chance there is an
-undiscovered and/or unfixed bug that may potentially corrupt your
-file, especially within the writing functions. By using getID3() you
-agree that it's not my fault if any of your files are corrupted.
-In fact, I'm not liable for anything :)
-
-
-
-License
-===========================================================================
-
-GNU General Public License - see license.txt
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to:
-Free Software Foundation, Inc.
-59 Temple Place - Suite 330
-Boston, MA 02111-1307, USA.
-
-FAQ:
-Q: Can I use getID3() in my program? Do I need a commercial license?
-A: You're generally free to use getID3 however you see fit. The only
- case in which you would require a commercial license is if you're
- selling your closed-source program that integrates getID3. If you
- sell your program including a copy of getID3, that's fine as long
- as you include a copy of the sourcecode when you sell it. Or you
- can distribute your code without getID3 and say "download it from
- getid3.sourceforge.net"
-
-
-
-Future Plans
-===========================================================================
-
-* Writing support for Real
-* Better support for MP4 container format
-* Support for Matroska (www.matroska.org)
- http://corecodec.com/modules.php?op=modload&name=PNphpBB2&file=viewtopic&t=227
-* Scan for appended ID3v2 tag at end of file per ID3v2.4 specs (Section 5.0)
-* Support for JPEG-2000 (http://www.morgan-multimedia.com/jpeg2000_overview.htm)
-* Support for MOD (mod/stm/s3m/it/xm/mtm/ult/669)
-* Support for ACE (thanks Vince)
-* Support for Ogg other than Vorbis, Speex and OggFlac (ie. Ogg+Xvid)
-* Ability to create Xing/LAME VBR header for VBR MP3s that are missing VBR header
-* Ability to "clean" ID3v2 padding (replace invalid padding with valid padding)
-* Warn if MP3s change version mid-stream (in full-scan mode)
-* check for corrupt/broken mid-file MP3 streams in histogram scan
-* Support for lossless-compression formats
- (http://www.firstpr.com.au/audiocomp/lossless/#Links)
- (http://compression.ca/act-sound.html)
- (http://web.inter.nl.net/users/hvdh/lossless/lossless.htm)
-* Support for RIFF-INFO chunks
- * http://lotto.st-andrews.ac.uk/~njh/tag_interchange.html
- (thanks Nick Humfrey <njhØsurgeradio*co*uk>)
- * http://abcavi.narod.ru/sof/abcavi/infotags.htm
- (thanks Kibi)
-* Better support for Bink video
-* http://www.hr/josip/DSP/AudioFile2.html
-* http://www.pcisys.net/~melanson/codecs/
-* Detect mp3PRO
-* Support for PSD
-* Support for JPC
-* Support for JP2
-* Support for JPX
-* Support for JB2
-* Support for IFF
-* Support for ICO
-* Support for ANI
-* Support for EXE (comments, author, etc) (thanks p*quaedackersØplanet*nl)
-* Support for DVD-IFO (region, subtitles, aspect ratio, etc)
- (thanks p*quaedackersØplanet*nl)
-* More complete support for SWF - parsing encapsulated MP3 and/or JPEG content
- (thanks n8n8Øyahoo*com)
-* Support for a2b
-* Optional scan-through-frames for AVI verification
- (thanks rockcohenØmassive-interactive*nl)
-* Support for TTF (thanks infoØbutterflyx*com)
-* Support for DSS (http://www.getid3.org/phpBB2/viewtopic.php?t=171)
-* Support for SMAF (http://smaf-yamaha.com/what/demo.html)
- http://www.getid3.org/phpBB2/viewtopic.php?t=182
-* Support for AMR (http://www.getid3.org/phpBB2/viewtopic.php?t=195)
-* Support for 3gpp (http://www.getid3.org/phpBB2/viewtopic.php?t=195)
-* Support for ID4 (http://www.wackysoft.cjb.net grizlyY2KØhotmail*com)
-* Parse XML data returned in Ogg comments
-* Parse XML data from Quicktime SMIL metafiles (klausrathØmac*com)
-* ID3v2 genre string creator function
-* More complete parsing of JPG
-* Support for all old-style ASF packets
-* ASF/WMA/WMV tag writing
-* Parse declared T??? ID3v2 text information frames, where appropriate
- (thanks Christian Fritz for the idea)
-* Recognize encoder:
- http://www.guerillasoft.com/EncSpot2/index.html
- http://ff123.net/identify.html
- http://www.hydrogenaudio.org/?act=ST&f=16&t=9414
- http://www.hydrogenaudio.org/?showtopic=11785
-* Support for other OS/2 bitmap structures: Bitmap Array('BA'),
- Color Icon('CI'), Color Pointer('CP'), Icon('IC'), Pointer ('PT')
- http://netghost.narod.ru/gff/graphics/summary/os2bmp.htm
-* Support for WavPack RAW mode
-* ASF/WMA/WMV data packet parsing
-* ID3v2FrameFlagsLookupTagAlter()
-* ID3v2FrameFlagsLookupFileAlter()
-* obey ID3v2 tag alter/preserve/discard rules
-* http://www.geocities.com/SiliconValley/Sector/9654/Softdoc/Illyrium/Aolyr.htm
-* proper checking for LINK/LNK frame validity in ID3v2 writing
-* proper checking for ASPI-TLEN frame validity in ID3v2 writing
-* proper checking for COMR frame validity in ID3v2 writing
-* http://www.geocities.co.jp/SiliconValley-Oakland/3664/index.html
-* decode GEOB ID3v2 structure as encoded by RealJukebox,
- decode NCON ID3v2 structure as encoded by MusicMatch
- (probably won't happen - the formats are proprietary)
-
-
-
-Known Bugs/Issues in getID3() that may be fixed eventually
-===========================================================================
-
-* Cannot determine bitrate for MPEG video with VBR video data
- (need documentation)
-* Interlace/progressive cannot be determined for MPEG video
- (need documentation)
-* MIDI playtime is sometimes inaccurate
-* AAC-RAW mode files cannot be identified
-* WavPack-RAW mode files cannot be identified
-* mp4 files report lots of "Unknown QuickTime atom type"
- (need documentation)
-* Encrypted ASF/WMA/WMV files warn about "unhandled GUID
- ASF_Content_Encryption_Object"
-* Bitrate split between audio and video cannot be calculated for
- NSV, only the total bitrate. (need documentation)
-* All Ogg formats (Vorbis, OggFLAC, Speex) are affected by the
- problem of large VorbisComments spanning multiple Ogg pages, but
- but only OggVorbis files can be processed with vorbiscomment.
-* The version of "head" supplied with Mac OS 10.2.8 (maybe other
- versions too) does only understands a single option (-n) and
- therefore fails. getID3 ignores this and returns wrong md5_data.
-
-
-
-Known Bugs/Issues in getID3() that cannot be fixed
---------------------------------------------------
-
-* Files larger than 2GB cannot always be parsed fully by getID3()
- due to limitations in the PHP filesystem functions.
- NOTE: Since v1.7.8b3 there is partial support for larger-than-
- 2GB files, most of which will parse OK, as long as no critical
- data is located beyond the 2GB offset.
- Known will-work:
- * ZIP (format doesn't support files >2GB)
- * FLAC (current encoders don't support files >2GB)
- Known will-not-work:
- * ID3v1 tags (always located at end-of-file)
- * Lyrics3 tags (always located at end-of-file)
- * APE tags (always located at end-of-file)
- Maybe-will-work:
- * Quicktime (will work if needed metadata is before 2GB offset,
- that is if the file has been hinted/optimized for streaming)
- * RIFF.WAV (should work fine, but gives warnings about not being
- able to parse all chunks)
- * RIFF.AVI (playtime will probably be wrong, is only based on
- "movi" chunk that fits in the first 2GB, should issue error
- to show that playtime is incorrect. Other data should be mostly
- correct, assuming that data is constant throughout the file)
-
-
-
-Known Bugs/Issues in other programs
------------------------------------
-
-* Winamp (up to v2.80 at least) does not support ID3v2.4 tags,
- only ID3v2.3
- see: http://forums.winamp.com/showthread.php?postid=387524
-* Some versions of Helium2 (www.helium2.com) do not write
- ID3v2.4-compliant Frame Sizes, even though the tag is marked
- as ID3v2.4) (detected by getID3())
-* MP3ext V3.3.17 places a non-compliant padding string at the end
- of the ID3v2 header. This is supposedly fixed in v3.4b21 but
- only if you manually add a registry key. This fix is not yet
- confirmed. (detected by getID3())
-* CDex v1.40 (fixed by v1.50b7) writes non-compliant Ogg comment
- strings, supposed to be in the format "NAME=value" but actually
- written just "value" (detected by getID3())
-* Oggenc 0.9-rc3 flags the encoded file as ABR whether it's
- actually ABR or VBR.
-* iTunes (versions "X v2.0.3", "v3.0.1" are known-guilty, probably
- other versions are too) writes ID3v2.3 comment tags using a
- frame name 'COM ' which is not valid for ID3v2.3+ (it's an
- ID3v2.2-style frame name) (detected by getID3())
-* MP2enc does not encode mono CBR MP2 files properly (half speed
- sound and double playtime)
-* MP2enc does not encode mono VBR MP2 files properly (actually
- encoded as stereo)
-* tooLAME does not encode mono VBR MP2 files properly (actually
- encoded as stereo)
-* AACenc encodes files in VBR mode (actually ABR) even if CBR is
- specified
-* AAC/ADIF - bitrate_mode = cbr for vbr files
-* LAME 3.90-3.92 prepends one frame of null data (space for the
- LAME/VBR header, but it never gets written) when encoding in CBR
- mode with the DLL
-* Ahead Nero encodes TwinVQF with a DSIZ value (which is supposed
- to be the filesize in bytes) of "0" for TwinVQF v1.0 and "1" for
- TwinVQF v2.0 (detected by getID3())
-* Ahead Nero encodes TwinVQF files 1 second shorter than they
- should be
-* AAC-ADTS files are always actually encoded VBR, even if CBR mode
- is specified (the CBR-mode switches on the encoder enable ABR
- mode, not CBR as such, but it's not possible to tell the
- difference between such ABR files and true VBR)
-* STREAMINFO.audio_signature in OggFLAC is always null. "The reason
- it's like that is because there is no seeking support in
- libOggFLAC yet, so it has no way to go back and write the
- computed sum after encoding. Seeking support in Ogg FLAC is the
- #1 item for the next release." - Josh Coalson (FLAC developer)
- NOTE: getID3() will calculate md5_data in a method similar to
- other file formats, but that value cannot be compared to the
- md5_data value from FLAC data in a FLAC file format.
-* STREAMINFO.audio_signature is not calculated in FLAC v0.3.0 &
- v0.4.0 - getID3() will calculate md5_data in a method similar to
- other file formats, but that value cannot be compared to the
- md5_data value from FLAC v0.5.0+
-* RioPort (various versions including 2.0 and 3.11) tags ID3v2 with
- a WCOM frame that has no data portion
-* Earlier versions of Coolplayer adds illegal ID3 tags to Ogg Vorbis
- files, thus making them corrupt.
-* Meracl ID3 Tag Writer v1.3.4 (and older) incorrectly truncates the
- last byte of data from an MP3 file when appending a new ID3v1 tag.
- (detected by getID3())
-* Lossless-Audio files encoded with and without the -noseek switch
- do actually differ internally and therefore cannot match md5_data
-* iTunes has been known to append a new ID3v1 tag on the end of an
- existing ID3v1 tag when ID3v2 tag is also present
- (detected by getID3())
-
-
-
-
-Reference material:
-===========================================================================
-
-[www.id3.org material now mirrored at http://id3lib.sourceforge.net/id3/]
-* http://www.id3.org/id3v2.4.0-structure.txt
-* http://www.id3.org/id3v2.4.0-frames.txt
-* http://www.id3.org/id3v2.4.0-changes.txt
-* http://www.id3.org/id3v2.3.0.txt
-* http://www.id3.org/id3v2-00.txt
-* http://www.id3.org/mp3frame.html
-* http://minnie.tuhs.org/pipermail/mp3encoder/2001-January/001800.html <mathewhendry@hotmail.com>
-* http://www.dv.co.yu/mpgscript/mpeghdr.htm
-* http://www.mp3-tech.org/programmer/frame_header.html
-* http://users.belgacom.net/gc247244/extra/tag.html
-* http://gabriel.mp3-tech.org/mp3infotag.html
-* http://www.id3.org/iso4217.html
-* http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-1.TXT
-* http://www.xiph.org/ogg/vorbis/doc/framing.html
-* http://www.xiph.org/ogg/vorbis/doc/v-comment.html
-* http://leknor.com/code/php/class.ogg.php.txt
-* http://www.id3.org/iso639-2.html
-* http://www.id3.org/lyrics3.html
-* http://www.id3.org/lyrics3200.html
-* http://www.psc.edu/general/software/packages/ieee/ieee.html
-* http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
-* http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
-* http://www.jmcgowan.com/avi.html
-* http://www.wotsit.org/
-* http://www.herdsoft.com/ti/davincie/davp3xo2.htm
-* http://www.mathdogs.com/vorbis-illuminated/bitstream-appendix.html
-* "Standard MIDI File Format" by Dustin Caldwell (from www.wotsit.org)
-* http://midistudio.com/Help/GMSpecs_Patches.htm
-* http://www.xiph.org/archives/vorbis/200109/0459.html
-* http://www.replaygain.org/
-* http://www.lossless-audio.com/
-* http://download.microsoft.com/download/winmediatech40/Doc/1.0/WIN98MeXP/EN-US/ASF_Specification_v.1.0.exe
-* http://mediaxw.sourceforge.net/files/doc/Active%20Streaming%20Format%20(ASF)%201.0%20Specification.pdf
-* http://www.uni-jena.de/~pfk/mpp/sv8/
-* http://jfaul.de/atl/
-* http://www.uni-jena.de/~pfk/mpp/
-* http://www.libpng.org/pub/png/spec/png-1.2-pdg.html
-* http://www.real.com/devzone/library/creating/rmsdk/doc/rmff.htm
-* http://www.fastgraph.com/help/bmp_os2_header_format.html
-* http://netghost.narod.ru/gff/graphics/summary/os2bmp.htm
-* http://flac.sourceforge.net/format.html
-* http://www.research.att.com/projects/mpegaudio/mpeg2.html
-* http://www.audiocoding.com/wiki/index.php?page=AAC
-* http://libmpeg.org/mpeg4/doc/w2203tfs.pdf
-* http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt
-* http://developer.apple.com/techpubs/quicktime/qtdevdocs/RM/frameset.htm
-* http://www.nullsoft.com/nsv/
-* http://www.wotsit.org/download.asp?f=iso9660
-* http://sandbox.mc.edu/~bennet/cs110/tc/tctod.html
-* http://www.cdroller.com/htm/readdata.html
-* http://www.speex.org/manual/node10.html
-* http://www.harmony-central.com/Computer/Programming/aiff-file-format.doc
-* http://www.faqs.org/rfcs/rfc2361.html
-* http://ghido.shelter.ro/
-* http://www.ebu.ch/tech_t3285.pdf
-* http://www.sr.se/utveckling/tu/bwf
-* http://ftp.aessc.org/pub/aes46-2002.pdf
-* http://cartchunk.org:8080/
-* http://www.broadcastpapers.com/radio/cartchunk01.htm
-* http://www.hr/josip/DSP/AudioFile2.html
-* http://home.attbi.com/~chris.bagwell/AudioFormats-11.html
-* http://www.pure-mac.com/extkey.html
-* http://cesnet.dl.sourceforge.net/sourceforge/bonkenc/bonk-binary-format-0.9.txt
-* http://www.headbands.com/gspot/
-* http://www.openswf.org/spec/SWFfileformat.html
-* http://j-faul.virtualave.net/
-* http://www.btinternet.com/~AnthonyJ/Atari/programming/avr_format.html
-* http://cui.unige.ch/OSG/info/AudioFormats/ap11.html
-* http://sswf.sourceforge.net/SWFalexref.html
-* http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
-* http://www-lehre.informatik.uni-osnabrueck.de/~fbstark/diplom/docs/swf/Flash_Uncovered.htm
-* http://developer.apple.com/quicktime/icefloe/dispatch012.html
-* http://www.csdn.net/Dev/Format/graphics/PCD.htm
-* http://tta.iszf.irk.ru/
-* http://www.atsc.org/standards/a_52a.pdf
-* http://www.alanwood.net/unicode/
-* http://www.freelists.org/archives/matroska-devel/07-2003/msg00010.html
-* http://www.its.msstate.edu/net/real/reports/config/tags.stats
-* http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt
-* http://brennan.young.net/Comp/LiveStage/things.html
-* http://www.multiweb.cz/twoinches/MP3inside.htm
-* http://www.geocities.co.jp/SiliconValley-Oakland/3664/alittle.html#GenreExtended
-* http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
-* http://www.unicode.org/unicode/faq/utf_bom.html
-* http://tta.corecodec.org/?menu=format
-* http://www.scvi.net/nsvformat.htm
-* http://pda.etsi.org/pda/queryform.asp
-* http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
-* http://trac.musepack.net/trac/wiki/SV8Specification
diff --git a/apps/media/getID3/structure.txt b/apps/media/getID3/structure.txt
deleted file mode 100644
index a0651c60936..00000000000
--- a/apps/media/getID3/structure.txt
+++ /dev/null
@@ -1,2251 +0,0 @@
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// changelog.txt - part of getID3() //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-What does the returned data structure look like?
-================================================
-
-Hint: If you take a look at the nicely-formatted output of
-/demos/demo.browse.php you can generally see where the data you want
-is returned.
-
-Note that what is described below is only a rough guide to what data
-is actually returned by getID3(), since the actual data returned
-depends entirely on what data is in your file, what type of file it
-is, what kind of data is in the tags, etc. In addition, some formats
-(Quicktime for example) use a freeform recursive structure that is
-impossible to document completely.
-
-In the vast majority of cases, all the data you'll need is located
-in the root of the array or the special arrays described below in
-Section 1 (['audio'], ['video'], ['tags_html'], ['replay_gain']).
-
-It is suggested that for most applications you should use tag data
-from the root ['tags_html'] array, as this is the only location
-where data is stored in a consistant format: HTML-compatible
-character entities (ie &#1234;) for characters outside the 0x20-0x7F
-range (printable ISO-8859-1 characters). This data can be used as-is
-for output in HTML, and can be converted to whatever character set
-you wish to use if the output is not HTML.
-
-If you want to merge all available tags (for example, ID3v2 + ID3v1)
-into one array, you can call
-getid3_lib::CopyTagsToComments($ThisFileInfo)
-and you'll then have ['comments'] and ['comments_html'] which are
-identical to ['tags'] and ['tags_html'] except the array is one
-dimension shorter (no tag type array keys). For example, artist is:
-['tags_html']['id3v1']['artist'][0] or ['comments_html']['artist'][0]
-
-
-Some commonly-used information is found in these locations:
-
-File type: ['fileformat'] // ex 'mp3'
-Song length: ['playtime_string'] // ex '3:45' (minutes:seconds)
- ['playtime_seconds'] // ex 225.13 (seconds)
-Overall bitrate: ['bitrate'] // ex 113485.71 (bits-per-second - divide by 1000 for kbps)
-Audio frequency: ['audio']['sample_rate'] // ex 44100 (Hertz)
-Artist name: ['comments_html']['artist'][0] // ex 'Elvis' (if CopyTagsToComments() is used - see above)
- // more than one artist may be present, you may want to use implode:
- // implode(' & ', ['comments_html']['artist'])
-
-
-/////////////////////////////////////////////////////////////////
-
-array() {
- // SECTION 1: Values that are present for most or all file types
-
- ['getID3version']=>string() // version of getID3() that scanned this file (ex: '1.6.2')
- ['error']=>array() // if present, contains one or more fatal error messages
- ['warning']=>array() // if present, contains one or more non-fatal warning messages
- ['exist']=>boolean() // does this file actually exist?
- ['fileformat']=>string() // one of the standard filetype abbreviations ('mp3', 'riff', 'quicktime', etc)
- ['filename']=>string() // filename only, no path
- ['filenamepath']=>string() // full filename with path
- ['filepath']=>string() // path to file, not including filename
- ['filesize']=>integer() // filesize in bytes
- ['md5_file']=>string() // md5 hash of entire file
- ['md5_data']=>string() // md5 hash of portion of file excluding prepended and appeneded metainformation tags (ID3, APE, etc) - may be identical to ['md5_file']
- ['md5_data_source']=>string() // md5 hash of original source file before compression (currently used by FLAC, OptimFROG, WavPack v4+)
- ['sha1_file']=>string() // sha1 hash of entire file
- ['sha1_data']=>string() // sha1 hash of portion of file excluding prepended and appeneded metainformation tags (ID3, APE, etc) - may be identical to ['md5_file']
- ['avdataoffset']=>integer() // offset in bytes where audio/video data starts and prepended tags end
- ['avdataend']=>integer() // offset in bytes where audio/video data ends and appended tags start
- ['bitrate']=>double() // average bitrate for entire file (all audio/video streams), in bits per second
- ['mime_type']=>string() // if present, MIME type of scanned file
- ['playtime_seconds']=>double() // playing time of file, in seconds
- ['playtime_string']=>string() // playing time of file, formatted as <minutes>:<seconds>
- ['tags']=>array() // array of all metainformation tags present in file ('id3v1', 'id3v2', 'ape', 'riff', 'asf', etc)
- ['audio']=>array() {
- ['bitrate']=>double() // average bitrate for audio portion of file (all audio streams), in bits per second
- ['bitrate_mode']=>string() // 'cbr' (Constant Bit Rate) or 'vbr' (Variable Bit Rate)
- ['bits_per_sample']=>integer() //
- ['channelmode']=>string() // 'mono' or 'stereo'
- ['channels']=>integer() // number of audio channels
- ['codec']=>string() // name of audio compression codec
- ['compression_ratio']=>double() // ratio of compressed byte size of audio to uncompressed size
- ['dataformat']=>string() // one of the standard filetype abbreviations ('mp3', 'wma', etc)
- ['encoder']=>string() // name and version of encoder used to create file, if known
- ['lossless']=>boolean() // true = lossless compression; false = lossy compression
- ['sample_rate']=>integer()
- }
- ['video']=>array() {
- ['bitrate']=>integer() // average bitrate for video portion of file (all video streams), in bits per second
- ['bitrate_mode']=>string() // 'cbr' (Constant Bit Rate) or 'vbr' (Variable Bit Rate)
- ['bits_per_sample']=>integer() //
- ['codec']=>string() // name of video compression codec
- ['compression_ratio']=>double() // ratio of compressed byte size of video to uncompressed size
- ['dataformat']=>string() // one of the standard filetype abbreviations ('avi', 'mpeg', etc)
- ['encoder']=>string() // name and version of encoder used to create file, if known
- ['frame_rate']=>double() // frames per second
- ['lossless']=>boolean() // true = lossless compression; false = lossy compression
- ['resolution_x']=>integer() // horizontal dimension of video/image in pixels
- ['resolution_y']=>integer() // vertical dimension of video/image in pixels
- ['pixel_aspect_ratio']=>double() // pixel display aspect ratio
- }
- ['tags']=>array() { // array of array of strings containing best data from any available metainformation tag (APE, ID3v2, ID3v1, Lyrics3, Vorbis, ASF, RIFF, Real, etc.)
- [<key name>]=>array() // <key name> can be anything, usually 'artist', 'title', etc. Contains array of one or more values (eg: multiple artists are possible)
- }
- ['tags_html']=>array() { // identical to ['tags'], but with all entries converted to HTML entities as appropriate from various source encodings
- [<key name>]=>array() //
- }
- ['replay_gain']=>array() { // replay gain information combined from any source that contains this information (LAME, ID3v2, Vorbis, APE, etc)
- ['audiophile']=>array() {
- ['adjustment']=>double()
- ['originator']=>string()
- ['peak']=>double()
- }
- ['radio']=>array() {
- ['adjustment']=>double()
- ['originator']=>string()
- ['peak']=>double()
- }
- }
-
-
- // SECTION 2: Values that are present for specific file types only
-
- ['aac']=>array() { // AAC - Advanced Audio Coding / MPEG-4
- ['bitrate_distribution']=>array() //
- ['header']=>array() { //
- ['channel_configuration']=>integer() //
- ['crc_present']=>boolean() //
- ['home']=>boolean() //
- ['layer']=>integer() //
- ['mpeg_version']=>integer() //
- ['original']=>boolean() //
- ['private']=>boolean() //
- ['profile_id']=>integer() //
- ['profile_text']=>string() //
- ['sample_frequency']=>integer() //
- ['sample_frequency_index']=>integer() //
- ['synch']=>integer() //
- } //
- ['header_type']=>string() //
- } //
- //
- ['ape']=>array() //
- { //
- ['comments']=>array() { // array of array of strings containing best data from any available metainformation tag (APE, ID3v2, ID3v1, Lyrics3, Vorbis, ASF, RIFF, Real, etc.)
- [<key name>]=>array() // <key name> can be anything, usually 'artist', 'title', etc. Contains array of one or more values (eg: multiple artists are possible)
- } //
- ['footer']=>array() //
- { //
- ['flags']=>array() //
- ['raw']=>array() //
- ['tag_version']=>integer() //
- } //
- ['header']=>array() //
- { //
- ['flags']=>array() //
- ['raw']=>array() //
- ['tag_version']=>integer() //
- } //
- ['items']=>array() { // array of array of strings containing metainformation
- [<key name>]=>array() { // <key name> can be anything, usually 'artist', 'title', etc. Contains array of one or more values (eg: multiple artists are possible)
- ['data']=>array() { // array of one or more Unicode values
- ['data_ascii']=>array() { // array of values converted approximately from Unicode to ASCII
- ['flags']=>array() //
- } //
- } //
- ['tag_offset_end']=>integer() //
- ['tag_offset_start']=>integer() //
- } //
-
-
- ['asf']=>array() { // ASF - Advanced Streaming Format (ASF, Windows Media Audio (WMA), Windows Media Video (WMV))
- ['audio_media']=>array() { //
- [<x>]=>array() { //
- ['bitrate']=>integer() //
- ['bits_per_sample']=>integer() //
- ['channels']=>integer() //
- ['codec']=>string() //
- ['codec_data']=>string() //
- ['codec_data_size']=>integer() //
- ['raw']=>array() { //
- ['nAvgBytesPerSec']=>integer() //
- ['wBitsPerSample']=>integer() //
- ['nBlockAlign']=>integer() //
- ['nChannels']=>integer() //
- ['nSamplesPerSec']=>integer() //
- ['wFormatTag']=>integer() //
- } //
- ['sample_rate']=>integer() //
- } //
- } //
- ['codec_list']=>array() { //
- ['codec_entries']=>array() { //
- [<x>]=>array() { //
- ['description']=>string() //
- ['description_ascii']=>string() //
- ['information']=>string() //
- ['name']=>string() //
- ['name_ascii']=>string() //
- ['type']=>string() //
- ['type_raw']=>integer() //
- } //
- } //
- ['codec_entries_count']=>integer() //
- ['objectid']=>string() //
- ['objectid_guid']=>string() //
- ['objectsize']=>integer() //
- ['reserved']=>string() //
- ['reserved_guid']=>string() //
- } //
- ['comments']=>array() { // array of comment values, derived from ['content_description']
- ['album']=>string() //
- ['artist']=>string() //
- ['comment']=>string() //
- ['copyright']=>string() //
- ['genre']=>string() //
- ['title']=>string() //
- ['track']=>string() //
- ['year']=>string() //
- } //
- ['content_description']=>array() { // raw values - should use values from ['comments'] instead
- ['author']=>string() //
- ['author_ascii']=>string() //
- ['author_length']=>integer() //
- ['copyright']=>string() //
- ['copyright_ascii']=>string() //
- ['copyright_length']=>integer() //
- ['description']=>string() //
- ['description_ascii']=>string() //
- ['description_length']=>integer() //
- ['objectid']=>string() //
- ['objectid_guid']=>string() //
- ['objectsize']=>integer() //
- ['rating']=>string() //
- ['rating_ascii']=>string() //
- ['rating_length']=>integer() //
- ['title']=>string() //
- ['title_ascii']=>string() //
- ['title_length']=>integer() //
- } //
- ['data_object']=>array() { //
- ['fileid']=>string() //
- ['fileid_guid']=>string() //
- ['objectid']=>string() //
- ['objectid_guid']=>string() //
- ['objectsize']=>integer() //
- ['reserved']=>integer() //
- ['total_data_packets']=>integer() //
- } //
- ['extended_content_description']=>array() { //
- ['content_descriptors']=>array() { //
- [<x>]=>array() { //
- ['name']=>string() //
- ['name_ascii']=>string() //
- ['name_length']=>integer() //
- ['value']=>string() //
- ['value_ascii']=>string() //
- ['value_length']=>integer() //
- ['value_type']=>integer() //
- } //
- } //
- ['content_descriptors_count']=>integer() //
- ['objectid']=>string() //
- ['objectid_guid']=>string() //
- ['objectsize']=>integer() //
- } //
- ['file_properties_object']=>array() { //
- ['creation_date']=>double() //
- ['creation_date_unix']=>double() //
- ['data_packets']=>integer() //
- ['fileid']=>string() //
- ['fileid_guid']=>string() //
- ['filesize']=>integer() //
- ['flags']=>array() { //
- ['broadcast']=>boolean() //
- ['seekable']=>boolean() //
- } //
- ['flags_raw']=>integer() //
- ['max_bitrate']=>integer() //
- ['max_packet_size']=>integer() //
- ['min_packet_size']=>integer() //
- ['objectid']=>string() //
- ['objectid_guid']=>string() //
- ['objectsize']=>integer() //
- ['play_duration']=>double() //
- ['preroll']=>integer() //
- ['send_duration']=>double() //
- } //
- ['header_extension_object']=>array() { //
- ['extension_data']=>integer() //
- ['extension_data_size']=>integer() //
- ['objectid']=>string() //
- ['objectid_guid']=>string() //
- ['objectsize']=>integer() //
- ['reserved_1']=>string() //
- ['reserved_1_guid']=>string() //
- ['reserved_2']=>integer() //
- } //
- ['header_object']=>array() { //
- ['headerobjects']=>integer() //
- ['objectid']=>string() //
- ['objectid_guid']=>string() //
- ['objectsize']=>integer() //
- ['reserved1']=>integer() //
- ['reserved2']=>integer() //
- } //
- ['marker_object']=>array() { //
- ['markers_count']=>integer() //
- ['objectid']=>string() //
- ['objectid_guid']=>string() //
- ['objectsize']=>integer() //
- ['reserved']=>string() //
- ['reserved_2']=>integer() //
- ['reserved_guid']=>string() //
- } //
- ['stream_bitrate_properties']=>array() { //
- ['bitrate_records']=>array() { //
- [<x>]=>array() { //
- ['bitrate']=>integer() //
- ['flags_raw']=>integer() //
- ['flags']=>array() { //
- ['stream_number']=>integer() //
- } //
- } //
- } //
- ['bitrate_records_count']=>integer() //
- ['objectid']=>string() //
- ['objectid_guid']=>string() //
- ['objectsize']=>integer() //
- } //
- ['stream_properties_object']=>array() { //
- [<x>]=>array() { //
- ['error_correct_data']=>string() //
- ['error_correct_guid']=>string() //
- ['error_correct_type']=>string() //
- ['error_data_length']=>integer() //
- ['flags_raw']=>integer() //
- ['flags']=>array() { //
- ['encrypted']=>boolean() //
- } //
- ['objectid']=>string() //
- ['objectid_guid']=>string() //
- ['objectsize']=>integer() //
- ['stream_type']=>string() //
- ['stream_type_guid']=>string() //
- ['time_offset']=>integer() //
- ['type_data_length']=>integer() //
- ['type_specific_data']=>string() //
- } //
- } //
- ['video_media']=>array() { //
- [<x>]=>array() { //
- ['flags']=>integer() //
- ['format_data']=>array() { //
- ['bits_per_pixel']=>integer() //
- ['codec']=>string() //
- ['codec_data']=>boolean() //
- ['codec_fourcc']=>string() //
- ['colors_important']=>integer() //
- ['colors_used']=>integer() //
- ['format_data_size']=>integer() //
- ['horizontal_pels']=>integer() //
- ['image_height']=>integer() //
- ['image_size']=>integer() //
- ['image_width']=>integer() //
- ['reserved']=>integer() //
- ['vertical_pels']=>integer() //
- } //
- ['format_data_size']=>integer() //
- ['image_height']=>integer() //
- ['image_width']=>integer() //
- } //
- } //
- } //
-
-
- ['au']=>array() { // AU - Next/Sun AUdio format
- ['bits_per_sample']=>integer() //
- ['channels']=>integer() //
- ['comment']=>string() //
- ['data_format']=>string() //
- ['data_format_id']=>integer() //
- ['data_size']=>integer() //
- ['header_length']=>integer() //
- ['sample_rate']=>integer() //
- ['used_bits_per_sample']=>integer() //
- } //
-
-
- ['bmp']=>array() { // BMP - OS/2 or Windows BitMaP
- ['header']=>array() { //
- ['compression']=>string() //
- ['raw']=>array() { //
- ['bits_per_pixel']=>integer() //
- ['bmp_data_size']=>integer() //
- ['colors_important']=>integer() //
- ['colors_used']=>integer() //
- ['compression']=>integer() //
- ['data_offset']=>integer() //
- ['filesize']=>integer() //
- ['header_size']=>integer() //
- ['height']=>integer() //
- ['identifier']=>string() //
- ['planes']=>integer() //
- ['resolution_h']=>integer() //
- ['resolution_v']=>integer() //
- ['width']=>integer() //
- } //
- } //
- ['type_os']=>string() //
- ['type_version']=>integer() //
- } //
-
-
- ['bonk']=>array() { // BONK - lossy/lossless audio compression (www.bonkenc.org)
- ['BONK']=>array() { //
- ['channels']=>integer() //
- ['downsampling_ratio']=>integer() //
- ['joint_stereo']=>boolean() //
- ['lossless']=>boolean() //
- ['number_samples']=>integer() //
- ['number_taps']=>integer() //
- ['offset']=>integer() //
- ['sample_rate']=>integer() //
- ['samples_per_packet']=>integer() //
- ['size']=>integer() //
- ['version']=>integer() //
- } //
- ['INFO']=>array() { //
- ['size']=>integer() //
- ['offset']=>integer() //
- ['version']=>integer() //
- [<x>]=>array() { //
- ['nextbit']=>integer() //
- ['offset']=>integer() //
- } //
- } //
- ['dataend']=>integer() //
- ['dataoffset']=>integer() //
- } //
-
-
- ['flac']=>array() { // FLAC - Free Lossless Audio Compressor
- ['SEEKTABLE']=>array() { //
- [<x>]=>array() { //
- ['offset']=>integer() //
- ['samples']=>integer() //
- } //
- ['placeholders']=>integer() //
- ['raw']=>array() { //
- ['block_data']=>string() //
- ['block_length']=>integer() //
- ['block_type']=>integer() //
- ['block_type_text']=>string() //
- ['last_meta_block']=>boolean() //
- ['offset']=>integer() //
- } //
- } //
- ['STREAMINFO']=>array() { //
- ['audio_signature']=>string() //
- ['bits_per_sample']=>integer() //
- ['channels']=>integer() //
- ['max_block_size']=>integer() //
- ['max_frame_size']=>integer() //
- ['min_block_size']=>integer() //
- ['min_frame_size']=>integer() //
- ['raw']=>array() { //
- ['block_data']=>string() //
- ['block_length']=>integer() //
- ['block_type']=>integer() //
- ['block_type_text']=>string() //
- ['last_meta_block']=>boolean() //
- ['offset']=>integer() //
- } //
- ['sample_rate']=>integer() //
- ['samples_stream']=>integer() //
- } //
- ['VORBIS_COMMENT']=>array() { //
- ['raw']=>array() { //
- ['block_data']=>string() //
- ['block_length']=>integer() //
- ['block_type']=>integer() //
- ['block_type_text']=>string() //
- ['last_meta_block']=>boolean() //
- ['offset']=>integer() //
- } //
- } //
- ['compressed_audio_bytes']=>integer() //
- ['compression_ratio']=>double() //
- ['uncompressed_audio_bytes']=>integer() //
- } //
-
-
- ['gif']=>array() { // GIF - Graphics Interchange Format
- ['global_color_table']=>array() { //
- [<x>]=>integer() //
- } //
- ['header']=>array() { //
- ['bits_per_pixel']=>integer() //
- ['flags']=>array() { //
- ['global_color_sorted']=>boolean() //
- ['global_color_table']=>boolean() //
- } //
- ['global_color_size']=>integer() //
- ['raw']=>array() { //
- ['aspect_ratio']=>integer() //
- ['bg_color_index']=>integer() //
- ['flags']=>integer() //
- ['height']=>integer() //
- ['identifier']=>string() //
- ['version']=>string() //
- ['width']=>integer() //
- } //
- } //
- ['version']=>string() //
- } //
-
-
- ['id3v1']=>array() { // ID3v1
- ['album']=>string() //
- ['artist']=>string() //
- ['comment']=>string() //
- ['genre']=>string() //
- ['genreid']=>integer() //
- ['title']=>string() //
- ['track']=>integer() //
- ['year']=>string() //
- ['padding_valid']=>boolean() //
- ['comments']=>array() //
- ['tag_offset_start']=>integer() //
- ['tag_offset_end']=>integer() //
- } //
-
-
- ['id3v2']=>array() { // ID3v2 - www.id3.org
- [<frame name>]=>array() { // <frame name> can be any of the 4-character (3-character in ID3v2.2) frame names allowed in the ID3v2 spec. Exact contents of returned array data varies with frame type.
- [<x>]=>array() { // some frames types allow multiple values ('COMM' for example), others do not and do not have this array level
- ['asciidata']=>boolean() //
- ['asciidescription']=>string() //
- ['data']=>boolean() //
- ['datalength']=>integer() //
- ['dataoffset']=>integer() //
- ['description']=>string() //
- ['encoding']=>string() //
- ['encodingid']=>integer() //
- ['flags']=>array() { //
- ['Encryption']=>boolean() //
- ['FileAlterPreservation']=>boolean() //
- ['GroupingIdentity']=>boolean() //
- ['ReadOnly']=>boolean() //
- ['TagAlterPreservation']=>boolean() //
- ['compression']=>boolean() //
- } //
- ['framenamelong']=>string() //
- ['language']=>string() //
- ['languagename']=>string() //
- } //
- } //
- ['comments']=>array() { // array of array of strings containing best data from any available metainformation tag (APE, ID3v2, ID3v1, Lyrics3, Vorbis, ASF, RIFF, Real, etc.)
- [<key name>]=>array() // <key name> can be anything, usually 'artist', 'title', etc. Contains array of one or more values (eg: multiple artists are possible)
- } //
- ['flags']=>array() { //
- ['experim']=>string() //
- ['exthead']=>string() //
- ['unsynch']=>string() //
- } //
- ['header']=>boolean() //
- ['headerlength']=>integer() //
- ['majorversion']=>integer() //
- ['minorversion']=>integer() //
- ['padding']=>array() { //
- ['length']=>integer() //
- ['start']=>integer() //
- ['valid']=>boolean() //
- } //
- ['tag_offset_end']=>integer() //
- ['tag_offset_start']=>integer() //
- } //
-
-
- ['iso']=>array() { // ISO-9660 - CD-ROM Image
- ['directories']=>array() { //
- [<x>]=>array() { //
- [<x>]=>array() { //
- ['file_flags']=>array() { //
- ['associated']=>boolean() //
- ['directory']=>boolean() //
- ['extended']=>boolean() //
- ['hidden']=>boolean() //
- ['multiple']=>boolean() //
- ['permissions']=>boolean() //
- } //
- ['file_identifier_ascii']=>string() //
- ['filename']=>string() //
- ['filesize']=>integer() //
- ['offset_bytes']=>integer() //
- ['raw']=>array() { //
- ['extended_attribute_length']=>integer() //
- ['file_flags']=>integer() //
- ['file_identifier']=>string() //
- ['file_identifier_length']=>integer() //
- ['file_unit_size']=>integer() //
- ['filesize']=>integer() //
- ['interleave_gap_size']=>integer() //
- ['length']=>integer() //
- ['offset_logical']=>integer() //
- ['recording_date_time']=>string() //
- ['volume_sequence_number']=>integer() //
- } //
- ['recording_timestamp']=>integer() //
- } //
- } //
- } //
- ['files']=>array() { // multidimensional tree-structure array listing of all files and directories in image
- [<directory name>]=>array() // entries of type array are directories (key is directory name), may contain files and/or other subdirectories
- [<file name>]=>integer() // entries of type integer are files (key is file name, value is file size in bytes)
- } //
- ['path_table']=>array() { //
- ['directories']=>array() { //
- [<x>]=>array() { //
- ['extended_length']=>integer() //
- ['full_path']=>string() //
- ['length']=>integer() //
- ['location_bytes']=>integer() //
- ['location_logical']=>integer() //
- ['name']=>string() //
- ['name_ascii']=>string() //
- ['parent_directory']=>integer() //
- } //
- } //
- ['offset']=>integer() //
- ['raw']=>string() //
- } //
- ['primary_volume_descriptor']=>array() { //
- ['abstract_file_identifier']=>string() //
- ['application_identifier']=>string() //
- ['bibliographic_file_identifier']=>string() //
- ['copyright_file_identifier']=>string() //
- ['data_preparer_identifier']=>string() //
- ['offset']=>integer() //
- ['publisher_identifier']=>string() //
- ['raw']=>array() { //
- ['abstract_file_identifier']=>string() //
- ['application_data']=>string() //
- ['application_identifier']=>string() //
- ['bibliographic_file_identifier']=>string() //
- ['copyright_file_identifier']=>string() //
- ['data_preparer_identifier']=>string() //
- ['file_structure_version']=>integer() //
- ['logical_block_size']=>integer() //
- ['path_table_l_location']=>integer() //
- ['path_table_l_opt_location']=>integer() //
- ['path_table_m_location']=>integer() //
- ['path_table_m_opt_location']=>integer() //
- ['path_table_size']=>integer() //
- ['publisher_identifier']=>string() //
- ['root_directory_record']=>string() //
- ['standard_identifier']=>string() //
- ['system_identifier']=>string() //
- ['unused_1']=>string() //
- ['unused_2']=>string() //
- ['unused_3']=>string() //
- ['unused_4']=>integer() //
- ['volume_creation_date_time']=>string() //
- ['volume_descriptor_type']=>integer() //
- ['volume_descriptor_version']=>integer() //
- ['volume_effective_date_time']=>string() //
- ['volume_expiration_date_time']=>string() //
- ['volume_identifier']=>string() //
- ['volume_modification_date_time']=>string() //
- ['volume_sequence_number']=>integer() //
- ['volume_set_identifier']=>string() //
- ['volume_set_size']=>integer() //
- ['volume_space_size']=>integer() //
- } //
- ['system_identifier']=>string() //
- ['volume_creation_date_time']=>integer() //
- ['volume_effective_date_time']=>boolean() //
- ['volume_expiration_date_time']=>boolean() //
- ['volume_identifier']=>string() //
- ['volume_modification_date_time']=>integer() //
- ['volume_set_identifier']=>string() //
- } //
- ['supplementary_volume_descriptor']=>array() { //
- ['abstract_file_identifier']=>string() //
- ['application_identifier']=>string() //
- ['bibliographic_file_identifier']=>string() //
- ['copyright_file_identifier']=>string() //
- ['data_preparer_identifier']=>string() //
- ['offset']=>integer() //
- ['publisher_identifier']=>string() //
- ['raw']=>array() { //
- ['abstract_file_identifier']=>string() //
- ['application_data']=>string() //
- ['application_identifier']=>string() //
- ['bibliographic_file_identifier']=>string() //
- ['copyright_file_identifier']=>string() //
- ['data_preparer_identifier']=>string() //
- ['file_structure_version']=>integer() //
- ['logical_block_size']=>integer() //
- ['path_table_l_location']=>integer() //
- ['path_table_l_opt_location']=>integer() //
- ['path_table_m_location']=>integer() //
- ['path_table_m_opt_location']=>integer() //
- ['path_table_size']=>integer() //
- ['publisher_identifier']=>string() //
- ['root_directory_record']=>string() //
- ['standard_identifier']=>string() //
- ['system_identifier']=>string() //
- ['unused_1']=>string() //
- ['unused_2']=>string() //
- ['unused_3']=>string() //
- ['unused_4']=>integer() //
- ['volume_creation_date_time']=>string() //
- ['volume_descriptor_type']=>integer() //
- ['volume_descriptor_version']=>integer() //
- ['volume_effective_date_time']=>string() //
- ['volume_expiration_date_time']=>string() //
- ['volume_identifier']=>string() //
- ['volume_modification_date_time']=>string() //
- ['volume_sequence_number']=>integer() //
- ['volume_set_identifier']=>string() //
- ['volume_set_size']=>integer() //
- ['volume_space_size']=>integer() //
- } //
- ['system_identifier']=>string() //
- ['volume_creation_date_time']=>integer() //
- ['volume_effective_date_time']=>boolean() //
- ['volume_expiration_date_time']=>boolean() //
- ['volume_identifier']=>string() //
- ['volume_modification_date_time']=>integer() //
- ['volume_set_identifier']=>string() //
- } //
- } //
-
-
- ['jpg']=>array() { // JPEG - still image
- ['exif']=>array() // data returned from PHP's exif_read_data() function
- } //
-
-
- ['la']=>array() { // LA - Lossless Audio (www.lossless-audio.com)
- ['raw']=>array() {
- ['format']=>integer() //
- ['flags']=>integer() //
- } //
- ['flags']=>array() { //
- ['seekable']=>boolean() //
- ['high_compression']=>boolean() //
- } //
- ['bits_per_sample']=>integer() //
- ['bytes_per_sample']=>integer() //
- ['bytes_per_second']=>integer() //
- ['channels']=>integer() //
- ['compression_ratio']=>double() //
- ['format_size']=>integer() //
- ['header_size']=>integer() //
- ['original_crc']=>double() //
- ['sample_rate']=>integer() //
- ['samples']=>integer() //
- ['uncompressed_size']=>integer() //
- ['version']=>double() //
- ['version_major']=>integer() //
- ['version_minor']=>integer() //
- ['footerstart']=>double() //
- }
-
-
- ['lpac']=>array() { // LPAC - Lossless Predictive Audio Compressor
- ['block_length']=>integer() //
- ['file_version']=>integer() //
- ['flags']=>array() { //
- ['16_bit']=>boolean() //
- ['24_bit']=>boolean() //
- ['adaptive_prediction_order']=>boolean() //
- ['adaptive_quantization']=>boolean() //
- ['fast_compress']=>boolean() //
- ['is_wave']=>boolean() //
- ['joint_stereo']=>boolean() //
- ['max_prediction_order']=>integer() //
- ['quantization']=>integer() //
- ['random_access']=>boolean() //
- ['stereo']=>boolean() //
- } //
- ['raw']=>array() { //
- ['audio_type']=>integer() //
- ['parameters']=>double() //
- } //
- ['total_samples']=>integer() //
- } //
-
-
- ['lyrics3']=>array() { // Lyrics3 - metainformation tags
- ['comments']=>array() { //
- ['album']=>string() //
- ['artist']=>string() //
- ['author']=>string() //
- ['comment']=>string() //
- ['title']=>string() //
- } //
- ['flags']=>array() { //
- ['lyrics']=>boolean() //
- ['timestamps']=>boolean() //
- } //
- ['images']=>array() { //
- [<x>]=>array() { //
- ['description']=>string() //
- ['filename']=>string() //
- ['timestamp']=>integer() //
- } //
- } //
- ['raw']=>array() { //
- ['offset_start']=>integer() //
- ['offset_end']=>integer() //
- ['AUT']=>string() //
- ['EAL']=>string() //
- ['EAR']=>string() //
- ['ETT']=>string() //
- ['IMG']=>string() //
- ['IND']=>string() //
- ['INF']=>string() //
- ['LYR']=>string() //
- ['lyrics3tagsize']=>integer() //
- ['lyrics3version']=>integer() //
- ['unparsed']=>string() //
- } //
- ['synchedlyrics']=>array() { //
- [<x>]=>string() //
- } //
- ['unsynchedlyrics']=>string() //
- } //
-
-
- ['midi']=>array() { // MIDI (Musical Instrument Digital Interface) - sequenced music
- ['comments']=>array() { //
- ['comment']=>string() //
- ['copyright']=>string() //
- } //
- ['keysignature']=>array() { //
- [<x>]=>string() //
- } //
- ['raw']=>array() { //
- ['events']=>array() { //
- [<x>]=>array() { //
- [<x>]=>array() { //
- ['us_qnote']=>integer() //
- } //
- } //
- } //
- ['fileformat']=>integer() //
- ['headersize']=>integer() //
- ['ticksperqnote']=>integer() //
- ['track']=>array() { //
- [<x>]=>array() { //
- ['instrument']=>string() //
- ['instrumentid']=>integer() //
- ['name']=>string() //
- } //
- } //
- ['tracks']=>integer() //
- } //
- ['timesignature']=>array() { //
- [<x>]=>string() //
- } //
- ['totalticks']=>integer() //
- } //
-
-
- ['monkeys_audio']=>array() { // Monkey's Audio - lossless audio compression
- ['bitrate']=>double() //
- ['bits_per_sample']=>integer() //
- ['channels']=>integer() //
- ['compressed_size']=>integer() //
- ['compression']=>string() //
- ['compression_ratio']=>double() //
- ['flags']=>array() { //
- ['24-bit']=>boolean() //
- ['8-bit']=>boolean() //
- ['crc-32']=>boolean() //
- ['no_wav_header']=>boolean() //
- ['peak_level']=>boolean() //
- ['seek_elements']=>boolean() //
- } //
- ['frames']=>integer() //
- ['peak_level']=>integer() //
- ['peak_ratio']=>double() //
- ['playtime']=>double() //
- ['raw']=>array() { //
- ['header_tag']=>string() //
- ['nChannels']=>integer() //
- ['nCompressionLevel']=>integer() //
- ['nFinalFrameSamples']=>integer() //
- ['nFormatFlags']=>integer() //
- ['nPeakLevel']=>integer() //
- ['nSampleRate']=>integer() //
- ['nSeekElements']=>integer() //
- ['nTotalFrames']=>integer() //
- ['nVersion']=>integer() //
- ['nWAVHeaderBytes']=>integer() //
- ['nWAVTerminatingBytes']=>integer() //
- } //
- ['sample_rate']=>integer() //
- ['samples']=>integer() //
- ['samples_per_frame']=>integer() //
- ['uncompressed_size']=>integer() //
- ['version']=>double() //
- } //
-
-
- ['mpc']=>array() { // MPC (Musepack) - lossy audio compression
- ['header']=>array() { //
- ['album_gain_db']=>integer() //
- ['album_peak']=>integer() //
- ['album_peak_db']=>boolean() //
- ['title_gain_db']=>integer() //
- ['title_peak']=>integer() //
- ['title_peak_db']=>boolean() //
- ['begin_loud']=>boolean() //
- ['end_loud']=>boolean() //
- ['encoder_version']=>string() //
- ['frame_count']=>integer() //
- ['intensity_stereo']=>boolean() //
- ['last_frame_length']=>integer() //
- ['max_level']=>integer() //
- ['max_subband']=>integer() //
- ['mid_side_stereo']=>boolean() //
- ['profile']=>string() //
- ['sample_rate']=>integer() //
- ['samples']=>integer() //
- ['size']=>integer() //
- ['stream_major_version']=>integer() //
- ['stream_minor_version']=>integer() //
- ['true_gapless']=>boolean() //
- ['raw']=>array() { //
- ['album_gain']=>integer() //
- ['album_peak']=>integer() //
- ['encoder_version']=>integer() //
- ['preamble']=>string() //
- ['profile']=>integer() //
- ['sample_rate']=>integer() //
- ['title_gain']=>integer() //
- ['title_peak']=>integer() //
- } //
- } //
- } //
-
-
- ['mpeg']=>array() { // MPEG (Motion Picture Experts Group) - MPEG video and/or MPEG audio (MP3/MP2/MP1)
- ['audio']=>array() { //
- ['LAME']=>array() { //
- ['RGAD']=>array() { //
- ['peak_amplitude']=>double() //
- } //
- ['ath_type']=>integer() //
- ['audio_bytes']=>integer() //
- ['bitrate_min']=>integer() //
- ['encoder_delay']=>integer() //
- ['encoding_flags']=>array() { //
- ['nogap_next']=>boolean() //
- ['nogap_prev']=>boolean() //
- ['nspsytune']=>boolean() //
- ['nssafejoint']=>boolean() //
- } //
- ['end_padding']=>integer() //
- ['lame_tag_crc']=>integer() //
- ['lowpass_frequency']=>integer() //
- ['mp3_gain_db']=>double() //
- ['mp3_gain_factor']=>double() //
- ['mp3_gain_raw']=>integer() //
- ['music_crc']=>integer() //
- ['noise_shaping']=>integer() //
- ['noise_shaping_raw']=>integer() //
- ['not_optimal_quality']=>boolean() //
- ['not_optimal_quality_raw']=>integer() //
- ['preset_used_id']=>integer() //
- ['short_version']=>string() // ex: "LAME 3.93"
- ['long_version']=>string() // (pre-v3.90 only) ex: "LAME 3.88 (alpha)"
- ['source_sample_freq']=>string() //
- ['source_sample_freq_raw']=>integer() //
- ['stereo_mode']=>string() //
- ['stereo_mode_raw']=>integer() //
- ['surround_info']=>string() //
- ['surround_info_id']=>integer() //
- ['tag_revision']=>integer() //
- ['vbr_method']=>string() //
- ['vbr_method_raw']=>integer() //
- } //
- ['VBR_bitrate']=>double() //
- ['VBR_bytes']=>integer() //
- ['VBR_frames']=>integer() //
- ['VBR_method']=>string() //
- ['VBR_scale']=>integer() //
- ['bitrate']=>integer() //
- ['bitrate_distribution']=>array() { //
- ['free']=>integer() //
- ['8']=>integer() //
- ['16']=>integer() //
- ['24']=>integer() //
- ['32']=>integer() //
- ['40']=>integer() //
- ['48']=>integer() //
- ['56']=>integer() //
- ['64']=>integer() //
- ['80']=>integer() //
- ['96']=>integer() //
- ['112']=>integer() //
- ['128']=>integer() //
- ['144']=>integer() //
- ['160']=>integer() //
- } //
- ['bitrate_mode']=>string() //
- ['channelmode']=>string() //
- ['channels']=>integer() //
- ['copyright']=>boolean() //
- ['crc']=>integer() //
- ['emphasis']=>string() //
- ['frame_count']=>integer() //
- ['framelength']=>integer() //
- ['layer']=>integer() //
- ['modeextension']=>string() //
- ['original']=>boolean() //
- ['padding']=>boolean() //
- ['private']=>boolean() //
- ['protection']=>boolean() //
- ['raw']=>array() { //
- ['bitrate']=>integer() //
- ['channelmode']=>integer() //
- ['copyright']=>integer() //
- ['emphasis']=>integer() //
- ['layer']=>integer() //
- ['modeextension']=>integer() //
- ['original']=>integer() //
- ['padding']=>integer() //
- ['private']=>integer() //
- ['protection']=>integer() //
- ['sample_rate']=>integer() //
- ['synch']=>integer() //
- ['version']=>integer() //
- } //
- ['sample_rate']=>integer() //
- ['stereo_distribution']=>array() { //
- ['dual channel']=>integer() //
- ['joint stereo']=>integer() //
- ['mono']=>integer() //
- ['stereo']=>integer() //
- } //
- ['toc']=>array() { //
- [<x>]=>integer() //
- } //
- ['version']=>string() //
- ['version_distribution']=>array() { //
- [<x>]=>integer() //
- [<x>]=>integer() //
- ['2.5']=>integer() //
- } //
- ['xing_flags']=>array() { //
- ['bytes']=>boolean() //
- ['frames']=>boolean() //
- ['toc']=>boolean() //
- ['vbr_scale']=>boolean() //
- } //
- ['xing_flags_raw']=>string() //
- } //
- ['video']=>array() { //
- ['bitrate']=>integer() //
- ['bitrate_mode']=>string() //
- ['frame_rate']=>double() //
- ['framesize_horizontal']=>integer() //
- ['framesize_vertical']=>integer() //
- ['pixel_aspect_ratio']=>double() //
- ['pixel_aspect_ratio_text']=>string() //
- ['raw']=>array() { //
- ['bitrate']=>integer() //
- ['constrained_param_flag']=>integer() //
- ['frame_rate']=>integer() //
- ['framesize_horizontal']=>integer() //
- ['framesize_vertical']=>integer() //
- ['intra_quant_flag']=>integer() //
- ['marker_bit']=>integer() //
- ['pixel_aspect_ratio']=>integer() //
- ['vbv_buffer_size']=>integer() //
- } //
- } //
- } //
-
-
- ['nsv']=>array() { // NSV - Nullsoft Streaming Video
- ['NSVf']=>array() { //
- ['TOC_entries_1']=>integer() //
- ['TOC_entries_2']=>integer() //
- ['file_size']=>integer() //
- ['header_length']=>integer() //
- ['identifier']=>string() //
- ['meta_size']=>integer() //
- ['metadata']=>string() //
- ['playtime_ms']=>integer() //
- } //
- ['NSVs']=>array() { //
- ['audio_codec']=>string() //
- ['frame_rate']=>double() //
- ['framerate_index']=>integer() //
- ['identifier']=>string() //
- ['offset']=>integer() //
- ['resolution_x']=>integer() //
- ['resolution_y']=>integer() //
- ['unknown1b']=>integer() //
- ['unknown1c']=>integer() //
- ['unknown1d']=>integer() //
- ['unknown2a']=>integer() //
- ['unknown2b']=>integer() //
- ['unknown2c']=>integer() //
- ['unknown2d']=>integer() //
- ['unknown3a']=>integer() //
- ['unknown3b']=>integer() //
- ['unknown3c']=>integer() //
- ['unknown3d']=>integer() //
- ['video_codec']=>string() //
- } //
- ['comments']=>array() { //
- ['aspect']=>string() //
- ['title']=>string() //
- } //
- } //
-
-
- ['ofr']=>array() { // OFR (OptimFROG) - lossless audio compression
- ['COMP']=>array() { //
- [<x>]=>array() { //
- ['channel_configuration']=>string() //
- ['crc_32']=>boolean() //
- ['encoder']=>string() //
- ['offset']=>integer() //
- ['raw']=>array() { //
- ['algorithm_id']=>integer() //
- ['channel_configuration']=>integer() //
- ['encoder_id']=>integer() //
- ['sample_type']=>integer() //
- } //
- ['sample_count']=>integer() //
- ['sample_type']=>string() //
- ['size']=>integer() //
- } //
- } //
- ['HEAD']=>array() { //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- ['OFR ']=>array() { //
- ['channel_config']=>integer() //
- ['channels']=>integer() //
- ['compression']=>string() //
- ['encoder']=>string() //
- ['offset']=>integer() //
- ['raw']=>array() { //
- ['compression']=>integer() //
- ['encoder_id']=>integer() //
- ['sample_type']=>integer() //
- } //
- ['sample_rate']=>integer() //
- ['sample_type']=>string() //
- ['size']=>integer() //
- ['total_samples']=>integer() //
- } //
- ['TAIL']=>array() { //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
-
-
- ['ogg']=>array() { // OGG - container format for Ogg Vorbis, OggFLAC, Speex, etc
- ['bitrate_average']=>double() //
- ['bitrate_max']=>integer() //
- ['bitrate_min']=>integer() //
- ['bitrate_nominal']=>integer() //
- ['bitstreamversion']=>integer() //
- ['blocksize_large']=>integer() //
- ['blocksize_small']=>integer() //
- ['comments']=>array() { // array of array of strings containing best data from any available metainformation tag (APE, ID3v2, ID3v1, Lyrics3, Vorbis, ASF, RIFF, Real, etc.)
- [<key name>]=>array() // <key name> can be anything, usually 'artist', 'title', etc. Contains array of one or more values (eg: multiple artists are possible)
- } //
- ['comments_raw']=>array() { //
- [<x>]=>array() { //
- ['dataoffset']=>integer() //
- ['key']=>string() //
- ['size']=>integer() //
- ['value']=>string() //
- } //
- } //
- ['numberofchannels']=>integer() //
- ['pageheader']=>array() { //
- [<x>]=>array() { //
- ['flags']=>array() { //
- ['bos']=>boolean() //
- ['eos']=>boolean() //
- ['fresh']=>boolean() //
- } //
- ['flags_raw']=>integer() //
- ['header_end_offset']=>integer() //
- ['packet_type']=>integer() //
- ['page_checksum']=>double() //
- ['page_end_offset']=>integer() //
- ['page_length']=>integer() //
- ['page_segments']=>integer() //
- ['page_seqno']=>integer() //
- ['page_start_offset']=>integer() //
- ['pcm_abs_position']=>integer() //
- ['segment_table']=>array() { //
- [<x>]=>integer() //
- } //
- ['stream_serialno']=>integer() //
- ['stream_structver']=>integer() //
- ['stream_type']=>string() //
- } //
- ['eos']=>array() { //
- ['flags']=>array() { //
- ['bos']=>boolean() //
- ['eos']=>boolean() //
- ['fresh']=>boolean() //
- } //
- ['flags_raw']=>integer() //
- ['header_end_offset']=>integer() //
- ['page_checksum']=>double() //
- ['page_end_offset']=>integer() //
- ['page_length']=>integer() //
- ['page_segments']=>integer() //
- ['page_seqno']=>integer() //
- ['page_start_offset']=>integer() //
- ['pcm_abs_position']=>integer() //
- ['segment_table']=>array() { //
- [<x>]=>integer() //
- } //
- ['stream_serialno']=>integer() //
- ['stream_structver']=>integer() //
- } //
- } //
- ['samplerate']=>integer() //
- ['samples']=>integer() //
- ['stop_bit']=>integer() //
- ['vendor']=>string() //
- } //
-
-
- ['png']=>array() { // PNG (Portable Network Graphics) - still image
- ['IDAT']=>array() { //
- [<x>]=>array() { //
- ['header']=>array() { //
- ['crc']=>integer() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- } //
- } //
- ['IEND']=>array() { //
- ['header']=>array() { //
- ['crc']=>double() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- } //
- ['IHDR']=>array() { //
- ['color_type']=>array() { //
- ['alpha']=>boolean() //
- ['palette']=>boolean() //
- ['true_color']=>boolean() //
- } //
- ['compression_method_text']=>string() //
- ['header']=>array() { //
- ['crc']=>double() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- ['height']=>integer() //
- ['raw']=>array() { //
- ['bit_depth']=>integer() //
- ['color_type']=>integer() //
- ['compression_method']=>integer() //
- ['filter_method']=>integer() //
- ['interlace_method']=>integer() //
- } //
- ['width']=>integer() //
- } //
- ['PLTE']=>array() { //
- ['header']=>array() { //
- ['crc']=>double() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- [<x>]=>integer() //
- } //
- ['comments']=>array() { // array of array of strings containing best data from any available metainformation tag (APE, ID3v2, ID3v1, Lyrics3, Vorbis, ASF, RIFF, Real, etc.)
- [<key name>]=>array() // <key name> can be anything, usually 'artist', 'title', etc. Contains array of one or more values (eg: multiple artists are possible)
- } //
- ['gAMA']=>array() { //
- ['gamma']=>double() //
- ['header']=>array() { //
- ['crc']=>integer() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- } //
- ['oFFs']=>array() { //
- ['header']=>array() { //
- ['crc']=>double() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- ['position_x']=>integer() //
- ['position_y']=>integer() //
- ['unit']=>string() //
- ['unit_specifier']=>integer() //
- } //
- ['pHYs']=>array() { //
- ['header']=>array() { //
- ['crc']=>integer() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- ['pixels_per_unit_x']=>integer() //
- ['pixels_per_unit_y']=>integer() //
- ['unit']=>string() //
- ['unit_specifier']=>integer() //
- } //
- ['pcLb']=>array() { //
- ['header']=>array() { //
- ['crc']=>double() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- } //
- ['tEXt']=>array() { //
- ['header']=>array() { //
- ['crc']=>integer() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- ['keyword']=>string() //
- ['text']=>string() //
- } //
- ['tIME']=>array() { //
- ['day']=>integer() //
- ['header']=>array() { //
- ['crc']=>integer() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- ['hour']=>integer() //
- ['minute']=>integer() //
- ['month']=>integer() //
- ['second']=>integer() //
- ['unix']=>integer() //
- ['year']=>integer() //
- } //
- ['tRNS']=>array() { //
- ['header']=>array() { //
- ['crc']=>double() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- ['transparent_color_blue']=>integer() //
- ['transparent_color_green']=>integer() //
- ['transparent_color_red']=>integer() //
- } //
- ['zTXt']=>array() { //
- ['compressed_text']=>string() //
- ['compression_method']=>integer() //
- ['compression_method_text']=>string() //
- ['header']=>array() { //
- ['crc']=>double() //
- ['data']=>string() //
- ['data_length']=>integer() //
- ['flags']=>array() { //
- ['ancilliary']=>boolean() //
- ['private']=>boolean() //
- ['reserved']=>boolean() //
- ['safe_to_copy']=>boolean() //
- } //
- ['type_raw']=>double() //
- ['type_text']=>string() //
- } //
- ['keyword']=>string() //
- ['text']=>string() //
- } //
- } //
-
-
- ['quicktime']=>array() { // Quicktime - video/audio
- ['']=>array() { //
- ['name']=>boolean() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- ['audio']=>array() { //
- ['bit_depth']=>integer() //
- ['channels']=>integer() //
- ['codec']=>string() //
- ['sample_rate']=>double() //
- } //
- ['free']=>array() { //
- ['name']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- ['mdat']=>array() { //
- ['name']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- ['moov']=>array() { //
- ['hierarchy']=>string() //
- ['name']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- ['subatoms']=>array() // This is an undocumentably-complex recursive array, typically containing a huge amount of seemingly disorganized data. Avoid this like the plague.
- } //
- ['time_scale']=>integer() //
- ['display_scale']=>integer() // 1 = normal; 0.5 = half; 2 = double
- ['video']=>array() { //
- ['codec']=>string() //
- ['color_depth']=>integer() //
- ['color_depth_name']=>string() //
- ['resolution_x']=>double() //
- ['resolution_y']=>double() //
- } //
- ['wide']=>array() { //
- ['name']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
-
-
- ['real']=>array() { // Real (RealAudio / RealVideo) - audio/video
- ['chunks']=>array() { //
- [<x>]=>array() { //
- ['file_version']=>integer() //
- ['headers_count']=>integer() //
- ['length']=>integer() //
- ['name']=>string() //
- ['object_version']=>integer() //
- ['offset']=>integer() //
- } //
- [<x>]=>array() { //
- ['avg_bit_rate']=>integer() //
- ['avg_packet_size']=>integer() //
- ['data_offset']=>integer() //
- ['duration']=>integer() //
- ['flags']=>array() { //
- ['live_broadcast']=>boolean() //
- ['perfect_play']=>boolean() //
- ['save_enabled']=>boolean() //
- } //
- ['flags_raw']=>integer() //
- ['index_offset']=>integer() //
- ['length']=>integer() //
- ['max_bit_rate']=>integer() //
- ['max_packet_size']=>integer() //
- ['name']=>string() //
- ['num_packets']=>integer() //
- ['num_streams']=>integer() //
- ['object_version']=>integer() //
- ['offset']=>integer() //
- ['preroll']=>integer() //
- } //
- } //
- ['comments']=>array() { //
- ['artist']=>string() //
- ['comment']=>string() //
- ['title']=>string() //
- } //
- } //
-
-
- ['riff']=>array() { // RIFF (Resource Interchange File Format) - audio/video container format (AVI, WAV, CDDA, etc)
- ['AIFC']=>array() { //
- ['COMM']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['FVER']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['INST']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['MARK']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['SSND']=>array() { //
- [<x>]=>array() { //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- } //
- ['AIFF']=>array() { //
- ['(c) ']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['COMM']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['SSND']=>array() { //
- [<x>]=>array() { //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- } //
- ['AVI ']=>array() { //
- ['JUNK']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['hdrl']=>array() { //
- ['avih']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['odml']=>array() { //
- ['dmlh']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- } //
- ['strl']=>array() { //
- ['JUNK']=>array() { //
- [<x>]=>array() { //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['strf']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['strh']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['strn']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- } //
- } //
- ['idx1']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['movi']=>array() { //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['CDDA']=>array() { //
- ['fmt ']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['disc_id']=>integer() //
- ['offset']=>integer() //
- ['playtime_frames']=>integer() //
- ['playtime_seconds']=>double() //
- ['size']=>integer() //
- ['start_offset_frame']=>integer() //
- ['start_offset_seconds']=>double() //
- ['track_num']=>integer() //
- ['unknown1']=>integer() //
- ['unknown6']=>integer() //
- ['unknown7']=>integer() //
- } //
- } //
- } //
- ['WAVE']=>array() { //
- ['DISP']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['INFO']=>array() { //
- ['IART']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['ICMT']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['ICOP']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['IENG']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['IGNR']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['IKEY']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['IMED']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['INAM']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['ISBJ']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['ISFT']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['ISRC']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['ISRF']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['ITCH']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- } //
- ['MEXT']=>array() { //
- [<x>]=>array() { //
- ['anciliary_data_length']=>integer() //
- ['data']=>string() //
- ['flags']=>array() { //
- ['anciliary_data_free']=>boolean() //
- ['anciliary_data_left']=>boolean() //
- ['anciliary_data_right']=>boolean() //
- ['homogenous']=>boolean() //
- } //
- ['offset']=>integer() //
- ['raw']=>array() { //
- ['anciliary_data_def']=>integer() //
- ['sound_information']=>integer() //
- } //
- ['size']=>integer() //
- } //
- } //
- ['bext']=>array() { //
- [<x>]=>array() { //
- ['author']=>string() //
- ['bwf_version']=>integer() //
- ['coding_history']=>array() { //
- [<x>]=>string() //
- } //
- ['data']=>string() //
- ['offset']=>integer() //
- ['origin_date']=>string() //
- ['origin_date_unix']=>integer() //
- ['origin_time']=>string() //
- ['reference']=>string() //
- ['reserved']=>integer() //
- ['size']=>integer() //
- ['time_reference']=>integer() //
- ['title']=>string() //
- } //
- } //
- ['cart']=>array() { //
- [<x>]=>array() { //
- ['artist']=>string() //
- ['category']=>string() //
- ['classification']=>string() //
- ['client_id']=>string() //
- ['cut_id']=>string() //
- ['data']=>string() //
- ['end_date']=>string() //
- ['end_time']=>string() //
- ['offset']=>integer() //
- ['out_cue']=>string() //
- ['post_time']=>array() { //
- [<x>]=>array() { //
- ['timer_value']=>integer() //
- ['usage_fourcc']=>string() //
- } //
- } //
- ['producer_app_id']=>string() //
- ['producer_app_version']=>string() //
- ['size']=>integer() //
- ['start_date']=>string() //
- ['start_time']=>string() //
- ['tag_text']=>array() { //
- [<x>]=>string() //
- } //
- ['title']=>string() //
- ['url']=>string() //
- ['user_defined_text']=>string() //
- ['version']=>string() //
- ['zero_db_reference']=>integer() //
- } //
- } //
- ['data']=>array() { //
- [<x>]=>array() { //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['fact']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['fmt ']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- ['rgad']=>array() { //
- [<x>]=>array() { //
- ['data']=>string() //
- ['offset']=>integer() //
- ['size']=>integer() //
- } //
- } //
- } //
- ['audio']=>array() { //
- [<x>]=>array() { //
- ['bitrate']=>integer() //
- ['bits_per_sample']=>integer() //
- ['channels']=>integer() //
- ['codec']=>string() //
- ['sample_rate']=>integer() //
- } //
- ['bits_per_sample']=>integer() //
- ['channels']=>integer() //
- ['codec_fourcc']=>string() //
- ['codec_name']=>string() //
- ['sample_rate']=>integer() //
- ['total_samples']=>integer() //
- } //
- ['comments']=>array() { // array of array of strings containing best data from any available metainformation tag (APE, ID3v2, ID3v1, Lyrics3, Vorbis, ASF, RIFF, Real, etc.)
- [<key name>]=>array() // <key name> can be anything, usually 'artist', 'title', etc. Contains array of one or more values (eg: multiple artists are possible)
- } //
- ['header_size']=>integer() //
- ['raw']=>array() { //
- ['avih']=>array() { //
- ['dwFlags']=>integer() //
- ['dwHeight']=>integer() //
- ['dwInitialFrames']=>integer() //
- ['dwLength']=>integer() //
- ['dwMaxBytesPerSec']=>integer() //
- ['dwMicroSecPerFrame']=>integer() //
- ['dwPaddingGranularity']=>integer() //
- ['dwRate']=>integer() //
- ['dwScale']=>integer() //
- ['dwStart']=>integer() //
- ['dwStreams']=>integer() //
- ['dwSuggestedBufferSize']=>integer() //
- ['dwTotalFrames']=>integer() //
- ['dwWidth']=>integer() //
- ['flags']=>array() { //
- ['capturedfile']=>boolean() //
- ['copyrighted']=>boolean() //
- ['hasindex']=>boolean() //
- ['interleaved']=>boolean() //
- ['mustuseindex']=>boolean() //
- ['trustcktype']=>boolean() //
- } //
- } //
- ['fact']=>array() { //
- ['NumberOfSamples']=>integer() //
- } //
- ['fmt ']=>array() { //
- ['nAvgBytesPerSec']=>integer() //
- ['wBitsPerSample']=>integer() //
- ['nBlockAlign']=>integer() //
- ['nChannels']=>integer() //
- ['nSamplesPerSec']=>integer() //
- ['wFormatTag']=>integer() //
- } //
- ['rgad']=>array() { //
- ['audiophile']=>array() { //
- ['adjustment']=>integer() //
- ['name']=>integer() //
- ['originator']=>integer() //
- ['signbit']=>integer() //
- } //
- ['fPeakAmplitude']=>double() //
- ['nAudiophileRgAdjust']=>integer() //
- ['nRadioRgAdjust']=>integer() //
- ['radio']=>array() { //
- ['adjustment']=>integer() //
- ['name']=>integer() //
- ['originator']=>integer() //
- ['signbit']=>integer() //
- } //
- } //
- ['strf']=>array() { //
- ['auds']=>array() { //
- [<x>]=>array() { //
- ['nAvgBytesPerSec']=>integer() //
- ['wBitsPerSample']=>integer() //
- ['nBlockAlign']=>integer() //
- ['nChannels']=>integer() //
- ['nSamplesPerSec']=>integer() //
- ['wFormatTag']=>integer() //
- } //
- } //
- ['vids']=>array() { //
- [<x>]=>array() { //
- ['biBitCount']=>integer() //
- ['biClrImportant']=>integer() //
- ['biClrUsed']=>integer() //
- ['biHeight']=>integer() //
- ['biPlanes']=>integer() //
- ['biSize']=>integer() //
- ['biSizeImage']=>integer() //
- ['biWidth']=>integer() //
- ['biXPelsPerMeter']=>integer() //
- ['biYPelsPerMeter']=>integer() //
- ['fourcc']=>string() //
- } //
- } //
- } //
- ['strh']=>array() { //
- [<x>]=>array() { //
- ['dwFlags']=>integer() //
- ['dwInitialFrames']=>integer() //
- ['dwLength']=>integer() //
- ['dwQuality']=>integer() //
- ['dwRate']=>integer() //
- ['dwSampleSize']=>integer() //
- ['dwScale']=>integer() //
- ['dwStart']=>integer() //
- ['dwSuggestedBufferSize']=>integer() //
- ['fccHandler']=>string() //
- ['fccType']=>string() //
- ['rcFrame']=>integer() //
- ['wLanguage']=>integer() //
- ['wPriority']=>integer() //
- } //
- } //
- } //
- ['rgad']=>array() { //
- ['audiophile']=>array() { //
- ['adjustment']=>double() //
- ['name']=>string() //
- ['originator']=>string() //
- } //
- ['peakamplitude']=>double() //
- ['radio']=>array() { //
- ['adjustment']=>double() //
- ['name']=>string() //
- ['originator']=>string() //
- } //
- } //
- ['video']=>array() { //
- [<x>]=>array() { //
- ['codec']=>string() //
- ['frame_height']=>integer() //
- ['frame_rate']=>double() //
- ['frame_width']=>integer() //
- } //
- } //
- ['litewave']=>array() { // http://www.clearjump.com
- ['raw']=>array() { //
- ['compression_method']=>integer() // 1=lossy; 2=lossless
- ['compression_flags']=>integer() //
- ['m_dwScale']=>integer() // scalefactor for lossy compression - related to m_wQuality as: $m_wQuality = round((2000 - $m_dwScale) / 20)
- ['m_dwBlockSize']=>integer() // number of samples in encoded blocks
- ['m_wQuality']=>integer() // quality factor (0=most compressed lossy; 99=best quality lossy; 100=lossless)
- ['m_wMarkDistance']=>integer() // distance between marks in bytes
- ['m_wReserved']=>integer() //
- ['m_dwOrgSize']=>integer() // original file size in bytes
- ['m_bFactExists']=>integer() // indicates if 'fact' chunk exists in the original file
- ['m_dwRiffChunkSize']=>integer() // riff chunk size in the original file
- } //
- ['quality_factor']=>integer() // alias of ['raw']['m_wQuality']
- } //
- } //
-
-
- ['shn']=>array() { // Shorten - lossless audio compression
- ['seektable']=>array() { //
- ['length']=>integer() //
- ['offset']=>integer() //
- ['present']=>boolean() //
- } //
- ['version']=>integer() //
- } //
-
-
- ['swf']=>array() { // SWF - ShockWave Flash (www.openswf.org)
- ['header']=>array() { //
- ['frame_count']=>integer() //
- ['frame_height']=>integer() //
- ['frame_width']=>integer() //
- ['length']=>integer() //
- ['signature']=>string() //
- ['version']=>integer() //
- } //
- ['bgcolor']=>string() //
- ['tags']=>array() //
- } //
-
-
- ['voc']=>array() { // VOC - SoundBlaster VOC audio format
- ['blocks']=>array() { //
- [<x>]=>array() { //
- ['bits_per_sample']=>integer() //
- ['block_offset']=>integer() //
- ['block_size']=>integer() //
- ['block_type_id']=>integer() //
- ['channels']=>integer() //
- ['compression_name']=>string() //
- ['compression_type']=>integer() //
- ['pack_method']=>integer() //
- ['sample_rate']=>integer() //
- ['sample_rate_id']=>integer() //
- ['stereo']=>boolean() //
- ['time_constant']=>integer() //
- ['wFormat']=>integer() //
- } //
- } //
- ['compressed_bits_per_sample']=>integer() //
- ['header']=>array() { //
- ['datablock_offset']=>integer() //
- ['major_version']=>integer() //
- ['minor_version']=>integer() //
- } //
- } //
-
-
- ['vqf']=>array() { // VQF - transform-domain weighted interleave Vector Quantization Format (lossy audio)
- ['COMM']=>array() { //
- ['bitrate']=>integer() //
- ['channel_mode']=>integer() //
- ['sample_rate']=>integer() //
- ['security_level']=>integer() //
- } //
- ['DSIZ']=>integer() //
- ['comments']=>array() { // array of array of strings containing best data from any available metainformation tag (APE, ID3v2, ID3v1, Lyrics3, Vorbis, ASF, RIFF, Real, etc.)
- [<key name>]=>array() // <key name> can be anything, usually 'artist', 'title', etc. Contains array of one or more values (eg: multiple artists are possible)
- } //
- ['raw']=>array() { //
- ['header_tag']=>string() //
- ['size']=>integer() //
- ['version']=>string() //
- } //
- } //
-
-
- ['wavpack']=>array() { // WavPack - lossless audio compression
- ['bits']=>integer() //
- ['crc1']=>double() //
- ['crc2']=>integer() //
- ['extension']=>string() //
- ['extra_bc']=>string() //
- ['extras']=>string() //
- ['flags_raw']=>integer() //
- ['offset']=>integer() //
- ['shift']=>integer() //
- ['size']=>integer() //
- ['total_samples']=>integer() //
- ['version']=>integer() //
- } //
-
-
- ['zip']=>array() { // ZIP - lossless data compression
- ['central_directory']=>array() { //
- [<x>]=>array() { //
- ['compressed_size']=>integer() //
- ['compression_method']=>string() //
- ['create_version']=>string() //
- ['entry_offset']=>integer() //
- ['extract_version']=>string() //
- ['filename']=>string() //
- ['flags']=>array() { //
- ['compression_speed']=>string() //
- ['data_descriptor_used']=>boolean() //
- ['encrypted']=>boolean() //
- } //
- ['host_os']=>string() //
- ['last_modified_timestamp']=>integer() //
- ['offset']=>integer() //
- ['raw']=>array() { //
- ['compressed_size']=>integer() //
- ['compression_method']=>integer() //
- ['crc_32']=>double() //
- ['create_version']=>integer() //
- ['disk_number_start']=>integer() //
- ['external_file_attrib']=>double() //
- ['extra_field_length']=>integer() //
- ['extract_version']=>integer() //
- ['file_comment_length']=>integer() //
- ['filename_length']=>integer() //
- ['general_flags']=>integer() //
- ['internal_file_attrib']=>integer() //
- ['last_mod_file_date']=>integer() //
- ['last_mod_file_time']=>integer() //
- ['local_header_offset']=>integer() //
- ['signature']=>integer() //
- ['uncompressed_size']=>integer() //
- } //
- ['uncompressed_size']=>integer() //
- } //
- } //
- ['comments']=>array() { //
- ['comment']=>string() //
- } //
- ['compressed_size']=>integer() //
- ['compression_method']=>string() //
- ['compression_speed']=>string() //
- ['end_central_directory']=>array() { //
- ['comment']=>string() //
- ['comment_length']=>integer() //
- ['directory_entries_this_disk']=>integer() //
- ['directory_entries_total']=>integer() //
- ['directory_offset']=>integer() //
- ['directory_size']=>integer() //
- ['disk_number_current']=>integer() //
- ['disk_number_start_directory']=>integer() //
- ['offset']=>integer() //
- ['signature']=>integer() //
- } //
- ['entries']=>array() { //
- [<x>]=>array() { //
- ['compressed_size']=>integer() //
- ['compression_method']=>string() //
- ['extract_version']=>string() //
- ['filename']=>string() //
- ['flags']=>array() { //
- ['compression_speed']=>string() //
- ['data_descriptor_used']=>boolean() //
- ['encrypted']=>boolean() //
- } //
- ['host_os']=>string() //
- ['last_modified_timestamp']=>integer() //
- ['offset']=>integer() //
- ['raw']=>array() { //
- ['compressed_size']=>integer() //
- ['compression_method']=>integer() //
- ['crc_32']=>integer() //
- ['extra_field_length']=>integer() //
- ['extract_version']=>integer() //
- ['filename_length']=>integer() //
- ['general_flags']=>integer() //
- ['last_mod_file_date']=>integer() //
- ['last_mod_file_time']=>integer() //
- ['signature']=>integer() //
- ['uncompressed_size']=>integer() //
- } //
- ['uncompressed_size']=>integer() //
- } //
- } //
- ['entries_count']=>integer() //
- ['files']=>array() { // multidimensional tree-structure array listing of all files and directories in image
- [<directory name>]=>array() // entries of type array are directories (key is directory name), may contain files and/or other subdirectories
- [<file name>]=>integer() // entries of type integer are files (key is file name, value is file size in bytes)
- } //
- ['uncompressed_size']=>integer() //
- } //
-} //
diff --git a/apps/media/js/loader.js b/apps/media/js/loader.js
index a832180d1e3..514965666fa 100644
--- a/apps/media/js/loader.js
+++ b/apps/media/js/loader.js
@@ -1,5 +1,5 @@
function musicTypeFromFile(file){
- var extention=file.substr(file.indexOf('.')+1);
+ var extention=file.substr(file.indexOf('.')+1).toLowerCase();
if(extention=='ogg'){
return 'oga';
}
@@ -56,4 +56,4 @@ $(document).ready(function() {
loadPlayer();
}
}
-}); \ No newline at end of file
+});
diff --git a/apps/media/js/music.js b/apps/media/js/music.js
index 1ffe4e10087..f93f0fded62 100644
--- a/apps/media/js/music.js
+++ b/apps/media/js/music.js
@@ -48,7 +48,7 @@ function getUrlVars(){
}
function musicTypeFromFile(file){
- var extention=file.split('.').pop();
+ var extention=file.split('.').pop().toLowerCase();
if(extention=='ogg'){
return 'oga';
}
diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php
index 39658b27ba9..341f411bdb8 100644
--- a/apps/media/lib_scanner.php
+++ b/apps/media/lib_scanner.php
@@ -21,7 +21,7 @@
*
*/
-require_once('getID3/getid3/getid3.php');
+require_once('getid3/getid3.php');
//class for scanning directories for music
class OC_MEDIA_SCANNER{
diff --git a/apps/user_openid/templates/settings.php b/apps/user_openid/templates/settings.php
index 7c742030ce3..24dfaa17891 100644
--- a/apps/user_openid/templates/settings.php
+++ b/apps/user_openid/templates/settings.php
@@ -1,7 +1,7 @@
<form id="openidform">
<fieldset class="personalblock">
<strong>OpenID</strong>
- <?php echo ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].OC::$WEBROOT.'/?'; echo OC_User::getUser(); ?><br /><em><?php echo $l->t('you can authenticate to other sites with this address');?></em><br />
+ <?php echo ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http').'://'.OC_Helper::serverHost().OC::$WEBROOT.'/?'; echo OC_User::getUser(); ?><br /><em><?php echo $l->t('you can authenticate to other sites with this address');?></em><br />
<label for="identity"><?php echo $l->t('Authorized OpenID provider');?></label>
<input type="text" name="identity" id="identity" value="<?php echo $_['identity']; ?>" placeholder="<?php echo $l->t('Your address at Wordpress, Identi.ca, &hellip;');?>" /><span class="msg"></span>
</fieldset>
diff --git a/core/ajax/appconfig.php b/core/ajax/appconfig.php
index 50984ac32b9..f815d710631 100644
--- a/core/ajax/appconfig.php
+++ b/core/ajax/appconfig.php
@@ -11,7 +11,7 @@ $action=isset($_POST['action'])?$_POST['action']:$_GET['action'];
$result=false;
switch($action){
case 'getValue':
- $result=OC_Appconfig::getValue($_GET['app'],$_GET['key'],$_GET['default']);
+ $result=OC_Appconfig::getValue($_GET['app'],$_GET['key'],$_GET['defaultValue']);
break;
case 'setValue':
$result=OC_Appconfig::setValue($_POST['app'],$_POST['key'],$_POST['value']);
diff --git a/core/ajax/vcategories/delete.php b/core/ajax/vcategories/delete.php
index 602ee1d74a4..75def433d30 100644
--- a/core/ajax/vcategories/delete.php
+++ b/core/ajax/vcategories/delete.php
@@ -17,7 +17,7 @@ function debug($msg) {
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
-$app = isset($_GET['app'])?$_GET['app']:null;
+$app = isset($_POST['app'])?$_POST['app']:null;
$categories = isset($_POST['categories'])?$_POST['categories']:null;
if(is_null($app)) {
bailOut(OC_Contacts_App::$l10n->t('Application name not provided.'));
diff --git a/core/css/oc-vcategories.css b/core/css/oc-vcategories.css
deleted file mode 100644
index 68ff832bb06..00000000000
--- a/core/css/oc-vcategories.css
+++ /dev/null
@@ -1,7 +0,0 @@
-#categoryform .scrollarea { position: absolute; left: 10px; top: 10px; right: 10px; bottom: 50px; overflow: auto; border:1px solid #ddd; background: #f8f8f8; }
-#categoryform .bottombuttons { position: absolute; bottom: 10px;}
-#categoryform .bottombuttons * { float: left;}
-/*#categorylist { border:1px solid #ddd;}*/
-#categorylist li { background:#f8f8f8; padding:.3em .8em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; -webkit-transition:background-color 500ms; -moz-transition:background-color 500ms; -o-transition:background-color 500ms; transition:background-color 500ms; }
-#categorylist li:hover, li:active { background:#eee; }
-#category_addinput { width: 10em; }
diff --git a/core/css/styles.css b/core/css/styles.css
index e5380b1b6b0..5cc15f4b5b6 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -106,7 +106,7 @@ label.infield { cursor: text !important; }
#notification { z-index:101; cursor:pointer; background-color:#fc4; border:0; padding:0 .7em .3em; display:none; position:fixed; left:50%; top:0; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; }
-.action, .selectedActions a, #logout { opacity:.3; -webkit-transition:opacity 500ms; -moz-transition:opacity 500ms; -o-transition:opacity 500ms; transition:opacity 500ms; }
+.action, .selectedActions a, #logout { opacity:.5; -webkit-transition:opacity 500ms; -moz-transition:opacity 500ms; -o-transition:opacity 500ms; transition:opacity 500ms; }
.action { width: 16px; height: 16px; }
.action:hover, .selectedActions a:hover, #logout:hover { opacity:1; }
@@ -132,9 +132,19 @@ li.error { width:640px; margin:4em auto; padding:1em 1em 1em 4em; background:#ff
a.bookmarklet { background-color: #ddd; border:1px solid #ccc; padding: 5px;padding-top: 0px;padding-bottom: 2px; text-decoration: none; margin-top: 5px }
-/* ---- DIALOGS ---- */
+/* ---- DIALOGS ---- */
#dirtree {width: 100%;}
#filelist {height: 270px; overflow:scroll; background-color: white;}
.filepicker_element_selected { background-color: lightblue;}
.filepicker_loader {height: 120px; width: 100%; background-color: #333; opacity: 0.3; visibility: visible; position:absolute; top:0; left:0; text-align:center; padding-top: 150px;}
+
+
+/* ---- CATEGORIES ---- */
+#categoryform .scrollarea { position: absolute; left: 10px; top: 10px; right: 10px; bottom: 50px; overflow: auto; border:1px solid #ddd; background: #f8f8f8; }
+#categoryform .bottombuttons { position: absolute; bottom: 10px;}
+#categoryform .bottombuttons * { float: left;}
+/*#categorylist { border:1px solid #ddd;}*/
+#categorylist li { background:#f8f8f8; padding:.3em .8em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; -webkit-transition:background-color 500ms; -moz-transition:background-color 500ms; -o-transition:background-color 500ms; transition:background-color 500ms; }
+#categorylist li:hover, li:active { background:#eee; }
+#category_addinput { width: 10em; }
diff --git a/core/js/config.js b/core/js/config.js
index 500fe072a64..11168f1c483 100644
--- a/core/js/config.js
+++ b/core/js/config.js
@@ -31,7 +31,7 @@ OC.AppConfig={
callback=defaultValue;
defaultValue=null;
}
- OC.AppConfig.getCall('getValue',{app:app,key:key,default:defaultValue},callback);
+ OC.AppConfig.getCall('getValue',{app:app,key:key,defaultValue:defaultValue},callback);
},
setValue:function(app,key,value){
OC.AppConfig.postCall('setValue',{app:app,key:key,value:value});
diff --git a/core/js/js.js b/core/js/js.js
index 44b4f503b8c..7e8ca6164c6 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -413,9 +413,10 @@ $(document).ready(function(){
$('.jp-controls .jp-previous').tipsy({gravity:'nw', fade:true, live:true});
$('.jp-controls .jp-next').tipsy({gravity:'n', fade:true, live:true});
$('.password .action').tipsy({gravity:'se', fade:true, live:true});
- $('.file_upload_button_wrapper').tipsy({gravity:'w', fade:true});
- $('.selectedActions a.delete').tipsy({gravity: 'se', fade:true, live:true});
+ $('.file_upload_button_wrapper').tipsy({gravity:'w', fade:true});
$('.selectedActions a').tipsy({gravity:'s', fade:true, live:true});
+ $('a.delete').tipsy({gravity: 'se', fade:true, live:true});
+ $('a.action').tipsy({gravity:'s', fade:true, live:true});
$('#headerSize').tipsy({gravity:'s', fade:true, live:true});
$('td.filesize').tipsy({gravity:'s', fade:true, live:true});
$('td .modified').tipsy({gravity:'s', fade:true, live:true});
diff --git a/core/js/oc-vcategories.js b/core/js/oc-vcategories.js
index e3b1abba08d..4d8d010a36f 100644
--- a/core/js/oc-vcategories.js
+++ b/core/js/oc-vcategories.js
@@ -53,25 +53,21 @@ OCCategories={
}
});
},
+ _processDeleteResult:function(jsondata, status, xhr){
+ if(jsondata.status == 'success'){
+ OCCategories._update(jsondata.data.categories);
+ } else {
+ OC.dialogs.alert(jsondata.data.message, 'Error');
+ }
+ },
doDelete:function(){
var categories = $('#categorylist').find('input[type="checkbox"]').serialize();
categories += '&app=' + OCCategories.app;
console.log('OCCategories.delete: ' + categories);
- $.post(OC.filePath(OCCategories.app, 'ajax', 'categories/delete.php'),categories,function(jsondata, status, xhr){
- if (status == 'error' && xhr.status == 404) {
- $.post(OC.filePath('core', 'ajax', 'vcategories/delete.php'),categories,function(jsondata, status, xhr){
- if(jsondata.status == 'success'){
- OCCategories._update(jsondata.data.categories);
- } else {
- OC.dialogs.alert(jsondata.data.message, 'Error');
- }
- });
- return;
- }
- if(jsondata.status == 'success'){
- OCCategories._update(jsondata.data.categories);
- } else {
- OC.dialogs.alert(jsondata.data.message, 'Error');
+ $.post(OC.filePath(OCCategories.app, 'ajax', 'categories/delete.php'), categories, OCCategories._processDeleteResult)
+ .error(function(xhr){
+ if (xhr.status == 404) {
+ $.post(OC.filePath('core', 'ajax', 'vcategories/delete.php'), categories, OCCategories._processDeleteResult);
}
});
},
@@ -88,16 +84,16 @@ OCCategories={
},
rescan:function(){
console.log('Categories.rescan');
- $.getJSON(OC.filePath(OCCategories.app, 'ajax', 'categories/rescan.php'),{},function(jsondata, status, xhr){
- if (status == 'error' && xhr.status == 404) {
- OC.dialogs.alert('The required file ' + OC.filePath(Categories.app, 'ajax', 'categories/rescan.php') + ' is not installed!', 'Error');
- return;
- }
+ $.getJSON(OC.filePath(OCCategories.app, 'ajax', 'categories/rescan.php'),function(jsondata, status, xhr){
if(jsondata.status == 'success'){
OCCategories._update(jsondata.data.categories);
} else {
OC.dialogs.alert(jsondata.data.message, 'Error');
}
+ }).error(function(xhr){
+ if (xhr.status == 404) {
+ OC.dialogs.alert('The required file ' + OC.filePath(Categories.app, 'ajax', 'categories/rescan.php') + ' is not installed!', 'Error');
+ }
});
},
_update:function(categories){
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index c048653cce9..85cf0899792 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -31,7 +31,7 @@
<form class="searchbox" action="#" method="post">
<input id="searchbox" class="svg" type="search" name="query" value="<?php if(isset($_POST['query'])){echo $_POST['query'];};?>" autocomplete="off" />
</form>
- <a id="logout" href="<?php echo link_to('', 'index.php'); ?>?logout=true"><img class="svg" alt="<?php echo $l->t('Log out');?>" src="<?php echo image_path('', 'actions/logout.svg'); ?>" /></a>
+ <a id="logout" href="<?php echo link_to('', 'index.php'); ?>?logout=true"><img class="svg" alt="<?php echo $l->t('Log out');?>" title="<?php echo $l->t('Log out');?>" src="<?php echo image_path('', 'actions/logout.svg'); ?>" /></a>
</div></header>
<nav><div id="navigation">
diff --git a/files/admin.php b/files/admin.php
index 1fe1ff55a4c..4ae3ee51236 100644
--- a/files/admin.php
+++ b/files/admin.php
@@ -28,22 +28,25 @@ require_once('../lib/base.php');
OC_Util::checkAdminUser();
$htaccessWorking=(getenv('htaccessWorking')=='true');
+
+$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
+$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
+$maxUploadFilesize = OC_Helper::humanFileSize(min($upload_max_filesize, $post_max_size));
if($_POST) {
if(isset($_POST['maxUploadSize'])){
- $maxUploadFilesize=$_POST['maxUploadSize'];
- OC_Files::setUploadLimit(OC_Helper::computerFileSize($maxUploadFilesize));
+ if(($setMaxSize = OC_Files::setUploadLimit(OC_Helper::computerFileSize($_POST['maxUploadSize']))) !== false) {
+ $maxUploadFilesize = OC_Helper::humanFileSize($setMaxSize);
+ }
}
if(isset($_POST['maxZipInputSize'])) {
$maxZipInputSize=$_POST['maxZipInputSize'];
OC_Config::setValue('maxZipInputSize', OC_Helper::computerFileSize($maxZipInputSize));
}
- OC_Config::setValue('allowZipDownload', isset($_POST['allowZipDownload']));
-}else{
- $upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
- $post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
- $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
- $maxZipInputSize = OC_Helper::humanfilesize(OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB')));
+ if(isset($_POST['submitFilesAdminSettings'])) {
+ OC_Config::setValue('allowZipDownload', isset($_POST['allowZipDownload']));
+ }
}
+$maxZipInputSize = OC_Helper::humanFileSize(OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB')));
$allowZipDownload = intval(OC_Config::getValue('allowZipDownload', true));
OC_App::setActiveNavigationEntry( "files_administration" );
@@ -51,6 +54,7 @@ OC_App::setActiveNavigationEntry( "files_administration" );
$tmpl = new OC_Template( 'files', 'admin' );
$tmpl->assign( 'htaccessWorking', $htaccessWorking );
$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
+$tmpl->assign( 'maxPossibleUploadSize', OC_Helper::humanFileSize(PHP_INT_MAX));
$tmpl->assign( 'allowZipDownload', $allowZipDownload);
$tmpl->assign( 'maxZipInputSize', $maxZipInputSize);
return $tmpl->fetchPage(); \ No newline at end of file
diff --git a/files/js/fileactions.js b/files/js/fileactions.js
index b33be280ad5..60c4fadedd0 100644
--- a/files/js/fileactions.js
+++ b/files/js/fileactions.js
@@ -66,7 +66,7 @@ FileActions={
if(img.call){
img=img(file);
}
- var html='<a href="#" title="'+name+'" class="action" style="display:none" />';
+ var html='<a href="#" original-title="'+name+'" class="action" style="display:none" />';
var element=$(html);
if(img){
element.append($('<img src="'+img+'"/>'));
@@ -89,7 +89,7 @@ FileActions={
if(img.call){
img=img(file);
}
- var html='<a href="#" title="Delete" class="action" style="display:none" />';
+ var html='<a href="#" original-title="Delete" class="action delete" style="display:none" />';
var element=$(html);
if(img){
element.append($('<img src="'+img+'"/>'));
diff --git a/files/templates/admin.php b/files/templates/admin.php
index fd86d02e1ed..9bcc40e9361 100644
--- a/files/templates/admin.php
+++ b/files/templates/admin.php
@@ -4,12 +4,12 @@
<fieldset class="personalblock">
<legend><strong><?php echo $l->t('File handling');?></strong></legend>
<?php if($_['htaccessWorking']):?>
- <label for="maxUploadSize"><?php echo $l->t( 'Maximum upload size' ); ?> </label><input name='maxUploadSize' id="maxUploadSize" value='<?php echo $_['uploadMaxFilesize'] ?>'/><br/>
+ <label for="maxUploadSize"><?php echo $l->t( 'Maximum upload size' ); ?> </label><input name='maxUploadSize' id="maxUploadSize" value='<?php echo $_['uploadMaxFilesize'] ?>'/>(<?php echo $l->t('max. possible: '); echo $_['maxPossibleUploadSize'] ?>)<br/>
<?php endif;?>
<input type="checkbox" name="allowZipDownload" id="allowZipDownload" value="1" title="<?php echo $l->t( 'Needed for multi-file and folder downloads.' ); ?>"<?php if ($_['allowZipDownload']) echo ' checked="checked"'; ?> /> <label for="allowZipDownload"><?php echo $l->t( 'Enable ZIP-download' ); ?></label> <br/>
<fieldset class="personalblock">
<label for="maxZipInputSize"><?php echo $l->t( 'Maximum input size for ZIP files:' ); ?> </label><input name="maxZipInputSize" id="maxZipInputSize" value='<?php echo $_['maxZipInputSize'] ?>' title="<?php echo $l->t( '0 is unlimited' ); ?>"<?php if (!$_['allowZipDownload']) echo ' disabled="disabled"'; ?> /><br/>
</fieldset>
- <input type="submit" value="Save"/>
+ <input type="submit" name="submitFilesAdminSettings" id="submitFilesAdminSettings" value="Save"/>
</fieldset>
</form>
diff --git a/lib/base.php b/lib/base.php
index 83dd0c98f45..f3dacdc0f76 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -265,7 +265,7 @@ class OC{
public static function init(){
// register autoloader
spl_autoload_register(array('OC','autoload'));
-
+ setlocale(LC_ALL, 'en_US.UTF-8');
// set some stuff
//ob_start();
@@ -346,7 +346,7 @@ class OC{
OC_User::useBackend( OC_Config::getValue( "userbackend", "database" ));
- OC_Group::setBackend( OC_Config::getValue( "groupbackend", "database" ));
+ OC_Group::useBackend(new OC_Group_Database());
// Set up file system unless forbidden
global $RUNTIME_NOSETUPFS;
diff --git a/lib/db.php b/lib/db.php
index 9c46a40addb..9364b9e0015 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -86,6 +86,7 @@ class OC_DB {
$user = OC_Config::getValue( "dbuser", "" );
$pass = OC_Config::getValue( "dbpassword", "" );
$type = OC_Config::getValue( "dbtype", "sqlite" );
+ $opts = array();
$datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT.'/data' );
// do nothing if the connection already has been established
@@ -100,13 +101,14 @@ class OC_DB {
break;
case 'mysql':
$dsn='mysql:dbname='.$name.';host='.$host;
+ $opts[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES 'UTF8'";
break;
case 'pgsql':
$dsn='pgsql:dbname='.$name.';host='.$host;
break;
}
try{
- self::$PDO=new PDO($dsn,$user,$pass);
+ self::$PDO=new PDO($dsn,$user,$pass,$opts);
}catch(PDOException $e){
echo( '<b>can not connect to database, using '.$type.'. ('.$e->getMessage().')</center>');
die();
diff --git a/lib/files.php b/lib/files.php
index a68c29ad989..051cfd4b81c 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -317,17 +317,54 @@ class OC_Files {
/**
* set the maximum upload size limit for apache hosts using .htaccess
* @param int size filesisze in bytes
+ * @return false on failure, size on success
*/
static function setUploadLimit($size){
- $size=OC_Helper::humanFileSize($size);
- $size=substr($size,0,-1);//strip the B
- $size=str_replace(' ','',$size); //remove the space between the size and the postfix
- $content = "ErrorDocument 404 /".OC::$WEBROOT."/core/templates/404.php\n";//custom 404 error page
- $content.= "php_value upload_max_filesize $size\n";//upload limit
- $content.= "php_value post_max_size $size\n";
- $content.= "SetEnv htaccessWorking true\n";
- $content.= "Options -Indexes\n";
- @file_put_contents(OC::$SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
+ //don't allow user to break his config -- upper boundary
+ if($size > PHP_INT_MAX) {
+ //max size is always 1 byte lower than computerFileSize returns
+ if($size > PHP_INT_MAX+1)
+ return false;
+ $size -=1;
+ } else {
+ $size=OC_Helper::humanFileSize($size);
+ $size=substr($size,0,-1);//strip the B
+ $size=str_replace(' ','',$size); //remove the space between the size and the postfix
+ }
+
+ //don't allow user to break his config -- broken or malicious size input
+ if(intval($size) == 0) {
+ return false;
+ }
+
+ $htaccess = @file_get_contents(OC::$SERVERROOT.'/.htaccess'); //supress errors in case we don't have permissions for
+ if(!$htaccess) {
+ return false;
+ }
+
+ $phpValueKeys = array(
+ 'upload_max_filesize',
+ 'post_max_size'
+ );
+
+ foreach($phpValueKeys as $key) {
+ $pattern = '/php_value '.$key.' (\S)*/';
+ $setting = 'php_value '.$key.' '.$size;
+ $hasReplaced = 0;
+ $content = preg_replace($pattern, $setting, $htaccess, 1, $hasReplaced);
+ if($content !== NULL) {
+ $htaccess = $content;
+ }
+ if($hasReplaced == 0) {
+ $htaccess .= "\n" . $setting;
+ }
+ }
+
+ //supress errors in case we don't have permissions for it
+ if(@file_put_contents(OC::$SERVERROOT.'/.htaccess', $htaccess)) {
+ return OC_Helper::computerFileSize($size);
+ }
+ return false;
}
/**
diff --git a/lib/filesystem.php b/lib/filesystem.php
index b6909f5acdf..dc678fba74c 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -249,6 +249,14 @@ class OC_Filesystem{
}
/**
+ * clear all mounts and storage backends
+ */
+ public static function clearMounts(){
+ self::$mounts=array();
+ self::$storages=array();
+ }
+
+ /**
* mount an OC_Filestorage in our virtual filesystem
* @param OC_Filestorage storage
* @param string mountpoint
diff --git a/lib/group.php b/lib/group.php
index fbff41e30e9..4ae9302f78b 100644
--- a/lib/group.php
+++ b/lib/group.php
@@ -34,57 +34,25 @@
* post_removeFromGroup(uid, gid)
*/
class OC_Group {
- // The backend used for user management
- private static $_backend;
-
- // Backends available (except database)
- private static $_backends = array();
-
- /**
- * @brief registers backend
- * @param $name name of the backend
- * @returns true/false
- *
- * Makes a list of backends that can be used by other modules
- */
- public static function registerBackend( $name ){
- self::$_backends[] = $name;
- return true;
- }
-
- /**
- * @brief gets available backends
- * @returns array of backends
- *
- * Returns the names of all backends.
- */
- public static function getBackends(){
- return self::$_backends;
- }
+ // The backend used for group management
+ private static $_usedBackends = array();
/**
* @brief set the group backend
* @param string $backend The backend to use for user managment
* @returns true/false
*/
- public static function setBackend( $backend = 'database' ){
- // You'll never know what happens
- if( null === $backend OR !is_string( $backend )){
- $backend = 'database';
+ public static function useBackend( $backend ){
+ if($backend instanceof OC_Group_Backend){
+ self::$_usedBackends[]=$backend;
}
+ }
- // Load backend
- switch( $backend ){
- case 'database':
- case 'mysql':
- case 'sqlite':
- self::$_backend = new OC_Group_Database();
- break;
- default:
- $className = 'OC_GROUP_' . strToUpper($backend);
- self::$_backend = new $className();
- break;
- }
+ /**
+ * remove all used backends
+ */
+ public static function clearBackends(){
+ self::$_usedBackends=array();
}
/**
@@ -115,11 +83,18 @@ class OC_Group {
$run = true;
OC_Hook::emit( "OC_Group", "pre_createGroup", array( "run" => &$run, "gid" => $gid ));
- if( $run && self::$_backend->createGroup( $gid )){
- OC_Hook::emit( "OC_Group", "post_createGroup", array( "gid" => $gid ));
- return true;
- }
- else{
+ if($run){
+ //create the user in the first backend that supports creating users
+ foreach(self::$_usedBackends as $backend){
+ if(!$backend->implementsActions(OC_GROUP_BACKEND_CREATE_GROUP))
+ continue;
+
+ $backend->createGroup($gid);
+ OC_Hook::emit( "OC_User", "post_createGroup", array( "gid" => $gid ));
+
+ return true;
+ }
+ }else{
return false;
}
}
@@ -140,11 +115,18 @@ class OC_Group {
$run = true;
OC_Hook::emit( "OC_Group", "pre_deleteGroup", array( "run" => &$run, "gid" => $gid ));
- if( $run && self::$_backend->deleteGroup( $gid )){
- OC_Hook::emit( "OC_Group", "post_deleteGroup", array( "gid" => $gid ));
- return true;
- }
- else{
+ if($run){
+ //delete the group from all backends
+ foreach(self::$_usedBackends as $backend){
+ if(!$backend->implementsActions(OC_GROUP_BACKEND_DELETE_GROUP))
+ continue;
+
+ $backend->deleteGroup($gid);
+ OC_Hook::emit( "OC_User", "post_deleteGroup", array( "gid" => $gid ));
+
+ return true;
+ }
+ }else{
return false;
}
}
@@ -158,7 +140,15 @@ class OC_Group {
* Checks whether the user is member of a group or not.
*/
public static function inGroup( $uid, $gid ){
- return self::$_backend->inGroup($uid, $gid);
+ foreach(self::$_usedBackends as $backend){
+ if(!$backend->implementsActions(OC_GROUP_BACKEND_IN_GROUP))
+ continue;
+
+ if($backend->inGroup($uid,$gid)){
+ return true;
+ }
+ }
+ return false;
}
/**
@@ -170,10 +160,6 @@ class OC_Group {
* Adds a user to a group.
*/
public static function addToGroup( $uid, $gid ){
- // Does the user exist?
- if( !OC_User::userExists($uid)){
- return false;
- }
// Does the group exist?
if( !OC_Group::groupExists($gid)){
return false;
@@ -183,11 +169,19 @@ class OC_Group {
$run = true;
OC_Hook::emit( "OC_Group", "pre_addToGroup", array( "run" => &$run, "uid" => $uid, "gid" => $gid ));
- if( $run && self::$_backend->addToGroup( $uid, $gid )){
- OC_Hook::emit( "OC_Group", "post_addToGroup", array( "uid" => $uid, "gid" => $gid ));
- return true;
- }
- else{
+ if($run){
+ $succes=false;
+
+ //add the user to the all backends that have the group
+ foreach(self::$_usedBackends as $backend){
+ if(!$backend->implementsActions(OC_GROUP_BACKEND_ADD_TO_GROUP))
+ continue;
+
+ $succes|=$backend->addToGroup($uid, $gid);
+ OC_Hook::emit( "OC_User", "post_addToGroup", array( "uid" => $uid, "gid" => $gid ));
+ }
+ return $succes;
+ }else{
return false;
}
}
@@ -204,11 +198,17 @@ class OC_Group {
$run = true;
OC_Hook::emit( "OC_Group", "pre_removeFromGroup", array( "run" => &$run, "uid" => $uid, "gid" => $gid ));
- if( $run && self::$_backend->removeFromGroup( $uid, $gid )){
- OC_Hook::emit( "OC_Group", "post_removeFromGroup", array( "uid" => $uid, "gid" => $gid ));
+ if($run){
+ //remove the user from the all backends that have the group
+ foreach(self::$_usedBackends as $backend){
+ if(!$backend->implementsActions(OC_GROUP_BACKEND_REMOVE_FROM_GOUP))
+ continue;
+
+ $backend->removeFromGroup($uid, $gid);
+ OC_Hook::emit( "OC_User", "post_removeFromGroup", array( "uid" => $uid, "gid" => $gid ));
+ }
return true;
- }
- else{
+ }else{
return false;
}
}
@@ -222,7 +222,14 @@ class OC_Group {
* if the user exists at all.
*/
public static function getUserGroups( $uid ){
- return self::$_backend->getUserGroups($uid);
+ $groups=array();
+ foreach(self::$_usedBackends as $backend){
+ if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_USER_GROUPS))
+ continue;
+
+ $groups=array_merge($backend->getUserGroups($uid),$groups);
+ }
+ return $groups;
}
/**
@@ -232,7 +239,14 @@ class OC_Group {
* Returns a list with all groups
*/
public static function getGroups(){
- return self::$_backend->getGroups();
+ $groups=array();
+ foreach(self::$_usedBackends as $backend){
+ if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_GROUPS))
+ continue;
+
+ $groups=array_merge($backend->getGroups(),$groups);
+ }
+ return $groups;
}
/**
@@ -249,6 +263,13 @@ class OC_Group {
* @returns array with user ids
*/
public static function usersInGroup($gid){
- return self::$_backend->usersInGroup($gid);
+ $users=array();
+ foreach(self::$_usedBackends as $backend){
+ if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_USERS))
+ continue;
+
+ $users=array_merge($backend->usersInGroup($gid),$users);
+ }
+ return $users;
}
}
diff --git a/lib/group/backend.php b/lib/group/backend.php
index 43f94e7ea1a..b3fc06ac9a8 100644
--- a/lib/group/backend.php
+++ b/lib/group/backend.php
@@ -21,82 +21,65 @@
*
*/
+/**
+ * error code for functions not provided by the group backend
+ */
+define('OC_GROUP_BACKEND_NOT_IMPLEMENTED', -501);
+/**
+ * actions that user backends can define
+ */
+define('OC_GROUP_BACKEND_CREATE_GROUP', 0x00000001);
+define('OC_GROUP_BACKEND_DELETE_GROUP', 0x00000010);
+define('OC_GROUP_BACKEND_IN_GROUP', 0x00000100);
+define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00001000);
+define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00010000);
+define('OC_GROUP_BACKEND_GET_USER_GROUPS', 0x00100000);
+define('OC_GROUP_BACKEND_GET_USERS', 0x01000000);
+define('OC_GROUP_BACKEND_GET_GROUPS', 0x10000000);
/**
* Abstract base class for user management
*/
abstract class OC_Group_Backend {
+ protected $possibleActions = array(
+ OC_GROUP_BACKEND_CREATE_GROUP => 'createGroup',
+ OC_GROUP_BACKEND_DELETE_GROUP => 'deleteGroup',
+ OC_GROUP_BACKEND_IN_GROUP => 'inGroup',
+ OC_GROUP_BACKEND_ADD_TO_GROUP => 'addToGroup',
+ OC_GROUP_BACKEND_REMOVE_FROM_GOUP => 'removeFromGroup',
+ OC_GROUP_BACKEND_GET_USER_GROUPS => 'getUserGroups',
+ OC_GROUP_BACKEND_GET_USERS => 'usersInGroup',
+ OC_GROUP_BACKEND_GET_GROUPS => 'getGroups'
+ );
+
/**
- * @brief Try to create a new group
- * @param $gid The name of the group to create
- * @returns true/false
- *
- * Trys to create a new group. If the group name already exists, false will
- * be returned.
- */
- public static function createGroup($gid){}
-
- /**
- * @brief delete a group
- * @param $gid gid of the group to delete
- * @returns true/false
- *
- * Deletes a group and removes it from the group_user-table
- */
- public static function removeGroup($gid){}
-
- /**
- * @brief is user in group?
- * @param $uid uid of the user
- * @param $gid gid of the group
- * @returns true/false
- *
- * Checks whether the user is member of a group or not.
- */
- public static function inGroup($uid, $gid){}
-
- /**
- * @brief Add a user to a group
- * @param $uid Name of the user to add to group
- * @param $gid Name of the group in which add the user
- * @returns true/false
- *
- * Adds a user to a group.
- */
- public static function addToGroup($uid, $gid){}
-
- /**
- * @brief Removes a user from a group
- * @param $uid Name of the user to remove from group
- * @param $gid Name of the group from which remove the user
- * @returns true/false
- *
- * removes the user from a group.
- */
- public static function removeFromGroup($uid,$gid){}
-
- /**
- * @brief Get all groups a user belongs to
- * @param $uid Name of the user
- * @returns array with group names
- *
- * This function fetches all groups a user belongs to. It does not check
- * if the user exists at all.
- */
- public static function getUserGroups($uid){}
+ * @brief Get all supported actions
+ * @returns bitwise-or'ed actions
+ *
+ * Returns the supported actions as int to be
+ * compared with OC_USER_BACKEND_CREATE_USER etc.
+ */
+ public function getSupportedActions(){
+ $actions = 0;
+ foreach($this->possibleActions AS $action => $methodName){
+ if(method_exists($this, $methodName)) {
+ $actions |= $action;
+ }
+ }
- /**
- * @brief get a list of all groups
- * @returns array with group names
- *
- * Returns a list with all groups
- */
- public static function getGroups(){}
+ return $actions;
+ }
/**
- * @brief get a list of all users in a group
- * @returns array with user ids
- */
- public static function usersInGroup($gid){}
+ * @brief Check if backend implements actions
+ * @param $actions bitwise-or'ed actions
+ * @returns boolean
+ *
+ * Returns the supported actions as int to be
+ * compared with OC_GROUP_BACKEND_CREATE_GROUP etc.
+ */
+ public function implementsActions($actions){
+ return (bool)($this->getSupportedActions() & $actions);
+ }
}
diff --git a/lib/group/database.php b/lib/group/database.php
index 1afd4b5fe4c..d401acf43b3 100644
--- a/lib/group/database.php
+++ b/lib/group/database.php
@@ -117,8 +117,10 @@ class OC_Group_Database extends OC_Group_Backend {
if( !self::inGroup( $uid, $gid )){
$query = OC_DB::prepare( "INSERT INTO `*PREFIX*group_user` ( `uid`, `gid` ) VALUES( ?, ? )" );
$result = $query->execute( array( $uid, $gid ));
+ return true;
+ }else{
+ return false;
}
- return true;
}
/**
diff --git a/lib/group/dummy.php b/lib/group/dummy.php
new file mode 100644
index 00000000000..5220237ecbf
--- /dev/null
+++ b/lib/group/dummy.php
@@ -0,0 +1,159 @@
+<?php
+
+/**
+* ownCloud
+*
+* @author Frank Karlitschek
+* @copyright 2010 Frank Karlitschek karlitschek@kde.org
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+/**
+ * dummy group backend, does not keep state, only for testing use
+ */
+class OC_Group_Dummy extends OC_Group_Backend {
+ private $groups=array();
+ /**
+ * @brief Try to create a new group
+ * @param $gid The name of the group to create
+ * @returns true/false
+ *
+ * Trys to create a new group. If the group name already exists, false will
+ * be returned.
+ */
+ public function createGroup($gid){
+ if(!isset($this->groups[$gid])){
+ $this->groups[$gid]=array();
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+ /**
+ * @brief delete a group
+ * @param $gid gid of the group to delete
+ * @returns true/false
+ *
+ * Deletes a group and removes it from the group_user-table
+ */
+ public function deleteGroup($gid){
+ if(isset($this->groups[$gid])){
+ unset($this->groups[$gid]);
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+ /**
+ * @brief is user in group?
+ * @param $uid uid of the user
+ * @param $gid gid of the group
+ * @returns true/false
+ *
+ * Checks whether the user is member of a group or not.
+ */
+ public function inGroup($uid, $gid){
+ if(isset($this->groups[$gid])){
+ return (array_search($uid,$this->groups[$gid])!==false);
+ }else{
+ return false;
+ }
+ }
+
+ /**
+ * @brief Add a user to a group
+ * @param $uid Name of the user to add to group
+ * @param $gid Name of the group in which add the user
+ * @returns true/false
+ *
+ * Adds a user to a group.
+ */
+ public function addToGroup($uid, $gid){
+ if(isset($this->groups[$gid])){
+ if(array_search($uid,$this->groups[$gid])===false){
+ $this->groups[$gid][]=$uid;
+ return true;
+ }else{
+ return false;
+ }
+ }else{
+ return false;
+ }
+ }
+
+ /**
+ * @brief Removes a user from a group
+ * @param $uid NameUSER of the user to remove from group
+ * @param $gid Name of the group from which remove the user
+ * @returns true/false
+ *
+ * removes the user from a group.
+ */
+ public function removeFromGroup($uid,$gid){
+ if(isset($this->groups[$gid])){
+ if(($index=array_search($uid,$this->groups[$gid]))!==false){
+ unset($this->groups[$gid][$index]);
+ }else{
+ return false;
+ }
+ }else{
+ return false;
+ }
+ }
+
+ /**
+ * @brief Get all groups a user belongs to
+ * @param $uid Name of the user
+ * @returns array with group names
+ *
+ * This function fetches all groups a user belongs to. It does not check
+ * if the user exists at all.
+ */
+ public function getUserGroups($uid){
+ $groups=array();
+ foreach($this->groups as $group=>$user){
+ if($this->inGroup($uid,$group)){
+ $groups[]=$group;
+ }
+ }
+ return $groups;
+ }
+
+ /**
+ * @brief get a list of all groups
+ * @returns array with group names
+ *
+ * Returns a list with all groups
+ */
+ public function getGroups(){
+ return array_keys($this->groups);
+ }
+
+ /**
+ * @brief get a list of all users in a group
+ * @returns array with user ids
+ */
+ public function usersInGroup($gid){
+ if(isset($this->groups[$gid])){
+ return $this->groups[$gid];
+ }else{
+ return array();
+ }
+ }
+
+}
diff --git a/lib/group/example.php b/lib/group/example.php
new file mode 100644
index 00000000000..a88159f91be
--- /dev/null
+++ b/lib/group/example.php
@@ -0,0 +1,102 @@
+<?php
+
+/**
+* ownCloud
+*
+* @author Frank Karlitschek
+* @copyright 2010 Frank Karlitschek karlitschek@kde.org
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+/**
+ * abstract reference class for group management
+ * this class should only be used as a reference for method signatures and their descriptions
+ */
+abstract class OC_Group_Example {
+ /**
+ * @brief Try to create a new group
+ * @param $gid The name of the group to create
+ * @returns true/false
+ *
+ * Trys to create a new group. If the group name already exists, false will
+ * be returned.
+ */
+ public static function createGroup($gid){}
+
+ /**
+ * @brief delete a group
+ * @param $gid gid of the group to delete
+ * @returns true/false
+ *
+ * Deletes a group and removes it from the group_user-table
+ */
+ public static function deleteGroup($gid){}
+
+ /**
+ * @brief is user in group?
+ * @param $uid uid of the user
+ * @param $gid gid of the group
+ * @returns true/false
+ *
+ * Checks whether the user is member of a group or not.
+ */
+ public static function inGroup($uid, $gid){}
+
+ /**
+ * @brief Add a user to a group
+ * @param $uid Name of the user to add to group
+ * @param $gid Name of the group in which add the user
+ * @returns true/false
+ *
+ * Adds a user to a group.
+ */
+ public static function addToGroup($uid, $gid){}
+
+ /**
+ * @brief Removes a user from a group
+ * @param $uid NameUSER of the user to remove from group
+ * @param $gid Name of the group from which remove the user
+ * @returns true/false
+ *
+ * removes the user from a group.
+ */
+ public static function removeFromGroup($uid,$gid){}
+
+ /**
+ * @brief Get all groups a user belongs to
+ * @param $uid Name of the user
+ * @returns array with group names
+ *
+ * This function fetches all groups a user belongs to. It does not check
+ * if the user exists at all.
+ */
+ public static function getUserGroups($uid){}
+
+ /**
+ * @brief get a list of all groups
+ * @returns array with group names
+ *
+ * Returns a list with all groups
+ */
+ public static function getGroups(){}
+
+ /**
+ * @brief get a list of all users in a group
+ * @returns array with user ids
+ */
+ public static function usersInGroup($gid){}
+
+}
diff --git a/lib/helper.php b/lib/helper.php
index efff00c2fe6..f5626bccaa7 100755
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -60,6 +60,28 @@ class OC_Helper {
}
/**
+ * @brief Returns the server host
+ * @returns the server host
+ *
+ * Returns the server host, even if the website uses one or more
+ * reverse proxies
+ */
+ public static function serverHost() {
+ if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
+ if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ",") !== false) {
+ $host = trim(array_pop(explode(",", $_SERVER['HTTP_X_FORWARDED_HOST'])));
+ }
+ else{
+ $host=$_SERVER['HTTP_X_FORWARDED_HOST'];
+ }
+ }
+ else{
+ $host = $_SERVER['HTTP_HOST'];
+ }
+ return $host;
+ }
+
+ /**
* @brief Creates an absolute url
* @param $app app
* @param $file file
@@ -71,7 +93,7 @@ class OC_Helper {
$urlLinkTo = self::linkTo( $app, $file );
// Checking if the request was made through HTTPS. The last in line is for IIS
$protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off');
- $urlLinkTo = ($protocol?'https':'http') . '://' . $_SERVER['HTTP_HOST'] . $urlLinkTo;
+ $urlLinkTo = ($protocol?'https':'http') . '://' . self::serverHost() . $urlLinkTo;
return $urlLinkTo;
}
diff --git a/lib/user.php b/lib/user.php
index fda19a33154..8c27ec30cc2 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -186,7 +186,7 @@ class OC_User {
* @param $password The password of the user
* @returns true/false
*
- * Log in a user - if the password is ok
+ * Log in a user and regenerate a new session - if the password is ok
*/
public static function login( $uid, $password ){
$run = true;
@@ -195,6 +195,7 @@ class OC_User {
if( $run ){
$uid=self::checkPassword( $uid, $password );
if($uid){
+ session_regenerate_id();
self::setUserId($uid);
OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid, 'password'=>$password ));
return true;
@@ -221,7 +222,8 @@ class OC_User {
*/
public static function logout(){
OC_Hook::emit( "OC_User", "logout", array());
- $_SESSION['user_id'] = false;
+ session_unset();
+ session_destroy();
OC_User::unsetMagicInCookie();
return true;
}
diff --git a/lib/util.php b/lib/util.php
index 722b7404d0c..34f535d2d5c 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -66,7 +66,7 @@ class OC_Util {
* @return array
*/
public static function getVersion(){
- return array(3,00,4);
+ return array(3,80,0);
}
/**
@@ -74,7 +74,7 @@ class OC_Util {
* @return string
*/
public static function getVersionString(){
- return '3';
+ return '4 alpha';
}
/**
diff --git a/lib/vcategories.php b/lib/vcategories.php
index 5a7bacd2025..b3b6a493c8d 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -50,13 +50,12 @@ class OC_VCategories {
* parameter should normally be omitted but to make an app able to
* update categories for all users it is made possible to provide it.
* @param $defcategories An array of default categories to be used if none is stored.
- * NOTE: Not implemented.
*/
- public function __construct($app, $user=null, $defcategories=null) {
+ public function __construct($app, $user=null, $defcategories=array()) {
$this->app = $app;
$this->user = is_null($user) ? OC_User::getUser() : $user;
$categories = trim(OC_Preferences::getValue($this->user, $app, self::PREF_CATEGORIES_LABEL, ''));
- $this->categories = $categories != '' ? unserialize($categories) : array();
+ $this->categories = $categories != '' ? unserialize($categories) : $defcategories;
}
/**
@@ -65,6 +64,7 @@ class OC_VCategories {
*/
public function categories() {
OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG);
+ usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys
return $this->categories;
}
@@ -97,7 +97,6 @@ class OC_VCategories {
}
if(count($newones) > 0) {
$this->categories = array_merge($this->categories, $newones);
- natcasesort($this->categories); // Dunno if this is necessary
if($sync === true) {
$this->save();
}
@@ -147,6 +146,7 @@ class OC_VCategories {
* @brief Save the list with categories
*/
private function save() {
+ usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys
$escaped_categories = serialize($this->categories);
OC_Log::write('core','OC_VCategories::save: '.print_r($this->categories, true), OC_Log::DEBUG);
OC_Preferences::setValue($this->user, $this->app, self::PREF_CATEGORIES_LABEL, $escaped_categories);
diff --git a/tests/lib/filestorage/local.php b/tests/lib/filestorage/local.php
index 0a2d46c5ebc..692f05f9fca 100644
--- a/tests/lib/filestorage/local.php
+++ b/tests/lib/filestorage/local.php
@@ -26,10 +26,7 @@ class Test_Filestorage_Local extends Test_FileStorage {
*/
private $tmpDir;
public function setUp(){
- $this->tmpDir=get_temp_dir().'/filestoragelocal';
- if(!file_exists($this->tmpDir)){
- mkdir($this->tmpDir);
- }
+ $this->tmpDir=OC_Helper::tmpFolder();
$this->instance=new OC_Filestorage_Local(array('datadir'=>$this->tmpDir));
}
diff --git a/tests/lib/filesystem.php b/tests/lib/filesystem.php
new file mode 100644
index 00000000000..3e28d8c06e5
--- /dev/null
+++ b/tests/lib/filesystem.php
@@ -0,0 +1,64 @@
+<?php
+/**
+* ownCloud
+*
+* @author Robin Appelman
+* @copyright 2012 Robin Appelman icewind@owncloud.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+class Test_Filesystem extends UnitTestCase{
+ /**
+ * @var array tmpDirs
+ */
+ private $tmpDirs;
+
+ /**
+ * @return array
+ */
+ private function getStorageData(){
+ $dir=OC_Helper::tmpFolder();
+ $this->tmpDirs[]=$dir;
+ return array('datadir'=>$dir);
+ }
+
+ public function tearDown(){
+ foreach($this->tmpDirs as $dir){
+ OC_Helper::rmdirr($dir);
+ }
+ }
+
+ public function setUp(){
+ OC_Filesystem::clearMounts();
+ }
+
+ public function testMount(){
+ OC_Filesystem::mount('OC_Filestorage_Local',self::getStorageData(),'/');
+ $this->assertEqual('/',OC_Filesystem::getMountPoint('/'));
+ $this->assertEqual('/',OC_Filesystem::getMountPoint('/some/folder'));
+ $this->assertEqual('',OC_Filesystem::getInternalPath('/'));
+ $this->assertEqual('some/folder',OC_Filesystem::getInternalPath('/some/folder'));
+
+ OC_Filesystem::mount('OC_Filestorage_Local',self::getStorageData(),'/some');
+ $this->assertEqual('/',OC_Filesystem::getMountPoint('/'));
+ $this->assertEqual('/some/',OC_Filesystem::getMountPoint('/some/folder'));
+ $this->assertEqual('/some/',OC_Filesystem::getMountPoint('/some/'));
+ $this->assertEqual('/',OC_Filesystem::getMountPoint('/some'));
+ $this->assertEqual('folder',OC_Filesystem::getInternalPath('/some/folder'));
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/lib/group.php b/tests/lib/group.php
new file mode 100644
index 00000000000..922613211bc
--- /dev/null
+++ b/tests/lib/group.php
@@ -0,0 +1,114 @@
+<?php
+/**
+* ownCloud
+*
+* @author Robin Appelman
+* @copyright 2012 Robin Appelman icewind@owncloud.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+class Test_Group extends UnitTestCase {
+ function setUp(){
+ OC_Group::clearBackends();
+ }
+
+ function testSingleBackend(){
+ OC_Group::useBackend(new OC_Group_Dummy());
+
+ $group1=uniqid();
+ $group2=uniqid();
+ OC_Group::createGroup($group1);
+ OC_Group::createGroup($group2);
+
+ $user1=uniqid();
+ $user2=uniqid();
+
+ $this->assertFalse(OC_Group::inGroup($user1,$group1));
+ $this->assertFalse(OC_Group::inGroup($user2,$group1));
+ $this->assertFalse(OC_Group::inGroup($user1,$group2));
+ $this->assertFalse(OC_Group::inGroup($user2,$group2));
+
+ $this->assertTrue(OC_Group::addToGroup($user1,$group1));
+
+ $this->assertTrue(OC_Group::inGroup($user1,$group1));
+ $this->assertFalse(OC_Group::inGroup($user2,$group1));
+ $this->assertFalse(OC_Group::inGroup($user1,$group2));
+ $this->assertFalse(OC_Group::inGroup($user2,$group2));
+
+ $this->assertFalse(OC_Group::addToGroup($user1,$group1));
+
+ $this->assertEqual(array($user1),OC_Group::usersInGroup($group1));
+ $this->assertEqual(array(),OC_Group::usersInGroup($group2));
+
+ $this->assertEqual(array($group1),OC_Group::getUserGroups($user1));
+ $this->assertEqual(array(),OC_Group::getUserGroups($user2));
+
+ OC_Group::deleteGroup($group1);
+ $this->assertEqual(array(),OC_Group::getUserGroups($user1));
+ $this->assertEqual(array(),OC_Group::usersInGroup($group1));
+ $this->assertFalse(OC_Group::inGroup($user1,$group1));
+ }
+
+ function testMultiBackend(){
+ $backend1=new OC_Group_Dummy();
+ $backend2=new OC_Group_Dummy();
+ OC_Group::useBackend($backend1);
+ OC_Group::useBackend($backend2);
+
+ $group1=uniqid();
+ $group2=uniqid();
+ OC_Group::createGroup($group1);
+
+ //groups should be added to the first registered backend
+ $this->assertEqual(array($group1),$backend1->getGroups());
+ $this->assertEqual(array(),$backend2->getGroups());
+
+ $this->assertEqual(array($group1),OC_Group::getGroups());
+ $this->assertTrue(OC_Group::groupExists($group1));
+ $this->assertFalse(OC_Group::groupExists($group2));
+
+ $backend1->createGroup($group2);
+
+ $this->assertEqual(array($group1,$group2),OC_Group::getGroups());
+ $this->assertTrue(OC_Group::groupExists($group1));
+ $this->assertTrue(OC_Group::groupExists($group2));
+
+ $user1=uniqid();
+ $user2=uniqid();
+
+ $this->assertFalse(OC_Group::inGroup($user1,$group1));
+ $this->assertFalse(OC_Group::inGroup($user2,$group1));
+
+
+ $this->assertTrue(OC_Group::addToGroup($user1,$group1));
+
+ $this->assertTrue(OC_Group::inGroup($user1,$group1));
+ $this->assertFalse(OC_Group::inGroup($user2,$group1));
+ $this->assertFalse($backend2->inGroup($user1,$group1));
+
+ $this->assertFalse(OC_Group::addToGroup($user1,$group1));
+
+ $this->assertEqual(array($user1),OC_Group::usersInGroup($group1));
+
+ $this->assertEqual(array($group1),OC_Group::getUserGroups($user1));
+ $this->assertEqual(array(),OC_Group::getUserGroups($user2));
+
+ OC_Group::deleteGroup($group1);
+ $this->assertEqual(array(),OC_Group::getUserGroups($user1));
+ $this->assertEqual(array(),OC_Group::usersInGroup($group1));
+ $this->assertFalse(OC_Group::inGroup($user1,$group1));
+ }
+}
diff --git a/tests/lib/group/backend.php b/tests/lib/group/backend.php
new file mode 100644
index 00000000000..9405e90aabf
--- /dev/null
+++ b/tests/lib/group/backend.php
@@ -0,0 +1,105 @@
+<?php
+/**
+* ownCloud
+*
+* @author Robin Appelman
+* @copyright 2012 Robin Appelman icewind@owncloud.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+abstract class Test_Group_Backend extends UnitTestCase {
+ /**
+ * @var OC_Group_Backend $backend
+ */
+ protected $backend;
+
+ /**
+ * get a new unique group name
+ * test cases can override this in order to clean up created groups
+ * @return array
+ */
+ public function getGroupName(){
+ return uniqid('test_');
+ }
+
+ /**
+ * get a new unique user name
+ * test cases can override this in order to clean up created user
+ * @return array
+ */
+ public function getUserName(){
+ return uniqid('test_');
+ }
+
+ public function testAddRemove(){
+ //get the number of groups we start with, in case there are exising groups
+ $startCount=count($this->backend->getGroups());
+
+ $name1=$this->getGroupName();
+ $name2=$this->getGroupName();
+ $this->backend->createGroup($name1);
+ $count=count($this->backend->getGroups())-$startCount;
+ $this->assertEqual(1,$count);
+ $this->assertTrue((array_search($name1,$this->backend->getGroups())!==false));
+ $this->assertFalse((array_search($name2,$this->backend->getGroups())!==false));
+ $this->backend->createGroup($name2);
+ $count=count($this->backend->getGroups())-$startCount;
+ $this->assertEqual(2,$count);
+ $this->assertTrue((array_search($name1,$this->backend->getGroups())!==false));
+ $this->assertTrue((array_search($name2,$this->backend->getGroups())!==false));
+
+ $this->backend->deleteGroup($name2);
+ $count=count($this->backend->getGroups())-$startCount;
+ $this->assertEqual(1,$count);
+ $this->assertTrue((array_search($name1,$this->backend->getGroups())!==false));
+ $this->assertFalse((array_search($name2,$this->backend->getGroups())!==false));
+ }
+
+ public function testUser(){
+ $group1=$this->getGroupName();
+ $group2=$this->getGroupName();
+ $this->backend->createGroup($group1);
+ $this->backend->createGroup($group2);
+
+ $user1=$this->getUserName();
+ $user2=$this->getUserName();
+
+ $this->assertFalse($this->backend->inGroup($user1,$group1));
+ $this->assertFalse($this->backend->inGroup($user2,$group1));
+ $this->assertFalse($this->backend->inGroup($user1,$group2));
+ $this->assertFalse($this->backend->inGroup($user2,$group2));
+
+ $this->assertTrue($this->backend->addToGroup($user1,$group1));
+
+ $this->assertTrue($this->backend->inGroup($user1,$group1));
+ $this->assertFalse($this->backend->inGroup($user2,$group1));
+ $this->assertFalse($this->backend->inGroup($user1,$group2));
+ $this->assertFalse($this->backend->inGroup($user2,$group2));
+
+ $this->assertFalse($this->backend->addToGroup($user1,$group1));
+
+ $this->assertEqual(array($user1),$this->backend->usersInGroup($group1));
+ $this->assertEqual(array(),$this->backend->usersInGroup($group2));
+
+ $this->assertEqual(array($group1),$this->backend->getUserGroups($user1));
+ $this->assertEqual(array(),$this->backend->getUserGroups($user2));
+
+ $this->backend->deleteGroup($group1);
+ $this->assertEqual(array(),$this->backend->getUserGroups($user1));
+ $this->assertEqual(array(),$this->backend->usersInGroup($group1));
+ $this->assertFalse($this->backend->inGroup($user1,$group1));
+ }
+}
diff --git a/tests/lib/group/database.php b/tests/lib/group/database.php
new file mode 100644
index 00000000000..fb51bc8d8d9
--- /dev/null
+++ b/tests/lib/group/database.php
@@ -0,0 +1,55 @@
+<?php
+/**
+* ownCloud
+*
+* @author Robin Appelman
+* @copyright 2012 Robin Appelman icewind@owncloud.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+class Test_Group_Database extends Test_Group_Backend {
+ private $groups=array();
+
+ /**
+ * get a new unique group name
+ * test cases can override this in order to clean up created groups
+ * @return array
+ */
+ public function getGroupName(){
+ $name=uniqid('test_');
+ $this->groups[]=$name;
+ return $name;
+ }
+
+ /**
+ * get a new unique user name
+ * test cases can override this in order to clean up created user
+ * @return array
+ */
+ public function getUserName(){
+ return uniqid('test_');
+ }
+
+ public function setUp(){
+ $this->backend=new OC_Group_Database();
+ }
+
+ public function tearDown(){
+ foreach($this->groups as $group){
+ $this->backend->deleteGroup($group);
+ }
+ }
+}
diff --git a/tests/lib/group/dummy.php b/tests/lib/group/dummy.php
new file mode 100644
index 00000000000..d0b475d3ec5
--- /dev/null
+++ b/tests/lib/group/dummy.php
@@ -0,0 +1,27 @@
+<?php
+/**
+* ownCloud
+*
+* @author Robin Appelman
+* @copyright 2012 Robin Appelman icewind@owncloud.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+class Test_Group_Dummy extends Test_Group_Backend {
+ public function setUp(){
+ $this->backend=new OC_Group_Dummy();
+ }
+}