summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2012-10-11 14:59:57 -0400
committerPaul Arthur <paul.arthur@flowerysong.com>2012-10-11 14:59:57 -0400
commit10b2d039d41bd8409643143260210c9a35b96558 (patch)
tree278288ae1a0a8a2070df4794fae8960fa2e527cd
parent866e7f4a1c4c93abc625c5c463dc7f902f930a37 (diff)
downloadampache-10b2d039d41bd8409643143260210c9a35b96558.tar.gz
ampache-10b2d039d41bd8409643143260210c9a35b96558.tar.bz2
ampache-10b2d039d41bd8409643143260210c9a35b96558.zip
Update getID3 to 1.9.4b1
Notably: "PHP5 standards improvements". Maybe it will throw less PHP warnings now.
-rwxr-xr-xdocs/CHANGELOG1
-rw-r--r--modules/getid3/docs/changelog.txt33
-rw-r--r--modules/getid3/docs/readme.txt8
-rw-r--r--modules/getid3/extension.cache.dbm.php13
-rw-r--r--modules/getid3/extension.cache.mysql.php16
-rw-r--r--modules/getid3/extension.cache.sqlite3.php264
-rw-r--r--modules/getid3/getid3.lib.php261
-rw-r--r--modules/getid3/getid3.php406
-rw-r--r--modules/getid3/module.archive.gzip.php9
-rw-r--r--modules/getid3/module.archive.rar.php7
-rw-r--r--modules/getid3/module.archive.szip.php4
-rw-r--r--modules/getid3/module.archive.tar.php12
-rw-r--r--modules/getid3/module.archive.zip.php23
-rw-r--r--modules/getid3/module.audio-video.asf.php42
-rw-r--r--modules/getid3/module.audio-video.bink.php8
-rw-r--r--modules/getid3/module.audio-video.flv.php112
-rw-r--r--modules/getid3/module.audio-video.matroska.php455
-rw-r--r--modules/getid3/module.audio-video.mpeg.php13
-rw-r--r--modules/getid3/module.audio-video.nsv.php11
-rw-r--r--modules/getid3/module.audio-video.quicktime.php71
-rw-r--r--modules/getid3/module.audio-video.real.php11
-rw-r--r--modules/getid3/module.audio-video.riff.php886
-rw-r--r--modules/getid3/module.audio-video.swf.php7
-rw-r--r--modules/getid3/module.audio-video.ts.php78
-rw-r--r--modules/getid3/module.audio.aa.php7
-rw-r--r--modules/getid3/module.audio.aac.php9
-rw-r--r--modules/getid3/module.audio.ac3.php219
-rw-r--r--modules/getid3/module.audio.au.php11
-rw-r--r--modules/getid3/module.audio.avr.php5
-rw-r--r--modules/getid3/module.audio.bonk.php9
-rw-r--r--modules/getid3/module.audio.dss.php7
-rw-r--r--modules/getid3/module.audio.dts.php70
-rw-r--r--modules/getid3/module.audio.flac.php525
-rw-r--r--modules/getid3/module.audio.la.php6
-rw-r--r--modules/getid3/module.audio.lpac.php5
-rw-r--r--modules/getid3/module.audio.midi.php11
-rw-r--r--modules/getid3/module.audio.mod.php13
-rw-r--r--modules/getid3/module.audio.monkey.php8
-rw-r--r--modules/getid3/module.audio.mp3.php136
-rw-r--r--modules/getid3/module.audio.mpc.php23
-rw-r--r--modules/getid3/module.audio.ogg.php214
-rw-r--r--modules/getid3/module.audio.optimfrog.php23
-rw-r--r--modules/getid3/module.audio.rkau.php6
-rw-r--r--modules/getid3/module.audio.shorten.php6
-rw-r--r--modules/getid3/module.audio.tta.php7
-rw-r--r--modules/getid3/module.audio.voc.php25
-rw-r--r--modules/getid3/module.audio.vqf.php9
-rw-r--r--modules/getid3/module.audio.wavpack.php9
-rw-r--r--modules/getid3/module.graphic.bmp.php15
-rw-r--r--modules/getid3/module.graphic.efax.php5
-rw-r--r--modules/getid3/module.graphic.gif.php7
-rw-r--r--modules/getid3/module.graphic.jpg.php29
-rw-r--r--modules/getid3/module.graphic.pcd.php8
-rw-r--r--modules/getid3/module.graphic.png.php19
-rw-r--r--modules/getid3/module.graphic.svg.php5
-rw-r--r--modules/getid3/module.graphic.tiff.php11
-rw-r--r--modules/getid3/module.misc.cue.php25
-rw-r--r--modules/getid3/module.misc.doc.php32
-rw-r--r--modules/getid3/module.misc.exe.php5
-rw-r--r--modules/getid3/module.misc.iso.php20
-rw-r--r--modules/getid3/module.misc.msoffice.php5
-rw-r--r--modules/getid3/module.misc.par2.php5
-rw-r--r--modules/getid3/module.misc.pdf.php5
-rw-r--r--modules/getid3/module.tag.apetag.php16
-rw-r--r--modules/getid3/module.tag.id3v1.php25
-rw-r--r--modules/getid3/module.tag.id3v2.php141
-rw-r--r--modules/getid3/module.tag.lyrics3.php13
-rw-r--r--modules/getid3/module.tag.xmp.php31
-rw-r--r--modules/getid3/write.apetag.php26
-rw-r--r--modules/getid3/write.id3v1.php22
-rw-r--r--modules/getid3/write.id3v2.php81
-rw-r--r--modules/getid3/write.lyrics3.php18
-rw-r--r--modules/getid3/write.metaflac.php18
-rw-r--r--modules/getid3/write.php44
-rw-r--r--modules/getid3/write.real.php28
-rw-r--r--modules/getid3/write.vorbiscomment.php18
76 files changed, 2558 insertions, 2233 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index b180bffa..6ff78014 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,7 @@
--------------------------------------------------------------------------
v.3.6-future
+ - Updated getID3 to 1.9.4b1
- Removed support for extremely old passwords
- Playlists imported from M3U now retain their ordering
(patch by Florent Fourcot)
diff --git a/modules/getid3/docs/changelog.txt b/modules/getid3/docs/changelog.txt
index f2439e81..bbaedf10 100644
--- a/modules/getid3/docs/changelog.txt
+++ b/modules/getid3/docs/changelog.txt
@@ -17,7 +17,38 @@
Version History
===============
-1.9.3: [2012-12-13] Dmitry Arkhipov, James Heinrich
+1.9.4b1: [2012-10-05] James Heinrich, Dmitry Arkhipov, Karl G. Holz
+ » New module: extension.cache.sqlite3.php (by Karl G. Holz)
+ » New demo: demos/getid3.demo.dirscan.php (by Karl G. Holz)
+ » PHP5 standards improvements (thanks phansysØgmail*com)
+ » more reliable >4GB file size parsing using COM (if available)
+ Scripting.FileSystemObject rather than parsing `dir` output
+ * added support for FLAC inside Matroska (audio bitrate cannot
+ be determined in this case)
+ * XMP module now returns all tags, not just whitelisted ones
+ * (#1297) Added detection of MPEG Transport Stream files.
+ Stub module.audio-video.ts.php incomplete
+ * (#1383) removed unneeded ?> tags (thanks daveØholyfield*info)
+ * Bugfix: XMP returns attributes array not just value strings
+ * Bugfix: (#1369) ID3v2 IPLS contents not parsed
+ * Bugfix: (#1357) demo.mysql.php mysql_table_exists() failed
+ * Bugfix: (#1355) copy Foobar2000 QuickTime tags to [comments]
+ * Bugfix: (#1351) QuickTime files with zero-sized atom boxes
+ could cause infinite loop
+ * Bugfix: (#1343) FLAC attached pictures Ogg not handled
+ * Bugfix: (#1343) ID3v2 inside WAV "id3 " chunk not handled
+ * Bugfix: (#1315) BMP detection was broken
+ * Bugfix: (#1309) ID3v2.2 content_group_description (TT2) did
+ not copy to same place as ID3v2.3/ID3v2.4 (TIT2)
+ * Bugfix: (#1308) [playtime_string] could show hh:mm:60
+ * Bugfix: (#1306) extension.cache.mysql.php keyword TYPE->ENGINE
+ * Bugfix: (#1295) missing video information if QuickTime file has
+ disabled tracks
+ * Bugfix: (#1275) MD5/SHA1 data hashes not working properly
+ under Windows
+
+
+1.9.3: [2011-12-13] Dmitry Arkhipov, James Heinrich
* Matroska module improved:
1. Added support for A_MS/ACM audio codec
2. Fixed issues in tags, cues, chapters and clusters parsing
diff --git a/modules/getid3/docs/readme.txt b/modules/getid3/docs/readme.txt
index d4ef1cb4..de960965 100644
--- a/modules/getid3/docs/readme.txt
+++ b/modules/getid3/docs/readme.txt
@@ -132,10 +132,10 @@ Writes:
Requirements
===========================================================================
-* PHP 4.2.0 (or higher) for getID3() 1.7.x (and earlier)
-* PHP 5.3.0 (or higher) for getID3() 1.8.x (and up)
-* PHP 5.0.0 (or higher) for getID3() 2.0.x (and up)
-* at least 4MB memory for PHP. 8MB is highly recommended.
+* PHP 4.2.0 up to 5.2.x for getID3() 1.7.x (and earlier)
+* PHP 5.0.5 (or higher) for getID3() 1.8.x (and up)
+* PHP 5.0.5 (or higher) for getID3() 2.0.x (and up)
+* at least 4MB memory for PHP. 8MB or more is highly recommended.
12MB is required with all modules loaded.
diff --git a/modules/getid3/extension.cache.dbm.php b/modules/getid3/extension.cache.dbm.php
index 9a88c22b..7ac4fce9 100644
--- a/modules/getid3/extension.cache.dbm.php
+++ b/modules/getid3/extension.cache.dbm.php
@@ -73,7 +73,7 @@ class getID3_cached_dbm extends getID3
{
// public: constructor - see top of this file for cache type and cache_options
- function getID3_cached_dbm($cache_type, $dbm_filename, $lock_filename) {
+ public function getID3_cached_dbm($cache_type, $dbm_filename, $lock_filename) {
// Check for dba extension
if (!extension_loaded('dba')) {
@@ -140,8 +140,8 @@ class getID3_cached_dbm extends getID3
- // public: destuctor
- function __destruct() {
+ // public: destructor
+ public function __destruct() {
// Close dbm file
dba_close($this->dba);
@@ -156,7 +156,7 @@ class getID3_cached_dbm extends getID3
// public: clear cache
- function clear_cache() {
+ public function clear_cache() {
// Close dbm file
dba_close($this->dba);
@@ -178,7 +178,7 @@ class getID3_cached_dbm extends getID3
// public: analyze file
- function analyze($filename) {
+ public function analyze($filename) {
if (file_exists($filename)) {
@@ -206,6 +206,3 @@ class getID3_cached_dbm extends getID3
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/extension.cache.mysql.php b/modules/getid3/extension.cache.mysql.php
index 1e1f91fa..ef3f5045 100644
--- a/modules/getid3/extension.cache.mysql.php
+++ b/modules/getid3/extension.cache.mysql.php
@@ -74,12 +74,12 @@ class getID3_cached_mysql extends getID3
{
// private vars
- var $cursor;
- var $connection;
+ private $cursor;
+ private $connection;
// public: constructor - see top of this file for cache type and cache_options
- function getID3_cached_mysql($host, $database, $username, $password, $table='getid3_cache') {
+ public function getID3_cached_mysql($host, $database, $username, $password, $table='getid3_cache') {
// Check for mysql support
if (!function_exists('mysql_pconnect')) {
@@ -118,7 +118,7 @@ class getID3_cached_mysql extends getID3
// public: clear cache
- function clear_cache() {
+ public function clear_cache() {
$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);
@@ -127,7 +127,7 @@ class getID3_cached_mysql extends getID3
// public: analyze file
- function analyze($filename) {
+ public function analyze($filename) {
if (file_exists($filename)) {
@@ -157,7 +157,7 @@ class getID3_cached_mysql extends getID3
// private: (re)create sql table
- function create_table($drop=false) {
+ private function create_table($drop=false) {
$this->cursor = mysql_query("CREATE TABLE IF NOT EXISTS `".mysql_real_escape_string($this->table)."` (
`filename` VARCHAR(255) NOT NULL DEFAULT '',
@@ -165,9 +165,7 @@ class getID3_cached_mysql extends getID3
`filetime` INT(11) NOT NULL DEFAULT '0',
`analyzetime` INT(11) NOT NULL DEFAULT '0',
`value` TEXT NOT NULL,
- PRIMARY KEY (`filename`,`filesize`,`filetime`)) TYPE=MyISAM", $this->connection);
+ PRIMARY KEY (`filename`,`filesize`,`filetime`)) ENGINE=MyISAM", $this->connection);
echo mysql_error($this->connection);
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/extension.cache.sqlite3.php b/modules/getid3/extension.cache.sqlite3.php
new file mode 100644
index 00000000..3e0fd4db
--- /dev/null
+++ b/modules/getid3/extension.cache.sqlite3.php
@@ -0,0 +1,264 @@
+<?php
+/////////////////////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org ///
+/////////////////////////////////////////////////////////////////////////////////
+/// //
+// extension.cache.sqlite3.php - part of getID3() //
+// Please see readme.txt for more information //
+// ///
+/////////////////////////////////////////////////////////////////////////////////
+/// //
+// MySQL extension written by Allan Hansen <ahØartemis*dk> //
+// Table name mod by Carlo Capocasa <calroØcarlocapocasa*com> //
+// MySQL extension was reworked for SQLite3 by Karl G. Holz <newaeonØmac*com> //
+// ///
+/////////////////////////////////////////////////////////////////////////////////
+/**
+* This is a caching extension for getID3(). It works the exact same
+* way as the getID3 class, but return cached information much faster
+*
+* Normal getID3 usage (example):
+*
+* require_once 'getid3/getid3.php';
+* $getID3 = new getID3;
+* $getID3->encoding = 'UTF-8';
+* $info1 = $getID3->analyze('file1.flac');
+* $info2 = $getID3->analyze('file2.wv');
+*
+* getID3_cached usage:
+*
+* require_once 'getid3/getid3.php';
+* require_once 'getid3/extension.cache.sqlite3.php';
+* // all parameters are optional, defaults are:
+* $getID3 = new getID3_cached_sqlite3($table='getid3_cache', $hide=FALSE);
+* $getID3->encoding = 'UTF-8';
+* $info1 = $getID3->analyze('file1.flac');
+* $info2 = $getID3->analyze('file2.wv');
+*
+*
+* Supported Cache Types (this extension)
+*
+* SQL Databases:
+*
+* cache_type cache_options
+* -------------------------------------------------------------------
+* mysql host, database, username, password
+*
+* sqlite3 table='getid3_cache', hide=false (PHP5)
+*
+
+*** database file will be stored in the same directory as this script,
+*** webserver must have write access to that directory!
+*** set $hide to TRUE to prefix db file with .ht to pervent access from web client
+*** this is a default setting in the Apache configuration:
+
+# The following lines prevent .htaccess and .htpasswd files from being viewed by Web clients.
+
+<Files ~ "^\.ht">
+ Order allow,deny
+ Deny from all
+ Satisfy all
+</Files>
+
+********************************************************************************
+*
+* -------------------------------------------------------------------
+* DBM-Style Databases: (use extension.cache.dbm)
+*
+* cache_type cache_options
+* -------------------------------------------------------------------
+* gdbm dbm_filename, lock_filename
+* ndbm dbm_filename, lock_filename
+* db2 dbm_filename, lock_filename
+* db3 dbm_filename, lock_filename
+* db4 dbm_filename, lock_filename (PHP5 required)
+*
+* PHP must have write access to both dbm_filename and lock_filename.
+*
+* Recommended Cache Types
+*
+* Infrequent updates, many reads any DBM
+* Frequent updates mysql
+********************************************************************************
+*
+* IMHO this is still a bit slow, I'm using this with MP4/MOV/ M4v files
+* there is a plan to add directory scanning and analyzing to make things work much faster
+*
+*
+*/
+class getID3_cached_sqlite3 extends getID3 {
+
+ /**
+ * __construct()
+ * @param string $table holds name of sqlite table
+ * @return type
+ */
+ public function __construct($table='getid3_cache', $hide=false) {
+ $this->table = $table; // Set table
+ $file = dirname(__FILE__).'/'.basename(__FILE__, 'php').'sqlite';
+ if ($hide) {
+ $file = dirname(__FILE__).'/.ht.'.basename(__FILE__, 'php').'sqlite';
+ }
+ $this->db = new SQLite3($file);
+ $db = $this->db;
+ $this->create_table(); // Create cache table if not exists
+ $version = '';
+ $sql = $this->version_check;
+ $stmt = $db->prepare($sql);
+ $stmt->bindValue(':filename', getID3::VERSION, SQLITE3_TEXT);
+ $result = $stmt->execute();
+ list($version) = $result->fetchArray();
+ if ($version != getID3::VERSION) { // Check version number and clear cache if changed
+ $this->clear_cache();
+ }
+ return parent::__construct();
+ }
+
+ /**
+ * close the database connection
+ */
+ public function __destruct() {
+ $db=$this->db;
+ $db->close();
+ }
+
+ /**
+ * hold the sqlite db
+ * @var SQLite Resource
+ */
+ private $db;
+
+ /**
+ * table to use for caching
+ * @var string $table
+ */
+ private $table;
+
+ /**
+ * clear the cache
+ * @access private
+ * @return type
+ */
+ private function clear_cache() {
+ $db = $this->db;
+ $sql = $this->delete_cache;
+ $db->exec($sql);
+ $sql = $this->set_version;
+ $stmt = $db->prepare($sql);
+ $stmt->bindValue(':filename', getID3::VERSION, SQLITE3_TEXT);
+ $stmt->bindValue(':dirname', getID3::VERSION, SQLITE3_TEXT);
+ $stmt->bindValue(':val', getID3::VERSION, SQLITE3_TEXT);
+ return $stmt->execute();
+ }
+
+ /**
+ * analyze file and cache them, if cached pull from the db
+ * @param type $filename
+ * @return boolean
+ */
+ public function analyze($filename) {
+ if (!file_exists($filename)) {
+ return false;
+ }
+ // items to track for caching
+ $filetime = filemtime($filename);
+ $filesize = filesize($filename);
+ // this will be saved for a quick directory lookup of analized files
+ // ... why do 50 seperate sql quries when you can do 1 for the same result
+ $dirname = dirname($filename);
+ // Lookup file
+ $db = $this->db;
+ $sql = $this->get_id3_data;
+ $stmt = $db->prepare($sql);
+ $stmt->bindValue(':filename', $filename, SQLITE3_TEXT);
+ $stmt->bindValue(':filesize', $filesize, SQLITE3_INTEGER);
+ $stmt->bindValue(':filetime', $filetime, SQLITE3_INTEGER);
+ $res = $stmt->execute();
+ list($result) = $res->fetchArray();
+ if (count($result) > 0 ) {
+ return unserialize(base64_decode($result));
+ }
+ // if it hasn't been analyzed before, then do it now
+ $analysis = parent::analyze($filename);
+ // Save result
+ $sql = $this->cache_file;
+ $stmt = $db->prepare($sql);
+ $stmt->bindValue(':filename', $filename, SQLITE3_TEXT);
+ $stmt->bindValue(':dirname', $dirname, SQLITE3_TEXT);
+ $stmt->bindValue(':filesize', $filesize, SQLITE3_INTEGER);
+ $stmt->bindValue(':filetime', $filetime, SQLITE3_INTEGER);
+ $stmt->bindValue(':atime', time(), SQLITE3_INTEGER);
+ $stmt->bindValue(':val', base64_encode(serialize($analysis)), SQLITE3_TEXT);
+ $res = $stmt->execute();
+ return $analysis;
+ }
+
+ /**
+ * create data base table
+ * this is almost the same as MySQL, with the exception of the dirname being added
+ * @return type
+ */
+ private function create_table() {
+ $db = $this->db;
+ $sql = $this->make_table;
+ return $db->exec($sql);
+ }
+
+ /**
+ * get cached directory
+ *
+ * This function is not in the MySQL extention, it's ment to speed up requesting multiple files
+ * which is ideal for podcasting, playlists, etc.
+ *
+ * @access public
+ * @param string $dir directory to search the cache database for
+ * @return array return an array of matching id3 data
+ */
+ public function get_cached_dir($dir) {
+ $db = $this->db;
+ $rows = array();
+ $sql = $this->get_cached_dir;
+ $stmt = $db->prepare($sql);
+ $stmt->bindValue(':dirname', $dir, SQLITE3_TEXT);
+ $res = $stmt->execute();
+ while ($row=$res->fetchArray()) {
+ $rows[] = unserialize(base64_decode($row));
+ }
+ return $rows;
+ }
+
+ /**
+ * use the magical __get() for sql queries
+ *
+ * access as easy as $this->{case name}, returns NULL if query is not found
+ */
+ public function __get($name) {
+ switch($name) {
+ case 'version_check':
+ return "SELECT val FROM $this->table WHERE filename = :filename AND filesize = '-1' AND filetime = '-1' AND analyzetime = '-1'";
+ break;
+ case 'delete_cache':
+ return "DELETE FROM $this->table";
+ break;
+ case 'set_version':
+ return "INSERT INTO $this->table (filename, dirname, filesize, filetime, analyzetime, val) VALUES (:filename, :dirname, -1, -1, -1, :val)";
+ break;
+ case 'get_id3_data':
+ return "SELECT val FROM $this->table WHERE filename = :filename AND filesize = :filesize AND filetime = :filetime";
+ break;
+ case 'cache_file':
+ return "INSERT INTO $this->table (filename, dirname, filesize, filetime, analyzetime, val) VALUES (:filename, :dirname, :filesize, :filetime, :atime, :val)";
+ break;
+ case 'make_table':
+ return "CREATE TABLE IF NOT EXISTS $this->table (filename VARCHAR(255) NOT NULL DEFAULT '', dirname VARCHAR(255) NOT NULL DEFAULT '', filesize INT(11) NOT NULL DEFAULT '0', filetime INT(11) NOT NULL DEFAULT '0', analyzetime INT(11) NOT NULL DEFAULT '0', val text not null, PRIMARY KEY (filename, filesize, filetime))";
+ break;
+ case 'get_cached_dir':
+ return "SELECT val FROM $this->table WHERE dirname = :dirname";
+ break;
+ }
+ return null;
+ }
+
+}
diff --git a/modules/getid3/getid3.lib.php b/modules/getid3/getid3.lib.php
index 723e2e24..c5bfda04 100644
--- a/modules/getid3/getid3.lib.php
+++ b/modules/getid3/getid3.lib.php
@@ -14,7 +14,7 @@
class getid3_lib
{
- static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') {
+ public static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') {
$returnstring = '';
for ($i = 0; $i < strlen($string); $i++) {
if ($hex) {
@@ -35,7 +35,7 @@ class getid3_lib
return $returnstring;
}
- static function trunc($floatnumber) {
+ public static function trunc($floatnumber) {
// truncates a floating-point number at the decimal point
// returns int (if possible, otherwise float)
if ($floatnumber >= 1) {
@@ -45,14 +45,14 @@ class getid3_lib
} else {
$truncatednumber = 0;
}
- if (getid3_lib::intValueSupported($truncatednumber)) {
+ if (self::intValueSupported($truncatednumber)) {
$truncatednumber = (int) $truncatednumber;
}
return $truncatednumber;
}
- static function safe_inc(&$variable, $increment=1) {
+ public static function safe_inc(&$variable, $increment=1) {
if (isset($variable)) {
$variable += $increment;
} else {
@@ -61,14 +61,14 @@ class getid3_lib
return true;
}
- static function CastAsInt($floatnum) {
+ public 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) {
+ if (self::trunc($floatnum) == $floatnum) {
// it's not floating point
- if (getid3_lib::intValueSupported($floatnum)) {
+ if (self::intValueSupported($floatnum)) {
// it's within int range
$floatnum = (int) $floatnum;
}
@@ -92,20 +92,20 @@ class getid3_lib
return false;
}
- static function DecimalizeFraction($fraction) {
+ public static function DecimalizeFraction($fraction) {
list($numerator, $denominator) = explode('/', $fraction);
return $numerator / ($denominator ? $denominator : 1);
}
- static function DecimalBinary2Float($binarynumerator) {
- $numerator = getid3_lib::Bin2Dec($binarynumerator);
- $denominator = getid3_lib::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
+ public static function DecimalBinary2Float($binarynumerator) {
+ $numerator = self::Bin2Dec($binarynumerator);
+ $denominator = self::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
return ($numerator / $denominator);
}
- static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
+ public static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
if (strpos($binarypointnumber, '.') === false) {
$binarypointnumber = '0.'.$binarypointnumber;
@@ -129,23 +129,23 @@ class getid3_lib
}
- static function Float2BinaryDecimal($floatvalue) {
+ public 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);
+ $intpart = self::trunc($floatvalue);
$floatpart = abs($floatvalue - $intpart);
$pointbitstring = '';
while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
$floatpart *= 2;
- $pointbitstring .= (string) getid3_lib::trunc($floatpart);
- $floatpart -= getid3_lib::trunc($floatpart);
+ $pointbitstring .= (string) self::trunc($floatpart);
+ $floatpart -= self::trunc($floatpart);
}
$binarypointnumber = decbin($intpart).'.'.$pointbitstring;
return $binarypointnumber;
}
- static function Float2String($floatvalue, $bits) {
+ public static function Float2String($floatvalue, $bits) {
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
switch ($bits) {
case 32:
@@ -167,26 +167,26 @@ class getid3_lib
} else {
$signbit = '1';
}
- $normalizedbinary = getid3_lib::NormalizeBinaryPoint(getid3_lib::Float2BinaryDecimal($floatvalue), $fractionbits);
+ $normalizedbinary = self::NormalizeBinaryPoint(self::Float2BinaryDecimal($floatvalue), $fractionbits);
$biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent']; // (127 or 1023) +/- exponent
$exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT);
$fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT);
- return getid3_lib::BigEndian2String(getid3_lib::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
+ return self::BigEndian2String(self::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
}
- static function LittleEndian2Float($byteword) {
- return getid3_lib::BigEndian2Float(strrev($byteword));
+ public static function LittleEndian2Float($byteword) {
+ return self::BigEndian2Float(strrev($byteword));
}
- static function BigEndian2Float($byteword) {
+ public 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);
+ $bitword = self::BigEndian2Bin($byteword);
if (!$bitword) {
return 0;
}
@@ -209,8 +209,8 @@ class getid3_lib
$exponentstring = substr($bitword, 1, 15);
$isnormalized = intval($bitword{16});
$fractionstring = substr($bitword, 17, 63);
- $exponent = pow(2, getid3_lib::Bin2Dec($exponentstring) - 16383);
- $fraction = $isnormalized + getid3_lib::DecimalBinary2Float($fractionstring);
+ $exponent = pow(2, self::Bin2Dec($exponentstring) - 16383);
+ $fraction = $isnormalized + self::DecimalBinary2Float($fractionstring);
$floatvalue = $exponent * $fraction;
if ($signbit == '1') {
$floatvalue *= -1;
@@ -224,8 +224,8 @@ class getid3_lib
}
$exponentstring = substr($bitword, 1, $exponentbits);
$fractionstring = substr($bitword, $exponentbits + 1, $fractionbits);
- $exponent = getid3_lib::Bin2Dec($exponentstring);
- $fraction = getid3_lib::Bin2Dec($fractionstring);
+ $exponent = self::Bin2Dec($exponentstring);
+ $fraction = self::Bin2Dec($fractionstring);
if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
// Not a Number
@@ -245,12 +245,12 @@ class getid3_lib
$floatvalue = ($signbit ? 0 : -0);
} elseif (($exponent == 0) && ($fraction != 0)) {
// These are 'unnormalized' values
- $floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fractionstring);
+ $floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * self::DecimalBinary2Float($fractionstring);
if ($signbit == '1') {
$floatvalue *= -1;
}
} elseif ($exponent != 0) {
- $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fractionstring));
+ $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + self::DecimalBinary2Float($fractionstring));
if ($signbit == '1') {
$floatvalue *= -1;
}
@@ -259,7 +259,7 @@ class getid3_lib
}
- static function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
+ public static function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
$intvalue = 0;
$bytewordlen = strlen($byteword);
if ($bytewordlen == 0) {
@@ -281,20 +281,20 @@ class getid3_lib
$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()');
+ throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in self::BigEndian2Int()');
break;
}
}
- return getid3_lib::CastAsInt($intvalue);
+ return self::CastAsInt($intvalue);
}
- static function LittleEndian2Int($byteword, $signed=false) {
- return getid3_lib::BigEndian2Int(strrev($byteword), false, $signed);
+ public static function LittleEndian2Int($byteword, $signed=false) {
+ return self::BigEndian2Int(strrev($byteword), false, $signed);
}
- static function BigEndian2Bin($byteword) {
+ public static function BigEndian2Bin($byteword) {
$binvalue = '';
$bytewordlen = strlen($byteword);
for ($i = 0; $i < $bytewordlen; $i++) {
@@ -304,15 +304,15 @@ class getid3_lib
}
- static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
+ public static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
if ($number < 0) {
- throw new Exception('ERROR: getid3_lib::BigEndian2String() does not support negative numbers');
+ throw new Exception('ERROR: self::BigEndian2String() does not support negative numbers');
}
$maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
$intstring = '';
if ($signed) {
if ($minbytes > PHP_INT_SIZE) {
- throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in getid3_lib::BigEndian2String()');
+ throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in self::BigEndian2String()');
}
$number = $number & (0x80 << (8 * ($minbytes - 1)));
}
@@ -325,7 +325,7 @@ class getid3_lib
}
- static function Dec2Bin($number) {
+ public static function Dec2Bin($number) {
while ($number >= 256) {
$bytes[] = (($number / 256) - (floor($number / 256))) * 256;
$number = floor($number / 256);
@@ -339,7 +339,7 @@ class getid3_lib
}
- static function Bin2Dec($binstring, $signed=false) {
+ public static function Bin2Dec($binstring, $signed=false) {
$signmult = 1;
if ($signed) {
if ($binstring{0} == '1') {
@@ -351,22 +351,22 @@ class getid3_lib
for ($i = 0; $i < strlen($binstring); $i++) {
$decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
}
- return getid3_lib::CastAsInt($decvalue * $signmult);
+ return self::CastAsInt($decvalue * $signmult);
}
- static function Bin2String($binstring) {
+ public static function Bin2String($binstring) {
// return 'hi' for input of '0110100001101001'
$string = '';
$binstringreversed = strrev($binstring);
for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
- $string = chr(getid3_lib::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
+ $string = chr(self::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
}
return $string;
}
- static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
+ public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
$intstring = '';
while ($number > 0) {
if ($synchsafe) {
@@ -381,7 +381,7 @@ class getid3_lib
}
- static function array_merge_clobber($array1, $array2) {
+ public 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)) {
@@ -390,7 +390,7 @@ class getid3_lib
$newarray = $array1;
foreach ($array2 as $key => $val) {
if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
- $newarray[$key] = getid3_lib::array_merge_clobber($newarray[$key], $val);
+ $newarray[$key] = self::array_merge_clobber($newarray[$key], $val);
} else {
$newarray[$key] = $val;
}
@@ -399,14 +399,14 @@ class getid3_lib
}
- static function array_merge_noclobber($array1, $array2) {
+ public static function array_merge_noclobber($array1, $array2) {
if (!is_array($array1) || !is_array($array2)) {
return false;
}
$newarray = $array1;
foreach ($array2 as $key => $val) {
if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
- $newarray[$key] = getid3_lib::array_merge_noclobber($newarray[$key], $val);
+ $newarray[$key] = self::array_merge_noclobber($newarray[$key], $val);
} elseif (!isset($newarray[$key])) {
$newarray[$key] = $val;
}
@@ -415,7 +415,7 @@ class getid3_lib
}
- static function ksort_recursive(&$theArray) {
+ public static function ksort_recursive(&$theArray) {
ksort($theArray);
foreach ($theArray as $key => $value) {
if (is_array($value)) {
@@ -425,7 +425,7 @@ class getid3_lib
return true;
}
- static function fileextension($filename, $numextensions=1) {
+ public static function fileextension($filename, $numextensions=1) {
if (strstr($filename, '.')) {
$reversedfilename = strrev($filename);
$offset = 0;
@@ -441,42 +441,42 @@ class getid3_lib
}
- static function PlaytimeString($seconds) {
+ public 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) );
+ $seconds = round(abs($seconds));
+ $H = (int) floor( $seconds / 3600);
+ $M = (int) floor(($seconds - (3600 * $H) ) / 60);
+ $S = (int) 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);
}
- static function DateMac2Unix($macdate) {
+ public 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);
+ return self::CastAsInt($macdate - 2082844800);
}
- static function FixedPoint8_8($rawdata) {
- return getid3_lib::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
+ public static function FixedPoint8_8($rawdata) {
+ return self::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (self::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
}
- static function FixedPoint16_16($rawdata) {
- return getid3_lib::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
+ public static function FixedPoint16_16($rawdata) {
+ return self::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (self::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
}
- 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)) / pow(2, 30));
+ public static function FixedPoint2_30($rawdata) {
+ $binarystring = self::BigEndian2Bin($rawdata);
+ return self::Bin2Dec(substr($binarystring, 0, 2)) + (float) (self::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
}
- static function CreateDeepArray($ArrayPath, $Separator, $Value) {
+ public static function CreateDeepArray($ArrayPath, $Separator, $Value) {
// assigns $Value to a nested array path:
- // $foo = getid3_lib::CreateDeepArray('/path/to/my', '/', 'file.txt')
+ // $foo = self::CreateDeepArray('/path/to/my', '/', 'file.txt')
// is the same as:
// $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
// or
@@ -485,14 +485,14 @@ class getid3_lib
$ArrayPath = substr($ArrayPath, 1);
}
if (($pos = strpos($ArrayPath, $Separator)) !== false) {
- $ReturnedArray[substr($ArrayPath, 0, $pos)] = getid3_lib::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
+ $ReturnedArray[substr($ArrayPath, 0, $pos)] = self::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
} else {
$ReturnedArray[$ArrayPath] = $Value;
}
return $ReturnedArray;
}
- static function array_max($arraydata, $returnkey=false) {
+ public static function array_max($arraydata, $returnkey=false) {
$maxvalue = false;
$maxkey = false;
foreach ($arraydata as $key => $value) {
@@ -506,7 +506,7 @@ class getid3_lib
return ($returnkey ? $maxkey : $maxvalue);
}
- static function array_min($arraydata, $returnkey=false) {
+ public static function array_min($arraydata, $returnkey=false) {
$minvalue = false;
$minkey = false;
foreach ($arraydata as $key => $value) {
@@ -520,7 +520,7 @@ class getid3_lib
return ($returnkey ? $minkey : $minvalue);
}
- static function XML2array($XMLstring) {
+ public static function XML2array($XMLstring) {
if (function_exists('simplexml_load_string')) {
if (function_exists('get_object_vars')) {
$XMLobject = simplexml_load_string($XMLstring);
@@ -530,7 +530,7 @@ class getid3_lib
return false;
}
- static function SimpleXMLelement2array($XMLobject) {
+ public static function SimpleXMLelement2array($XMLobject) {
if (!is_object($XMLobject) && !is_array($XMLobject)) {
return $XMLobject;
}
@@ -543,10 +543,10 @@ class getid3_lib
// Allan Hansen <ahØartemis*dk>
- // getid3_lib::md5_data() - returns md5sum for a file from startuing position to absolute end position
- static function hash_data($file, $offset, $end, $algorithm) {
+ // self::md5_data() - returns md5sum for a file from startuing position to absolute end position
+ public static function hash_data($file, $offset, $end, $algorithm) {
static $tempdir = '';
- if (!getid3_lib::intValueSupported($end)) {
+ if (!self::intValueSupported($end)) {
return false;
}
switch ($algorithm) {
@@ -565,7 +565,7 @@ class getid3_lib
break;
default:
- throw new Exception('Invalid algorithm ('.$algorithm.') in getid3_lib::hash_data()');
+ throw new Exception('Invalid algorithm ('.$algorithm.') in self::hash_data()');
break;
}
$size = $end - $offset;
@@ -582,10 +582,10 @@ class getid3_lib
foreach ($RequiredFiles as $required_file) {
if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
// helper apps not available - fall back to old method
- break;
+ break 2;
}
}
- $commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' "'.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).'" | ';
+ $commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' '.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).' | ';
$commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | ';
$commandline .= GETID3_HELPERAPPSDIR.$windows_call;
@@ -621,17 +621,17 @@ class getid3_lib
// copy parts of file
try {
- getid3_lib::CopyFileParts($file, $data_filename, $offset, $end - $offset);
+ self::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());
+ throw new Exception('self::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)) {
+ public static function CopyFileParts($filename_source, $filename_dest, $offset, $length) {
+ if (!self::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'))) {
@@ -657,7 +657,7 @@ class getid3_lib
return false;
}
- static function iconv_fallback_int_utf8($charval) {
+ public static function iconv_fallback_int_utf8($charval) {
if ($charval < 128) {
// 0bbbbbbb
$newcharstring = chr($charval);
@@ -681,7 +681,7 @@ class getid3_lib
}
// ISO-8859-1 => UTF-8
- static function iconv_fallback_iso88591_utf8($string, $bom=false) {
+ public static function iconv_fallback_iso88591_utf8($string, $bom=false) {
if (function_exists('utf8_encode')) {
return utf8_encode($string);
}
@@ -692,13 +692,13 @@ class getid3_lib
}
for ($i = 0; $i < strlen($string); $i++) {
$charval = ord($string{$i});
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
+ $newcharstring .= self::iconv_fallback_int_utf8($charval);
}
return $newcharstring;
}
// ISO-8859-1 => UTF-16BE
- static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
+ public static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFE\xFF";
@@ -710,7 +710,7 @@ class getid3_lib
}
// ISO-8859-1 => UTF-16LE
- static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
+ public static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFF\xFE";
@@ -722,12 +722,12 @@ class getid3_lib
}
// ISO-8859-1 => UTF-16LE (BOM)
- static function iconv_fallback_iso88591_utf16($string) {
- return getid3_lib::iconv_fallback_iso88591_utf16le($string, true);
+ public static function iconv_fallback_iso88591_utf16($string) {
+ return self::iconv_fallback_iso88591_utf16le($string, true);
}
// UTF-8 => ISO-8859-1
- static function iconv_fallback_utf8_iso88591($string) {
+ public static function iconv_fallback_utf8_iso88591($string) {
if (function_exists('utf8_decode')) {
return utf8_decode($string);
}
@@ -771,7 +771,7 @@ class getid3_lib
}
// UTF-8 => UTF-16BE
- static function iconv_fallback_utf8_utf16be($string, $bom=false) {
+ public static function iconv_fallback_utf8_utf16be($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFE\xFF";
@@ -807,14 +807,14 @@ class getid3_lib
$offset += 1;
}
if ($charval !== false) {
- $newcharstring .= (($charval < 65536) ? getid3_lib::BigEndian2String($charval, 2) : "\x00".'?');
+ $newcharstring .= (($charval < 65536) ? self::BigEndian2String($charval, 2) : "\x00".'?');
}
}
return $newcharstring;
}
// UTF-8 => UTF-16LE
- static function iconv_fallback_utf8_utf16le($string, $bom=false) {
+ public static function iconv_fallback_utf8_utf16le($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFF\xFE";
@@ -850,96 +850,96 @@ class getid3_lib
$offset += 1;
}
if ($charval !== false) {
- $newcharstring .= (($charval < 65536) ? getid3_lib::LittleEndian2String($charval, 2) : '?'."\x00");
+ $newcharstring .= (($charval < 65536) ? self::LittleEndian2String($charval, 2) : '?'."\x00");
}
}
return $newcharstring;
}
// UTF-8 => UTF-16LE (BOM)
- static function iconv_fallback_utf8_utf16($string) {
- return getid3_lib::iconv_fallback_utf8_utf16le($string, true);
+ public static function iconv_fallback_utf8_utf16($string) {
+ return self::iconv_fallback_utf8_utf16le($string, true);
}
// UTF-16BE => UTF-8
- static function iconv_fallback_utf16be_utf8($string) {
+ public static function iconv_fallback_utf16be_utf8($string) {
if (substr($string, 0, 2) == "\xFE\xFF") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
+ $charval = self::BigEndian2Int(substr($string, $i, 2));
+ $newcharstring .= self::iconv_fallback_int_utf8($charval);
}
return $newcharstring;
}
// UTF-16LE => UTF-8
- static function iconv_fallback_utf16le_utf8($string) {
+ public static function iconv_fallback_utf16le_utf8($string) {
if (substr($string, 0, 2) == "\xFF\xFE") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
+ $charval = self::LittleEndian2Int(substr($string, $i, 2));
+ $newcharstring .= self::iconv_fallback_int_utf8($charval);
}
return $newcharstring;
}
// UTF-16BE => ISO-8859-1
- static function iconv_fallback_utf16be_iso88591($string) {
+ public static function iconv_fallback_utf16be_iso88591($string) {
if (substr($string, 0, 2) == "\xFE\xFF") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
+ $charval = self::BigEndian2Int(substr($string, $i, 2));
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
}
return $newcharstring;
}
// UTF-16LE => ISO-8859-1
- static function iconv_fallback_utf16le_iso88591($string) {
+ public static function iconv_fallback_utf16le_iso88591($string) {
if (substr($string, 0, 2) == "\xFF\xFE") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
+ $charval = self::LittleEndian2Int(substr($string, $i, 2));
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
}
return $newcharstring;
}
// UTF-16 (BOM) => ISO-8859-1
- static function iconv_fallback_utf16_iso88591($string) {
+ public 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));
+ return self::iconv_fallback_utf16be_iso88591(substr($string, 2));
} elseif ($bom == "\xFF\xFE") {
- return getid3_lib::iconv_fallback_utf16le_iso88591(substr($string, 2));
+ return self::iconv_fallback_utf16le_iso88591(substr($string, 2));
}
return $string;
}
// UTF-16 (BOM) => UTF-8
- static function iconv_fallback_utf16_utf8($string) {
+ public 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));
+ return self::iconv_fallback_utf16be_utf8(substr($string, 2));
} elseif ($bom == "\xFF\xFE") {
- return getid3_lib::iconv_fallback_utf16le_utf8(substr($string, 2));
+ return self::iconv_fallback_utf16le_utf8(substr($string, 2));
}
return $string;
}
- static function iconv_fallback($in_charset, $out_charset, $string) {
+ public static function iconv_fallback($in_charset, $out_charset, $string) {
if ($in_charset == $out_charset) {
return $string;
@@ -982,13 +982,13 @@ class getid3_lib
}
if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
$ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
- return getid3_lib::$ConversionFunction($string);
+ return self::$ConversionFunction($string);
}
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') {
+ public 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 = '';
@@ -1053,7 +1053,7 @@ class getid3_lib
case 'UTF-16LE':
for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
+ $charval = self::LittleEndian2Int(substr($string, $i, 2));
if (($charval >= 32) && ($charval <= 127)) {
$HTMLstring .= chr($charval);
} else {
@@ -1064,7 +1064,7 @@ class getid3_lib
case 'UTF-16BE':
for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
+ $charval = self::BigEndian2Int(substr($string, $i, 2));
if (($charval >= 32) && ($charval <= 127)) {
$HTMLstring .= chr($charval);
} else {
@@ -1082,7 +1082,7 @@ class getid3_lib
- static function RGADnameLookup($namecode) {
+ public static function RGADnameLookup($namecode) {
static $RGADname = array();
if (empty($RGADname)) {
$RGADname[0] = 'not set';
@@ -1094,7 +1094,7 @@ class getid3_lib
}
- static function RGADoriginatorLookup($originatorcode) {
+ public static function RGADoriginatorLookup($originatorcode) {
static $RGADoriginator = array();
if (empty($RGADoriginator)) {
$RGADoriginator[0] = 'unspecified';
@@ -1107,7 +1107,7 @@ class getid3_lib
}
- static function RGADadjustmentLookup($rawadjustment, $signbit) {
+ public static function RGADadjustmentLookup($rawadjustment, $signbit) {
$adjustment = $rawadjustment / 10;
if ($signbit == 1) {
$adjustment *= -1;
@@ -1116,7 +1116,7 @@ class getid3_lib
}
- static function RGADgainString($namecode, $originatorcode, $replaygain) {
+ public static function RGADgainString($namecode, $originatorcode, $replaygain) {
if ($replaygain < 0) {
$signbit = '1';
} else {
@@ -1131,12 +1131,12 @@ class getid3_lib
return $gainstring;
}
- static function RGADamplitude2dB($amplitude) {
+ public static function RGADamplitude2dB($amplitude) {
return 20 * log10($amplitude);
}
- static function GetDataImageSize($imgData, &$imageinfo) {
+ public static function GetDataImageSize($imgData, &$imageinfo=array()) {
static $tempdir = '';
if (empty($tempdir)) {
// yes this is ugly, feel free to suggest a better way
@@ -1157,7 +1157,12 @@ class getid3_lib
return $GetDataImageSize;
}
- static function ImageTypesLookup($imagetypeid) {
+ public static function ImageExtFromMime($mime_type) {
+ // temporary way, works OK for now, but should be reworked in the future
+ return str_replace(array('image/', 'x-', 'jpeg'), array('', '', 'jpg'), $mime_type);
+ }
+
+ public static function ImageTypesLookup($imagetypeid) {
static $ImageTypesLookup = array();
if (empty($ImageTypesLookup)) {
$ImageTypesLookup[1] = 'gif';
@@ -1178,7 +1183,7 @@ class getid3_lib
return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : '');
}
- static function CopyTagsToComments(&$ThisFileInfo) {
+ public static function CopyTagsToComments(&$ThisFileInfo) {
// Copy all entries from ['tags'] into common ['comments']
if (!empty($ThisFileInfo['tags'])) {
@@ -1233,7 +1238,7 @@ class getid3_lib
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']));
+ $ThisFileInfo['comments_html'][$field][$index] = str_replace('&#0;', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
}
}
}
@@ -1242,7 +1247,7 @@ class getid3_lib
}
- static function EmbeddedLookup($key, $begin, $end, $file, $name) {
+ public static function EmbeddedLookup($key, $begin, $end, $file, $name) {
// Cached
static $cache;
@@ -1288,7 +1293,7 @@ class getid3_lib
return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
}
- static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
+ public static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
global $GETID3_ERRORARRAY;
if (file_exists($filename)) {
@@ -1313,5 +1318,3 @@ class getid3_lib
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/getid3.php b/modules/getid3/getid3.php
index e8a3f7e2..98bfb0a0 100644
--- a/modules/getid3/getid3.php
+++ b/modules/getid3/getid3.php
@@ -54,21 +54,12 @@ 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);
- }
+ define('GETID3_OS_ISWINDOWS', (stripos(PHP_OS, 'WIN') === 0));
}
// 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;
- }
- }
+ define('GETID3_INCLUDEPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
}
// End: Defines
@@ -107,15 +98,15 @@ class getID3
public $filename; // Filename of file being analysed.
public $fp; // Filepointer to file being analysed.
public $info; // Result array.
+ public $tempdir = GETID3_TEMP_DIR;
// Protected variables
protected $startup_error = '';
protected $startup_warning = '';
protected $memory_limit = 0;
- const VERSION = '1.9.3-20111213';
+ const VERSION = '1.9.4b1-20121005';
const FREAD_BUFFER_SIZE = 32768;
- var $tempdir = GETID3_TEMP_DIR;
const ATTACHMENTS_NONE = false;
const ATTACHMENTS_INLINE = true;
@@ -234,7 +225,7 @@ class getID3
// public: setOption
- function setOption($optArray) {
+ public function setOption($optArray) {
if (!is_array($optArray) || empty($optArray)) {
return false;
}
@@ -296,13 +287,23 @@ class getID3
(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];
+ if (class_exists('COM')) {
+ $filesystem = new COM('Scripting.FileSystemObject');
+ $file = $filesystem->GetFile($this->info['filenamepath']);
+ $real_filesize = $file->Size();
+ unset($filesystem, $file);
+ } else {
+ // From PHP 5.4.5, COM and DOTNET is no longer built into the php core.you have to add COM support in php.ini:
+ $this->warning('COM class not available.'.(version_compare(PHP_VERSION, '5.4.5', '>=') ? ' COM and DOTNET support are no longer built into PHP since v5.4.5, please enable in php.ini' : ''));
+
+ $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);
+ $commandline = 'ls -o -g -G --time-style=long-iso '.escapeshellarg($this->info['filenamepath']);
$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];
@@ -343,7 +344,7 @@ class getID3
}
// public: analyze file
- function analyze($filename) {
+ public function analyze($filename) {
try {
if (!$this->openfile($filename)) {
return $this->info;
@@ -447,18 +448,11 @@ class getID3
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);
+ $class = new $class_name($this);
+ //if (!empty($determined_format['set_inline_attachments'])) {
+ // $class->inline_attachments = $this->option_save_attachments;
//}
-
- if (!empty($determined_format['set_inline_attachments'])) {
- $class->inline_attachments = $this->option_save_attachments;
- }
$class->Analyze();
-
unset($class);
// close file
@@ -480,7 +474,7 @@ class getID3
// 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
+ // do not calc 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');
}
@@ -503,8 +497,8 @@ class getID3
}
- // private: error handling
- function error($message) {
+ // public: error handling
+ public function error($message) {
$this->CleanUp();
if (!isset($this->info['error'])) {
$this->info['error'] = array();
@@ -514,15 +508,15 @@ class getID3
}
- // private: warning handling
- function warning($message) {
+ // public: warning handling
+ public function warning($message) {
$this->info['warning'][] = $message;
return true;
}
// private: CleanUp
- function CleanUp() {
+ private function CleanUp() {
// remove possible empty keys
$AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
@@ -570,7 +564,7 @@ class getID3
// return array containing information about all supported formats
- function GetFileFormatArray() {
+ public function GetFileFormatArray() {
static $format_info = array();
if (empty($format_info)) {
$format_info = array(
@@ -594,15 +588,15 @@ class getID3
'fail_ape' => 'WARNING',
),
-
+/*
// AA - audio - Audible Audiobook
- 'adts' => array(
+ 'aa' => array(
'pattern' => '^.{4}\x57\x90\x75\x36',
'group' => 'audio',
'module' => 'aa',
- 'mime_type' => 'audio/audible ',
+ 'mime_type' => 'audio/audible',
),
-
+*/
// AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
'adts' => array(
'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]',
@@ -659,7 +653,7 @@ class getID3
'group' => 'audio',
'module' => 'flac',
'mime_type' => 'audio/x-flac',
- 'set_inline_attachments' => true,
+ //'set_inline_attachments' => true,
),
// LA - audio - Lossless Audio (LA)
@@ -839,7 +833,7 @@ class getID3
'group' => 'audio-video',
'module' => 'matroska',
'mime_type' => 'video/x-matroska', // may also be audio/x-matroska
- 'set_inline_attachments' => true,
+ //'set_inline_attachments' => true,
),
// MPEG - audio/video - MPEG (Moving Pictures Experts Group)
@@ -866,7 +860,7 @@ class getID3
'mime_type' => 'application/ogg',
'fail_id3' => 'WARNING',
'fail_ape' => 'WARNING',
- 'set_inline_attachments' => true,
+ //'set_inline_attachments' => true,
),
// QT - audio/video - Quicktime
@@ -902,6 +896,14 @@ class getID3
'mime_type' => 'application/x-shockwave-flash',
),
+ // TS - audio/video - MPEG-2 Transport Stream
+ 'ts' => array(
+ 'pattern' => '^\x47',
+ 'group' => 'audio-video',
+ 'module' => 'ts',
+ 'mime_type' => 'video/MP2T',
+ ),
+
// Still-Image formats
@@ -980,7 +982,7 @@ class getID3
// EFAX - still image - eFax (TIFF derivative)
- 'bmp' => array(
+ 'efax' => array(
'pattern' => '^\xDC\xFE',
'group' => 'graphic',
'module' => 'efax',
@@ -1102,7 +1104,7 @@ class getID3
- function GetFileFormat(&$filedata, $filename='') {
+ public function GetFileFormat(&$filedata, $filename='') {
// this function will determine the format of a file based on usually
// the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
// and in the case of ISO CD image, 6 bytes offset 32kb from the start
@@ -1141,7 +1143,7 @@ class getID3
// converts array to $encoding charset from $this->encoding
- function CharConvert(&$array, $encoding) {
+ public function CharConvert(&$array, $encoding) {
// identical encoding - end here
if ($encoding == $this->encoding) {
@@ -1164,7 +1166,7 @@ class getID3
}
- function HandleAllTags() {
+ public function HandleAllTags() {
// key name => array (tag name, character encoding)
static $tags;
@@ -1187,6 +1189,8 @@ class getID3
'ape' => array('ape' , 'UTF-8'),
'cue' => array('cue' , 'ISO-8859-1'),
'matroska' => array('matroska' , 'UTF-8'),
+ 'flac' => array('vorbiscomment' , 'UTF-8'),
+ 'divxtag' => array('divx' , 'ISO-8859-1'),
);
}
@@ -1201,7 +1205,6 @@ class getID3
// copy comments if key name set
if (!empty($this->info[$comment_name]['comments'])) {
-
foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
foreach ($valuearray as $key => $value) {
if (is_string($value)) {
@@ -1211,6 +1214,9 @@ class getID3
$this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value;
}
}
+ if ($tag_key == 'picture') {
+ unset($this->info[$comment_name]['comments'][$tag_key]);
+ }
}
if (!isset($this->info['tags'][$tag_name])) {
@@ -1284,7 +1290,7 @@ class getID3
}
- function getHashdata($algorithm) {
+ public function getHashdata($algorithm) {
switch ($algorithm) {
case 'md5':
case 'sha1':
@@ -1408,7 +1414,7 @@ class getID3
}
- function ChannelsBitratePlaytimeCalculations() {
+ public function ChannelsBitratePlaytimeCalculations() {
// set channelmode on audio
if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
@@ -1473,7 +1479,7 @@ class getID3
}
- function CalculateCompressionRatioVideo() {
+ public function CalculateCompressionRatioVideo() {
if (empty($this->info['video'])) {
return false;
}
@@ -1521,7 +1527,7 @@ class getID3
}
- function CalculateCompressionRatioAudio() {
+ public function CalculateCompressionRatioAudio() {
if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate'])) {
return false;
}
@@ -1538,7 +1544,7 @@ class getID3
}
- function CalculateReplayGain() {
+ public function CalculateReplayGain() {
if (isset($this->info['replay_gain'])) {
if (!isset($this->info['replay_gain']['reference_volume'])) {
$this->info['replay_gain']['reference_volume'] = (double) 89.0;
@@ -1560,7 +1566,7 @@ class getID3
return true;
}
- function ProcessAudioStreams() {
+ public function ProcessAudioStreams() {
if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
if (!isset($this->info['audio']['streams'])) {
foreach ($this->info['audio'] as $key => $value) {
@@ -1573,172 +1579,222 @@ class getID3
return true;
}
- function getid3_tempnam() {
+ public function getid3_tempnam() {
return tempnam($this->tempdir, 'gI3');
}
+ 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;
+ }
- 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
+abstract class getid3_handler
+{
+ protected $getid3; // pointer
- // extract to return array
- } elseif ($this->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
+ protected $data_string_flag = false; // analyzing filepointer or string
+ protected $data_string = ''; // string to analyze
+ protected $data_string_position = 0; // seek position in string
+ protected $data_string_length = 0; // string length
- // 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');
- }
+ private $dependency_to = null;
- // 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');
- }
+ public function __construct(getID3 $getid3, $call_module=null) {
+ $this->getid3 = $getid3;
- // 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;
- }
+ if ($call_module) {
+ $this->dependency_to = str_replace('getid3_', '', $call_module);
+ }
+ }
- } catch (Exception $e) {
- unset($ThisFileInfoIndex); // do not set any is case of error
- $this->warning('Failed to extract attachment '.$filename.': '.$e->getMessage());
- return false;
+ // Analyze from file pointer
+ abstract public function Analyze();
- }
- return true;
+
+ // Analyze from string instead
+ public function AnalyzeString($string) {
+ // Enter string mode
+ $this->setStringMode($string);
+
+ // Save info
+ $saved_avdataoffset = $this->getid3->info['avdataoffset'];
+ $saved_avdataend = $this->getid3->info['avdataend'];
+ $saved_filesize = (isset($this->getid3->info['filesize']) ? $this->getid3->info['filesize'] : null); // may be not set if called as dependency without openfile() call
+
+ // Reset some info
+ $this->getid3->info['avdataoffset'] = 0;
+ $this->getid3->info['avdataend'] = $this->getid3->info['filesize'] = $this->data_string_length;
+
+ // 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;
}
+ public function setStringMode($string) {
+ $this->data_string_flag = true;
+ $this->data_string = $string;
+ $this->data_string_length = strlen($string);
+ }
- 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.');
+ protected function ftell() {
+ if ($this->data_string_flag) {
+ return $this->data_string_position;
}
- include_once(GETID3_INCLUDEPATH.'module.'.$name.'.php');
- return true;
+ 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);
+ }
+ $pos = $this->ftell() + $bytes;
+ if (!getid3_lib::intValueSupported($pos)) {
+ throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
+ }
+ 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;
+ break;
-abstract class getid3_handler
-{
- protected $getid3; // pointer
+ case SEEK_CUR:
+ $this->data_string_position += $bytes;
+ break;
+
+ case SEEK_END:
+ $this->data_string_position = $this->data_string_length + $bytes;
+ break;
+ }
+ return 0;
+ } else {
+ $pos = $bytes;
+ if ($whence == SEEK_CUR) {
+ $pos = $this->ftell() + $bytes;
+ } elseif ($whence == SEEK_END) {
+ $pos = $this->info['filesize'] + $bytes;
+ }
+ if (!getid3_lib::intValueSupported($pos)) {
+ throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
+ }
+ }
+ return fseek($this->getid3->fp, $bytes, $whence);
+ }
- protected $data_string_flag = false; // analyzing filepointer or string
- protected $data_string; // string to analyze
- protected $data_string_position = 0; // seek position in string
+ protected function feof() {
+ if ($this->data_string_flag) {
+ return $this->data_string_position >= $this->data_string_length;
+ }
+ return feof($this->getid3->fp);
+ }
+ final protected function isDependencyFor($module) {
+ return $this->dependency_to == $module;
+ }
- public function __construct(getID3 $getid3) {
- $this->getid3 = $getid3;
- }
+ protected function error($text)
+ {
+ $this->getid3->info['error'][] = $text;
+ return false;
+ }
- // Analyze from file pointer
- abstract public function Analyze();
+ protected function warning($text)
+ {
+ return $this->getid3->warning($text);
+ }
+ protected function notice($text)
+ {
+ // does nothing for now
+ }
- // Analyze from string instead
- public function AnalyzeString(&$string) {
- // Enter string mode
- $this->data_string_flag = true;
- $this->data_string = $string;
+ public function saveAttachment($name, $offset, $length, $image_mime=null) {
+ try {
- // Save info
- $saved_avdataoffset = $this->getid3->info['avdataoffset'];
- $saved_avdataend = $this->getid3->info['avdataend'];
- $saved_filesize = $this->getid3->info['filesize'];
+ // do not extract at all
+ if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
- // Reset some info
- $this->getid3->info['avdataoffset'] = 0;
- $this->getid3->info['avdataend'] = $this->getid3->info['filesize'] = strlen($string);
+ $attachment = null; // do not set any
- // Analyze
- $this->Analyze();
+ // extract to return array
+ } elseif ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
- // Restore some info
- $this->getid3->info['avdataoffset'] = $saved_avdataoffset;
- $this->getid3->info['avdataend'] = $saved_avdataend;
- $this->getid3->info['filesize'] = $saved_filesize;
+ $this->fseek($offset);
+ $attachment = $this->fread($length); // get whole data in one pass, till it is anyway stored in memory
+ if ($attachment === false || strlen($attachment) != $length) {
+ throw new Exception('failed to read attachment data');
+ }
- // Exit string mode
- $this->data_string_flag = false;
- }
+ // assume directory path is given
+ } else {
+ // set up destination path
+ $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR);
+ if (!is_dir($dir) || !is_writable($dir)) { // check supplied directory
+ throw new Exception('supplied path ('.$dir.') does not exist, or is not writable');
+ }
+ $dest = $dir.DIRECTORY_SEPARATOR.$name.($image_mime ? '.'.getid3_lib::ImageExtFromMime($image_mime) : '');
- protected function ftell() {
- if ($this->data_string_flag) {
- return $this->data_string_position;
- }
- return ftell($this->getid3->fp);
- }
+ // create dest file
+ if (($fp_dest = fopen($dest, 'wb')) == false) {
+ throw new Exception('failed to create file '.$dest);
+ }
+ // copy data
+ $this->fseek($offset);
+ $buffersize = ($this->data_string_flag ? $length : $this->getid3->fread_buffer_size());
+ $bytesleft = $length;
+ while ($bytesleft > 0) {
+ if (($buffer = $this->fread(min($buffersize, $bytesleft))) === false || ($byteswritten = fwrite($fp_dest, $buffer)) === false) {
+ throw new Exception($buffer === false ? 'not enough data to read' : 'failed to write to destination file, may be not enough disk space');
+ }
+ $bytesleft -= $byteswritten;
+ }
- 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);
- }
+ fclose($fp_dest);
+ $attachment = $dest;
+ }
- protected function fseek($bytes, $whence = SEEK_SET) {
- if ($this->data_string_flag) {
- switch ($whence) {
- case SEEK_SET:
- $this->data_string_position = $bytes;
- return;
+ } catch(Exception $e) {
- case SEEK_CUR:
- $this->data_string_position += $bytes;
- return;
+ if (isset($fp_dest) && is_resource($fp_dest)) { // close and remove dest file if created
+ fclose($fp_dest);
+ unlink($dest);
+ }
+ $attachment = null; // do not set any is case of error
+ $this->warning('Failed to extract attachment '.$name.': '.$e->getMessage());
+ return false;
- case SEEK_END:
- $this->data_string_position = strlen($this->data_string) + $bytes;
- return;
- }
- }
- return fseek($this->getid3->fp, $bytes, $whence);
- }
+ }
+ return $attachment;
+ }
}
class getid3_exception extends Exception
{
- public $message;
+ public $message;
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.archive.gzip.php b/modules/getid3/module.archive.gzip.php
index c30052ed..f8818df5 100644
--- a/modules/getid3/module.archive.gzip.php
+++ b/modules/getid3/module.archive.gzip.php
@@ -22,9 +22,9 @@
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)
+ public $option_gzip_parse_contents = false; // decode gzipped files, if possible, and parse recursively (.tar.gz for example)
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'gzip';
@@ -245,7 +245,7 @@ class getid3_gzip extends getid3_handler {
}
// Converts the OS type
- function get_os_type($key) {
+ public function get_os_type($key) {
static $os_type = array(
'0' => 'FAT filesystem (MS-DOS, OS/2, NT/Win32)',
'1' => 'Amiga',
@@ -267,7 +267,7 @@ class getid3_gzip extends getid3_handler {
}
// Converts the eXtra FLags
- function get_xflag_type($key) {
+ public function get_xflag_type($key) {
static $xflag_type = array(
'0' => 'unknown',
'2' => 'maximum compression',
@@ -277,4 +277,3 @@ class getid3_gzip extends getid3_handler {
}
}
-?>
diff --git a/modules/getid3/module.archive.rar.php b/modules/getid3/module.archive.rar.php
index 4f5d46f8..e3155e40 100644
--- a/modules/getid3/module.archive.rar.php
+++ b/modules/getid3/module.archive.rar.php
@@ -17,9 +17,9 @@
class getid3_rar extends getid3_handler
{
- var $option_use_rar_extension = false;
+ public $option_use_rar_extension = false;
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'rar';
@@ -48,6 +48,3 @@ class getid3_rar extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.archive.szip.php b/modules/getid3/module.archive.szip.php
index 3be62532..8741e722 100644
--- a/modules/getid3/module.archive.szip.php
+++ b/modules/getid3/module.archive.szip.php
@@ -17,7 +17,7 @@
class getid3_szip extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -92,5 +92,3 @@ class getid3_szip extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.archive.tar.php b/modules/getid3/module.archive.tar.php
index 94d32039..ef4672ca 100644
--- a/modules/getid3/module.archive.tar.php
+++ b/modules/getid3/module.archive.tar.php
@@ -22,7 +22,7 @@
class getid3_tar extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'tar';
@@ -96,13 +96,13 @@ class getid3_tar extends getid3_handler
$info['tar']['file_details'][$name] = array (
'name' => $name,
'mode_raw' => $mode,
- 'mode' => getid3_tar::display_perms($mode),
+ 'mode' => self::display_perms($mode),
'uid' => $uid,
'gid' => $gid,
'size' => $size,
'mtime' => $mtime,
'chksum' => $chksum,
- 'typeflag' => getid3_tar::get_flag_type($typflag),
+ 'typeflag' => self::get_flag_type($typflag),
'linkname' => $lnkname,
'magic' => $magic,
'version' => $ver,
@@ -117,7 +117,7 @@ class getid3_tar extends getid3_handler
}
// Parses the file mode to file permissions
- function display_perms($mode) {
+ public function display_perms($mode) {
// Determine Type
if ($mode & 0x1000) $type='p'; // FIFO pipe
elseif ($mode & 0x2000) $type='c'; // Character special
@@ -152,7 +152,7 @@ class getid3_tar extends getid3_handler
}
// Converts the file type
- function get_flag_type($typflag) {
+ public function get_flag_type($typflag) {
static $flag_types = array(
'0' => 'LF_NORMAL',
'1' => 'LF_LINK',
@@ -174,5 +174,3 @@ class getid3_tar extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.archive.zip.php b/modules/getid3/module.archive.zip.php
index 7db8fd23..e846a20a 100644
--- a/modules/getid3/module.archive.zip.php
+++ b/modules/getid3/module.archive.zip.php
@@ -17,7 +17,7 @@
class getid3_zip extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'zip';
@@ -107,7 +107,7 @@ class getid3_zip extends getid3_handler
}
- function getZIPHeaderFilepointerTopDown() {
+ public function getZIPHeaderFilepointerTopDown() {
$info = &$this->getid3->info;
$info['fileformat'] = 'zip';
@@ -153,7 +153,7 @@ class getid3_zip extends getid3_handler
}
- function getZIPentriesFilepointer() {
+ public function getZIPentriesFilepointer() {
$info = &$this->getid3->info;
$info['zip']['compressed_size'] = 0;
@@ -176,7 +176,7 @@ class getid3_zip extends getid3_handler
}
- function ZIPparseLocalFileHeader() {
+ public function ZIPparseLocalFileHeader() {
$LocalFileHeader['offset'] = ftell($this->getid3->fp);
$ZIPlocalFileHeader = fread($this->getid3->fp, 30);
@@ -233,7 +233,7 @@ class getid3_zip extends getid3_handler
}
- function ZIPparseCentralDirectory() {
+ public function ZIPparseCentralDirectory() {
$CentralDirectory['offset'] = ftell($this->getid3->fp);
$ZIPcentralDirectory = fread($this->getid3->fp, 46);
@@ -289,7 +289,7 @@ class getid3_zip extends getid3_handler
return $CentralDirectory;
}
- function ZIPparseEndOfCentralDirectory() {
+ public function ZIPparseEndOfCentralDirectory() {
$EndOfCentralDirectory['offset'] = ftell($this->getid3->fp);
$ZIPendOfCentralDirectory = fread($this->getid3->fp, 22);
@@ -316,7 +316,7 @@ class getid3_zip extends getid3_handler
}
- static function ZIPparseGeneralPurposeFlags($flagbytes, $compressionmethod) {
+ public static function ZIPparseGeneralPurposeFlags($flagbytes, $compressionmethod) {
$ParsedFlags['encrypted'] = (bool) ($flagbytes & 0x0001);
switch ($compressionmethod) {
@@ -349,7 +349,7 @@ class getid3_zip extends getid3_handler
}
- static function ZIPversionOSLookup($index) {
+ public static function ZIPversionOSLookup($index) {
static $ZIPversionOSLookup = array(
0 => 'MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)',
1 => 'Amiga',
@@ -374,7 +374,7 @@ class getid3_zip extends getid3_handler
return (isset($ZIPversionOSLookup[$index]) ? $ZIPversionOSLookup[$index] : '[unknown]');
}
- static function ZIPcompressionMethodLookup($index) {
+ public static function ZIPcompressionMethodLookup($index) {
static $ZIPcompressionMethodLookup = array(
0 => 'store',
1 => 'shrink',
@@ -392,7 +392,7 @@ class getid3_zip extends getid3_handler
return (isset($ZIPcompressionMethodLookup[$index]) ? $ZIPcompressionMethodLookup[$index] : '[unknown]');
}
- static function DOStime2UNIXtime($DOSdate, $DOStime) {
+ public 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
@@ -419,6 +419,3 @@ class getid3_zip extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio-video.asf.php b/modules/getid3/module.audio-video.asf.php
index 0bb095f5..cfc60a78 100644
--- a/modules/getid3/module.audio-video.asf.php
+++ b/modules/getid3/module.audio-video.asf.php
@@ -18,7 +18,7 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php',
class getid3_asf extends getid3_handler
{
- function __construct(getID3 $getid3) {
+ public function __construct(getID3 $getid3) {
parent::__construct($getid3); // extends getid3_handler::__construct()
// initialize all GUID constants
@@ -30,7 +30,7 @@ class getid3_asf extends getid3_handler
}
}
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// Shortcuts
@@ -226,7 +226,7 @@ class getid3_asf extends getid3_handler
$thisfile_audio['dataformat'] = (!empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf');
$thisfile_audio['bitrate_mode'] = (!empty($thisfile_audio['bitrate_mode']) ? $thisfile_audio['bitrate_mode'] : 'cbr');
- $audiodata = getid3_riff::RIFFparseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16));
+ $audiodata = getid3_riff::parseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16));
unset($audiodata['raw']);
$thisfile_audio = getid3_lib::array_merge_noclobber($audiodata, $thisfile_audio);
break;
@@ -1033,7 +1033,7 @@ class getid3_asf extends getid3_handler
$audiomediaoffset = 0;
- $thisfile_asf_audiomedia_currentstream = getid3_riff::RIFFparseWAVEFORMATex(substr($streamdata['type_specific_data'], $audiomediaoffset, 16));
+ $thisfile_asf_audiomedia_currentstream = getid3_riff::parseWAVEFORMATex(substr($streamdata['type_specific_data'], $audiomediaoffset, 16));
$audiomediaoffset += 16;
$thisfile_audio['lossless'] = false;
@@ -1141,7 +1141,7 @@ class getid3_asf extends getid3_handler
}
}
- $thisfile_asf_videomedia_currentstream['format_data']['codec'] = getid3_riff::RIFFfourccLookup($thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']);
+ $thisfile_asf_videomedia_currentstream['format_data']['codec'] = getid3_riff::fourccLookup($thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']);
$thisfile_video['streams'][$streamnumber]['fourcc'] = $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc'];
$thisfile_video['streams'][$streamnumber]['codec'] = $thisfile_asf_videomedia_currentstream['format_data']['codec'];
@@ -1451,7 +1451,7 @@ class getid3_asf extends getid3_handler
return true;
}
- static function ASFCodecListObjectTypeLookup($CodecListType) {
+ public static function ASFCodecListObjectTypeLookup($CodecListType) {
static $ASFCodecListObjectTypeLookup = array();
if (empty($ASFCodecListObjectTypeLookup)) {
$ASFCodecListObjectTypeLookup[0x0001] = 'Video Codec';
@@ -1462,7 +1462,7 @@ class getid3_asf extends getid3_handler
return (isset($ASFCodecListObjectTypeLookup[$CodecListType]) ? $ASFCodecListObjectTypeLookup[$CodecListType] : 'Invalid Codec Type');
}
- static function KnownGUIDs() {
+ public 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',
@@ -1576,15 +1576,15 @@ class getid3_asf extends getid3_handler
return $GUIDarray;
}
- static function GUIDname($GUIDstring) {
+ public static function GUIDname($GUIDstring) {
static $GUIDarray = array();
if (empty($GUIDarray)) {
- $GUIDarray = getid3_asf::KnownGUIDs();
+ $GUIDarray = self::KnownGUIDs();
}
return array_search($GUIDstring, $GUIDarray);
}
- static function ASFIndexObjectIndexTypeLookup($id) {
+ public static function ASFIndexObjectIndexTypeLookup($id) {
static $ASFIndexObjectIndexTypeLookup = array();
if (empty($ASFIndexObjectIndexTypeLookup)) {
$ASFIndexObjectIndexTypeLookup[1] = 'Nearest Past Data Packet';
@@ -1594,7 +1594,7 @@ class getid3_asf extends getid3_handler
return (isset($ASFIndexObjectIndexTypeLookup[$id]) ? $ASFIndexObjectIndexTypeLookup[$id] : 'invalid');
}
- static function GUIDtoBytestring($GUIDstring) {
+ public 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
@@ -1629,7 +1629,7 @@ class getid3_asf extends getid3_handler
return $hexbytecharstring;
}
- static function BytestringToGUID($Bytestring) {
+ public 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);
@@ -1654,7 +1654,7 @@ class getid3_asf extends getid3_handler
return strtoupper($GUIDstring);
}
- static function FILETIMEtoUNIXtime($FILETIME, $round=true) {
+ public 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
@@ -1665,7 +1665,7 @@ class getid3_asf extends getid3_handler
return ($FILETIME - 116444736000000000) / 10000000;
}
- static function WMpictureTypeLookup($WMpictureType) {
+ public static function WMpictureTypeLookup($WMpictureType) {
static $WMpictureTypeLookup = array();
if (empty($WMpictureTypeLookup)) {
$WMpictureTypeLookup[0x03] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Front Cover');
@@ -1690,7 +1690,7 @@ class getid3_asf extends getid3_handler
return (isset($WMpictureTypeLookup[$WMpictureType]) ? $WMpictureTypeLookup[$WMpictureType] : '');
}
- function ASF_HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections) {
+ public function ASF_HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections) {
// http://msdn.microsoft.com/en-us/library/bb643323.aspx
$offset = 0;
@@ -1937,7 +1937,7 @@ class getid3_asf extends getid3_handler
}
- static function ASFmetadataLibraryObjectDataTypeLookup($id) {
+ public 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
@@ -1950,7 +1950,7 @@ class getid3_asf extends getid3_handler
return (isset($ASFmetadataLibraryObjectDataTypeLookup[$id]) ? $ASFmetadataLibraryObjectDataTypeLookup[$id] : 'invalid');
}
- function ASF_WMpicture(&$data) {
+ public function ASF_WMpicture(&$data) {
//typedef struct _WMPicture{
// LPWSTR pwszMIMEType;
// BYTE bPictureType;
@@ -2002,13 +2002,13 @@ class getid3_asf extends getid3_handler
// 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)), ' ');
+ public static function TrimConvert($string) {
+ return trim(getid3_lib::iconv_fallback('UTF-16LE', 'ISO-8859-1', self::TrimTerm($string)), ' ');
}
// Remove terminator 00 00
- static function TrimTerm($string) {
+ public static function TrimTerm($string) {
// remove terminator, only if present (it should be, but...)
if (substr($string, -2) === "\x00\x00") {
$string = substr($string, 0, -2);
@@ -2017,5 +2017,3 @@ class getid3_asf extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio-video.bink.php b/modules/getid3/module.audio-video.bink.php
index 0a321396..19262766 100644
--- a/modules/getid3/module.audio-video.bink.php
+++ b/modules/getid3/module.audio-video.bink.php
@@ -17,7 +17,7 @@
class getid3_bink extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['error'][] = 'Bink / Smacker files not properly processed by this version of getID3() ['.$this->getid3->version().']';
@@ -43,7 +43,7 @@ $info['error'][] = 'Bink / Smacker files not properly processed by this version
}
- function ParseBink() {
+ public function ParseBink() {
$info = &$this->getid3->info;
$info['fileformat'] = 'bink';
$info['video']['dataformat'] = 'bink';
@@ -60,7 +60,7 @@ $info['error'][] = 'Bink / Smacker files not properly processed by this version
return true;
}
- function ParseSmacker() {
+ public function ParseSmacker() {
$info = &$this->getid3->info;
$info['fileformat'] = 'smacker';
$info['video']['dataformat'] = 'smacker';
@@ -69,5 +69,3 @@ $info['error'][] = 'Bink / Smacker files not properly processed by this version
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio-video.flv.php b/modules/getid3/module.audio-video.flv.php
index ba3cd908..aef8a2fb 100644
--- a/modules/getid3/module.audio-video.flv.php
+++ b/modules/getid3/module.audio-video.flv.php
@@ -4,7 +4,7 @@
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// //
-// FLV module by Seth Kaufman <seth@whirl-i-gig.com> //
+// FLV module by Seth Kaufman <sethØwhirl-i-gig*com> //
// //
// * version 0.1 (26 June 2005) //
// //
@@ -14,7 +14,7 @@
// //
// * version 0.2 (22 February 2006) //
// Support for On2 VP6 codec and meta information //
-// by Steve Webster <steve.webster@featurecreep.com> //
+// by Steve Webster <steve.websterØfeaturecreep*com> //
// //
// * version 0.3 (15 June 2006) //
// Modified to not read entire file into memory //
@@ -23,13 +23,13 @@
// * version 0.4 (07 December 2007) //
// Bugfixes for incorrectly parsed FLV dimensions //
// and incorrect parsing of onMetaTag //
-// by Evgeny Moysevich <moysevich@gmail.com> //
+// 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> //
+// by Nigel Barnes <ngbarnesØhotmail*com> //
// //
// * version 0.6 (24 May 2009) //
// Better parsing of files with h264 video //
@@ -69,9 +69,9 @@ 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
+ public $max_frames = 100000; // break out of the loop if too many frames have been scanned; only scan this many if meta frame does not contain useful duration
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -317,7 +317,7 @@ class getid3_flv extends getid3_handler
}
- function FLVaudioFormat($id) {
+ public function FLVaudioFormat($id) {
$FLVaudioFormat = array(
0 => 'Linear PCM, platform endian',
1 => 'ADPCM',
@@ -339,7 +339,7 @@ class getid3_flv extends getid3_handler
return (isset($FLVaudioFormat[$id]) ? $FLVaudioFormat[$id] : false);
}
- function FLVaudioRate($id) {
+ public function FLVaudioRate($id) {
$FLVaudioRate = array(
0 => 5500,
1 => 11025,
@@ -349,7 +349,7 @@ class getid3_flv extends getid3_handler
return (isset($FLVaudioRate[$id]) ? $FLVaudioRate[$id] : false);
}
- function FLVaudioBitDepth($id) {
+ public function FLVaudioBitDepth($id) {
$FLVaudioBitDepth = array(
0 => 8,
1 => 16,
@@ -357,7 +357,7 @@ class getid3_flv extends getid3_handler
return (isset($FLVaudioBitDepth[$id]) ? $FLVaudioBitDepth[$id] : false);
}
- function FLVvideoCodec($id) {
+ public function FLVvideoCodec($id) {
$FLVvideoCodec = array(
GETID3_FLV_VIDEO_H263 => 'Sorenson H.263',
GETID3_FLV_VIDEO_SCREEN => 'Screen video',
@@ -371,82 +371,82 @@ class getid3_flv extends getid3_handler
}
class AMFStream {
- var $bytes;
- var $pos;
+ public $bytes;
+ public $pos;
- function AMFStream(&$bytes) {
+ public function AMFStream(&$bytes) {
$this->bytes =& $bytes;
$this->pos = 0;
}
- function readByte() {
+ public function readByte() {
return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
}
- function readInt() {
+ public function readInt() {
return ($this->readByte() << 8) + $this->readByte();
}
- function readLong() {
+ public function readLong() {
return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
}
- function readDouble() {
+ public function readDouble() {
return getid3_lib::BigEndian2Float($this->read(8));
}
- function readUTF() {
+ public function readUTF() {
$length = $this->readInt();
return $this->read($length);
}
- function readLongUTF() {
+ public function readLongUTF() {
$length = $this->readLong();
return $this->read($length);
}
- function read($length) {
+ public function read($length) {
$val = substr($this->bytes, $this->pos, $length);
$this->pos += $length;
return $val;
}
- function peekByte() {
+ public function peekByte() {
$pos = $this->pos;
$val = $this->readByte();
$this->pos = $pos;
return $val;
}
- function peekInt() {
+ public function peekInt() {
$pos = $this->pos;
$val = $this->readInt();
$this->pos = $pos;
return $val;
}
- function peekLong() {
+ public function peekLong() {
$pos = $this->pos;
$val = $this->readLong();
$this->pos = $pos;
return $val;
}
- function peekDouble() {
+ public function peekDouble() {
$pos = $this->pos;
$val = $this->readDouble();
$this->pos = $pos;
return $val;
}
- function peekUTF() {
+ public function peekUTF() {
$pos = $this->pos;
$val = $this->readUTF();
$this->pos = $pos;
return $val;
}
- function peekLongUTF() {
+ public function peekLongUTF() {
$pos = $this->pos;
$val = $this->readLongUTF();
$this->pos = $pos;
@@ -455,13 +455,13 @@ class AMFStream {
}
class AMFReader {
- var $stream;
+ public $stream;
- function AMFReader(&$stream) {
+ public function AMFReader(&$stream) {
$this->stream =& $stream;
}
- function readData() {
+ public function readData() {
$value = null;
$type = $this->stream->readByte();
@@ -531,19 +531,19 @@ class AMFReader {
return $value;
}
- function readDouble() {
+ public function readDouble() {
return $this->stream->readDouble();
}
- function readBoolean() {
+ public function readBoolean() {
return $this->stream->readByte() == 1;
}
- function readString() {
+ public function readString() {
return $this->stream->readUTF();
}
- function readObject() {
+ public function readObject() {
// Get highest numerical index - ignored
// $highestIndex = $this->stream->readLong();
@@ -560,7 +560,7 @@ class AMFReader {
return $data;
}
- function readMixedArray() {
+ public function readMixedArray() {
// Get highest numerical index - ignored
$highestIndex = $this->stream->readLong();
@@ -581,7 +581,7 @@ class AMFReader {
return $data;
}
- function readArray() {
+ public function readArray() {
$length = $this->stream->readLong();
$data = array();
@@ -591,39 +591,39 @@ class AMFReader {
return $data;
}
- function readDate() {
+ public function readDate() {
$timestamp = $this->stream->readDouble();
$timezone = $this->stream->readInt();
return $timestamp;
}
- function readLongString() {
+ public function readLongString() {
return $this->stream->readLongUTF();
}
- function readXML() {
+ public function readXML() {
return $this->stream->readLongUTF();
}
- function readTypedObject() {
+ public 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) {
+ public $sps;
+ public $start = 0;
+ public $currentBytes = 0;
+ public $currentBits = 0;
+ public $width;
+ public $height;
+
+ public function AVCSequenceParameterSetReader($sps) {
$this->sps = $sps;
}
- function readData() {
+ public function readData() {
$this->skipBits(8);
$this->skipBits(8);
$profile = $this->getBits(8); // read profile
@@ -675,19 +675,19 @@ class AVCSequenceParameterSetReader {
$this->height = (2 - $this->getBit()) * $heightMap * 16;
}
- function skipBits($bits) {
+ public function skipBits($bits) {
$newBits = $this->currentBits + $bits;
$this->currentBytes += (int)floor($newBits / 8);
$this->currentBits = $newBits % 8;
}
- function getBit() {
+ public function getBit() {
$result = (getid3_lib::BigEndian2Int(substr($this->sps, $this->currentBytes, 1)) >> (7 - $this->currentBits)) & 0x01;
$this->skipBits(1);
return $result;
}
- function getBits($bits) {
+ public function getBits($bits) {
$result = 0;
for ($i = 0; $i < $bits; $i++) {
$result = ($result << 1) + $this->getBit();
@@ -695,7 +695,7 @@ class AVCSequenceParameterSetReader {
return $result;
}
- function expGolombUe() {
+ public function expGolombUe() {
$significantBits = 0;
$bit = $this->getBit();
while ($bit == 0) {
@@ -710,7 +710,7 @@ class AVCSequenceParameterSetReader {
return (1 << $significantBits) + $this->getBits($significantBits) - 1;
}
- function expGolombSe() {
+ public function expGolombSe() {
$result = $this->expGolombUe();
if (($result & 0x01) == 0) {
return -($result >> 1);
@@ -719,13 +719,11 @@ class AVCSequenceParameterSetReader {
}
}
- function getWidth() {
+ public function getWidth() {
return $this->width;
}
- function getHeight() {
+ public function getHeight() {
return $this->height;
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio-video.matroska.php b/modules/getid3/module.audio-video.matroska.php
index b7ab6679..d1359f4f 100644
--- a/modules/getid3/module.audio-video.matroska.php
+++ b/modules/getid3/module.audio-video.matroska.php
@@ -90,7 +90,8 @@ define('EBML_ID_CUEBLOCKNUMBER', 0x1378); // [53][78] --
define('EBML_ID_TRACKOFFSET', 0x137F); // [53][7F] -- A value to add to the Block's Timecode. This can be used to adjust the playback offset of a track.
define('EBML_ID_SEEKID', 0x13AB); // [53][AB] -- The binary ID corresponding to the element name.
define('EBML_ID_SEEKPOSITION', 0x13AC); // [53][AC] -- The position of the element in the segment in octets (0 = first level 1 element).
-define('EBML_ID_STEREOMODE', 0x13B8); // [53][B8] -- Stereo-3D video mode on 2 bits (0: mono, 1: right eye, 2: left eye, 3: both eyes).
+define('EBML_ID_STEREOMODE', 0x13B8); // [53][B8] -- Stereo-3D video mode.
+define('EBML_ID_OLDSTEREOMODE', 0x13B9); // [53][B9] -- Bogus StereoMode value used in old versions of libmatroska. DO NOT USE. (0: mono, 1: right eye, 2: left eye, 3: both eyes).
define('EBML_ID_PIXELCROPBOTTOM', 0x14AA); // [54][AA] -- The number of video pixels to remove at the bottom of the image (for HDTV content).
define('EBML_ID_DISPLAYWIDTH', 0x14B0); // [54][B0] -- Width of the video frames to display.
define('EBML_ID_DISPLAYUNIT', 0x14B2); // [54][B2] -- Type of the unit for DisplayWidth/Height (0: pixels, 1: centimeters, 2: inches).
@@ -218,7 +219,7 @@ class getid3_matroska extends getid3_handler
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;
@@ -226,8 +227,7 @@ class getid3_matroska extends getid3_handler
// parse container
try {
$this->parseEBML($info);
- }
- catch (Exception $e) {
+ } catch (Exception $e) {
$info['error'][] = 'EBML parser: '.$e->getMessage();
}
@@ -252,44 +252,67 @@ class getid3_matroska extends getid3_handler
// 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['dataformat'] = self::CodecIDtoCommonName($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']; }
-
+ 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"');
+ $this->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']);
+ $track_info['codec'] = getid3_riff::fourccLookup($parsed['fourcc']);
$info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
break;
+
+ /*case 'V_MPEG4/ISO/AVC':
+ $h264['profile'] = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 1, 1));
+ $h264['level'] = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 3, 1));
+ $rn = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 4, 1));
+ $h264['NALUlength'] = ($rn & 3) + 1;
+ $rn = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 5, 1));
+ $nsps = ($rn & 31);
+ $offset = 6;
+ for ($i = 0; $i < $nsps; $i ++) {
+ $length = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 2));
+ $h264['SPS'][] = substr($trackarray['CodecPrivate'], $offset + 2, $length);
+ $offset += 2 + $length;
+ }
+ $npps = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 1));
+ $offset += 1;
+ for ($i = 0; $i < $npps; $i ++) {
+ $length = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 2));
+ $h264['PPS'][] = substr($trackarray['CodecPrivate'], $offset + 2, $length);
+ $offset += 2 + $length;
+ }
+ $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $h264;
+ 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']; }
-
+ if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; }
+
switch ($trackarray['CodecID']) {
case 'A_PCM/INT/LIT':
case 'A_PCM/INT/BIG':
@@ -299,32 +322,32 @@ class getid3_matroska extends getid3_handler
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"');
+ case 'A_MPEG/L2':
+ case 'A_FLAC':
+ if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.'.($track_info['dataformat'] == 'mp2' ? 'mp3' : $track_info['dataformat']).'.php', __FILE__, false)) {
+ $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio.'.$track_info['dataformat'].'.php"');
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');
+ $this->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);
+ if ($track_info['dataformat'] != 'flac') {
+ $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') {
+ if ($track_info['dataformat'][0] == 'm' || $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;
- }
+ $class = 'getid3_'.($track_info['dataformat'] == 'mp2' ? 'mp3' : $track_info['dataformat']);
+ $header_data_key = $track_info['dataformat'][0] == 'm' ? 'mpeg' : $track_info['dataformat'];
+ $getid3_audio = new $class($getid3_temp, __CLASS__);
if ($track_info['dataformat'] == 'flac') {
$getid3_audio->AnalyzeString($trackarray['CodecPrivate']);
}
@@ -332,7 +355,6 @@ class getid3_matroska extends getid3_handler
$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) {
@@ -341,13 +363,13 @@ class getid3_matroska extends getid3_handler
}
}
else {
- $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because '.$class.'::Analyze() failed at offset '.$getid3_temp->info['avdataoffset']);
+ $this->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.']');
+ $this->warning($class.'() says: ['.$newerror.']');
}
}
if (!empty($getid3_temp->info['warning'])) {
@@ -356,7 +378,7 @@ class getid3_matroska extends getid3_handler
// 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.']');
+ $this->warning($class.'() says: ['.$newerror.']');
}
}
unset($getid3_temp, $getid3_audio);
@@ -364,30 +386,31 @@ class getid3_matroska extends getid3_handler
case 'A_AAC':
case 'A_AAC/MPEG2/LC':
+ case 'A_AAC/MPEG2/LC/SBR':
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');
+ $this->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');
+ $this->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');
+ $this->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"');
+ $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio.ogg.php"');
+ break;
}
// create temp instance
$getid3_temp = new getID3();
- $getid3_temp->openfile($this->getid3->filename);
// analyze
$getid3_ogg = new getid3_ogg($getid3_temp);
@@ -401,19 +424,19 @@ class getid3_matroska extends getid3_handler
}
}
}
-
+
// copy errors and warnings
if (!empty($getid3_temp->info['error'])) {
foreach ($getid3_temp->info['error'] as $newerror) {
- $this->getid3->warning('getid3_ogg() says: ['.$newerror.']');
+ $this->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.']');
+ $this->warning('getid3_ogg() says: ['.$newerror.']');
}
}
-
+
if (!empty($getid3_temp->info['ogg']['bitrate_nominal'])) {
$track_info['bitrate'] = $getid3_temp->info['ogg']['bitrate_nominal'];
}
@@ -422,11 +445,11 @@ class getid3_matroska extends getid3_handler
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"');
+ $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio-video.riff.php"');
break;
}
-
- $parsed = getid3_riff::RIFFparseWAVEFORMATex($trackarray['CodecPrivate']);
+
+ $parsed = getid3_riff::parseWAVEFORMATex($trackarray['CodecPrivate']);
foreach ($parsed as $key => $value) {
if ($key != 'raw') {
$track_info[$key] = $value;
@@ -434,16 +457,16 @@ class getid3_matroska extends getid3_handler
}
$info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
break;
-
+
default:
- $this->getid3->warning('Unhandled audio type "'.(isset($trackarray['CodecID']) ? $trackarray['CodecID'] : '').'"');
+ $this->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']);
}
@@ -452,6 +475,15 @@ class getid3_matroska extends getid3_handler
}
}
+ // process attachments
+ if (isset($info['matroska']['attachments']) && $this->getid3->option_save_attachments !== getID3::ATTACHMENTS_NONE) {
+ foreach ($info['matroska']['attachments'] as $i => $entry) {
+ if (strpos($entry['FileMimeType'], 'image/') === 0 && !empty($entry['FileData'])) {
+ $info['matroska']['comments']['picture'][] = array('data' => $entry['FileData'], 'image_mime' => $entry['FileMimeType'], 'filename' => $entry['FileName']);
+ }
+ }
+ }
+
// determine mime type
if (!empty($info['video']['streams'])) {
$info['mime_type'] = ($info['matroska']['doctype'] == 'webm' ? 'video/webm' : 'video/x-matroska');
@@ -464,11 +496,7 @@ class getid3_matroska extends getid3_handler
return true;
}
-
-///////////////////////////////////////
-
- private function parseEBML(&$info)
- {
+ private function parseEBML(&$info) {
// http://www.matroska.org/technical/specs/index.html#EBMLBasics
$this->current_offset = $info['avdataoffset'];
@@ -564,7 +592,7 @@ class getid3_matroska extends getid3_handler
case EBML_ID_TRACKENTRY: //subelements: Describes a track with all elements.
- while ($this->getEBMLelement($subelement, $track_entry['end'], array(EBML_ID_VIDEO, EBML_ID_AUDIO, EBML_ID_CONTENTENCODINGS))) {
+ while ($this->getEBMLelement($subelement, $track_entry['end'], array(EBML_ID_VIDEO, EBML_ID_AUDIO, EBML_ID_CONTENTENCODINGS, EBML_ID_CODECPRIVATE))) {
switch ($subelement['id']) {
case EBML_ID_TRACKNUMBER:
@@ -587,9 +615,9 @@ class getid3_matroska extends getid3_handler
case EBML_ID_CODECNAME:
$track_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
break;
-
+
case EBML_ID_CODECPRIVATE:
- $track_entry[$subelement['id_name']] = $subelement['data'];
+ $track_entry[$subelement['id_name']] = $this->readEBMLelementData($subelement['length'], true);
break;
case EBML_ID_FLAGENABLED:
@@ -607,7 +635,6 @@ class getid3_matroska extends getid3_handler
case EBML_ID_PIXELWIDTH:
case EBML_ID_PIXELHEIGHT:
- case EBML_ID_STEREOMODE:
case EBML_ID_PIXELCROPBOTTOM:
case EBML_ID_PIXELCROPTOP:
case EBML_ID_PIXELCROPLEFT:
@@ -616,6 +643,8 @@ class getid3_matroska extends getid3_handler
case EBML_ID_DISPLAYHEIGHT:
case EBML_ID_DISPLAYUNIT:
case EBML_ID_ASPECTRATIOTYPE:
+ case EBML_ID_STEREOMODE:
+ case EBML_ID_OLDSTEREOMODE:
$track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
@@ -752,8 +781,6 @@ class getid3_matroska extends getid3_handler
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['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
break;
@@ -770,11 +797,13 @@ class getid3_matroska extends getid3_handler
case EBML_ID_SEGMENTUID:
case EBML_ID_PREVUID:
case EBML_ID_NEXTUID:
- case EBML_ID_SEGMENTFAMILY:
- case EBML_ID_CHAPTERTRANSLATEID:
$info_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
break;
+ case EBML_ID_SEGMENTFAMILY:
+ $info_entry[$subelement['id_name']][] = getid3_lib::trimNullByte($subelement['data']);
+ break;
+
case EBML_ID_SEGMENTFILENAME:
case EBML_ID_PREVFILENAME:
case EBML_ID_NEXTFILENAME:
@@ -785,6 +814,31 @@ class getid3_matroska extends getid3_handler
$info['matroska']['comments'][strtolower($subelement['id_name'])][] = $info_entry[$subelement['id_name']];
break;
+ case EBML_ID_CHAPTERTRANSLATE:
+ $chaptertranslate_entry = array();
+
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
+ switch ($sub_subelement['id']) {
+
+ case EBML_ID_CHAPTERTRANSLATEEDITIONUID:
+ $chaptertranslate_entry[$sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_subelement['data']);
+ break;
+
+ case EBML_ID_CHAPTERTRANSLATECODEC:
+ $chaptertranslate_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
+ break;
+
+ case EBML_ID_CHAPTERTRANSLATEID:
+ $chaptertranslate_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
+ break;
+
+ default:
+ $this->unhandledElement('info.chaptertranslate', __LINE__, $sub_subelement);
+ }
+ }
+ $info_entry[$subelement['id_name']] = $chaptertranslate_entry;
+ break;
+
default:
$this->unhandledElement('info', __LINE__, $subelement);
}
@@ -810,7 +864,7 @@ class getid3_matroska extends getid3_handler
case EBML_ID_CUETRACKPOSITIONS:
$cuetrackpositions_entry = array();
-
+
while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], true)) {
switch ($sub_sub_subelement['id']) {
@@ -848,13 +902,13 @@ class getid3_matroska extends getid3_handler
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 ($this->getEBMLelement($sub_subelement, $subelement['end'], false)) {
switch ($sub_subelement['id']) {
@@ -866,14 +920,14 @@ class getid3_matroska extends getid3_handler
case EBML_ID_TARGETTYPEVALUE:
$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']]);
+ $targets_entry[strtolower($sub_sub_subelement['id_name']).'_long'] = self::TargetTypeValue($targets_entry[$sub_sub_subelement['id_name']]);
break;
case EBML_ID_TARGETTYPE:
$targets_entry[$sub_sub_subelement['id_name']] = $sub_sub_subelement['data'];
break;
-
- case EBML_ID_TAGTRACKUID:
+
+ case EBML_ID_TAGTRACKUID:
case EBML_ID_TAGEDITIONUID:
case EBML_ID_TAGCHAPTERUID:
case EBML_ID_TAGATTACHMENTUID:
@@ -926,17 +980,11 @@ class getid3_matroska extends getid3_handler
$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[$sub_subelement['id_name']] = $this->saveAttachment(
$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;
@@ -948,19 +996,19 @@ class getid3_matroska extends getid3_handler
$this->unhandledElement('attachments.attachedfile', __LINE__, $sub_subelement);
}
}
- 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 {
+ //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' => $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:
@@ -1115,7 +1163,7 @@ class getid3_matroska extends getid3_handler
case EBML_ID_CLUSTERREFERENCEBLOCK: // signed-int
$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;
@@ -1144,7 +1192,9 @@ class getid3_matroska extends getid3_handler
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;
+ if (count($info['matroska']['track_data_offsets']) == count($info['matroska']['tracks']['tracks'])) {
+ return;
+ }
}
}
}
@@ -1162,36 +1212,33 @@ class getid3_matroska extends getid3_handler
}
}
- private function EnsureBufferHasEnoughData($min_data = 1024)
- {
+ 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;
+ $read_bytes = max($min_data, $this->getid3->fread_buffer_size());
+
+ try {
+ $this->fseek($this->current_offset);
+ $this->EBMLbuffer_offset = $this->current_offset;
+ $this->EBMLbuffer = $this->fread($read_bytes);
+ $this->EBMLbuffer_length = strlen($this->EBMLbuffer);
+ } catch (getid3_exception $e) {
+ $this->warning('EBML parser: '.$e->getMessage());
return false;
}
- 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 ($this->EBMLbuffer_length == 0 && $this->feof()) {
+ return $this->error('EBML parser: ran out of file at offset '.$this->current_offset);
}
}
-
return true;
}
- private function readEBMLint()
- {
+ private function readEBMLint() {
$actual_offset = $this->current_offset - $this->EBMLbuffer_offset;
// get length of integer
$first_byte_int = ord($this->EBMLbuffer[$actual_offset]);
- if (0x80 & $first_byte_int) {
+ if (0x80 & $first_byte_int) {
$length = 1;
} elseif (0x40 & $first_byte_int) {
$length = 2;
@@ -1218,16 +1265,16 @@ class getid3_matroska extends getid3_handler
return $int_value;
}
- private function readEBMLelementData($length)
- {
+ private function readEBMLelementData($length, $check_buffer=false) {
+ if ($check_buffer && !$this->EnsureBufferHasEnoughData($length)) {
+ return false;
+ }
$data = substr($this->EBMLbuffer, $this->current_offset - $this->EBMLbuffer_offset, $length);
$this->current_offset += $length;
-
return $data;
}
- private function getEBMLelement(&$element, $parent_end, $get_data = false)
- {
+ private function getEBMLelement(&$element, $parent_end, $get_data=false) {
if ($this->current_offset >= $parent_end) {
return false;
}
@@ -1263,11 +1310,10 @@ class getid3_matroska extends getid3_handler
return true;
}
- private function unhandledElement($type, $line, $element)
- {
+ 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']);
+ $this->warning('Unhandled '.$type.' element ['.basename(__FILE__).':'.$line.'] ('.$element['id'].'::'.$element['id_name'].' ['.$element['length'].' bytes]) at '.$element['offset']);
}
// increase offset for unparsed elements
@@ -1276,8 +1322,7 @@ class getid3_matroska extends getid3_handler
}
}
- private function ExtractCommentsSimpleTag($SimpleTagArray)
- {
+ private function ExtractCommentsSimpleTag($SimpleTagArray) {
if (!empty($SimpleTagArray['SimpleTag'])) {
foreach ($SimpleTagArray['SimpleTag'] as $SimpleTagKey => $SimpleTagData) {
if (!empty($SimpleTagData['TagName']) && !empty($SimpleTagData['TagString'])) {
@@ -1292,8 +1337,7 @@ class getid3_matroska extends getid3_handler
return true;
}
- private function HandleEMBLSimpleTag($parent_end)
- {
+ private function HandleEMBLSimpleTag($parent_end) {
$simpletag_entry = array();
while ($this->getEBMLelement($element, $parent_end, array(EBML_ID_SIMPLETAG))) {
@@ -1322,58 +1366,67 @@ class getid3_matroska extends getid3_handler
return $simpletag_entry;
}
- private function HandleEMBLClusterBlock($element, $block_type, &$info)
- {
+ 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));
+ $block_data = array();
+ $block_data['tracknumber'] = $this->readEBMLint();
+ $block_data['timecode'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(2), false, true);
+ $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);
+ $block_data['flags']['keyframe'] = (($block_data['flags_raw'] & 0x80) >> 7);
+ //$block_data['flags']['reserved1'] = (($block_data['flags_raw'] & 0x70) >> 4);
}
else {
- //$cluster_block_data['flags']['reserved1'] = (($cluster_block_data['flags_raw'] & 0xF0) >> 4);
+ //$block_data['flags']['reserved1'] = (($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); // 00=no lacing; 01=Xiph lacing; 11=EBML lacing; 10=fixed-size lacing
+ $block_data['flags']['invisible'] = (bool)(($block_data['flags_raw'] & 0x08) >> 3);
+ $block_data['flags']['lacing'] = (($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));
+ $block_data['flags']['discardable'] = (($block_data['flags_raw'] & 0x01));
}
else {
- //$cluster_block_data['flags']['reserved2'] = (($cluster_block_data['flags_raw'] & 0x01) >> 0);
+ //$block_data['flags']['reserved2'] = (($block_data['flags_raw'] & 0x01) >> 0);
}
- $cluster_block_data['flags']['lacing_type'] = self::MatroskaBlockLacingType($cluster_block_data['flags']['lacing']);
+ $block_data['flags']['lacing_type'] = self::BlockLacingType($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();
+ if ($block_data['flags']['lacing'] > 0) {
+ $block_data['lace_frames'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1)) + 1; // Number of frames in the lace-1 (uint8)
+ if ($block_data['flags']['lacing'] != 0x02) {
+ for ($i = 1; $i < $block_data['lace_frames']; $i ++) { // 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).
+ if ($block_data['flags']['lacing'] == 0x03) { // EBML lacing
+ $block_data['lace_frames_size'][$i] = $this->readEBMLint(); // 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.
}
else { // Xiph lacing
- $cluster_block_data['lace_frames_size'][$i] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1));
+ $block_data['lace_frames_size'][$i] = 0;
+ do {
+ $size = getid3_lib::BigEndian2Int($this->readEBMLelementData(1));
+ $block_data['lace_frames_size'][$i] += $size;
+ }
+ while ($size == 255);
}
}
+ if ($block_data['flags']['lacing'] == 0x01) { // calc size of the last frame only for Xiph lacing, till EBML sizes are now anyway determined incorrectly
+ $block_data['lace_frames_size'][] = $element['end'] - $this->current_offset - array_sum($block_data['lace_frames_size']);
+ }
}
}
- 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;
+ if (!isset($info['matroska']['track_data_offsets'][$block_data['tracknumber']])) {
+ $info['matroska']['track_data_offsets'][$block_data['tracknumber']]['offset'] = $this->current_offset;
+ $info['matroska']['track_data_offsets'][$block_data['tracknumber']]['length'] = $element['end'] - $this->current_offset;
+ //$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['total_length'] = 0;
}
+ //$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['total_length'] += $info['matroska']['track_data_offsets'][$block_data['tracknumber']]['length'];
+ //$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['duration'] = $block_data['timecode'] * ((isset($info['matroska']['info'][0]['TimecodeScale']) ? $info['matroska']['info'][0]['TimecodeScale'] : 1000000) / 1000000000);
// set offset manually
$this->current_offset = $element['end'];
- return $cluster_block_data;
+ return $block_data;
}
private static function EBML2Int($EBMLstring) {
@@ -1424,66 +1477,66 @@ class getid3_matroska extends getid3_handler
return round(($EBMLdatestamp / 1000000000) + 978307200);
}
- public static function MatroskaTargetTypeValue($target_type) {
+ public static function TargetTypeValue($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
+ static $TargetTypeValue = array();
+ if (empty($TargetTypeValue)) {
+ $TargetTypeValue[10] = 'A: ~ V:shot'; // the lowest hierarchy found in music or movies
+ $TargetTypeValue[20] = 'A:subtrack/part/movement ~ V:scene'; // corresponds to parts of a track for audio (like a movement)
+ $TargetTypeValue[30] = 'A:track/song ~ V:chapter'; // the common parts of an album or a movie
+ $TargetTypeValue[40] = 'A:part/session ~ V:part/session'; // when an album or episode has different logical parts
+ $TargetTypeValue[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)
+ $TargetTypeValue[60] = 'A:edition/issue/volume/opus ~ V:season/sequel/volume'; // a list of lower levels grouped together
+ $TargetTypeValue[70] = 'A:collection ~ V:collection'; // the high hierarchy consisting of many different lower items
}
- return (isset($MatroskaTargetTypeValue[$target_type]) ? $MatroskaTargetTypeValue[$target_type] : $target_type);
+ return (isset($TargetTypeValue[$target_type]) ? $TargetTypeValue[$target_type] : $target_type);
}
- public static function MatroskaBlockLacingType($lacingtype) {
+ public static function BlockLacingType($lacingtype) {
// http://matroska.org/technical/specs/index.html#block_structure
- static $MatroskaBlockLacingType = array();
- if (empty($MatroskaBlockLacingType)) {
- $MatroskaBlockLacingType[0x00] = 'no lacing';
- $MatroskaBlockLacingType[0x01] = 'Xiph lacing';
- $MatroskaBlockLacingType[0x02] = 'fixed-size lacing';
- $MatroskaBlockLacingType[0x03] = 'EBML lacing';
+ static $BlockLacingType = array();
+ if (empty($BlockLacingType)) {
+ $BlockLacingType[0x00] = 'no lacing';
+ $BlockLacingType[0x01] = 'Xiph lacing';
+ $BlockLacingType[0x02] = 'fixed-size lacing';
+ $BlockLacingType[0x03] = 'EBML lacing';
}
- return (isset($MatroskaBlockLacingType[$lacingtype]) ? $MatroskaBlockLacingType[$lacingtype] : $lacingtype);
+ return (isset($BlockLacingType[$lacingtype]) ? $BlockLacingType[$lacingtype] : $lacingtype);
}
- public static function MatroskaCodecIDtoCommonName($codecid) {
+ public static function CodecIDtoCommonName($codecid) {
// http://www.matroska.org/technical/specs/codecid/index.html
- static $MatroskaCodecIDlist = array();
- if (empty($MatroskaCodecIDlist)) {
- $MatroskaCodecIDlist['A_AAC'] = 'aac';
- $MatroskaCodecIDlist['A_AAC/MPEG2/LC'] = 'aac';
- $MatroskaCodecIDlist['A_AC3'] = 'ac3';
- $MatroskaCodecIDlist['A_DTS'] = 'dts';
- $MatroskaCodecIDlist['A_FLAC'] = 'flac';
- $MatroskaCodecIDlist['A_MPEG/L1'] = 'mp1';
- $MatroskaCodecIDlist['A_MPEG/L2'] = 'mp2';
- $MatroskaCodecIDlist['A_MPEG/L3'] = 'mp3';
- $MatroskaCodecIDlist['A_PCM/INT/LIT'] = 'pcm'; // PCM Integer Little Endian
- $MatroskaCodecIDlist['A_PCM/INT/BIG'] = 'pcm'; // PCM Integer Big Endian
- $MatroskaCodecIDlist['A_QUICKTIME/QDMC'] = 'quicktime'; // Quicktime: QDesign Music
- $MatroskaCodecIDlist['A_QUICKTIME/QDM2'] = 'quicktime'; // Quicktime: QDesign Music v2
- $MatroskaCodecIDlist['A_VORBIS'] = 'vorbis';
- $MatroskaCodecIDlist['V_MPEG1'] = 'mpeg';
- $MatroskaCodecIDlist['V_THEORA'] = 'theora';
- $MatroskaCodecIDlist['V_REAL/RV40'] = 'real';
- $MatroskaCodecIDlist['V_REAL/RV10'] = 'real';
- $MatroskaCodecIDlist['V_REAL/RV20'] = 'real';
- $MatroskaCodecIDlist['V_REAL/RV30'] = 'real';
- $MatroskaCodecIDlist['V_QUICKTIME'] = 'quicktime'; // Quicktime
- $MatroskaCodecIDlist['V_MPEG4/ISO/AP'] = 'mpeg4';
- $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';
+ static $CodecIDlist = array();
+ if (empty($CodecIDlist)) {
+ $CodecIDlist['A_AAC'] = 'aac';
+ $CodecIDlist['A_AAC/MPEG2/LC'] = 'aac';
+ $CodecIDlist['A_AC3'] = 'ac3';
+ $CodecIDlist['A_DTS'] = 'dts';
+ $CodecIDlist['A_FLAC'] = 'flac';
+ $CodecIDlist['A_MPEG/L1'] = 'mp1';
+ $CodecIDlist['A_MPEG/L2'] = 'mp2';
+ $CodecIDlist['A_MPEG/L3'] = 'mp3';
+ $CodecIDlist['A_PCM/INT/LIT'] = 'pcm'; // PCM Integer Little Endian
+ $CodecIDlist['A_PCM/INT/BIG'] = 'pcm'; // PCM Integer Big Endian
+ $CodecIDlist['A_QUICKTIME/QDMC'] = 'quicktime'; // Quicktime: QDesign Music
+ $CodecIDlist['A_QUICKTIME/QDM2'] = 'quicktime'; // Quicktime: QDesign Music v2
+ $CodecIDlist['A_VORBIS'] = 'vorbis';
+ $CodecIDlist['V_MPEG1'] = 'mpeg';
+ $CodecIDlist['V_THEORA'] = 'theora';
+ $CodecIDlist['V_REAL/RV40'] = 'real';
+ $CodecIDlist['V_REAL/RV10'] = 'real';
+ $CodecIDlist['V_REAL/RV20'] = 'real';
+ $CodecIDlist['V_REAL/RV30'] = 'real';
+ $CodecIDlist['V_QUICKTIME'] = 'quicktime'; // Quicktime
+ $CodecIDlist['V_MPEG4/ISO/AP'] = 'mpeg4';
+ $CodecIDlist['V_MPEG4/ISO/ASP'] = 'mpeg4';
+ $CodecIDlist['V_MPEG4/ISO/AVC'] = 'h264';
+ $CodecIDlist['V_MPEG4/ISO/SP'] = 'mpeg4';
+ $CodecIDlist['V_VP8'] = 'vp8';
+ $CodecIDlist['V_MS/VFW/FOURCC'] = 'riff';
+ $CodecIDlist['A_MS/ACM'] = 'riff';
}
- return (isset($MatroskaCodecIDlist[$codecid]) ? $MatroskaCodecIDlist[$codecid] : $codecid);
+ return (isset($CodecIDlist[$codecid]) ? $CodecIDlist[$codecid] : $codecid);
}
private static function EBMLidName($value) {
@@ -1647,6 +1700,7 @@ class getid3_matroska extends getid3_handler
$EBMLidList[EBML_ID_SIMPLETAG] = 'SimpleTag';
$EBMLidList[EBML_ID_CLUSTERSLICES] = 'ClusterSlices';
$EBMLidList[EBML_ID_STEREOMODE] = 'StereoMode';
+ $EBMLidList[EBML_ID_OLDSTEREOMODE] = 'OldStereoMode';
$EBMLidList[EBML_ID_TAG] = 'Tag';
$EBMLidList[EBML_ID_TAGATTACHMENTUID] = 'TagAttachmentUID';
$EBMLidList[EBML_ID_TAGBINARY] = 'TagBinary';
@@ -1682,7 +1736,7 @@ class getid3_matroska extends getid3_handler
return (isset($EBMLidList[$value]) ? $EBMLidList[$value] : dechex($value));
}
-
+
private static function getDefaultStreamInfo($streams)
{
foreach (array_reverse($streams) as $stream) {
@@ -1690,17 +1744,18 @@ class getid3_matroska extends getid3_handler
break;
}
}
- unset($stream['default']);
- if (isset($stream['name'])) {
- unset($stream['name']);
+
+ $unset = array('default', 'name');
+ foreach ($unset as $u) {
+ if (isset($stream[$u])) {
+ unset($stream[$u]);
+ }
}
-
+
$info = $stream;
$info['streams'] = $streams;
-
+
return $info;
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio-video.mpeg.php b/modules/getid3/module.audio-video.mpeg.php
index 499b740c..999c5d9a 100644
--- a/modules/getid3/module.audio-video.mpeg.php
+++ b/modules/getid3/module.audio-video.mpeg.php
@@ -28,7 +28,7 @@ define('GETID3_MPEG_AUDIO_START', "\x00\x00\x01\xC0");
class getid3_mpeg extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
if ($info['avdataend'] <= $info['avdataoffset']) {
@@ -226,7 +226,7 @@ class getid3_mpeg extends getid3_handler
}
- function MPEGsystemNonOverheadPercentage($VideoBitrate, $AudioBitrate) {
+ public function MPEGsystemNonOverheadPercentage($VideoBitrate, $AudioBitrate) {
$OverheadPercentage = 0;
$AudioBitrate = max(min($AudioBitrate / 1000, 384), 32); // limit to range of 32kbps - 384kbps (should be only legal bitrates, but maybe VBR?)
@@ -278,22 +278,19 @@ class getid3_mpeg extends getid3_handler
}
- function MPEGvideoFramerateLookup($rawframerate) {
+ public function MPEGvideoFramerateLookup($rawframerate) {
$MPEGvideoFramerateLookup = array(0, 23.976, 24, 25, 29.97, 30, 50, 59.94, 60);
return (isset($MPEGvideoFramerateLookup[$rawframerate]) ? (float) $MPEGvideoFramerateLookup[$rawframerate] : (float) 0);
}
- function MPEGvideoAspectRatioLookup($rawaspectratio) {
+ public function MPEGvideoAspectRatioLookup($rawaspectratio) {
$MPEGvideoAspectRatioLookup = array(0, 1, 0.6735, 0.7031, 0.7615, 0.8055, 0.8437, 0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575, 1.2015, 0);
return (isset($MPEGvideoAspectRatioLookup[$rawaspectratio]) ? (float) $MPEGvideoAspectRatioLookup[$rawaspectratio] : (float) 0);
}
- function MPEGvideoAspectRatioTextLookup($rawaspectratio) {
+ public function MPEGvideoAspectRatioTextLookup($rawaspectratio) {
$MPEGvideoAspectRatioTextLookup = array('forbidden', 'square pixels', '0.6735', '16:9, 625 line, PAL', '0.7615', '0.8055', '16:9, 525 line, NTSC', '0.8935', '4:3, 625 line, PAL, CCIR601', '0.9815', '1.0255', '1.0695', '4:3, 525 line, NTSC, CCIR601', '1.1575', '1.2015', 'reserved');
return (isset($MPEGvideoAspectRatioTextLookup[$rawaspectratio]) ? $MPEGvideoAspectRatioTextLookup[$rawaspectratio] : '');
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio-video.nsv.php b/modules/getid3/module.audio-video.nsv.php
index 5a587e67..3191eb3b 100644
--- a/modules/getid3/module.audio-video.nsv.php
+++ b/modules/getid3/module.audio-video.nsv.php
@@ -17,7 +17,7 @@
class getid3_nsv extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -58,7 +58,7 @@ class getid3_nsv extends getid3_handler
return true;
}
- function getNSVsHeaderFilepointer($fileoffset) {
+ public function getNSVsHeaderFilepointer($fileoffset) {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $fileoffset, SEEK_SET);
$NSVsheader = fread($this->getid3->fp, 28);
@@ -131,7 +131,7 @@ class getid3_nsv extends getid3_handler
return true;
}
- function getNSVfHeaderFilepointer($fileoffset, $getTOCoffsets=false) {
+ public function getNSVfHeaderFilepointer($fileoffset, $getTOCoffsets=false) {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $fileoffset, SEEK_SET);
$NSVfheader = fread($this->getid3->fp, 28);
@@ -205,7 +205,7 @@ class getid3_nsv extends getid3_handler
}
- static function NSVframerateLookup($framerateindex) {
+ public static function NSVframerateLookup($framerateindex) {
if ($framerateindex <= 127) {
return (float) $framerateindex;
}
@@ -221,6 +221,3 @@ class getid3_nsv extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio-video.quicktime.php b/modules/getid3/module.audio-video.quicktime.php
index 3e96ea1a..ce0d31f2 100644
--- a/modules/getid3/module.audio-video.quicktime.php
+++ b/modules/getid3/module.audio-video.quicktime.php
@@ -18,10 +18,10 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE_
class getid3_quicktime extends getid3_handler
{
- var $ReturnAtomData = true;
- var $ParseAllPossibleAtoms = false;
+ public $ReturnAtomData = true;
+ public $ParseAllPossibleAtoms = false;
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'quicktime';
@@ -165,7 +165,7 @@ class getid3_quicktime extends getid3_handler
return true;
}
- function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
+ public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
// http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm
$info = &$this->getid3->info;
@@ -382,6 +382,13 @@ class getid3_quicktime extends getid3_handler
$boxsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 4));
$boxtype = substr($atom_data, $atomoffset + 4, 4);
$boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8);
+ if ($boxsize <= 1) {
+ $info['warning'][] = 'Invalid QuickTime atom box size "'.$boxsize.'" in atom "'.$atomname.'" at offset: '.($atom_structure['offset'] + $atomoffset);
+ $atom_structure['data'] = null;
+ $atomoffset = strlen($atom_data);
+ break;
+ }
+ $atomoffset += $boxsize;
switch ($boxtype) {
case 'mean':
@@ -458,7 +465,6 @@ class getid3_quicktime extends getid3_handler
$atom_structure['data'] = $atom_data;
}
- $atomoffset += $boxsize;
}
}
}
@@ -1144,9 +1150,10 @@ class getid3_quicktime extends getid3_handler
$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']); }
+ // see: http://www.getid3.org/phpBB3/viewtopic.php?t=1295
+ //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;
@@ -1328,7 +1335,7 @@ class getid3_quicktime extends getid3_handler
break;
default:
- $info['warning'][] = 'Unknown QuickTime atom type: "'.getid3_lib::PrintHexBytes($atomname).'" at offset '.$baseoffset;
+ $info['warning'][] = 'Unknown QuickTime atom type: "'.$atomname.'" ('.trim(getid3_lib::PrintHexBytes($atomname)).') at offset '.$baseoffset;
$atom_structure['data'] = $atom_data;
break;
}
@@ -1336,7 +1343,7 @@ class getid3_quicktime extends getid3_handler
return $atom_structure;
}
- function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
+ public function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
//echo 'QuicktimeParseContainerAtom('.substr($atom_data, 4, 4).') @ '.$baseoffset.'<br><br>';
$atom_structure = false;
$subatomoffset = 0;
@@ -1364,7 +1371,7 @@ class getid3_quicktime extends getid3_handler
}
- function quicktime_read_mp4_descr_length($data, &$offset) {
+ public 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;
@@ -1376,7 +1383,7 @@ class getid3_quicktime extends getid3_handler
}
- function QuicktimeLanguageLookup($languageid) {
+ public function QuicktimeLanguageLookup($languageid) {
static $QuicktimeLanguageLookup = array();
if (empty($QuicktimeLanguageLookup)) {
$QuicktimeLanguageLookup[0] = 'English';
@@ -1493,7 +1500,7 @@ class getid3_quicktime extends getid3_handler
return (isset($QuicktimeLanguageLookup[$languageid]) ? $QuicktimeLanguageLookup[$languageid] : 'invalid');
}
- function QuicktimeVideoCodecLookup($codecid) {
+ public function QuicktimeVideoCodecLookup($codecid) {
static $QuicktimeVideoCodecLookup = array();
if (empty($QuicktimeVideoCodecLookup)) {
$QuicktimeVideoCodecLookup['.SGI'] = 'SGI';
@@ -1552,7 +1559,7 @@ class getid3_quicktime extends getid3_handler
return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : '');
}
- function QuicktimeAudioCodecLookup($codecid) {
+ public function QuicktimeAudioCodecLookup($codecid) {
static $QuicktimeAudioCodecLookup = array();
if (empty($QuicktimeAudioCodecLookup)) {
$QuicktimeAudioCodecLookup['.mp3'] = 'Fraunhofer MPEG Layer-III alias';
@@ -1597,7 +1604,7 @@ class getid3_quicktime extends getid3_handler
return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : '');
}
- function QuicktimeDCOMLookup($compressionid) {
+ public function QuicktimeDCOMLookup($compressionid) {
static $QuicktimeDCOMLookup = array();
if (empty($QuicktimeDCOMLookup)) {
$QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate';
@@ -1606,7 +1613,7 @@ class getid3_quicktime extends getid3_handler
return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : '');
}
- function QuicktimeColorNameLookup($colordepthid) {
+ public function QuicktimeColorNameLookup($colordepthid) {
static $QuicktimeColorNameLookup = array();
if (empty($QuicktimeColorNameLookup)) {
$QuicktimeColorNameLookup[1] = '2-color (monochrome)';
@@ -1624,7 +1631,7 @@ class getid3_quicktime extends getid3_handler
return (isset($QuicktimeColorNameLookup[$colordepthid]) ? $QuicktimeColorNameLookup[$colordepthid] : 'invalid');
}
- function QuicktimeSTIKLookup($stik) {
+ public function QuicktimeSTIKLookup($stik) {
static $QuicktimeSTIKLookup = array();
if (empty($QuicktimeSTIKLookup)) {
$QuicktimeSTIKLookup[0] = 'Movie';
@@ -1641,7 +1648,7 @@ class getid3_quicktime extends getid3_handler
return (isset($QuicktimeSTIKLookup[$stik]) ? $QuicktimeSTIKLookup[$stik] : 'invalid');
}
- function QuicktimeIODSaudioProfileName($audio_profile_id) {
+ public function QuicktimeIODSaudioProfileName($audio_profile_id) {
static $QuicktimeIODSaudioProfileNameLookup = array();
if (empty($QuicktimeIODSaudioProfileNameLookup)) {
$QuicktimeIODSaudioProfileNameLookup = array(
@@ -1701,7 +1708,7 @@ class getid3_quicktime extends getid3_handler
}
- function QuicktimeIODSvideoProfileName($video_profile_id) {
+ public function QuicktimeIODSvideoProfileName($video_profile_id) {
static $QuicktimeIODSvideoProfileNameLookup = array();
if (empty($QuicktimeIODSvideoProfileNameLookup)) {
$QuicktimeIODSvideoProfileNameLookup = array(
@@ -1773,7 +1780,7 @@ class getid3_quicktime extends getid3_handler
}
- function QuicktimeContentRatingLookup($rtng) {
+ public function QuicktimeContentRatingLookup($rtng) {
static $QuicktimeContentRatingLookup = array();
if (empty($QuicktimeContentRatingLookup)) {
$QuicktimeContentRatingLookup[0] = 'None';
@@ -1783,7 +1790,7 @@ class getid3_quicktime extends getid3_handler
return (isset($QuicktimeContentRatingLookup[$rtng]) ? $QuicktimeContentRatingLookup[$rtng] : 'invalid');
}
- function QuicktimeStoreAccountTypeLookup($akid) {
+ public function QuicktimeStoreAccountTypeLookup($akid) {
static $QuicktimeStoreAccountTypeLookup = array();
if (empty($QuicktimeStoreAccountTypeLookup)) {
$QuicktimeStoreAccountTypeLookup[0] = 'iTunes';
@@ -1792,7 +1799,7 @@ class getid3_quicktime extends getid3_handler
return (isset($QuicktimeStoreAccountTypeLookup[$akid]) ? $QuicktimeStoreAccountTypeLookup[$akid] : 'invalid');
}
- function QuicktimeStoreFrontCodeLookup($sfid) {
+ public function QuicktimeStoreFrontCodeLookup($sfid) {
static $QuicktimeStoreFrontCodeLookup = array();
if (empty($QuicktimeStoreFrontCodeLookup)) {
$QuicktimeStoreFrontCodeLookup[143460] = 'Australia';
@@ -1821,7 +1828,7 @@ class getid3_quicktime extends getid3_handler
return (isset($QuicktimeStoreFrontCodeLookup[$sfid]) ? $QuicktimeStoreFrontCodeLookup[$sfid] : 'invalid');
}
- function QuicktimeParseNikonNCTG($atom_data) {
+ public 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:
@@ -2000,7 +2007,7 @@ echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br
}
- function CopyToAppropriateCommentsSection($keyname, $data, $boxname='') {
+ public function CopyToAppropriateCommentsSection($keyname, $data, $boxname='') {
static $handyatomtranslatorarray = array();
if (empty($handyatomtranslatorarray)) {
$handyatomtranslatorarray['©cpy'] = 'copyright';
@@ -2075,6 +2082,7 @@ echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br
// boxnames:
+ /*
$handyatomtranslatorarray['iTunSMPB'] = 'iTunSMPB';
$handyatomtranslatorarray['iTunNORM'] = 'iTunNORM';
$handyatomtranslatorarray['Encoding Params'] = 'Encoding Params';
@@ -2087,11 +2095,16 @@ echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br
$handyatomtranslatorarray['MusicBrainz Album Artist Id'] = 'MusicBrainz Album Artist Id';
$handyatomtranslatorarray['MusicBrainz Track Id'] = 'MusicBrainz Track Id';
$handyatomtranslatorarray['MusicBrainz Disc Id'] = 'MusicBrainz Disc Id';
+
+ // http://age.hobba.nl/audio/tag_frame_reference.html
+ $handyatomtranslatorarray['PLAY_COUNTER'] = 'play_counter'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355
+ $handyatomtranslatorarray['MEDIATYPE'] = 'mediatype'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355
+ */
}
$info = &$this->getid3->info;
$comment_key = '';
- if ($boxname && ($boxname != $keyname) && isset($handyatomtranslatorarray[$boxname])) {
- $comment_key = $handyatomtranslatorarray[$boxname];
+ if ($boxname && ($boxname != $keyname)) {
+ $comment_key = (isset($handyatomtranslatorarray[$boxname]) ? $handyatomtranslatorarray[$boxname] : $boxname);
} elseif (isset($handyatomtranslatorarray[$keyname])) {
$comment_key = $handyatomtranslatorarray[$keyname];
}
@@ -2116,7 +2129,7 @@ echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br
return true;
}
- function NoNullString($nullterminatedstring) {
+ public 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);
@@ -2124,11 +2137,9 @@ echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br
return $nullterminatedstring;
}
- function Pascal2String($pascalstring) {
+ public 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/modules/getid3/module.audio-video.real.php b/modules/getid3/module.audio-video.real.php
index d716e7da..0226ac49 100644
--- a/modules/getid3/module.audio-video.real.php
+++ b/modules/getid3/module.audio-video.real.php
@@ -18,7 +18,7 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php',
class getid3_real extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'real';
@@ -202,7 +202,7 @@ class getid3_real extends getid3_handler
//$thisfile_real_chunks_currentchunk_videoinfo['unknown8'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 34, 2));
//$thisfile_real_chunks_currentchunk_videoinfo['unknown9'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 36, 2));
- $thisfile_real_chunks_currentchunk_videoinfo['codec'] = getid3_riff::RIFFfourccLookup($thisfile_real_chunks_currentchunk_videoinfo['fourcc2']);
+ $thisfile_real_chunks_currentchunk_videoinfo['codec'] = getid3_riff::fourccLookup($thisfile_real_chunks_currentchunk_videoinfo['fourcc2']);
$info['video']['resolution_x'] = $thisfile_real_chunks_currentchunk_videoinfo['width'];
$info['video']['resolution_y'] = $thisfile_real_chunks_currentchunk_videoinfo['height'];
@@ -370,7 +370,7 @@ class getid3_real extends getid3_handler
}
- function ParseOldRAheader($OldRAheaderData, &$ParsedArray) {
+ public function ParseOldRAheader($OldRAheaderData, &$ParsedArray) {
// http://www.freelists.org/archives/matroska-devel/07-2003/msg00010.html
$ParsedArray = array();
@@ -484,7 +484,7 @@ class getid3_real extends getid3_handler
return true;
}
- function RealAudioCodecFourCClookup($fourcc, $bitrate) {
+ public function RealAudioCodecFourCClookup($fourcc, $bitrate) {
static $RealAudioCodecFourCClookup = array();
if (empty($RealAudioCodecFourCClookup)) {
// http://www.its.msstate.edu/net/real/reports/config/tags.stats
@@ -525,6 +525,3 @@ class getid3_real extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio-video.riff.php b/modules/getid3/module.audio-video.riff.php
index 8e8f53a4..d3b7b8cf 100644
--- a/modules/getid3/module.audio-video.riff.php
+++ b/modules/getid3/module.audio-video.riff.php
@@ -12,17 +12,18 @@
// multiple formats supported by this module: //
// Wave, AVI, AIFF/AIFC, (MP3,AC3)/RIFF, Wavpack v3, 8SVX //
// dependencies: module.audio.mp3.php //
-// module.audio.ac3.php (optional) //
+// module.audio.ac3.php //
// module.audio.dts.php (optional) //
// ///
/////////////////////////////////////////////////////////////////
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
+getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, true);
class getid3_riff extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// initialize these values to an empty array, otherwise they default to NULL
@@ -38,30 +39,34 @@ class getid3_riff extends getid3_handler
$thisfile_riff_audio = &$thisfile_riff['audio'];
$thisfile_riff_video = &$thisfile_riff['video'];
-
$Original['avdataoffset'] = $info['avdataoffset'];
$Original['avdataend'] = $info['avdataend'];
- fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
- $RIFFheader = fread($this->getid3->fp, 12);
+ $this->fseek($info['avdataoffset']);
+ $RIFFheader = $this->fread(12);
+ $offset = $this->ftell();
+ $RIFFtype = substr($RIFFheader, 0, 4);
+ $RIFFsize = substr($RIFFheader, 4, 4);
$RIFFsubtype = substr($RIFFheader, 8, 4);
- switch (substr($RIFFheader, 0, 4)) {
- case 'FORM':
+
+ switch ($RIFFtype) {
+
+ case 'FORM': // AIFF, AIFC
$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']);
+ $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);
+ $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4));
break;
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));
+ $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);
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']);
+ $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4));
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
@@ -76,8 +81,8 @@ class getid3_riff extends getid3_handler
$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);
+ $this->fseek($nextRIFFoffset);
+ $nextRIFFheader = $this->fread(12);
if ($nextRIFFoffset == ($info['avdataend'] - 1)) {
if (substr($nextRIFFheader, 0, 1) == "\x00") {
// RIFF padded to WORD boundary, we're actually already at the end
@@ -98,33 +103,34 @@ class getid3_riff extends getid3_handler
$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']);
+ $chunkdata['chunks'] = $this->ParseRIFF($chunkdata['offset'] + 4, $nextRIFFoffset);
if (!isset($thisfile_riff[$nextRIFFtype])) {
$thisfile_riff[$nextRIFFtype] = array();
}
$thisfile_riff[$nextRIFFtype][] = $chunkdata;
break;
+
case 'JUNK':
// ignore
$thisfile_riff[$nextRIFFheaderID][] = $chunkdata;
break;
+
+ case 'IDVX':
+ $info['divxtag']['comments'] = self::ParseDIVXTAG($this->fread($chunkdata['size']));
+ break;
+
default:
if ($info['filesize'] == ($chunkdata['offset'] - 8 + 128)) {
- $DIVXTAG = $nextRIFFheader.fread($this->getid3->fp, 128 - 12);
+ $DIVXTAG = $nextRIFFheader.$this->fread(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;
- }
- }
+ $this->warning('Found wrongly-structured DIVXTAG at offset '.($this->ftell() - 128).', parsing anyway');
+ $info['divxtag']['comments'] = self::ParseDIVXTAG($DIVXTAG);
break 2;
}
}
- $info['warning'][] = 'expecting "RIFF" or "JUNK" at '.$nextRIFFoffset.', found '.getid3_lib::PrintHexBytes(substr($nextRIFFheader, 0, 4)).' - skipping rest of file';
+ $this->warning('Expecting "RIFF|JUNK|IDVX" at '.$nextRIFFoffset.', found "'.$nextRIFFheaderID.'" ('.getid3_lib::PrintHexBytes($nextRIFFheaderID).') - skipping rest of file');
break 2;
}
}
@@ -135,10 +141,9 @@ class getid3_riff extends getid3_handler
break;
default:
- $info['error'][] = 'Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "'.$RIFFsubtype.'" instead';
+ $this->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;
}
$streamindex = 0;
@@ -157,7 +162,7 @@ class getid3_riff extends getid3_handler
}
if (isset($thisfile_riff_WAVE['fmt '][0]['data'])) {
- $thisfile_riff_audio[$streamindex] = getid3_riff::RIFFparseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']);
+ $thisfile_riff_audio[$streamindex] = self::parseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']);
$thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
if (!isset($thisfile_riff_audio[$streamindex]['bitrate']) || ($thisfile_riff_audio[$streamindex]['bitrate'] == 0)) {
$info['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';
@@ -303,22 +308,22 @@ class getid3_riff extends getid3_handler
// shortcut
$thisfile_riff_WAVE_cart_0 = &$thisfile_riff_WAVE['cart'][0];
- $thisfile_riff_WAVE_cart_0['version'] = substr($thisfile_riff_WAVE_cart_0['data'], 0, 4);
- $thisfile_riff_WAVE_cart_0['title'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 4, 64));
- $thisfile_riff_WAVE_cart_0['artist'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 68, 64));
- $thisfile_riff_WAVE_cart_0['cut_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 132, 64));
- $thisfile_riff_WAVE_cart_0['client_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 196, 64));
- $thisfile_riff_WAVE_cart_0['category'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 260, 64));
- $thisfile_riff_WAVE_cart_0['classification'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 324, 64));
- $thisfile_riff_WAVE_cart_0['out_cue'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 388, 64));
- $thisfile_riff_WAVE_cart_0['start_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 452, 10));
- $thisfile_riff_WAVE_cart_0['start_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 462, 8));
- $thisfile_riff_WAVE_cart_0['end_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 470, 10));
- $thisfile_riff_WAVE_cart_0['end_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 480, 8));
- $thisfile_riff_WAVE_cart_0['producer_app_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 488, 64));
- $thisfile_riff_WAVE_cart_0['producer_app_version'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 552, 64));
- $thisfile_riff_WAVE_cart_0['user_defined_text'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 616, 64));
- $thisfile_riff_WAVE_cart_0['zero_db_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_cart_0['data'], 680, 4), true);
+ $thisfile_riff_WAVE_cart_0['version'] = substr($thisfile_riff_WAVE_cart_0['data'], 0, 4);
+ $thisfile_riff_WAVE_cart_0['title'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 4, 64));
+ $thisfile_riff_WAVE_cart_0['artist'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 68, 64));
+ $thisfile_riff_WAVE_cart_0['cut_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 132, 64));
+ $thisfile_riff_WAVE_cart_0['client_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 196, 64));
+ $thisfile_riff_WAVE_cart_0['category'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 260, 64));
+ $thisfile_riff_WAVE_cart_0['classification'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 324, 64));
+ $thisfile_riff_WAVE_cart_0['out_cue'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 388, 64));
+ $thisfile_riff_WAVE_cart_0['start_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 452, 10));
+ $thisfile_riff_WAVE_cart_0['start_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 462, 8));
+ $thisfile_riff_WAVE_cart_0['end_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 470, 10));
+ $thisfile_riff_WAVE_cart_0['end_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 480, 8));
+ $thisfile_riff_WAVE_cart_0['producer_app_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 488, 64));
+ $thisfile_riff_WAVE_cart_0['producer_app_version'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 552, 64));
+ $thisfile_riff_WAVE_cart_0['user_defined_text'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 616, 64));
+ $thisfile_riff_WAVE_cart_0['zero_db_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_cart_0['data'], 680, 4), true);
for ($i = 0; $i < 8; $i++) {
$thisfile_riff_WAVE_cart_0['post_time'][$i]['usage_fourcc'] = substr($thisfile_riff_WAVE_cart_0['data'], 684 + ($i * 8), 4);
$thisfile_riff_WAVE_cart_0['post_time'][$i]['timer_value'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_cart_0['data'], 684 + ($i * 8) + 4, 4));
@@ -362,7 +367,7 @@ class getid3_riff extends getid3_handler
$SNDM_startoffset += $SNDM_thisTagSize;
$thisfile_riff_WAVE_SNDM_0['parsed_raw'][$SNDM_thisTagKey] = $SNDM_thisTagDataText;
- if ($parsedkey = $this->RIFFwaveSNDMtagLookup($SNDM_thisTagKey)) {
+ if ($parsedkey = self::waveSNDMtagLookup($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).')';
@@ -424,15 +429,15 @@ class getid3_riff extends getid3_handler
$info['avdataend'] = $Original['avdataend'];
$thisfile_audio['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
- fseek($this->getid3->fp, $info['avdataoffset'] - 44, SEEK_SET);
- $RIFFdata = fread($this->getid3->fp, 44);
+ $this->fseek($info['avdataoffset'] - 44);
+ $RIFFdata = $this->fread(44);
$OrignalRIFFheaderSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 4, 4)) + 8;
$OrignalRIFFdataSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 40, 4)) + 44;
if ($OrignalRIFFheaderSize > $OrignalRIFFdataSize) {
$info['avdataend'] -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
- fseek($this->getid3->fp, $info['avdataend'], SEEK_SET);
- $RIFFdata .= fread($this->getid3->fp, $OrignalRIFFheaderSize - $OrignalRIFFdataSize);
+ $this->fseek($info['avdataend']);
+ $RIFFdata .= $this->fread($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
}
// move the data chunk after all other chunks (if any)
@@ -450,7 +455,7 @@ class getid3_riff extends getid3_handler
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['codec'] = self::wFormatTagLookup($thisfile_audio['wformattag']);
$thisfile_audio['lossless'] = false;
$thisfile_audio['bitrate'] = $info['ac3']['bitrate'];
$thisfile_audio['sample_rate'] = $info['ac3']['sample_rate'];
@@ -478,29 +483,36 @@ class getid3_riff extends getid3_handler
// shortcut
$thisfile_riff['litewave']['raw'] = array();
- $thisfile_riff_litewave = &$thisfile_riff['litewave'];
- $thisfile_riff_litewave_raw = &$thisfile_riff_litewave['raw'];
-
- $thisfile_riff_litewave_raw['compression_method'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 18, 1));
- $thisfile_riff_litewave_raw['compression_flags'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 19, 1));
- $thisfile_riff_litewave_raw['m_dwScale'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 20, 4));
- $thisfile_riff_litewave_raw['m_dwBlockSize'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 24, 4));
- $thisfile_riff_litewave_raw['m_wQuality'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 28, 2));
- $thisfile_riff_litewave_raw['m_wMarkDistance'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 30, 2));
- $thisfile_riff_litewave_raw['m_wReserved'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 32, 2));
- $thisfile_riff_litewave_raw['m_dwOrgSize'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 34, 4));
- $thisfile_riff_litewave_raw['m_bFactExists'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 38, 2));
- $thisfile_riff_litewave_raw['m_dwRiffChunkSize'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 40, 4));
-
- //$thisfile_riff_litewave['quality_factor'] = intval(round((2000 - $thisfile_riff_litewave_raw['m_dwScale']) / 20));
- $thisfile_riff_litewave['quality_factor'] = $thisfile_riff_litewave_raw['m_wQuality'];
-
- $thisfile_riff_litewave['flags']['raw_source'] = ($thisfile_riff_litewave_raw['compression_flags'] & 0x01) ? false : true;
- $thisfile_riff_litewave['flags']['vbr_blocksize'] = ($thisfile_riff_litewave_raw['compression_flags'] & 0x02) ? false : true;
- $thisfile_riff_litewave['flags']['seekpoints'] = (bool) ($thisfile_riff_litewave_raw['compression_flags'] & 0x04);
-
- $thisfile_audio['lossless'] = (($thisfile_riff_litewave_raw['m_wQuality'] == 100) ? true : false);
- $thisfile_audio['encoder_options'] = '-q'.$thisfile_riff_litewave['quality_factor'];
+ $riff_litewave = &$thisfile_riff['litewave'];
+ $riff_litewave_raw = &$riff_litewave['raw'];
+
+ $flags = array(
+ 'compression_method' => 1,
+ 'compression_flags' => 1,
+ 'm_dwScale' => 4,
+ 'm_dwBlockSize' => 4,
+ 'm_wQuality' => 2,
+ 'm_wMarkDistance' => 2,
+ 'm_wReserved' => 2,
+ 'm_dwOrgSize' => 4,
+ 'm_bFactExists' => 2,
+ 'm_dwRiffChunkSize' => 4,
+ );
+ $litewave_offset = 18;
+ foreach ($flags as $flag => $length) {
+ $riff_litewave_raw[$flag] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], $litewave_offset, $length));
+ $litewave_offset += $length;
+ }
+
+ //$riff_litewave['quality_factor'] = intval(round((2000 - $riff_litewave_raw['m_dwScale']) / 20));
+ $riff_litewave['quality_factor'] = $riff_litewave_raw['m_wQuality'];
+
+ $riff_litewave['flags']['raw_source'] = ($riff_litewave_raw['compression_flags'] & 0x01) ? false : true;
+ $riff_litewave['flags']['vbr_blocksize'] = ($riff_litewave_raw['compression_flags'] & 0x02) ? false : true;
+ $riff_litewave['flags']['seekpoints'] = (bool) ($riff_litewave_raw['compression_flags'] & 0x04);
+
+ $thisfile_audio['lossless'] = (($riff_litewave_raw['m_wQuality'] == 100) ? true : false);
+ $thisfile_audio['encoder_options'] = '-q'.$riff_litewave['quality_factor'];
break;
default:
@@ -586,19 +598,19 @@ class getid3_riff extends getid3_handler
// ),
//);
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'];
+ $ahsisd = &$thisfile_riff['AVI ']['hdrl']['strl']['indx'][$streamnumber]['data'];
- $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]['wLongsPerEntry'] = $this->EitherEndian2Int(substr($ahsisd, 0, 2));
+ $thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType'] = $this->EitherEndian2Int(substr($ahsisd, 2, 1));
+ $thisfile_riff_raw['indx'][$streamnumber]['bIndexType'] = $this->EitherEndian2Int(substr($ahsisd, 3, 1));
+ $thisfile_riff_raw['indx'][$streamnumber]['nEntriesInUse'] = $this->EitherEndian2Int(substr($ahsisd, 4, 4));
+ $thisfile_riff_raw['indx'][$streamnumber]['dwChunkId'] = substr($ahsisd, 8, 4);
+ $thisfile_riff_raw['indx'][$streamnumber]['dwReserved'] = $this->EitherEndian2Int(substr($ahsisd, 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']];
- unset($thisfile_riff_avi_hdrl_strl_indx_stream_data);
+ unset($ahsisd);
}
}
if (isset($thisfile_riff['AVI ']['hdrl']['avih'][$streamindex]['data'])) {
@@ -613,26 +625,39 @@ class getid3_riff extends getid3_handler
$info['error'][] = 'Corrupt RIFF file: avih.dwMicroSecPerFrame == zero';
return false;
}
- $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);
- $thisfile_riff_raw_avih['flags']['interleaved'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00000100);
- $thisfile_riff_raw_avih['flags']['trustcktype'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00000800);
- $thisfile_riff_raw_avih['flags']['capturedfile'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00010000);
- $thisfile_riff_raw_avih['flags']['copyrighted'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00020010);
+
+ $flags = array(
+ 'dwMaxBytesPerSec', // max. transfer rate
+ 'dwPaddingGranularity', // pad to multiples of this size; normally 2K.
+ 'dwFlags', // the ever-present flags
+ 'dwTotalFrames', // # frames in file
+ 'dwInitialFrames', //
+ 'dwStreams', //
+ 'dwSuggestedBufferSize', //
+ 'dwWidth', //
+ 'dwHeight', //
+ 'dwScale', //
+ 'dwRate', //
+ 'dwStart', //
+ 'dwLength', //
+ );
+ $avih_offset = 4;
+ foreach ($flags as $flag) {
+ $thisfile_riff_raw_avih[$flag] = $this->EitherEndian2Int(substr($avihData, $avih_offset, 4));
+ $avih_offset += 4;
+ }
+
+ $flags = array(
+ 'hasindex' => 0x00000010,
+ 'mustuseindex' => 0x00000020,
+ 'interleaved' => 0x00000100,
+ 'trustcktype' => 0x00000800,
+ 'capturedfile' => 0x00010000,
+ 'copyrighted' => 0x00020010,
+ );
+ foreach ($flags as $flag => $value) {
+ $thisfile_riff_raw_avih['flags'][$flag] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & $value);
+ }
// shortcut
$thisfile_riff_video[$streamindex] = array();
@@ -675,7 +700,7 @@ class getid3_riff extends getid3_handler
$streamindex = count($thisfile_riff_audio);
}
- $thisfile_riff_audio[$streamindex] = getid3_riff::RIFFparseWAVEFORMATex($strfData);
+ $thisfile_riff_audio[$streamindex] = self::parseWAVEFORMATex($strfData);
$thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
// shortcut
@@ -758,10 +783,10 @@ class getid3_riff extends getid3_handler
$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_riff_video_current['codec'] = self::fourccLookup($thisfile_riff_raw_strh_current['fccHandler']);
$thisfile_video['fourcc'] = $thisfile_riff_raw_strh_current['fccHandler'];
- if (!$thisfile_riff_video_current['codec'] && isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) && getid3_riff::RIFFfourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
- $thisfile_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']);
+ if (!$thisfile_riff_video_current['codec'] && isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) && self::fourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
+ $thisfile_riff_video_current['codec'] = self::fourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']);
$thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'];
}
$thisfile_video['codec'] = $thisfile_riff_video_current['codec'];
@@ -780,8 +805,7 @@ class getid3_riff extends getid3_handler
switch ($strhfccType) {
case 'vids':
- $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_riff_raw_strf_strhfccType_streamindex = self::ParseBITMAPINFOHEADER(substr($strfData, 0, 40), ($info['fileformat'] == 'riff'));
$thisfile_video['bits_per_sample'] = $thisfile_riff_raw_strf_strhfccType_streamindex['biBitCount'];
if ($thisfile_riff_video_current['codec'] == 'DV') {
@@ -806,8 +830,8 @@ class getid3_riff extends getid3_handler
if (isset($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']);
+ if (self::fourccLookup($thisfile_video['fourcc'])) {
+ $thisfile_riff_video_current['codec'] = self::fourccLookup($thisfile_video['fourcc']);
$thisfile_video['codec'] = $thisfile_riff_video_current['codec'];
}
@@ -969,7 +993,7 @@ class getid3_riff extends getid3_handler
$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();
@@ -981,6 +1005,7 @@ class getid3_riff extends getid3_handler
}
unset($getid3_temp, $getid3_id3v2);
}
+*/
break;
case '8SVX':
@@ -1090,10 +1115,37 @@ class getid3_riff extends getid3_handler
break;
}
+ switch ($RIFFsubtype) {
+ case 'WAVE':
+ case 'AIFF':
+ case 'AIFC':
+ $ID3v2_key_good = 'id3 ';
+ $ID3v2_keys_bad = array('ID3 ', 'tag ');
+ foreach ($ID3v2_keys_bad as $ID3v2_key_bad) {
+ if (isset($thisfile_riff[$RIFFsubtype][$ID3v2_key_bad]) && !array_key_exists($ID3v2_key_good, $thisfile_riff[$RIFFsubtype])) {
+ $thisfile_riff[$RIFFsubtype][$ID3v2_key_good] = $thisfile_riff[$RIFFsubtype][$ID3v2_key_bad];
+ $info['warning'][] = 'mapping "'.$ID3v2_key_bad.'" chunk to "'.$ID3v2_key_good.'"';
+ }
+ }
+
+ 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;
+ }
+
if (isset($thisfile_riff_raw['fmt ']['wFormatTag']) && ($thisfile_riff_raw['fmt ']['wFormatTag'] == 1)) {
// http://www.mega-nerd.com/erikd/Blog/Windiots/dts.html
- fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
- $FirstFourBytes = fread($this->getid3->fp, 4);
+ $this->fseek($info['avdataoffset']);
+ $FirstFourBytes = $this->fread(4);
if (preg_match('/^\xFF\x1F\x00\xE8/s', $FirstFourBytes)) {
// DTSWAV
$thisfile_audio_dataformat = 'dts';
@@ -1108,10 +1160,10 @@ class getid3_riff extends getid3_handler
$thisfile_riff['comments']['title'][] = trim(substr($thisfile_riff_WAVE['DISP'][count($thisfile_riff_WAVE['DISP']) - 1]['data'], 4));
}
if (isset($thisfile_riff_WAVE['INFO']) && is_array($thisfile_riff_WAVE['INFO'])) {
- $this->RIFFcommentsParse($thisfile_riff_WAVE['INFO'], $thisfile_riff['comments']);
+ self::parseComments($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']);
+ self::parseComments($thisfile_riff['AVI ']['INFO'], $thisfile_riff['comments']);
}
if (empty($thisfile_audio['encoder']) && !empty($info['mpeg']['audio']['LAME']['short_version'])) {
@@ -1220,155 +1272,77 @@ class getid3_riff extends getid3_handler
return true;
}
-
- static function RIFFcommentsParse(&$RIFFinfoArray, &$CommentsTargetArray) {
- $RIFFinfoKeyLookup = array(
- 'IARL'=>'archivallocation',
- 'IART'=>'artist',
- 'ICDS'=>'costumedesigner',
- 'ICMS'=>'commissionedby',
- 'ICMT'=>'comment',
- 'ICNT'=>'country',
- 'ICOP'=>'copyright',
- 'ICRD'=>'creationdate',
- 'IDIM'=>'dimensions',
- 'IDIT'=>'digitizationdate',
- 'IDPI'=>'resolution',
- 'IDST'=>'distributor',
- 'IEDT'=>'editor',
- 'IENG'=>'engineers',
- 'IFRM'=>'accountofparts',
- 'IGNR'=>'genre',
- 'IKEY'=>'keywords',
- 'ILGT'=>'lightness',
- 'ILNG'=>'language',
- 'IMED'=>'orignalmedium',
- 'IMUS'=>'composer',
- 'INAM'=>'title',
- 'IPDS'=>'productiondesigner',
- 'IPLT'=>'palette',
- 'IPRD'=>'product',
- 'IPRO'=>'producer',
- 'IPRT'=>'part',
- 'IRTD'=>'rating',
- 'ISBJ'=>'subject',
- 'ISFT'=>'software',
- 'ISGN'=>'secondarygenre',
- 'ISHP'=>'sharpness',
- 'ISRC'=>'sourcesupplier',
- 'ISRF'=>'digitizationsource',
- 'ISTD'=>'productionstudio',
- 'ISTR'=>'starring',
- 'ITCH'=>'encoded_by',
- 'IWEB'=>'url',
- 'IWRI'=>'writer'
- );
- foreach ($RIFFinfoKeyLookup as $key => $value) {
- if (isset($RIFFinfoArray[$key])) {
- foreach ($RIFFinfoArray[$key] as $commentid => $commentdata) {
- if (trim($commentdata['data']) != '') {
- if (isset($CommentsTargetArray[$value])) {
- $CommentsTargetArray[$value][] = trim($commentdata['data']);
- } else {
- $CommentsTargetArray[$value] = array(trim($commentdata['data']));
- }
- }
- }
- }
- }
- return true;
- }
-
- function ParseRIFF($startoffset, $maxoffset) {
+ public function ParseRIFF($startoffset, $maxoffset) {
$info = &$this->getid3->info;
- $maxoffset = min($maxoffset, $info['avdataend']);
-
$RIFFchunk = false;
$FoundAllChunksWeNeed = false;
- 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;
- }
- $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($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) {
- $info['error'][] = 'Expecting chunk name at offset '.(ftell($this->getid3->fp) - 4).' but found nothing. Aborting RIFF parsing.';
- break;
- }
- if ($chunksize == 0) {
- 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.';
+ try {
+ $this->fseek($startoffset);
+ $maxoffset = min($maxoffset, $info['avdataend']);
+ while ($this->ftell() < $maxoffset) {
+ $chunknamesize = $this->fread(8);
+ $chunkname = substr($chunknamesize, 0, 4);
+ $chunksize = $this->EitherEndian2Int(substr($chunknamesize, 4, 4));
+ if (strlen(trim($chunkname, "\x00")) < 4) {
+ $this->error('Expecting chunk name at offset '.($this->ftell() - 8).' but found nothing. Aborting RIFF parsing.');
break;
}
- }
- if (($chunksize % 2) != 0) {
- // all structures are packed on word boundaries
- $chunksize++;
- }
-
- switch ($chunkname) {
- case 'LIST':
- $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) {
-
- // skip over
-
- } else {
+ if (($chunksize == 0) && ($chunkname != 'JUNK')) {
+ $this->warning('Chunk ('.$chunkname.') size at offset '.($this->ftell() - 4).' is zero. Aborting RIFF parsing.');
+ break;
+ }
+ if (($chunksize % 2) != 0) {
+ // all structures are packed on word boundaries
+ $chunksize++;
+ }
- $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));
-
- if ($AudioChunkStreamType == 'wb') {
- $FirstFourBytes = substr($AudioChunkHeader, 8, 4);
- if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', $FirstFourBytes)) {
- // MP3
- if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) {
- $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'];
+ switch ($chunkname) {
+ case 'LIST':
+ $listname = $this->fread(4);
+ if (preg_match('#^(movi|rec )$#i', $listname)) {
+ $RIFFchunk[$listname]['offset'] = $this->ftell() - 4;
+ $RIFFchunk[$listname]['size'] = $chunksize;
+
+ if (!$FoundAllChunksWeNeed) {
+ $WhereWeWere = $this->ftell();
+ $AudioChunkHeader = $this->fread(12);
+ $AudioChunkStreamNum = substr($AudioChunkHeader, 0, 2);
+ $AudioChunkStreamType = substr($AudioChunkHeader, 2, 2);
+ $AudioChunkSize = getid3_lib::LittleEndian2Int(substr($AudioChunkHeader, 4, 4));
+
+ if ($AudioChunkStreamType == 'wb') {
+ $FirstFourBytes = substr($AudioChunkHeader, 8, 4);
+ if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', $FirstFourBytes)) {
+ // MP3
+ if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) {
+ $getid3_temp = new getID3();
+ $getid3_temp->openfile($this->getid3->filename);
+ $getid3_temp->info['avdataoffset'] = $this->ftell() - 4;
+ $getid3_temp->info['avdataend'] = $this->ftell() + $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($getid3_temp, $getid3_mp3);
}
- unset($getid3_temp, $getid3_mp3);
- }
- } elseif (preg_match('/^\x0B\x77/s', $FirstFourBytes)) {
+ } elseif (strpos($FirstFourBytes, getid3_ac3::syncword) === 0) {
- // AC3
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
+ // AC3
$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_temp->info['avdataoffset'] = $this->ftell() - 4;
+ $getid3_temp->info['avdataend'] = $this->ftell() + $AudioChunkSize;
$getid3_ac3 = new getid3_ac3($getid3_temp);
$getid3_ac3->Analyze();
if (empty($getid3_temp->info['error'])) {
@@ -1382,79 +1356,64 @@ class getid3_riff extends getid3_handler
}
unset($getid3_temp, $getid3_ac3);
}
-
}
-
+ $FoundAllChunksWeNeed = true;
+ $this->fseek($WhereWeWere);
}
+ $this->fseek($chunksize - 4, SEEK_CUR);
- $FoundAllChunksWeNeed = true;
- fseek($this->getid3->fp, $WhereWeWere, SEEK_SET);
-
- }
- fseek($this->getid3->fp, $chunksize - 4, SEEK_CUR);
+ } else {
- //} 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 = $this->ftell() - 4 + $chunksize;
+ if ($parsedChunk = $this->ParseRIFF($this->ftell(), $LISTchunkMaxOffset)) {
+ $RIFFchunk[$listname] = array_merge_recursive($RIFFchunk[$listname], $parsedChunk);
+ }
- if (!isset($RIFFchunk[$listname])) {
- $RIFFchunk[$listname] = array();
- }
- $LISTchunkParent = $listname;
- $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);
}
+ break;
- }
- break;
-
- default:
- 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;
+ default:
+ if (preg_match('#^[0-9]{2}(wb|pc|dc|db)$#', $chunkname)) {
+ $this->fseek($chunksize, SEEK_CUR);
+ break;
}
- 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($this->getid3->fp) - 8;
- $RIFFchunk[$chunkname][$thisindex]['size'] = $chunksize;
- switch ($chunkname) {
- case 'data':
- $info['avdataoffset'] = ftell($this->getid3->fp);
- $info['avdataend'] = $info['avdataoffset'] + $chunksize;
+ $thisindex = 0;
+ if (isset($RIFFchunk[$chunkname]) && is_array($RIFFchunk[$chunkname])) {
+ $thisindex = count($RIFFchunk[$chunkname]);
+ }
+ $RIFFchunk[$chunkname][$thisindex]['offset'] = $this->ftell() - 8;
+ $RIFFchunk[$chunkname][$thisindex]['size'] = $chunksize;
+ switch ($chunkname) {
+ case 'data':
+ $info['avdataoffset'] = $this->ftell();
+ $info['avdataend'] = $info['avdataoffset'] + $chunksize;
- $RIFFdataChunkContentsTest = fread($this->getid3->fp, 36);
+ $RIFFdataChunkContentsTest = $this->fread(36);
- if ((strlen($RIFFdataChunkContentsTest) > 0) && preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', substr($RIFFdataChunkContentsTest, 0, 4))) {
+ 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))) {
- $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'];
+ // Probably is MP3 data
+ if (getid3_mp3::MPEGaudioHeaderBytesValid(substr($RIFFdataChunkContentsTest, 0, 4))) {
+ $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);
}
- unset($getid3_temp, $getid3_mp3);
- }
- } elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 0, 2) == "\x0B\x77")) {
+ } elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 0, 2) == getid3_ac3::syncword)) {
- // This is probably AC-3 data
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
+ // This is probably AC-3 data
$getid3_temp = new getID3();
$getid3_temp->openfile($this->getid3->filename);
$getid3_temp->info['avdataoffset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
@@ -1467,18 +1426,13 @@ class getid3_riff extends getid3_handler
$info['warning'] = $getid3_temp->info['warning'];
}
unset($getid3_temp, $getid3_ac3);
- }
-
- } elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 8, 2) == "\x77\x0B")) {
- // Dolby Digital WAV
- // AC-3 content, but not encoded in same format as normal AC-3 file
- // For one thing, byte order is swapped
+ } elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 8, 2) == getid3_ac3::syncword)) {
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
-
- // ok to use tmpfile here - only 56 bytes
- if ($RIFFtempfilename = tempnam(GETID3_TEMP_DIR, 'id3')) {
+ // Dolby Digital WAV
+ // AC-3 content, but not encoded in same format as normal AC-3 file
+ // For one thing, byte order is swapped
+ if ($RIFFtempfilename = tempnam(GETID3_TEMP_DIR, 'id3')) { // ok to use tmpfile here - only 56 bytes
if ($fd_temp = fopen($RIFFtempfilename, 'wb')) {
for ($i = 0; $i < 28; $i += 2) {
// swap byte order
@@ -1504,109 +1458,100 @@ class getid3_riff extends getid3_handler
$info['error'][] = 'Error parsing Dolby Digital WAV (AC3-in-RIFF): failed to write temp file';
}
unlink($RIFFtempfilename);
-
} else {
$info['error'][] = 'Error parsing Dolby Digital WAV (AC3-in-RIFF): failed to write temp file';
}
- }
-
- } elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 0, 4) == 'wvpk')) {
+ } elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 0, 4) == 'wvpk')) {
- // This is WavPack data
- $info['wavpack']['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
- $info['wavpack']['size'] = getid3_lib::LittleEndian2Int(substr($RIFFdataChunkContentsTest, 4, 4));
- $this->RIFFparseWavPackHeader(substr($RIFFdataChunkContentsTest, 8, 28));
+ // This is WavPack data
+ $info['wavpack']['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
+ $info['wavpack']['size'] = getid3_lib::LittleEndian2Int(substr($RIFFdataChunkContentsTest, 4, 4));
+ self::parseWavPackHeader(substr($RIFFdataChunkContentsTest, 8, 28));
- } else {
+ } else {
- // This is some other kind of data (quite possibly just PCM)
- // do nothing special, just skip it
+ // This is some other kind of data (quite possibly just PCM)
+ // do nothing special, just skip it
- }
- $nextoffset = $RIFFchunk[$chunkname][$thisindex]['offset'] + 8 + $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, $RIFFchunk[$chunkname][$thisindex]['offset'] + 8 + $chunksize, SEEK_SET);
- break;
+ }
+ $nextoffset = $RIFFchunk[$chunkname][$thisindex]['offset'] + 8 + $chunksize;
+ $this->fseek($nextoffset);
+ break;
- case 'iXML':
- case 'bext':
- case 'cart':
- case 'fmt ':
- case 'strh':
- case 'strf':
- case 'indx':
- case 'MEXT':
- case 'DISP':
- // always read data in
- 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]);
+ case 'iXML':
+ case 'bext':
+ case 'cart':
+ case 'fmt ':
+ case 'strh':
+ case 'strf':
+ case 'indx':
+ case 'MEXT':
+ case 'DISP':
+ // always read data in
+ 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'] = $this->fread($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']);
}
- // but if nothing there, ignore
- // remove the key in either case
- unset($RIFFchunk[$chunkname][$thisindex]['data']);
}
+ } else {
+ $this->warning('Chunk "'.$chunkname.'" at offset '.$this->ftell().' is unexpectedly larger than 1MB (claims to be '.number_format($chunksize).' bytes), skipping data');
+ $this->fseek($chunksize, SEEK_CUR);
}
- } 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;
+ break;
- default:
- 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']);
- unset($RIFFchunk[$chunkname][$thisindex]['size']);
- if (isset($RIFFchunk[$chunkname][$thisindex]) && empty($RIFFchunk[$chunkname][$thisindex])) {
- unset($RIFFchunk[$chunkname][$thisindex]);
- }
- if (isset($RIFFchunk[$chunkname]) && empty($RIFFchunk[$chunkname])) {
- unset($RIFFchunk[$chunkname]);
- }
- $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($this->getid3->fp, $chunksize);
- } else {
- $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;
- }
- break;
+ //case 'IDVX':
+ // $info['divxtag']['comments'] = self::ParseDIVXTAG($this->fread($chunksize));
+ // break;
+ default:
+ if (!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']);
+ unset($RIFFchunk[$chunkname][$thisindex]['size']);
+ if (isset($RIFFchunk[$chunkname][$thisindex]) && empty($RIFFchunk[$chunkname][$thisindex])) {
+ unset($RIFFchunk[$chunkname][$thisindex]);
+ }
+ if (isset($RIFFchunk[$chunkname]) && empty($RIFFchunk[$chunkname])) {
+ unset($RIFFchunk[$chunkname]);
+ }
+ $RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['data'] = $this->fread($chunksize);
+ } elseif ($chunksize < 2048) {
+ // only read data in if smaller than 2kB
+ $RIFFchunk[$chunkname][$thisindex]['data'] = $this->fread($chunksize);
+ } else {
+ $this->fseek($chunksize, SEEK_CUR);
+ }
+ break;
+ }
+ break;
+ }
}
+ } catch (getid3_exception $e) {
+ if ($e->getCode() == 10) {
+ $this->warning('RIFF parser: '.$e->getMessage());
+ } else {
+ throw $e;
+ }
}
return $RIFFchunk;
}
-
- function ParseRIFFdata(&$RIFFdata) {
+ public function ParseRIFFdata(&$RIFFdata) {
$info = &$this->getid3->info;
if ($RIFFdata) {
$tempfile = tempnam(GETID3_TEMP_DIR, 'getID3');
@@ -1614,7 +1559,7 @@ class getid3_riff extends getid3_handler
$RIFFdataLength = strlen($RIFFdata);
$NewLengthString = getid3_lib::LittleEndian2String($RIFFdataLength, 4);
for ($i = 0; $i < 4; $i++) {
- $RIFFdata{$i + 4} = $NewLengthString{$i};
+ $RIFFdata[($i + 4)] = $NewLengthString[$i];
}
fwrite($fp_temp, $RIFFdata);
fclose($fp_temp);
@@ -1643,23 +1588,81 @@ class getid3_riff extends getid3_handler
return false;
}
+ public static function parseComments(&$RIFFinfoArray, &$CommentsTargetArray) {
+ $RIFFinfoKeyLookup = array(
+ 'IARL'=>'archivallocation',
+ 'IART'=>'artist',
+ 'ICDS'=>'costumedesigner',
+ 'ICMS'=>'commissionedby',
+ 'ICMT'=>'comment',
+ 'ICNT'=>'country',
+ 'ICOP'=>'copyright',
+ 'ICRD'=>'creationdate',
+ 'IDIM'=>'dimensions',
+ 'IDIT'=>'digitizationdate',
+ 'IDPI'=>'resolution',
+ 'IDST'=>'distributor',
+ 'IEDT'=>'editor',
+ 'IENG'=>'engineers',
+ 'IFRM'=>'accountofparts',
+ 'IGNR'=>'genre',
+ 'IKEY'=>'keywords',
+ 'ILGT'=>'lightness',
+ 'ILNG'=>'language',
+ 'IMED'=>'orignalmedium',
+ 'IMUS'=>'composer',
+ 'INAM'=>'title',
+ 'IPDS'=>'productiondesigner',
+ 'IPLT'=>'palette',
+ 'IPRD'=>'product',
+ 'IPRO'=>'producer',
+ 'IPRT'=>'part',
+ 'IRTD'=>'rating',
+ 'ISBJ'=>'subject',
+ 'ISFT'=>'software',
+ 'ISGN'=>'secondarygenre',
+ 'ISHP'=>'sharpness',
+ 'ISRC'=>'sourcesupplier',
+ 'ISRF'=>'digitizationsource',
+ 'ISTD'=>'productionstudio',
+ 'ISTR'=>'starring',
+ 'ITCH'=>'encoded_by',
+ 'IWEB'=>'url',
+ 'IWRI'=>'writer'
+ );
+ foreach ($RIFFinfoKeyLookup as $key => $value) {
+ if (isset($RIFFinfoArray[$key])) {
+ foreach ($RIFFinfoArray[$key] as $commentid => $commentdata) {
+ if (trim($commentdata['data']) != '') {
+ if (isset($CommentsTargetArray[$value])) {
+ $CommentsTargetArray[$value][] = trim($commentdata['data']);
+ } else {
+ $CommentsTargetArray[$value] = array(trim($commentdata['data']));
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
- public static function RIFFparseWAVEFORMATex($WaveFormatExData) {
+ public static function parseWAVEFORMATex($WaveFormatExData) {
// shortcut
$WaveFormatEx['raw'] = array();
$WaveFormatEx_raw = &$WaveFormatEx['raw'];
- $WaveFormatEx_raw['wFormatTag'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 0, 2));
- $WaveFormatEx_raw['nChannels'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 2, 2));
- $WaveFormatEx_raw['nSamplesPerSec'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 4, 4));
- $WaveFormatEx_raw['nAvgBytesPerSec'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 8, 4));
- $WaveFormatEx_raw['nBlockAlign'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 12, 2));
- $WaveFormatEx_raw['wBitsPerSample'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 14, 2));
+ $WaveFormatEx_raw['wFormatTag'] = substr($WaveFormatExData, 0, 2);
+ $WaveFormatEx_raw['nChannels'] = substr($WaveFormatExData, 2, 2);
+ $WaveFormatEx_raw['nSamplesPerSec'] = substr($WaveFormatExData, 4, 4);
+ $WaveFormatEx_raw['nAvgBytesPerSec'] = substr($WaveFormatExData, 8, 4);
+ $WaveFormatEx_raw['nBlockAlign'] = substr($WaveFormatExData, 12, 2);
+ $WaveFormatEx_raw['wBitsPerSample'] = substr($WaveFormatExData, 14, 2);
if (strlen($WaveFormatExData) > 16) {
- $WaveFormatEx_raw['cbSize'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 16, 2));
+ $WaveFormatEx_raw['cbSize'] = substr($WaveFormatExData, 16, 2);
}
+ $WaveFormatEx_raw = array_map('getid3_lib::LittleEndian2Int', $WaveFormatEx_raw);
- $WaveFormatEx['codec'] = getid3_riff::RIFFwFormatTagLookup($WaveFormatEx_raw['wFormatTag']);
+ $WaveFormatEx['codec'] = self::wFormatTagLookup($WaveFormatEx_raw['wFormatTag']);
$WaveFormatEx['channels'] = $WaveFormatEx_raw['nChannels'];
$WaveFormatEx['sample_rate'] = $WaveFormatEx_raw['nSamplesPerSec'];
$WaveFormatEx['bitrate'] = $WaveFormatEx_raw['nAvgBytesPerSec'] * 8;
@@ -1668,8 +1671,7 @@ class getid3_riff extends getid3_handler
return $WaveFormatEx;
}
-
- function RIFFparseWavPackHeader($WavPackChunkData) {
+ public function parseWavPackHeader($WavPackChunkData) {
// typedef struct {
// char ckID [4];
// long ckSize;
@@ -1732,23 +1734,24 @@ class getid3_riff extends getid3_handler
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['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['biSize'] = substr($BITMAPINFOHEADER, 0, 4); // number of bytes required by the BITMAPINFOHEADER structure
+ $parsed['biWidth'] = substr($BITMAPINFOHEADER, 4, 4); // width of the bitmap in pixels
+ $parsed['biHeight'] = 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'] = substr($BITMAPINFOHEADER, 12, 2); // number of color planes on the target device. In most cases this value must be set to 1
+ $parsed['biBitCount'] = substr($BITMAPINFOHEADER, 14, 2); // Specifies the number of bits per pixels
+ $parsed['biSizeImage'] = substr($BITMAPINFOHEADER, 20, 4); // size of the bitmap data section of the image (the actual pixel data, excluding BITMAPINFOHEADER and RGBQUAD structures)
+ $parsed['biXPelsPerMeter'] = substr($BITMAPINFOHEADER, 24, 4); // horizontal resolution, in pixels per metre, of the target device
+ $parsed['biYPelsPerMeter'] = substr($BITMAPINFOHEADER, 28, 4); // vertical resolution, in pixels per metre, of the target device
+ $parsed['biClrUsed'] = 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'] = 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 = array_map('getid3_lib::'.($littleEndian ? 'Little' : 'Big').'Endian2Int', $parsed);
+
+ $parsed['fourcc'] = substr($BITMAPINFOHEADER, 16, 4); // compression identifier
return $parsed;
}
- static function ParseDIVXTAG($DIVXTAG) {
+ public static function ParseDIVXTAG($DIVXTAG, $raw=false) {
// 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
@@ -1786,12 +1789,12 @@ class getid3_riff extends getid3_handler
21 => 'Western',
);
static $DIVXTAGrating = array(
- 0=>'Unrated',
- 1=>'G',
- 2=>'PG',
- 3=>'PG-13',
- 4=>'R',
- 5=>'NC-17'
+ 0 => 'Unrated',
+ 1 => 'G',
+ 2 => 'PG',
+ 3 => 'PG-13',
+ 4 => 'R',
+ 5 => 'NC-17',
);
$parsed['title'] = trim(substr($DIVXTAG, 0, 32));
@@ -1805,10 +1808,20 @@ class getid3_riff extends getid3_handler
$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']);
+
+ if (!$raw) {
+ unset($parsed['genre_id'], $parsed['rating_id']);
+ foreach ($parsed as $key => $value) {
+ if (!$value === '') {
+ unset($parsed['key']);
+ }
+ }
+ }
+
return $parsed;
}
- static function RIFFwaveSNDMtagLookup($tagshortname) {
+ public static function waveSNDMtagLookup($tagshortname) {
$begin = __LINE__;
/** This is not a comment!
@@ -1831,7 +1844,7 @@ class getid3_riff extends getid3_handler
return getid3_lib::EmbeddedLookup($tagshortname, $begin, __LINE__, __FILE__, 'riff-sndm');
}
- static function RIFFwFormatTagLookup($wFormatTag) {
+ public static function wFormatTagLookup($wFormatTag) {
$begin = __LINE__;
@@ -1998,11 +2011,9 @@ class getid3_riff extends getid3_handler
*/
return getid3_lib::EmbeddedLookup('0x'.str_pad(strtoupper(dechex($wFormatTag)), 4, '0', STR_PAD_LEFT), $begin, __LINE__, __FILE__, 'riff-wFormatTag');
-
}
-
- public static function RIFFfourccLookup($fourcc) {
+ public static function fourccLookup($fourcc) {
$begin = __LINE__;
@@ -2396,8 +2407,7 @@ class getid3_riff extends getid3_handler
return getid3_lib::EmbeddedLookup($fourcc, $begin, __LINE__, __FILE__, 'riff-fourcc');
}
-
- function EitherEndian2Int($byteword, $signed=false) {
+ private function EitherEndian2Int($byteword, $signed=false) {
if ($this->getid3->info['fileformat'] == 'riff') {
return getid3_lib::LittleEndian2Int($byteword, $signed);
}
@@ -2405,5 +2415,3 @@ class getid3_riff extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio-video.swf.php b/modules/getid3/module.audio-video.swf.php
index a3d49f95..48491cbf 100644
--- a/modules/getid3/module.audio-video.swf.php
+++ b/modules/getid3/module.audio-video.swf.php
@@ -16,9 +16,9 @@
class getid3_swf extends getid3_handler
{
- var $ReturnAllTagData = false;
+ public $ReturnAllTagData = false;
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'swf';
@@ -137,6 +137,3 @@ class getid3_swf extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio-video.ts.php b/modules/getid3/module.audio-video.ts.php
new file mode 100644
index 00000000..3fcf71ea
--- /dev/null
+++ b/modules/getid3/module.audio-video.ts.php
@@ -0,0 +1,78 @@
+<?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.ts.php //
+// module for analyzing MPEG Transport Stream (.ts) files //
+// dependencies: NONE //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_ts extends getid3_handler
+{
+
+ public function Analyze() {
+ $info = &$this->getid3->info;
+
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $TSheader = fread($this->getid3->fp, 19);
+ $magic = "\x47";
+ if (substr($TSheader, 0, 1) != $magic) {
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at '.$info['avdataoffset'].', found '.getid3_lib::PrintHexBytes(substr($TSheader, 0, 1)).' instead.';
+ return false;
+ }
+ $info['fileformat'] = 'ts';
+
+ // http://en.wikipedia.org/wiki/.ts
+
+ $offset = 0;
+ $info['ts']['packet']['sync'] = getid3_lib::BigEndian2Int(substr($TSheader, $offset, 1)); $offset += 1;
+ $pid_flags_raw = getid3_lib::BigEndian2Int(substr($TSheader, $offset, 2)); $offset += 2;
+ $SAC_raw = getid3_lib::BigEndian2Int(substr($TSheader, $offset, 1)); $offset += 1;
+ $info['ts']['packet']['flags']['transport_error_indicator'] = (bool) ($pid_flags_raw & 0x8000); // Set by demodulator if can't correct errors in the stream, to tell the demultiplexer that the packet has an uncorrectable error
+ $info['ts']['packet']['flags']['payload_unit_start_indicator'] = (bool) ($pid_flags_raw & 0x4000); // 1 means start of PES data or PSI otherwise zero only.
+ $info['ts']['packet']['flags']['transport_high_priority'] = (bool) ($pid_flags_raw & 0x2000); // 1 means higher priority than other packets with the same PID.
+ $info['ts']['packet']['packet_id'] = ($pid_flags_raw & 0x1FFF) >> 0;
+
+ $info['ts']['packet']['raw']['scrambling_control'] = ($SAC_raw & 0xC0) >> 6;
+ $info['ts']['packet']['flags']['adaption_field_exists'] = (bool) ($SAC_raw & 0x20);
+ $info['ts']['packet']['flags']['payload_exists'] = (bool) ($SAC_raw & 0x10);
+ $info['ts']['packet']['continuity_counter'] = ($SAC_raw & 0x0F) >> 0; // Incremented only when a payload is present
+ $info['ts']['packet']['scrambling_control'] = $this->TSscramblingControlLookup($info['ts']['packet']['raw']['scrambling_control']);
+
+ if ($info['ts']['packet']['flags']['adaption_field_exists']) {
+ $AdaptionField_raw = getid3_lib::BigEndian2Int(substr($TSheader, $offset, 2)); $offset += 2;
+ $info['ts']['packet']['adaption']['field_length'] = ($AdaptionField_raw & 0xFF00) >> 8; // Number of bytes in the adaptation field immediately following this byte
+ $info['ts']['packet']['adaption']['flags']['discontinuity'] = (bool) ($AdaptionField_raw & 0x0080); // Set to 1 if current TS packet is in a discontinuity state with respect to either the continuity counter or the program clock reference
+ $info['ts']['packet']['adaption']['flags']['random_access'] = (bool) ($AdaptionField_raw & 0x0040); // Set to 1 if the PES packet in this TS packet starts a video/audio sequence
+ $info['ts']['packet']['adaption']['flags']['high_priority'] = (bool) ($AdaptionField_raw & 0x0020); // 1 = higher priority
+ $info['ts']['packet']['adaption']['flags']['pcr'] = (bool) ($AdaptionField_raw & 0x0010); // 1 means adaptation field does contain a PCR field
+ $info['ts']['packet']['adaption']['flags']['opcr'] = (bool) ($AdaptionField_raw & 0x0008); // 1 means adaptation field does contain an OPCR field
+ $info['ts']['packet']['adaption']['flags']['splice_point'] = (bool) ($AdaptionField_raw & 0x0004); // 1 means presence of splice countdown field in adaptation field
+ $info['ts']['packet']['adaption']['flags']['private_data'] = (bool) ($AdaptionField_raw & 0x0002); // 1 means presence of private data bytes in adaptation field
+ $info['ts']['packet']['adaption']['flags']['extension'] = (bool) ($AdaptionField_raw & 0x0001); // 1 means presence of adaptation field extension
+ if ($info['ts']['packet']['adaption']['flags']['pcr']) {
+ $info['ts']['packet']['adaption']['raw']['pcr'] = getid3_lib::BigEndian2Int(substr($TSheader, $offset, 6)); $offset += 6;
+ }
+ if ($info['ts']['packet']['adaption']['flags']['opcr']) {
+ $info['ts']['packet']['adaption']['raw']['opcr'] = getid3_lib::BigEndian2Int(substr($TSheader, $offset, 6)); $offset += 6;
+ }
+ }
+
+$info['error'][] = 'MPEG Transport Stream (.ts) parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
+return false;
+
+ }
+
+
+ public function TSscramblingControlLookup($raw) {
+ $TSscramblingControlLookup = array(0x00=>'not scrambled', 0x01=>'reserved', 0x02=>'scrambled, even key', 0x03=>'scrambled, odd key');
+ return (isset($TSscramblingControlLookup[$raw]) ? $TSscramblingControlLookup[$raw] : 'invalid');
+ }
+}
diff --git a/modules/getid3/module.audio.aa.php b/modules/getid3/module.audio.aa.php
index 39cb77c8..dbf1b7c8 100644
--- a/modules/getid3/module.audio.aa.php
+++ b/modules/getid3/module.audio.aa.php
@@ -17,7 +17,7 @@
class getid3_aa extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -35,6 +35,8 @@ class getid3_aa extends getid3_handler
$info['fileformat'] = 'aa';
$info['audio']['dataformat'] = 'aa';
+$info['error'][] = 'Audible Audiobook (.aa) parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
+return false;
$info['audio']['bitrate_mode'] = 'cbr'; // is it?
$thisfile_au['encoding'] = 'ISO-8859-1';
@@ -54,6 +56,3 @@ class getid3_aa extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.aac.php b/modules/getid3/module.audio.aac.php
index d573e11d..537ce567 100644
--- a/modules/getid3/module.audio.aac.php
+++ b/modules/getid3/module.audio.aac.php
@@ -16,7 +16,7 @@
class getid3_aac extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
if (fread($this->getid3->fp, 4) == 'ADIF') {
@@ -29,7 +29,7 @@ class getid3_aac extends getid3_handler
- function getAACADIFheaderFilepointer() {
+ public function getAACADIFheaderFilepointer() {
$info = &$this->getid3->info;
$info['fileformat'] = 'aac';
$info['audio']['dataformat'] = 'aac';
@@ -257,7 +257,7 @@ class getid3_aac extends getid3_handler
}
- function getAACADTSheaderFilepointer($MaxFramesToScan=1000000, $ReturnExtendedInfo=false) {
+ public function getAACADTSheaderFilepointer($MaxFramesToScan=1000000, $ReturnExtendedInfo=false) {
$info = &$this->getid3->info;
// based loosely on code from AACfile by Jurgen Faul <jfaulØgmx.de>
@@ -510,6 +510,3 @@ class getid3_aac extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.ac3.php b/modules/getid3/module.audio.ac3.php
index ffe01746..be3064f1 100644
--- a/modules/getid3/module.audio.ac3.php
+++ b/modules/getid3/module.audio.ac3.php
@@ -16,9 +16,10 @@
class getid3_ac3 extends getid3_handler
{
- private $AC3header = '';
+ private $AC3header = array();
private $BSIoffset = 0;
+ const syncword = "\x0B\x77";
public function Analyze() {
$info = &$this->getid3->info;
@@ -32,7 +33,7 @@ class getid3_ac3 extends getid3_handler
// http://www.atsc.org/standards/a_52a.pdf
- $info['fileformat'] = 'ac3';
+ $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
@@ -45,21 +46,6 @@ class getid3_ac3 extends getid3_handler
//
// 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
@@ -67,21 +53,40 @@ class getid3_ac3 extends getid3_handler
// 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));
+ $this->fseek($info['avdataoffset']);
+ $this->AC3header['syncinfo'] = $this->fread(5);
+
+ if (strpos($this->AC3header['syncinfo'], self::syncword) === 0) {
+ $thisfile_ac3_raw['synchinfo']['synchword'] = self::syncword;
+ $offset = 2;
+ } else {
+ if (!$this->isDependencyFor('matroska')) {
+ unset($info['fileformat'], $info['ac3']);
+ return $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::syncword).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($this->AC3header['syncinfo'], 0, 2)).'"');
+ }
+ $offset = 0;
+ $this->fseek(-2, SEEK_CUR);
+ }
+
+ $info['audio']['dataformat'] = 'ac3';
+ $info['audio']['bitrate_mode'] = 'cbr';
+ $info['audio']['lossless'] = false;
+
+ $thisfile_ac3_raw['synchinfo']['crc1'] = getid3_lib::LittleEndian2Int(substr($this->AC3header['syncinfo'], $offset, 2));
+ $ac3_synchinfo_fscod_frmsizecod = getid3_lib::LittleEndian2Int(substr($this->AC3header['syncinfo'], ($offset + 2), 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']);
+ $thisfile_ac3['sample_rate'] = self::sampleRateCodeLookup($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']);
+ $thisfile_ac3['frame_length'] = self::frameSizeLookup($thisfile_ac3_raw['synchinfo']['frmsizecod'], $thisfile_ac3_raw['synchinfo']['fscod']);
+ $thisfile_ac3['bitrate'] = self::bitrateLookup($thisfile_ac3_raw['synchinfo']['frmsizecod']);
$info['audio']['bitrate'] = $thisfile_ac3['bitrate'];
- $this->AC3header['bsi'] = getid3_lib::BigEndian2Bin(fread($this->getid3->fp, 15));
+ $this->AC3header['bsi'] = getid3_lib::BigEndian2Bin($this->fread(15));
$ac3_bsi_offset = 0;
$thisfile_ac3_raw_bsi['bsid'] = $this->readHeaderBSI(5);
@@ -89,16 +94,16 @@ class getid3_ac3 extends getid3_handler
// 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);
+ $this->error('Bit stream identification is version '.$thisfile_ac3_raw_bsi['bsid'].', but getID3() only understands up to version 8');
+ unset($info['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']);
+ $thisfile_ac3['service_type'] = self::serviceTypeLookup($thisfile_ac3_raw_bsi['bsmod'], $thisfile_ac3_raw_bsi['acmod']);
+ $ac3_coding_mode = self::audioCodingModeLookup($thisfile_ac3_raw_bsi['acmod']);
foreach($ac3_coding_mode as $key => $value) {
$thisfile_ac3[$key] = $value;
}
@@ -120,19 +125,19 @@ class getid3_ac3 extends getid3_handler
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']);
+ $thisfile_ac3['center_mix_level'] = self::centerMixLevelLookup($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']);
+ $thisfile_ac3['surround_mix_level'] = self::surroundMixLevelLookup($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['dolby_surround_mode'] = self::dolbySurroundModeLookup($thisfile_ac3_raw_bsi['dsurmod']);
}
$thisfile_ac3_raw_bsi['lfeon'] = (bool) $this->readHeaderBSI(1);
@@ -142,9 +147,9 @@ class getid3_ac3 extends getid3_handler
$info['audio']['channels'] .= '.1';
}
- $thisfile_ac3['channels_enabled'] = $this->AC3channelsEnabledLookup($thisfile_ac3_raw_bsi['acmod'], $thisfile_ac3_raw_bsi['lfeon']);
+ $thisfile_ac3['channels_enabled'] = self::channelsEnabledLookup($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.
+ // 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';
@@ -152,7 +157,7 @@ class getid3_ac3 extends getid3_handler
$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['heavy_compression'] = self::heavyCompression($thisfile_ac3_raw_bsi['compr']);
}
$thisfile_ac3_raw_bsi['langcode_flag'] = (bool) $this->readHeaderBSI(1);
@@ -166,7 +171,7 @@ class getid3_ac3 extends getid3_handler
$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']);
+ $thisfile_ac3['room_type'] = self::roomTypeLookup($thisfile_ac3_raw_bsi['roomtyp']);
}
if ($thisfile_ac3_raw_bsi['acmod'] == 0x00) {
@@ -174,7 +179,7 @@ class getid3_ac3 extends getid3_handler
// 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.
+ // 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';
@@ -182,7 +187,7 @@ class getid3_ac3 extends getid3_handler
$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['heavy_compression2'] = self::heavyCompression($thisfile_ac3_raw_bsi['compr2']);
}
$thisfile_ac3_raw_bsi['langcode_flag2'] = (bool) $this->readHeaderBSI(1);
@@ -196,7 +201,7 @@ class getid3_ac3 extends getid3_handler
$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['room_type2'] = self::roomTypeLookup($thisfile_ac3_raw_bsi['roomtyp2']);
}
}
@@ -219,7 +224,7 @@ class getid3_ac3 extends getid3_handler
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']));
+ $this->AC3header['bsi'] .= getid3_lib::BigEndian2Bin($this->fread($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;
@@ -235,42 +240,42 @@ class getid3_ac3 extends getid3_handler
return bindec($data);
}
- public static function AC3sampleRateCodeLookup($fscod) {
- static $AC3sampleRateCodeLookup = array(
+ public static function sampleRateCodeLookup($fscod) {
+ static $sampleRateCodeLookup = 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);
+ return (isset($sampleRateCodeLookup[$fscod]) ? $sampleRateCodeLookup[$fscod] : false);
}
- public static function AC3serviceTypeLookup($bsmod, $acmod) {
- static $AC3serviceTypeLookup = array();
- if (empty($AC3serviceTypeLookup)) {
+ public static function serviceTypeLookup($bsmod, $acmod) {
+ static $serviceTypeLookup = array();
+ if (empty($serviceTypeLookup)) {
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)';
+ $serviceTypeLookup[0][$i] = 'main audio service: complete main (CM)';
+ $serviceTypeLookup[1][$i] = 'main audio service: music and effects (ME)';
+ $serviceTypeLookup[2][$i] = 'associated service: visually impaired (VI)';
+ $serviceTypeLookup[3][$i] = 'associated service: hearing impaired (HI)';
+ $serviceTypeLookup[4][$i] = 'associated service: dialogue (D)';
+ $serviceTypeLookup[5][$i] = 'associated service: commentary (C)';
+ $serviceTypeLookup[6][$i] = 'associated service: emergency (E)';
}
- $AC3serviceTypeLookup[7][1] = 'associated service: voice over (VO)';
+ $serviceTypeLookup[7][1] = 'associated service: voice over (VO)';
for ($i = 2; $i <= 7; $i++) {
- $AC3serviceTypeLookup[7][$i] = 'main audio service: karaoke';
+ $serviceTypeLookup[7][$i] = 'main audio service: karaoke';
}
}
- return (isset($AC3serviceTypeLookup[$bsmod][$acmod]) ? $AC3serviceTypeLookup[$bsmod][$acmod] : false);
+ return (isset($serviceTypeLookup[$bsmod][$acmod]) ? $serviceTypeLookup[$bsmod][$acmod] : false);
}
- public static function AC3audioCodingModeLookup($acmod) {
- static $AC3audioCodingModeLookup = array();
- if (empty($AC3audioCodingModeLookup)) {
+ public static function audioCodingModeLookup($acmod) {
+ static $audioCodingModeLookup = array();
+ if (empty($audioCodingModeLookup)) {
// array(channel configuration, # channels (not incl LFE), channel order)
- $AC3audioCodingModeLookup = array (
+ $audioCodingModeLookup = 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'),
@@ -281,47 +286,47 @@ class getid3_ac3 extends getid3_handler
7 => array('channel_config'=>'3/2', 'num_channels'=>5, 'channel_order'=>'L,C,R,SL,SR')
);
}
- return (isset($AC3audioCodingModeLookup[$acmod]) ? $AC3audioCodingModeLookup[$acmod] : false);
+ return (isset($audioCodingModeLookup[$acmod]) ? $audioCodingModeLookup[$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)
+ public static function centerMixLevelLookup($cmixlev) {
+ static $centerMixLevelLookup;
+ if (empty($centerMixLevelLookup)) {
+ $centerMixLevelLookup = 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);
+ return (isset($centerMixLevelLookup[$cmixlev]) ? $centerMixLevelLookup[$cmixlev] : false);
}
- public static function AC3surroundMixLevelLookup($surmixlev) {
- static $AC3surroundMixLevelLookup;
- if (empty($AC3surroundMixLevelLookup)) {
- $AC3surroundMixLevelLookup = array(
+ public static function surroundMixLevelLookup($surmixlev) {
+ static $surroundMixLevelLookup;
+ if (empty($surroundMixLevelLookup)) {
+ $surroundMixLevelLookup = array(
0 => pow(2, -3.0 / 6),
1 => pow(2, -6.0 / 6),
2 => 0,
3 => 'reserved'
);
}
- return (isset($AC3surroundMixLevelLookup[$surmixlev]) ? $AC3surroundMixLevelLookup[$surmixlev] : false);
+ return (isset($surroundMixLevelLookup[$surmixlev]) ? $surroundMixLevelLookup[$surmixlev] : false);
}
- public static function AC3dolbySurroundModeLookup($dsurmod) {
- static $AC3dolbySurroundModeLookup = array(
+ public static function dolbySurroundModeLookup($dsurmod) {
+ static $dolbySurroundModeLookup = array(
0 => 'not indicated',
1 => 'Not Dolby Surround encoded',
2 => 'Dolby Surround encoded',
3 => 'reserved'
);
- return (isset($AC3dolbySurroundModeLookup[$dsurmod]) ? $AC3dolbySurroundModeLookup[$dsurmod] : false);
+ return (isset($dolbySurroundModeLookup[$dsurmod]) ? $dolbySurroundModeLookup[$dsurmod] : false);
}
- public static function AC3channelsEnabledLookup($acmod, $lfeon) {
- $AC3channelsEnabledLookup = array(
+ public static function channelsEnabledLookup($acmod, $lfeon) {
+ $channelsEnabledLookup = array(
'ch1'=>(bool) ($acmod == 0),
'ch2'=>(bool) ($acmod == 0),
'left'=>(bool) ($acmod > 1),
@@ -334,25 +339,25 @@ class getid3_ac3 extends getid3_handler
switch ($acmod) {
case 4:
case 5:
- $AC3channelsEnabledLookup['surround_mono'] = true;
+ $channelsEnabledLookup['surround_mono'] = true;
break;
case 6:
case 7:
- $AC3channelsEnabledLookup['surround_left'] = true;
- $AC3channelsEnabledLookup['surround_right'] = true;
+ $channelsEnabledLookup['surround_left'] = true;
+ $channelsEnabledLookup['surround_right'] = true;
break;
}
- return $AC3channelsEnabledLookup;
+ return $channelsEnabledLookup;
}
- public static function AC3heavyCompression($compre) {
+ public static function heavyCompression($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
+ // 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
@@ -365,13 +370,13 @@ class getid3_ac3 extends getid3_handler
// 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
+ // -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') {
@@ -381,37 +386,37 @@ class getid3_ac3 extends getid3_handler
}
$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
+ // 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.
+ // 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.
+ // 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(
+ public static function roomTypeLookup($roomtyp) {
+ static $roomTypeLookup = array(
0 => 'not indicated',
1 => 'large room, X curve monitor',
2 => 'small room, flat monitor',
3 => 'reserved'
);
- return (isset($AC3roomTypeLookup[$roomtyp]) ? $AC3roomTypeLookup[$roomtyp] : false);
+ return (isset($roomTypeLookup[$roomtyp]) ? $roomTypeLookup[$roomtyp] : false);
}
- public static function AC3frameSizeLookup($frmsizecod, $fscod) {
+ public static function frameSizeLookup($frmsizecod, $fscod) {
$padding = (bool) ($frmsizecod % 2);
$framesizeid = floor($frmsizecod / 2);
- static $AC3frameSizeLookup = array();
- if (empty($AC3frameSizeLookup)) {
- $AC3frameSizeLookup = array (
+ static $frameSizeLookup = array();
+ if (empty($frameSizeLookup)) {
+ $frameSizeLookup = array (
0 => array(128, 138, 192),
1 => array(40, 160, 174, 240),
2 => array(48, 192, 208, 288),
@@ -435,15 +440,15 @@ class getid3_ac3 extends getid3_handler
}
if (($fscod == 1) && $padding) {
// frame lengths are padded by 1 word (16 bits) at 44100
- $AC3frameSizeLookup[$frmsizecod] += 2;
+ $frameSizeLookup[$frmsizecod] += 2;
}
- return (isset($AC3frameSizeLookup[$framesizeid][$fscod]) ? $AC3frameSizeLookup[$framesizeid][$fscod] : false);
+ return (isset($frameSizeLookup[$framesizeid][$fscod]) ? $frameSizeLookup[$framesizeid][$fscod] : false);
}
- public static function AC3bitrateLookup($frmsizecod) {
+ public static function bitrateLookup($frmsizecod) {
$framesizeid = floor($frmsizecod / 2);
- static $AC3bitrateLookup = array(
+ static $bitrateLookup = array(
0 => 32000,
1 => 40000,
2 => 48000,
@@ -464,10 +469,8 @@ class getid3_ac3 extends getid3_handler
17 => 576000,
18 => 640000
);
- return (isset($AC3bitrateLookup[$framesizeid]) ? $AC3bitrateLookup[$framesizeid] : false);
+ return (isset($bitrateLookup[$framesizeid]) ? $bitrateLookup[$framesizeid] : false);
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.au.php b/modules/getid3/module.audio.au.php
index a1094dbc..5951684a 100644
--- a/modules/getid3/module.audio.au.php
+++ b/modules/getid3/module.audio.au.php
@@ -17,7 +17,7 @@
class getid3_au extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -69,7 +69,7 @@ class getid3_au extends getid3_handler
return true;
}
- function AUdataFormatNameLookup($id) {
+ public function AUdataFormatNameLookup($id) {
static $AUdataFormatNameLookup = array(
0 => 'unspecified format',
1 => '8-bit mu-law',
@@ -103,7 +103,7 @@ class getid3_au extends getid3_handler
return (isset($AUdataFormatNameLookup[$id]) ? $AUdataFormatNameLookup[$id] : false);
}
- function AUdataFormatBitsPerSampleLookup($id) {
+ public function AUdataFormatBitsPerSampleLookup($id) {
static $AUdataFormatBitsPerSampleLookup = array(
1 => 8,
2 => 8,
@@ -131,7 +131,7 @@ class getid3_au extends getid3_handler
return (isset($AUdataFormatBitsPerSampleLookup[$id]) ? $AUdataFormatBitsPerSampleLookup[$id] : false);
}
- function AUdataFormatUsedBitsPerSampleLookup($id) {
+ public function AUdataFormatUsedBitsPerSampleLookup($id) {
static $AUdataFormatUsedBitsPerSampleLookup = array(
1 => 8,
2 => 8,
@@ -160,6 +160,3 @@ class getid3_au extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.avr.php b/modules/getid3/module.audio.avr.php
index 9c6d6650..77107eae 100644
--- a/modules/getid3/module.audio.avr.php
+++ b/modules/getid3/module.audio.avr.php
@@ -17,7 +17,7 @@
class getid3_avr extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// http://cui.unige.ch/OSG/info/AudioFormats/ap11.html
@@ -122,6 +122,3 @@ class getid3_avr extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.bonk.php b/modules/getid3/module.audio.bonk.php
index 9f5187e3..b16eff7c 100644
--- a/modules/getid3/module.audio.bonk.php
+++ b/modules/getid3/module.audio.bonk.php
@@ -16,7 +16,7 @@
class getid3_bonk extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// shortcut
@@ -113,7 +113,7 @@ class getid3_bonk extends getid3_handler
}
- function HandleBonkTags($BonkTagName) {
+ public function HandleBonkTags($BonkTagName) {
$info = &$this->getid3->info;
switch ($BonkTagName) {
case 'BONK':
@@ -212,7 +212,7 @@ class getid3_bonk extends getid3_handler
}
}
- static function BonkIsValidTagName($PossibleBonkTag, $ignorecase=false) {
+ public static function BonkIsValidTagName($PossibleBonkTag, $ignorecase=false) {
static $BonkIsValidTagName = array('BONK', 'INFO', ' ID3', 'META');
foreach ($BonkIsValidTagName as $validtagname) {
if ($validtagname == $PossibleBonkTag) {
@@ -225,6 +225,3 @@ class getid3_bonk extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.dss.php b/modules/getid3/module.audio.dss.php
index b7b43676..5e1ceacb 100644
--- a/modules/getid3/module.audio.dss.php
+++ b/modules/getid3/module.audio.dss.php
@@ -17,7 +17,7 @@
class getid3_dss extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -58,7 +58,7 @@ class getid3_dss extends getid3_handler
return true;
}
- function DSSdateStringToUnixDate($datestring) {
+ public function DSSdateStringToUnixDate($datestring) {
$y = substr($datestring, 0, 2);
$m = substr($datestring, 2, 2);
$d = substr($datestring, 4, 2);
@@ -70,6 +70,3 @@ class getid3_dss extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.dts.php b/modules/getid3/module.audio.dts.php
index 8102ba8b..5b910940 100644
--- a/modules/getid3/module.audio.dts.php
+++ b/modules/getid3/module.audio.dts.php
@@ -16,6 +16,7 @@
class getid3_dts extends getid3_handler
{
+ const syncword = "\x7F\xFE\x80\x01";
public function Analyze() {
$info = &$this->getid3->info;
@@ -26,18 +27,21 @@ class getid3_dts extends getid3_handler
$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;
+ $this->fseek($info['avdataoffset']);
+ $DTSheader = $this->fread(16);
+
+ if (strpos($DTSheader, self::syncword) === 0) {
+ $info['dts']['raw']['magic'] = self::syncword;
+ $offset = 4;
+ } else {
+ if (!$this->isDependencyFor('matroska')) {
+ unset($info['fileformat']);
+ return $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::syncword).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($DTSheader, 0, 4)).'"');
+ }
+ $offset = 0;
}
- $fhBS = getid3_lib::BigEndian2Bin(substr($DTSheader, 4, 12));
+ $fhBS = getid3_lib::BigEndian2Bin(substr($DTSheader, $offset, 12));
$bsOffset = 0;
$info['dts']['raw']['frame_type'] = $this->readBinData($fhBS, $bsOffset, 1);
$info['dts']['raw']['deficit_samples'] = $this->readBinData($fhBS, $bsOffset, 5);
@@ -70,14 +74,14 @@ class getid3_dts extends getid3_handler
$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']['bitrate'] = self::bitrateLookup($info['dts']['raw']['bitrate']);
+ $info['dts']['bits_per_sample'] = self::bitPerSampleLookup($info['dts']['raw']['bits_per_sample']);
+ $info['dts']['sample_rate'] = self::sampleRateLookup($info['dts']['raw']['sample_frequency']);
+ $info['dts']['dialog_normalization'] = self::dialogNormalization($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['dts']['channels'] = self::numChannelsLookup($info['dts']['raw']['channel_arrangement']);
+ $info['dts']['channel_arrangement'] = self::channelArrangementLookup($info['dts']['raw']['channel_arrangement']);
$info['audio']['dataformat'] = 'dts';
$info['audio']['lossless'] = $info['dts']['flags']['lossless'];
@@ -99,8 +103,8 @@ class getid3_dts extends getid3_handler
return bindec($data);
}
- private static function DTSbitrateLookup($index) {
- $DTSbitrateLookup = array(
+ public static function bitrateLookup($index) {
+ static $lookup = array(
0 => 32000,
1 => 56000,
2 => 64000,
@@ -132,13 +136,13 @@ class getid3_dts extends getid3_handler
28 => 3840000,
29 => 'open',
30 => 'variable',
- 31 => 'lossless'
+ 31 => 'lossless',
);
- return (isset($DTSbitrateLookup[$index]) ? $DTSbitrateLookup[$index] : false);
+ return (isset($lookup[$index]) ? $lookup[$index] : false);
}
- private static function DTSsampleRateLookup($index) {
- $DTSsampleRateLookup = array(
+ public static function sampleRateLookup($index) {
+ static $lookup = array(
0 => 'invalid',
1 => 8000,
2 => 16000,
@@ -154,22 +158,22 @@ class getid3_dts extends getid3_handler
12 => 24000,
13 => 48000,
14 => 'invalid',
- 15 => 'invalid'
+ 15 => 'invalid',
);
- return (isset($DTSsampleRateLookup[$index]) ? $DTSsampleRateLookup[$index] : false);
+ return (isset($lookup[$index]) ? $lookup[$index] : false);
}
- private static function DTSbitPerSampleLookup($index) {
- $DTSbitPerSampleLookup = array(
+ public static function bitPerSampleLookup($index) {
+ static $lookup = array(
0 => 16,
1 => 20,
2 => 24,
3 => 24,
);
- return (isset($DTSbitPerSampleLookup[$index]) ? $DTSbitPerSampleLookup[$index] : false);
+ return (isset($lookup[$index]) ? $lookup[$index] : false);
}
- private static function DTSnumChannelsLookup($index) {
+ public static function numChannelsLookup($index) {
switch ($index) {
case 0:
return 1;
@@ -207,8 +211,8 @@ class getid3_dts extends getid3_handler
return false;
}
- private static function DTSchannelArrangementLookup($index) {
- $DTSchannelArrangementLookup = array(
+ public static function channelArrangementLookup($index) {
+ static $lookup = array(
0 => 'A',
1 => 'A + B (dual mono)',
2 => 'L + R (stereo)',
@@ -226,10 +230,10 @@ class getid3_dts extends getid3_handler
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');
+ return (isset($lookup[$index]) ? $lookup[$index] : 'user-defined');
}
- private static function DTSdialogNormalization($index, $version) {
+ public static function dialogNormalization($index, $version) {
switch ($version) {
case 7:
return 0 - $index;
@@ -242,5 +246,3 @@ class getid3_dts extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.flac.php b/modules/getid3/module.audio.flac.php
index 98daec0f..ec8136fe 100644
--- a/modules/getid3/module.audio.flac.php
+++ b/modules/getid3/module.audio.flac.php
@@ -18,296 +18,230 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE_
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
+ const syncword = 'fLaC';
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// http://flac.sourceforge.net/format.html
- $this->fseek($info['avdataoffset'], SEEK_SET);
+ $this->fseek($info['avdataoffset']);
$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;
+ if ($StreamMarker != self::syncword) {
+ return $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::syncword).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($StreamMarker).'"');
}
$info['fileformat'] = 'flac';
$info['audio']['dataformat'] = 'flac';
$info['audio']['bitrate_mode'] = 'vbr';
$info['audio']['lossless'] = true;
- return $this->FLACparseMETAdata();
+ // parse flac container
+ return $this->parseMETAdata();
}
-
- function FLACparseMETAdata() {
+ public function parseMETAdata() {
$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;
+ $BlockOffset = $this->ftell();
+ $BlockHeader = $this->fread(4);
+ $LBFBT = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1));
+ $LastBlockFlag = (bool) ($LBFBT & 0x80);
+ $BlockType = ($LBFBT & 0x7F);
+ $BlockLength = getid3_lib::BigEndian2Int(substr($BlockHeader, 1, 3));
+ $BlockTypeText = self::metaBlockTypeLookup($BlockType);
+
+ if (($BlockOffset + 4 + $BlockLength) > $info['avdataend']) {
+ $this->error('METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockTypeText.') at offset '.$BlockOffset.' extends beyond end of file');
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';
+ if ($BlockLength < 1) {
+ $this->error('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockLength.') at offset '.$BlockOffset.' is invalid');
break;
}
- if ($METAdataBlockLength < 1) {
- $info['error'][] = 'METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$METAdataBlockLength.') at offset '.$METAdataBlockOffset.' is invalid';
- break;
+
+ $info['flac'][$BlockTypeText]['raw'] = array();
+ $BlockTypeText_raw = &$info['flac'][$BlockTypeText]['raw'];
+
+ $BlockTypeText_raw['offset'] = $BlockOffset;
+ $BlockTypeText_raw['last_meta_block'] = $LastBlockFlag;
+ $BlockTypeText_raw['block_type'] = $BlockType;
+ $BlockTypeText_raw['block_type_text'] = $BlockTypeText;
+ $BlockTypeText_raw['block_length'] = $BlockLength;
+ if ($BlockTypeText_raw['block_type'] != 0x06) { // do not read attachment data automatically
+ $BlockTypeText_raw['block_data'] = $this->fread($BlockLength);
}
- $ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'] = $this->fread($METAdataBlockLength);
- $info['avdataoffset'] = $this->ftell();
- switch ($METAdataBlockTypeText) {
+ switch ($BlockTypeText) {
case 'STREAMINFO': // 0x00
- if (!$this->FLACparseSTREAMINFO($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'])) {
+ if (!$this->parseSTREAMINFO($BlockTypeText_raw['block_data'])) {
return false;
}
break;
case 'PADDING': // 0x01
- // ignore
+ unset($info['flac']['PADDING']); // ignore
break;
case 'APPLICATION': // 0x02
- if (!$this->FLACparseAPPLICATION($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'])) {
+ if (!$this->parseAPPLICATION($BlockTypeText_raw['block_data'])) {
return false;
}
break;
case 'SEEKTABLE': // 0x03
- if (!$this->FLACparseSEEKTABLE($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'])) {
+ if (!$this->parseSEEKTABLE($BlockTypeText_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'];
+ if (!$this->parseVORBIS_COMMENT($BlockTypeText_raw['block_data'])) {
+ return false;
}
- unset($getid3_temp, $getid3_ogg);
break;
case 'CUESHEET': // 0x05
- if (!getid3_flac::FLACparseCUESHEET($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'])) {
+ if (!$this->parseCUESHEET($BlockTypeText_raw['block_data'])) {
return false;
}
break;
case 'PICTURE': // 0x06
- if (!getid3_flac::FLACparsePICTURE($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'])) {
+ if (!$this->parsePICTURE()) {
return false;
}
break;
default:
- $info['warning'][] = 'Unhandled METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$METAdataBlockType.') at offset '.$METAdataBlockOffset;
- break;
+ $this->warning('Unhandled METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockType.') at offset '.$BlockOffset);
}
- } while ($METAdataLastBlockFlag === false);
+ unset($info['flac'][$BlockTypeText]['raw']);
+ $info['avdataoffset'] = $this->ftell();
+ }
+ while ($LastBlockFlag === false);
+
+ // handle tags
+ if (!empty($info['flac']['VORBIS_COMMENT']['comments'])) {
+ $info['flac']['comments'] = $info['flac']['VORBIS_COMMENT']['comments'];
+ }
+ if (!empty($info['flac']['VORBIS_COMMENT']['vendor'])) {
+ $info['audio']['encoder'] = str_replace('reference ', '', $info['flac']['VORBIS_COMMENT']['vendor']);
+ }
- 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']);
+ // copy attachments to 'comments' array if nesesary
+ if (isset($info['flac']['PICTURE']) && ($this->getid3->option_save_attachments !== getID3::ATTACHMENTS_NONE)) {
+ foreach ($info['flac']['PICTURE'] as $entry) {
+ if (!empty($entry['data'])) {
+ $info['flac']['comments']['picture'][] = array('image_mime'=>$entry['image_mime'], 'data'=>$entry['data']);
}
}
}
if (isset($info['flac']['STREAMINFO'])) {
- $info['flac']['compressed_audio_bytes'] = $info['avdataend'] - $info['avdataoffset'];
+ if (!$this->isDependencyFor('matroska')) {
+ $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;
+ return $this->error('Corrupt FLAC file: uncompressed_audio_bytes == zero');
+ }
+ if (!$this->isDependencyFor('matroska')) {
+ $info['flac']['compression_ratio'] = $info['flac']['compressed_audio_bytes'] / $info['flac']['uncompressed_audio_bytes'];
}
- $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 {
-
+ $this->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);
+ $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'];
+ if (isset($info['flac']['STREAMINFO']['bits_per_sample'])) {
+ $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
+ $this->warning('FLAC calculates MD5 data strangely on 8-bit audio, so the stored md5_data_source value will not match the decoded WAV file');
+ }
}
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');
- }
+ private function parseSTREAMINFO($BlockData) {
+ $info = &$this->getid3->info;
- 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');
- }
+ $info['flac']['STREAMINFO'] = array();
+ $streaminfo = &$info['flac']['STREAMINFO'];
- function FLACparseSTREAMINFO($METAdataBlockData) {
- $info = &$this->getid3->info;
+ $streaminfo['min_block_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 0, 2));
+ $streaminfo['max_block_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 2, 2));
+ $streaminfo['min_frame_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 4, 3));
+ $streaminfo['max_frame_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 7, 3));
- $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;
+ $SRCSBSS = getid3_lib::BigEndian2Bin(substr($BlockData, 10, 8));
+ $streaminfo['sample_rate'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 0, 20));
+ $streaminfo['channels'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 20, 3)) + 1;
+ $streaminfo['bits_per_sample'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 23, 5)) + 1;
+ $streaminfo['samples_stream'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 28, 36));
- $info['flac']['STREAMINFO']['audio_signature'] = substr($METAdataBlockData, $offset, 16);
- $offset += 16;
+ $streaminfo['audio_signature'] = substr($BlockData, 18, 16);
- if (!empty($info['flac']['STREAMINFO']['sample_rate'])) {
+ if (!empty($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'];
+ $info['audio']['bitrate_mode'] = 'vbr';
+ $info['audio']['sample_rate'] = $streaminfo['sample_rate'];
+ $info['audio']['channels'] = $streaminfo['channels'];
+ $info['audio']['bits_per_sample'] = $streaminfo['bits_per_sample'];
+ $info['playtime_seconds'] = $streaminfo['samples_stream'] / $streaminfo['sample_rate'];
if ($info['playtime_seconds'] > 0) {
- $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+ if (!$this->isDependencyFor('matroska')) {
+ $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+ }
+ else {
+ $this->warning('Cannot determine audio bitrate because total stream size is unknown');
+ }
}
} else {
- $info['error'][] = 'Corrupt METAdata block: STREAMINFO';
- return false;
+ return $this->error('Corrupt METAdata block: STREAMINFO');
}
- unset($info['flac']['STREAMINFO']['raw']);
+
return true;
}
-
- function FLACparseAPPLICATION($METAdataBlockData) {
+ private function parseAPPLICATION($BlockData) {
$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;
+ $ApplicationID = getid3_lib::BigEndian2Int(substr($BlockData, 0, 4));
+ $info['flac']['APPLICATION'][$ApplicationID]['name'] = self::applicationIDLookup($ApplicationID);
+ $info['flac']['APPLICATION'][$ApplicationID]['data'] = substr($BlockData, 4);
- unset($info['flac']['APPLICATION']['raw']);
return true;
}
-
- function FLACparseSEEKTABLE($METAdataBlockData) {
+ private function parseSEEKTABLE($BlockData) {
$info = &$this->getid3->info;
$offset = 0;
- $METAdataBlockLength = strlen($METAdataBlockData);
+ $BlockLength = strlen($BlockData);
$placeholderpattern = str_repeat("\xFF", 8);
- while ($offset < $METAdataBlockLength) {
- $SampleNumberString = substr($METAdataBlockData, $offset, 8);
+ while ($offset < $BlockLength) {
+ $SampleNumberString = substr($BlockData, $offset, 8);
$offset += 8;
if ($SampleNumberString == $placeholderpattern) {
@@ -317,60 +251,77 @@ class getid3_flac extends getid3_handler
} else {
- $SampleNumber = getid3_lib::BigEndian2Int($SampleNumberString);
- $info['flac']['SEEKTABLE'][$SampleNumber]['offset'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
+ $SampleNumber = getid3_lib::BigEndian2Int($SampleNumberString);
+ $info['flac']['SEEKTABLE'][$SampleNumber]['offset'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
$offset += 8;
- $info['flac']['SEEKTABLE'][$SampleNumber]['samples'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 2));
+ $info['flac']['SEEKTABLE'][$SampleNumber]['samples'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 2));
$offset += 2;
}
}
- unset($info['flac']['SEEKTABLE']['raw']);
+ return true;
+ }
+
+ private function parseVORBIS_COMMENT($BlockData) {
+ $info = &$this->getid3->info;
+
+ $getid3_ogg = new getid3_ogg($this->getid3);
+ if ($this->isDependencyFor('matroska')) {
+ $getid3_ogg->setStringMode($this->data_string);
+ }
+ $getid3_ogg->ParseVorbisComments();
+ if (isset($info['ogg'])) {
+ unset($info['ogg']['comments_raw']);
+ $info['flac']['VORBIS_COMMENT'] = $info['ogg'];
+ unset($info['ogg']);
+ }
+
+ unset($getid3_ogg);
return true;
}
- function FLACparseCUESHEET($METAdataBlockData) {
+ private function parseCUESHEET($BlockData) {
$info = &$this->getid3->info;
$offset = 0;
- $info['flac']['CUESHEET']['media_catalog_number'] = trim(substr($METAdataBlockData, $offset, 128), "\0");
+ $info['flac']['CUESHEET']['media_catalog_number'] = trim(substr($BlockData, $offset, 128), "\0");
$offset += 128;
- $info['flac']['CUESHEET']['lead_in_samples'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
+ $info['flac']['CUESHEET']['lead_in_samples'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
$offset += 8;
- $info['flac']['CUESHEET']['flags']['is_cd'] = (bool) (getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1)) & 0x80);
+ $info['flac']['CUESHEET']['flags']['is_cd'] = (bool) (getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1)) & 0x80);
$offset += 1;
$offset += 258; // reserved
- $info['flac']['CUESHEET']['number_tracks'] = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
+ $info['flac']['CUESHEET']['number_tracks'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
$offset += 1;
for ($track = 0; $track < $info['flac']['CUESHEET']['number_tracks']; $track++) {
- $TrackSampleOffset = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
+ $TrackSampleOffset = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
$offset += 8;
- $TrackNumber = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
+ $TrackNumber = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
$offset += 1;
$info['flac']['CUESHEET']['tracks'][$TrackNumber]['sample_offset'] = $TrackSampleOffset;
- $info['flac']['CUESHEET']['tracks'][$TrackNumber]['isrc'] = substr($METAdataBlockData, $offset, 12);
+ $info['flac']['CUESHEET']['tracks'][$TrackNumber]['isrc'] = substr($BlockData, $offset, 12);
$offset += 12;
- $TrackFlagsRaw = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
+ $TrackFlagsRaw = getid3_lib::BigEndian2Int(substr($BlockData, $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));
+ $info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
$offset += 1;
for ($index = 0; $index < $info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points']; $index++) {
- $IndexSampleOffset = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
+ $IndexSampleOffset = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
$offset += 8;
- $IndexNumber = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
+ $IndexNumber = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
$offset += 1;
$offset += 3; // reserved
@@ -379,102 +330,112 @@ class getid3_flac extends getid3_handler
}
}
- unset($info['flac']['CUESHEET']['raw']);
-
return true;
}
-
- function FLACparsePICTURE($meta_data_block_data) {
+ /**
+ * Parse METADATA_BLOCK_PICTURE flac structure and extract attachment
+ * External usage: audio.ogg
+ */
+ public function parsePICTURE() {
$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']);
+ $picture['typeid'] = getid3_lib::BigEndian2Int($this->fread(4));
+ $picture['type'] = self::pictureTypeLookup($picture['typeid']);
+ $picture['image_mime'] = $this->fread(getid3_lib::BigEndian2Int($this->fread(4)));
+ $descr_length = getid3_lib::BigEndian2Int($this->fread(4));
+ if ($descr_length) {
+ $picture['description'] = $this->fread($descr_length);
+ }
+ $picture['width'] = getid3_lib::BigEndian2Int($this->fread(4));
+ $picture['height'] = getid3_lib::BigEndian2Int($this->fread(4));
+ $picture['color_depth'] = getid3_lib::BigEndian2Int($this->fread(4));
+ $picture['colors_indexed'] = getid3_lib::BigEndian2Int($this->fread(4));
+ $data_length = getid3_lib::BigEndian2Int($this->fread(4));
+
+ if ($picture['image_mime'] == '-->') {
+ $picture['data'] = $this->fread($data_length);
+ } else {
+ $picture['data'] = $this->saveAttachment(
+ $picture['type'].'_'.$this->ftell(),
+ $this->ftell(),
+ $data_length,
+ $picture['image_mime']);
+ }
+ $info['flac']['PICTURE'][] = $picture;
- 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;
+ }
+ public static function metaBlockTypeLookup($blocktype) {
+ static $lookup = array(
+ 0 => 'STREAMINFO',
+ 1 => 'PADDING',
+ 2 => 'APPLICATION',
+ 3 => 'SEEKTABLE',
+ 4 => 'VORBIS_COMMENT',
+ 5 => 'CUESHEET',
+ 6 => 'PICTURE',
+ );
+ return (isset($lookup[$blocktype]) ? $lookup[$blocktype] : 'reserved');
+ }
+ public static function applicationIDLookup($applicationid) {
+ // http://flac.sourceforge.net/id.html
+ static $lookup = array(
+ 0x41544348 => 'FlacFile', // "ATCH"
+ 0x42534F4C => 'beSolo', // "BSOL"
+ 0x42554753 => 'Bugs Player', // "BUGS"
+ 0x43756573 => 'GoldWave cue points (specification)', // "Cues"
+ 0x46696361 => 'CUE Splitter', // "Fica"
+ 0x46746F6C => 'flac-tools', // "Ftol"
+ 0x4D4F5442 => 'MOTB MetaCzar', // "MOTB"
+ 0x4D505345 => 'MP3 Stream Editor', // "MPSE"
+ 0x4D754D4C => 'MusicML: Music Metadata Language', // "MuML"
+ 0x52494646 => 'Sound Devices RIFF chunk storage', // "RIFF"
+ 0x5346464C => 'Sound Font FLAC', // "SFFL"
+ 0x534F4E59 => 'Sony Creative Software', // "SONY"
+ 0x5351455A => 'flacsqueeze', // "SQEZ"
+ 0x54745776 => 'TwistedWave', // "TtWv"
+ 0x55495453 => 'UITS Embedding tools', // "UITS"
+ 0x61696666 => 'FLAC AIFF chunk storage', // "aiff"
+ 0x696D6167 => 'flac-image application for storing arbitrary files in APPLICATION metadata blocks', // "imag"
+ 0x7065656D => 'Parseable Embedded Extensible Metadata (specification)', // "peem"
+ 0x71667374 => 'QFLAC Studio', // "qfst"
+ 0x72696666 => 'FLAC RIFF chunk storage', // "riff"
+ 0x74756E65 => 'TagTuner', // "tune"
+ 0x78626174 => 'XBAT', // "xbat"
+ 0x786D6364 => 'xmcd', // "xmcd"
+ );
+ return (isset($lookup[$applicationid]) ? $lookup[$applicationid] : 'reserved');
+ }
- return true;
+ public static function pictureTypeLookup($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');
}
-}
-?> \ No newline at end of file
+}
diff --git a/modules/getid3/module.audio.la.php b/modules/getid3/module.audio.la.php
index 98d80a6d..943a4ca7 100644
--- a/modules/getid3/module.audio.la.php
+++ b/modules/getid3/module.audio.la.php
@@ -18,7 +18,7 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php',
class getid3_la extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$offset = 0;
@@ -193,7 +193,6 @@ class getid3_la extends getid3_handler
$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) {
@@ -224,6 +223,3 @@ class getid3_la extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.lpac.php b/modules/getid3/module.audio.lpac.php
index 6ef0fb8a..3d45e000 100644
--- a/modules/getid3/module.audio.lpac.php
+++ b/modules/getid3/module.audio.lpac.php
@@ -18,7 +18,7 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php',
class getid3_lpac extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -125,6 +125,3 @@ class getid3_lpac extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.midi.php b/modules/getid3/module.audio.midi.php
index 7b839cf1..17a87084 100644
--- a/modules/getid3/module.audio.midi.php
+++ b/modules/getid3/module.audio.midi.php
@@ -18,9 +18,9 @@ define('GETID3_MIDI_MAGIC_MTRK', 'MTrk'); // MIDI track header magic
class getid3_midi extends getid3_handler
{
- var $scanwholefile = true;
+ public $scanwholefile = true;
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// shortcut
@@ -322,7 +322,7 @@ class getid3_midi extends getid3_handler
return true;
}
- function GeneralMIDIinstrumentLookup($instrumentid) {
+ public function GeneralMIDIinstrumentLookup($instrumentid) {
$begin = __LINE__;
@@ -462,7 +462,7 @@ class getid3_midi extends getid3_handler
return getid3_lib::EmbeddedLookup($instrumentid, $begin, __LINE__, __FILE__, 'GeneralMIDIinstrument');
}
- function GeneralMIDIpercussionLookup($instrumentid) {
+ public function GeneralMIDIpercussionLookup($instrumentid) {
$begin = __LINE__;
@@ -521,6 +521,3 @@ class getid3_midi extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.mod.php b/modules/getid3/module.audio.mod.php
index b8817694..3bed8586 100644
--- a/modules/getid3/module.audio.mod.php
+++ b/modules/getid3/module.audio.mod.php
@@ -17,7 +17,7 @@
class getid3_mod extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$fileheader = fread($this->getid3->fp, 1088);
@@ -35,7 +35,7 @@ class getid3_mod extends getid3_handler
}
- function getMODheaderFilepointer() {
+ public function getMODheaderFilepointer() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'] + 1080);
$FormatID = fread($this->getid3->fp, 4);
@@ -50,7 +50,7 @@ class getid3_mod extends getid3_handler
return false;
}
- function getXMheaderFilepointer() {
+ public function getXMheaderFilepointer() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset']);
$FormatID = fread($this->getid3->fp, 15);
@@ -65,7 +65,7 @@ class getid3_mod extends getid3_handler
return false;
}
- function getS3MheaderFilepointer() {
+ public function getS3MheaderFilepointer() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'] + 44);
$FormatID = fread($this->getid3->fp, 4);
@@ -80,7 +80,7 @@ class getid3_mod extends getid3_handler
return false;
}
- function getITheaderFilepointer() {
+ public function getITheaderFilepointer() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset']);
$FormatID = fread($this->getid3->fp, 4);
@@ -96,6 +96,3 @@ class getid3_mod extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.monkey.php b/modules/getid3/module.audio.monkey.php
index ffaeae9f..9edba5d8 100644
--- a/modules/getid3/module.audio.monkey.php
+++ b/modules/getid3/module.audio.monkey.php
@@ -17,7 +17,7 @@
class getid3_monkey extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// based loosely on code from TMonkey by Jurgen Faul <jfaulØgmx*de>
@@ -176,7 +176,7 @@ class getid3_monkey extends getid3_handler
return true;
}
- function MonkeyCompressionLevelNameLookup($compressionlevel) {
+ public function MonkeyCompressionLevelNameLookup($compressionlevel) {
static $MonkeyCompressionLevelNameLookup = array(
0 => 'unknown',
1000 => 'fast',
@@ -188,7 +188,7 @@ class getid3_monkey extends getid3_handler
return (isset($MonkeyCompressionLevelNameLookup[$compressionlevel]) ? $MonkeyCompressionLevelNameLookup[$compressionlevel] : 'invalid');
}
- function MonkeySamplesPerFrame($versionid, $compressionlevel) {
+ public function MonkeySamplesPerFrame($versionid, $compressionlevel) {
if ($versionid >= 3950) {
return 73728 * 4;
} elseif ($versionid >= 3900) {
@@ -201,5 +201,3 @@ class getid3_monkey extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.mp3.php b/modules/getid3/module.audio.mp3.php
index 909646e1..e6ffea94 100644
--- a/modules/getid3/module.audio.mp3.php
+++ b/modules/getid3/module.audio.mp3.php
@@ -24,9 +24,9 @@ define('GETID3_MP3_VALID_CHECK_FRAMES', 35);
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
+ public $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 Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$initialOffset = $info['avdataoffset'];
@@ -160,7 +160,7 @@ class getid3_mp3 extends getid3_handler
}
- function GuessEncoderOptions() {
+ public function GuessEncoderOptions() {
// shortcuts
$info = &$this->getid3->info;
if (!empty($info['mpeg']['audio'])) {
@@ -404,7 +404,7 @@ class getid3_mp3 extends getid3_handler
}
- function decodeMPEGaudioHeader($offset, &$info, $recursivesearch=true, $ScanAsCBR=false, $FastMPEGheaderScan=false) {
+ public function decodeMPEGaudioHeader($offset, &$info, $recursivesearch=true, $ScanAsCBR=false, $FastMPEGheaderScan=false) {
static $MPEGaudioVersionLookup;
static $MPEGaudioLayerLookup;
static $MPEGaudioBitrateLookup;
@@ -413,13 +413,13 @@ class getid3_mp3 extends getid3_handler
static $MPEGaudioModeExtensionLookup;
static $MPEGaudioEmphasisLookup;
if (empty($MPEGaudioVersionLookup)) {
- $MPEGaudioVersionLookup = getid3_mp3::MPEGaudioVersionArray();
- $MPEGaudioLayerLookup = getid3_mp3::MPEGaudioLayerArray();
- $MPEGaudioBitrateLookup = getid3_mp3::MPEGaudioBitrateArray();
- $MPEGaudioFrequencyLookup = getid3_mp3::MPEGaudioFrequencyArray();
- $MPEGaudioChannelModeLookup = getid3_mp3::MPEGaudioChannelModeArray();
- $MPEGaudioModeExtensionLookup = getid3_mp3::MPEGaudioModeExtensionArray();
- $MPEGaudioEmphasisLookup = getid3_mp3::MPEGaudioEmphasisArray();
+ $MPEGaudioVersionLookup = self::MPEGaudioVersionArray();
+ $MPEGaudioLayerLookup = self::MPEGaudioLayerArray();
+ $MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray();
+ $MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray();
+ $MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray();
+ $MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray();
+ $MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray();
}
if (fseek($this->getid3->fp, $offset, SEEK_SET) != 0) {
@@ -441,14 +441,14 @@ class getid3_mp3 extends getid3_handler
if (isset($MPEGaudioHeaderDecodeCache[$head4])) {
$MPEGheaderRawArray = $MPEGaudioHeaderDecodeCache[$head4];
} else {
- $MPEGheaderRawArray = getid3_mp3::MPEGaudioHeaderDecode($head4);
+ $MPEGheaderRawArray = self::MPEGaudioHeaderDecode($head4);
$MPEGaudioHeaderDecodeCache[$head4] = $MPEGheaderRawArray;
}
static $MPEGaudioHeaderValidCache = array();
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);
+ //$MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGheaderRawArray, false, true); // allow badly-formatted freeformat (from LAME 3.90 - 3.93.1)
+ $MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGheaderRawArray, false, false);
}
// shortcut
@@ -533,7 +533,7 @@ class getid3_mp3 extends getid3_handler
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']);
+ $thisfile_mpeg_audio['framelength'] = self::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;
@@ -594,7 +594,7 @@ class getid3_mp3 extends getid3_handler
// Xing VBR header is hardcoded 'Xing' at a offset 0x0D (13), 0x15 (21) or 0x24 (36)
// depending on MPEG layer and number of channels
- $VBRidOffset = getid3_mp3::XingVBRidOffset($thisfile_mpeg_audio['version'], $thisfile_mpeg_audio['channelmode']);
+ $VBRidOffset = self::XingVBRidOffset($thisfile_mpeg_audio['version'], $thisfile_mpeg_audio['channelmode']);
$SideInfoData = substr($headerstring, 4 + 2, $VBRidOffset - 4);
if ((substr($headerstring, $VBRidOffset, strlen('Xing')) == 'Xing') || (substr($headerstring, $VBRidOffset, strlen('Info')) == 'Info')) {
@@ -720,7 +720,7 @@ class getid3_mp3 extends getid3_handler
$thisfile_mpeg_audio_lame['tag_revision'] = ($LAMEtagRevisionVBRmethod & 0xF0) >> 4;
$thisfile_mpeg_audio_lame_raw['vbr_method'] = $LAMEtagRevisionVBRmethod & 0x0F;
- $thisfile_mpeg_audio_lame['vbr_method'] = getid3_mp3::LAMEvbrMethodLookup($thisfile_mpeg_audio_lame_raw['vbr_method']);
+ $thisfile_mpeg_audio_lame['vbr_method'] = self::LAMEvbrMethodLookup($thisfile_mpeg_audio_lame_raw['vbr_method']);
$thisfile_mpeg_audio['bitrate_mode'] = substr($thisfile_mpeg_audio_lame['vbr_method'], 0, 3); // usually either 'cbr' or 'vbr', but truncates 'vbr-old / vbr-rh' to 'vbr'
// byte $A6 Lowpass filter value
@@ -819,9 +819,9 @@ class getid3_mp3 extends getid3_handler
$thisfile_mpeg_audio_lame_raw['not_optimal_quality'] = ($MiscByte & 0x20) >> 5;
$thisfile_mpeg_audio_lame_raw['source_sample_freq'] = ($MiscByte & 0xC0) >> 6;
$thisfile_mpeg_audio_lame['noise_shaping'] = $thisfile_mpeg_audio_lame_raw['noise_shaping'];
- $thisfile_mpeg_audio_lame['stereo_mode'] = getid3_mp3::LAMEmiscStereoModeLookup($thisfile_mpeg_audio_lame_raw['stereo_mode']);
+ $thisfile_mpeg_audio_lame['stereo_mode'] = self::LAMEmiscStereoModeLookup($thisfile_mpeg_audio_lame_raw['stereo_mode']);
$thisfile_mpeg_audio_lame['not_optimal_quality'] = (bool) $thisfile_mpeg_audio_lame_raw['not_optimal_quality'];
- $thisfile_mpeg_audio_lame['source_sample_freq'] = getid3_mp3::LAMEmiscSourceSampleFrequencyLookup($thisfile_mpeg_audio_lame_raw['source_sample_freq']);
+ $thisfile_mpeg_audio_lame['source_sample_freq'] = self::LAMEmiscSourceSampleFrequencyLookup($thisfile_mpeg_audio_lame_raw['source_sample_freq']);
// byte $B5 MP3 Gain
$thisfile_mpeg_audio_lame_raw['mp3_gain'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB5, 1), false, true);
@@ -832,9 +832,9 @@ class getid3_mp3 extends getid3_handler
$PresetSurroundBytes = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB6, 2));
// Reserved = ($PresetSurroundBytes & 0xC000);
$thisfile_mpeg_audio_lame_raw['surround_info'] = ($PresetSurroundBytes & 0x3800);
- $thisfile_mpeg_audio_lame['surround_info'] = getid3_mp3::LAMEsurroundInfoLookup($thisfile_mpeg_audio_lame_raw['surround_info']);
+ $thisfile_mpeg_audio_lame['surround_info'] = self::LAMEsurroundInfoLookup($thisfile_mpeg_audio_lame_raw['surround_info']);
$thisfile_mpeg_audio_lame['preset_used_id'] = ($PresetSurroundBytes & 0x07FF);
- $thisfile_mpeg_audio_lame['preset_used'] = getid3_mp3::LAMEpresetUsedLookup($thisfile_mpeg_audio_lame);
+ $thisfile_mpeg_audio_lame['preset_used'] = self::LAMEpresetUsedLookup($thisfile_mpeg_audio_lame);
if (!empty($thisfile_mpeg_audio_lame['preset_used_id']) && empty($thisfile_mpeg_audio_lame['preset_used'])) {
$info['warning'][] = 'Unknown LAME preset used ('.$thisfile_mpeg_audio_lame['preset_used_id'].') - please report to info@getid3.org';
}
@@ -858,7 +858,7 @@ class getid3_mp3 extends getid3_handler
if ($thisfile_mpeg_audio_lame_raw['vbr_method'] == 1) {
$thisfile_mpeg_audio['bitrate_mode'] = 'cbr';
- $thisfile_mpeg_audio['bitrate'] = getid3_mp3::ClosestStandardMP3Bitrate($thisfile_mpeg_audio['bitrate']);
+ $thisfile_mpeg_audio['bitrate'] = self::ClosestStandardMP3Bitrate($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'];
@@ -1069,7 +1069,7 @@ class getid3_mp3 extends getid3_handler
return true;
}
- function RecursiveFrameScanning(&$offset, &$nextframetestoffset, $ScanAsCBR) {
+ public function RecursiveFrameScanning(&$offset, &$nextframetestoffset, $ScanAsCBR) {
$info = &$this->getid3->info;
$firstframetestarray = array('error'=>'', 'warning'=>'', 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']);
$this->decodeMPEGaudioHeader($offset, $firstframetestarray, false);
@@ -1115,7 +1115,7 @@ class getid3_mp3 extends getid3_handler
return true;
}
- function FreeFormatFrameLength($offset, $deepscan=false) {
+ public function FreeFormatFrameLength($offset, $deepscan=false) {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $offset, SEEK_SET);
@@ -1192,17 +1192,17 @@ class getid3_mp3 extends getid3_handler
return $framelength;
}
- function getOnlyMPEGaudioInfoBruteForce() {
+ public function getOnlyMPEGaudioInfoBruteForce() {
$MPEGaudioHeaderDecodeCache = array();
$MPEGaudioHeaderValidCache = array();
$MPEGaudioHeaderLengthCache = array();
- $MPEGaudioVersionLookup = getid3_mp3::MPEGaudioVersionArray();
- $MPEGaudioLayerLookup = getid3_mp3::MPEGaudioLayerArray();
- $MPEGaudioBitrateLookup = getid3_mp3::MPEGaudioBitrateArray();
- $MPEGaudioFrequencyLookup = getid3_mp3::MPEGaudioFrequencyArray();
- $MPEGaudioChannelModeLookup = getid3_mp3::MPEGaudioChannelModeArray();
- $MPEGaudioModeExtensionLookup = getid3_mp3::MPEGaudioModeExtensionArray();
- $MPEGaudioEmphasisLookup = getid3_mp3::MPEGaudioEmphasisArray();
+ $MPEGaudioVersionLookup = self::MPEGaudioVersionArray();
+ $MPEGaudioLayerLookup = self::MPEGaudioLayerArray();
+ $MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray();
+ $MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray();
+ $MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray();
+ $MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray();
+ $MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray();
$LongMPEGversionLookup = array();
$LongMPEGlayerLookup = array();
$LongMPEGbitrateLookup = array();
@@ -1237,10 +1237,10 @@ class getid3_mp3 extends getid3_handler
continue;
}
if (!isset($MPEGaudioHeaderDecodeCache[$head4])) {
- $MPEGaudioHeaderDecodeCache[$head4] = getid3_mp3::MPEGaudioHeaderDecode($head4);
+ $MPEGaudioHeaderDecodeCache[$head4] = self::MPEGaudioHeaderDecode($head4);
}
if (!isset($MPEGaudioHeaderValidCache[$head4])) {
- $MPEGaudioHeaderValidCache[$head4] = getid3_mp3::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$head4], false, false);
+ $MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$head4], false, false);
}
if ($MPEGaudioHeaderValidCache[$head4]) {
@@ -1250,7 +1250,7 @@ class getid3_mp3 extends getid3_handler
$LongMPEGbitrateLookup[$head4] = $MPEGaudioBitrateLookup[$LongMPEGversionLookup[$head4]][$LongMPEGlayerLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['bitrate']];
$LongMPEGpaddingLookup[$head4] = (bool) $MPEGaudioHeaderDecodeCache[$head4]['padding'];
$LongMPEGfrequencyLookup[$head4] = $MPEGaudioFrequencyLookup[$LongMPEGversionLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['sample_rate']];
- $MPEGaudioHeaderLengthCache[$head4] = getid3_mp3::MPEGaudioFrameLength(
+ $MPEGaudioHeaderLengthCache[$head4] = self::MPEGaudioFrameLength(
$LongMPEGbitrateLookup[$head4],
$LongMPEGversionLookup[$head4],
$LongMPEGlayerLookup[$head4],
@@ -1263,10 +1263,10 @@ class getid3_mp3 extends getid3_handler
$next4 = fread($this->getid3->fp, 4);
if ($next4{0} == "\xFF") {
if (!isset($MPEGaudioHeaderDecodeCache[$next4])) {
- $MPEGaudioHeaderDecodeCache[$next4] = getid3_mp3::MPEGaudioHeaderDecode($next4);
+ $MPEGaudioHeaderDecodeCache[$next4] = self::MPEGaudioHeaderDecode($next4);
}
if (!isset($MPEGaudioHeaderValidCache[$next4])) {
- $MPEGaudioHeaderValidCache[$next4] = getid3_mp3::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false);
+ $MPEGaudioHeaderValidCache[$next4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false);
}
if ($MPEGaudioHeaderValidCache[$next4]) {
fseek($this->getid3->fp, -4, SEEK_CUR);
@@ -1340,7 +1340,7 @@ class getid3_mp3 extends getid3_handler
}
- function getOnlyMPEGaudioInfo($avdataoffset, $BitrateHistogram=false) {
+ public function getOnlyMPEGaudioInfo($avdataoffset, $BitrateHistogram=false) {
// looks for synch, decodes MPEG audio header
$info = &$this->getid3->info;
@@ -1349,9 +1349,9 @@ class getid3_mp3 extends getid3_handler
static $MPEGaudioLayerLookup;
static $MPEGaudioBitrateLookup;
if (empty($MPEGaudioVersionLookup)) {
- $MPEGaudioVersionLookup = getid3_mp3::MPEGaudioVersionArray();
- $MPEGaudioLayerLookup = getid3_mp3::MPEGaudioLayerArray();
- $MPEGaudioBitrateLookup = getid3_mp3::MPEGaudioBitrateArray();
+ $MPEGaudioVersionLookup = self::MPEGaudioVersionArray();
+ $MPEGaudioLayerLookup = self::MPEGaudioLayerArray();
+ $MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray();
}
@@ -1620,17 +1620,17 @@ class getid3_mp3 extends getid3_handler
}
- static function MPEGaudioVersionArray() {
+ public static function MPEGaudioVersionArray() {
static $MPEGaudioVersion = array('2.5', false, '2', '1');
return $MPEGaudioVersion;
}
- static function MPEGaudioLayerArray() {
+ public static function MPEGaudioLayerArray() {
static $MPEGaudioLayer = array(false, 3, 2, 1);
return $MPEGaudioLayer;
}
- static function MPEGaudioBitrateArray() {
+ public static function MPEGaudioBitrateArray() {
static $MPEGaudioBitrate;
if (empty($MPEGaudioBitrate)) {
$MPEGaudioBitrate = array (
@@ -1649,7 +1649,7 @@ class getid3_mp3 extends getid3_handler
return $MPEGaudioBitrate;
}
- static function MPEGaudioFrequencyArray() {
+ public static function MPEGaudioFrequencyArray() {
static $MPEGaudioFrequency;
if (empty($MPEGaudioFrequency)) {
$MPEGaudioFrequency = array (
@@ -1661,12 +1661,12 @@ class getid3_mp3 extends getid3_handler
return $MPEGaudioFrequency;
}
- static function MPEGaudioChannelModeArray() {
+ public static function MPEGaudioChannelModeArray() {
static $MPEGaudioChannelMode = array('stereo', 'joint stereo', 'dual channel', 'mono');
return $MPEGaudioChannelMode;
}
- static function MPEGaudioModeExtensionArray() {
+ public static function MPEGaudioModeExtensionArray() {
static $MPEGaudioModeExtension;
if (empty($MPEGaudioModeExtension)) {
$MPEGaudioModeExtension = array (
@@ -1678,16 +1678,16 @@ class getid3_mp3 extends getid3_handler
return $MPEGaudioModeExtension;
}
- static function MPEGaudioEmphasisArray() {
+ public static function MPEGaudioEmphasisArray() {
static $MPEGaudioEmphasis = array('none', '50/15ms', false, 'CCIT J.17');
return $MPEGaudioEmphasis;
}
- static function MPEGaudioHeaderBytesValid($head4, $allowBitrate15=false) {
- return getid3_mp3::MPEGaudioHeaderValid(getid3_mp3::MPEGaudioHeaderDecode($head4), false, $allowBitrate15);
+ public static function MPEGaudioHeaderBytesValid($head4, $allowBitrate15=false) {
+ return self::MPEGaudioHeaderValid(self::MPEGaudioHeaderDecode($head4), false, $allowBitrate15);
}
- static function MPEGaudioHeaderValid($rawarray, $echoerrors=false, $allowBitrate15=false) {
+ public static function MPEGaudioHeaderValid($rawarray, $echoerrors=false, $allowBitrate15=false) {
if (($rawarray['synch'] & 0x0FFE) != 0x0FFE) {
return false;
}
@@ -1700,13 +1700,13 @@ class getid3_mp3 extends getid3_handler
static $MPEGaudioModeExtensionLookup;
static $MPEGaudioEmphasisLookup;
if (empty($MPEGaudioVersionLookup)) {
- $MPEGaudioVersionLookup = getid3_mp3::MPEGaudioVersionArray();
- $MPEGaudioLayerLookup = getid3_mp3::MPEGaudioLayerArray();
- $MPEGaudioBitrateLookup = getid3_mp3::MPEGaudioBitrateArray();
- $MPEGaudioFrequencyLookup = getid3_mp3::MPEGaudioFrequencyArray();
- $MPEGaudioChannelModeLookup = getid3_mp3::MPEGaudioChannelModeArray();
- $MPEGaudioModeExtensionLookup = getid3_mp3::MPEGaudioModeExtensionArray();
- $MPEGaudioEmphasisLookup = getid3_mp3::MPEGaudioEmphasisArray();
+ $MPEGaudioVersionLookup = self::MPEGaudioVersionArray();
+ $MPEGaudioLayerLookup = self::MPEGaudioLayerArray();
+ $MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray();
+ $MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray();
+ $MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray();
+ $MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray();
+ $MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray();
}
if (isset($MPEGaudioVersionLookup[$rawarray['version']])) {
@@ -1759,7 +1759,7 @@ class getid3_mp3 extends getid3_handler
return true;
}
- static function MPEGaudioHeaderDecode($Header4Bytes) {
+ public static function MPEGaudioHeaderDecode($Header4Bytes) {
// AAAA AAAA AAAB BCCD EEEE FFGH IIJJ KLMM
// A - Frame sync (all bits set)
// B - MPEG Audio version ID
@@ -1796,7 +1796,7 @@ class getid3_mp3 extends getid3_handler
return $MPEGrawHeader;
}
- static function MPEGaudioFrameLength(&$bitrate, &$version, &$layer, $padding, &$samplerate) {
+ public static function MPEGaudioFrameLength(&$bitrate, &$version, &$layer, $padding, &$samplerate) {
static $AudioFrameLengthCache = array();
if (!isset($AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate])) {
@@ -1857,7 +1857,7 @@ class getid3_mp3 extends getid3_handler
return $AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate];
}
- static function ClosestStandardMP3Bitrate($bit_rate) {
+ public 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));
@@ -1877,7 +1877,7 @@ class getid3_mp3 extends getid3_handler
return $bit_rate_table[$round_bit_rate];
}
- static function XingVBRidOffset($version, $channelmode) {
+ public static function XingVBRidOffset($version, $channelmode) {
static $XingVBRidOffsetCache = array();
if (empty($XingVBRidOffset)) {
$XingVBRidOffset = array (
@@ -1903,7 +1903,7 @@ class getid3_mp3 extends getid3_handler
return $XingVBRidOffset[$version][$channelmode];
}
- static function LAMEvbrMethodLookup($VBRmethodID) {
+ public static function LAMEvbrMethodLookup($VBRmethodID) {
static $LAMEvbrMethodLookup = array(
0x00 => 'unknown',
0x01 => 'cbr',
@@ -1919,7 +1919,7 @@ class getid3_mp3 extends getid3_handler
return (isset($LAMEvbrMethodLookup[$VBRmethodID]) ? $LAMEvbrMethodLookup[$VBRmethodID] : '');
}
- static function LAMEmiscStereoModeLookup($StereoModeID) {
+ public static function LAMEmiscStereoModeLookup($StereoModeID) {
static $LAMEmiscStereoModeLookup = array(
0 => 'mono',
1 => 'stereo',
@@ -1933,7 +1933,7 @@ class getid3_mp3 extends getid3_handler
return (isset($LAMEmiscStereoModeLookup[$StereoModeID]) ? $LAMEmiscStereoModeLookup[$StereoModeID] : '');
}
- static function LAMEmiscSourceSampleFrequencyLookup($SourceSampleFrequencyID) {
+ public static function LAMEmiscSourceSampleFrequencyLookup($SourceSampleFrequencyID) {
static $LAMEmiscSourceSampleFrequencyLookup = array(
0 => '<= 32 kHz',
1 => '44.1 kHz',
@@ -1943,7 +1943,7 @@ class getid3_mp3 extends getid3_handler
return (isset($LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID]) ? $LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID] : '');
}
- static function LAMEsurroundInfoLookup($SurroundInfoID) {
+ public static function LAMEsurroundInfoLookup($SurroundInfoID) {
static $LAMEsurroundInfoLookup = array(
0 => 'no surround info',
1 => 'DPL encoding',
@@ -1953,7 +1953,7 @@ class getid3_mp3 extends getid3_handler
return (isset($LAMEsurroundInfoLookup[$SurroundInfoID]) ? $LAMEsurroundInfoLookup[$SurroundInfoID] : 'reserved');
}
- static function LAMEpresetUsedLookup($LAMEtag) {
+ public static function LAMEpresetUsedLookup($LAMEtag) {
if ($LAMEtag['preset_used_id'] == 0) {
// no preset used (LAME >=3.93)
@@ -2007,5 +2007,3 @@ class getid3_mp3 extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.mpc.php b/modules/getid3/module.audio.mpc.php
index 9a0b16d9..8ab421eb 100644
--- a/modules/getid3/module.audio.mpc.php
+++ b/modules/getid3/module.audio.mpc.php
@@ -17,7 +17,7 @@
class getid3_mpc extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['mpc']['header'] = array();
@@ -59,7 +59,7 @@ class getid3_mpc extends getid3_handler
}
- function ParseMPCsv8() {
+ public function ParseMPCsv8() {
// this is SV8
// http://trac.musepack.net/trac/wiki/SV8Specification
@@ -207,7 +207,7 @@ class getid3_mpc extends getid3_handler
return true;
}
- function ParseMPCsv7() {
+ public function ParseMPCsv7() {
// this is SV7
// http://www.uni-jena.de/~pfk/mpp/sv8/header.html
@@ -321,7 +321,7 @@ class getid3_mpc extends getid3_handler
return true;
}
- function ParseMPCsv6() {
+ public function ParseMPCsv6() {
// this is SV4 - SV6
$info = &$this->getid3->info;
@@ -397,7 +397,7 @@ class getid3_mpc extends getid3_handler
}
- function MPCprofileNameLookup($profileid) {
+ public function MPCprofileNameLookup($profileid) {
static $MPCprofileNameLookup = array(
0 => 'no profile',
1 => 'Experimental',
@@ -419,7 +419,7 @@ class getid3_mpc extends getid3_handler
return (isset($MPCprofileNameLookup[$profileid]) ? $MPCprofileNameLookup[$profileid] : 'invalid');
}
- function MPCfrequencyLookup($frequencyid) {
+ public function MPCfrequencyLookup($frequencyid) {
static $MPCfrequencyLookup = array(
0 => 44100,
1 => 48000,
@@ -429,14 +429,14 @@ class getid3_mpc extends getid3_handler
return (isset($MPCfrequencyLookup[$frequencyid]) ? $MPCfrequencyLookup[$frequencyid] : 'invalid');
}
- function MPCpeakDBLookup($intvalue) {
+ public function MPCpeakDBLookup($intvalue) {
if ($intvalue > 0) {
return ((log10($intvalue) / log10(2)) - 15) * 6;
}
return false;
}
- function MPCencoderVersionLookup($encoderversion) {
+ public function MPCencoderVersionLookup($encoderversion) {
//Encoder version * 100 (106 = 1.06)
//EncoderVersion % 10 == 0 Release (1.0)
//EncoderVersion % 2 == 0 Beta (1.06)
@@ -463,7 +463,7 @@ class getid3_mpc extends getid3_handler
return number_format($encoderversion / 100, 2).' alpha';
}
- function SV8variableLengthInteger($data, &$packetLength, $maxHandledPacketLength=9) {
+ public function SV8variableLengthInteger($data, &$packetLength, $maxHandledPacketLength=9) {
$packet_size = 0;
for ($packetLength = 1; $packetLength <= $maxHandledPacketLength; $packetLength++) {
// variable-length size field:
@@ -487,7 +487,7 @@ class getid3_mpc extends getid3_handler
return $packet_size;
}
- function MPCsv8PacketName($packetKey) {
+ public function MPCsv8PacketName($packetKey) {
static $MPCsv8PacketName = array();
if (empty($MPCsv8PacketName)) {
$MPCsv8PacketName = array(
@@ -504,6 +504,3 @@ class getid3_mpc extends getid3_handler
return (isset($MPCsv8PacketName[$packetKey]) ? $MPCsv8PacketName[$packetKey] : $packetKey);
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.ogg.php b/modules/getid3/module.audio.ogg.php
index c987fa67..a2a35aad 100644
--- a/modules/getid3/module.audio.ogg.php
+++ b/modules/getid3/module.audio.ogg.php
@@ -17,9 +17,8 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.flac.php', __FILE
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() {
+ // http://xiph.org/vorbis/doc/Vorbis_I_spec.html
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'ogg';
@@ -38,19 +37,19 @@ class getid3_ogg extends getid3_handler
// Page 1 - Stream Header
- fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
+ $this->fseek($info['avdataoffset']);
$oggpageinfo = $this->ParseOggPageHeader();
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
- if (ftell($this->getid3->fp) >= $this->getid3->fread_buffer_size()) {
+ if ($this->ftell() >= $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']);
+ $filedata = $this->fread($oggpageinfo['page_length']);
$filedataoffset = 0;
if (substr($filedata, 0, 4) == 'fLaC') {
@@ -146,8 +145,8 @@ class getid3_ogg extends getid3_handler
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);
+ $filedata = $this->fread($oggpageinfo['page_length']);
+ $this->fseek($oggpageinfo['page_end_offset']);
if (substr($filedata, 0, 8) == "fisbone\x00") {
@@ -174,25 +173,24 @@ class getid3_ogg extends getid3_handler
} 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;
+ $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;
+ $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;
+ $this->fseek($oggpageinfo['page_start_offset']);
+ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3 ['.$this->getid3->version().']';
+ //return false;
} else {
@@ -209,44 +207,41 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
switch ($info['audio']['dataformat']) {
case 'vorbis':
- $filedata = fread($this->getid3->fp, $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
+ $filedata = $this->fread($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();
+ $this->ParseVorbisComments();
break;
case 'flac':
- $getid3_flac = new getid3_flac($this->getid3);
- if (!$getid3_flac->FLACparseMETAdata()) {
+ $flac = new getid3_flac($this->getid3);
+ if (!$flac->parseMETAdata()) {
$info['error'][] = 'Failed to parse FLAC headers';
return false;
}
- unset($getid3_flac);
+ unset($flac);
break;
case 'speex':
- fseek($this->getid3->fp, $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length'], SEEK_CUR);
- $this->ParseVorbisCommentsFilepointer();
+ $this->fseek($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length'], SEEK_CUR);
+ $this->ParseVorbisComments();
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()));
+ $this->fseek(max($info['avdataend'] - $this->getid3->fread_buffer_size(), 0));
+ $LastChunkOfOgg = strrev($this->fread($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);
+ $this->fseek($info['avdataend'] - ($LastOggSpostion + strlen('SggO')));
+ $info['avdataend'] = $this->ftell();
$info['ogg']['pageheader']['eos'] = $this->ParseOggPageHeader();
$info['ogg']['samples'] = $info['ogg']['pageheader']['eos']['pcm_abs_position'];
if ($info['ogg']['samples'] == 0) {
@@ -305,7 +300,7 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
return true;
}
- function ParseVorbisPageHeader(&$filedata, &$filedataoffset, &$oggpageinfo) {
+ public function ParseVorbisPageHeader(&$filedata, &$filedataoffset, &$oggpageinfo) {
$info = &$this->getid3->info;
$info['audio']['dataformat'] = 'vorbis';
$info['audio']['lossless'] = false;
@@ -353,19 +348,19 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
return true;
}
- function ParseOggPageHeader() {
+ public 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
+ $oggheader['page_start_offset'] = $this->ftell(); // where we started from in the file
- $filedata = fread($this->getid3->fp, $this->getid3->fread_buffer_size());
+ $filedata = $this->fread($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()) {
+ if (($this->ftell() - $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)) {
+ if ($this->feof() || (($filedata .= $this->fread($this->getid3->fread_buffer_size())) === false)) {
// get some more data, unless eof, in which case fail
return false;
}
@@ -399,45 +394,40 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
}
$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);
+ $this->fseek($oggheader['header_end_offset']);
return $oggheader;
}
-
- function ParseVorbisCommentsFilepointer() {
+ // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810005
+ public function ParseVorbisComments() {
$info = &$this->getid3->info;
- $OriginalOffset = ftell($this->getid3->fp);
+ $OriginalOffset = $this->ftell();
$commentdataoffset = 0;
$VorbisCommentPage = 1;
switch ($info['audio']['dataformat']) {
case 'vorbis':
+ case 'speex':
$CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block
- fseek($this->getid3->fp, $CommentStartOffset, SEEK_SET);
+ $this->fseek($CommentStartOffset);
$commentdataoffset = 27 + $info['ogg']['pageheader'][$VorbisCommentPage]['page_segments'];
- $commentdata = fread($this->getid3->fp, getid3_ogg::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset);
+ $commentdata = $this->fread(self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset);
- $commentdataoffset += (strlen('vorbis') + 1);
+ if ($info['audio']['dataformat'] == 'vorbis') {
+ $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);
+ $this->fseek($CommentStartOffset);
+ $commentdata = $this->fread($info['flac']['VORBIS_COMMENT']['raw']['block_length']);
break;
default:
return false;
- break;
}
$VendorSize = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
@@ -456,7 +446,7 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
$ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] = $CommentStartOffset + $commentdataoffset;
- if (ftell($this->getid3->fp) < ($ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + 4)) {
+ if ($this->ftell() < ($ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + 4)) {
if ($oggpageinfo = $this->ParseOggPageHeader()) {
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
@@ -475,8 +465,8 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
// 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));
+ //$commentdata .= $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
+ $commentdata .= $this->fread($this->OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1));
}
}
@@ -510,17 +500,17 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
// 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 .= $this->fread($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);
+ $info['warning'][] = 'undefined Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.$this->ftell();
break;
}
- $readlength = getid3_ogg::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1);
+ $readlength = self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1);
if ($readlength <= 0) {
- $info['warning'][] = 'invalid length Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.ftell($this->getid3->fp);
+ $info['warning'][] = 'invalid length Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.$this->ftell();
break;
}
- $commentdata .= fread($this->getid3->fp, $readlength);
+ $commentdata .= $this->fread($readlength);
//$filebaseoffset += $oggpageinfo['header_end_offset'] - $oggpageinfo['page_start_offset'];
}
@@ -536,75 +526,53 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
} 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']);
- }
+ $ThisFileInfo_ogg_comments_raw[$i]['key'] = strtoupper($commentexploded[0]);
+ $ThisFileInfo_ogg_comments_raw[$i]['value'] = (isset($commentexploded[1]) ? $commentexploded[1] : '');
+
+ if ($ThisFileInfo_ogg_comments_raw[$i]['key'] == 'METADATA_BLOCK_PICTURE') {
+
+ // http://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
+ // The unencoded format is that of the FLAC picture block. The fields are stored in big endian order as in FLAC, picture data is stored according to the relevant standard.
+ // http://flac.sourceforge.net/format.html#metadata_block_picture
+ $flac = new getid3_flac($this->getid3);
+ $flac->setStringMode(base64_decode($ThisFileInfo_ogg_comments_raw[$i]['value']));
+ $flac->parsePICTURE();
+ $info['ogg']['comments']['picture'][] = $flac->getid3->info['flac']['PICTURE'][0];
+ unset($flac);
+
+ } elseif ($ThisFileInfo_ogg_comments_raw[$i]['key'] == 'COVERART') {
+
+ $data = base64_decode($ThisFileInfo_ogg_comments_raw[$i]['value']);
+ $this->notice('Found deprecated COVERART tag, it should be replaced in honor of METADATA_BLOCK_PICTURE structure');
+ /** @todo use 'coverartmime' where available */
+ $imageinfo = getid3_lib::GetDataImageSize($data);
+ if ($imageinfo === false || !isset($imageinfo['mime'])) {
+ $this->warning('COVERART vorbiscomment tag contains invalid image');
+ continue;
}
- }
- 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'];
+ $ogg = new self($this->getid3);
+ $ogg->setStringMode($data);
+ $info['ogg']['comments']['picture'][] = array(
+ 'image_mime' => $imageinfo['mime'],
+ 'data' => $ogg->saveAttachment('coverart', 0, strlen($data), $imageinfo['mime']),
+ );
+ unset($ogg);
+
} 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);
- }
+ $info['ogg']['comments'][strtolower($ThisFileInfo_ogg_comments_raw[$i]['key'])][] = $ThisFileInfo_ogg_comments_raw[$i]['value'];
+ }
} else {
$info['warning'][] = '[known problem with CDex >= v1.40, < v1.50b7] Invalid Ogg comment name/value pair ['.$i.']: '.$commentstring;
}
+ unset($ThisFileInfo_ogg_comments_raw[$i]);
}
+ unset($ThisFileInfo_ogg_comments_raw);
// Replay Gain Adjustment
@@ -647,12 +615,12 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
}
}
- fseek($this->getid3->fp, $OriginalOffset, SEEK_SET);
+ $this->fseek($OriginalOffset);
return true;
}
- static function SpeexBandModeLookup($mode) {
+ public static function SpeexBandModeLookup($mode) {
static $SpeexBandModeLookup = array();
if (empty($SpeexBandModeLookup)) {
$SpeexBandModeLookup[0] = 'narrow';
@@ -663,7 +631,7 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
}
- static function OggPageSegmentLength($OggInfoArray, $SegmentNumber=1) {
+ public static function OggPageSegmentLength($OggInfoArray, $SegmentNumber=1) {
for ($i = 0; $i < $SegmentNumber; $i++) {
$segmentlength = 0;
foreach ($OggInfoArray['segment_table'] as $key => $value) {
@@ -677,7 +645,7 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
}
- static function get_quality_from_nominal_bitrate($nominal_bitrate) {
+ public static function get_quality_from_nominal_bitrate($nominal_bitrate) {
// decrease precision
$nominal_bitrate = $nominal_bitrate / 1000;
@@ -701,5 +669,3 @@ $info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.optimfrog.php b/modules/getid3/module.audio.optimfrog.php
index c1c89638..5df74b7b 100644
--- a/modules/getid3/module.audio.optimfrog.php
+++ b/modules/getid3/module.audio.optimfrog.php
@@ -18,7 +18,7 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php',
class getid3_optimfrog extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'ofr';
@@ -44,7 +44,7 @@ class getid3_optimfrog extends getid3_handler
}
- function ParseOptimFROGheader42() {
+ public function ParseOptimFROGheader42() {
// for fileformat of v4.21 and older
$info = &$this->getid3->info;
@@ -91,7 +91,7 @@ class getid3_optimfrog extends getid3_handler
}
- function ParseOptimFROGheader45() {
+ public function ParseOptimFROGheader45() {
// for fileformat of v4.50a and higher
$info = &$this->getid3->info;
@@ -313,7 +313,7 @@ class getid3_optimfrog extends getid3_handler
}
- static function OptimFROGsampleTypeLookup($SampleType) {
+ public static function OptimFROGsampleTypeLookup($SampleType) {
static $OptimFROGsampleTypeLookup = array(
0 => 'unsigned int (8-bit)',
1 => 'signed int (8-bit)',
@@ -330,7 +330,7 @@ class getid3_optimfrog extends getid3_handler
return (isset($OptimFROGsampleTypeLookup[$SampleType]) ? $OptimFROGsampleTypeLookup[$SampleType] : false);
}
- static function OptimFROGbitsPerSampleTypeLookup($SampleType) {
+ public static function OptimFROGbitsPerSampleTypeLookup($SampleType) {
static $OptimFROGbitsPerSampleTypeLookup = array(
0 => 8,
1 => 8,
@@ -347,7 +347,7 @@ class getid3_optimfrog extends getid3_handler
return (isset($OptimFROGbitsPerSampleTypeLookup[$SampleType]) ? $OptimFROGbitsPerSampleTypeLookup[$SampleType] : false);
}
- static function OptimFROGchannelConfigurationLookup($ChannelConfiguration) {
+ public static function OptimFROGchannelConfigurationLookup($ChannelConfiguration) {
static $OptimFROGchannelConfigurationLookup = array(
0 => 'mono',
1 => 'stereo'
@@ -355,7 +355,7 @@ class getid3_optimfrog extends getid3_handler
return (isset($OptimFROGchannelConfigurationLookup[$ChannelConfiguration]) ? $OptimFROGchannelConfigurationLookup[$ChannelConfiguration] : false);
}
- static function OptimFROGchannelConfigNumChannelsLookup($ChannelConfiguration) {
+ public static function OptimFROGchannelConfigNumChannelsLookup($ChannelConfiguration) {
static $OptimFROGchannelConfigNumChannelsLookup = array(
0 => 1,
1 => 2
@@ -371,7 +371,7 @@ class getid3_optimfrog extends getid3_handler
// }
- static function OptimFROGencoderNameLookup($EncoderID) {
+ public static function OptimFROGencoderNameLookup($EncoderID) {
// version = (encoderID >> 4) + 4500
// system = encoderID & 0xF
@@ -386,7 +386,7 @@ class getid3_optimfrog extends getid3_handler
return $EncoderVersion.' ('.(isset($OptimFROGencoderSystemLookup[$EncoderSystemID]) ? $OptimFROGencoderSystemLookup[$EncoderSystemID] : 'undefined encoder type (0x'.dechex($EncoderSystemID).')').')';
}
- static function OptimFROGcompressionLookup($CompressionID) {
+ public static function OptimFROGcompressionLookup($CompressionID) {
// mode = compression >> 3
// speedup = compression & 0x07
@@ -408,7 +408,7 @@ class getid3_optimfrog extends getid3_handler
return (isset($OptimFROGencoderModeLookup[$CompressionModeID]) ? $OptimFROGencoderModeLookup[$CompressionModeID] : 'undefined mode (0x'.str_pad(dechex($CompressionModeID), 2, '0', STR_PAD_LEFT).')');
}
- static function OptimFROGspeedupLookup($CompressionID) {
+ public static function OptimFROGspeedupLookup($CompressionID) {
// mode = compression >> 3
// speedup = compression & 0x07
@@ -424,6 +424,3 @@ class getid3_optimfrog extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.rkau.php b/modules/getid3/module.audio.rkau.php
index c4420762..0ea051bc 100644
--- a/modules/getid3/module.audio.rkau.php
+++ b/modules/getid3/module.audio.rkau.php
@@ -17,7 +17,7 @@
class getid3_rkau extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -76,7 +76,7 @@ class getid3_rkau extends getid3_handler
}
- function RKAUqualityLookup(&$RKAUdata) {
+ public function RKAUqualityLookup(&$RKAUdata) {
$level = ($RKAUdata['raw']['quality'] & 0xF0) >> 4;
$quality = $RKAUdata['raw']['quality'] & 0x0F;
@@ -90,5 +90,3 @@ class getid3_rkau extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.shorten.php b/modules/getid3/module.audio.shorten.php
index 7b3d312e..a047f16f 100644
--- a/modules/getid3/module.audio.shorten.php
+++ b/modules/getid3/module.audio.shorten.php
@@ -17,7 +17,7 @@
class getid3_shorten extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -150,7 +150,7 @@ class getid3_shorten extends getid3_handler
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
$fmt_size = getid3_lib::LittleEndian2Int(substr($output, 16, 4));
- $DecodedWAVFORMATEX = getid3_riff::RIFFparseWAVEFORMATex(substr($output, 20, $fmt_size));
+ $DecodedWAVFORMATEX = getid3_riff::parseWAVEFORMATex(substr($output, 20, $fmt_size));
$info['audio']['channels'] = $DecodedWAVFORMATEX['channels'];
$info['audio']['bits_per_sample'] = $DecodedWAVFORMATEX['bits_per_sample'];
$info['audio']['sample_rate'] = $DecodedWAVFORMATEX['sample_rate'];
@@ -179,5 +179,3 @@ class getid3_shorten extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.tta.php b/modules/getid3/module.audio.tta.php
index 1c646ee6..a3056db6 100644
--- a/modules/getid3/module.audio.tta.php
+++ b/modules/getid3/module.audio.tta.php
@@ -17,7 +17,7 @@
class getid3_tta extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'tta';
@@ -77,7 +77,7 @@ class getid3_tta extends getid3_handler
$info['tta']['major_version'] = 3;
$info['avdataoffset'] += 26;
- $info['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2)); // getid3_riff::RIFFwFormatTagLookup()
+ $info['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2)); // getid3_riff::wFormatTagLookup()
$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));
@@ -104,6 +104,3 @@ class getid3_tta extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.voc.php b/modules/getid3/module.audio.voc.php
index 1186a4cc..e38fa482 100644
--- a/modules/getid3/module.audio.voc.php
+++ b/modules/getid3/module.audio.voc.php
@@ -17,7 +17,7 @@
class getid3_voc extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$OriginalAVdataOffset = $info['avdataoffset'];
@@ -163,7 +163,7 @@ class getid3_voc extends getid3_handler
return true;
}
- function VOCcompressionTypeLookup($index) {
+ public function VOCcompressionTypeLookup($index) {
static $VOCcompressionTypeLookup = array(
0 => '8-bit',
1 => '4-bit',
@@ -173,7 +173,7 @@ class getid3_voc extends getid3_handler
return (isset($VOCcompressionTypeLookup[$index]) ? $VOCcompressionTypeLookup[$index] : 'Multi DAC ('.($index - 3).') channels');
}
- function VOCwFormatLookup($index) {
+ public function VOCwFormatLookup($index) {
static $VOCwFormatLookup = array(
0x0000 => '8-bit unsigned PCM',
0x0001 => 'Creative 8-bit to 4-bit ADPCM',
@@ -187,21 +187,18 @@ class getid3_voc extends getid3_handler
return (isset($VOCwFormatLookup[$index]) ? $VOCwFormatLookup[$index] : false);
}
- function VOCwFormatActualBitsPerSampleLookup($index) {
+ public function VOCwFormatActualBitsPerSampleLookup($index) {
static $VOCwFormatLookup = array(
- 0x0000 => 8,
- 0x0001 => 4,
- 0x0002 => 3,
- 0x0003 => 2,
+ 0x0000 => 8,
+ 0x0001 => 4,
+ 0x0002 => 3,
+ 0x0003 => 2,
0x0004 => 16,
- 0x0006 => 8,
- 0x0007 => 8,
- 0x2000 => 4
+ 0x0006 => 8,
+ 0x0007 => 8,
+ 0x2000 => 4
);
return (isset($VOCwFormatLookup[$index]) ? $VOCwFormatLookup[$index] : false);
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.vqf.php b/modules/getid3/module.audio.vqf.php
index dc6ff5ec..b963c6ec 100644
--- a/modules/getid3/module.audio.vqf.php
+++ b/modules/getid3/module.audio.vqf.php
@@ -16,7 +16,7 @@
class getid3_vqf extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// based loosely on code from TTwinVQ by Jurgen Faul <jfaulØgmx*de>
@@ -135,7 +135,7 @@ class getid3_vqf extends getid3_handler
return true;
}
- function VQFchannelFrequencyLookup($frequencyid) {
+ public function VQFchannelFrequencyLookup($frequencyid) {
static $VQFchannelFrequencyLookup = array(
11 => 11025,
22 => 22050,
@@ -144,7 +144,7 @@ class getid3_vqf extends getid3_handler
return (isset($VQFchannelFrequencyLookup[$frequencyid]) ? $VQFchannelFrequencyLookup[$frequencyid] : $frequencyid * 1000);
}
- function VQFcommentNiceNameLookup($shortname) {
+ public function VQFcommentNiceNameLookup($shortname) {
static $VQFcommentNiceNameLookup = array(
'NAME' => 'title',
'AUTH' => 'artist',
@@ -157,6 +157,3 @@ class getid3_vqf extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.wavpack.php b/modules/getid3/module.audio.wavpack.php
index 6ab5b438..8daf6034 100644
--- a/modules/getid3/module.audio.wavpack.php
+++ b/modules/getid3/module.audio.wavpack.php
@@ -17,7 +17,7 @@
class getid3_wavpack extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -247,7 +247,7 @@ class getid3_wavpack extends getid3_handler
$metablock['riff'] = $getid3_riff->ParseRIFF($startoffset, $startoffset + $metablock['size']);
if (!empty($metablock['riff']['INFO'])) {
- $getid3_riff->RIFFcommentsParse($metablock['riff']['INFO'], $metablock['comments']);
+ getid3_riff::parseComments($metablock['riff']['INFO'], $metablock['comments']);
$info['tags']['riff'] = $metablock['comments'];
}
unset($getid3_temp, $getid3_riff);
@@ -368,7 +368,7 @@ class getid3_wavpack extends getid3_handler
}
- function WavPackMetablockNameLookup(&$id) {
+ public function WavPackMetablockNameLookup(&$id) {
static $WavPackMetablockNameLookup = array(
0x00 => 'Dummy',
0x01 => 'Encoder Info',
@@ -395,6 +395,3 @@ class getid3_wavpack extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.graphic.bmp.php b/modules/getid3/module.graphic.bmp.php
index 5ac671fb..5dabd9b0 100644
--- a/modules/getid3/module.graphic.bmp.php
+++ b/modules/getid3/module.graphic.bmp.php
@@ -16,10 +16,10 @@
class getid3_bmp extends getid3_handler
{
- var $ExtractPalette = false;
- var $ExtractData = false;
+ public $ExtractPalette = false;
+ public $ExtractData = false;
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// shortcuts
@@ -625,7 +625,7 @@ class getid3_bmp extends getid3_handler
}
- function PlotBMP(&$BMPinfo) {
+ public function PlotBMP(&$BMPinfo) {
$starttime = time();
if (!isset($BMPinfo['bmp']['data']) || !is_array($BMPinfo['bmp']['data'])) {
echo 'ERROR: no pixel data<BR>';
@@ -661,7 +661,7 @@ class getid3_bmp extends getid3_handler
return false;
}
- function BMPcompressionWindowsLookup($compressionid) {
+ public function BMPcompressionWindowsLookup($compressionid) {
static $BMPcompressionWindowsLookup = array(
0 => 'BI_RGB',
1 => 'BI_RLE8',
@@ -673,7 +673,7 @@ class getid3_bmp extends getid3_handler
return (isset($BMPcompressionWindowsLookup[$compressionid]) ? $BMPcompressionWindowsLookup[$compressionid] : 'invalid');
}
- function BMPcompressionOS2Lookup($compressionid) {
+ public function BMPcompressionOS2Lookup($compressionid) {
static $BMPcompressionOS2Lookup = array(
0 => 'BI_RGB',
1 => 'BI_RLE8',
@@ -685,6 +685,3 @@ class getid3_bmp extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.graphic.efax.php b/modules/getid3/module.graphic.efax.php
index 2a57302e..dfedf6e6 100644
--- a/modules/getid3/module.graphic.efax.php
+++ b/modules/getid3/module.graphic.efax.php
@@ -17,7 +17,7 @@
class getid3_efax extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -48,6 +48,3 @@ return false;
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.graphic.gif.php b/modules/getid3/module.graphic.gif.php
index 0b3e1379..cd8457e3 100644
--- a/modules/getid3/module.graphic.gif.php
+++ b/modules/getid3/module.graphic.gif.php
@@ -17,7 +17,7 @@
class getid3_gif extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'gif';
@@ -167,7 +167,7 @@ class getid3_gif extends getid3_handler
}
- function GetLSBits($bits) {
+ public 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;
@@ -179,6 +179,3 @@ class getid3_gif extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.graphic.jpg.php b/modules/getid3/module.graphic.jpg.php
index 153ebcd0..5663a2f5 100644
--- a/modules/getid3/module.graphic.jpg.php
+++ b/modules/getid3/module.graphic.jpg.php
@@ -19,7 +19,7 @@ class getid3_jpg extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'jpg';
@@ -64,7 +64,9 @@ class getid3_jpg extends getid3_handler
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);
+//$info['warning'][] = 'known issue: https://bugs.php.net/bug.php?id=62523';
+//return false;
+ $info['jpg']['exif'] = exif_read_data($info['filenamepath'], null, true, false);
} else {
$info['warning'][] = 'exif_read_data() cannot parse non-EXIF data in APP1 (expected "Exif", found "'.substr($imageinfo['APP1'], 0, 4).'")';
}
@@ -135,9 +137,11 @@ class getid3_jpg extends getid3_handler
}
$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']['GPSAltitudeRef'])) {
+ $info['jpg']['exif']['GPS']['GPSAltitudeRef'] = ord($info['jpg']['exif']['GPS']['GPSAltitudeRef']); // 0 = above sea level; 1 = below sea level
+ }
if (isset($info['jpg']['exif']['GPS']['GPSAltitude'])) {
- $direction_multiplier = ((isset($info['jpg']['exif']['GPS']['GPSAltitudeRef']) && ($info['jpg']['exif']['GPS']['GPSAltitudeRef'] === chr(1))) ? -1 : 1);
+ $direction_multiplier = (!empty($info['jpg']['exif']['GPS']['GPSAltitudeRef']) ? -1 : 1); // 0 = above sea level; 1 = below sea level
$info['jpg']['exif']['GPS']['computed']['altitude'] = $direction_multiplier * getid3_lib::DecimalizeFraction($info['jpg']['exif']['GPS']['GPSAltitude']);
}
@@ -149,8 +153,12 @@ class getid3_jpg extends getid3_handler
$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 (strpos($key, ':')) {
+ list($subsection, $tagname) = explode(':', $key);
+ $info['xmp'][$subsection][$tagname] = $this->CastAsAppropriate($value);
+ } else {
+ $info['warning'][] = 'XMP: expecting "<subsection>:<tagname>", found "'.$key.'"';
+ }
}
}
}
@@ -163,7 +171,7 @@ class getid3_jpg extends getid3_handler
}
- function CastAsAppropriate($value) {
+ public function CastAsAppropriate($value) {
if (is_array($value)) {
return $value;
} elseif (preg_match('#^[0-9]+/[0-9]+$#', $value)) {
@@ -177,7 +185,7 @@ class getid3_jpg extends getid3_handler
}
- function IPTCrecordName($iptc_record) {
+ public function IPTCrecordName($iptc_record) {
// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/IPTC.html
static $IPTCrecordName = array();
if (empty($IPTCrecordName)) {
@@ -194,7 +202,7 @@ class getid3_jpg extends getid3_handler
}
- function IPTCrecordTagName($iptc_record, $iptc_tagkey) {
+ public function IPTCrecordTagName($iptc_record, $iptc_tagkey) {
// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/IPTC.html
static $IPTCrecordTagName = array();
if (empty($IPTCrecordTagName)) {
@@ -333,6 +341,3 @@ class getid3_jpg extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.graphic.pcd.php b/modules/getid3/module.graphic.pcd.php
index dcbc6763..2ea2a45b 100644
--- a/modules/getid3/module.graphic.pcd.php
+++ b/modules/getid3/module.graphic.pcd.php
@@ -16,9 +16,9 @@
class getid3_pcd extends getid3_handler
{
- var $ExtractData = 0;
+ public $ExtractData = 0;
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'pcd';
@@ -98,7 +98,7 @@ class getid3_pcd extends getid3_handler
}
- function YCbCr2RGB($Y, $Cb, $Cr) {
+ public function YCbCr2RGB($Y, $Cb, $Cr) {
static $YCbCr_constants = array();
if (empty($YCbCr_constants)) {
$YCbCr_constants['red']['Y'] = 0.0054980 * 256;
@@ -130,5 +130,3 @@ class getid3_pcd extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.graphic.png.php b/modules/getid3/module.graphic.png.php
index 9109c436..250ca1b1 100644
--- a/modules/getid3/module.graphic.png.php
+++ b/modules/getid3/module.graphic.png.php
@@ -17,7 +17,7 @@
class getid3_png extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// shortcut
@@ -438,7 +438,7 @@ class getid3_png extends getid3_handler
return true;
}
- function PNGsRGBintentLookup($sRGB) {
+ public function PNGsRGBintentLookup($sRGB) {
static $PNGsRGBintentLookup = array(
0 => 'Perceptual',
1 => 'Relative colorimetric',
@@ -448,14 +448,14 @@ class getid3_png extends getid3_handler
return (isset($PNGsRGBintentLookup[$sRGB]) ? $PNGsRGBintentLookup[$sRGB] : 'invalid');
}
- function PNGcompressionMethodLookup($compressionmethod) {
+ public function PNGcompressionMethodLookup($compressionmethod) {
static $PNGcompressionMethodLookup = array(
0 => 'deflate/inflate'
);
return (isset($PNGcompressionMethodLookup[$compressionmethod]) ? $PNGcompressionMethodLookup[$compressionmethod] : 'invalid');
}
- function PNGpHYsUnitLookup($unitid) {
+ public function PNGpHYsUnitLookup($unitid) {
static $PNGpHYsUnitLookup = array(
0 => 'unknown',
1 => 'meter'
@@ -463,7 +463,7 @@ class getid3_png extends getid3_handler
return (isset($PNGpHYsUnitLookup[$unitid]) ? $PNGpHYsUnitLookup[$unitid] : 'invalid');
}
- function PNGoFFsUnitLookup($unitid) {
+ public function PNGoFFsUnitLookup($unitid) {
static $PNGoFFsUnitLookup = array(
0 => 'pixel',
1 => 'micrometer'
@@ -471,7 +471,7 @@ class getid3_png extends getid3_handler
return (isset($PNGoFFsUnitLookup[$unitid]) ? $PNGoFFsUnitLookup[$unitid] : 'invalid');
}
- function PNGpCALequationTypeLookup($equationtype) {
+ public function PNGpCALequationTypeLookup($equationtype) {
static $PNGpCALequationTypeLookup = array(
0 => 'Linear mapping',
1 => 'Base-e exponential mapping',
@@ -481,7 +481,7 @@ class getid3_png extends getid3_handler
return (isset($PNGpCALequationTypeLookup[$equationtype]) ? $PNGpCALequationTypeLookup[$equationtype] : 'invalid');
}
- function PNGsCALUnitLookup($unitid) {
+ public function PNGsCALUnitLookup($unitid) {
static $PNGsCALUnitLookup = array(
0 => 'meter',
1 => 'radian'
@@ -489,7 +489,7 @@ class getid3_png extends getid3_handler
return (isset($PNGsCALUnitLookup[$unitid]) ? $PNGsCALUnitLookup[$unitid] : 'invalid');
}
- function IHDRcalculateBitsPerSample($color_type, $bit_depth) {
+ public function IHDRcalculateBitsPerSample($color_type, $bit_depth) {
switch ($color_type) {
case 0: // Each pixel is a grayscale sample.
return $bit_depth;
@@ -515,6 +515,3 @@ class getid3_png extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.graphic.svg.php b/modules/getid3/module.graphic.svg.php
index d9d52d74..8b31167e 100644
--- a/modules/getid3/module.graphic.svg.php
+++ b/modules/getid3/module.graphic.svg.php
@@ -18,7 +18,7 @@ class getid3_svg extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -99,6 +99,3 @@ class getid3_svg extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.graphic.tiff.php b/modules/getid3/module.graphic.tiff.php
index e9771242..25996f0e 100644
--- a/modules/getid3/module.graphic.tiff.php
+++ b/modules/getid3/module.graphic.tiff.php
@@ -17,7 +17,7 @@
class getid3_tiff extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -182,7 +182,7 @@ class getid3_tiff extends getid3_handler
}
- function TIFFendian2Int($bytestring, $byteorder) {
+ public function TIFFendian2Int($bytestring, $byteorder) {
if ($byteorder == 'Intel') {
return getid3_lib::LittleEndian2Int($bytestring);
} elseif ($byteorder == 'Motorola') {
@@ -191,7 +191,7 @@ class getid3_tiff extends getid3_handler
return false;
}
- function TIFFcompressionMethod($id) {
+ public function TIFFcompressionMethod($id) {
static $TIFFcompressionMethod = array();
if (empty($TIFFcompressionMethod)) {
$TIFFcompressionMethod = array(
@@ -205,7 +205,7 @@ class getid3_tiff extends getid3_handler
return (isset($TIFFcompressionMethod[$id]) ? $TIFFcompressionMethod[$id] : 'unknown/invalid ('.$id.')');
}
- function TIFFcommentName($id) {
+ public function TIFFcommentName($id) {
static $TIFFcommentName = array();
if (empty($TIFFcommentName)) {
$TIFFcommentName = array(
@@ -222,6 +222,3 @@ class getid3_tiff extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.misc.cue.php b/modules/getid3/module.misc.cue.php
index c99ce247..1d3a0cea 100644
--- a/modules/getid3/module.misc.cue.php
+++ b/modules/getid3/module.misc.cue.php
@@ -32,9 +32,9 @@
*/
class getid3_cue extends getid3_handler
{
- var $cuesheet = array();
+ public $cuesheet = array();
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'cue';
@@ -45,7 +45,7 @@ class getid3_cue extends getid3_handler
- function readCueSheetFilename($filename)
+ public function readCueSheetFilename($filename)
{
$filedata = file_get_contents($filename);
return $this->readCueSheet($filedata);
@@ -55,7 +55,7 @@ class getid3_cue extends getid3_handler
*
* @param string $filename - The filename for the cue sheet to open.
*/
- function readCueSheet(&$filedata)
+ public function readCueSheet(&$filedata)
{
$cue_lines = array();
foreach (explode("\n", str_replace("\r", null, $filedata)) as $line)
@@ -75,7 +75,7 @@ class getid3_cue extends getid3_handler
*
* @param array $file - The cuesheet as an array of each line.
*/
- function parseCueSheet($file)
+ public function parseCueSheet($file)
{
//-1 means still global, all others are track specific
$track_on = -1;
@@ -129,7 +129,7 @@ class getid3_cue extends getid3_handler
* @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)
+ public function parseComment($line, $track_on)
{
$explodedline = explode(' ', $line, 3);
$comment_REM = (isset($explodedline[0]) ? $explodedline[0] : '');
@@ -152,7 +152,7 @@ class getid3_cue extends getid3_handler
* @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)
+ public function parseFile($line)
{
$line = substr($line, strpos($line, ' ') + 1);
$type = strtolower(substr($line, strrpos($line, ' ')));
@@ -172,7 +172,7 @@ class getid3_cue extends getid3_handler
* @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)
+ public function parseFlags($line, $track_on)
{
if ($track_on != -1)
{
@@ -210,7 +210,7 @@ class getid3_cue extends getid3_handler
* @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)
+ public function parseGarbage($line, $track_on)
{
if ( strlen($line) > 0 )
{
@@ -231,7 +231,7 @@ class getid3_cue extends getid3_handler
* @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)
+ public function parseIndex($line, $track_on)
{
$type = strtolower(substr($line, 0, strpos($line, ' ')));
$line = substr($line, strpos($line, ' ') + 1);
@@ -260,7 +260,7 @@ class getid3_cue extends getid3_handler
}
}
- function parseString($line, $track_on)
+ public function parseString($line, $track_on)
{
$category = strtolower(substr($line, 0, strpos($line, ' ')));
$line = substr($line, strpos($line, ' ') + 1);
@@ -296,7 +296,7 @@ class getid3_cue extends getid3_handler
* @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)
+ public function parseTrack($line, $track_on)
{
$line = substr($line, strpos($line, ' ') + 1);
$track = ltrim(substr($line, 0, strpos($line, ' ')), '0');
@@ -309,4 +309,3 @@ class getid3_cue extends getid3_handler
}
-?>
diff --git a/modules/getid3/module.misc.doc.php b/modules/getid3/module.misc.doc.php
deleted file mode 100644
index cb65abf2..00000000
--- a/modules/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/modules/getid3/module.misc.exe.php b/modules/getid3/module.misc.exe.php
index 108e62ec..15e786b4 100644
--- a/modules/getid3/module.misc.exe.php
+++ b/modules/getid3/module.misc.exe.php
@@ -17,7 +17,7 @@
class getid3_exe extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -56,6 +56,3 @@ return false;
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.misc.iso.php b/modules/getid3/module.misc.iso.php
index 727fdf87..39bd16af 100644
--- a/modules/getid3/module.misc.iso.php
+++ b/modules/getid3/module.misc.iso.php
@@ -17,7 +17,7 @@
class getid3_iso extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'iso';
@@ -55,7 +55,7 @@ class getid3_iso extends getid3_handler
}
- function ParsePrimaryVolumeDescriptor(&$ISOheader) {
+ public 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
@@ -129,7 +129,7 @@ class getid3_iso extends getid3_handler
}
- function ParseSupplementaryVolumeDescriptor(&$ISOheader) {
+ public 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
@@ -208,7 +208,7 @@ class getid3_iso extends getid3_handler
}
- function ParsePathTable() {
+ public 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;
@@ -267,7 +267,7 @@ class getid3_iso extends getid3_handler
}
- function ParseDirectoryRecord($directorydata) {
+ public function ParseDirectoryRecord($directorydata) {
$info = &$this->getid3->info;
if (isset($info['iso']['supplementary_volume_descriptor'])) {
$TextEncoding = 'UTF-16BE'; // Big-Endian Unicode
@@ -320,7 +320,7 @@ class getid3_iso extends getid3_handler
return $DirectoryRecord;
}
- function ISOstripFilenameVersion($ISOfilename) {
+ public function ISOstripFilenameVersion($ISOfilename) {
// convert 'filename.ext;1' to 'filename.ext'
if (!strstr($ISOfilename, ';')) {
return $ISOfilename;
@@ -329,7 +329,7 @@ class getid3_iso extends getid3_handler
}
}
- function ISOtimeText2UNIXtime($ISOtime) {
+ public function ISOtimeText2UNIXtime($ISOtime) {
$UNIXyear = (int) substr($ISOtime, 0, 4);
$UNIXmonth = (int) substr($ISOtime, 4, 2);
@@ -344,7 +344,7 @@ class getid3_iso extends getid3_handler
return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
}
- function ISOtime2UNIXtime($ISOtime) {
+ public function ISOtime2UNIXtime($ISOtime) {
// Represented by seven bytes:
// 1: Number of years since 1900
// 2: Month of the year from 1 to 12
@@ -365,7 +365,7 @@ class getid3_iso extends getid3_handler
return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
}
- function TwosCompliment2Decimal($BinaryValue) {
+ public function TwosCompliment2Decimal($BinaryValue) {
// http://sandbox.mc.edu/~bennet/cs110/tc/tctod.html
// First check if the number is negative or positive by looking at the sign bit.
// If it is positive, simply convert it to decimal.
@@ -385,5 +385,3 @@ class getid3_iso extends getid3_handler
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.misc.msoffice.php b/modules/getid3/module.misc.msoffice.php
index 8fea1085..a5077e12 100644
--- a/modules/getid3/module.misc.msoffice.php
+++ b/modules/getid3/module.misc.msoffice.php
@@ -17,7 +17,7 @@
class getid3_msoffice extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -35,6 +35,3 @@ return false;
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.misc.par2.php b/modules/getid3/module.misc.par2.php
index d8b0a388..80b47d29 100644
--- a/modules/getid3/module.misc.par2.php
+++ b/modules/getid3/module.misc.par2.php
@@ -17,7 +17,7 @@
class getid3_par2 extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'par2';
@@ -28,6 +28,3 @@ class getid3_par2 extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.misc.pdf.php b/modules/getid3/module.misc.pdf.php
index 38ed646a..3b8aaa14 100644
--- a/modules/getid3/module.misc.pdf.php
+++ b/modules/getid3/module.misc.pdf.php
@@ -17,7 +17,7 @@
class getid3_pdf extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'pdf';
@@ -28,6 +28,3 @@ class getid3_pdf extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.tag.apetag.php b/modules/getid3/module.tag.apetag.php
index 6522475f..afeede76 100644
--- a/modules/getid3/module.tag.apetag.php
+++ b/modules/getid3/module.tag.apetag.php
@@ -15,10 +15,10 @@
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;
+ public $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
+ public $overrideendoffset = 0;
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
if (!getid3_lib::intValueSupported($info['filesize'])) {
@@ -289,7 +289,7 @@ class getid3_apetag extends getid3_handler
return true;
}
- function parseAPEheaderFooter($APEheaderFooterData) {
+ public function parseAPEheaderFooter($APEheaderFooterData) {
// http://www.uni-jena.de/~pfk/mpp/sv8/apeheader.html
// shortcut
@@ -313,7 +313,7 @@ class getid3_apetag extends getid3_handler
return $headerfooterinfo;
}
- function parseAPEtagFlags($rawflagint) {
+ public function parseAPEtagFlags($rawflagint) {
// "Note: APE Tags 1.0 do not use any of the APE Tag flags.
// All are set to zero on creation and ignored on reading."
// http://www.uni-jena.de/~pfk/mpp/sv8/apetagflags.html
@@ -328,7 +328,7 @@ class getid3_apetag extends getid3_handler
return $flags;
}
- function APEcontentTypeFlagLookup($contenttypeid) {
+ public function APEcontentTypeFlagLookup($contenttypeid) {
static $APEcontentTypeFlagLookup = array(
0 => 'utf-8',
1 => 'binary',
@@ -338,7 +338,7 @@ class getid3_apetag extends getid3_handler
return (isset($APEcontentTypeFlagLookup[$contenttypeid]) ? $APEcontentTypeFlagLookup[$contenttypeid] : 'invalid');
}
- function APEtagItemIsUTF8Lookup($itemkey) {
+ public function APEtagItemIsUTF8Lookup($itemkey) {
static $APEtagItemIsUTF8Lookup = array(
'title',
'subtitle',
@@ -368,5 +368,3 @@ class getid3_apetag extends getid3_handler
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.tag.id3v1.php b/modules/getid3/module.tag.id3v1.php
index a9932d13..fd9069e0 100644
--- a/modules/getid3/module.tag.id3v1.php
+++ b/modules/getid3/module.tag.id3v1.php
@@ -17,7 +17,7 @@
class getid3_id3v1 extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
if (!getid3_lib::intValueSupported($info['filesize'])) {
@@ -102,11 +102,11 @@ class getid3_id3v1 extends getid3_handler
return true;
}
- static function cutfield($str) {
+ public static function cutfield($str) {
return trim(substr($str, 0, strcspn($str, "\x00")));
}
- static function ArrayOfGenres($allowSCMPXextended=false) {
+ public static function ArrayOfGenres($allowSCMPXextended=false) {
static $GenreLookup = array(
0 => 'Blues',
1 => 'Classic Rock',
@@ -290,7 +290,7 @@ class getid3_id3v1 extends getid3_handler
return ($allowSCMPXextended ? $GenreLookupSCMPX : $GenreLookup);
}
- static function LookupGenreName($genreid, $allowSCMPXextended=true) {
+ public static function LookupGenreName($genreid, $allowSCMPXextended=true) {
switch ($genreid) {
case 'RX':
case 'CR':
@@ -302,12 +302,12 @@ class getid3_id3v1 extends getid3_handler
$genreid = intval($genreid); // to handle 3 or '3' or '03'
break;
}
- $GenreLookup = getid3_id3v1::ArrayOfGenres($allowSCMPXextended);
+ $GenreLookup = self::ArrayOfGenres($allowSCMPXextended);
return (isset($GenreLookup[$genreid]) ? $GenreLookup[$genreid] : false);
}
- static function LookupGenreID($genre, $allowSCMPXextended=false) {
- $GenreLookup = getid3_id3v1::ArrayOfGenres($allowSCMPXextended);
+ public static function LookupGenreID($genre, $allowSCMPXextended=false) {
+ $GenreLookup = self::ArrayOfGenres($allowSCMPXextended);
$LowerCaseNoSpaceSearchTerm = strtolower(str_replace(' ', '', $genre));
foreach ($GenreLookup as $key => $value) {
if (strtolower(str_replace(' ', '', $value)) == $LowerCaseNoSpaceSearchTerm) {
@@ -317,14 +317,14 @@ class getid3_id3v1 extends getid3_handler
return false;
}
- static function StandardiseID3v1GenreName($OriginalGenre) {
- if (($GenreID = getid3_id3v1::LookupGenreID($OriginalGenre)) !== false) {
- return getid3_id3v1::LookupGenreName($GenreID);
+ public static function StandardiseID3v1GenreName($OriginalGenre) {
+ if (($GenreID = self::LookupGenreID($OriginalGenre)) !== false) {
+ return self::LookupGenreName($GenreID);
}
return $OriginalGenre;
}
- static function GenerateID3v1Tag($title, $artist, $album, $year, $genreid, $comment, $track='') {
+ public 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);
@@ -357,6 +357,3 @@ class getid3_id3v1 extends getid3_handler
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.tag.id3v2.php b/modules/getid3/module.tag.id3v2.php
index 56adeb95..3704b64b 100644
--- a/modules/getid3/module.tag.id3v2.php
+++ b/modules/getid3/module.tag.id3v2.php
@@ -17,10 +17,9 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE_
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;
+ public $StartingOffset = 0;
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// Overall tag structure:
@@ -495,7 +494,7 @@ class getid3_id3v2 extends getid3_handler
}
- function ParseID3v2GenreString($genrestring) {
+ public function ParseID3v2GenreString($genrestring) {
// 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
@@ -518,7 +517,7 @@ class getid3_id3v2 extends getid3_handler
}
- function ParseID3v2Frame(&$parsedFrame) {
+ public function ParseID3v2Frame(&$parsedFrame) {
// shortcuts
$info = &$this->getid3->info;
@@ -738,6 +737,7 @@ class getid3_id3v2 extends getid3_handler
} elseif ((($id3v2_majorversion == 3) && ($parsedFrame['frame_name'] == 'IPLS')) || // 4.4 IPLS Involved people list (ID3v2.3 only)
(($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'IPL'))) { // 4.4 IPL Involved people list (ID3v2.2 only)
+ // http://id3.org/id3v2.3.0#sec4.4
// There may only be one 'IPL' frame in each tag
// <Header for 'User defined URL link frame', ID: 'IPL'>
// Text encoding $xx
@@ -750,10 +750,68 @@ class getid3_id3v2 extends getid3_handler
}
$parsedFrame['encodingid'] = $frame_textencoding;
$parsedFrame['encoding'] = $this->TextEncodingNameLookup($parsedFrame['encodingid']);
+ $parsedFrame['data_raw'] = (string) substr($parsedFrame['data'], $frame_offset);
+
+ // http://www.getid3.org/phpBB3/viewtopic.php?t=1369
+ // "this tag typically contains null terminated strings, which are associated in pairs"
+ // "there are users that use the tag incorrectly"
+ $IPLS_parts = array();
+ if (strpos($parsedFrame['data_raw'], "\x00") !== false) {
+ $IPLS_parts_unsorted = array();
+ if (((strlen($parsedFrame['data_raw']) % 2) == 0) && ((substr($parsedFrame['data_raw'], 0, 2) == "\xFF\xFE") || (substr($parsedFrame['data_raw'], 0, 2) == "\xFE\xFF"))) {
+ // UTF-16, be careful looking for null bytes since most 2-byte characters may contain one; you need to find twin null bytes, and on even padding
+ $thisILPS = '';
+ for ($i = 0; $i < strlen($parsedFrame['data_raw']); $i += 2) {
+ $twobytes = substr($parsedFrame['data_raw'], $i, 2);
+ if ($twobytes === "\x00\x00") {
+ $IPLS_parts_unsorted[] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $thisILPS);
+ $thisILPS = '';
+ } else {
+ $thisILPS .= $twobytes;
+ }
+ }
+ if (strlen($thisILPS) > 2) { // 2-byte BOM
+ $IPLS_parts_unsorted[] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $thisILPS);
+ }
+ } else {
+ // ISO-8859-1 or UTF-8 or other single-byte-null character set
+ $IPLS_parts_unsorted = explode("\x00", $parsedFrame['data_raw']);
+ }
+ if (count($IPLS_parts_unsorted) == 1) {
+ // just a list of names, e.g. "Dino Baptiste, Jimmy Copley, John Gordon, Bernie Marsden, Sharon Watson"
+ foreach ($IPLS_parts_unsorted as $key => $value) {
+ $IPLS_parts_sorted = preg_split('#[;,\\r\\n\\t]#', $value);
+ $position = '';
+ foreach ($IPLS_parts_sorted as $person) {
+ $IPLS_parts[] = array('position'=>$position, 'person'=>$person);
+ }
+ }
+ } elseif ((count($IPLS_parts_unsorted) % 2) == 0) {
+ $position = '';
+ $person = '';
+ foreach ($IPLS_parts_unsorted as $key => $value) {
+ if (($key % 2) == 0) {
+ $position = $value;
+ } else {
+ $person = $value;
+ $IPLS_parts[] = array('position'=>$position, 'person'=>$person);
+ $position = '';
+ $person = '';
+ }
+ }
+ } else {
+ foreach ($IPLS_parts_unsorted as $key => $value) {
+ $IPLS_parts[] = array($value);
+ }
+ }
+
+ } else {
+ $IPLS_parts = preg_split('#[;,\\r\\n\\t]#', $parsedFrame['data_raw']);
+ }
+ $parsedFrame['data'] = $IPLS_parts;
- $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset);
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
- $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['data'];
}
@@ -1306,32 +1364,34 @@ class getid3_id3v2 extends getid3_handler
}
do {
- if ($this->inline_attachments === false) {
+ if ($this->getid3->option_save_attachments === false) {
// skip entirely
unset($parsedFrame['data']);
break;
}
- if ($this->inline_attachments === true) {
+ if ($this->getid3->option_save_attachments === true) {
// great
- } elseif (is_int($this->inline_attachments)) {
- if ($this->inline_attachments < $parsedFrame['data_length']) {
+/*
+ } elseif (is_int($this->getid3->option_save_attachments)) {
+ if ($this->getid3->option_save_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)) {
+*/
+ } elseif (is_string($this->getid3->option_save_attachments)) {
+ $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR);
+ if (!is_dir($dir) || !is_writable($dir)) {
// cannot write, skip
- $info['warning'][] = 'attachment at '.$frame_offset.' cannot be saved to "'.$this->inline_attachments.'" (not writable)';
+ $info['warning'][] = 'attachment at '.$frame_offset.' cannot be saved to "'.$dir.'" (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 (is_string($this->getid3->option_save_attachments)) {
+ $destination_filename = $dir.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$frame_offset;
if (!file_exists($destination_filename) || is_writable($destination_filename)) {
file_put_contents($destination_filename, $parsedFrame['data']);
} else {
@@ -1851,11 +1911,11 @@ class getid3_id3v2 extends getid3_handler
}
- function DeUnsynchronise($data) {
+ public function DeUnsynchronise($data) {
return str_replace("\xFF\x00", "\xFF", $data);
}
- function LookupExtendedHeaderRestrictionsTagSizeLimits($index) {
+ public 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',
@@ -1865,7 +1925,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($LookupExtendedHeaderRestrictionsTagSizeLimits[$index]) ? $LookupExtendedHeaderRestrictionsTagSizeLimits[$index] : '');
}
- function LookupExtendedHeaderRestrictionsTextEncodings($index) {
+ public function LookupExtendedHeaderRestrictionsTextEncodings($index) {
static $LookupExtendedHeaderRestrictionsTextEncodings = array(
0x00 => 'No restrictions',
0x01 => 'Strings are only encoded with ISO-8859-1 or UTF-8',
@@ -1873,7 +1933,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($LookupExtendedHeaderRestrictionsTextEncodings[$index]) ? $LookupExtendedHeaderRestrictionsTextEncodings[$index] : '');
}
- function LookupExtendedHeaderRestrictionsTextFieldSize($index) {
+ public function LookupExtendedHeaderRestrictionsTextFieldSize($index) {
static $LookupExtendedHeaderRestrictionsTextFieldSize = array(
0x00 => 'No restrictions',
0x01 => 'No string is longer than 1024 characters',
@@ -1883,7 +1943,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($LookupExtendedHeaderRestrictionsTextFieldSize[$index]) ? $LookupExtendedHeaderRestrictionsTextFieldSize[$index] : '');
}
- function LookupExtendedHeaderRestrictionsImageEncoding($index) {
+ public function LookupExtendedHeaderRestrictionsImageEncoding($index) {
static $LookupExtendedHeaderRestrictionsImageEncoding = array(
0x00 => 'No restrictions',
0x01 => 'Images are encoded only with PNG or JPEG',
@@ -1891,7 +1951,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($LookupExtendedHeaderRestrictionsImageEncoding[$index]) ? $LookupExtendedHeaderRestrictionsImageEncoding[$index] : '');
}
- function LookupExtendedHeaderRestrictionsImageSizeSize($index) {
+ public function LookupExtendedHeaderRestrictionsImageSizeSize($index) {
static $LookupExtendedHeaderRestrictionsImageSizeSize = array(
0x00 => 'No restrictions',
0x01 => 'All images are 256x256 pixels or smaller',
@@ -1901,7 +1961,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($LookupExtendedHeaderRestrictionsImageSizeSize[$index]) ? $LookupExtendedHeaderRestrictionsImageSizeSize[$index] : '');
}
- function LookupCurrencyUnits($currencyid) {
+ public function LookupCurrencyUnits($currencyid) {
$begin = __LINE__;
@@ -2098,7 +2158,7 @@ class getid3_id3v2 extends getid3_handler
}
- function LookupCurrencyCountry($currencyid) {
+ public function LookupCurrencyCountry($currencyid) {
$begin = __LINE__;
@@ -2295,7 +2355,7 @@ class getid3_id3v2 extends getid3_handler
- static function LanguageLookup($languagecode, $casesensitive=false) {
+ public static function LanguageLookup($languagecode, $casesensitive=false) {
if (!$casesensitive) {
$languagecode = strtolower($languagecode);
@@ -2751,7 +2811,7 @@ class getid3_id3v2 extends getid3_handler
}
- static function ETCOEventLookup($index) {
+ public static function ETCOEventLookup($index) {
if (($index >= 0x17) && ($index <= 0xDF)) {
return 'reserved for future use';
}
@@ -2794,7 +2854,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($EventLookup[$index]) ? $EventLookup[$index] : '');
}
- static function SYTLContentTypeLookup($index) {
+ public static function SYTLContentTypeLookup($index) {
static $SYTLContentTypeLookup = array(
0x00 => 'other',
0x01 => 'lyrics',
@@ -2810,7 +2870,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($SYTLContentTypeLookup[$index]) ? $SYTLContentTypeLookup[$index] : '');
}
- static function APICPictureTypeLookup($index, $returnarray=false) {
+ public static function APICPictureTypeLookup($index, $returnarray=false) {
static $APICPictureTypeLookup = array(
0x00 => 'Other',
0x01 => '32x32 pixels \'file icon\' (PNG only)',
@@ -2840,7 +2900,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($APICPictureTypeLookup[$index]) ? $APICPictureTypeLookup[$index] : '');
}
- static function COMRReceivedAsLookup($index) {
+ public static function COMRReceivedAsLookup($index) {
static $COMRReceivedAsLookup = array(
0x00 => 'Other',
0x01 => 'Standard CD album with other songs',
@@ -2856,7 +2916,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($COMRReceivedAsLookup[$index]) ? $COMRReceivedAsLookup[$index] : '');
}
- static function RVA2ChannelTypeLookup($index) {
+ public static function RVA2ChannelTypeLookup($index) {
static $RVA2ChannelTypeLookup = array(
0x00 => 'Other',
0x01 => 'Master volume',
@@ -2872,7 +2932,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($RVA2ChannelTypeLookup[$index]) ? $RVA2ChannelTypeLookup[$index] : '');
}
- static function FrameNameLongLookup($framename) {
+ public static function FrameNameLongLookup($framename) {
$begin = __LINE__;
@@ -3056,7 +3116,7 @@ class getid3_id3v2 extends getid3_handler
}
- static function FrameNameShortLookup($framename) {
+ public static function FrameNameShortLookup($framename) {
$begin = __LINE__;
@@ -3197,7 +3257,7 @@ class getid3_id3v2 extends getid3_handler
TSSE encoder_settings
TSST set_subtitle
TST title_sort_order
- TT1 description
+ TT1 content_group_description
TT2 title
TT3 subtitle
TXT lyricist
@@ -3235,7 +3295,7 @@ class getid3_id3v2 extends getid3_handler
return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_short');
}
- static function TextEncodingTerminatorLookup($encoding) {
+ public 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:
static $TextEncodingTerminatorLookup = array(
@@ -3248,7 +3308,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($TextEncodingTerminatorLookup[$encoding]) ? $TextEncodingTerminatorLookup[$encoding] : '');
}
- static function TextEncodingNameLookup($encoding) {
+ public static function TextEncodingNameLookup($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:
static $TextEncodingNameLookup = array(
@@ -3261,7 +3321,7 @@ class getid3_id3v2 extends getid3_handler
return (isset($TextEncodingNameLookup[$encoding]) ? $TextEncodingNameLookup[$encoding] : 'ISO-8859-1');
}
- static function IsValidID3v2FrameName($framename, $id3v2majorversion) {
+ public static function IsValidID3v2FrameName($framename, $id3v2majorversion) {
switch ($id3v2majorversion) {
case 2:
return preg_match('#[A-Z][A-Z0-9]{2}#', $framename);
@@ -3275,7 +3335,7 @@ class getid3_id3v2 extends getid3_handler
return false;
}
- static function IsANumber($numberstring, $allowdecimal=false, $allownegative=false) {
+ public 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) {
@@ -3290,7 +3350,7 @@ class getid3_id3v2 extends getid3_handler
return true;
}
- static function IsValidDateStampString($datestamp) {
+ public static function IsValidDateStampString($datestamp) {
if (strlen($datestamp) != 8) {
return false;
}
@@ -3318,10 +3378,9 @@ class getid3_id3v2 extends getid3_handler
return true;
}
- static function ID3v2HeaderLength($majorversion) {
+ public static function ID3v2HeaderLength($majorversion) {
return (($majorversion == 2) ? 6 : 10);
}
}
-?>
diff --git a/modules/getid3/module.tag.lyrics3.php b/modules/getid3/module.tag.lyrics3.php
index aaff7178..108d7aee 100644
--- a/modules/getid3/module.tag.lyrics3.php
+++ b/modules/getid3/module.tag.lyrics3.php
@@ -17,7 +17,7 @@
class getid3_lyrics3 extends getid3_handler
{
- function Analyze() {
+ public function Analyze() {
$info = &$this->getid3->info;
// http://www.volweb.cz/str/tags.htm
@@ -122,7 +122,7 @@ class getid3_lyrics3 extends getid3_handler
return true;
}
- function getLyrics3Data($endoffset, $version, $length) {
+ public function getLyrics3Data($endoffset, $version, $length) {
// http://www.volweb.cz/str/tags.htm
$info = &$this->getid3->info;
@@ -246,14 +246,14 @@ class getid3_lyrics3 extends getid3_handler
return true;
}
- function Lyrics3Timestamp2Seconds($rawtimestamp) {
+ public function Lyrics3Timestamp2Seconds($rawtimestamp) {
if (preg_match('#^\\[([0-9]{2}):([0-9]{2})\\]$#', $rawtimestamp, $regs)) {
return (int) (($regs[1] * 60) + $regs[2]);
}
return false;
}
- function Lyrics3LyricsTimestampParse(&$Lyrics3data) {
+ public function Lyrics3LyricsTimestampParse(&$Lyrics3data) {
$lyricsarray = explode("\r\n", $Lyrics3data['raw']['LYR']);
foreach ($lyricsarray as $key => $lyricline) {
$regs = array();
@@ -283,7 +283,7 @@ class getid3_lyrics3 extends getid3_handler
return true;
}
- function IntString2Bool($char) {
+ public function IntString2Bool($char) {
if ($char == '1') {
return true;
} elseif ($char == '0') {
@@ -292,6 +292,3 @@ class getid3_lyrics3 extends getid3_handler
return null;
}
}
-
-
-?> \ No newline at end of file
diff --git a/modules/getid3/module.tag.xmp.php b/modules/getid3/module.tag.xmp.php
index 141fd09d..d5ec5adc 100644
--- a/modules/getid3/module.tag.xmp.php
+++ b/modules/getid3/module.tag.xmp.php
@@ -37,21 +37,21 @@ class Image_XMP
* The name of the image file that contains the XMP fields to extract and modify.
* @see Image_XMP()
*/
- var $_sFilename = null;
+ public $_sFilename = null;
/**
* @var array
* The XMP fields that were extracted from the image or updated by this class.
* @see getAllTags()
*/
- var $_aXMP = array();
+ public $_aXMP = array();
/**
* @var boolean
* True if an APP1 segment was found to contain XMP metadata.
* @see isValid()
*/
- var $_bXMPParse = false;
+ public $_bXMPParse = false;
/**
* Returns the status of XMP parsing during instantiation
@@ -61,7 +61,7 @@ class Image_XMP
* @return boolean
* Returns true if an APP1 segment was found to contain XMP metadata.
*/
- function isValid()
+ public function isValid()
{
return $this->_bXMPParse;
}
@@ -71,7 +71,7 @@ class Image_XMP
*
* @return array - An array of XMP fields as it extracted by the XMPparse() function
*/
- function getAllTags()
+ public function getAllTags()
{
return $this->_aXMP;
}
@@ -83,7 +83,7 @@ class Image_XMP
* @return array $headerdata - Array of JPEG header segments
* @return boolean FALSE - if headers could not be read
*/
- function _get_jpeg_header_data($filename)
+ public function _get_jpeg_header_data($filename)
{
// prevent refresh from aborting file operations and hosing file
ignore_user_abort(true);
@@ -193,7 +193,7 @@ class Image_XMP
* @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)
+ public function _get_XMP_text($filename)
{
//Get JPEG header data
$jpeg_header_data = $this->_get_jpeg_header_data($filename);
@@ -226,7 +226,7 @@ class Image_XMP
* @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)
+ public function read_XMP_array_from_text($xmltext)
{
// Check if there actually is any text to parse
if (trim($xmltext) == '')
@@ -302,7 +302,8 @@ class Image_XMP
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']))
+// if (in_array($key, $GLOBALS['XMP_tag_captions']))
+ if (true)
{
// Attribute wanted
$xmp_array[$key] = $xml_elem['attributes'][$key];
@@ -359,7 +360,8 @@ class Image_XMP
default:
// Check whether we want the details from this attribute
- if (in_array($xml_elem['tag'], $GLOBALS['XMP_tag_captions']))
+// if (in_array($xml_elem['tag'], $GLOBALS['XMP_tag_captions']))
+ if (true)
{
switch ($xml_elem['type'])
{
@@ -375,7 +377,7 @@ class Image_XMP
case 'complete':
// store attribute value
- $xmp_array[$xml_elem['tag']] = (isset($xml_elem['value']) ? $xml_elem['value'] : '');
+ $xmp_array[$xml_elem['tag']] = (isset($xml_elem['attributes']) ? $xml_elem['attributes'] : (isset($xml_elem['value']) ? $xml_elem['value'] : ''));
break;
case 'cdata':
@@ -396,7 +398,7 @@ class Image_XMP
*
* @param string - Name of the image file to access and extract XMP information from.
*/
- function Image_XMP($sFilename)
+ public function Image_XMP($sFilename)
{
$this->_sFilename = $sFilename;
@@ -420,6 +422,7 @@ class Image_XMP
* 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',
@@ -688,7 +691,7 @@ $GLOBALS['XMP_tag_captions'] = array(
'exif:Rows',
'exif:Settings',
);
-
+*/
/**
* Global Variable: JPEG_Segment_Names
@@ -762,5 +765,3 @@ $GLOBALS['JPEG_Segment_Names'] = array(
0xFD => 'JPG13',
0xFE => 'COM',
);
-
-?> \ No newline at end of file
diff --git a/modules/getid3/write.apetag.php b/modules/getid3/write.apetag.php
index 2b553699..110c4b84 100644
--- a/modules/getid3/write.apetag.php
+++ b/modules/getid3/write.apetag.php
@@ -19,17 +19,17 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE
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
+ public $filename;
+ public $tag_data;
+ public $always_preserve_replaygain = true; // ReplayGain / MP3gain tags will be copied from old tag even if not passed in data
+ public $warnings = array(); // any non-critical errors will be stored here
+ public $errors = array(); // any critical errors will be stored here
- function getid3_write_apetag() {
+ public function getid3_write_apetag() {
return true;
}
- function WriteAPEtag() {
+ public function WriteAPEtag() {
// NOTE: All data passed to this function must be UTF-8 format
$getID3 = new getID3;
@@ -91,7 +91,7 @@ class getid3_write_apetag
return false;
}
- function DeleteAPEtag() {
+ public function DeleteAPEtag() {
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($this->filename);
if (isset($ThisFileInfo['ape']['tag_offset_start']) && isset($ThisFileInfo['ape']['tag_offset_end'])) {
@@ -125,7 +125,7 @@ class getid3_write_apetag
}
- function GenerateAPEtag() {
+ public function GenerateAPEtag() {
// NOTE: All data passed to this function must be UTF-8 format
$items = array();
@@ -159,7 +159,7 @@ class getid3_write_apetag
return $this->GenerateAPEtagHeaderFooter($items, true).implode('', $items).$this->GenerateAPEtagHeaderFooter($items, false);
}
- function GenerateAPEtagHeaderFooter(&$items, $isheader=false) {
+ public function GenerateAPEtagHeaderFooter(&$items, $isheader=false) {
$tagdatalength = 0;
foreach ($items as $itemdata) {
$tagdatalength += strlen($itemdata);
@@ -175,7 +175,7 @@ class getid3_write_apetag
return $APEheader;
}
- function GenerateAPEtagFlags($header=true, $footer=true, $isheader=false, $encodingid=0, $readonly=false) {
+ public function GenerateAPEtagFlags($header=true, $footer=true, $isheader=false, $encodingid=0, $readonly=false) {
$APEtagFlags = array_fill(0, 4, 0);
if ($header) {
$APEtagFlags[0] |= 0x80; // Tag contains a header
@@ -200,7 +200,7 @@ class getid3_write_apetag
return chr($APEtagFlags[3]).chr($APEtagFlags[2]).chr($APEtagFlags[1]).chr($APEtagFlags[0]);
}
- function CleanAPEtagItemKey($itemkey) {
+ public function CleanAPEtagItemKey($itemkey) {
$itemkey = preg_replace("#[^\x20-\x7E]#i", '', $itemkey);
// http://www.personal.uni-jena.de/~pfk/mpp/sv8/apekey.html
@@ -221,5 +221,3 @@ class getid3_write_apetag
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/write.id3v1.php b/modules/getid3/write.id3v1.php
index cecccd8a..86d50920 100644
--- a/modules/getid3/write.id3v1.php
+++ b/modules/getid3/write.id3v1.php
@@ -17,17 +17,17 @@ 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
+ public $filename;
+ public $filesize;
+ public $tag_data;
+ public $warnings = array(); // any non-critical errors will be stored here
+ public $errors = array(); // any critical errors will be stored here
- function getid3_write_id3v1() {
+ public function getid3_write_id3v1() {
return true;
}
- function WriteID3v1() {
+ public function WriteID3v1() {
// File MUST be writeable - CHMOD(646) at least
if (!empty($this->filename) && is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename)) {
$this->setRealFileSize();
@@ -65,7 +65,7 @@ class getid3_write_id3v1
return false;
}
- function FixID3v1Padding() {
+ public function FixID3v1Padding() {
// ID3v1 data is supposed to be padded with NULL characters, but some taggers incorrectly use spaces
// This function rewrites the ID3v1 tag with correct padding
@@ -87,7 +87,7 @@ class getid3_write_id3v1
return false;
}
- function RemoveID3v1() {
+ public function RemoveID3v1() {
// File MUST be writeable - CHMOD(646) at least
if (!empty($this->filename) && is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename)) {
$this->setRealFileSize();
@@ -115,7 +115,7 @@ class getid3_write_id3v1
return false;
}
- function setRealFileSize() {
+ public function setRealFileSize() {
if (PHP_INT_MAX > 2147483647) {
$this->filesize = filesize($this->filename);
return true;
@@ -134,5 +134,3 @@ class getid3_write_id3v1
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/write.id3v2.php b/modules/getid3/write.id3v2.php
index ee7c5de2..54b8aaed 100644
--- a/modules/getid3/write.id3v2.php
+++ b/modules/getid3/write.id3v2.php
@@ -17,23 +17,23 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE_
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
- var $merge_existing_data = false; // if true, merge new data with existing tags; if false, delete old tag data and only write new tags
- var $id3v2_default_encodingid = 0; // default text encoding (ISO-8859-1) if not explicitly passed
- var $id3v2_use_unsynchronisation = false; // the specs say it should be TRUE, but most other ID3v2-aware programs are broken if unsynchronization is used, so by default don't use it.
- var $warnings = array(); // any non-critical errors will be stored here
- var $errors = array(); // any critical errors will be stored here
-
- function getid3_write_id3v2() {
+ public $filename;
+ public $tag_data;
+ public $fread_buffer_size = 32768; // read buffer size in bytes
+ public $paddedlength = 4096; // minimum length of ID3v2 tag in bytes
+ public $majorversion = 3; // ID3v2 major version (2, 3 (recommended), 4)
+ public $minorversion = 0; // ID3v2 minor version - always 0
+ public $merge_existing_data = false; // if true, merge new data with existing tags; if false, delete old tag data and only write new tags
+ public $id3v2_default_encodingid = 0; // default text encoding (ISO-8859-1) if not explicitly passed
+ public $id3v2_use_unsynchronisation = false; // the specs say it should be TRUE, but most other ID3v2-aware programs are broken if unsynchronization is used, so by default don't use it.
+ public $warnings = array(); // any non-critical errors will be stored here
+ public $errors = array(); // any critical errors will be stored here
+
+ public function getid3_write_id3v2() {
return true;
}
- function WriteID3v2() {
+ public function WriteID3v2() {
// 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.
@@ -133,7 +133,7 @@ class getid3_write_id3v2
return false;
}
- function RemoveID3v2() {
+ public function RemoveID3v2() {
// 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(dirname($this->filename))) {
@@ -225,7 +225,7 @@ class getid3_write_id3v2
}
- function GenerateID3v2TagFlags($flags) {
+ public function GenerateID3v2TagFlags($flags) {
switch ($this->majorversion) {
case 4:
// %abcd0000
@@ -259,7 +259,7 @@ class getid3_write_id3v2
}
- function GenerateID3v2FrameFlags($TagAlter=false, $FileAlter=false, $ReadOnly=false, $Compression=false, $Encryption=false, $GroupingIdentity=false, $Unsynchronisation=false, $DataLengthIndicator=false) {
+ public function GenerateID3v2FrameFlags($TagAlter=false, $FileAlter=false, $ReadOnly=false, $Compression=false, $Encryption=false, $GroupingIdentity=false, $Unsynchronisation=false, $DataLengthIndicator=false) {
switch ($this->majorversion) {
case 4:
// %0abc0000 %0h00kmnp
@@ -299,7 +299,7 @@ class getid3_write_id3v2
return chr(bindec($flag1)).chr(bindec($flag2));
}
- function GenerateID3v2FrameData($frame_name, $source_data_array) {
+ public function GenerateID3v2FrameData($frame_name, $source_data_array) {
if (!getid3_id3v2::IsValidID3v2FrameName($frame_name, $this->majorversion)) {
return false;
}
@@ -1173,7 +1173,7 @@ class getid3_write_id3v2
return $framedata;
}
- function ID3v2FrameIsAllowed($frame_name, $source_data_array) {
+ public function ID3v2FrameIsAllowed($frame_name, $source_data_array) {
static $PreviousFrames = array();
if ($frame_name === null) {
@@ -1530,7 +1530,7 @@ class getid3_write_id3v2
return true;
}
- function GenerateID3v2Tag($noerrorsonly=true) {
+ public function GenerateID3v2Tag($noerrorsonly=true) {
$this->ID3v2FrameIsAllowed(null, ''); // clear static array in case this isn't the first call to $this->GenerateID3v2Tag()
$tagstring = '';
@@ -1641,7 +1641,7 @@ class getid3_write_id3v2
return false;
}
- function ID3v2IsValidPriceString($pricestring) {
+ public function ID3v2IsValidPriceString($pricestring) {
if (getid3_id3v2::LanguageLookup(substr($pricestring, 0, 3), true) == '') {
return false;
} elseif (!$this->IsANumber(substr($pricestring, 3), true)) {
@@ -1650,7 +1650,7 @@ class getid3_write_id3v2
return true;
}
- function ID3v2FrameFlagsLookupTagAlter($framename) {
+ public function ID3v2FrameFlagsLookupTagAlter($framename) {
// unfinished
switch ($framename) {
case 'RGAD':
@@ -1662,7 +1662,7 @@ class getid3_write_id3v2
return $allow;
}
- function ID3v2FrameFlagsLookupFileAlter($framename) {
+ public function ID3v2FrameFlagsLookupFileAlter($framename) {
// unfinished
switch ($framename) {
case 'RGAD':
@@ -1675,7 +1675,7 @@ class getid3_write_id3v2
}
}
- function ID3v2IsValidETCOevent($eventid) {
+ public function ID3v2IsValidETCOevent($eventid) {
if (($eventid < 0) || ($eventid > 0xFF)) {
// outside range of 1 byte
return false;
@@ -1695,7 +1695,7 @@ class getid3_write_id3v2
return true;
}
- function ID3v2IsValidSYLTtype($contenttype) {
+ public function ID3v2IsValidSYLTtype($contenttype) {
if (($contenttype >= 0) && ($contenttype <= 8) && ($this->majorversion == 4)) {
return true;
} elseif (($contenttype >= 0) && ($contenttype <= 6) && ($this->majorversion == 3)) {
@@ -1704,21 +1704,21 @@ class getid3_write_id3v2
return false;
}
- function ID3v2IsValidRVA2channeltype($channeltype) {
+ public function ID3v2IsValidRVA2channeltype($channeltype) {
if (($channeltype >= 0) && ($channeltype <= 8) && ($this->majorversion == 4)) {
return true;
}
return false;
}
- function ID3v2IsValidAPICpicturetype($picturetype) {
+ public function ID3v2IsValidAPICpicturetype($picturetype) {
if (($picturetype >= 0) && ($picturetype <= 0x14) && ($this->majorversion >= 2) && ($this->majorversion <= 4)) {
return true;
}
return false;
}
- function ID3v2IsValidAPICimageformat($imageformat) {
+ public function ID3v2IsValidAPICimageformat($imageformat) {
if ($imageformat == '-->') {
return true;
} elseif ($this->majorversion == 2) {
@@ -1733,28 +1733,28 @@ class getid3_write_id3v2
return false;
}
- function ID3v2IsValidCOMRreceivedAs($receivedas) {
+ public function ID3v2IsValidCOMRreceivedAs($receivedas) {
if (($this->majorversion >= 3) && ($receivedas >= 0) && ($receivedas <= 8)) {
return true;
}
return false;
}
- function ID3v2IsValidRGADname($RGADname) {
+ public function ID3v2IsValidRGADname($RGADname) {
if (($RGADname >= 0) && ($RGADname <= 2)) {
return true;
}
return false;
}
- function ID3v2IsValidRGADoriginator($RGADoriginator) {
+ public function ID3v2IsValidRGADoriginator($RGADoriginator) {
if (($RGADoriginator >= 0) && ($RGADoriginator <= 3)) {
return true;
}
return false;
}
- function ID3v2IsValidTextEncoding($textencodingbyte) {
+ public function ID3v2IsValidTextEncoding($textencodingbyte) {
static $ID3v2IsValidTextEncoding_cache = array(
2 => array(true, true),
3 => array(true, true),
@@ -1762,7 +1762,7 @@ class getid3_write_id3v2
return isset($ID3v2IsValidTextEncoding_cache[$this->majorversion][$textencodingbyte]);
}
- function Unsynchronise($data) {
+ public function Unsynchronise($data) {
// Whenever a false synchronisation is found within the tag, one zeroed
// byte is inserted after the first false synchronisation byte. The
// format of a correct sync that should be altered by ID3 encoders is as
@@ -1792,7 +1792,7 @@ class getid3_write_id3v2
return $unsyncheddata;
}
- function is_hash($var) {
+ public function is_hash($var) {
// written by dev-nullØchristophe*vg
// taken from http://www.php.net/manual/en/function.array-merge-recursive.php
if (is_array($var)) {
@@ -1807,7 +1807,7 @@ class getid3_write_id3v2
return false;
}
- function array_join_merge($arr1, $arr2) {
+ public function array_join_merge($arr1, $arr2) {
// written by dev-nullØchristophe*vg
// taken from http://www.php.net/manual/en/function.array-merge-recursive.php
if (is_array($arr1) && is_array($arr2)) {
@@ -1831,14 +1831,14 @@ class getid3_write_id3v2
}
}
- function IsValidMIMEstring($mimestring) {
+ public function IsValidMIMEstring($mimestring) {
if ((strlen($mimestring) >= 3) && (strpos($mimestring, '/') > 0) && (strpos($mimestring, '/') < (strlen($mimestring) - 1))) {
return true;
}
return false;
}
- function IsWithinBitRange($number, $maxbits, $signed=false) {
+ public function IsWithinBitRange($number, $maxbits, $signed=false) {
if ($signed) {
if (($number > (0 - pow(2, $maxbits - 1))) && ($number <= pow(2, $maxbits - 1))) {
return true;
@@ -1851,7 +1851,7 @@ class getid3_write_id3v2
return false;
}
- function safe_parse_url($url) {
+ public function safe_parse_url($url) {
$parts = @parse_url($url);
$parts['scheme'] = (isset($parts['scheme']) ? $parts['scheme'] : '');
$parts['host'] = (isset($parts['host']) ? $parts['host'] : '');
@@ -1862,7 +1862,7 @@ class getid3_write_id3v2
return $parts;
}
- function IsValidURL($url, $allowUserPass=false) {
+ public function IsValidURL($url, $allowUserPass=false) {
if ($url == '') {
return false;
}
@@ -1893,7 +1893,7 @@ class getid3_write_id3v2
return false;
}
- static function ID3v2ShortFrameNameLookup($majorversion, $long_description) {
+ public static function ID3v2ShortFrameNameLookup($majorversion, $long_description) {
$long_description = str_replace(' ', '_', strtolower(trim($long_description)));
static $ID3v2ShortFrameNameLookup = array();
if (empty($ID3v2ShortFrameNameLookup)) {
@@ -2047,4 +2047,3 @@ class getid3_write_id3v2
}
-?>
diff --git a/modules/getid3/write.lyrics3.php b/modules/getid3/write.lyrics3.php
index fa49cd16..1f85ebd0 100644
--- a/modules/getid3/write.lyrics3.php
+++ b/modules/getid3/write.lyrics3.php
@@ -16,21 +16,21 @@
class getid3_write_lyrics3
{
- var $filename;
- var $tag_data;
- //var $lyrics3_version = 2; // 1 or 2
- var $warnings = array(); // any non-critical errors will be stored here
- var $errors = array(); // any critical errors will be stored here
+ public $filename;
+ public $tag_data;
+ //public $lyrics3_version = 2; // 1 or 2
+ public $warnings = array(); // any non-critical errors will be stored here
+ public $errors = array(); // any critical errors will be stored here
- function getid3_write_lyrics3() {
+ public function getid3_write_lyrics3() {
return true;
}
- function WriteLyrics3() {
+ public function WriteLyrics3() {
$this->errors[] = 'WriteLyrics3() not yet functional - cannot write Lyrics3';
return false;
}
- function DeleteLyrics3() {
+ public function DeleteLyrics3() {
// Initialize getID3 engine
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($this->filename);
@@ -69,5 +69,3 @@ class getid3_write_lyrics3
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/write.metaflac.php b/modules/getid3/write.metaflac.php
index dfd6950a..f20ea604 100644
--- a/modules/getid3/write.metaflac.php
+++ b/modules/getid3/write.metaflac.php
@@ -17,16 +17,16 @@
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
+ public $filename;
+ public $tag_data;
+ public $warnings = array(); // any non-critical errors will be stored here
+ public $errors = array(); // any critical errors will be stored here
- function getid3_write_metaflac() {
+ public function getid3_write_metaflac() {
return true;
}
- function WriteMetaFLAC() {
+ public 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';
@@ -100,7 +100,7 @@ class getid3_write_metaflac
}
- function DeleteMetaFLAC() {
+ public 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';
@@ -146,7 +146,7 @@ class getid3_write_metaflac
}
- function CleanmetaflacName($originalcommentname) {
+ public 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).
@@ -159,5 +159,3 @@ class getid3_write_metaflac
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/write.php b/modules/getid3/write.php
index 16b19c7d..3a7f1974 100644
--- a/modules/getid3/write.php
+++ b/modules/getid3/write.php
@@ -47,28 +47,28 @@ if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
class getid3_writetags
{
// public
- var $filename; // absolute filename of file to write tags to
- 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 $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
+ public $filename; // absolute filename of file to write tags to
+ public $tagformats = array(); // array of tag formats to write ('id3v1', 'id3v2.2', 'id2v2.3', 'id3v2.4', 'ape', 'vorbiscomment', 'metaflac', 'real')
+ public $tag_data = array(array()); // 2-dimensional array of tag data (ex: $data['ARTIST'][0] = 'Elvis')
+ public $tag_encoding = 'ISO-8859-1'; // text encoding used for tag data ('ISO-8859-1', 'UTF-8', 'UTF-16', 'UTF-16LE', 'UTF-16BE', )
+ public $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
+ public $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)
- var $id3v2_paddedlength = 4096; // minimum length of ID3v2 tags (will be padded to this length if tag data is shorter)
+ public $id3v2_tag_language = 'eng'; // ISO-639-2 3-character language code needed for some ID3v2 frames (http://www.id3.org/iso639-2.html)
+ public $id3v2_paddedlength = 4096; // minimum length of ID3v2 tags (will be padded to this length if tag data is shorter)
- var $warnings = array(); // any non-critical errors will be stored here
- var $errors = array(); // any critical errors will be stored here
+ public $warnings = array(); // any non-critical errors will be stored here
+ public $errors = array(); // any critical errors will be stored here
// private
- var $ThisFileInfo; // analysis of file before writing
+ private $ThisFileInfo; // analysis of file before writing
- function getid3_writetags() {
+ public function getid3_writetags() {
return true;
}
- function WriteTags() {
+ public function WriteTags() {
if (empty($this->filename)) {
$this->errors[] = 'filename is undefined in getid3_writetags';
@@ -341,7 +341,7 @@ class getid3_writetags
}
- function DeleteTags($TagFormatsToDelete) {
+ public function DeleteTags($TagFormatsToDelete) {
foreach ($TagFormatsToDelete as $DeleteTagFormat) {
$success = false; // overridden if tag deletion is successful
switch ($DeleteTagFormat) {
@@ -414,7 +414,7 @@ class getid3_writetags
}
- function MergeExistingTagData($TagFormat, &$tag_data) {
+ public function MergeExistingTagData($TagFormat, &$tag_data) {
// Merge supplied data with existing data, if requested
if ($this->overwrite_tags) {
// do nothing - ignore previous data
@@ -428,7 +428,7 @@ throw new Exception('$this->overwrite_tags=false is known to be buggy in this ve
return true;
}
- function FormatDataForAPE() {
+ public function FormatDataForAPE() {
$ape_tag_data = array();
foreach ($this->tag_data as $tag_key => $valuearray) {
switch ($tag_key) {
@@ -455,7 +455,7 @@ throw new Exception('$this->overwrite_tags=false is known to be buggy in this ve
}
- function FormatDataForID3v1() {
+ public function FormatDataForID3v1() {
$tag_data_id3v1['genreid'] = 255;
if (!empty($this->tag_data['GENRE'])) {
foreach ($this->tag_data['GENRE'] as $key => $value) {
@@ -479,7 +479,7 @@ throw new Exception('$this->overwrite_tags=false is known to be buggy in this ve
return $tag_data_id3v1;
}
- function FormatDataForID3v2($id3v2_majorversion) {
+ public function FormatDataForID3v2($id3v2_majorversion) {
$tag_data_id3v2 = array();
$ID3v2_text_encoding_lookup[2] = array('ISO-8859-1'=>0, 'UTF-16'=>1);
@@ -565,7 +565,7 @@ throw new Exception('$this->overwrite_tags=false is known to be buggy in this ve
return $tag_data_id3v2;
}
- function FormatDataForVorbisComment() {
+ public function FormatDataForVorbisComment() {
$tag_data_vorbiscomment = $this->tag_data;
// check for multi-line comment values - split out to multiple comments if neccesary
@@ -594,13 +594,13 @@ throw new Exception('$this->overwrite_tags=false is known to be buggy in this ve
return $tag_data_vorbiscomment;
}
- function FormatDataForMetaFLAC() {
+ public function FormatDataForMetaFLAC() {
// FLAC & OggFLAC use VorbisComments same as OggVorbis
// but require metaflac to do the writing rather than vorbiscomment
return $this->FormatDataForVorbisComment();
}
- function FormatDataForReal() {
+ public function FormatDataForReal() {
$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())));
@@ -611,5 +611,3 @@ throw new Exception('$this->overwrite_tags=false is known to be buggy in this ve
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/write.real.php b/modules/getid3/write.real.php
index ad37e74a..02b91652 100644
--- a/modules/getid3/write.real.php
+++ b/modules/getid3/write.real.php
@@ -15,18 +15,18 @@
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() {
+ public $filename;
+ public $tag_data = array();
+ public $fread_buffer_size = 32768; // read buffer size in bytes
+ public $warnings = array(); // any non-critical errors will be stored here
+ public $errors = array(); // any critical errors will be stored here
+ public $paddedlength = 512; // minimum length of CONT tag in bytes
+
+ public function getid3_write_real() {
return true;
}
- function WriteReal() {
+ public 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'))) {
@@ -126,7 +126,7 @@ class getid3_write_real
return false;
}
- function GenerateRMFchunk(&$chunks) {
+ public function GenerateRMFchunk(&$chunks) {
$oldCONTexists = false;
foreach ($chunks as $key => $chunk) {
$chunkNameKeys[$chunk['name']] = $key;
@@ -144,7 +144,7 @@ class getid3_write_real
return $RMFchunk;
}
- function GeneratePROPchunk(&$chunks, &$new_CONT_tag_data) {
+ public function GeneratePROPchunk(&$chunks, &$new_CONT_tag_data) {
$old_CONT_length = 0;
$old_DATA_offset = 0;
$old_INDX_offset = 0;
@@ -181,7 +181,7 @@ class getid3_write_real
return $PROPchunk;
}
- function GenerateCONTchunk() {
+ public function GenerateCONTchunk() {
foreach ($this->tag_data as $key => $value) {
// limit each value to 0xFFFF bytes
$this->tag_data[$key] = substr($value, 0, 65535);
@@ -210,7 +210,7 @@ class getid3_write_real
return $CONTchunk;
}
- function RemoveReal() {
+ public 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'))) {
@@ -271,5 +271,3 @@ class getid3_write_real
}
}
-
-?> \ No newline at end of file
diff --git a/modules/getid3/write.vorbiscomment.php b/modules/getid3/write.vorbiscomment.php
index ac8dc693..7fc722be 100644
--- a/modules/getid3/write.vorbiscomment.php
+++ b/modules/getid3/write.vorbiscomment.php
@@ -17,16 +17,16 @@
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
+ public $filename;
+ public $tag_data;
+ public $warnings = array(); // any non-critical errors will be stored here
+ public $errors = array(); // any critical errors will be stored here
- function getid3_write_vorbiscomment() {
+ public function getid3_write_vorbiscomment() {
return true;
}
- function WriteVorbisComment() {
+ public 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';
@@ -99,12 +99,12 @@ class getid3_write_vorbiscomment
return true;
}
- function DeleteVorbisComment() {
+ public function DeleteVorbisComment() {
$this->tag_data = array(array());
return $this->WriteVorbisComment();
}
- function CleanVorbisCommentName($originalcommentname) {
+ public 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).
@@ -117,5 +117,3 @@ class getid3_write_vorbiscomment
}
}
-
-?> \ No newline at end of file