Version Description
- Released on 12/19/2014
- You must have WordPress 3.6 or newer and PHP 5.2 or newer for PowerPress 6.0.
- NEW FEATURE: Playlist player, utilizes WordPress built-in playlist specifically for podcasting. Learn more
- NEW FEATURE: Subscribe links, adds subscribe on iTunes and via RSS links below the player and links.
- NEW FEATURE: Subscribe page template and
[powerpress_subscribe]
page shortcode added. Create a "Subscribe to podcast" page for your podcast. - NEW FEATURE: Subscribe to podcast widget, adds subscribe on iTunes and via RSS links to side bar, with optional link to subscribe to podcast page.
- NEW FEATURE: Podcasting SEO settings. Includes options to customize podcast feed titles, AudioObjects, VideoObjects, and highlight key iTunes fields.
- NEW FEATURE: Migrate to Blubrry Podcast Hosting in 3 easy steps added.
- iTunes image requirements updated, 1400x1400 minimum size is now "required" and 2048x2048 is now the maximum size for iTunes artwork.
- iTunes category and subcategory selection updated for latest iTunes category selection rules.
- Enhnaced iTunes Summary is back! The feature actually never left, but for the past few years links were not formatted in the iOS app. Now that they are, we now recommend the feature.
- Fixed bug where Feed Maximizer option only worked when Podcast Channels was enabled (Thanks Daniel Lewis for bringing to our attention!)
- Fixed bug where player and links would not appear if Yoast's WordPress SEO plugin option "Add Open Graph meta data" was enabled.
- iTunes keywords feature has been removed, feature was deprecated last year by Apple. The iTunes keywords field will appear for previous episodes that used the feature.
- Added support for Opus audio with content type audio/ogg. (Thanks thebugcast for the heads up!)
- Files with 'ogg' file extension are now treated as audio/ogg, unless the following define is added to your wp-config.php:
define('POWERPRESS_OGG_VIDEO', true);
(Thanks thebugcast for pointing out the default!) - Updated the Find and Replace episode URLs tool to use native WordPress MySQL query functions.
- Changed the logic for HEAD requests for HTTP authentication. Default WordPress behavior is to exit all HEAD requests. (Thanks thebugcast!)
- Changed all content types to either use the site default or use UTF8 (applies to play in new window and 401 Unauthorized HTML pages).
- Added new
powerpress_premium_content_authorized
filter for premium plugins to override the default behavior which uses roles and capabilities. - Updated the getid3 library to latest version, PowerPress now includes ogg duration detection support for "Speex" or "vorbis".
- We are no longer detecting if the sample rate is optimal, we're no longer worried about Flash playback.
- Removed Flow Player, Simple Flash, AudioPlay and Flash Mp3 Maxi players. These flash players are no longer supported.
- New MediaElement.js Audio player max width setting added. Player will now display full with otherwise. Player is now responsive, the width will shrink or stretch for the screen.
- Improved MediaElement.js Video player width and height settings. Player will now display full width, or as styled by the theme's CSS if width and height are blank. Player is now responsive, the width will shrink or stretch for the screen, the height can be set with a blank width to allow for the player to fit different screens.
- We are now warning users not to use Flash based players in the player selection screens.
- Added option to set stats redirect at the channel/post type level. Requires a define
CHANNEL_STATS_REDIRECT
and/orPOST_TYPE_STATS_REDIRECT
in the wp-config.php file. - FeedBurner feed URL when set will be used in the new subscribe page and subscribe sidebar widget (Thanks Daniel Lewis for bringing to our attention)
- Playlist Player no longer includes the play time when it is zero. (Thanks Daniel Lewis for bringing to our attention)
- Program Titles with double quotes in the general settings was not escaped correctly, it is now fixed. (Thanks Robin for bringing to our attention)
- Edit value fields now use the
esc_attr()
wordpress function rather than thehtmlspecialchars()
native PHP function. - Added
powerpress_admin_capabilities
filter for premium capabilities. (Thanks Blair Williams for the suggestion) - Made subscribe sidebar and subscribe embed button icons Retina screen compatible
- Re-added the blubrry folder icon for blubrry podcast hosting customers.
- Tweaked wording and updated documentation for SEO settings (Thanks Daniel Lewis for the feedback!)
- Tweaked updated documentation for the PowerPress Playlist (Thanks Daniel Lewis for asking questions, it helped us better document the features)
- Fixed subscribe links always displaying (thanks Thiago Miro for pointing out the bug)
- Fixed upload itunes image and poster image episode functions to use selected image size when "Link URL" is blank (Thanks Daniel Lewis for bringing to our attention)
- Added a learn more link to the SEO page.
- Added code for the new Subscribe embed so the subscribe embed CSS is only loaded when the shortcode is used in a page.
- Added the wp-video and wp-video-shortcode classes to the MEJS video player so latest CSS styling in WordPress is again applied 100% of the time to the MEJS player packaged in PowerPress.
- Playlist player will now use the iTunes episode image if one is set for each episode. Program level image is used if no image is set.
- Playlist player taxonomy podcasting now accepts the term_taxonomy_id, making it more efficient.
- Moved the Shortcodes into their own section in Media Appearance settings, they are now included in Podcast Channels, Category Podcasting, Post Type podcasting and Taxonomy podcasting with the appropriate attributes set for convenience.
- Brazilian Portuguese translation for v6.0+ by Leo Lopes from Radiofobia.
=
Download this release
Release Info
Developer | amandato |
Plugin | PowerPress Podcasting plugin by Blubrry |
Version | 6.0 |
Comparing to | |
See all releases |
Code changes from version 5.0.10 to 6.0
- 3rdparty/maxi_player/generator.js +0 -147
- audioplay.swf +0 -0
- buttons/classic/pausedown.png +0 -0
- buttons/classic/pauseover.png +0 -0
- buttons/classic/pauseup.png +0 -0
- buttons/classic/playdown.png +0 -0
- buttons/classic/playover.png +0 -0
- buttons/classic/playup.png +0 -0
- buttons/classic/stopdown.png +0 -0
- buttons/classic/stopover.png +0 -0
- buttons/classic/stopup.png +0 -0
- buttons/classic_small/pausedown.png +0 -0
- buttons/classic_small/pauseover.png +0 -0
- buttons/classic_small/pauseup.png +0 -0
- buttons/classic_small/playdown.png +0 -0
- buttons/classic_small/playover.png +0 -0
- buttons/classic_small/playup.png +0 -0
- buttons/classic_small/stopdown.png +0 -0
- buttons/classic_small/stopover.png +0 -0
- buttons/classic_small/stopup.png +0 -0
- buttons/negative/pausedown.png +0 -0
- buttons/negative/pauseover.png +0 -0
- buttons/negative/pauseup.png +0 -0
- buttons/negative/playdown.png +0 -0
- buttons/negative/playover.png +0 -0
- buttons/negative/playup.png +0 -0
- buttons/negative/stopdown.png +0 -0
- buttons/negative/stopover.png +0 -0
- buttons/negative/stopup.png +0 -0
- buttons/negative_small/pausedown.png +0 -0
- buttons/negative_small/pauseover.png +0 -0
- buttons/negative_small/pauseup.png +0 -0
- buttons/negative_small/playdown.png +0 -0
- buttons/negative_small/playover.png +0 -0
- buttons/negative_small/playup.png +0 -0
- buttons/negative_small/stopdown.png +0 -0
- buttons/negative_small/stopover.png +0 -0
- buttons/negative_small/stopup.png +0 -0
- class.powerpress-subscribe-widget.php +256 -0
- css/admin.css +18 -10
- css/dashboard.css +23 -1
- css/subscribe.css +171 -0
- getid3/getid3.lib.php +1379 -1317
- getid3/getid3.php +1809 -1766
- getid3/module.audio-video.quicktime.php +2246 -2134
- getid3/module.audio-video.riff.php +2586 -2409
- getid3/module.audio.aac.php +513 -515
- getid3/module.audio.flac.php +443 -0
- getid3/module.audio.mp3.php +2012 -2011
- getid3/module.audio.ogg.php +756 -0
- getid3/module.tag.apetag.php +57 -372
3rdparty/maxi_player/generator.js
DELETED
@@ -1,147 +0,0 @@
|
|
1 |
-
var generator = new Object();
|
2 |
-
generator.params = new Object();
|
3 |
-
generator.updateParam = function(name, value)
|
4 |
-
{
|
5 |
-
//var element = document.getElementById(id);
|
6 |
-
switch (this.params[name].type) {
|
7 |
-
case "url":
|
8 |
-
case "text":
|
9 |
-
case "color":
|
10 |
-
this.params[name].value = value;
|
11 |
-
break;
|
12 |
-
case "int":
|
13 |
-
this.params[name].value = Number(value);
|
14 |
-
break;
|
15 |
-
case "bool":
|
16 |
-
this.params[name].value = value; // (value == "on")?1:0;
|
17 |
-
break;
|
18 |
-
}
|
19 |
-
}
|
20 |
-
|
21 |
-
generator.addParam = function(id, name, type, defaultValue)
|
22 |
-
{
|
23 |
-
var element = document.getElementById(id);
|
24 |
-
this.params[name] = new Object();
|
25 |
-
this.params[name].type = type;
|
26 |
-
this.params[name].defaultValue = defaultValue;
|
27 |
-
this.params[name].element = element;
|
28 |
-
switch (type) {
|
29 |
-
case "url":
|
30 |
-
case "text":
|
31 |
-
this.params[name].value = element.value;
|
32 |
-
element.onchange = delegate(this.params[name], function()
|
33 |
-
{
|
34 |
-
this.value = this.element.value;
|
35 |
-
generator.updatePlayer();
|
36 |
-
});
|
37 |
-
break;
|
38 |
-
case "color":
|
39 |
-
this.params[name].value = element.value.replace(/#/, '');
|
40 |
-
element.onchange = delegate(this.params[name], function()
|
41 |
-
{
|
42 |
-
this.value = this.element.value;
|
43 |
-
generator.updatePlayer();
|
44 |
-
});
|
45 |
-
break;
|
46 |
-
break;
|
47 |
-
case "int":
|
48 |
-
this.params[name].value = Number(element.value);
|
49 |
-
element.onchange = delegate(this.params[name], function()
|
50 |
-
{
|
51 |
-
this.value = Number(this.element.value);
|
52 |
-
generator.updatePlayer();
|
53 |
-
});
|
54 |
-
break;
|
55 |
-
case "bool":
|
56 |
-
this.params[name].value = element.value; // (element.value == "on")?1:0;
|
57 |
-
element.onchange = delegate(this.params[name], function()
|
58 |
-
{
|
59 |
-
this.value = this.element.value; // (this.element.value == "on")?1:0;
|
60 |
-
generator.updatePlayer();
|
61 |
-
});
|
62 |
-
break;
|
63 |
-
}
|
64 |
-
};
|
65 |
-
generator.updatePlayer = function()
|
66 |
-
{
|
67 |
-
var out = '<object type="application/x-shockwave-flash" data="'+this.player+'" width="'+this.params.width.value+'" height="'+this.params.height.value+'">'+"\n";
|
68 |
-
out += ' <param name="movie" value="'+this.player+'" />'+"\n";
|
69 |
-
if (this.params.bgcolor) {
|
70 |
-
out += ' <param name="bgcolor" value="#'+this.params.bgcolor.value.replace(/#/, '')+'" />'+"\n";
|
71 |
-
}
|
72 |
-
out += ' <param name="FlashVars" value="';
|
73 |
-
|
74 |
-
var separator = '';
|
75 |
-
for (var i in this.params) {
|
76 |
-
if (this.params[i].value != this.params[i].defaultValue && this.params[i].value != '' ) {
|
77 |
-
if (this.params[i].type == "url") {
|
78 |
-
out += separator + i + '=' + escape(this.params[i].value);
|
79 |
-
}
|
80 |
-
else if(this.params[i].type == "color") {
|
81 |
-
out += separator + i + '=' + this.params[i].value.replace(/#/, '');
|
82 |
-
}
|
83 |
-
else {
|
84 |
-
out += separator + i + '=' + escapeHTML(this.params[i].value);
|
85 |
-
}
|
86 |
-
separator = '&';
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
out += '" />'+"\n";
|
91 |
-
out += '</object>';
|
92 |
-
|
93 |
-
var player = document.getElementById("player_preview");
|
94 |
-
player.innerHTML = out;
|
95 |
-
};
|
96 |
-
|
97 |
-
var params = new Object();
|
98 |
-
|
99 |
-
/* =============== UTILS =============== */
|
100 |
-
var delegate = function(pTarget, pFunction)
|
101 |
-
{
|
102 |
-
var f = function(){
|
103 |
-
arguments.callee.func.apply(arguments.callee.target, arguments);
|
104 |
-
};
|
105 |
-
f.target = pTarget;
|
106 |
-
f.func = pFunction;
|
107 |
-
return f;
|
108 |
-
}
|
109 |
-
var escapeHTML = function(str) {
|
110 |
-
str = String(str);
|
111 |
-
str = str.replace(/&/gi, '');
|
112 |
-
|
113 |
-
var div = document.createElement("div");
|
114 |
-
var text = document.createTextNode('');
|
115 |
-
div.appendChild(text);
|
116 |
-
text.data = str;
|
117 |
-
|
118 |
-
var result = div.innerHTML;
|
119 |
-
result = result.replace(/"/gi, '"');
|
120 |
-
|
121 |
-
return result;
|
122 |
-
}
|
123 |
-
var findPosX = function (obj)
|
124 |
-
{
|
125 |
-
var curleft = 0;
|
126 |
-
do {
|
127 |
-
curleft += obj.offsetLeft || 0;
|
128 |
-
obj = obj.offsetParent;
|
129 |
-
} while (obj);
|
130 |
-
return curleft;
|
131 |
-
};
|
132 |
-
var findPosY = function (obj)
|
133 |
-
{
|
134 |
-
var curtop = 0;
|
135 |
-
do {
|
136 |
-
curtop += obj.offsetTop || 0;
|
137 |
-
obj = obj.offsetParent;
|
138 |
-
} while (obj);
|
139 |
-
return curtop;
|
140 |
-
};
|
141 |
-
var twoChar = function (str)
|
142 |
-
{
|
143 |
-
if (str.length == 1) {
|
144 |
-
return "0" + str;
|
145 |
-
}
|
146 |
-
return str;
|
147 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
audioplay.swf
DELETED
Binary file
|
buttons/classic/pausedown.png
DELETED
Binary file
|
buttons/classic/pauseover.png
DELETED
Binary file
|
buttons/classic/pauseup.png
DELETED
Binary file
|
buttons/classic/playdown.png
DELETED
Binary file
|
buttons/classic/playover.png
DELETED
Binary file
|
buttons/classic/playup.png
DELETED
Binary file
|
buttons/classic/stopdown.png
DELETED
Binary file
|
buttons/classic/stopover.png
DELETED
Binary file
|
buttons/classic/stopup.png
DELETED
Binary file
|
buttons/classic_small/pausedown.png
DELETED
Binary file
|
buttons/classic_small/pauseover.png
DELETED
Binary file
|
buttons/classic_small/pauseup.png
DELETED
Binary file
|
buttons/classic_small/playdown.png
DELETED
Binary file
|
buttons/classic_small/playover.png
DELETED
Binary file
|
buttons/classic_small/playup.png
DELETED
Binary file
|
buttons/classic_small/stopdown.png
DELETED
Binary file
|
buttons/classic_small/stopover.png
DELETED
Binary file
|
buttons/classic_small/stopup.png
DELETED
Binary file
|
buttons/negative/pausedown.png
DELETED
Binary file
|
buttons/negative/pauseover.png
DELETED
Binary file
|
buttons/negative/pauseup.png
DELETED
Binary file
|
buttons/negative/playdown.png
DELETED
Binary file
|
buttons/negative/playover.png
DELETED
Binary file
|
buttons/negative/playup.png
DELETED
Binary file
|
buttons/negative/stopdown.png
DELETED
Binary file
|
buttons/negative/stopover.png
DELETED
Binary file
|
buttons/negative/stopup.png
DELETED
Binary file
|
buttons/negative_small/pausedown.png
DELETED
Binary file
|
buttons/negative_small/pauseover.png
DELETED
Binary file
|
buttons/negative_small/pauseup.png
DELETED
Binary file
|
buttons/negative_small/playdown.png
DELETED
Binary file
|
buttons/negative_small/playover.png
DELETED
Binary file
|
buttons/negative_small/playup.png
DELETED
Binary file
|
buttons/negative_small/stopdown.png
DELETED
Binary file
|
buttons/negative_small/stopover.png
DELETED
Binary file
|
buttons/negative_small/stopup.png
DELETED
Binary file
|
class.powerpress-subscribe-widget.php
ADDED
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package PowerPressSubscribe_Widget
|
4 |
+
*/
|
5 |
+
class PowerPressSubscribe_Widget extends WP_Widget {
|
6 |
+
|
7 |
+
function __construct() {
|
8 |
+
load_plugin_textdomain( 'powerpress' );
|
9 |
+
|
10 |
+
parent::__construct(
|
11 |
+
'powerpress_subscribe',
|
12 |
+
__( 'Subscribe to Podcast' , 'powerpress'),
|
13 |
+
array( 'description' => __( 'Display subscribe to podcast links.' , 'powerpress') )
|
14 |
+
);
|
15 |
+
|
16 |
+
if ( is_active_widget( false, false, $this->id_base ) ) {
|
17 |
+
add_action( 'wp_head', array( $this, 'css' ) );
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
function css() {
|
22 |
+
?>
|
23 |
+
|
24 |
+
<style type="text/css">
|
25 |
+
|
26 |
+
/*
|
27 |
+
PowerPress subscribe sidebar widget
|
28 |
+
*/
|
29 |
+
.widget-area .widget_powerpress_subscribe h2,
|
30 |
+
.widget-area .widget_powerpress_subscribe h3,
|
31 |
+
.widget-area .widget_powerpress_subscribe h4,
|
32 |
+
.widget_powerpress_subscribe h2,
|
33 |
+
.widget_powerpress_subscribe h3,
|
34 |
+
.widget_powerpress_subscribe h4 {
|
35 |
+
margin-bottom: 0;
|
36 |
+
padding-bottom: 0;
|
37 |
+
}
|
38 |
+
|
39 |
+
.pp-ssb-widget {
|
40 |
+
width: 100%;
|
41 |
+
margin: 0 auto;
|
42 |
+
font-family: Sans-serif;
|
43 |
+
color: #FFFFFF;
|
44 |
+
}
|
45 |
+
body .pp-ssb-widget a.pp-ssb-btn {
|
46 |
+
width: 100% !important;
|
47 |
+
height: 48px;
|
48 |
+
padding: 0;
|
49 |
+
color: #FFFFFF;
|
50 |
+
display: inline-block;
|
51 |
+
margin: 10px 0 10px 0;
|
52 |
+
text-decoration: none;
|
53 |
+
text-align:left;
|
54 |
+
vertical-align: middle;
|
55 |
+
line-height: 48px;
|
56 |
+
font-size: 90% !important;
|
57 |
+
font-weight: bold !important;
|
58 |
+
overflow: hidden;
|
59 |
+
border-radius: 1px;
|
60 |
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
|
61 |
+
}
|
62 |
+
|
63 |
+
body .sidebar .widget .pp-ssb-widget a:link,
|
64 |
+
body .sidebar .widget .pp-ssb-widget a:visited,
|
65 |
+
body .sidebar .widget .pp-ssb-widget a:active,
|
66 |
+
body .sidebar .widget .pp-ssb-widget a:hover,
|
67 |
+
body .pp-ssb-widget a.pp-ssb-btn:link,
|
68 |
+
body .pp-ssb-widget a.pp-ssb-btn:visited,
|
69 |
+
body .pp-ssb-widget a.pp-ssb-btn:active,
|
70 |
+
body .pp-ssb-widget a.pp-ssb-btn:hover {
|
71 |
+
text-decoration: none !important;
|
72 |
+
color: #FFFFFF;
|
73 |
+
}
|
74 |
+
.pp-ssb-widget-dark a,
|
75 |
+
.pp-ssb-widget-modern a {
|
76 |
+
background-color: #222222;
|
77 |
+
}
|
78 |
+
.pp-ssb-widget-modern a.pp-ssb-itunes {
|
79 |
+
background-color: #732BBE;
|
80 |
+
}
|
81 |
+
.pp-ssb-widget-modern a.pp-ssb-email {
|
82 |
+
background-color: #337EC9;
|
83 |
+
}
|
84 |
+
.pp-ssb-widget-modern a.pp-ssb-rss {
|
85 |
+
background-color: #FF8800;
|
86 |
+
}
|
87 |
+
.pp-ssb-ic {
|
88 |
+
width: 48px;
|
89 |
+
height: 48px;
|
90 |
+
border: 0;
|
91 |
+
display: inline-block;
|
92 |
+
vertical-align: middle;
|
93 |
+
margin-right: 2px;
|
94 |
+
background-image: url(<?php echo powerpress_get_root_url(); ?>/images/spriteStandard.png);
|
95 |
+
background-repeat: no-repeat;
|
96 |
+
background-size: 294px;
|
97 |
+
}
|
98 |
+
.pp-ssb-itunes .pp-ssb-ic {
|
99 |
+
background-position: -49px 0;
|
100 |
+
}
|
101 |
+
.pp-ssb-rss .pp-ssb-ic {
|
102 |
+
background-position: 0 -49px;
|
103 |
+
}
|
104 |
+
.pp-ssb-email .pp-ssb-ic {
|
105 |
+
background-position: -196px -49px;
|
106 |
+
}
|
107 |
+
.pp-ssb-more .pp-ssb-ic {
|
108 |
+
background-position: -49px -49px;
|
109 |
+
}
|
110 |
+
/* Retina-specific stuff here */
|
111 |
+
@media only screen and (-webkit-min-device-pixel-ratio: 2.0),
|
112 |
+
only screen and (min--moz-device-pixel-ratio: 2.0),
|
113 |
+
only screen and (-o-min-device-pixel-ratio: 200/100),
|
114 |
+
only screen and (min-device-pixel-ratio: 2.0) {
|
115 |
+
.pp-sub-ic {
|
116 |
+
background-image: url(<?php echo powerpress_get_root_url(); ?>/images/spriteRetina.png);
|
117 |
+
}
|
118 |
+
}
|
119 |
+
</style>
|
120 |
+
<?php
|
121 |
+
}
|
122 |
+
|
123 |
+
function form( $instance ) {
|
124 |
+
if ( empty($instance['title']) ) {
|
125 |
+
$instance['title'] = __( 'Subscribe to Podcast' , 'powerpress');
|
126 |
+
}
|
127 |
+
if ( empty($instance['subscribe_type']) ) {
|
128 |
+
$instance['subscribe_type'] = '';
|
129 |
+
}
|
130 |
+
if ( empty($instance['subscribe_post_type']) ) {
|
131 |
+
$instance['subscribe_post_type'] = '';
|
132 |
+
}
|
133 |
+
if ( empty($instance['subscribe_feed_slug']) ) {
|
134 |
+
$instance['subscribe_feed_slug'] = '';
|
135 |
+
}
|
136 |
+
if ( empty($instance['subscribe_category_id']) ) {
|
137 |
+
$instance['subscribe_category_id'] = '';
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
?>
|
142 |
+
<p>
|
143 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:' , 'powerpress'); ?></label>
|
144 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
|
145 |
+
</p>
|
146 |
+
<p>
|
147 |
+
<label for="<?php echo $this->get_field_id('subscribe_type'); ?>"><?php _e( 'Select Podcast Type:', 'powerpress' ); ?></label>
|
148 |
+
<select class="widefat" id="<?php echo $this->get_field_id('subscribe_type'); ?>" name="<?php echo $this->get_field_name('subscribe_type'); ?>">
|
149 |
+
<?php
|
150 |
+
$types = array(''=>__('Default Podcast','powerpress'), 'channel'=>__('Podcast Channel','powerpress'), 'category'=>__('Category Podcasting','powerpress') ); //, 'post_type'=>__('Post Type Podcasting','powerpress'), 'ttid'=>__('Taxonomy Podcasting','powerpress'));
|
151 |
+
while( list($type, $label) = each($types) ) {
|
152 |
+
echo '<option value="' . $type . '"'
|
153 |
+
. selected( $instance['subscribe_type'], $type, false )
|
154 |
+
. '>' . $label . "</option>\n";
|
155 |
+
}
|
156 |
+
?>
|
157 |
+
</select>
|
158 |
+
</p>
|
159 |
+
<?php
|
160 |
+
/*
|
161 |
+
?>
|
162 |
+
<p id="<?php echo $this->get_field_id('subscribe_post_type_section'); ?>">
|
163 |
+
<label for="<?php echo $this->get_field_id('subscribe_post_type'); ?>"><?php _e( 'Select Post Type:', 'powerpress' ); ?></label>
|
164 |
+
<select class="widefat" id="<?php echo $this->get_field_id('subscribe_post_type'); ?>" name="<?php echo $this->get_field_name('subscribe_post_type'); ?>">
|
165 |
+
<option value=""><?php echo __('Select Post Type', 'powerpress'); ?></option>
|
166 |
+
<?php
|
167 |
+
$post_types = powerpress_admin_get_post_types(false);
|
168 |
+
while( list($index, $label) = each($post_types) ) {
|
169 |
+
echo '<option value="' . $label . '"'
|
170 |
+
. selected( $instance['subscribe_post_type'], $label, false )
|
171 |
+
. '>' . $label . "</option>\n";
|
172 |
+
}
|
173 |
+
?>
|
174 |
+
</select>
|
175 |
+
</p>
|
176 |
+
<?php */ ?>
|
177 |
+
|
178 |
+
<p id="<?php echo $this->get_field_id('subscribe_feed_slug_section'); ?>">
|
179 |
+
<label for="<?php echo $this->get_field_id( 'subscribe_feed_slug' ); ?>"><?php esc_html_e( 'Feed Slug:' , 'powerpress'); ?></label>
|
180 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'subscribe_feed_slug' ); ?>" name="<?php echo $this->get_field_name( 'subscribe_feed_slug' ); ?>" type="text" value="<?php echo esc_attr( $instance['subscribe_feed_slug'] ); ?>" />
|
181 |
+
</p>
|
182 |
+
|
183 |
+
<p id="<?php echo $this->get_field_id('subscribe_category_id_section'); ?>">
|
184 |
+
<label for="<?php echo $this->get_field_id( 'subscribe_category_id' ); ?>"><?php esc_html_e( 'Category ID:' , 'powerpress'); ?></label>
|
185 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'subscribe_category_id' ); ?>" name="<?php echo $this->get_field_name( 'subscribe_category_id' ); ?>" type="text" value="<?php echo esc_attr( $instance['subscribe_category_id'] ); ?>" />
|
186 |
+
</p>
|
187 |
+
|
188 |
+
<?php
|
189 |
+
}
|
190 |
+
|
191 |
+
function update( $new_instance, $old_instance ) {
|
192 |
+
$instance['title'] = strip_tags( $new_instance['title'] );
|
193 |
+
$instance['subscribe_type'] = strip_tags( $new_instance['subscribe_type'] ); // general, channel, category, post_type, ttid
|
194 |
+
$instance['subscribe_post_type'] = strip_tags( $new_instance['subscribe_post_type'] );; // eg sermons
|
195 |
+
$instance['subscribe_feed_slug'] = strip_tags( $new_instance['subscribe_feed_slug'] );; // e.g. podcast
|
196 |
+
$instance['subscribe_category_id'] = strip_tags( $new_instance['subscribe_category_id'] );; // e.g. 456
|
197 |
+
//$instance['subscribe_term_taxonomy_id'] = strip_tags( $new_instance['subscribe_term_taxonomy_id'] );; // e.g. 345
|
198 |
+
return $instance;
|
199 |
+
}
|
200 |
+
|
201 |
+
function widget( $args, $instance ) {
|
202 |
+
|
203 |
+
$ExtraData = array('type'=>'general', 'feed'=>'', 'taxonomy_term_id'=>'', 'cat_id'=>'', 'post_type'=>'');
|
204 |
+
if( !empty($instance['subscribe_type']) )
|
205 |
+
$ExtraData['type'] = $instance['subscribe_type'];
|
206 |
+
|
207 |
+
switch( $instance['subscribe_type'] )
|
208 |
+
{
|
209 |
+
case 'post_type': {
|
210 |
+
if( empty($instance['subscribe_post_type']) )
|
211 |
+
return;
|
212 |
+
$ExtraData['post_type'] = $instance['subscribe_post_type'];
|
213 |
+
};
|
214 |
+
case 'channel': {
|
215 |
+
if( empty($instance['subscribe_feed_slug']) )
|
216 |
+
return;
|
217 |
+
$ExtraData['feed'] = $instance['subscribe_feed_slug'];
|
218 |
+
}; break;
|
219 |
+
case 'ttid': {
|
220 |
+
if( empty($instance['subscribe_term_taxonomy_id']) || !is_numeric($instance['subscribe_term_taxonomy_id']) )
|
221 |
+
return;
|
222 |
+
$ExtraData['taxonomy_term_id'] = $instance['subscribe_term_taxonomy_id'];
|
223 |
+
}; break;
|
224 |
+
case 'category': {
|
225 |
+
if( empty($instance['subscribe_category_id']) || !is_numeric($instance['subscribe_category_id']) )
|
226 |
+
return;
|
227 |
+
$ExtraData['cat_id'] = $instance['subscribe_category_id'];
|
228 |
+
}; break;
|
229 |
+
default: {
|
230 |
+
// Doesn't matter, we'r using the default podcast channel
|
231 |
+
|
232 |
+
};
|
233 |
+
}
|
234 |
+
|
235 |
+
$Settings = powerpresssubscribe_get_settings( $ExtraData );
|
236 |
+
if( empty($Settings) )
|
237 |
+
return;
|
238 |
+
|
239 |
+
echo $args['before_widget'];
|
240 |
+
if ( ! empty( $instance['title'] ) ) {
|
241 |
+
echo $args['before_title'];
|
242 |
+
echo esc_html( $instance['title'] );
|
243 |
+
echo $args['after_title'];
|
244 |
+
}
|
245 |
+
|
246 |
+
echo powerpress_do_subscribe_sidebar_widget( $Settings );
|
247 |
+
echo $args['after_widget'];
|
248 |
+
return;
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
function powerpress_subscribe_register_widget() {
|
253 |
+
register_widget( 'PowerPressSubscribe_Widget' );
|
254 |
+
}
|
255 |
+
|
256 |
+
add_action( 'widgets_init', 'powerpress_subscribe_register_widget' );
|
css/admin.css
CHANGED
@@ -2,28 +2,29 @@
|
|
2 |
.powerpress-notice,
|
3 |
div.powerpress-notice,
|
4 |
.wrap div.powerpress-notice {
|
5 |
-
margin
|
6 |
-
|
7 |
line-height: 29px;
|
8 |
font-size: 12px;
|
9 |
border-width: 1px;
|
10 |
border-style: solid;
|
11 |
font-weight: bold;
|
|
|
12 |
}
|
13 |
.powerpress-error,
|
14 |
div.powerpress-error,
|
15 |
.wrap div.powerpress-error {
|
16 |
-
margin
|
17 |
-
|
18 |
line-height: 29px;
|
19 |
font-size: 12px;
|
20 |
border-width: 1px;
|
21 |
border-style: solid;
|
22 |
font-weight: bold;
|
23 |
-
|
24 |
}
|
25 |
#powerpress_settings {
|
26 |
-
background-image:url(
|
27 |
background-repeat: no-repeat;
|
28 |
background-position: bottom right;
|
29 |
}
|
@@ -243,11 +244,21 @@ padding-bottom: 15px;
|
|
243 |
left: 0;
|
244 |
position: absolute;
|
245 |
}
|
|
|
|
|
|
|
|
|
246 |
#powerpress_steps p {
|
247 |
font-size: 20px;
|
248 |
margin: 20px 4px;
|
249 |
color: #CCCCCC;
|
250 |
-
line-height:120
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
}
|
252 |
#powerpress_steps a {
|
253 |
color: #CCCCCC;
|
@@ -260,7 +271,6 @@ padding-bottom: 15px;
|
|
260 |
|
261 |
#powerpress_steps .active-step h3 {
|
262 |
color: #337EC9;
|
263 |
-
|
264 |
}
|
265 |
#powerpress_steps .active-step p,
|
266 |
#powerpress_steps .active-step a {
|
@@ -376,5 +386,3 @@ padding-bottom: 15px;
|
|
376 |
margin-right: 10px;
|
377 |
}
|
378 |
}
|
379 |
-
|
380 |
-
|
2 |
.powerpress-notice,
|
3 |
div.powerpress-notice,
|
4 |
.wrap div.powerpress-notice {
|
5 |
+
margin: 20px 0 10px;
|
6 |
+
padding: 0 5px;
|
7 |
line-height: 29px;
|
8 |
font-size: 12px;
|
9 |
border-width: 1px;
|
10 |
border-style: solid;
|
11 |
font-weight: bold;
|
12 |
+
/* background-color: #FFFFE0; /* yellow */
|
13 |
}
|
14 |
.powerpress-error,
|
15 |
div.powerpress-error,
|
16 |
.wrap div.powerpress-error {
|
17 |
+
margin: 20px 5px 10px;
|
18 |
+
padding: 0 10px;
|
19 |
line-height: 29px;
|
20 |
font-size: 12px;
|
21 |
border-width: 1px;
|
22 |
border-style: solid;
|
23 |
font-weight: bold;
|
24 |
+
/* background-color: #ffebe8; /* red */
|
25 |
}
|
26 |
#powerpress_settings {
|
27 |
+
background-image:url(//images.blubrry.com/powerpress/blubrry_logo5.png);
|
28 |
background-repeat: no-repeat;
|
29 |
background-position: bottom right;
|
30 |
}
|
244 |
left: 0;
|
245 |
position: absolute;
|
246 |
}
|
247 |
+
#powerpress_single_step h3 {
|
248 |
+
color: #337EC9;
|
249 |
+
font-size: 24px;
|
250 |
+
}
|
251 |
#powerpress_steps p {
|
252 |
font-size: 20px;
|
253 |
margin: 20px 4px;
|
254 |
color: #CCCCCC;
|
255 |
+
line-height:120%;
|
256 |
+
}
|
257 |
+
#powerpress_steps p.normal {
|
258 |
+
font-size: 14px;
|
259 |
+
margin: 8px 0 8px 8px;
|
260 |
+
color: #CCCCCC;
|
261 |
+
line-height: normal;
|
262 |
}
|
263 |
#powerpress_steps a {
|
264 |
color: #CCCCCC;
|
271 |
|
272 |
#powerpress_steps .active-step h3 {
|
273 |
color: #337EC9;
|
|
|
274 |
}
|
275 |
#powerpress_steps .active-step p,
|
276 |
#powerpress_steps .active-step a {
|
386 |
margin-right: 10px;
|
387 |
}
|
388 |
}
|
|
|
|
css/dashboard.css
CHANGED
@@ -42,4 +42,26 @@
|
|
42 |
#powerpress_dashboard_notice_3 a.browse-happy-link,
|
43 |
#powerpress_dashboard_notice_3 a.update-browser-link {
|
44 |
text-shadow: #d29a04 0 1px 0;
|
45 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
#powerpress_dashboard_notice_3 a.browse-happy-link,
|
43 |
#powerpress_dashboard_notice_3 a.update-browser-link {
|
44 |
text-shadow: #d29a04 0 1px 0;
|
45 |
+
}
|
46 |
+
|
47 |
+
/*
|
48 |
+
.powerpressadmin-mejs-video {
|
49 |
+
width: auto;
|
50 |
+
}
|
51 |
+
.powerpressadmin-mejs-video .powerpress_player {
|
52 |
+
position: relative;
|
53 |
+
width: 100%;
|
54 |
+
height: 0;
|
55 |
+
padding-bottom: 56.2%;
|
56 |
+
}
|
57 |
+
|
58 |
+
.powerpressadmin-mejs-video .powerpress_player .wp-video,
|
59 |
+
.powerpressadmin-mejs-video .powerpress_player .mejs-container,
|
60 |
+
.powerpressadmin-mejs-video .powerpress_player video {
|
61 |
+
position: absolute;
|
62 |
+
top: 0;
|
63 |
+
left: 0;
|
64 |
+
width: 100% !important;
|
65 |
+
height: 100% !important;
|
66 |
+
}
|
67 |
+
*/
|
css/subscribe.css
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* subscribe.css PowerPress subscribe widget */
|
2 |
+
|
3 |
+
.pp-sub-widget {
|
4 |
+
width: 100%;
|
5 |
+
max-width: 800px;
|
6 |
+
margin: 10px auto;
|
7 |
+
border: 3px solid #787878;
|
8 |
+
font-family: Sans-serif;
|
9 |
+
background-color: #FFFFFF;
|
10 |
+
}
|
11 |
+
.pp-sub-widget .pp-sub-bx {
|
12 |
+
-webkit-column-count: 2;
|
13 |
+
-moz-column-count: 2;
|
14 |
+
column-count: 2;
|
15 |
+
-webkit-column-gap: 20px;
|
16 |
+
-moz-column-gap: 20px;
|
17 |
+
column-gap: 20px;
|
18 |
+
width: auto;
|
19 |
+
height: auto;
|
20 |
+
margin: 0 10px -10px 10px;
|
21 |
+
}
|
22 |
+
|
23 |
+
.pp-sub-widget div.pp-sub-h {
|
24 |
+
margin: 10px 10px 0 10px;
|
25 |
+
font-size: 90%;
|
26 |
+
font-weight: bold;
|
27 |
+
color: #666666;
|
28 |
+
}
|
29 |
+
.pp-sub-widget h2.pp-sub-t {
|
30 |
+
margin: 10px 10px 0 10px !important;
|
31 |
+
padding: 0 !important;
|
32 |
+
font-size: 200% !important;
|
33 |
+
color: #222222 !important;
|
34 |
+
}
|
35 |
+
|
36 |
+
.pp-sub-widget a.pp-sub-btn {
|
37 |
+
width: 100%;
|
38 |
+
height: 48px;
|
39 |
+
padding: 0px 0px 0px 0px;
|
40 |
+
color: #FFFFFF;
|
41 |
+
display: inline-block;
|
42 |
+
margin: 10px 0 10px 0;
|
43 |
+
text-decoration: none;
|
44 |
+
text-align:left;
|
45 |
+
vertical-align: middle;
|
46 |
+
line-height: 48px;
|
47 |
+
font-size: 90% !important;
|
48 |
+
font-weight: bold !important;
|
49 |
+
overflow: hidden;
|
50 |
+
border-radius: 1px;
|
51 |
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
|
52 |
+
}
|
53 |
+
|
54 |
+
.pp-sub-widget .pp-sub-btn-l {
|
55 |
+
|
56 |
+
}
|
57 |
+
body .entry-content .pp-sub-widget a:link,
|
58 |
+
body .entry-content .pp-sub-widget a:visited,
|
59 |
+
body .entry-content .pp-sub-widget a:active,
|
60 |
+
body .entry-content .pp-sub-widget a:hover,
|
61 |
+
body .pp-sub-widget a:link,
|
62 |
+
body .pp-sub-widget a:visited,
|
63 |
+
body .pp-sub-widget a:active,
|
64 |
+
body .pp-sub-widget a:hover {
|
65 |
+
text-decoration: none !important;
|
66 |
+
color: #FFFFFF !important;
|
67 |
+
}
|
68 |
+
|
69 |
+
.pp-sub-widget img.pp-sub-l {
|
70 |
+
width: 100% !important;
|
71 |
+
height: auto !important;
|
72 |
+
max-width: 300px;
|
73 |
+
padding: 0;
|
74 |
+
margin: 10px 0;
|
75 |
+
|
76 |
+
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
|
77 |
+
}
|
78 |
+
.pp-sub-widget .pp-sub-btns {
|
79 |
+
width: 100% !important;
|
80 |
+
margin: 0;
|
81 |
+
padding: 0;
|
82 |
+
display: inline-block;
|
83 |
+
}
|
84 |
+
.pp-sub-widget .pp-sub-m {
|
85 |
+
clear: both;
|
86 |
+
margin: 10px;
|
87 |
+
}
|
88 |
+
.pp-sub-widget p.pp-sub-m-p {
|
89 |
+
margin: 0;
|
90 |
+
font-size: 90%;
|
91 |
+
color: #222222;
|
92 |
+
}
|
93 |
+
.pp-sub-widget .pp-sub-m-i {
|
94 |
+
width: 80%;
|
95 |
+
color: #333333;
|
96 |
+
font-size: 85%;
|
97 |
+
border: 1px solid #999999;
|
98 |
+
padding: 5px;
|
99 |
+
}
|
100 |
+
@media screen and (max-width: 400px) {
|
101 |
+
.pp-sub-widget .pp-sub-bx {
|
102 |
+
-webkit-column-count: 1;
|
103 |
+
-moz-column-count: 1;
|
104 |
+
column-count: 1;
|
105 |
+
-webkit-column-gap: 0;
|
106 |
+
-moz-column-gap: 0;
|
107 |
+
column-gap: 0;
|
108 |
+
}
|
109 |
+
.pp-sub-widget .pp-sub-t {
|
110 |
+
font-size: 150%;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
.pp-sub-widget-dark a,
|
114 |
+
.pp-sub-widget-modern a {
|
115 |
+
background-color: #222222;
|
116 |
+
}
|
117 |
+
.pp-sub-widget-modern a.pp-sub-itunes {
|
118 |
+
background-color: #732BBE;
|
119 |
+
}
|
120 |
+
.pp-sub-widget-modern a.pp-sub-pr,
|
121 |
+
.pp-sub-widget-modern a.pp-sub-email {
|
122 |
+
background-color: #337EC9;
|
123 |
+
}
|
124 |
+
.pp-sub-widget-modern a.pp-sub-bp,
|
125 |
+
.pp-sub-widget-modern a.pp-sub-rss {
|
126 |
+
background-color: #FF8800;
|
127 |
+
}
|
128 |
+
|
129 |
+
.pp-sub-widget-modern div.pp-sub-h,
|
130 |
+
.pp-sub-widget-modern p.pp-sub-m-p {
|
131 |
+
color: #337EC9;
|
132 |
+
}
|
133 |
+
|
134 |
+
.pp-sub-widget .pp-sub-ic {
|
135 |
+
width: 48px;
|
136 |
+
height: 48px;
|
137 |
+
border: 0;
|
138 |
+
display: inline-block;
|
139 |
+
vertical-align: middle;
|
140 |
+
margin-right: 2px;
|
141 |
+
}
|
142 |
+
.pp-sub-ic {
|
143 |
+
background-image: url(../images/spriteStandard.png);
|
144 |
+
background-repeat: no-repeat;
|
145 |
+
background-size: 294px;
|
146 |
+
}
|
147 |
+
.pp-sub-itunes .pp-sub-ic {
|
148 |
+
background-position: -49px 0;
|
149 |
+
}
|
150 |
+
.pp-sub-rss .pp-sub-ic {
|
151 |
+
background-position: 0 -49px;
|
152 |
+
}
|
153 |
+
.pp-sub-email .pp-sub-ic {
|
154 |
+
background-position: -196px -49px;
|
155 |
+
}
|
156 |
+
.pp-sub-pr .pp-sub-ic {
|
157 |
+
background-position: -196px 0;
|
158 |
+
}
|
159 |
+
.pp-sub-bp .pp-sub-ic {
|
160 |
+
background-position: -147px 0;
|
161 |
+
}
|
162 |
+
|
163 |
+
/* Retina-specific stuff here */
|
164 |
+
@media only screen and (-webkit-min-device-pixel-ratio: 2.0),
|
165 |
+
only screen and (min--moz-device-pixel-ratio: 2.0),
|
166 |
+
only screen and (-o-min-device-pixel-ratio: 200/100),
|
167 |
+
only screen and (min-device-pixel-ratio: 2.0) {
|
168 |
+
.pp-sub-ic {
|
169 |
+
background-image: url(../images/spriteRetina.png);
|
170 |
+
}
|
171 |
+
}
|
getid3/getid3.lib.php
CHANGED
@@ -1,1317 +1,1379 @@
|
|
1 |
-
<?php
|
2 |
-
/////////////////////////////////////////////////////////////////
|
3 |
-
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
-
// available at http://getid3.sourceforge.net //
|
5 |
-
// or http://www.getid3.org //
|
6 |
-
|
7 |
-
|
8 |
-
//
|
9 |
-
//
|
10 |
-
//
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
//
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
if
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
$
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
$
|
120 |
-
|
121 |
-
|
122 |
-
$
|
123 |
-
$
|
124 |
-
$binarypointnumber =
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
$
|
136 |
-
$
|
137 |
-
$
|
138 |
-
|
139 |
-
|
140 |
-
$
|
141 |
-
$
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
$
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
$
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
$
|
172 |
-
$
|
173 |
-
$
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
//
|
187 |
-
// http://www.
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
$
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
//
|
209 |
-
|
210 |
-
$
|
211 |
-
$
|
212 |
-
$
|
213 |
-
$
|
214 |
-
$
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
$
|
227 |
-
$
|
228 |
-
$
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
$
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
$intvalue
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
}
|
287 |
-
}
|
288 |
-
return
|
289 |
-
}
|
290 |
-
|
291 |
-
|
292 |
-
static function LittleEndian2Int($byteword, $signed=false) {
|
293 |
-
return
|
294 |
-
}
|
295 |
-
|
296 |
-
|
297 |
-
static function BigEndian2Bin($byteword) {
|
298 |
-
$binvalue = '';
|
299 |
-
$bytewordlen = strlen($byteword);
|
300 |
-
for ($i = 0; $i < $bytewordlen; $i++) {
|
301 |
-
$binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
|
302 |
-
}
|
303 |
-
return $binvalue;
|
304 |
-
}
|
305 |
-
|
306 |
-
|
307 |
-
static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
|
308 |
-
if ($number < 0) {
|
309 |
-
throw new Exception('ERROR:
|
310 |
-
}
|
311 |
-
$maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
|
312 |
-
$intstring = '';
|
313 |
-
if ($signed) {
|
314 |
-
if ($minbytes > PHP_INT_SIZE) {
|
315 |
-
throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in
|
316 |
-
}
|
317 |
-
$number = $number & (0x80 << (8 * ($minbytes - 1)));
|
318 |
-
}
|
319 |
-
while ($number != 0) {
|
320 |
-
$quotient = ($number / ($maskbyte + 1));
|
321 |
-
$intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring;
|
322 |
-
$number = floor($quotient);
|
323 |
-
}
|
324 |
-
return str_pad($intstring, $minbytes, "\x00", STR_PAD_LEFT);
|
325 |
-
}
|
326 |
-
|
327 |
-
|
328 |
-
static function Dec2Bin($number) {
|
329 |
-
while ($number >= 256) {
|
330 |
-
$bytes[] = (($number / 256) - (floor($number / 256))) * 256;
|
331 |
-
$number = floor($number / 256);
|
332 |
-
}
|
333 |
-
$bytes[] = $number;
|
334 |
-
$binstring = '';
|
335 |
-
for ($i = 0; $i < count($bytes); $i++) {
|
336 |
-
$binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;
|
337 |
-
}
|
338 |
-
return $binstring;
|
339 |
-
}
|
340 |
-
|
341 |
-
|
342 |
-
static function Bin2Dec($binstring, $signed=false) {
|
343 |
-
$signmult = 1;
|
344 |
-
if ($signed) {
|
345 |
-
if ($binstring{0} == '1') {
|
346 |
-
$signmult = -1;
|
347 |
-
}
|
348 |
-
$binstring = substr($binstring, 1);
|
349 |
-
}
|
350 |
-
$decvalue = 0;
|
351 |
-
for ($i = 0; $i < strlen($binstring); $i++) {
|
352 |
-
$decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
|
353 |
-
}
|
354 |
-
return
|
355 |
-
}
|
356 |
-
|
357 |
-
|
358 |
-
static function Bin2String($binstring) {
|
359 |
-
// return 'hi' for input of '0110100001101001'
|
360 |
-
$string = '';
|
361 |
-
$binstringreversed = strrev($binstring);
|
362 |
-
for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
|
363 |
-
$string = chr(
|
364 |
-
}
|
365 |
-
return $string;
|
366 |
-
}
|
367 |
-
|
368 |
-
|
369 |
-
static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
|
370 |
-
$intstring = '';
|
371 |
-
while ($number > 0) {
|
372 |
-
if ($synchsafe) {
|
373 |
-
$intstring = $intstring.chr($number & 127);
|
374 |
-
$number >>= 7;
|
375 |
-
} else {
|
376 |
-
$intstring = $intstring.chr($number & 255);
|
377 |
-
$number >>= 8;
|
378 |
-
}
|
379 |
-
}
|
380 |
-
return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
|
381 |
-
}
|
382 |
-
|
383 |
-
|
384 |
-
static function array_merge_clobber($array1, $array2) {
|
385 |
-
// written by
|
386 |
-
// taken from http://www.php.net/manual/en/function.array-merge-recursive.php
|
387 |
-
if (!is_array($array1) || !is_array($array2)) {
|
388 |
-
return false;
|
389 |
-
}
|
390 |
-
$newarray = $array1;
|
391 |
-
foreach ($array2 as $key => $val) {
|
392 |
-
if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
|
393 |
-
$newarray[$key] =
|
394 |
-
} else {
|
395 |
-
$newarray[$key] = $val;
|
396 |
-
}
|
397 |
-
}
|
398 |
-
return $newarray;
|
399 |
-
}
|
400 |
-
|
401 |
-
|
402 |
-
static function array_merge_noclobber($array1, $array2) {
|
403 |
-
if (!is_array($array1) || !is_array($array2)) {
|
404 |
-
return false;
|
405 |
-
}
|
406 |
-
$newarray = $array1;
|
407 |
-
foreach ($array2 as $key => $val) {
|
408 |
-
if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
|
409 |
-
$newarray[$key] =
|
410 |
-
} elseif (!isset($newarray[$key])) {
|
411 |
-
$newarray[$key] = $val;
|
412 |
-
}
|
413 |
-
}
|
414 |
-
return $newarray;
|
415 |
-
}
|
416 |
-
|
417 |
-
|
418 |
-
static function ksort_recursive(&$theArray) {
|
419 |
-
ksort($theArray);
|
420 |
-
foreach ($theArray as $key => $value) {
|
421 |
-
if (is_array($value)) {
|
422 |
-
self::ksort_recursive($theArray[$key]);
|
423 |
-
}
|
424 |
-
}
|
425 |
-
return true;
|
426 |
-
}
|
427 |
-
|
428 |
-
static function fileextension($filename, $numextensions=1) {
|
429 |
-
if (strstr($filename, '.')) {
|
430 |
-
$reversedfilename = strrev($filename);
|
431 |
-
$offset = 0;
|
432 |
-
for ($i = 0; $i < $numextensions; $i++) {
|
433 |
-
$offset = strpos($reversedfilename, '.', $offset + 1);
|
434 |
-
if ($offset === false) {
|
435 |
-
return '';
|
436 |
-
}
|
437 |
-
}
|
438 |
-
return strrev(substr($reversedfilename, 0, $offset));
|
439 |
-
}
|
440 |
-
return '';
|
441 |
-
}
|
442 |
-
|
443 |
-
|
444 |
-
static function PlaytimeString($seconds) {
|
445 |
-
$sign = (($seconds < 0) ? '-' : '');
|
446 |
-
$seconds = abs($seconds);
|
447 |
-
$H = floor( $seconds / 3600);
|
448 |
-
$M = floor(($seconds - (3600 * $H) ) / 60);
|
449 |
-
$S = round( $seconds - (3600 * $H) - (60 * $M) );
|
450 |
-
return $sign.($H ? $H.':' : '').($H ? str_pad($M, 2, '0', STR_PAD_LEFT) : intval($M)).':'.str_pad($S, 2, 0, STR_PAD_LEFT);
|
451 |
-
}
|
452 |
-
|
453 |
-
|
454 |
-
static function DateMac2Unix($macdate) {
|
455 |
-
// Macintosh timestamp: seconds since 00:00h January 1, 1904
|
456 |
-
// UNIX timestamp: seconds since 00:00h January 1, 1970
|
457 |
-
return
|
458 |
-
}
|
459 |
-
|
460 |
-
|
461 |
-
static function FixedPoint8_8($rawdata) {
|
462 |
-
return
|
463 |
-
}
|
464 |
-
|
465 |
-
|
466 |
-
static function FixedPoint16_16($rawdata) {
|
467 |
-
return
|
468 |
-
}
|
469 |
-
|
470 |
-
|
471 |
-
static function FixedPoint2_30($rawdata) {
|
472 |
-
$binarystring =
|
473 |
-
return
|
474 |
-
}
|
475 |
-
|
476 |
-
|
477 |
-
static function CreateDeepArray($ArrayPath, $Separator, $Value) {
|
478 |
-
// assigns $Value to a nested array path:
|
479 |
-
// $foo =
|
480 |
-
// is the same as:
|
481 |
-
// $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
|
482 |
-
// or
|
483 |
-
// $foo['path']['to']['my'] = 'file.txt';
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
$ReturnedArray[
|
489 |
-
}
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
$
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
$
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
$
|
557 |
-
$
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
$
|
564 |
-
$
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
$commandline
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
$commandline
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
}
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
}
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
}
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
}
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
$newcharstring
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
$newcharstring
|
678 |
-
$newcharstring .= chr(($charval
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
$
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
$offset
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
$offset
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
$offset
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
return
|
927 |
-
}
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
return
|
938 |
-
}
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
$ConversionFunctionList['ISO-8859-1']['UTF-
|
971 |
-
$ConversionFunctionList['ISO-8859-1']['UTF-
|
972 |
-
$ConversionFunctionList['
|
973 |
-
$ConversionFunctionList['
|
974 |
-
$ConversionFunctionList['UTF-8']['
|
975 |
-
$ConversionFunctionList['UTF-8']['UTF-
|
976 |
-
$ConversionFunctionList['UTF-
|
977 |
-
$ConversionFunctionList['UTF-
|
978 |
-
$ConversionFunctionList['UTF-
|
979 |
-
$ConversionFunctionList['UTF-
|
980 |
-
$ConversionFunctionList['UTF-
|
981 |
-
$ConversionFunctionList['UTF-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
$
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
case '
|
1012 |
-
case '
|
1013 |
-
case '
|
1014 |
-
case '
|
1015 |
-
case '
|
1016 |
-
case '
|
1017 |
-
case '
|
1018 |
-
case '
|
1019 |
-
case '
|
1020 |
-
case '
|
1021 |
-
case '
|
1022 |
-
case '
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
case '
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
if (
|
1047 |
-
$
|
1048 |
-
}
|
1049 |
-
$
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
$
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
break;
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
$
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
$
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
static function
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
$
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
$
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
$
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/////////////////////////////////////////////////////////////////
|
3 |
+
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
+
// available at http://getid3.sourceforge.net //
|
5 |
+
// or http://www.getid3.org //
|
6 |
+
// also https://github.com/JamesHeinrich/getID3 //
|
7 |
+
/////////////////////////////////////////////////////////////////
|
8 |
+
// //
|
9 |
+
// getid3.lib.php - part of getID3() //
|
10 |
+
// See readme.txt for more details //
|
11 |
+
// ///
|
12 |
+
/////////////////////////////////////////////////////////////////
|
13 |
+
|
14 |
+
|
15 |
+
class getid3_lib
|
16 |
+
{
|
17 |
+
|
18 |
+
public static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') {
|
19 |
+
$returnstring = '';
|
20 |
+
for ($i = 0; $i < strlen($string); $i++) {
|
21 |
+
if ($hex) {
|
22 |
+
$returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
|
23 |
+
} else {
|
24 |
+
$returnstring .= ' '.(preg_match("#[\x20-\x7E]#", $string{$i}) ? $string{$i} : '¤');
|
25 |
+
}
|
26 |
+
if ($spaces) {
|
27 |
+
$returnstring .= ' ';
|
28 |
+
}
|
29 |
+
}
|
30 |
+
if (!empty($htmlencoding)) {
|
31 |
+
if ($htmlencoding === true) {
|
32 |
+
$htmlencoding = 'UTF-8'; // prior to getID3 v1.9.0 the function's 4th parameter was boolean
|
33 |
+
}
|
34 |
+
$returnstring = htmlentities($returnstring, ENT_QUOTES, $htmlencoding);
|
35 |
+
}
|
36 |
+
return $returnstring;
|
37 |
+
}
|
38 |
+
|
39 |
+
public static function trunc($floatnumber) {
|
40 |
+
// truncates a floating-point number at the decimal point
|
41 |
+
// returns int (if possible, otherwise float)
|
42 |
+
if ($floatnumber >= 1) {
|
43 |
+
$truncatednumber = floor($floatnumber);
|
44 |
+
} elseif ($floatnumber <= -1) {
|
45 |
+
$truncatednumber = ceil($floatnumber);
|
46 |
+
} else {
|
47 |
+
$truncatednumber = 0;
|
48 |
+
}
|
49 |
+
if (self::intValueSupported($truncatednumber)) {
|
50 |
+
$truncatednumber = (int) $truncatednumber;
|
51 |
+
}
|
52 |
+
return $truncatednumber;
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
public static function safe_inc(&$variable, $increment=1) {
|
57 |
+
if (isset($variable)) {
|
58 |
+
$variable += $increment;
|
59 |
+
} else {
|
60 |
+
$variable = $increment;
|
61 |
+
}
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
|
65 |
+
public static function CastAsInt($floatnum) {
|
66 |
+
// convert to float if not already
|
67 |
+
$floatnum = (float) $floatnum;
|
68 |
+
|
69 |
+
// convert a float to type int, only if possible
|
70 |
+
if (self::trunc($floatnum) == $floatnum) {
|
71 |
+
// it's not floating point
|
72 |
+
if (self::intValueSupported($floatnum)) {
|
73 |
+
// it's within int range
|
74 |
+
$floatnum = (int) $floatnum;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
return $floatnum;
|
78 |
+
}
|
79 |
+
|
80 |
+
public static function intValueSupported($num) {
|
81 |
+
// check if integers are 64-bit
|
82 |
+
static $hasINT64 = null;
|
83 |
+
if ($hasINT64 === null) { // 10x faster than is_null()
|
84 |
+
$hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1
|
85 |
+
if (!$hasINT64 && !defined('PHP_INT_MIN')) {
|
86 |
+
define('PHP_INT_MIN', ~PHP_INT_MAX);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
// if integers are 64-bit - no other check required
|
90 |
+
if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) {
|
91 |
+
return true;
|
92 |
+
}
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
|
96 |
+
public static function DecimalizeFraction($fraction) {
|
97 |
+
list($numerator, $denominator) = explode('/', $fraction);
|
98 |
+
return $numerator / ($denominator ? $denominator : 1);
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
public static function DecimalBinary2Float($binarynumerator) {
|
103 |
+
$numerator = self::Bin2Dec($binarynumerator);
|
104 |
+
$denominator = self::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
|
105 |
+
return ($numerator / $denominator);
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
public static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
|
110 |
+
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
|
111 |
+
if (strpos($binarypointnumber, '.') === false) {
|
112 |
+
$binarypointnumber = '0.'.$binarypointnumber;
|
113 |
+
} elseif ($binarypointnumber{0} == '.') {
|
114 |
+
$binarypointnumber = '0'.$binarypointnumber;
|
115 |
+
}
|
116 |
+
$exponent = 0;
|
117 |
+
while (($binarypointnumber{0} != '1') || (substr($binarypointnumber, 1, 1) != '.')) {
|
118 |
+
if (substr($binarypointnumber, 1, 1) == '.') {
|
119 |
+
$exponent--;
|
120 |
+
$binarypointnumber = substr($binarypointnumber, 2, 1).'.'.substr($binarypointnumber, 3);
|
121 |
+
} else {
|
122 |
+
$pointpos = strpos($binarypointnumber, '.');
|
123 |
+
$exponent += ($pointpos - 1);
|
124 |
+
$binarypointnumber = str_replace('.', '', $binarypointnumber);
|
125 |
+
$binarypointnumber = $binarypointnumber{0}.'.'.substr($binarypointnumber, 1);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
$binarypointnumber = str_pad(substr($binarypointnumber, 0, $maxbits + 2), $maxbits + 2, '0', STR_PAD_RIGHT);
|
129 |
+
return array('normalized'=>$binarypointnumber, 'exponent'=>(int) $exponent);
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
public static function Float2BinaryDecimal($floatvalue) {
|
134 |
+
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
|
135 |
+
$maxbits = 128; // to how many bits of precision should the calculations be taken?
|
136 |
+
$intpart = self::trunc($floatvalue);
|
137 |
+
$floatpart = abs($floatvalue - $intpart);
|
138 |
+
$pointbitstring = '';
|
139 |
+
while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
|
140 |
+
$floatpart *= 2;
|
141 |
+
$pointbitstring .= (string) self::trunc($floatpart);
|
142 |
+
$floatpart -= self::trunc($floatpart);
|
143 |
+
}
|
144 |
+
$binarypointnumber = decbin($intpart).'.'.$pointbitstring;
|
145 |
+
return $binarypointnumber;
|
146 |
+
}
|
147 |
+
|
148 |
+
|
149 |
+
public static function Float2String($floatvalue, $bits) {
|
150 |
+
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
|
151 |
+
switch ($bits) {
|
152 |
+
case 32:
|
153 |
+
$exponentbits = 8;
|
154 |
+
$fractionbits = 23;
|
155 |
+
break;
|
156 |
+
|
157 |
+
case 64:
|
158 |
+
$exponentbits = 11;
|
159 |
+
$fractionbits = 52;
|
160 |
+
break;
|
161 |
+
|
162 |
+
default:
|
163 |
+
return false;
|
164 |
+
break;
|
165 |
+
}
|
166 |
+
if ($floatvalue >= 0) {
|
167 |
+
$signbit = '0';
|
168 |
+
} else {
|
169 |
+
$signbit = '1';
|
170 |
+
}
|
171 |
+
$normalizedbinary = self::NormalizeBinaryPoint(self::Float2BinaryDecimal($floatvalue), $fractionbits);
|
172 |
+
$biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent']; // (127 or 1023) +/- exponent
|
173 |
+
$exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT);
|
174 |
+
$fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT);
|
175 |
+
|
176 |
+
return self::BigEndian2String(self::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
|
177 |
+
}
|
178 |
+
|
179 |
+
|
180 |
+
public static function LittleEndian2Float($byteword) {
|
181 |
+
return self::BigEndian2Float(strrev($byteword));
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
public static function BigEndian2Float($byteword) {
|
186 |
+
// ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
|
187 |
+
// http://www.psc.edu/general/software/packages/ieee/ieee.html
|
188 |
+
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
|
189 |
+
|
190 |
+
$bitword = self::BigEndian2Bin($byteword);
|
191 |
+
if (!$bitword) {
|
192 |
+
return 0;
|
193 |
+
}
|
194 |
+
$signbit = $bitword{0};
|
195 |
+
|
196 |
+
switch (strlen($byteword) * 8) {
|
197 |
+
case 32:
|
198 |
+
$exponentbits = 8;
|
199 |
+
$fractionbits = 23;
|
200 |
+
break;
|
201 |
+
|
202 |
+
case 64:
|
203 |
+
$exponentbits = 11;
|
204 |
+
$fractionbits = 52;
|
205 |
+
break;
|
206 |
+
|
207 |
+
case 80:
|
208 |
+
// 80-bit Apple SANE format
|
209 |
+
// http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
|
210 |
+
$exponentstring = substr($bitword, 1, 15);
|
211 |
+
$isnormalized = intval($bitword{16});
|
212 |
+
$fractionstring = substr($bitword, 17, 63);
|
213 |
+
$exponent = pow(2, self::Bin2Dec($exponentstring) - 16383);
|
214 |
+
$fraction = $isnormalized + self::DecimalBinary2Float($fractionstring);
|
215 |
+
$floatvalue = $exponent * $fraction;
|
216 |
+
if ($signbit == '1') {
|
217 |
+
$floatvalue *= -1;
|
218 |
+
}
|
219 |
+
return $floatvalue;
|
220 |
+
break;
|
221 |
+
|
222 |
+
default:
|
223 |
+
return false;
|
224 |
+
break;
|
225 |
+
}
|
226 |
+
$exponentstring = substr($bitword, 1, $exponentbits);
|
227 |
+
$fractionstring = substr($bitword, $exponentbits + 1, $fractionbits);
|
228 |
+
$exponent = self::Bin2Dec($exponentstring);
|
229 |
+
$fraction = self::Bin2Dec($fractionstring);
|
230 |
+
|
231 |
+
if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
|
232 |
+
// Not a Number
|
233 |
+
$floatvalue = false;
|
234 |
+
} elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
|
235 |
+
if ($signbit == '1') {
|
236 |
+
$floatvalue = '-infinity';
|
237 |
+
} else {
|
238 |
+
$floatvalue = '+infinity';
|
239 |
+
}
|
240 |
+
} elseif (($exponent == 0) && ($fraction == 0)) {
|
241 |
+
if ($signbit == '1') {
|
242 |
+
$floatvalue = -0;
|
243 |
+
} else {
|
244 |
+
$floatvalue = 0;
|
245 |
+
}
|
246 |
+
$floatvalue = ($signbit ? 0 : -0);
|
247 |
+
} elseif (($exponent == 0) && ($fraction != 0)) {
|
248 |
+
// These are 'unnormalized' values
|
249 |
+
$floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * self::DecimalBinary2Float($fractionstring);
|
250 |
+
if ($signbit == '1') {
|
251 |
+
$floatvalue *= -1;
|
252 |
+
}
|
253 |
+
} elseif ($exponent != 0) {
|
254 |
+
$floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + self::DecimalBinary2Float($fractionstring));
|
255 |
+
if ($signbit == '1') {
|
256 |
+
$floatvalue *= -1;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
return (float) $floatvalue;
|
260 |
+
}
|
261 |
+
|
262 |
+
|
263 |
+
public static function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
|
264 |
+
$intvalue = 0;
|
265 |
+
$bytewordlen = strlen($byteword);
|
266 |
+
if ($bytewordlen == 0) {
|
267 |
+
return false;
|
268 |
+
}
|
269 |
+
for ($i = 0; $i < $bytewordlen; $i++) {
|
270 |
+
if ($synchsafe) { // disregard MSB, effectively 7-bit bytes
|
271 |
+
//$intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7); // faster, but runs into problems past 2^31 on 32-bit systems
|
272 |
+
$intvalue += (ord($byteword{$i}) & 0x7F) * pow(2, ($bytewordlen - 1 - $i) * 7);
|
273 |
+
} else {
|
274 |
+
$intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
|
275 |
+
}
|
276 |
+
}
|
277 |
+
if ($signed && !$synchsafe) {
|
278 |
+
// synchsafe ints are not allowed to be signed
|
279 |
+
if ($bytewordlen <= PHP_INT_SIZE) {
|
280 |
+
$signMaskBit = 0x80 << (8 * ($bytewordlen - 1));
|
281 |
+
if ($intvalue & $signMaskBit) {
|
282 |
+
$intvalue = 0 - ($intvalue & ($signMaskBit - 1));
|
283 |
+
}
|
284 |
+
} else {
|
285 |
+
throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in self::BigEndian2Int()');
|
286 |
+
}
|
287 |
+
}
|
288 |
+
return self::CastAsInt($intvalue);
|
289 |
+
}
|
290 |
+
|
291 |
+
|
292 |
+
public static function LittleEndian2Int($byteword, $signed=false) {
|
293 |
+
return self::BigEndian2Int(strrev($byteword), false, $signed);
|
294 |
+
}
|
295 |
+
|
296 |
+
|
297 |
+
public static function BigEndian2Bin($byteword) {
|
298 |
+
$binvalue = '';
|
299 |
+
$bytewordlen = strlen($byteword);
|
300 |
+
for ($i = 0; $i < $bytewordlen; $i++) {
|
301 |
+
$binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
|
302 |
+
}
|
303 |
+
return $binvalue;
|
304 |
+
}
|
305 |
+
|
306 |
+
|
307 |
+
public static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
|
308 |
+
if ($number < 0) {
|
309 |
+
throw new Exception('ERROR: self::BigEndian2String() does not support negative numbers');
|
310 |
+
}
|
311 |
+
$maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
|
312 |
+
$intstring = '';
|
313 |
+
if ($signed) {
|
314 |
+
if ($minbytes > PHP_INT_SIZE) {
|
315 |
+
throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in self::BigEndian2String()');
|
316 |
+
}
|
317 |
+
$number = $number & (0x80 << (8 * ($minbytes - 1)));
|
318 |
+
}
|
319 |
+
while ($number != 0) {
|
320 |
+
$quotient = ($number / ($maskbyte + 1));
|
321 |
+
$intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring;
|
322 |
+
$number = floor($quotient);
|
323 |
+
}
|
324 |
+
return str_pad($intstring, $minbytes, "\x00", STR_PAD_LEFT);
|
325 |
+
}
|
326 |
+
|
327 |
+
|
328 |
+
public static function Dec2Bin($number) {
|
329 |
+
while ($number >= 256) {
|
330 |
+
$bytes[] = (($number / 256) - (floor($number / 256))) * 256;
|
331 |
+
$number = floor($number / 256);
|
332 |
+
}
|
333 |
+
$bytes[] = $number;
|
334 |
+
$binstring = '';
|
335 |
+
for ($i = 0; $i < count($bytes); $i++) {
|
336 |
+
$binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;
|
337 |
+
}
|
338 |
+
return $binstring;
|
339 |
+
}
|
340 |
+
|
341 |
+
|
342 |
+
public static function Bin2Dec($binstring, $signed=false) {
|
343 |
+
$signmult = 1;
|
344 |
+
if ($signed) {
|
345 |
+
if ($binstring{0} == '1') {
|
346 |
+
$signmult = -1;
|
347 |
+
}
|
348 |
+
$binstring = substr($binstring, 1);
|
349 |
+
}
|
350 |
+
$decvalue = 0;
|
351 |
+
for ($i = 0; $i < strlen($binstring); $i++) {
|
352 |
+
$decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
|
353 |
+
}
|
354 |
+
return self::CastAsInt($decvalue * $signmult);
|
355 |
+
}
|
356 |
+
|
357 |
+
|
358 |
+
public static function Bin2String($binstring) {
|
359 |
+
// return 'hi' for input of '0110100001101001'
|
360 |
+
$string = '';
|
361 |
+
$binstringreversed = strrev($binstring);
|
362 |
+
for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
|
363 |
+
$string = chr(self::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
|
364 |
+
}
|
365 |
+
return $string;
|
366 |
+
}
|
367 |
+
|
368 |
+
|
369 |
+
public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
|
370 |
+
$intstring = '';
|
371 |
+
while ($number > 0) {
|
372 |
+
if ($synchsafe) {
|
373 |
+
$intstring = $intstring.chr($number & 127);
|
374 |
+
$number >>= 7;
|
375 |
+
} else {
|
376 |
+
$intstring = $intstring.chr($number & 255);
|
377 |
+
$number >>= 8;
|
378 |
+
}
|
379 |
+
}
|
380 |
+
return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
|
381 |
+
}
|
382 |
+
|
383 |
+
|
384 |
+
public static function array_merge_clobber($array1, $array2) {
|
385 |
+
// written by kcØhireability*com
|
386 |
+
// taken from http://www.php.net/manual/en/function.array-merge-recursive.php
|
387 |
+
if (!is_array($array1) || !is_array($array2)) {
|
388 |
+
return false;
|
389 |
+
}
|
390 |
+
$newarray = $array1;
|
391 |
+
foreach ($array2 as $key => $val) {
|
392 |
+
if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
|
393 |
+
$newarray[$key] = self::array_merge_clobber($newarray[$key], $val);
|
394 |
+
} else {
|
395 |
+
$newarray[$key] = $val;
|
396 |
+
}
|
397 |
+
}
|
398 |
+
return $newarray;
|
399 |
+
}
|
400 |
+
|
401 |
+
|
402 |
+
public static function array_merge_noclobber($array1, $array2) {
|
403 |
+
if (!is_array($array1) || !is_array($array2)) {
|
404 |
+
return false;
|
405 |
+
}
|
406 |
+
$newarray = $array1;
|
407 |
+
foreach ($array2 as $key => $val) {
|
408 |
+
if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
|
409 |
+
$newarray[$key] = self::array_merge_noclobber($newarray[$key], $val);
|
410 |
+
} elseif (!isset($newarray[$key])) {
|
411 |
+
$newarray[$key] = $val;
|
412 |
+
}
|
413 |
+
}
|
414 |
+
return $newarray;
|
415 |
+
}
|
416 |
+
|
417 |
+
|
418 |
+
public static function ksort_recursive(&$theArray) {
|
419 |
+
ksort($theArray);
|
420 |
+
foreach ($theArray as $key => $value) {
|
421 |
+
if (is_array($value)) {
|
422 |
+
self::ksort_recursive($theArray[$key]);
|
423 |
+
}
|
424 |
+
}
|
425 |
+
return true;
|
426 |
+
}
|
427 |
+
|
428 |
+
public static function fileextension($filename, $numextensions=1) {
|
429 |
+
if (strstr($filename, '.')) {
|
430 |
+
$reversedfilename = strrev($filename);
|
431 |
+
$offset = 0;
|
432 |
+
for ($i = 0; $i < $numextensions; $i++) {
|
433 |
+
$offset = strpos($reversedfilename, '.', $offset + 1);
|
434 |
+
if ($offset === false) {
|
435 |
+
return '';
|
436 |
+
}
|
437 |
+
}
|
438 |
+
return strrev(substr($reversedfilename, 0, $offset));
|
439 |
+
}
|
440 |
+
return '';
|
441 |
+
}
|
442 |
+
|
443 |
+
|
444 |
+
public static function PlaytimeString($seconds) {
|
445 |
+
$sign = (($seconds < 0) ? '-' : '');
|
446 |
+
$seconds = round(abs($seconds));
|
447 |
+
$H = (int) floor( $seconds / 3600);
|
448 |
+
$M = (int) floor(($seconds - (3600 * $H) ) / 60);
|
449 |
+
$S = (int) round( $seconds - (3600 * $H) - (60 * $M) );
|
450 |
+
return $sign.($H ? $H.':' : '').($H ? str_pad($M, 2, '0', STR_PAD_LEFT) : intval($M)).':'.str_pad($S, 2, 0, STR_PAD_LEFT);
|
451 |
+
}
|
452 |
+
|
453 |
+
|
454 |
+
public static function DateMac2Unix($macdate) {
|
455 |
+
// Macintosh timestamp: seconds since 00:00h January 1, 1904
|
456 |
+
// UNIX timestamp: seconds since 00:00h January 1, 1970
|
457 |
+
return self::CastAsInt($macdate - 2082844800);
|
458 |
+
}
|
459 |
+
|
460 |
+
|
461 |
+
public static function FixedPoint8_8($rawdata) {
|
462 |
+
return self::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (self::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
|
463 |
+
}
|
464 |
+
|
465 |
+
|
466 |
+
public static function FixedPoint16_16($rawdata) {
|
467 |
+
return self::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (self::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
|
468 |
+
}
|
469 |
+
|
470 |
+
|
471 |
+
public static function FixedPoint2_30($rawdata) {
|
472 |
+
$binarystring = self::BigEndian2Bin($rawdata);
|
473 |
+
return self::Bin2Dec(substr($binarystring, 0, 2)) + (float) (self::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
|
474 |
+
}
|
475 |
+
|
476 |
+
|
477 |
+
public static function CreateDeepArray($ArrayPath, $Separator, $Value) {
|
478 |
+
// assigns $Value to a nested array path:
|
479 |
+
// $foo = self::CreateDeepArray('/path/to/my', '/', 'file.txt')
|
480 |
+
// is the same as:
|
481 |
+
// $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
|
482 |
+
// or
|
483 |
+
// $foo['path']['to']['my'] = 'file.txt';
|
484 |
+
$ArrayPath = ltrim($ArrayPath, $Separator);
|
485 |
+
if (($pos = strpos($ArrayPath, $Separator)) !== false) {
|
486 |
+
$ReturnedArray[substr($ArrayPath, 0, $pos)] = self::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
|
487 |
+
} else {
|
488 |
+
$ReturnedArray[$ArrayPath] = $Value;
|
489 |
+
}
|
490 |
+
return $ReturnedArray;
|
491 |
+
}
|
492 |
+
|
493 |
+
public static function array_max($arraydata, $returnkey=false) {
|
494 |
+
$maxvalue = false;
|
495 |
+
$maxkey = false;
|
496 |
+
foreach ($arraydata as $key => $value) {
|
497 |
+
if (!is_array($value)) {
|
498 |
+
if ($value > $maxvalue) {
|
499 |
+
$maxvalue = $value;
|
500 |
+
$maxkey = $key;
|
501 |
+
}
|
502 |
+
}
|
503 |
+
}
|
504 |
+
return ($returnkey ? $maxkey : $maxvalue);
|
505 |
+
}
|
506 |
+
|
507 |
+
public static function array_min($arraydata, $returnkey=false) {
|
508 |
+
$minvalue = false;
|
509 |
+
$minkey = false;
|
510 |
+
foreach ($arraydata as $key => $value) {
|
511 |
+
if (!is_array($value)) {
|
512 |
+
if ($value > $minvalue) {
|
513 |
+
$minvalue = $value;
|
514 |
+
$minkey = $key;
|
515 |
+
}
|
516 |
+
}
|
517 |
+
}
|
518 |
+
return ($returnkey ? $minkey : $minvalue);
|
519 |
+
}
|
520 |
+
|
521 |
+
public static function XML2array($XMLstring) {
|
522 |
+
if (function_exists('simplexml_load_string')) {
|
523 |
+
if (function_exists('get_object_vars')) {
|
524 |
+
if (function_exists('libxml_disable_entity_loader')) { // (PHP 5 >= 5.2.11)
|
525 |
+
// http://websec.io/2012/08/27/Preventing-XEE-in-PHP.html
|
526 |
+
libxml_disable_entity_loader(true);
|
527 |
+
}
|
528 |
+
$XMLobject = simplexml_load_string($XMLstring);
|
529 |
+
return self::SimpleXMLelement2array($XMLobject);
|
530 |
+
}
|
531 |
+
}
|
532 |
+
return false;
|
533 |
+
}
|
534 |
+
|
535 |
+
public static function SimpleXMLelement2array($XMLobject) {
|
536 |
+
if (!is_object($XMLobject) && !is_array($XMLobject)) {
|
537 |
+
return $XMLobject;
|
538 |
+
}
|
539 |
+
$XMLarray = (is_object($XMLobject) ? get_object_vars($XMLobject) : $XMLobject);
|
540 |
+
foreach ($XMLarray as $key => $value) {
|
541 |
+
$XMLarray[$key] = self::SimpleXMLelement2array($value);
|
542 |
+
}
|
543 |
+
return $XMLarray;
|
544 |
+
}
|
545 |
+
|
546 |
+
|
547 |
+
// Allan Hansen <ahØartemis*dk>
|
548 |
+
// self::md5_data() - returns md5sum for a file from startuing position to absolute end position
|
549 |
+
public static function hash_data($file, $offset, $end, $algorithm) {
|
550 |
+
static $tempdir = '';
|
551 |
+
if (!self::intValueSupported($end)) {
|
552 |
+
return false;
|
553 |
+
}
|
554 |
+
switch ($algorithm) {
|
555 |
+
case 'md5':
|
556 |
+
$hash_function = 'md5_file';
|
557 |
+
$unix_call = 'md5sum';
|
558 |
+
$windows_call = 'md5sum.exe';
|
559 |
+
$hash_length = 32;
|
560 |
+
break;
|
561 |
+
|
562 |
+
case 'sha1':
|
563 |
+
$hash_function = 'sha1_file';
|
564 |
+
$unix_call = 'sha1sum';
|
565 |
+
$windows_call = 'sha1sum.exe';
|
566 |
+
$hash_length = 40;
|
567 |
+
break;
|
568 |
+
|
569 |
+
default:
|
570 |
+
throw new Exception('Invalid algorithm ('.$algorithm.') in self::hash_data()');
|
571 |
+
break;
|
572 |
+
}
|
573 |
+
$size = $end - $offset;
|
574 |
+
while (true) {
|
575 |
+
if (GETID3_OS_ISWINDOWS) {
|
576 |
+
|
577 |
+
// It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data
|
578 |
+
// Fall back to create-temp-file method:
|
579 |
+
if ($algorithm == 'sha1') {
|
580 |
+
break;
|
581 |
+
}
|
582 |
+
|
583 |
+
$RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call);
|
584 |
+
foreach ($RequiredFiles as $required_file) {
|
585 |
+
if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
|
586 |
+
// helper apps not available - fall back to old method
|
587 |
+
break 2;
|
588 |
+
}
|
589 |
+
}
|
590 |
+
$commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' '.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).' | ';
|
591 |
+
$commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | ';
|
592 |
+
$commandline .= GETID3_HELPERAPPSDIR.$windows_call;
|
593 |
+
|
594 |
+
} else {
|
595 |
+
|
596 |
+
$commandline = 'head -c'.$end.' '.escapeshellarg($file).' | ';
|
597 |
+
$commandline .= 'tail -c'.$size.' | ';
|
598 |
+
$commandline .= $unix_call;
|
599 |
+
|
600 |
+
}
|
601 |
+
if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
|
602 |
+
//throw new Exception('PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm');
|
603 |
+
break;
|
604 |
+
}
|
605 |
+
return substr(`$commandline`, 0, $hash_length);
|
606 |
+
}
|
607 |
+
|
608 |
+
if (empty($tempdir)) {
|
609 |
+
// yes this is ugly, feel free to suggest a better way
|
610 |
+
require_once(dirname(__FILE__).'/getid3.php');
|
611 |
+
$getid3_temp = new getID3();
|
612 |
+
$tempdir = $getid3_temp->tempdir;
|
613 |
+
unset($getid3_temp);
|
614 |
+
}
|
615 |
+
// try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
|
616 |
+
if (($data_filename = tempnam($tempdir, 'gI3')) === false) {
|
617 |
+
// can't find anywhere to create a temp file, just fail
|
618 |
+
return false;
|
619 |
+
}
|
620 |
+
|
621 |
+
// Init
|
622 |
+
$result = false;
|
623 |
+
|
624 |
+
// copy parts of file
|
625 |
+
try {
|
626 |
+
self::CopyFileParts($file, $data_filename, $offset, $end - $offset);
|
627 |
+
$result = $hash_function($data_filename);
|
628 |
+
} catch (Exception $e) {
|
629 |
+
throw new Exception('self::CopyFileParts() failed in getid_lib::hash_data(): '.$e->getMessage());
|
630 |
+
}
|
631 |
+
unlink($data_filename);
|
632 |
+
return $result;
|
633 |
+
}
|
634 |
+
|
635 |
+
public static function CopyFileParts($filename_source, $filename_dest, $offset, $length) {
|
636 |
+
if (!self::intValueSupported($offset + $length)) {
|
637 |
+
throw new Exception('cannot copy file portion, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
|
638 |
+
}
|
639 |
+
if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) {
|
640 |
+
if (($fp_dest = fopen($filename_dest, 'wb'))) {
|
641 |
+
if (fseek($fp_src, $offset) == 0) {
|
642 |
+
$byteslefttowrite = $length;
|
643 |
+
while (($byteslefttowrite > 0) && ($buffer = fread($fp_src, min($byteslefttowrite, getID3::FREAD_BUFFER_SIZE)))) {
|
644 |
+
$byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite);
|
645 |
+
$byteslefttowrite -= $byteswritten;
|
646 |
+
}
|
647 |
+
return true;
|
648 |
+
} else {
|
649 |
+
throw new Exception('failed to seek to offset '.$offset.' in '.$filename_source);
|
650 |
+
}
|
651 |
+
fclose($fp_dest);
|
652 |
+
} else {
|
653 |
+
throw new Exception('failed to create file for writing '.$filename_dest);
|
654 |
+
}
|
655 |
+
fclose($fp_src);
|
656 |
+
} else {
|
657 |
+
throw new Exception('failed to open file for reading '.$filename_source);
|
658 |
+
}
|
659 |
+
return false;
|
660 |
+
}
|
661 |
+
|
662 |
+
public static function iconv_fallback_int_utf8($charval) {
|
663 |
+
if ($charval < 128) {
|
664 |
+
// 0bbbbbbb
|
665 |
+
$newcharstring = chr($charval);
|
666 |
+
} elseif ($charval < 2048) {
|
667 |
+
// 110bbbbb 10bbbbbb
|
668 |
+
$newcharstring = chr(($charval >> 6) | 0xC0);
|
669 |
+
$newcharstring .= chr(($charval & 0x3F) | 0x80);
|
670 |
+
} elseif ($charval < 65536) {
|
671 |
+
// 1110bbbb 10bbbbbb 10bbbbbb
|
672 |
+
$newcharstring = chr(($charval >> 12) | 0xE0);
|
673 |
+
$newcharstring .= chr(($charval >> 6) | 0xC0);
|
674 |
+
$newcharstring .= chr(($charval & 0x3F) | 0x80);
|
675 |
+
} else {
|
676 |
+
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
|
677 |
+
$newcharstring = chr(($charval >> 18) | 0xF0);
|
678 |
+
$newcharstring .= chr(($charval >> 12) | 0xC0);
|
679 |
+
$newcharstring .= chr(($charval >> 6) | 0xC0);
|
680 |
+
$newcharstring .= chr(($charval & 0x3F) | 0x80);
|
681 |
+
}
|
682 |
+
return $newcharstring;
|
683 |
+
}
|
684 |
+
|
685 |
+
// ISO-8859-1 => UTF-8
|
686 |
+
public static function iconv_fallback_iso88591_utf8($string, $bom=false) {
|
687 |
+
if (function_exists('utf8_encode')) {
|
688 |
+
return utf8_encode($string);
|
689 |
+
}
|
690 |
+
// utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
|
691 |
+
$newcharstring = '';
|
692 |
+
if ($bom) {
|
693 |
+
$newcharstring .= "\xEF\xBB\xBF";
|
694 |
+
}
|
695 |
+
for ($i = 0; $i < strlen($string); $i++) {
|
696 |
+
$charval = ord($string{$i});
|
697 |
+
$newcharstring .= self::iconv_fallback_int_utf8($charval);
|
698 |
+
}
|
699 |
+
return $newcharstring;
|
700 |
+
}
|
701 |
+
|
702 |
+
// ISO-8859-1 => UTF-16BE
|
703 |
+
public static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
|
704 |
+
$newcharstring = '';
|
705 |
+
if ($bom) {
|
706 |
+
$newcharstring .= "\xFE\xFF";
|
707 |
+
}
|
708 |
+
for ($i = 0; $i < strlen($string); $i++) {
|
709 |
+
$newcharstring .= "\x00".$string{$i};
|
710 |
+
}
|
711 |
+
return $newcharstring;
|
712 |
+
}
|
713 |
+
|
714 |
+
// ISO-8859-1 => UTF-16LE
|
715 |
+
public static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
|
716 |
+
$newcharstring = '';
|
717 |
+
if ($bom) {
|
718 |
+
$newcharstring .= "\xFF\xFE";
|
719 |
+
}
|
720 |
+
for ($i = 0; $i < strlen($string); $i++) {
|
721 |
+
$newcharstring .= $string{$i}."\x00";
|
722 |
+
}
|
723 |
+
return $newcharstring;
|
724 |
+
}
|
725 |
+
|
726 |
+
// ISO-8859-1 => UTF-16LE (BOM)
|
727 |
+
public static function iconv_fallback_iso88591_utf16($string) {
|
728 |
+
return self::iconv_fallback_iso88591_utf16le($string, true);
|
729 |
+
}
|
730 |
+
|
731 |
+
// UTF-8 => ISO-8859-1
|
732 |
+
public static function iconv_fallback_utf8_iso88591($string) {
|
733 |
+
if (function_exists('utf8_decode')) {
|
734 |
+
return utf8_decode($string);
|
735 |
+
}
|
736 |
+
// utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
|
737 |
+
$newcharstring = '';
|
738 |
+
$offset = 0;
|
739 |
+
$stringlength = strlen($string);
|
740 |
+
while ($offset < $stringlength) {
|
741 |
+
if ((ord($string{$offset}) | 0x07) == 0xF7) {
|
742 |
+
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
|
743 |
+
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
|
744 |
+
((ord($string{($offset + 1)}) & 0x3F) << 12) &
|
745 |
+
((ord($string{($offset + 2)}) & 0x3F) << 6) &
|
746 |
+
(ord($string{($offset + 3)}) & 0x3F);
|
747 |
+
$offset += 4;
|
748 |
+
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
|
749 |
+
// 1110bbbb 10bbbbbb 10bbbbbb
|
750 |
+
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
|
751 |
+
((ord($string{($offset + 1)}) & 0x3F) << 6) &
|
752 |
+
(ord($string{($offset + 2)}) & 0x3F);
|
753 |
+
$offset += 3;
|
754 |
+
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
|
755 |
+
// 110bbbbb 10bbbbbb
|
756 |
+
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
|
757 |
+
(ord($string{($offset + 1)}) & 0x3F);
|
758 |
+
$offset += 2;
|
759 |
+
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
|
760 |
+
// 0bbbbbbb
|
761 |
+
$charval = ord($string{$offset});
|
762 |
+
$offset += 1;
|
763 |
+
} else {
|
764 |
+
// error? throw some kind of warning here?
|
765 |
+
$charval = false;
|
766 |
+
$offset += 1;
|
767 |
+
}
|
768 |
+
if ($charval !== false) {
|
769 |
+
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
|
770 |
+
}
|
771 |
+
}
|
772 |
+
return $newcharstring;
|
773 |
+
}
|
774 |
+
|
775 |
+
// UTF-8 => UTF-16BE
|
776 |
+
public static function iconv_fallback_utf8_utf16be($string, $bom=false) {
|
777 |
+
$newcharstring = '';
|
778 |
+
if ($bom) {
|
779 |
+
$newcharstring .= "\xFE\xFF";
|
780 |
+
}
|
781 |
+
$offset = 0;
|
782 |
+
$stringlength = strlen($string);
|
783 |
+
while ($offset < $stringlength) {
|
784 |
+
if ((ord($string{$offset}) | 0x07) == 0xF7) {
|
785 |
+
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
|
786 |
+
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
|
787 |
+
((ord($string{($offset + 1)}) & 0x3F) << 12) &
|
788 |
+
((ord($string{($offset + 2)}) & 0x3F) << 6) &
|
789 |
+
(ord($string{($offset + 3)}) & 0x3F);
|
790 |
+
$offset += 4;
|
791 |
+
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
|
792 |
+
// 1110bbbb 10bbbbbb 10bbbbbb
|
793 |
+
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
|
794 |
+
((ord($string{($offset + 1)}) & 0x3F) << 6) &
|
795 |
+
(ord($string{($offset + 2)}) & 0x3F);
|
796 |
+
$offset += 3;
|
797 |
+
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
|
798 |
+
// 110bbbbb 10bbbbbb
|
799 |
+
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
|
800 |
+
(ord($string{($offset + 1)}) & 0x3F);
|
801 |
+
$offset += 2;
|
802 |
+
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
|
803 |
+
// 0bbbbbbb
|
804 |
+
$charval = ord($string{$offset});
|
805 |
+
$offset += 1;
|
806 |
+
} else {
|
807 |
+
// error? throw some kind of warning here?
|
808 |
+
$charval = false;
|
809 |
+
$offset += 1;
|
810 |
+
}
|
811 |
+
if ($charval !== false) {
|
812 |
+
$newcharstring .= (($charval < 65536) ? self::BigEndian2String($charval, 2) : "\x00".'?');
|
813 |
+
}
|
814 |
+
}
|
815 |
+
return $newcharstring;
|
816 |
+
}
|
817 |
+
|
818 |
+
// UTF-8 => UTF-16LE
|
819 |
+
public static function iconv_fallback_utf8_utf16le($string, $bom=false) {
|
820 |
+
$newcharstring = '';
|
821 |
+
if ($bom) {
|
822 |
+
$newcharstring .= "\xFF\xFE";
|
823 |
+
}
|
824 |
+
$offset = 0;
|
825 |
+
$stringlength = strlen($string);
|
826 |
+
while ($offset < $stringlength) {
|
827 |
+
if ((ord($string{$offset}) | 0x07) == 0xF7) {
|
828 |
+
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
|
829 |
+
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
|
830 |
+
((ord($string{($offset + 1)}) & 0x3F) << 12) &
|
831 |
+
((ord($string{($offset + 2)}) & 0x3F) << 6) &
|
832 |
+
(ord($string{($offset + 3)}) & 0x3F);
|
833 |
+
$offset += 4;
|
834 |
+
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
|
835 |
+
// 1110bbbb 10bbbbbb 10bbbbbb
|
836 |
+
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
|
837 |
+
((ord($string{($offset + 1)}) & 0x3F) << 6) &
|
838 |
+
(ord($string{($offset + 2)}) & 0x3F);
|
839 |
+
$offset += 3;
|
840 |
+
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
|
841 |
+
// 110bbbbb 10bbbbbb
|
842 |
+
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
|
843 |
+
(ord($string{($offset + 1)}) & 0x3F);
|
844 |
+
$offset += 2;
|
845 |
+
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
|
846 |
+
// 0bbbbbbb
|
847 |
+
$charval = ord($string{$offset});
|
848 |
+
$offset += 1;
|
849 |
+
} else {
|
850 |
+
// error? maybe throw some warning here?
|
851 |
+
$charval = false;
|
852 |
+
$offset += 1;
|
853 |
+
}
|
854 |
+
if ($charval !== false) {
|
855 |
+
$newcharstring .= (($charval < 65536) ? self::LittleEndian2String($charval, 2) : '?'."\x00");
|
856 |
+
}
|
857 |
+
}
|
858 |
+
return $newcharstring;
|
859 |
+
}
|
860 |
+
|
861 |
+
// UTF-8 => UTF-16LE (BOM)
|
862 |
+
public static function iconv_fallback_utf8_utf16($string) {
|
863 |
+
return self::iconv_fallback_utf8_utf16le($string, true);
|
864 |
+
}
|
865 |
+
|
866 |
+
// UTF-16BE => UTF-8
|
867 |
+
public static function iconv_fallback_utf16be_utf8($string) {
|
868 |
+
if (substr($string, 0, 2) == "\xFE\xFF") {
|
869 |
+
// strip BOM
|
870 |
+
$string = substr($string, 2);
|
871 |
+
}
|
872 |
+
$newcharstring = '';
|
873 |
+
for ($i = 0; $i < strlen($string); $i += 2) {
|
874 |
+
$charval = self::BigEndian2Int(substr($string, $i, 2));
|
875 |
+
$newcharstring .= self::iconv_fallback_int_utf8($charval);
|
876 |
+
}
|
877 |
+
return $newcharstring;
|
878 |
+
}
|
879 |
+
|
880 |
+
// UTF-16LE => UTF-8
|
881 |
+
public static function iconv_fallback_utf16le_utf8($string) {
|
882 |
+
if (substr($string, 0, 2) == "\xFF\xFE") {
|
883 |
+
// strip BOM
|
884 |
+
$string = substr($string, 2);
|
885 |
+
}
|
886 |
+
$newcharstring = '';
|
887 |
+
for ($i = 0; $i < strlen($string); $i += 2) {
|
888 |
+
$charval = self::LittleEndian2Int(substr($string, $i, 2));
|
889 |
+
$newcharstring .= self::iconv_fallback_int_utf8($charval);
|
890 |
+
}
|
891 |
+
return $newcharstring;
|
892 |
+
}
|
893 |
+
|
894 |
+
// UTF-16BE => ISO-8859-1
|
895 |
+
public static function iconv_fallback_utf16be_iso88591($string) {
|
896 |
+
if (substr($string, 0, 2) == "\xFE\xFF") {
|
897 |
+
// strip BOM
|
898 |
+
$string = substr($string, 2);
|
899 |
+
}
|
900 |
+
$newcharstring = '';
|
901 |
+
for ($i = 0; $i < strlen($string); $i += 2) {
|
902 |
+
$charval = self::BigEndian2Int(substr($string, $i, 2));
|
903 |
+
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
|
904 |
+
}
|
905 |
+
return $newcharstring;
|
906 |
+
}
|
907 |
+
|
908 |
+
// UTF-16LE => ISO-8859-1
|
909 |
+
public static function iconv_fallback_utf16le_iso88591($string) {
|
910 |
+
if (substr($string, 0, 2) == "\xFF\xFE") {
|
911 |
+
// strip BOM
|
912 |
+
$string = substr($string, 2);
|
913 |
+
}
|
914 |
+
$newcharstring = '';
|
915 |
+
for ($i = 0; $i < strlen($string); $i += 2) {
|
916 |
+
$charval = self::LittleEndian2Int(substr($string, $i, 2));
|
917 |
+
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
|
918 |
+
}
|
919 |
+
return $newcharstring;
|
920 |
+
}
|
921 |
+
|
922 |
+
// UTF-16 (BOM) => ISO-8859-1
|
923 |
+
public static function iconv_fallback_utf16_iso88591($string) {
|
924 |
+
$bom = substr($string, 0, 2);
|
925 |
+
if ($bom == "\xFE\xFF") {
|
926 |
+
return self::iconv_fallback_utf16be_iso88591(substr($string, 2));
|
927 |
+
} elseif ($bom == "\xFF\xFE") {
|
928 |
+
return self::iconv_fallback_utf16le_iso88591(substr($string, 2));
|
929 |
+
}
|
930 |
+
return $string;
|
931 |
+
}
|
932 |
+
|
933 |
+
// UTF-16 (BOM) => UTF-8
|
934 |
+
public static function iconv_fallback_utf16_utf8($string) {
|
935 |
+
$bom = substr($string, 0, 2);
|
936 |
+
if ($bom == "\xFE\xFF") {
|
937 |
+
return self::iconv_fallback_utf16be_utf8(substr($string, 2));
|
938 |
+
} elseif ($bom == "\xFF\xFE") {
|
939 |
+
return self::iconv_fallback_utf16le_utf8(substr($string, 2));
|
940 |
+
}
|
941 |
+
return $string;
|
942 |
+
}
|
943 |
+
|
944 |
+
public static function iconv_fallback($in_charset, $out_charset, $string) {
|
945 |
+
|
946 |
+
if ($in_charset == $out_charset) {
|
947 |
+
return $string;
|
948 |
+
}
|
949 |
+
|
950 |
+
// iconv() availble
|
951 |
+
if (function_exists('iconv')) {
|
952 |
+
if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
|
953 |
+
switch ($out_charset) {
|
954 |
+
case 'ISO-8859-1':
|
955 |
+
$converted_string = rtrim($converted_string, "\x00");
|
956 |
+
break;
|
957 |
+
}
|
958 |
+
return $converted_string;
|
959 |
+
}
|
960 |
+
|
961 |
+
// iconv() may sometimes fail with "illegal character in input string" error message
|
962 |
+
// and return an empty string, but returning the unconverted string is more useful
|
963 |
+
return $string;
|
964 |
+
}
|
965 |
+
|
966 |
+
|
967 |
+
// iconv() not available
|
968 |
+
static $ConversionFunctionList = array();
|
969 |
+
if (empty($ConversionFunctionList)) {
|
970 |
+
$ConversionFunctionList['ISO-8859-1']['UTF-8'] = 'iconv_fallback_iso88591_utf8';
|
971 |
+
$ConversionFunctionList['ISO-8859-1']['UTF-16'] = 'iconv_fallback_iso88591_utf16';
|
972 |
+
$ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be';
|
973 |
+
$ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le';
|
974 |
+
$ConversionFunctionList['UTF-8']['ISO-8859-1'] = 'iconv_fallback_utf8_iso88591';
|
975 |
+
$ConversionFunctionList['UTF-8']['UTF-16'] = 'iconv_fallback_utf8_utf16';
|
976 |
+
$ConversionFunctionList['UTF-8']['UTF-16BE'] = 'iconv_fallback_utf8_utf16be';
|
977 |
+
$ConversionFunctionList['UTF-8']['UTF-16LE'] = 'iconv_fallback_utf8_utf16le';
|
978 |
+
$ConversionFunctionList['UTF-16']['ISO-8859-1'] = 'iconv_fallback_utf16_iso88591';
|
979 |
+
$ConversionFunctionList['UTF-16']['UTF-8'] = 'iconv_fallback_utf16_utf8';
|
980 |
+
$ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591';
|
981 |
+
$ConversionFunctionList['UTF-16LE']['UTF-8'] = 'iconv_fallback_utf16le_utf8';
|
982 |
+
$ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591';
|
983 |
+
$ConversionFunctionList['UTF-16BE']['UTF-8'] = 'iconv_fallback_utf16be_utf8';
|
984 |
+
}
|
985 |
+
if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
|
986 |
+
$ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
|
987 |
+
return self::$ConversionFunction($string);
|
988 |
+
}
|
989 |
+
throw new Exception('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
|
990 |
+
}
|
991 |
+
|
992 |
+
public static function recursiveMultiByteCharString2HTML($data, $charset='ISO-8859-1') {
|
993 |
+
if (is_string($data)) {
|
994 |
+
return self::MultiByteCharString2HTML($data, $charset);
|
995 |
+
} elseif (is_array($data)) {
|
996 |
+
$return_data = array();
|
997 |
+
foreach ($data as $key => $value) {
|
998 |
+
$return_data[$key] = self::recursiveMultiByteCharString2HTML($value, $charset);
|
999 |
+
}
|
1000 |
+
return $return_data;
|
1001 |
+
}
|
1002 |
+
// integer, float, objects, resources, etc
|
1003 |
+
return $data;
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
public static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
|
1007 |
+
$string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string
|
1008 |
+
$HTMLstring = '';
|
1009 |
+
|
1010 |
+
switch ($charset) {
|
1011 |
+
case '1251':
|
1012 |
+
case '1252':
|
1013 |
+
case '866':
|
1014 |
+
case '932':
|
1015 |
+
case '936':
|
1016 |
+
case '950':
|
1017 |
+
case 'BIG5':
|
1018 |
+
case 'BIG5-HKSCS':
|
1019 |
+
case 'cp1251':
|
1020 |
+
case 'cp1252':
|
1021 |
+
case 'cp866':
|
1022 |
+
case 'EUC-JP':
|
1023 |
+
case 'EUCJP':
|
1024 |
+
case 'GB2312':
|
1025 |
+
case 'ibm866':
|
1026 |
+
case 'ISO-8859-1':
|
1027 |
+
case 'ISO-8859-15':
|
1028 |
+
case 'ISO8859-1':
|
1029 |
+
case 'ISO8859-15':
|
1030 |
+
case 'KOI8-R':
|
1031 |
+
case 'koi8-ru':
|
1032 |
+
case 'koi8r':
|
1033 |
+
case 'Shift_JIS':
|
1034 |
+
case 'SJIS':
|
1035 |
+
case 'win-1251':
|
1036 |
+
case 'Windows-1251':
|
1037 |
+
case 'Windows-1252':
|
1038 |
+
$HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
|
1039 |
+
break;
|
1040 |
+
|
1041 |
+
case 'UTF-8':
|
1042 |
+
$strlen = strlen($string);
|
1043 |
+
for ($i = 0; $i < $strlen; $i++) {
|
1044 |
+
$char_ord_val = ord($string{$i});
|
1045 |
+
$charval = 0;
|
1046 |
+
if ($char_ord_val < 0x80) {
|
1047 |
+
$charval = $char_ord_val;
|
1048 |
+
} elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F && $i+3 < $strlen) {
|
1049 |
+
$charval = (($char_ord_val & 0x07) << 18);
|
1050 |
+
$charval += ((ord($string{++$i}) & 0x3F) << 12);
|
1051 |
+
$charval += ((ord($string{++$i}) & 0x3F) << 6);
|
1052 |
+
$charval += (ord($string{++$i}) & 0x3F);
|
1053 |
+
} elseif ((($char_ord_val & 0xE0) >> 5) == 0x07 && $i+2 < $strlen) {
|
1054 |
+
$charval = (($char_ord_val & 0x0F) << 12);
|
1055 |
+
$charval += ((ord($string{++$i}) & 0x3F) << 6);
|
1056 |
+
$charval += (ord($string{++$i}) & 0x3F);
|
1057 |
+
} elseif ((($char_ord_val & 0xC0) >> 6) == 0x03 && $i+1 < $strlen) {
|
1058 |
+
$charval = (($char_ord_val & 0x1F) << 6);
|
1059 |
+
$charval += (ord($string{++$i}) & 0x3F);
|
1060 |
+
}
|
1061 |
+
if (($charval >= 32) && ($charval <= 127)) {
|
1062 |
+
$HTMLstring .= htmlentities(chr($charval));
|
1063 |
+
} else {
|
1064 |
+
$HTMLstring .= '&#'.$charval.';';
|
1065 |
+
}
|
1066 |
+
}
|
1067 |
+
break;
|
1068 |
+
|
1069 |
+
case 'UTF-16LE':
|
1070 |
+
for ($i = 0; $i < strlen($string); $i += 2) {
|
1071 |
+
$charval = self::LittleEndian2Int(substr($string, $i, 2));
|
1072 |
+
if (($charval >= 32) && ($charval <= 127)) {
|
1073 |
+
$HTMLstring .= chr($charval);
|
1074 |
+
} else {
|
1075 |
+
$HTMLstring .= '&#'.$charval.';';
|
1076 |
+
}
|
1077 |
+
}
|
1078 |
+
break;
|
1079 |
+
|
1080 |
+
case 'UTF-16BE':
|
1081 |
+
for ($i = 0; $i < strlen($string); $i += 2) {
|
1082 |
+
$charval = self::BigEndian2Int(substr($string, $i, 2));
|
1083 |
+
if (($charval >= 32) && ($charval <= 127)) {
|
1084 |
+
$HTMLstring .= chr($charval);
|
1085 |
+
} else {
|
1086 |
+
$HTMLstring .= '&#'.$charval.';';
|
1087 |
+
}
|
1088 |
+
}
|
1089 |
+
break;
|
1090 |
+
|
1091 |
+
default:
|
1092 |
+
$HTMLstring = 'ERROR: Character set "'.$charset.'" not supported in MultiByteCharString2HTML()';
|
1093 |
+
break;
|
1094 |
+
}
|
1095 |
+
return $HTMLstring;
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
|
1099 |
+
|
1100 |
+
public static function RGADnameLookup($namecode) {
|
1101 |
+
static $RGADname = array();
|
1102 |
+
if (empty($RGADname)) {
|
1103 |
+
$RGADname[0] = 'not set';
|
1104 |
+
$RGADname[1] = 'Track Gain Adjustment';
|
1105 |
+
$RGADname[2] = 'Album Gain Adjustment';
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : '');
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
|
1112 |
+
public static function RGADoriginatorLookup($originatorcode) {
|
1113 |
+
static $RGADoriginator = array();
|
1114 |
+
if (empty($RGADoriginator)) {
|
1115 |
+
$RGADoriginator[0] = 'unspecified';
|
1116 |
+
$RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer';
|
1117 |
+
$RGADoriginator[2] = 'set by user';
|
1118 |
+
$RGADoriginator[3] = 'determined automatically';
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : '');
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
|
1125 |
+
public static function RGADadjustmentLookup($rawadjustment, $signbit) {
|
1126 |
+
$adjustment = $rawadjustment / 10;
|
1127 |
+
if ($signbit == 1) {
|
1128 |
+
$adjustment *= -1;
|
1129 |
+
}
|
1130 |
+
return (float) $adjustment;
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
|
1134 |
+
public static function RGADgainString($namecode, $originatorcode, $replaygain) {
|
1135 |
+
if ($replaygain < 0) {
|
1136 |
+
$signbit = '1';
|
1137 |
+
} else {
|
1138 |
+
$signbit = '0';
|
1139 |
+
}
|
1140 |
+
$storedreplaygain = intval(round($replaygain * 10));
|
1141 |
+
$gainstring = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
|
1142 |
+
$gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
|
1143 |
+
$gainstring .= $signbit;
|
1144 |
+
$gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT);
|
1145 |
+
|
1146 |
+
return $gainstring;
|
1147 |
+
}
|
1148 |
+
|
1149 |
+
public static function RGADamplitude2dB($amplitude) {
|
1150 |
+
return 20 * log10($amplitude);
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
|
1154 |
+
public static function GetDataImageSize($imgData, &$imageinfo=array()) {
|
1155 |
+
static $tempdir = '';
|
1156 |
+
if (empty($tempdir)) {
|
1157 |
+
// yes this is ugly, feel free to suggest a better way
|
1158 |
+
require_once(dirname(__FILE__).'/getid3.php');
|
1159 |
+
$getid3_temp = new getID3();
|
1160 |
+
$tempdir = $getid3_temp->tempdir;
|
1161 |
+
unset($getid3_temp);
|
1162 |
+
}
|
1163 |
+
$GetDataImageSize = false;
|
1164 |
+
if ($tempfilename = tempnam($tempdir, 'gI3')) {
|
1165 |
+
if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename, 'wb'))) {
|
1166 |
+
fwrite($tmp, $imgData);
|
1167 |
+
fclose($tmp);
|
1168 |
+
$GetDataImageSize = @getimagesize($tempfilename, $imageinfo);
|
1169 |
+
}
|
1170 |
+
unlink($tempfilename);
|
1171 |
+
}
|
1172 |
+
return $GetDataImageSize;
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
public static function ImageExtFromMime($mime_type) {
|
1176 |
+
// temporary way, works OK for now, but should be reworked in the future
|
1177 |
+
return str_replace(array('image/', 'x-', 'jpeg'), array('', '', 'jpg'), $mime_type);
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
public static function ImageTypesLookup($imagetypeid) {
|
1181 |
+
static $ImageTypesLookup = array();
|
1182 |
+
if (empty($ImageTypesLookup)) {
|
1183 |
+
$ImageTypesLookup[1] = 'gif';
|
1184 |
+
$ImageTypesLookup[2] = 'jpeg';
|
1185 |
+
$ImageTypesLookup[3] = 'png';
|
1186 |
+
$ImageTypesLookup[4] = 'swf';
|
1187 |
+
$ImageTypesLookup[5] = 'psd';
|
1188 |
+
$ImageTypesLookup[6] = 'bmp';
|
1189 |
+
$ImageTypesLookup[7] = 'tiff (little-endian)';
|
1190 |
+
$ImageTypesLookup[8] = 'tiff (big-endian)';
|
1191 |
+
$ImageTypesLookup[9] = 'jpc';
|
1192 |
+
$ImageTypesLookup[10] = 'jp2';
|
1193 |
+
$ImageTypesLookup[11] = 'jpx';
|
1194 |
+
$ImageTypesLookup[12] = 'jb2';
|
1195 |
+
$ImageTypesLookup[13] = 'swc';
|
1196 |
+
$ImageTypesLookup[14] = 'iff';
|
1197 |
+
}
|
1198 |
+
return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : '');
|
1199 |
+
}
|
1200 |
+
|
1201 |
+
public static function CopyTagsToComments(&$ThisFileInfo) {
|
1202 |
+
|
1203 |
+
// Copy all entries from ['tags'] into common ['comments']
|
1204 |
+
if (!empty($ThisFileInfo['tags'])) {
|
1205 |
+
foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
|
1206 |
+
foreach ($tagarray as $tagname => $tagdata) {
|
1207 |
+
foreach ($tagdata as $key => $value) {
|
1208 |
+
if (!empty($value)) {
|
1209 |
+
if (empty($ThisFileInfo['comments'][$tagname])) {
|
1210 |
+
|
1211 |
+
// fall through and append value
|
1212 |
+
|
1213 |
+
} elseif ($tagtype == 'id3v1') {
|
1214 |
+
|
1215 |
+
$newvaluelength = strlen(trim($value));
|
1216 |
+
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
|
1217 |
+
$oldvaluelength = strlen(trim($existingvalue));
|
1218 |
+
if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) {
|
1219 |
+
// new value is identical but shorter-than (or equal-length to) one already in comments - skip
|
1220 |
+
break 2;
|
1221 |
+
}
|
1222 |
+
}
|
1223 |
+
|
1224 |
+
} elseif (!is_array($value)) {
|
1225 |
+
|
1226 |
+
$newvaluelength = strlen(trim($value));
|
1227 |
+
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
|
1228 |
+
$oldvaluelength = strlen(trim($existingvalue));
|
1229 |
+
if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
|
1230 |
+
$ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
|
1231 |
+
//break 2;
|
1232 |
+
break;
|
1233 |
+
}
|
1234 |
+
}
|
1235 |
+
|
1236 |
+
}
|
1237 |
+
if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
|
1238 |
+
$value = (is_string($value) ? trim($value) : $value);
|
1239 |
+
if (!is_numeric($key)) {
|
1240 |
+
$ThisFileInfo['comments'][$tagname][$key] = $value;
|
1241 |
+
} else {
|
1242 |
+
$ThisFileInfo['comments'][$tagname][] = $value;
|
1243 |
+
}
|
1244 |
+
}
|
1245 |
+
}
|
1246 |
+
}
|
1247 |
+
}
|
1248 |
+
}
|
1249 |
+
|
1250 |
+
// Copy to ['comments_html']
|
1251 |
+
if (!empty($ThisFileInfo['comments'])) {
|
1252 |
+
foreach ($ThisFileInfo['comments'] as $field => $values) {
|
1253 |
+
if ($field == 'picture') {
|
1254 |
+
// pictures can take up a lot of space, and we don't need multiple copies of them
|
1255 |
+
// let there be a single copy in [comments][picture], and not elsewhere
|
1256 |
+
continue;
|
1257 |
+
}
|
1258 |
+
foreach ($values as $index => $value) {
|
1259 |
+
if (is_array($value)) {
|
1260 |
+
$ThisFileInfo['comments_html'][$field][$index] = $value;
|
1261 |
+
} else {
|
1262 |
+
$ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
|
1263 |
+
}
|
1264 |
+
}
|
1265 |
+
}
|
1266 |
+
}
|
1267 |
+
|
1268 |
+
}
|
1269 |
+
return true;
|
1270 |
+
}
|
1271 |
+
|
1272 |
+
|
1273 |
+
public static function EmbeddedLookup($key, $begin, $end, $file, $name) {
|
1274 |
+
|
1275 |
+
// Cached
|
1276 |
+
static $cache;
|
1277 |
+
if (isset($cache[$file][$name])) {
|
1278 |
+
return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
|
1279 |
+
}
|
1280 |
+
|
1281 |
+
// Init
|
1282 |
+
$keylength = strlen($key);
|
1283 |
+
$line_count = $end - $begin - 7;
|
1284 |
+
|
1285 |
+
// Open php file
|
1286 |
+
$fp = fopen($file, 'r');
|
1287 |
+
|
1288 |
+
// Discard $begin lines
|
1289 |
+
for ($i = 0; $i < ($begin + 3); $i++) {
|
1290 |
+
fgets($fp, 1024);
|
1291 |
+
}
|
1292 |
+
|
1293 |
+
// Loop thru line
|
1294 |
+
while (0 < $line_count--) {
|
1295 |
+
|
1296 |
+
// Read line
|
1297 |
+
$line = ltrim(fgets($fp, 1024), "\t ");
|
1298 |
+
|
1299 |
+
// METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key
|
1300 |
+
//$keycheck = substr($line, 0, $keylength);
|
1301 |
+
//if ($key == $keycheck) {
|
1302 |
+
// $cache[$file][$name][$keycheck] = substr($line, $keylength + 1);
|
1303 |
+
// break;
|
1304 |
+
//}
|
1305 |
+
|
1306 |
+
// METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
|
1307 |
+
//$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
|
1308 |
+
$explodedLine = explode("\t", $line, 2);
|
1309 |
+
$ThisKey = (isset($explodedLine[0]) ? $explodedLine[0] : '');
|
1310 |
+
$ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : '');
|
1311 |
+
$cache[$file][$name][$ThisKey] = trim($ThisValue);
|
1312 |
+
}
|
1313 |
+
|
1314 |
+
// Close and return
|
1315 |
+
fclose($fp);
|
1316 |
+
return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
public static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
|
1320 |
+
global $GETID3_ERRORARRAY;
|
1321 |
+
|
1322 |
+
if (file_exists($filename)) {
|
1323 |
+
if (include_once($filename)) {
|
1324 |
+
return true;
|
1325 |
+
} else {
|
1326 |
+
$diemessage = basename($sourcefile).' depends on '.$filename.', which has errors';
|
1327 |
+
}
|
1328 |
+
} else {
|
1329 |
+
$diemessage = basename($sourcefile).' depends on '.$filename.', which is missing';
|
1330 |
+
}
|
1331 |
+
if ($DieOnFailure) {
|
1332 |
+
throw new Exception($diemessage);
|
1333 |
+
} else {
|
1334 |
+
$GETID3_ERRORARRAY[] = $diemessage;
|
1335 |
+
}
|
1336 |
+
return false;
|
1337 |
+
}
|
1338 |
+
|
1339 |
+
public static function trimNullByte($string) {
|
1340 |
+
return trim($string, "\x00");
|
1341 |
+
}
|
1342 |
+
|
1343 |
+
public static function getFileSizeSyscall($path) {
|
1344 |
+
$filesize = false;
|
1345 |
+
|
1346 |
+
if (GETID3_OS_ISWINDOWS) {
|
1347 |
+
if (class_exists('COM')) { // From PHP 5.3.15 and 5.4.5, COM and DOTNET is no longer built into the php core.you have to add COM support in php.ini:
|
1348 |
+
$filesystem = new COM('Scripting.FileSystemObject');
|
1349 |
+
$file = $filesystem->GetFile($path);
|
1350 |
+
$filesize = $file->Size();
|
1351 |
+
unset($filesystem, $file);
|
1352 |
+
} else {
|
1353 |
+
$commandline = 'for %I in ('.escapeshellarg($path).') do @echo %~zI';
|
1354 |
+
}
|
1355 |
+
} else {
|
1356 |
+
$commandline = 'ls -l '.escapeshellarg($path).' | awk \'{print $5}\'';
|
1357 |
+
}
|
1358 |
+
if (isset($commandline)) {
|
1359 |
+
$output = trim(`$commandline`);
|
1360 |
+
if (ctype_digit($output)) {
|
1361 |
+
$filesize = (float) $output;
|
1362 |
+
}
|
1363 |
+
}
|
1364 |
+
return $filesize;
|
1365 |
+
}
|
1366 |
+
|
1367 |
+
|
1368 |
+
/**
|
1369 |
+
* Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268)
|
1370 |
+
* @param string $path A path.
|
1371 |
+
* @param string $suffix If the name component ends in suffix this will also be cut off.
|
1372 |
+
* @return string
|
1373 |
+
*/
|
1374 |
+
public static function mb_basename($path, $suffix = null) {
|
1375 |
+
$splited = preg_split('#/#', rtrim($path, '/ '));
|
1376 |
+
return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
|
1377 |
+
}
|
1378 |
+
|
1379 |
+
}
|
getid3/getid3.php
CHANGED
@@ -1,1766 +1,1809 @@
|
|
1 |
-
<?php
|
2 |
-
/////////////////////////////////////////////////////////////////
|
3 |
-
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
-
// available at http://getid3.sourceforge.net //
|
5 |
-
// or http://www.getid3.org //
|
6 |
-
|
7 |
-
|
8 |
-
//
|
9 |
-
//
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
{
|
15 |
-
|
16 |
-
}
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
if (
|
23 |
-
|
24 |
-
}
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
$
|
40 |
-
$
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
}
|
55 |
-
if (!$
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
//
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
//
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
public $
|
94 |
-
|
95 |
-
//
|
96 |
-
public $
|
97 |
-
|
98 |
-
public
|
99 |
-
public $
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
//
|
104 |
-
public $
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
//
|
119 |
-
public
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
$
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
// Check
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
//
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
$this
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
}
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
$this->info['filesize'] = $
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
$this->info['
|
299 |
-
$this->info['
|
300 |
-
$this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
|
301 |
-
|
302 |
-
|
303 |
-
// option_max_2gb_check
|
304 |
-
if ($this->option_max_2gb_check) {
|
305 |
-
// PHP (32-bit all, and 64-bit Windows) doesn't support integers larger than 2^31 (~2GB)
|
306 |
-
// filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
|
307 |
-
// ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
|
308 |
-
$fseek = fseek($this->fp, 0, SEEK_END);
|
309 |
-
if (($fseek < 0) || (($this->info['filesize'] != 0) && (ftell($this->fp) == 0)) ||
|
310 |
-
($this->info['filesize'] < 0) ||
|
311 |
-
(ftell($this->fp) < 0)) {
|
312 |
-
$real_filesize =
|
313 |
-
|
314 |
-
|
315 |
-
$
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
$
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
$this->
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
foreach (array('
|
374 |
-
$
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
}
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
//
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
//
|
468 |
-
$
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
//
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
$this->info
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
}
|
559 |
-
|
560 |
-
// remove
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
if (empty($
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
'
|
605 |
-
'
|
606 |
-
'
|
607 |
-
'
|
608 |
-
),
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
'
|
614 |
-
'
|
615 |
-
'
|
616 |
-
'
|
617 |
-
),
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
'
|
623 |
-
'
|
624 |
-
'
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
'
|
631 |
-
'
|
632 |
-
'
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
'
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
'
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
'
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
'
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
'
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
'
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
'
|
706 |
-
'
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
'
|
714 |
-
'
|
715 |
-
'
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
//
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
//
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
'
|
732 |
-
'
|
733 |
-
'
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
'
|
741 |
-
'
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
'
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
'
|
775 |
-
'
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
'
|
783 |
-
'
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
'
|
791 |
-
'
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
'
|
817 |
-
'
|
818 |
-
'
|
819 |
-
'
|
820 |
-
),
|
821 |
-
|
822 |
-
//
|
823 |
-
'
|
824 |
-
'pattern' => '^
|
825 |
-
'group' => 'audio',
|
826 |
-
'module' => '
|
827 |
-
'mime_type' => 'application/octet-stream',
|
828 |
-
),
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
'
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
'
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
'
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
'
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
'
|
886 |
-
'
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
'
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
'
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
'
|
908 |
-
'
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
'
|
922 |
-
'
|
923 |
-
'
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
'
|
933 |
-
'
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
'
|
943 |
-
'
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
'
|
953 |
-
'
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
'
|
963 |
-
'
|
964 |
-
'
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
'
|
974 |
-
'
|
975 |
-
'
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
'
|
985 |
-
'
|
986 |
-
'
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
'
|
996 |
-
'
|
997 |
-
'
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
'
|
1007 |
-
'
|
1008 |
-
'
|
1009 |
-
'
|
1010 |
-
'
|
1011 |
-
'
|
1012 |
-
),
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
'
|
1020 |
-
'
|
1021 |
-
'
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
'
|
1031 |
-
'
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
'
|
1041 |
-
'
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
'
|
1051 |
-
'
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
'
|
1061 |
-
'
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
'
|
1071 |
-
'
|
1072 |
-
'
|
1073 |
-
'
|
1074 |
-
'
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
'
|
1084 |
-
'
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
'
|
1094 |
-
'
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
}
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
'
|
1196 |
-
'
|
1197 |
-
'
|
1198 |
-
'
|
1199 |
-
'
|
1200 |
-
'
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
'
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
}
|
1237 |
-
|
1238 |
-
if (
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
}
|
1280 |
-
}
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
//
|
1324 |
-
//
|
1325 |
-
//
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
$
|
1343 |
-
$this->info[
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
} else {
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
//
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
}
|
1443 |
-
|
1444 |
-
//
|
1445 |
-
$
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
}
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
if (
|
1493 |
-
|
1494 |
-
}
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
}
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
if (
|
1566 |
-
$this->info['replay_gain']['
|
1567 |
-
}
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
}
|
1581 |
-
}
|
1582 |
-
return true;
|
1583 |
-
}
|
1584 |
-
|
1585 |
-
function
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
return true;
|
1596 |
-
}
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/////////////////////////////////////////////////////////////////
|
3 |
+
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
+
// available at http://getid3.sourceforge.net //
|
5 |
+
// or http://www.getid3.org //
|
6 |
+
// also https://github.com/JamesHeinrich/getID3 //
|
7 |
+
/////////////////////////////////////////////////////////////////
|
8 |
+
// //
|
9 |
+
// Please see readme.txt for more information //
|
10 |
+
// ///
|
11 |
+
/////////////////////////////////////////////////////////////////
|
12 |
+
|
13 |
+
// define a constant rather than looking up every time it is needed
|
14 |
+
if (!defined('GETID3_OS_ISWINDOWS')) {
|
15 |
+
define('GETID3_OS_ISWINDOWS', (stripos(PHP_OS, 'WIN') === 0));
|
16 |
+
}
|
17 |
+
// Get base path of getID3() - ONCE
|
18 |
+
if (!defined('GETID3_INCLUDEPATH')) {
|
19 |
+
define('GETID3_INCLUDEPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
|
20 |
+
}
|
21 |
+
// Workaround Bug #39923 (https://bugs.php.net/bug.php?id=39923)
|
22 |
+
if (!defined('IMG_JPG') && defined('IMAGETYPE_JPEG')) {
|
23 |
+
define('IMG_JPG', IMAGETYPE_JPEG);
|
24 |
+
}
|
25 |
+
|
26 |
+
// attempt to define temp dir as something flexible but reliable
|
27 |
+
$temp_dir = ini_get('upload_tmp_dir');
|
28 |
+
if ($temp_dir && (!is_dir($temp_dir) || !is_readable($temp_dir))) {
|
29 |
+
$temp_dir = '';
|
30 |
+
}
|
31 |
+
if (!$temp_dir) {
|
32 |
+
// sys_get_temp_dir() may give inaccessible temp dir, e.g. with open_basedir on virtual hosts
|
33 |
+
$temp_dir = sys_get_temp_dir();
|
34 |
+
}
|
35 |
+
$temp_dir = @realpath($temp_dir); // see https://github.com/JamesHeinrich/getID3/pull/10
|
36 |
+
$open_basedir = ini_get('open_basedir');
|
37 |
+
if ($open_basedir) {
|
38 |
+
// e.g. "/var/www/vhosts/getid3.org/httpdocs/:/tmp/"
|
39 |
+
$temp_dir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $temp_dir);
|
40 |
+
$open_basedir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $open_basedir);
|
41 |
+
if (substr($temp_dir, -1, 1) != DIRECTORY_SEPARATOR) {
|
42 |
+
$temp_dir .= DIRECTORY_SEPARATOR;
|
43 |
+
}
|
44 |
+
$found_valid_tempdir = false;
|
45 |
+
$open_basedirs = explode(PATH_SEPARATOR, $open_basedir);
|
46 |
+
foreach ($open_basedirs as $basedir) {
|
47 |
+
if (substr($basedir, -1, 1) != DIRECTORY_SEPARATOR) {
|
48 |
+
$basedir .= DIRECTORY_SEPARATOR;
|
49 |
+
}
|
50 |
+
if (preg_match('#^'.preg_quote($basedir).'#', $temp_dir)) {
|
51 |
+
$found_valid_tempdir = true;
|
52 |
+
break;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
if (!$found_valid_tempdir) {
|
56 |
+
$temp_dir = '';
|
57 |
+
}
|
58 |
+
unset($open_basedirs, $found_valid_tempdir, $basedir);
|
59 |
+
}
|
60 |
+
if (!$temp_dir) {
|
61 |
+
$temp_dir = '*'; // invalid directory name should force tempnam() to use system default temp dir
|
62 |
+
}
|
63 |
+
// $temp_dir = '/something/else/'; // feel free to override temp dir here if it works better for your system
|
64 |
+
if (!defined('GETID3_TEMP_DIR')) {
|
65 |
+
define('GETID3_TEMP_DIR', $temp_dir);
|
66 |
+
}
|
67 |
+
unset($open_basedir, $temp_dir);
|
68 |
+
|
69 |
+
// End: Defines
|
70 |
+
|
71 |
+
|
72 |
+
class getID3
|
73 |
+
{
|
74 |
+
// public: Settings
|
75 |
+
public $encoding = 'UTF-8'; // CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
|
76 |
+
public $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN' or 'CP1252'
|
77 |
+
|
78 |
+
// public: Optional tag checks - disable for speed.
|
79 |
+
public $option_tag_id3v1 = true; // Read and process ID3v1 tags
|
80 |
+
public $option_tag_id3v2 = true; // Read and process ID3v2 tags
|
81 |
+
public $option_tag_lyrics3 = true; // Read and process Lyrics3 tags
|
82 |
+
public $option_tag_apetag = true; // Read and process APE tags
|
83 |
+
public $option_tags_process = true; // Copy tags to root key 'tags' and encode to $this->encoding
|
84 |
+
public $option_tags_html = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
|
85 |
+
|
86 |
+
// public: Optional tag/comment calucations
|
87 |
+
public $option_extra_info = true; // Calculate additional info such as bitrate, channelmode etc
|
88 |
+
|
89 |
+
// public: Optional handling of embedded attachments (e.g. images)
|
90 |
+
public $option_save_attachments = true; // defaults to true (ATTACHMENTS_INLINE) for backward compatibility
|
91 |
+
|
92 |
+
// public: Optional calculations
|
93 |
+
public $option_md5_data = false; // Get MD5 sum of data part - slow
|
94 |
+
public $option_md5_data_source = false; // Use MD5 of source file if availble - only FLAC and OptimFROG
|
95 |
+
public $option_sha1_data = false; // Get SHA1 sum of data part - slow
|
96 |
+
public $option_max_2gb_check = null; // Check whether file is larger than 2GB and thus not supported by 32-bit PHP (null: auto-detect based on PHP_INT_MAX)
|
97 |
+
|
98 |
+
// public: Read buffer size in bytes
|
99 |
+
public $option_fread_buffer_size = 32768;
|
100 |
+
|
101 |
+
// Public variables
|
102 |
+
public $filename; // Filename of file being analysed.
|
103 |
+
public $fp; // Filepointer to file being analysed.
|
104 |
+
public $info; // Result array.
|
105 |
+
public $tempdir = GETID3_TEMP_DIR;
|
106 |
+
public $memory_limit = 0;
|
107 |
+
|
108 |
+
// Protected variables
|
109 |
+
protected $startup_error = '';
|
110 |
+
protected $startup_warning = '';
|
111 |
+
|
112 |
+
const VERSION = '1.9.8-20140511';
|
113 |
+
const FREAD_BUFFER_SIZE = 32768;
|
114 |
+
|
115 |
+
const ATTACHMENTS_NONE = false;
|
116 |
+
const ATTACHMENTS_INLINE = true;
|
117 |
+
|
118 |
+
// public: constructor
|
119 |
+
public function __construct() {
|
120 |
+
|
121 |
+
// Check for PHP version
|
122 |
+
$required_php_version = '5.3.0';
|
123 |
+
if (version_compare(PHP_VERSION, $required_php_version, '<')) {
|
124 |
+
$this->startup_error .= 'getID3() requires PHP v'.$required_php_version.' or higher - you are running v'.PHP_VERSION;
|
125 |
+
return false;
|
126 |
+
}
|
127 |
+
|
128 |
+
// Check memory
|
129 |
+
$this->memory_limit = ini_get('memory_limit');
|
130 |
+
if (preg_match('#([0-9]+)M#i', $this->memory_limit, $matches)) {
|
131 |
+
// could be stored as "16M" rather than 16777216 for example
|
132 |
+
$this->memory_limit = $matches[1] * 1048576;
|
133 |
+
} elseif (preg_match('#([0-9]+)G#i', $this->memory_limit, $matches)) { // The 'G' modifier is available since PHP 5.1.0
|
134 |
+
// could be stored as "2G" rather than 2147483648 for example
|
135 |
+
$this->memory_limit = $matches[1] * 1073741824;
|
136 |
+
}
|
137 |
+
if ($this->memory_limit <= 0) {
|
138 |
+
// memory limits probably disabled
|
139 |
+
} elseif ($this->memory_limit <= 4194304) {
|
140 |
+
$this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini';
|
141 |
+
} elseif ($this->memory_limit <= 12582912) {
|
142 |
+
$this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
|
143 |
+
}
|
144 |
+
|
145 |
+
// Check safe_mode off
|
146 |
+
if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
|
147 |
+
$this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
|
148 |
+
}
|
149 |
+
|
150 |
+
if (intval(ini_get('mbstring.func_overload')) > 0) {
|
151 |
+
$this->warning('WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", this may break things.');
|
152 |
+
}
|
153 |
+
|
154 |
+
// Check for magic_quotes_runtime
|
155 |
+
if (function_exists('get_magic_quotes_runtime')) {
|
156 |
+
if (get_magic_quotes_runtime()) {
|
157 |
+
return $this->startup_error('magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).');
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
// Check for magic_quotes_gpc
|
162 |
+
if (function_exists('magic_quotes_gpc')) {
|
163 |
+
if (get_magic_quotes_gpc()) {
|
164 |
+
return $this->startup_error('magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).');
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
// Load support library
|
169 |
+
if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
|
170 |
+
$this->startup_error .= 'getid3.lib.php is missing or corrupt';
|
171 |
+
}
|
172 |
+
|
173 |
+
if ($this->option_max_2gb_check === null) {
|
174 |
+
$this->option_max_2gb_check = (PHP_INT_MAX <= 2147483647);
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
// Needed for Windows only:
|
179 |
+
// Define locations of helper applications for Shorten, VorbisComment, MetaFLAC
|
180 |
+
// as well as other helper functions such as head, tail, md5sum, etc
|
181 |
+
// This path cannot contain spaces, but the below code will attempt to get the
|
182 |
+
// 8.3-equivalent path automatically
|
183 |
+
// IMPORTANT: This path must include the trailing slash
|
184 |
+
if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
|
185 |
+
|
186 |
+
$helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
|
187 |
+
|
188 |
+
if (!is_dir($helperappsdir)) {
|
189 |
+
$this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
|
190 |
+
} elseif (strpos(realpath($helperappsdir), ' ') !== false) {
|
191 |
+
$DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
|
192 |
+
$path_so_far = array();
|
193 |
+
foreach ($DirPieces as $key => $value) {
|
194 |
+
if (strpos($value, ' ') !== false) {
|
195 |
+
if (!empty($path_so_far)) {
|
196 |
+
$commandline = 'dir /x '.escapeshellarg(implode(DIRECTORY_SEPARATOR, $path_so_far));
|
197 |
+
$dir_listing = `$commandline`;
|
198 |
+
$lines = explode("\n", $dir_listing);
|
199 |
+
foreach ($lines as $line) {
|
200 |
+
$line = trim($line);
|
201 |
+
if (preg_match('#^([0-9/]{10}) +([0-9:]{4,5}( [AP]M)?) +(<DIR>|[0-9,]+) +([^ ]{0,11}) +(.+)$#', $line, $matches)) {
|
202 |
+
list($dummy, $date, $time, $ampm, $filesize, $shortname, $filename) = $matches;
|
203 |
+
if ((strtoupper($filesize) == '<DIR>') && (strtolower($filename) == strtolower($value))) {
|
204 |
+
$value = $shortname;
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
} else {
|
209 |
+
$this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.';
|
210 |
+
}
|
211 |
+
}
|
212 |
+
$path_so_far[] = $value;
|
213 |
+
}
|
214 |
+
$helperappsdir = implode(DIRECTORY_SEPARATOR, $path_so_far);
|
215 |
+
}
|
216 |
+
define('GETID3_HELPERAPPSDIR', $helperappsdir.DIRECTORY_SEPARATOR);
|
217 |
+
}
|
218 |
+
|
219 |
+
return true;
|
220 |
+
}
|
221 |
+
|
222 |
+
public function version() {
|
223 |
+
return self::VERSION;
|
224 |
+
}
|
225 |
+
|
226 |
+
public function fread_buffer_size() {
|
227 |
+
return $this->option_fread_buffer_size;
|
228 |
+
}
|
229 |
+
|
230 |
+
|
231 |
+
// public: setOption
|
232 |
+
public function setOption($optArray) {
|
233 |
+
if (!is_array($optArray) || empty($optArray)) {
|
234 |
+
return false;
|
235 |
+
}
|
236 |
+
foreach ($optArray as $opt => $val) {
|
237 |
+
if (isset($this->$opt) === false) {
|
238 |
+
continue;
|
239 |
+
}
|
240 |
+
$this->$opt = $val;
|
241 |
+
}
|
242 |
+
return true;
|
243 |
+
}
|
244 |
+
|
245 |
+
|
246 |
+
public function openfile($filename, $filesize = false) { // , $filesize=false added by POWERPRESS
|
247 |
+
try {
|
248 |
+
if (!empty($this->startup_error)) {
|
249 |
+
throw new getid3_exception($this->startup_error);
|
250 |
+
}
|
251 |
+
if (!empty($this->startup_warning)) {
|
252 |
+
$this->warning($this->startup_warning);
|
253 |
+
}
|
254 |
+
|
255 |
+
// init result array and set parameters
|
256 |
+
$this->filename = $filename;
|
257 |
+
$this->info = array();
|
258 |
+
$this->info['GETID3_VERSION'] = $this->version();
|
259 |
+
$this->info['php_memory_limit'] = $this->memory_limit;
|
260 |
+
|
261 |
+
// remote files not supported
|
262 |
+
if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
|
263 |
+
throw new getid3_exception('Remote files are not supported - please copy the file locally first');
|
264 |
+
}
|
265 |
+
|
266 |
+
$filename = str_replace('/', DIRECTORY_SEPARATOR, $filename);
|
267 |
+
$filename = preg_replace('#(.+)'.preg_quote(DIRECTORY_SEPARATOR).'{2,}#U', '\1'.DIRECTORY_SEPARATOR, $filename);
|
268 |
+
|
269 |
+
// open local file
|
270 |
+
//if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { // see http://www.getid3.org/phpBB3/viewtopic.php?t=1720
|
271 |
+
if ((is_readable($filename) || file_exists($filename)) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) {
|
272 |
+
// great
|
273 |
+
} else {
|
274 |
+
$errormessagelist = array();
|
275 |
+
if (!is_readable($filename)) {
|
276 |
+
$errormessagelist[] = '!is_readable';
|
277 |
+
}
|
278 |
+
if (!is_file($filename)) {
|
279 |
+
$errormessagelist[] = '!is_file';
|
280 |
+
}
|
281 |
+
if (!file_exists($filename)) {
|
282 |
+
$errormessagelist[] = '!file_exists';
|
283 |
+
}
|
284 |
+
if (empty($errormessagelist)) {
|
285 |
+
$errormessagelist[] = 'fopen failed';
|
286 |
+
}
|
287 |
+
throw new getid3_exception('Could not open "'.$filename.'" ('.implode('; ', $errormessagelist).')');
|
288 |
+
}
|
289 |
+
|
290 |
+
// START ADDED BY POWERPRESS
|
291 |
+
if( $filesize )
|
292 |
+
$this->info['filesize'] = $filesize;
|
293 |
+
else // END ADDED BY POWERPRESS
|
294 |
+
$this->info['filesize'] = filesize($filename);
|
295 |
+
// set redundant parameters - might be needed in some include file
|
296 |
+
// filenames / filepaths in getID3 are always expressed with forward slashes (unix-style) for both Windows and other to try and minimize confusion
|
297 |
+
$filename = str_replace('\\', '/', $filename);
|
298 |
+
$this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
|
299 |
+
$this->info['filename'] = getid3_lib::mb_basename($filename);
|
300 |
+
$this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
|
301 |
+
|
302 |
+
|
303 |
+
// option_max_2gb_check
|
304 |
+
if ($this->option_max_2gb_check) {
|
305 |
+
// PHP (32-bit all, and 64-bit Windows) doesn't support integers larger than 2^31 (~2GB)
|
306 |
+
// filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
|
307 |
+
// ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
|
308 |
+
$fseek = fseek($this->fp, 0, SEEK_END);
|
309 |
+
if (($fseek < 0) || (($this->info['filesize'] != 0) && (ftell($this->fp) == 0)) ||
|
310 |
+
($this->info['filesize'] < 0) ||
|
311 |
+
(ftell($this->fp) < 0)) {
|
312 |
+
$real_filesize = getid3_lib::getFileSizeSyscall($this->info['filenamepath']);
|
313 |
+
|
314 |
+
if ($real_filesize === false) {
|
315 |
+
unset($this->info['filesize']);
|
316 |
+
fclose($this->fp);
|
317 |
+
throw new getid3_exception('Unable to determine actual filesize. File is most likely larger than '.round(PHP_INT_MAX / 1073741824).'GB and is not supported by PHP.');
|
318 |
+
} elseif (getid3_lib::intValueSupported($real_filesize)) {
|
319 |
+
unset($this->info['filesize']);
|
320 |
+
fclose($this->fp);
|
321 |
+
throw new getid3_exception('PHP seems to think the file is larger than '.round(PHP_INT_MAX / 1073741824).'GB, but filesystem reports it as '.number_format($real_filesize, 3).'GB, please report to info@getid3.org');
|
322 |
+
}
|
323 |
+
$this->info['filesize'] = $real_filesize;
|
324 |
+
$this->warning('File is larger than '.round(PHP_INT_MAX / 1073741824).'GB (filesystem reports it as '.number_format($real_filesize, 3).'GB) and is not properly supported by PHP.');
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
// set more parameters
|
329 |
+
$this->info['avdataoffset'] = 0;
|
330 |
+
$this->info['avdataend'] = $this->info['filesize'];
|
331 |
+
$this->info['fileformat'] = ''; // filled in later
|
332 |
+
$this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
|
333 |
+
$this->info['video']['dataformat'] = ''; // filled in later, unset if not used
|
334 |
+
$this->info['tags'] = array(); // filled in later, unset if not used
|
335 |
+
$this->info['error'] = array(); // filled in later, unset if not used
|
336 |
+
$this->info['warning'] = array(); // filled in later, unset if not used
|
337 |
+
$this->info['comments'] = array(); // filled in later, unset if not used
|
338 |
+
$this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
|
339 |
+
|
340 |
+
return true;
|
341 |
+
|
342 |
+
} catch (Exception $e) {
|
343 |
+
$this->error($e->getMessage());
|
344 |
+
}
|
345 |
+
return false;
|
346 |
+
}
|
347 |
+
|
348 |
+
// public: analyze file
|
349 |
+
public function analyze($filename, $filesize=false, $orig_filename='file.mp3') { // 2nd AND 3rd PARAMTERS ADDED BY POWERPRESS
|
350 |
+
try {
|
351 |
+
if (!$this->openfile($filename, $filesize)) { // 2nd PARAMTER ADDED BY POWERPRESS
|
352 |
+
return $this->info;
|
353 |
+
}
|
354 |
+
|
355 |
+
// Handle tags
|
356 |
+
foreach (array('id3v2'=>'id3v2', 'id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
|
357 |
+
$option_tag = 'option_tag_'.$tag_name;
|
358 |
+
if ($this->$option_tag) {
|
359 |
+
$this->include_module('tag.'.$tag_name);
|
360 |
+
try {
|
361 |
+
$tag_class = 'getid3_'.$tag_name;
|
362 |
+
$tag = new $tag_class($this);
|
363 |
+
$tag->Analyze();
|
364 |
+
}
|
365 |
+
catch (getid3_exception $e) {
|
366 |
+
throw $e;
|
367 |
+
}
|
368 |
+
}
|
369 |
+
}
|
370 |
+
if (isset($this->info['id3v2']['tag_offset_start'])) {
|
371 |
+
$this->info['avdataoffset'] = max($this->info['avdataoffset'], $this->info['id3v2']['tag_offset_end']);
|
372 |
+
}
|
373 |
+
foreach (array('id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
|
374 |
+
if (isset($this->info[$tag_key]['tag_offset_start'])) {
|
375 |
+
$this->info['avdataend'] = min($this->info['avdataend'], $this->info[$tag_key]['tag_offset_start']);
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
// ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier
|
380 |
+
if (!$this->option_tag_id3v2) {
|
381 |
+
fseek($this->fp, 0);
|
382 |
+
$header = fread($this->fp, 10);
|
383 |
+
if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) {
|
384 |
+
$this->info['id3v2']['header'] = true;
|
385 |
+
$this->info['id3v2']['majorversion'] = ord($header{3});
|
386 |
+
$this->info['id3v2']['minorversion'] = ord($header{4});
|
387 |
+
$this->info['avdataoffset'] += getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
// read 32 kb file data
|
392 |
+
fseek($this->fp, $this->info['avdataoffset']);
|
393 |
+
$formattest = fread($this->fp, 32774);
|
394 |
+
|
395 |
+
// determine format
|
396 |
+
// MODIFIED BY POWERPRESS
|
397 |
+
$determined_format = $this->GetFileFormat($formattest, $orig_filename);
|
398 |
+
// MODIFIED BY POWERPRESS
|
399 |
+
|
400 |
+
// unable to determine file format
|
401 |
+
if (!$determined_format) {
|
402 |
+
fclose($this->fp);
|
403 |
+
return $this->error('unable to determine file format');
|
404 |
+
}
|
405 |
+
|
406 |
+
// check for illegal ID3 tags
|
407 |
+
if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) {
|
408 |
+
if ($determined_format['fail_id3'] === 'ERROR') {
|
409 |
+
fclose($this->fp);
|
410 |
+
return $this->error('ID3 tags not allowed on this file type.');
|
411 |
+
} elseif ($determined_format['fail_id3'] === 'WARNING') {
|
412 |
+
$this->warning('ID3 tags not allowed on this file type.');
|
413 |
+
}
|
414 |
+
}
|
415 |
+
|
416 |
+
// check for illegal APE tags
|
417 |
+
if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) {
|
418 |
+
if ($determined_format['fail_ape'] === 'ERROR') {
|
419 |
+
fclose($this->fp);
|
420 |
+
return $this->error('APE tags not allowed on this file type.');
|
421 |
+
} elseif ($determined_format['fail_ape'] === 'WARNING') {
|
422 |
+
$this->warning('APE tags not allowed on this file type.');
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
// set mime type
|
427 |
+
$this->info['mime_type'] = $determined_format['mime_type'];
|
428 |
+
|
429 |
+
// supported format signature pattern detected, but module deleted
|
430 |
+
if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
|
431 |
+
fclose($this->fp);
|
432 |
+
return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
|
433 |
+
}
|
434 |
+
|
435 |
+
// module requires iconv support
|
436 |
+
// Check encoding/iconv support
|
437 |
+
if (!empty($determined_format['iconv_req']) && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
|
438 |
+
$errormessage = 'iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
|
439 |
+
if (GETID3_OS_ISWINDOWS) {
|
440 |
+
$errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
|
441 |
+
} else {
|
442 |
+
$errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
|
443 |
+
}
|
444 |
+
return $this->error($errormessage);
|
445 |
+
}
|
446 |
+
|
447 |
+
// include module
|
448 |
+
include_once(GETID3_INCLUDEPATH.$determined_format['include']);
|
449 |
+
|
450 |
+
// instantiate module class
|
451 |
+
$class_name = 'getid3_'.$determined_format['module'];
|
452 |
+
if (!class_exists($class_name)) {
|
453 |
+
return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
|
454 |
+
}
|
455 |
+
$class = new $class_name($this);
|
456 |
+
$class->Analyze();
|
457 |
+
unset($class);
|
458 |
+
|
459 |
+
// close file
|
460 |
+
fclose($this->fp);
|
461 |
+
|
462 |
+
// process all tags - copy to 'tags' and convert charsets
|
463 |
+
if ($this->option_tags_process) {
|
464 |
+
$this->HandleAllTags();
|
465 |
+
}
|
466 |
+
|
467 |
+
// perform more calculations
|
468 |
+
if ($this->option_extra_info) {
|
469 |
+
$this->ChannelsBitratePlaytimeCalculations();
|
470 |
+
$this->CalculateCompressionRatioVideo();
|
471 |
+
$this->CalculateCompressionRatioAudio();
|
472 |
+
$this->CalculateReplayGain();
|
473 |
+
$this->ProcessAudioStreams();
|
474 |
+
}
|
475 |
+
|
476 |
+
// get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
|
477 |
+
if ($this->option_md5_data) {
|
478 |
+
// do not calc md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
|
479 |
+
if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
|
480 |
+
$this->getHashdata('md5');
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
// get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
|
485 |
+
if ($this->option_sha1_data) {
|
486 |
+
$this->getHashdata('sha1');
|
487 |
+
}
|
488 |
+
|
489 |
+
// remove undesired keys
|
490 |
+
$this->CleanUp();
|
491 |
+
|
492 |
+
} catch (Exception $e) {
|
493 |
+
$this->error('Caught exception: '.$e->getMessage());
|
494 |
+
}
|
495 |
+
|
496 |
+
// return info array
|
497 |
+
return $this->info;
|
498 |
+
}
|
499 |
+
|
500 |
+
|
501 |
+
// private: error handling
|
502 |
+
public function error($message) {
|
503 |
+
$this->CleanUp();
|
504 |
+
if (!isset($this->info['error'])) {
|
505 |
+
$this->info['error'] = array();
|
506 |
+
}
|
507 |
+
$this->info['error'][] = $message;
|
508 |
+
return $this->info;
|
509 |
+
}
|
510 |
+
|
511 |
+
|
512 |
+
// private: warning handling
|
513 |
+
public function warning($message) {
|
514 |
+
$this->info['warning'][] = $message;
|
515 |
+
return true;
|
516 |
+
}
|
517 |
+
|
518 |
+
|
519 |
+
// private: CleanUp
|
520 |
+
private function CleanUp() {
|
521 |
+
|
522 |
+
// remove possible empty keys
|
523 |
+
$AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
|
524 |
+
foreach ($AVpossibleEmptyKeys as $dummy => $key) {
|
525 |
+
if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) {
|
526 |
+
unset($this->info['audio'][$key]);
|
527 |
+
}
|
528 |
+
if (empty($this->info['video'][$key]) && isset($this->info['video'][$key])) {
|
529 |
+
unset($this->info['video'][$key]);
|
530 |
+
}
|
531 |
+
}
|
532 |
+
|
533 |
+
// remove empty root keys
|
534 |
+
if (!empty($this->info)) {
|
535 |
+
foreach ($this->info as $key => $value) {
|
536 |
+
if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
|
537 |
+
unset($this->info[$key]);
|
538 |
+
}
|
539 |
+
}
|
540 |
+
}
|
541 |
+
|
542 |
+
// remove meaningless entries from unknown-format files
|
543 |
+
if (empty($this->info['fileformat'])) {
|
544 |
+
if (isset($this->info['avdataoffset'])) {
|
545 |
+
unset($this->info['avdataoffset']);
|
546 |
+
}
|
547 |
+
if (isset($this->info['avdataend'])) {
|
548 |
+
unset($this->info['avdataend']);
|
549 |
+
}
|
550 |
+
}
|
551 |
+
|
552 |
+
// remove possible duplicated identical entries
|
553 |
+
if (!empty($this->info['error'])) {
|
554 |
+
$this->info['error'] = array_values(array_unique($this->info['error']));
|
555 |
+
}
|
556 |
+
if (!empty($this->info['warning'])) {
|
557 |
+
$this->info['warning'] = array_values(array_unique($this->info['warning']));
|
558 |
+
}
|
559 |
+
|
560 |
+
// remove "global variable" type keys
|
561 |
+
unset($this->info['php_memory_limit']);
|
562 |
+
|
563 |
+
return true;
|
564 |
+
}
|
565 |
+
|
566 |
+
|
567 |
+
// return array containing information about all supported formats
|
568 |
+
public function GetFileFormatArray() {
|
569 |
+
static $format_info = array();
|
570 |
+
if (empty($format_info)) {
|
571 |
+
$format_info = array(
|
572 |
+
|
573 |
+
// Audio formats
|
574 |
+
|
575 |
+
// AC-3 - audio - Dolby AC-3 / Dolby Digital
|
576 |
+
'ac3' => array(
|
577 |
+
'pattern' => '^\x0B\x77',
|
578 |
+
'group' => 'audio',
|
579 |
+
'module' => 'ac3',
|
580 |
+
'mime_type' => 'audio/ac3',
|
581 |
+
),
|
582 |
+
|
583 |
+
// AAC - audio - Advanced Audio Coding (AAC) - ADIF format
|
584 |
+
'adif' => array(
|
585 |
+
'pattern' => '^ADIF',
|
586 |
+
'group' => 'audio',
|
587 |
+
'module' => 'aac',
|
588 |
+
'mime_type' => 'application/octet-stream',
|
589 |
+
'fail_ape' => 'WARNING',
|
590 |
+
),
|
591 |
+
|
592 |
+
/*
|
593 |
+
// AA - audio - Audible Audiobook
|
594 |
+
'aa' => array(
|
595 |
+
'pattern' => '^.{4}\x57\x90\x75\x36',
|
596 |
+
'group' => 'audio',
|
597 |
+
'module' => 'aa',
|
598 |
+
'mime_type' => 'audio/audible',
|
599 |
+
),
|
600 |
+
*/
|
601 |
+
// AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
|
602 |
+
'adts' => array(
|
603 |
+
'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]',
|
604 |
+
'group' => 'audio',
|
605 |
+
'module' => 'aac',
|
606 |
+
'mime_type' => 'application/octet-stream',
|
607 |
+
'fail_ape' => 'WARNING',
|
608 |
+
),
|
609 |
+
|
610 |
+
|
611 |
+
// AU - audio - NeXT/Sun AUdio (AU)
|
612 |
+
'au' => array(
|
613 |
+
'pattern' => '^\.snd',
|
614 |
+
'group' => 'audio',
|
615 |
+
'module' => 'au',
|
616 |
+
'mime_type' => 'audio/basic',
|
617 |
+
),
|
618 |
+
|
619 |
+
// AMR - audio - Adaptive Multi Rate
|
620 |
+
'amr' => array(
|
621 |
+
'pattern' => '^\x23\x21AMR\x0A', // #!AMR[0A]
|
622 |
+
'group' => 'audio',
|
623 |
+
'module' => 'amr',
|
624 |
+
'mime_type' => 'audio/amr',
|
625 |
+
),
|
626 |
+
|
627 |
+
// AVR - audio - Audio Visual Research
|
628 |
+
'avr' => array(
|
629 |
+
'pattern' => '^2BIT',
|
630 |
+
'group' => 'audio',
|
631 |
+
'module' => 'avr',
|
632 |
+
'mime_type' => 'application/octet-stream',
|
633 |
+
),
|
634 |
+
|
635 |
+
// BONK - audio - Bonk v0.9+
|
636 |
+
'bonk' => array(
|
637 |
+
'pattern' => '^\x00(BONK|INFO|META| ID3)',
|
638 |
+
'group' => 'audio',
|
639 |
+
'module' => 'bonk',
|
640 |
+
'mime_type' => 'audio/xmms-bonk',
|
641 |
+
),
|
642 |
+
|
643 |
+
// DSS - audio - Digital Speech Standard
|
644 |
+
'dss' => array(
|
645 |
+
'pattern' => '^[\x02-\x03]ds[s2]',
|
646 |
+
'group' => 'audio',
|
647 |
+
'module' => 'dss',
|
648 |
+
'mime_type' => 'application/octet-stream',
|
649 |
+
),
|
650 |
+
|
651 |
+
// DTS - audio - Dolby Theatre System
|
652 |
+
'dts' => array(
|
653 |
+
'pattern' => '^\x7F\xFE\x80\x01',
|
654 |
+
'group' => 'audio',
|
655 |
+
'module' => 'dts',
|
656 |
+
'mime_type' => 'audio/dts',
|
657 |
+
),
|
658 |
+
|
659 |
+
// FLAC - audio - Free Lossless Audio Codec
|
660 |
+
'flac' => array(
|
661 |
+
'pattern' => '^fLaC',
|
662 |
+
'group' => 'audio',
|
663 |
+
'module' => 'flac',
|
664 |
+
'mime_type' => 'audio/x-flac',
|
665 |
+
),
|
666 |
+
|
667 |
+
// LA - audio - Lossless Audio (LA)
|
668 |
+
'la' => array(
|
669 |
+
'pattern' => '^LA0[2-4]',
|
670 |
+
'group' => 'audio',
|
671 |
+
'module' => 'la',
|
672 |
+
'mime_type' => 'application/octet-stream',
|
673 |
+
),
|
674 |
+
|
675 |
+
// LPAC - audio - Lossless Predictive Audio Compression (LPAC)
|
676 |
+
'lpac' => array(
|
677 |
+
'pattern' => '^LPAC',
|
678 |
+
'group' => 'audio',
|
679 |
+
'module' => 'lpac',
|
680 |
+
'mime_type' => 'application/octet-stream',
|
681 |
+
),
|
682 |
+
|
683 |
+
// MIDI - audio - MIDI (Musical Instrument Digital Interface)
|
684 |
+
'midi' => array(
|
685 |
+
'pattern' => '^MThd',
|
686 |
+
'group' => 'audio',
|
687 |
+
'module' => 'midi',
|
688 |
+
'mime_type' => 'audio/midi',
|
689 |
+
),
|
690 |
+
|
691 |
+
// MAC - audio - Monkey's Audio Compressor
|
692 |
+
'mac' => array(
|
693 |
+
'pattern' => '^MAC ',
|
694 |
+
'group' => 'audio',
|
695 |
+
'module' => 'monkey',
|
696 |
+
'mime_type' => 'application/octet-stream',
|
697 |
+
),
|
698 |
+
|
699 |
+
// has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available
|
700 |
+
// // MOD - audio - MODule (assorted sub-formats)
|
701 |
+
// 'mod' => array(
|
702 |
+
// 'pattern' => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)',
|
703 |
+
// 'group' => 'audio',
|
704 |
+
// 'module' => 'mod',
|
705 |
+
// 'option' => 'mod',
|
706 |
+
// 'mime_type' => 'audio/mod',
|
707 |
+
// ),
|
708 |
+
|
709 |
+
// MOD - audio - MODule (Impulse Tracker)
|
710 |
+
'it' => array(
|
711 |
+
'pattern' => '^IMPM',
|
712 |
+
'group' => 'audio',
|
713 |
+
'module' => 'mod',
|
714 |
+
//'option' => 'it',
|
715 |
+
'mime_type' => 'audio/it',
|
716 |
+
),
|
717 |
+
|
718 |
+
// MOD - audio - MODule (eXtended Module, various sub-formats)
|
719 |
+
'xm' => array(
|
720 |
+
'pattern' => '^Extended Module',
|
721 |
+
'group' => 'audio',
|
722 |
+
'module' => 'mod',
|
723 |
+
//'option' => 'xm',
|
724 |
+
'mime_type' => 'audio/xm',
|
725 |
+
),
|
726 |
+
|
727 |
+
// MOD - audio - MODule (ScreamTracker)
|
728 |
+
's3m' => array(
|
729 |
+
'pattern' => '^.{44}SCRM',
|
730 |
+
'group' => 'audio',
|
731 |
+
'module' => 'mod',
|
732 |
+
//'option' => 's3m',
|
733 |
+
'mime_type' => 'audio/s3m',
|
734 |
+
),
|
735 |
+
|
736 |
+
// MPC - audio - Musepack / MPEGplus
|
737 |
+
'mpc' => array(
|
738 |
+
'pattern' => '^(MPCK|MP\+|[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
|
739 |
+
'group' => 'audio',
|
740 |
+
'module' => 'mpc',
|
741 |
+
'mime_type' => 'audio/x-musepack',
|
742 |
+
),
|
743 |
+
|
744 |
+
// MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS)
|
745 |
+
'mp3' => array(
|
746 |
+
'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\x0B\x10-\x1B\x20-\x2B\x30-\x3B\x40-\x4B\x50-\x5B\x60-\x6B\x70-\x7B\x80-\x8B\x90-\x9B\xA0-\xAB\xB0-\xBB\xC0-\xCB\xD0-\xDB\xE0-\xEB\xF0-\xFB]',
|
747 |
+
'group' => 'audio',
|
748 |
+
'module' => 'mp3',
|
749 |
+
'mime_type' => 'audio/mpeg',
|
750 |
+
),
|
751 |
+
|
752 |
+
// OFR - audio - OptimFROG
|
753 |
+
'ofr' => array(
|
754 |
+
'pattern' => '^(\*RIFF|OFR)',
|
755 |
+
'group' => 'audio',
|
756 |
+
'module' => 'optimfrog',
|
757 |
+
'mime_type' => 'application/octet-stream',
|
758 |
+
),
|
759 |
+
|
760 |
+
// RKAU - audio - RKive AUdio compressor
|
761 |
+
'rkau' => array(
|
762 |
+
'pattern' => '^RKA',
|
763 |
+
'group' => 'audio',
|
764 |
+
'module' => 'rkau',
|
765 |
+
'mime_type' => 'application/octet-stream',
|
766 |
+
),
|
767 |
+
|
768 |
+
// SHN - audio - Shorten
|
769 |
+
'shn' => array(
|
770 |
+
'pattern' => '^ajkg',
|
771 |
+
'group' => 'audio',
|
772 |
+
'module' => 'shorten',
|
773 |
+
'mime_type' => 'audio/xmms-shn',
|
774 |
+
'fail_id3' => 'ERROR',
|
775 |
+
'fail_ape' => 'ERROR',
|
776 |
+
),
|
777 |
+
|
778 |
+
// TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org)
|
779 |
+
'tta' => array(
|
780 |
+
'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
|
781 |
+
'group' => 'audio',
|
782 |
+
'module' => 'tta',
|
783 |
+
'mime_type' => 'application/octet-stream',
|
784 |
+
),
|
785 |
+
|
786 |
+
// VOC - audio - Creative Voice (VOC)
|
787 |
+
'voc' => array(
|
788 |
+
'pattern' => '^Creative Voice File',
|
789 |
+
'group' => 'audio',
|
790 |
+
'module' => 'voc',
|
791 |
+
'mime_type' => 'audio/voc',
|
792 |
+
),
|
793 |
+
|
794 |
+
// VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF)
|
795 |
+
'vqf' => array(
|
796 |
+
'pattern' => '^TWIN',
|
797 |
+
'group' => 'audio',
|
798 |
+
'module' => 'vqf',
|
799 |
+
'mime_type' => 'application/octet-stream',
|
800 |
+
),
|
801 |
+
|
802 |
+
// WV - audio - WavPack (v4.0+)
|
803 |
+
'wv' => array(
|
804 |
+
'pattern' => '^wvpk',
|
805 |
+
'group' => 'audio',
|
806 |
+
'module' => 'wavpack',
|
807 |
+
'mime_type' => 'application/octet-stream',
|
808 |
+
),
|
809 |
+
|
810 |
+
|
811 |
+
// Audio-Video formats
|
812 |
+
|
813 |
+
// ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
|
814 |
+
'asf' => array(
|
815 |
+
'pattern' => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
|
816 |
+
'group' => 'audio-video',
|
817 |
+
'module' => 'asf',
|
818 |
+
'mime_type' => 'video/x-ms-asf',
|
819 |
+
'iconv_req' => false,
|
820 |
+
),
|
821 |
+
|
822 |
+
// BINK - audio/video - Bink / Smacker
|
823 |
+
'bink' => array(
|
824 |
+
'pattern' => '^(BIK|SMK)',
|
825 |
+
'group' => 'audio-video',
|
826 |
+
'module' => 'bink',
|
827 |
+
'mime_type' => 'application/octet-stream',
|
828 |
+
),
|
829 |
+
|
830 |
+
// FLV - audio/video - FLash Video
|
831 |
+
'flv' => array(
|
832 |
+
'pattern' => '^FLV\x01',
|
833 |
+
'group' => 'audio-video',
|
834 |
+
'module' => 'flv',
|
835 |
+
'mime_type' => 'video/x-flv',
|
836 |
+
),
|
837 |
+
|
838 |
+
// MKAV - audio/video - Mastroka
|
839 |
+
'matroska' => array(
|
840 |
+
'pattern' => '^\x1A\x45\xDF\xA3',
|
841 |
+
'group' => 'audio-video',
|
842 |
+
'module' => 'matroska',
|
843 |
+
'mime_type' => 'video/x-matroska', // may also be audio/x-matroska
|
844 |
+
),
|
845 |
+
|
846 |
+
// MPEG - audio/video - MPEG (Moving Pictures Experts Group)
|
847 |
+
'mpeg' => array(
|
848 |
+
'pattern' => '^\x00\x00\x01(\xBA|\xB3)',
|
849 |
+
'group' => 'audio-video',
|
850 |
+
'module' => 'mpeg',
|
851 |
+
'mime_type' => 'video/mpeg',
|
852 |
+
),
|
853 |
+
|
854 |
+
// NSV - audio/video - Nullsoft Streaming Video (NSV)
|
855 |
+
'nsv' => array(
|
856 |
+
'pattern' => '^NSV[sf]',
|
857 |
+
'group' => 'audio-video',
|
858 |
+
'module' => 'nsv',
|
859 |
+
'mime_type' => 'application/octet-stream',
|
860 |
+
),
|
861 |
+
|
862 |
+
// Ogg - audio/video - Ogg (Ogg-Vorbis, Ogg-FLAC, Speex, Ogg-Theora(*), Ogg-Tarkin(*))
|
863 |
+
'ogg' => array(
|
864 |
+
'pattern' => '^OggS',
|
865 |
+
'group' => 'audio',
|
866 |
+
'module' => 'ogg',
|
867 |
+
'mime_type' => 'application/ogg',
|
868 |
+
'fail_id3' => 'WARNING',
|
869 |
+
'fail_ape' => 'WARNING',
|
870 |
+
),
|
871 |
+
|
872 |
+
// QT - audio/video - Quicktime
|
873 |
+
'quicktime' => array(
|
874 |
+
'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
|
875 |
+
'group' => 'audio-video',
|
876 |
+
'module' => 'quicktime',
|
877 |
+
'mime_type' => 'video/quicktime',
|
878 |
+
),
|
879 |
+
|
880 |
+
// RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
|
881 |
+
'riff' => array(
|
882 |
+
'pattern' => '^(RIFF|SDSS|FORM)',
|
883 |
+
'group' => 'audio-video',
|
884 |
+
'module' => 'riff',
|
885 |
+
'mime_type' => 'audio/x-wave',
|
886 |
+
'fail_ape' => 'WARNING',
|
887 |
+
),
|
888 |
+
|
889 |
+
// Real - audio/video - RealAudio, RealVideo
|
890 |
+
'real' => array(
|
891 |
+
'pattern' => '^(\\.RMF|\\.ra)',
|
892 |
+
'group' => 'audio-video',
|
893 |
+
'module' => 'real',
|
894 |
+
'mime_type' => 'audio/x-realaudio',
|
895 |
+
),
|
896 |
+
|
897 |
+
// SWF - audio/video - ShockWave Flash
|
898 |
+
'swf' => array(
|
899 |
+
'pattern' => '^(F|C)WS',
|
900 |
+
'group' => 'audio-video',
|
901 |
+
'module' => 'swf',
|
902 |
+
'mime_type' => 'application/x-shockwave-flash',
|
903 |
+
),
|
904 |
+
|
905 |
+
// TS - audio/video - MPEG-2 Transport Stream
|
906 |
+
'ts' => array(
|
907 |
+
'pattern' => '^(\x47.{187}){10,}', // packets are 188 bytes long and start with 0x47 "G". Check for at least 10 packets matching this pattern
|
908 |
+
'group' => 'audio-video',
|
909 |
+
'module' => 'ts',
|
910 |
+
'mime_type' => 'video/MP2T',
|
911 |
+
),
|
912 |
+
|
913 |
+
|
914 |
+
// Still-Image formats
|
915 |
+
|
916 |
+
// BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
|
917 |
+
'bmp' => array(
|
918 |
+
'pattern' => '^BM',
|
919 |
+
'group' => 'graphic',
|
920 |
+
'module' => 'bmp',
|
921 |
+
'mime_type' => 'image/bmp',
|
922 |
+
'fail_id3' => 'ERROR',
|
923 |
+
'fail_ape' => 'ERROR',
|
924 |
+
),
|
925 |
+
|
926 |
+
// GIF - still image - Graphics Interchange Format
|
927 |
+
'gif' => array(
|
928 |
+
'pattern' => '^GIF',
|
929 |
+
'group' => 'graphic',
|
930 |
+
'module' => 'gif',
|
931 |
+
'mime_type' => 'image/gif',
|
932 |
+
'fail_id3' => 'ERROR',
|
933 |
+
'fail_ape' => 'ERROR',
|
934 |
+
),
|
935 |
+
|
936 |
+
// JPEG - still image - Joint Photographic Experts Group (JPEG)
|
937 |
+
'jpg' => array(
|
938 |
+
'pattern' => '^\xFF\xD8\xFF',
|
939 |
+
'group' => 'graphic',
|
940 |
+
'module' => 'jpg',
|
941 |
+
'mime_type' => 'image/jpeg',
|
942 |
+
'fail_id3' => 'ERROR',
|
943 |
+
'fail_ape' => 'ERROR',
|
944 |
+
),
|
945 |
+
|
946 |
+
// PCD - still image - Kodak Photo CD
|
947 |
+
'pcd' => array(
|
948 |
+
'pattern' => '^.{2048}PCD_IPI\x00',
|
949 |
+
'group' => 'graphic',
|
950 |
+
'module' => 'pcd',
|
951 |
+
'mime_type' => 'image/x-photo-cd',
|
952 |
+
'fail_id3' => 'ERROR',
|
953 |
+
'fail_ape' => 'ERROR',
|
954 |
+
),
|
955 |
+
|
956 |
+
|
957 |
+
// PNG - still image - Portable Network Graphics (PNG)
|
958 |
+
'png' => array(
|
959 |
+
'pattern' => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
|
960 |
+
'group' => 'graphic',
|
961 |
+
'module' => 'png',
|
962 |
+
'mime_type' => 'image/png',
|
963 |
+
'fail_id3' => 'ERROR',
|
964 |
+
'fail_ape' => 'ERROR',
|
965 |
+
),
|
966 |
+
|
967 |
+
|
968 |
+
// SVG - still image - Scalable Vector Graphics (SVG)
|
969 |
+
'svg' => array(
|
970 |
+
'pattern' => '(<!DOCTYPE svg PUBLIC |xmlns="http:\/\/www\.w3\.org\/2000\/svg")',
|
971 |
+
'group' => 'graphic',
|
972 |
+
'module' => 'svg',
|
973 |
+
'mime_type' => 'image/svg+xml',
|
974 |
+
'fail_id3' => 'ERROR',
|
975 |
+
'fail_ape' => 'ERROR',
|
976 |
+
),
|
977 |
+
|
978 |
+
|
979 |
+
// TIFF - still image - Tagged Information File Format (TIFF)
|
980 |
+
'tiff' => array(
|
981 |
+
'pattern' => '^(II\x2A\x00|MM\x00\x2A)',
|
982 |
+
'group' => 'graphic',
|
983 |
+
'module' => 'tiff',
|
984 |
+
'mime_type' => 'image/tiff',
|
985 |
+
'fail_id3' => 'ERROR',
|
986 |
+
'fail_ape' => 'ERROR',
|
987 |
+
),
|
988 |
+
|
989 |
+
|
990 |
+
// EFAX - still image - eFax (TIFF derivative)
|
991 |
+
'efax' => array(
|
992 |
+
'pattern' => '^\xDC\xFE',
|
993 |
+
'group' => 'graphic',
|
994 |
+
'module' => 'efax',
|
995 |
+
'mime_type' => 'image/efax',
|
996 |
+
'fail_id3' => 'ERROR',
|
997 |
+
'fail_ape' => 'ERROR',
|
998 |
+
),
|
999 |
+
|
1000 |
+
|
1001 |
+
// Data formats
|
1002 |
+
|
1003 |
+
// ISO - data - International Standards Organization (ISO) CD-ROM Image
|
1004 |
+
'iso' => array(
|
1005 |
+
'pattern' => '^.{32769}CD001',
|
1006 |
+
'group' => 'misc',
|
1007 |
+
'module' => 'iso',
|
1008 |
+
'mime_type' => 'application/octet-stream',
|
1009 |
+
'fail_id3' => 'ERROR',
|
1010 |
+
'fail_ape' => 'ERROR',
|
1011 |
+
'iconv_req' => false,
|
1012 |
+
),
|
1013 |
+
|
1014 |
+
// RAR - data - RAR compressed data
|
1015 |
+
'rar' => array(
|
1016 |
+
'pattern' => '^Rar\!',
|
1017 |
+
'group' => 'archive',
|
1018 |
+
'module' => 'rar',
|
1019 |
+
'mime_type' => 'application/octet-stream',
|
1020 |
+
'fail_id3' => 'ERROR',
|
1021 |
+
'fail_ape' => 'ERROR',
|
1022 |
+
),
|
1023 |
+
|
1024 |
+
// SZIP - audio/data - SZIP compressed data
|
1025 |
+
'szip' => array(
|
1026 |
+
'pattern' => '^SZ\x0A\x04',
|
1027 |
+
'group' => 'archive',
|
1028 |
+
'module' => 'szip',
|
1029 |
+
'mime_type' => 'application/octet-stream',
|
1030 |
+
'fail_id3' => 'ERROR',
|
1031 |
+
'fail_ape' => 'ERROR',
|
1032 |
+
),
|
1033 |
+
|
1034 |
+
// TAR - data - TAR compressed data
|
1035 |
+
'tar' => array(
|
1036 |
+
'pattern' => '^.{100}[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',
|
1037 |
+
'group' => 'archive',
|
1038 |
+
'module' => 'tar',
|
1039 |
+
'mime_type' => 'application/x-tar',
|
1040 |
+
'fail_id3' => 'ERROR',
|
1041 |
+
'fail_ape' => 'ERROR',
|
1042 |
+
),
|
1043 |
+
|
1044 |
+
// GZIP - data - GZIP compressed data
|
1045 |
+
'gz' => array(
|
1046 |
+
'pattern' => '^\x1F\x8B\x08',
|
1047 |
+
'group' => 'archive',
|
1048 |
+
'module' => 'gzip',
|
1049 |
+
'mime_type' => 'application/x-gzip',
|
1050 |
+
'fail_id3' => 'ERROR',
|
1051 |
+
'fail_ape' => 'ERROR',
|
1052 |
+
),
|
1053 |
+
|
1054 |
+
// ZIP - data - ZIP compressed data
|
1055 |
+
'zip' => array(
|
1056 |
+
'pattern' => '^PK\x03\x04',
|
1057 |
+
'group' => 'archive',
|
1058 |
+
'module' => 'zip',
|
1059 |
+
'mime_type' => 'application/zip',
|
1060 |
+
'fail_id3' => 'ERROR',
|
1061 |
+
'fail_ape' => 'ERROR',
|
1062 |
+
),
|
1063 |
+
|
1064 |
+
|
1065 |
+
// Misc other formats
|
1066 |
+
|
1067 |
+
// PAR2 - data - Parity Volume Set Specification 2.0
|
1068 |
+
'par2' => array (
|
1069 |
+
'pattern' => '^PAR2\x00PKT',
|
1070 |
+
'group' => 'misc',
|
1071 |
+
'module' => 'par2',
|
1072 |
+
'mime_type' => 'application/octet-stream',
|
1073 |
+
'fail_id3' => 'ERROR',
|
1074 |
+
'fail_ape' => 'ERROR',
|
1075 |
+
),
|
1076 |
+
|
1077 |
+
// PDF - data - Portable Document Format
|
1078 |
+
'pdf' => array(
|
1079 |
+
'pattern' => '^\x25PDF',
|
1080 |
+
'group' => 'misc',
|
1081 |
+
'module' => 'pdf',
|
1082 |
+
'mime_type' => 'application/pdf',
|
1083 |
+
'fail_id3' => 'ERROR',
|
1084 |
+
'fail_ape' => 'ERROR',
|
1085 |
+
),
|
1086 |
+
|
1087 |
+
// MSOFFICE - data - ZIP compressed data
|
1088 |
+
'msoffice' => array(
|
1089 |
+
'pattern' => '^\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1', // D0CF11E == DOCFILE == Microsoft Office Document
|
1090 |
+
'group' => 'misc',
|
1091 |
+
'module' => 'msoffice',
|
1092 |
+
'mime_type' => 'application/octet-stream',
|
1093 |
+
'fail_id3' => 'ERROR',
|
1094 |
+
'fail_ape' => 'ERROR',
|
1095 |
+
),
|
1096 |
+
|
1097 |
+
// CUE - data - CUEsheet (index to single-file disc images)
|
1098 |
+
'cue' => array(
|
1099 |
+
'pattern' => '', // empty pattern means cannot be automatically detected, will fall through all other formats and match based on filename and very basic file contents
|
1100 |
+
'group' => 'misc',
|
1101 |
+
'module' => 'cue',
|
1102 |
+
'mime_type' => 'application/octet-stream',
|
1103 |
+
),
|
1104 |
+
|
1105 |
+
);
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
return $format_info;
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
|
1112 |
+
|
1113 |
+
public function GetFileFormat(&$filedata, $filename='') {
|
1114 |
+
// this function will determine the format of a file based on usually
|
1115 |
+
// the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
|
1116 |
+
// and in the case of ISO CD image, 6 bytes offset 32kb from the start
|
1117 |
+
// of the file).
|
1118 |
+
|
1119 |
+
// Identify file format - loop through $format_info and detect with reg expr
|
1120 |
+
foreach ($this->GetFileFormatArray() as $format_name => $info) {
|
1121 |
+
// The /s switch on preg_match() forces preg_match() NOT to treat
|
1122 |
+
// newline (0x0A) characters as special chars but do a binary match
|
1123 |
+
if (!empty($info['pattern']) && preg_match('#'.$info['pattern'].'#s', $filedata)) {
|
1124 |
+
$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
|
1125 |
+
return $info;
|
1126 |
+
}
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
|
1130 |
+
if (preg_match('#\.mp[123a]$#i', $filename)) {
|
1131 |
+
// Too many mp3 encoders on the market put gabage in front of mpeg files
|
1132 |
+
// use assume format on these if format detection failed
|
1133 |
+
$GetFileFormatArray = $this->GetFileFormatArray();
|
1134 |
+
$info = $GetFileFormatArray['mp3'];
|
1135 |
+
$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
|
1136 |
+
return $info;
|
1137 |
+
} elseif (preg_match('/\.cue$/i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) {
|
1138 |
+
// there's not really a useful consistent "magic" at the beginning of .cue files to identify them
|
1139 |
+
// so until I think of something better, just go by filename if all other format checks fail
|
1140 |
+
// and verify there's at least one instance of "TRACK xx AUDIO" in the file
|
1141 |
+
$GetFileFormatArray = $this->GetFileFormatArray();
|
1142 |
+
$info = $GetFileFormatArray['cue'];
|
1143 |
+
$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
|
1144 |
+
return $info;
|
1145 |
+
}
|
1146 |
+
|
1147 |
+
return false;
|
1148 |
+
}
|
1149 |
+
|
1150 |
+
|
1151 |
+
// converts array to $encoding charset from $this->encoding
|
1152 |
+
public function CharConvert(&$array, $encoding) {
|
1153 |
+
|
1154 |
+
// identical encoding - end here
|
1155 |
+
if ($encoding == $this->encoding) {
|
1156 |
+
return;
|
1157 |
+
}
|
1158 |
+
|
1159 |
+
// loop thru array
|
1160 |
+
foreach ($array as $key => $value) {
|
1161 |
+
|
1162 |
+
// go recursive
|
1163 |
+
if (is_array($value)) {
|
1164 |
+
$this->CharConvert($array[$key], $encoding);
|
1165 |
+
}
|
1166 |
+
|
1167 |
+
// convert string
|
1168 |
+
elseif (is_string($value)) {
|
1169 |
+
$array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));
|
1170 |
+
}
|
1171 |
+
}
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
|
1175 |
+
public function HandleAllTags() {
|
1176 |
+
|
1177 |
+
// key name => array (tag name, character encoding)
|
1178 |
+
static $tags;
|
1179 |
+
if (empty($tags)) {
|
1180 |
+
$tags = array(
|
1181 |
+
'asf' => array('asf' , 'UTF-16LE'),
|
1182 |
+
'midi' => array('midi' , 'ISO-8859-1'),
|
1183 |
+
'nsv' => array('nsv' , 'ISO-8859-1'),
|
1184 |
+
'ogg' => array('vorbiscomment' , 'UTF-8'),
|
1185 |
+
'png' => array('png' , 'UTF-8'),
|
1186 |
+
'tiff' => array('tiff' , 'ISO-8859-1'),
|
1187 |
+
'quicktime' => array('quicktime' , 'UTF-8'),
|
1188 |
+
'real' => array('real' , 'ISO-8859-1'),
|
1189 |
+
'vqf' => array('vqf' , 'ISO-8859-1'),
|
1190 |
+
'zip' => array('zip' , 'ISO-8859-1'),
|
1191 |
+
'riff' => array('riff' , 'ISO-8859-1'),
|
1192 |
+
'lyrics3' => array('lyrics3' , 'ISO-8859-1'),
|
1193 |
+
'id3v1' => array('id3v1' , $this->encoding_id3v1),
|
1194 |
+
'id3v2' => array('id3v2' , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
|
1195 |
+
'ape' => array('ape' , 'UTF-8'),
|
1196 |
+
'cue' => array('cue' , 'ISO-8859-1'),
|
1197 |
+
'matroska' => array('matroska' , 'UTF-8'),
|
1198 |
+
'flac' => array('vorbiscomment' , 'UTF-8'),
|
1199 |
+
'divxtag' => array('divx' , 'ISO-8859-1'),
|
1200 |
+
'iptc' => array('iptc' , 'ISO-8859-1'),
|
1201 |
+
);
|
1202 |
+
}
|
1203 |
+
|
1204 |
+
// loop through comments array
|
1205 |
+
foreach ($tags as $comment_name => $tagname_encoding_array) {
|
1206 |
+
list($tag_name, $encoding) = $tagname_encoding_array;
|
1207 |
+
|
1208 |
+
// fill in default encoding type if not already present
|
1209 |
+
if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
|
1210 |
+
$this->info[$comment_name]['encoding'] = $encoding;
|
1211 |
+
}
|
1212 |
+
|
1213 |
+
// copy comments if key name set
|
1214 |
+
if (!empty($this->info[$comment_name]['comments'])) {
|
1215 |
+
foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
|
1216 |
+
foreach ($valuearray as $key => $value) {
|
1217 |
+
if (is_string($value)) {
|
1218 |
+
$value = trim($value, " \r\n\t"); // do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed!
|
1219 |
+
}
|
1220 |
+
if ($value) {
|
1221 |
+
if (!is_numeric($key)) {
|
1222 |
+
$this->info['tags'][trim($tag_name)][trim($tag_key)][$key] = $value;
|
1223 |
+
} else {
|
1224 |
+
$this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value;
|
1225 |
+
}
|
1226 |
+
}
|
1227 |
+
}
|
1228 |
+
if ($tag_key == 'picture') {
|
1229 |
+
unset($this->info[$comment_name]['comments'][$tag_key]);
|
1230 |
+
}
|
1231 |
+
}
|
1232 |
+
|
1233 |
+
if (!isset($this->info['tags'][$tag_name])) {
|
1234 |
+
// comments are set but contain nothing but empty strings, so skip
|
1235 |
+
continue;
|
1236 |
+
}
|
1237 |
+
|
1238 |
+
if ($this->option_tags_html) {
|
1239 |
+
foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
|
1240 |
+
$this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $encoding);
|
1241 |
+
}
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
$this->CharConvert($this->info['tags'][$tag_name], $encoding); // only copy gets converted!
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
}
|
1248 |
+
|
1249 |
+
// pictures can take up a lot of space, and we don't need multiple copies of them
|
1250 |
+
// let there be a single copy in [comments][picture], and not elsewhere
|
1251 |
+
if (!empty($this->info['tags'])) {
|
1252 |
+
$unset_keys = array('tags', 'tags_html');
|
1253 |
+
foreach ($this->info['tags'] as $tagtype => $tagarray) {
|
1254 |
+
foreach ($tagarray as $tagname => $tagdata) {
|
1255 |
+
if ($tagname == 'picture') {
|
1256 |
+
foreach ($tagdata as $key => $tagarray) {
|
1257 |
+
$this->info['comments']['picture'][] = $tagarray;
|
1258 |
+
if (isset($tagarray['data']) && isset($tagarray['image_mime'])) {
|
1259 |
+
if (isset($this->info['tags'][$tagtype][$tagname][$key])) {
|
1260 |
+
unset($this->info['tags'][$tagtype][$tagname][$key]);
|
1261 |
+
}
|
1262 |
+
if (isset($this->info['tags_html'][$tagtype][$tagname][$key])) {
|
1263 |
+
unset($this->info['tags_html'][$tagtype][$tagname][$key]);
|
1264 |
+
}
|
1265 |
+
}
|
1266 |
+
}
|
1267 |
+
}
|
1268 |
+
}
|
1269 |
+
foreach ($unset_keys as $unset_key) {
|
1270 |
+
// remove possible empty keys from (e.g. [tags][id3v2][picture])
|
1271 |
+
if (empty($this->info[$unset_key][$tagtype]['picture'])) {
|
1272 |
+
unset($this->info[$unset_key][$tagtype]['picture']);
|
1273 |
+
}
|
1274 |
+
if (empty($this->info[$unset_key][$tagtype])) {
|
1275 |
+
unset($this->info[$unset_key][$tagtype]);
|
1276 |
+
}
|
1277 |
+
if (empty($this->info[$unset_key])) {
|
1278 |
+
unset($this->info[$unset_key]);
|
1279 |
+
}
|
1280 |
+
}
|
1281 |
+
// remove duplicate copy of picture data from (e.g. [id3v2][comments][picture])
|
1282 |
+
if (isset($this->info[$tagtype]['comments']['picture'])) {
|
1283 |
+
unset($this->info[$tagtype]['comments']['picture']);
|
1284 |
+
}
|
1285 |
+
if (empty($this->info[$tagtype]['comments'])) {
|
1286 |
+
unset($this->info[$tagtype]['comments']);
|
1287 |
+
}
|
1288 |
+
if (empty($this->info[$tagtype])) {
|
1289 |
+
unset($this->info[$tagtype]);
|
1290 |
+
}
|
1291 |
+
}
|
1292 |
+
}
|
1293 |
+
return true;
|
1294 |
+
}
|
1295 |
+
|
1296 |
+
public function getHashdata($algorithm) {
|
1297 |
+
switch ($algorithm) {
|
1298 |
+
case 'md5':
|
1299 |
+
case 'sha1':
|
1300 |
+
break;
|
1301 |
+
|
1302 |
+
default:
|
1303 |
+
return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
|
1304 |
+
break;
|
1305 |
+
}
|
1306 |
+
|
1307 |
+
if (!empty($this->info['fileformat']) && !empty($this->info['dataformat']) && ($this->info['fileformat'] == 'ogg') && ($this->info['audio']['dataformat'] == 'vorbis')) {
|
1308 |
+
|
1309 |
+
// We cannot get an identical md5_data value for Ogg files where the comments
|
1310 |
+
// span more than 1 Ogg page (compared to the same audio data with smaller
|
1311 |
+
// comments) using the normal getID3() method of MD5'ing the data between the
|
1312 |
+
// end of the comments and the end of the file (minus any trailing tags),
|
1313 |
+
// because the page sequence numbers of the pages that the audio data is on
|
1314 |
+
// do not match. Under normal circumstances, where comments are smaller than
|
1315 |
+
// the nominal 4-8kB page size, then this is not a problem, but if there are
|
1316 |
+
// very large comments, the only way around it is to strip off the comment
|
1317 |
+
// tags with vorbiscomment and MD5 that file.
|
1318 |
+
// This procedure must be applied to ALL Ogg files, not just the ones with
|
1319 |
+
// comments larger than 1 page, because the below method simply MD5's the
|
1320 |
+
// whole file with the comments stripped, not just the portion after the
|
1321 |
+
// comments block (which is the standard getID3() method.
|
1322 |
+
|
1323 |
+
// The above-mentioned problem of comments spanning multiple pages and changing
|
1324 |
+
// page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
|
1325 |
+
// currently vorbiscomment only works on OggVorbis files.
|
1326 |
+
|
1327 |
+
if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
|
1328 |
+
|
1329 |
+
$this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)');
|
1330 |
+
$this->info[$algorithm.'_data'] = false;
|
1331 |
+
|
1332 |
+
} else {
|
1333 |
+
|
1334 |
+
// Prevent user from aborting script
|
1335 |
+
$old_abort = ignore_user_abort(true);
|
1336 |
+
|
1337 |
+
// Create empty file
|
1338 |
+
$empty = tempnam(GETID3_TEMP_DIR, 'getID3');
|
1339 |
+
touch($empty);
|
1340 |
+
|
1341 |
+
// Use vorbiscomment to make temp file without comments
|
1342 |
+
$temp = tempnam(GETID3_TEMP_DIR, 'getID3');
|
1343 |
+
$file = $this->info['filenamepath'];
|
1344 |
+
|
1345 |
+
if (GETID3_OS_ISWINDOWS) {
|
1346 |
+
|
1347 |
+
if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
|
1348 |
+
|
1349 |
+
$commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"';
|
1350 |
+
$VorbisCommentError = `$commandline`;
|
1351 |
+
|
1352 |
+
} else {
|
1353 |
+
|
1354 |
+
$VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
|
1355 |
+
|
1356 |
+
}
|
1357 |
+
|
1358 |
+
} else {
|
1359 |
+
|
1360 |
+
$commandline = 'vorbiscomment -w -c "'.$empty.'" "'.$file.'" "'.$temp.'" 2>&1';
|
1361 |
+
$commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
|
1362 |
+
$VorbisCommentError = `$commandline`;
|
1363 |
+
|
1364 |
+
}
|
1365 |
+
|
1366 |
+
if (!empty($VorbisCommentError)) {
|
1367 |
+
|
1368 |
+
$this->info['warning'][] = 'Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
|
1369 |
+
$this->info[$algorithm.'_data'] = false;
|
1370 |
+
|
1371 |
+
} else {
|
1372 |
+
|
1373 |
+
// Get hash of newly created file
|
1374 |
+
switch ($algorithm) {
|
1375 |
+
case 'md5':
|
1376 |
+
$this->info[$algorithm.'_data'] = md5_file($temp);
|
1377 |
+
break;
|
1378 |
+
|
1379 |
+
case 'sha1':
|
1380 |
+
$this->info[$algorithm.'_data'] = sha1_file($temp);
|
1381 |
+
break;
|
1382 |
+
}
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
// Clean up
|
1386 |
+
unlink($empty);
|
1387 |
+
unlink($temp);
|
1388 |
+
|
1389 |
+
// Reset abort setting
|
1390 |
+
ignore_user_abort($old_abort);
|
1391 |
+
|
1392 |
+
}
|
1393 |
+
|
1394 |
+
} else {
|
1395 |
+
|
1396 |
+
if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
|
1397 |
+
|
1398 |
+
// get hash from part of file
|
1399 |
+
$this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);
|
1400 |
+
|
1401 |
+
} else {
|
1402 |
+
|
1403 |
+
// get hash from whole file
|
1404 |
+
switch ($algorithm) {
|
1405 |
+
case 'md5':
|
1406 |
+
$this->info[$algorithm.'_data'] = md5_file($this->info['filenamepath']);
|
1407 |
+
break;
|
1408 |
+
|
1409 |
+
case 'sha1':
|
1410 |
+
$this->info[$algorithm.'_data'] = sha1_file($this->info['filenamepath']);
|
1411 |
+
break;
|
1412 |
+
}
|
1413 |
+
}
|
1414 |
+
|
1415 |
+
}
|
1416 |
+
return true;
|
1417 |
+
}
|
1418 |
+
|
1419 |
+
|
1420 |
+
public function ChannelsBitratePlaytimeCalculations() {
|
1421 |
+
|
1422 |
+
// set channelmode on audio
|
1423 |
+
if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
|
1424 |
+
// ignore
|
1425 |
+
} elseif ($this->info['audio']['channels'] == 1) {
|
1426 |
+
$this->info['audio']['channelmode'] = 'mono';
|
1427 |
+
} elseif ($this->info['audio']['channels'] == 2) {
|
1428 |
+
$this->info['audio']['channelmode'] = 'stereo';
|
1429 |
+
}
|
1430 |
+
|
1431 |
+
// Calculate combined bitrate - audio + video
|
1432 |
+
$CombinedBitrate = 0;
|
1433 |
+
$CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);
|
1434 |
+
$CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);
|
1435 |
+
if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {
|
1436 |
+
$this->info['bitrate'] = $CombinedBitrate;
|
1437 |
+
}
|
1438 |
+
//if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) {
|
1439 |
+
// // for example, VBR MPEG video files cannot determine video bitrate:
|
1440 |
+
// // should not set overall bitrate and playtime from audio bitrate only
|
1441 |
+
// unset($this->info['bitrate']);
|
1442 |
+
//}
|
1443 |
+
|
1444 |
+
// video bitrate undetermined, but calculable
|
1445 |
+
if (isset($this->info['video']['dataformat']) && $this->info['video']['dataformat'] && (!isset($this->info['video']['bitrate']) || ($this->info['video']['bitrate'] == 0))) {
|
1446 |
+
// if video bitrate not set
|
1447 |
+
if (isset($this->info['audio']['bitrate']) && ($this->info['audio']['bitrate'] > 0) && ($this->info['audio']['bitrate'] == $this->info['bitrate'])) {
|
1448 |
+
// AND if audio bitrate is set to same as overall bitrate
|
1449 |
+
if (isset($this->info['playtime_seconds']) && ($this->info['playtime_seconds'] > 0)) {
|
1450 |
+
// AND if playtime is set
|
1451 |
+
if (isset($this->info['avdataend']) && isset($this->info['avdataoffset'])) {
|
1452 |
+
// AND if AV data offset start/end is known
|
1453 |
+
// THEN we can calculate the video bitrate
|
1454 |
+
$this->info['bitrate'] = round((($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds']);
|
1455 |
+
$this->info['video']['bitrate'] = $this->info['bitrate'] - $this->info['audio']['bitrate'];
|
1456 |
+
}
|
1457 |
+
}
|
1458 |
+
}
|
1459 |
+
}
|
1460 |
+
|
1461 |
+
if ((!isset($this->info['playtime_seconds']) || ($this->info['playtime_seconds'] <= 0)) && !empty($this->info['bitrate'])) {
|
1462 |
+
$this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];
|
1463 |
+
}
|
1464 |
+
|
1465 |
+
if (!isset($this->info['bitrate']) && !empty($this->info['playtime_seconds'])) {
|
1466 |
+
$this->info['bitrate'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds'];
|
1467 |
+
}
|
1468 |
+
if (isset($this->info['bitrate']) && empty($this->info['audio']['bitrate']) && empty($this->info['video']['bitrate'])) {
|
1469 |
+
if (isset($this->info['audio']['dataformat']) && empty($this->info['video']['resolution_x'])) {
|
1470 |
+
// audio only
|
1471 |
+
$this->info['audio']['bitrate'] = $this->info['bitrate'];
|
1472 |
+
} elseif (isset($this->info['video']['resolution_x']) && empty($this->info['audio']['dataformat'])) {
|
1473 |
+
// video only
|
1474 |
+
$this->info['video']['bitrate'] = $this->info['bitrate'];
|
1475 |
+
}
|
1476 |
+
}
|
1477 |
+
|
1478 |
+
// Set playtime string
|
1479 |
+
if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
|
1480 |
+
$this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);
|
1481 |
+
}
|
1482 |
+
}
|
1483 |
+
|
1484 |
+
|
1485 |
+
public function CalculateCompressionRatioVideo() {
|
1486 |
+
if (empty($this->info['video'])) {
|
1487 |
+
return false;
|
1488 |
+
}
|
1489 |
+
if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
|
1490 |
+
return false;
|
1491 |
+
}
|
1492 |
+
if (empty($this->info['video']['bits_per_sample'])) {
|
1493 |
+
return false;
|
1494 |
+
}
|
1495 |
+
|
1496 |
+
switch ($this->info['video']['dataformat']) {
|
1497 |
+
case 'bmp':
|
1498 |
+
case 'gif':
|
1499 |
+
case 'jpeg':
|
1500 |
+
case 'jpg':
|
1501 |
+
case 'png':
|
1502 |
+
case 'tiff':
|
1503 |
+
$FrameRate = 1;
|
1504 |
+
$PlaytimeSeconds = 1;
|
1505 |
+
$BitrateCompressed = $this->info['filesize'] * 8;
|
1506 |
+
break;
|
1507 |
+
|
1508 |
+
default:
|
1509 |
+
if (!empty($this->info['video']['frame_rate'])) {
|
1510 |
+
$FrameRate = $this->info['video']['frame_rate'];
|
1511 |
+
} else {
|
1512 |
+
return false;
|
1513 |
+
}
|
1514 |
+
if (!empty($this->info['playtime_seconds'])) {
|
1515 |
+
$PlaytimeSeconds = $this->info['playtime_seconds'];
|
1516 |
+
} else {
|
1517 |
+
return false;
|
1518 |
+
}
|
1519 |
+
if (!empty($this->info['video']['bitrate'])) {
|
1520 |
+
$BitrateCompressed = $this->info['video']['bitrate'];
|
1521 |
+
} else {
|
1522 |
+
return false;
|
1523 |
+
}
|
1524 |
+
break;
|
1525 |
+
}
|
1526 |
+
$BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;
|
1527 |
+
|
1528 |
+
$this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
|
1529 |
+
return true;
|
1530 |
+
}
|
1531 |
+
|
1532 |
+
|
1533 |
+
public function CalculateCompressionRatioAudio() {
|
1534 |
+
if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate']) || !is_numeric($this->info['audio']['sample_rate'])) {
|
1535 |
+
return false;
|
1536 |
+
}
|
1537 |
+
$this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
|
1538 |
+
|
1539 |
+
if (!empty($this->info['audio']['streams'])) {
|
1540 |
+
foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {
|
1541 |
+
if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {
|
1542 |
+
$this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
|
1543 |
+
}
|
1544 |
+
}
|
1545 |
+
}
|
1546 |
+
return true;
|
1547 |
+
}
|
1548 |
+
|
1549 |
+
|
1550 |
+
public function CalculateReplayGain() {
|
1551 |
+
if (isset($this->info['replay_gain'])) {
|
1552 |
+
if (!isset($this->info['replay_gain']['reference_volume'])) {
|
1553 |
+
$this->info['replay_gain']['reference_volume'] = (double) 89.0;
|
1554 |
+
}
|
1555 |
+
if (isset($this->info['replay_gain']['track']['adjustment'])) {
|
1556 |
+
$this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
|
1557 |
+
}
|
1558 |
+
if (isset($this->info['replay_gain']['album']['adjustment'])) {
|
1559 |
+
$this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];
|
1560 |
+
}
|
1561 |
+
|
1562 |
+
if (isset($this->info['replay_gain']['track']['peak'])) {
|
1563 |
+
$this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);
|
1564 |
+
}
|
1565 |
+
if (isset($this->info['replay_gain']['album']['peak'])) {
|
1566 |
+
$this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);
|
1567 |
+
}
|
1568 |
+
}
|
1569 |
+
return true;
|
1570 |
+
}
|
1571 |
+
|
1572 |
+
public function ProcessAudioStreams() {
|
1573 |
+
if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
|
1574 |
+
if (!isset($this->info['audio']['streams'])) {
|
1575 |
+
foreach ($this->info['audio'] as $key => $value) {
|
1576 |
+
if ($key != 'streams') {
|
1577 |
+
$this->info['audio']['streams'][0][$key] = $value;
|
1578 |
+
}
|
1579 |
+
}
|
1580 |
+
}
|
1581 |
+
}
|
1582 |
+
return true;
|
1583 |
+
}
|
1584 |
+
|
1585 |
+
public function getid3_tempnam() {
|
1586 |
+
return tempnam($this->tempdir, 'gI3');
|
1587 |
+
}
|
1588 |
+
|
1589 |
+
public function include_module($name) {
|
1590 |
+
//if (!file_exists($this->include_path.'module.'.$name.'.php')) {
|
1591 |
+
if (!file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) {
|
1592 |
+
throw new getid3_exception('Required module.'.$name.'.php is missing.');
|
1593 |
+
}
|
1594 |
+
include_once(GETID3_INCLUDEPATH.'module.'.$name.'.php');
|
1595 |
+
return true;
|
1596 |
+
}
|
1597 |
+
|
1598 |
+
}
|
1599 |
+
|
1600 |
+
|
1601 |
+
abstract class getid3_handler {
|
1602 |
+
|
1603 |
+
/**
|
1604 |
+
* @var getID3
|
1605 |
+
*/
|
1606 |
+
protected $getid3; // pointer
|
1607 |
+
|
1608 |
+
protected $data_string_flag = false; // analyzing filepointer or string
|
1609 |
+
protected $data_string = ''; // string to analyze
|
1610 |
+
protected $data_string_position = 0; // seek position in string
|
1611 |
+
protected $data_string_length = 0; // string length
|
1612 |
+
|
1613 |
+
private $dependency_to = null;
|
1614 |
+
|
1615 |
+
|
1616 |
+
public function __construct(getID3 $getid3, $call_module=null) {
|
1617 |
+
$this->getid3 = $getid3;
|
1618 |
+
|
1619 |
+
if ($call_module) {
|
1620 |
+
$this->dependency_to = str_replace('getid3_', '', $call_module);
|
1621 |
+
}
|
1622 |
+
}
|
1623 |
+
|
1624 |
+
|
1625 |
+
// Analyze from file pointer
|
1626 |
+
abstract public function Analyze();
|
1627 |
+
|
1628 |
+
|
1629 |
+
// Analyze from string instead
|
1630 |
+
public function AnalyzeString($string) {
|
1631 |
+
// Enter string mode
|
1632 |
+
$this->setStringMode($string);
|
1633 |
+
|
1634 |
+
// Save info
|
1635 |
+
$saved_avdataoffset = $this->getid3->info['avdataoffset'];
|
1636 |
+
$saved_avdataend = $this->getid3->info['avdataend'];
|
1637 |
+
$saved_filesize = (isset($this->getid3->info['filesize']) ? $this->getid3->info['filesize'] : null); // may be not set if called as dependency without openfile() call
|
1638 |
+
|
1639 |
+
// Reset some info
|
1640 |
+
$this->getid3->info['avdataoffset'] = 0;
|
1641 |
+
$this->getid3->info['avdataend'] = $this->getid3->info['filesize'] = $this->data_string_length;
|
1642 |
+
|
1643 |
+
// Analyze
|
1644 |
+
$this->Analyze();
|
1645 |
+
|
1646 |
+
// Restore some info
|
1647 |
+
$this->getid3->info['avdataoffset'] = $saved_avdataoffset;
|
1648 |
+
$this->getid3->info['avdataend'] = $saved_avdataend;
|
1649 |
+
$this->getid3->info['filesize'] = $saved_filesize;
|
1650 |
+
|
1651 |
+
// Exit string mode
|
1652 |
+
$this->data_string_flag = false;
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
public function setStringMode($string) {
|
1656 |
+
$this->data_string_flag = true;
|
1657 |
+
$this->data_string = $string;
|
1658 |
+
$this->data_string_length = strlen($string);
|
1659 |
+
}
|
1660 |
+
|
1661 |
+
protected function ftell() {
|
1662 |
+
if ($this->data_string_flag) {
|
1663 |
+
return $this->data_string_position;
|
1664 |
+
}
|
1665 |
+
return ftell($this->getid3->fp);
|
1666 |
+
}
|
1667 |
+
|
1668 |
+
protected function fread($bytes) {
|
1669 |
+
if ($this->data_string_flag) {
|
1670 |
+
$this->data_string_position += $bytes;
|
1671 |
+
return substr($this->data_string, $this->data_string_position - $bytes, $bytes);
|
1672 |
+
}
|
1673 |
+
$pos = $this->ftell() + $bytes;
|
1674 |
+
if (!getid3_lib::intValueSupported($pos)) {
|
1675 |
+
throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
|
1676 |
+
}
|
1677 |
+
return fread($this->getid3->fp, $bytes);
|
1678 |
+
}
|
1679 |
+
|
1680 |
+
protected function fseek($bytes, $whence=SEEK_SET) {
|
1681 |
+
if ($this->data_string_flag) {
|
1682 |
+
switch ($whence) {
|
1683 |
+
case SEEK_SET:
|
1684 |
+
$this->data_string_position = $bytes;
|
1685 |
+
break;
|
1686 |
+
|
1687 |
+
case SEEK_CUR:
|
1688 |
+
$this->data_string_position += $bytes;
|
1689 |
+
break;
|
1690 |
+
|
1691 |
+
case SEEK_END:
|
1692 |
+
$this->data_string_position = $this->data_string_length + $bytes;
|
1693 |
+
break;
|
1694 |
+
}
|
1695 |
+
return 0;
|
1696 |
+
} else {
|
1697 |
+
$pos = $bytes;
|
1698 |
+
if ($whence == SEEK_CUR) {
|
1699 |
+
$pos = $this->ftell() + $bytes;
|
1700 |
+
} elseif ($whence == SEEK_END) {
|
1701 |
+
$pos = $this->getid3->info['filesize'] + $bytes;
|
1702 |
+
}
|
1703 |
+
if (!getid3_lib::intValueSupported($pos)) {
|
1704 |
+
throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
|
1705 |
+
}
|
1706 |
+
}
|
1707 |
+
return fseek($this->getid3->fp, $bytes, $whence);
|
1708 |
+
}
|
1709 |
+
|
1710 |
+
protected function feof() {
|
1711 |
+
if ($this->data_string_flag) {
|
1712 |
+
return $this->data_string_position >= $this->data_string_length;
|
1713 |
+
}
|
1714 |
+
return feof($this->getid3->fp);
|
1715 |
+
}
|
1716 |
+
|
1717 |
+
final protected function isDependencyFor($module) {
|
1718 |
+
return $this->dependency_to == $module;
|
1719 |
+
}
|
1720 |
+
|
1721 |
+
protected function error($text) {
|
1722 |
+
$this->getid3->info['error'][] = $text;
|
1723 |
+
|
1724 |
+
return false;
|
1725 |
+
}
|
1726 |
+
|
1727 |
+
protected function warning($text) {
|
1728 |
+
return $this->getid3->warning($text);
|
1729 |
+
}
|
1730 |
+
|
1731 |
+
protected function notice($text) {
|
1732 |
+
// does nothing for now
|
1733 |
+
}
|
1734 |
+
|
1735 |
+
public function saveAttachment($name, $offset, $length, $image_mime=null) {
|
1736 |
+
try {
|
1737 |
+
|
1738 |
+
// do not extract at all
|
1739 |
+
if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
|
1740 |
+
|
1741 |
+
$attachment = null; // do not set any
|
1742 |
+
|
1743 |
+
// extract to return array
|
1744 |
+
} elseif ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
|
1745 |
+
|
1746 |
+
$this->fseek($offset);
|
1747 |
+
$attachment = $this->fread($length); // get whole data in one pass, till it is anyway stored in memory
|
1748 |
+
if ($attachment === false || strlen($attachment) != $length) {
|
1749 |
+
throw new Exception('failed to read attachment data');
|
1750 |
+
}
|
1751 |
+
|
1752 |
+
// assume directory path is given
|
1753 |
+
} else {
|
1754 |
+
|
1755 |
+
// set up destination path
|
1756 |
+
$dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR);
|
1757 |
+
if (!is_dir($dir) || !is_writable($dir)) { // check supplied directory
|
1758 |
+
throw new Exception('supplied path ('.$dir.') does not exist, or is not writable');
|
1759 |
+
}
|
1760 |
+
$dest = $dir.DIRECTORY_SEPARATOR.$name.($image_mime ? '.'.getid3_lib::ImageExtFromMime($image_mime) : '');
|
1761 |
+
|
1762 |
+
// create dest file
|
1763 |
+
if (($fp_dest = fopen($dest, 'wb')) == false) {
|
1764 |
+
throw new Exception('failed to create file '.$dest);
|
1765 |
+
}
|
1766 |
+
|
1767 |
+
// copy data
|
1768 |
+
$this->fseek($offset);
|
1769 |
+
$buffersize = ($this->data_string_flag ? $length : $this->getid3->fread_buffer_size());
|
1770 |
+
$bytesleft = $length;
|
1771 |
+
while ($bytesleft > 0) {
|
1772 |
+
if (($buffer = $this->fread(min($buffersize, $bytesleft))) === false || ($byteswritten = fwrite($fp_dest, $buffer)) === false || ($byteswritten === 0)) {
|
1773 |
+
throw new Exception($buffer === false ? 'not enough data to read' : 'failed to write to destination file, may be not enough disk space');
|
1774 |
+
}
|
1775 |
+
$bytesleft -= $byteswritten;
|
1776 |
+
}
|
1777 |
+
|
1778 |
+
fclose($fp_dest);
|
1779 |
+
$attachment = $dest;
|
1780 |
+
|
1781 |
+
}
|
1782 |
+
|
1783 |
+
} catch (Exception $e) {
|
1784 |
+
|
1785 |
+
// close and remove dest file if created
|
1786 |
+
if (isset($fp_dest) && is_resource($fp_dest)) {
|
1787 |
+
fclose($fp_dest);
|
1788 |
+
unlink($dest);
|
1789 |
+
}
|
1790 |
+
|
1791 |
+
// do not set any is case of error
|
1792 |
+
$attachment = null;
|
1793 |
+
$this->warning('Failed to extract attachment '.$name.': '.$e->getMessage());
|
1794 |
+
|
1795 |
+
}
|
1796 |
+
|
1797 |
+
// seek to the end of attachment
|
1798 |
+
$this->fseek($offset + $length);
|
1799 |
+
|
1800 |
+
return $attachment;
|
1801 |
+
}
|
1802 |
+
|
1803 |
+
}
|
1804 |
+
|
1805 |
+
|
1806 |
+
class getid3_exception extends Exception
|
1807 |
+
{
|
1808 |
+
public $message;
|
1809 |
+
}
|
getid3/module.audio-video.quicktime.php
CHANGED
@@ -1,2134 +1,2246 @@
|
|
1 |
-
<?php
|
2 |
-
/////////////////////////////////////////////////////////////////
|
3 |
-
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
-
// available at http://getid3.sourceforge.net //
|
5 |
-
// or http://www.getid3.org //
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
//
|
11 |
-
// module
|
12 |
-
//
|
13 |
-
//
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
$info
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
$
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
$
|
45 |
-
$
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
case '
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
}
|
222 |
-
break;
|
223 |
-
|
224 |
-
|
225 |
-
case
|
226 |
-
case
|
227 |
-
case
|
228 |
-
case
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
case '
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
case '
|
275 |
-
case '
|
276 |
-
case '
|
277 |
-
case '
|
278 |
-
case '
|
279 |
-
case '
|
280 |
-
case '
|
281 |
-
case '
|
282 |
-
case '
|
283 |
-
case '
|
284 |
-
case '
|
285 |
-
case '
|
286 |
-
case '
|
287 |
-
case '
|
288 |
-
case '
|
289 |
-
case '
|
290 |
-
case '
|
291 |
-
case '
|
292 |
-
case '
|
293 |
-
case '
|
294 |
-
case '
|
295 |
-
case '
|
296 |
-
case '
|
297 |
-
case '
|
298 |
-
case '
|
299 |
-
case '
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
case '
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
$
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
case '
|
485 |
-
$atom_structure['
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
case '
|
491 |
-
|
492 |
-
|
493 |
-
$atom_structure['
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
break;
|
515 |
-
|
516 |
-
|
517 |
-
case '
|
518 |
-
$atom_structure['
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
$atom_structure['
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
$atom_structure['
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
$atom_structure['
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
$atom_structure['
|
562 |
-
$atom_structure['
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
$atom_structure['
|
574 |
-
$atom_structure['
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
$atom_structure['
|
582 |
-
|
583 |
-
$atom_structure['
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
$atom_structure['
|
589 |
-
|
590 |
-
$
|
591 |
-
|
592 |
-
$
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
$atom_structure['
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
case '
|
663 |
-
case '
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
case '
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
case '
|
674 |
-
|
675 |
-
$info['
|
676 |
-
$info['
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
$info['
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
$
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
$
|
731 |
-
$
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
case '
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
case '
|
762 |
-
case '
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
break;
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
$atom_structure['
|
912 |
-
$
|
913 |
-
$atom_structure['
|
914 |
-
$
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
$atom_structure['
|
925 |
-
$atom_structure['
|
926 |
-
$atom_structure['
|
927 |
-
$
|
928 |
-
$atom_structure['
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
$atom_structure['
|
947 |
-
$atom_structure['
|
948 |
-
|
949 |
-
$atom_structure['
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
$atom_structure['
|
959 |
-
$atom_structure['
|
960 |
-
$atom_structure['
|
961 |
-
$atom_structure['
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
$atom_structure['
|
971 |
-
$atom_structure['
|
972 |
-
|
973 |
-
$atom_structure['
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
$
|
984 |
-
|
985 |
-
$atom_structure['
|
986 |
-
|
987 |
-
$atom_structure['
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
$atom_structure['
|
997 |
-
$atom_structure['
|
998 |
-
$atom_structure['
|
999 |
-
$atom_structure['
|
1000 |
-
|
1001 |
-
$atom_structure['
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
$
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
$
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
$atom_structure['
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
$atom_structure['
|
1072 |
-
$atom_structure['
|
1073 |
-
$atom_structure['
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
$atom_structure['
|
1079 |
-
$atom_structure['
|
1080 |
-
$atom_structure['
|
1081 |
-
$atom_structure['
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
$atom_structure['
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
$atom_structure['
|
1098 |
-
$atom_structure['
|
1099 |
-
$
|
1100 |
-
$
|
1101 |
-
$
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
$atom_structure['
|
1107 |
-
$atom_structure['
|
1108 |
-
$atom_structure['
|
1109 |
-
$atom_structure['
|
1110 |
-
$atom_structure['
|
1111 |
-
$atom_structure['
|
1112 |
-
$atom_structure['
|
1113 |
-
$atom_structure['
|
1114 |
-
$atom_structure['
|
1115 |
-
$atom_structure['
|
1116 |
-
|
1117 |
-
$atom_structure['
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
$atom_structure['
|
1122 |
-
$atom_structure['
|
1123 |
-
$
|
1124 |
-
$
|
1125 |
-
$
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
$atom_structure['
|
1131 |
-
$atom_structure['
|
1132 |
-
$atom_structure['
|
1133 |
-
$atom_structure['
|
1134 |
-
$atom_structure['
|
1135 |
-
$atom_structure['
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
$
|
1158 |
-
$atom_structure['
|
1159 |
-
$
|
1160 |
-
$atom_structure['
|
1161 |
-
|
1162 |
-
$atom_structure['
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
$
|
1190 |
-
$atom_structure['
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
$atom_structure['
|
1195 |
-
$
|
1196 |
-
$atom_structure['
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
$
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
}
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
//
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
//
|
1304 |
-
|
1305 |
-
break;
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
//
|
1315 |
-
//
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
$
|
1437 |
-
$
|
1438 |
-
$
|
1439 |
-
$
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
$
|
1447 |
-
|
1448 |
-
$
|
1449 |
-
$
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
$
|
1461 |
-
$
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
$QuicktimeLanguageLookup[
|
1472 |
-
$QuicktimeLanguageLookup[
|
1473 |
-
$QuicktimeLanguageLookup[
|
1474 |
-
$QuicktimeLanguageLookup[
|
1475 |
-
$QuicktimeLanguageLookup[
|
1476 |
-
$QuicktimeLanguageLookup[
|
1477 |
-
$QuicktimeLanguageLookup[
|
1478 |
-
$QuicktimeLanguageLookup[
|
1479 |
-
$QuicktimeLanguageLookup[
|
1480 |
-
$QuicktimeLanguageLookup[
|
1481 |
-
$QuicktimeLanguageLookup[
|
1482 |
-
$QuicktimeLanguageLookup[
|
1483 |
-
$QuicktimeLanguageLookup[
|
1484 |
-
$QuicktimeLanguageLookup[
|
1485 |
-
$QuicktimeLanguageLookup[
|
1486 |
-
$QuicktimeLanguageLookup[
|
1487 |
-
$QuicktimeLanguageLookup[
|
1488 |
-
$QuicktimeLanguageLookup[
|
1489 |
-
$QuicktimeLanguageLookup[
|
1490 |
-
$QuicktimeLanguageLookup[
|
1491 |
-
$QuicktimeLanguageLookup[
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
$
|
1500 |
-
$
|
1501 |
-
$
|
1502 |
-
$
|
1503 |
-
$
|
1504 |
-
$
|
1505 |
-
$
|
1506 |
-
$
|
1507 |
-
$
|
1508 |
-
$
|
1509 |
-
$
|
1510 |
-
$
|
1511 |
-
$
|
1512 |
-
$
|
1513 |
-
$
|
1514 |
-
$
|
1515 |
-
$
|
1516 |
-
$
|
1517 |
-
$
|
1518 |
-
$
|
1519 |
-
$
|
1520 |
-
$
|
1521 |
-
$
|
1522 |
-
$
|
1523 |
-
$
|
1524 |
-
$
|
1525 |
-
$
|
1526 |
-
$
|
1527 |
-
$
|
1528 |
-
$
|
1529 |
-
$
|
1530 |
-
$
|
1531 |
-
$
|
1532 |
-
$
|
1533 |
-
$
|
1534 |
-
$
|
1535 |
-
$
|
1536 |
-
$
|
1537 |
-
$
|
1538 |
-
$
|
1539 |
-
$
|
1540 |
-
$
|
1541 |
-
$
|
1542 |
-
$
|
1543 |
-
$
|
1544 |
-
$
|
1545 |
-
$
|
1546 |
-
$
|
1547 |
-
$
|
1548 |
-
$
|
1549 |
-
$
|
1550 |
-
$
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
$
|
1559 |
-
$
|
1560 |
-
$
|
1561 |
-
$
|
1562 |
-
$
|
1563 |
-
$
|
1564 |
-
$
|
1565 |
-
$
|
1566 |
-
$
|
1567 |
-
$
|
1568 |
-
$
|
1569 |
-
$
|
1570 |
-
$
|
1571 |
-
$
|
1572 |
-
$
|
1573 |
-
$
|
1574 |
-
$
|
1575 |
-
$
|
1576 |
-
$
|
1577 |
-
$
|
1578 |
-
$
|
1579 |
-
$
|
1580 |
-
$
|
1581 |
-
$
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
$
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
$
|
1613 |
-
$
|
1614 |
-
$
|
1615 |
-
$
|
1616 |
-
$
|
1617 |
-
$
|
1618 |
-
$
|
1619 |
-
$
|
1620 |
-
$
|
1621 |
-
$
|
1622 |
-
$
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
$
|
1631 |
-
$
|
1632 |
-
$
|
1633 |
-
$
|
1634 |
-
$
|
1635 |
-
$
|
1636 |
-
$
|
1637 |
-
$
|
1638 |
-
$
|
1639 |
-
$
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
$
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
$
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
$
|
1985 |
-
break;
|
1986 |
-
case
|
1987 |
-
$data =
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
)
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
$
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
$
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/////////////////////////////////////////////////////////////////
|
3 |
+
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
+
// available at http://getid3.sourceforge.net //
|
5 |
+
// or http://www.getid3.org //
|
6 |
+
// also https://github.com/JamesHeinrich/getID3 //
|
7 |
+
/////////////////////////////////////////////////////////////////
|
8 |
+
// See readme.txt for more details //
|
9 |
+
/////////////////////////////////////////////////////////////////
|
10 |
+
// //
|
11 |
+
// module.audio-video.quicktime.php //
|
12 |
+
// module for analyzing Quicktime and MP3-in-MP4 files //
|
13 |
+
// dependencies: module.audio.mp3.php //
|
14 |
+
// dependencies: module.tag.id3v2.php //
|
15 |
+
// ///
|
16 |
+
/////////////////////////////////////////////////////////////////
|
17 |
+
|
18 |
+
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
|
19 |
+
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true); // needed for ISO 639-2 language code lookup
|
20 |
+
|
21 |
+
class getid3_quicktime extends getid3_handler
|
22 |
+
{
|
23 |
+
|
24 |
+
public $ReturnAtomData = true;
|
25 |
+
public $ParseAllPossibleAtoms = false;
|
26 |
+
|
27 |
+
public function Analyze() {
|
28 |
+
$info = &$this->getid3->info;
|
29 |
+
|
30 |
+
$info['fileformat'] = 'quicktime';
|
31 |
+
$info['quicktime']['hinting'] = false;
|
32 |
+
$info['quicktime']['controller'] = 'standard'; // may be overridden if 'ctyp' atom is present
|
33 |
+
|
34 |
+
$this->fseek($info['avdataoffset']);
|
35 |
+
|
36 |
+
$offset = 0;
|
37 |
+
$atomcounter = 0;
|
38 |
+
|
39 |
+
while ($offset < $info['avdataend']) {
|
40 |
+
if (!getid3_lib::intValueSupported($offset)) {
|
41 |
+
$info['error'][] = 'Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
|
42 |
+
break;
|
43 |
+
}
|
44 |
+
$this->fseek($offset);
|
45 |
+
$AtomHeader = $this->fread(8);
|
46 |
+
|
47 |
+
$atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
|
48 |
+
$atomname = substr($AtomHeader, 4, 4);
|
49 |
+
|
50 |
+
// 64-bit MOV patch by jlegateØktnc*com
|
51 |
+
if ($atomsize == 1) {
|
52 |
+
$atomsize = getid3_lib::BigEndian2Int($this->fread(8));
|
53 |
+
}
|
54 |
+
|
55 |
+
$info['quicktime'][$atomname]['name'] = $atomname;
|
56 |
+
$info['quicktime'][$atomname]['size'] = $atomsize;
|
57 |
+
$info['quicktime'][$atomname]['offset'] = $offset;
|
58 |
+
|
59 |
+
if (($offset + $atomsize) > $info['avdataend']) {
|
60 |
+
$info['error'][] = 'Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)';
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
|
64 |
+
if ($atomsize == 0) {
|
65 |
+
// Furthermore, for historical reasons the list of atoms is optionally
|
66 |
+
// terminated by a 32-bit integer set to 0. If you are writing a program
|
67 |
+
// to read user data atoms, you should allow for the terminating 0.
|
68 |
+
break;
|
69 |
+
}
|
70 |
+
$atomHierarchy = array();
|
71 |
+
$info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread(min($atomsize, round($this->getid3->memory_limit / 2))), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);
|
72 |
+
|
73 |
+
$offset += $atomsize;
|
74 |
+
$atomcounter++;
|
75 |
+
}
|
76 |
+
|
77 |
+
if (!empty($info['avdataend_tmp'])) {
|
78 |
+
// this value is assigned to a temp value and then erased because
|
79 |
+
// otherwise any atoms beyond the 'mdat' atom would not get parsed
|
80 |
+
$info['avdataend'] = $info['avdataend_tmp'];
|
81 |
+
unset($info['avdataend_tmp']);
|
82 |
+
}
|
83 |
+
|
84 |
+
if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) {
|
85 |
+
$info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
|
86 |
+
}
|
87 |
+
if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info['quicktime']['video'])) {
|
88 |
+
$info['audio']['bitrate'] = $info['bitrate'];
|
89 |
+
}
|
90 |
+
if (!empty($info['playtime_seconds']) && !isset($info['video']['frame_rate']) && !empty($info['quicktime']['stts_framecount'])) {
|
91 |
+
foreach ($info['quicktime']['stts_framecount'] as $key => $samples_count) {
|
92 |
+
$samples_per_second = $samples_count / $info['playtime_seconds'];
|
93 |
+
if ($samples_per_second > 240) {
|
94 |
+
// has to be audio samples
|
95 |
+
} else {
|
96 |
+
$info['video']['frame_rate'] = $samples_per_second;
|
97 |
+
break;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
if (($info['audio']['dataformat'] == 'mp4') && empty($info['video']['resolution_x'])) {
|
102 |
+
$info['fileformat'] = 'mp4';
|
103 |
+
$info['mime_type'] = 'audio/mp4';
|
104 |
+
unset($info['video']['dataformat']);
|
105 |
+
}
|
106 |
+
|
107 |
+
if (!$this->ReturnAtomData) {
|
108 |
+
unset($info['quicktime']['moov']);
|
109 |
+
}
|
110 |
+
|
111 |
+
if (empty($info['audio']['dataformat']) && !empty($info['quicktime']['audio'])) {
|
112 |
+
$info['audio']['dataformat'] = 'quicktime';
|
113 |
+
}
|
114 |
+
if (empty($info['video']['dataformat']) && !empty($info['quicktime']['video'])) {
|
115 |
+
$info['video']['dataformat'] = 'quicktime';
|
116 |
+
}
|
117 |
+
|
118 |
+
return true;
|
119 |
+
}
|
120 |
+
|
121 |
+
public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
|
122 |
+
// http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm
|
123 |
+
|
124 |
+
$info = &$this->getid3->info;
|
125 |
+
|
126 |
+
$atom_parent = end($atomHierarchy); // not array_pop($atomHierarchy); see http://www.getid3.org/phpBB3/viewtopic.php?t=1717
|
127 |
+
array_push($atomHierarchy, $atomname);
|
128 |
+
$atom_structure['hierarchy'] = implode(' ', $atomHierarchy);
|
129 |
+
$atom_structure['name'] = $atomname;
|
130 |
+
$atom_structure['size'] = $atomsize;
|
131 |
+
$atom_structure['offset'] = $baseoffset;
|
132 |
+
switch ($atomname) {
|
133 |
+
case 'moov': // MOVie container atom
|
134 |
+
case 'trak': // TRAcK container atom
|
135 |
+
case 'clip': // CLIPping container atom
|
136 |
+
case 'matt': // track MATTe container atom
|
137 |
+
case 'edts': // EDiTS container atom
|
138 |
+
case 'tref': // Track REFerence container atom
|
139 |
+
case 'mdia': // MeDIA container atom
|
140 |
+
case 'minf': // Media INFormation container atom
|
141 |
+
case 'dinf': // Data INFormation container atom
|
142 |
+
case 'udta': // User DaTA container atom
|
143 |
+
case 'cmov': // Compressed MOVie container atom
|
144 |
+
case 'rmra': // Reference Movie Record Atom
|
145 |
+
case 'rmda': // Reference Movie Descriptor Atom
|
146 |
+
case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR)
|
147 |
+
$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
|
148 |
+
break;
|
149 |
+
|
150 |
+
case 'ilst': // Item LiST container atom
|
151 |
+
if ($atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms)) {
|
152 |
+
// some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted
|
153 |
+
$allnumericnames = true;
|
154 |
+
foreach ($atom_structure['subatoms'] as $subatomarray) {
|
155 |
+
if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) {
|
156 |
+
$allnumericnames = false;
|
157 |
+
break;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
if ($allnumericnames) {
|
161 |
+
$newData = array();
|
162 |
+
foreach ($atom_structure['subatoms'] as $subatomarray) {
|
163 |
+
foreach ($subatomarray['subatoms'] as $newData_subatomarray) {
|
164 |
+
unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']);
|
165 |
+
$newData[$subatomarray['name']] = $newData_subatomarray;
|
166 |
+
break;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
$atom_structure['data'] = $newData;
|
170 |
+
unset($atom_structure['subatoms']);
|
171 |
+
}
|
172 |
+
}
|
173 |
+
break;
|
174 |
+
|
175 |
+
case "\x00\x00\x00\x01":
|
176 |
+
case "\x00\x00\x00\x02":
|
177 |
+
case "\x00\x00\x00\x03":
|
178 |
+
case "\x00\x00\x00\x04":
|
179 |
+
case "\x00\x00\x00\x05":
|
180 |
+
$atomname = getid3_lib::BigEndian2Int($atomname);
|
181 |
+
$atom_structure['name'] = $atomname;
|
182 |
+
$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
|
183 |
+
break;
|
184 |
+
|
185 |
+
case 'stbl': // Sample TaBLe container atom
|
186 |
+
$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
|
187 |
+
$isVideo = false;
|
188 |
+
$framerate = 0;
|
189 |
+
$framecount = 0;
|
190 |
+
foreach ($atom_structure['subatoms'] as $key => $value_array) {
|
191 |
+
if (isset($value_array['sample_description_table'])) {
|
192 |
+
foreach ($value_array['sample_description_table'] as $key2 => $value_array2) {
|
193 |
+
if (isset($value_array2['data_format'])) {
|
194 |
+
switch ($value_array2['data_format']) {
|
195 |
+
case 'avc1':
|
196 |
+
case 'mp4v':
|
197 |
+
// video data
|
198 |
+
$isVideo = true;
|
199 |
+
break;
|
200 |
+
case 'mp4a':
|
201 |
+
// audio data
|
202 |
+
break;
|
203 |
+
}
|
204 |
+
}
|
205 |
+
}
|
206 |
+
} elseif (isset($value_array['time_to_sample_table'])) {
|
207 |
+
foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) {
|
208 |
+
if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0)) {
|
209 |
+
$framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3);
|
210 |
+
$framecount = $value_array2['sample_count'];
|
211 |
+
}
|
212 |
+
}
|
213 |
+
}
|
214 |
+
}
|
215 |
+
if ($isVideo && $framerate) {
|
216 |
+
$info['quicktime']['video']['frame_rate'] = $framerate;
|
217 |
+
$info['video']['frame_rate'] = $info['quicktime']['video']['frame_rate'];
|
218 |
+
}
|
219 |
+
if ($isVideo && $framecount) {
|
220 |
+
$info['quicktime']['video']['frame_count'] = $framecount;
|
221 |
+
}
|
222 |
+
break;
|
223 |
+
|
224 |
+
|
225 |
+
case 'aART': // Album ARTist
|
226 |
+
case 'catg': // CaTeGory
|
227 |
+
case 'covr': // COVeR artwork
|
228 |
+
case 'cpil': // ComPILation
|
229 |
+
case 'cprt': // CoPyRighT
|
230 |
+
case 'desc': // DESCription
|
231 |
+
case 'disk': // DISK number
|
232 |
+
case 'egid': // Episode Global ID
|
233 |
+
case 'gnre': // GeNRE
|
234 |
+
case 'keyw': // KEYWord
|
235 |
+
case 'ldes':
|
236 |
+
case 'pcst': // PodCaST
|
237 |
+
case 'pgap': // GAPless Playback
|
238 |
+
case 'purd': // PURchase Date
|
239 |
+
case 'purl': // Podcast URL
|
240 |
+
case 'rati':
|
241 |
+
case 'rndu':
|
242 |
+
case 'rpdu':
|
243 |
+
case 'rtng': // RaTiNG
|
244 |
+
case 'stik':
|
245 |
+
case 'tmpo': // TeMPO (BPM)
|
246 |
+
case 'trkn': // TRacK Number
|
247 |
+
case 'tves': // TV EpiSode
|
248 |
+
case 'tvnn': // TV Network Name
|
249 |
+
case 'tvsh': // TV SHow Name
|
250 |
+
case 'tvsn': // TV SeasoN
|
251 |
+
case 'akID': // iTunes store account type
|
252 |
+
case 'apID':
|
253 |
+
case 'atID':
|
254 |
+
case 'cmID':
|
255 |
+
case 'cnID':
|
256 |
+
case 'geID':
|
257 |
+
case 'plID':
|
258 |
+
case 'sfID': // iTunes store country
|
259 |
+
case "\xA9".'alb': // ALBum
|
260 |
+
case "\xA9".'art': // ARTist
|
261 |
+
case "\xA9".'ART':
|
262 |
+
case "\xA9".'aut':
|
263 |
+
case "\xA9".'cmt': // CoMmenT
|
264 |
+
case "\xA9".'com': // COMposer
|
265 |
+
case "\xA9".'cpy':
|
266 |
+
case "\xA9".'day': // content created year
|
267 |
+
case "\xA9".'dir':
|
268 |
+
case "\xA9".'ed1':
|
269 |
+
case "\xA9".'ed2':
|
270 |
+
case "\xA9".'ed3':
|
271 |
+
case "\xA9".'ed4':
|
272 |
+
case "\xA9".'ed5':
|
273 |
+
case "\xA9".'ed6':
|
274 |
+
case "\xA9".'ed7':
|
275 |
+
case "\xA9".'ed8':
|
276 |
+
case "\xA9".'ed9':
|
277 |
+
case "\xA9".'enc':
|
278 |
+
case "\xA9".'fmt':
|
279 |
+
case "\xA9".'gen': // GENre
|
280 |
+
case "\xA9".'grp': // GRouPing
|
281 |
+
case "\xA9".'hst':
|
282 |
+
case "\xA9".'inf':
|
283 |
+
case "\xA9".'lyr': // LYRics
|
284 |
+
case "\xA9".'mak':
|
285 |
+
case "\xA9".'mod':
|
286 |
+
case "\xA9".'nam': // full NAMe
|
287 |
+
case "\xA9".'ope':
|
288 |
+
case "\xA9".'PRD':
|
289 |
+
case "\xA9".'prd':
|
290 |
+
case "\xA9".'prf':
|
291 |
+
case "\xA9".'req':
|
292 |
+
case "\xA9".'src':
|
293 |
+
case "\xA9".'swr':
|
294 |
+
case "\xA9".'too': // encoder
|
295 |
+
case "\xA9".'trk': // TRacK
|
296 |
+
case "\xA9".'url':
|
297 |
+
case "\xA9".'wrn':
|
298 |
+
case "\xA9".'wrt': // WRiTer
|
299 |
+
case '----': // itunes specific
|
300 |
+
if ($atom_parent == 'udta') {
|
301 |
+
// User data atom handler
|
302 |
+
$atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
|
303 |
+
$atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
|
304 |
+
$atom_structure['data'] = substr($atom_data, 4);
|
305 |
+
|
306 |
+
$atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
|
307 |
+
if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
|
308 |
+
$info['comments']['language'][] = $atom_structure['language'];
|
309 |
+
}
|
310 |
+
} else {
|
311 |
+
// Apple item list box atom handler
|
312 |
+
$atomoffset = 0;
|
313 |
+
if (substr($atom_data, 2, 2) == "\x10\xB5") {
|
314 |
+
// not sure what it means, but observed on iPhone4 data.
|
315 |
+
// Each $atom_data has 2 bytes of datasize, plus 0x10B5, then data
|
316 |
+
while ($atomoffset < strlen($atom_data)) {
|
317 |
+
$boxsmallsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 2));
|
318 |
+
$boxsmalltype = substr($atom_data, $atomoffset + 2, 2);
|
319 |
+
$boxsmalldata = substr($atom_data, $atomoffset + 4, $boxsmallsize);
|
320 |
+
if ($boxsmallsize <= 1) {
|
321 |
+
$info['warning'][] = 'Invalid QuickTime atom smallbox size "'.$boxsmallsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset);
|
322 |
+
$atom_structure['data'] = null;
|
323 |
+
$atomoffset = strlen($atom_data);
|
324 |
+
break;
|
325 |
+
}
|
326 |
+
switch ($boxsmalltype) {
|
327 |
+
case "\x10\xB5":
|
328 |
+
$atom_structure['data'] = $boxsmalldata;
|
329 |
+
break;
|
330 |
+
default:
|
331 |
+
$info['warning'][] = 'Unknown QuickTime smallbox type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxsmalltype).'" ('.trim(getid3_lib::PrintHexBytes($boxsmalltype)).') at offset '.$baseoffset;
|
332 |
+
$atom_structure['data'] = $atom_data;
|
333 |
+
break;
|
334 |
+
}
|
335 |
+
$atomoffset += (4 + $boxsmallsize);
|
336 |
+
}
|
337 |
+
} else {
|
338 |
+
while ($atomoffset < strlen($atom_data)) {
|
339 |
+
$boxsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 4));
|
340 |
+
$boxtype = substr($atom_data, $atomoffset + 4, 4);
|
341 |
+
$boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8);
|
342 |
+
if ($boxsize <= 1) {
|
343 |
+
$info['warning'][] = 'Invalid QuickTime atom box size "'.$boxsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset);
|
344 |
+
$atom_structure['data'] = null;
|
345 |
+
$atomoffset = strlen($atom_data);
|
346 |
+
break;
|
347 |
+
}
|
348 |
+
$atomoffset += $boxsize;
|
349 |
+
|
350 |
+
switch ($boxtype) {
|
351 |
+
case 'mean':
|
352 |
+
case 'name':
|
353 |
+
$atom_structure[$boxtype] = substr($boxdata, 4);
|
354 |
+
break;
|
355 |
+
|
356 |
+
case 'data':
|
357 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1));
|
358 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3));
|
359 |
+
switch ($atom_structure['flags_raw']) {
|
360 |
+
case 0: // data flag
|
361 |
+
case 21: // tmpo/cpil flag
|
362 |
+
switch ($atomname) {
|
363 |
+
case 'cpil':
|
364 |
+
case 'pcst':
|
365 |
+
case 'pgap':
|
366 |
+
$atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
|
367 |
+
break;
|
368 |
+
|
369 |
+
case 'tmpo':
|
370 |
+
$atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2));
|
371 |
+
break;
|
372 |
+
|
373 |
+
case 'disk':
|
374 |
+
case 'trkn':
|
375 |
+
$num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2));
|
376 |
+
$num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2));
|
377 |
+
$atom_structure['data'] = empty($num) ? '' : $num;
|
378 |
+
$atom_structure['data'] .= empty($num_total) ? '' : '/'.$num_total;
|
379 |
+
break;
|
380 |
+
|
381 |
+
case 'gnre':
|
382 |
+
$GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
|
383 |
+
$atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1);
|
384 |
+
break;
|
385 |
+
|
386 |
+
case 'rtng':
|
387 |
+
$atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
|
388 |
+
$atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]);
|
389 |
+
break;
|
390 |
+
|
391 |
+
case 'stik':
|
392 |
+
$atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
|
393 |
+
$atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]);
|
394 |
+
break;
|
395 |
+
|
396 |
+
case 'sfID':
|
397 |
+
$atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
|
398 |
+
$atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]);
|
399 |
+
break;
|
400 |
+
|
401 |
+
case 'egid':
|
402 |
+
case 'purl':
|
403 |
+
$atom_structure['data'] = substr($boxdata, 8);
|
404 |
+
break;
|
405 |
+
|
406 |
+
default:
|
407 |
+
$atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
|
408 |
+
}
|
409 |
+
break;
|
410 |
+
|
411 |
+
case 1: // text flag
|
412 |
+
case 13: // image flag
|
413 |
+
default:
|
414 |
+
$atom_structure['data'] = substr($boxdata, 8);
|
415 |
+
if ($atomname == 'covr') {
|
416 |
+
// not a foolproof check, but better than nothing
|
417 |
+
if (preg_match('#^\xFF\xD8\xFF#', $atom_structure['data'])) {
|
418 |
+
$atom_structure['image_mime'] = 'image/jpeg';
|
419 |
+
} elseif (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $atom_structure['data'])) {
|
420 |
+
$atom_structure['image_mime'] = 'image/png';
|
421 |
+
} elseif (preg_match('#^GIF#', $atom_structure['data'])) {
|
422 |
+
$atom_structure['image_mime'] = 'image/gif';
|
423 |
+
}
|
424 |
+
}
|
425 |
+
break;
|
426 |
+
|
427 |
+
}
|
428 |
+
break;
|
429 |
+
|
430 |
+
default:
|
431 |
+
$info['warning'][] = 'Unknown QuickTime box type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxtype).'" ('.trim(getid3_lib::PrintHexBytes($boxtype)).') at offset '.$baseoffset;
|
432 |
+
$atom_structure['data'] = $atom_data;
|
433 |
+
|
434 |
+
}
|
435 |
+
}
|
436 |
+
}
|
437 |
+
}
|
438 |
+
$this->CopyToAppropriateCommentsSection($atomname, $atom_structure['data'], $atom_structure['name']);
|
439 |
+
break;
|
440 |
+
|
441 |
+
|
442 |
+
case 'play': // auto-PLAY atom
|
443 |
+
$atom_structure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
444 |
+
|
445 |
+
$info['quicktime']['autoplay'] = $atom_structure['autoplay'];
|
446 |
+
break;
|
447 |
+
|
448 |
+
|
449 |
+
case 'WLOC': // Window LOCation atom
|
450 |
+
$atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
|
451 |
+
$atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
|
452 |
+
break;
|
453 |
+
|
454 |
+
|
455 |
+
case 'LOOP': // LOOPing atom
|
456 |
+
case 'SelO': // play SELection Only atom
|
457 |
+
case 'AllF': // play ALL Frames atom
|
458 |
+
$atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data);
|
459 |
+
break;
|
460 |
+
|
461 |
+
|
462 |
+
case 'name': //
|
463 |
+
case 'MCPS': // Media Cleaner PRo
|
464 |
+
case '@PRM': // adobe PReMiere version
|
465 |
+
case '@PRQ': // adobe PRemiere Quicktime version
|
466 |
+
$atom_structure['data'] = $atom_data;
|
467 |
+
break;
|
468 |
+
|
469 |
+
|
470 |
+
case 'cmvd': // Compressed MooV Data atom
|
471 |
+
// Code by ubergeekØubergeek*tv based on information from
|
472 |
+
// http://developer.apple.com/quicktime/icefloe/dispatch012.html
|
473 |
+
$atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
|
474 |
+
|
475 |
+
$CompressedFileData = substr($atom_data, 4);
|
476 |
+
if ($UncompressedHeader = @gzuncompress($CompressedFileData)) {
|
477 |
+
$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, 0, $atomHierarchy, $ParseAllPossibleAtoms);
|
478 |
+
} else {
|
479 |
+
$info['warning'][] = 'Error decompressing compressed MOV atom at offset '.$atom_structure['offset'];
|
480 |
+
}
|
481 |
+
break;
|
482 |
+
|
483 |
+
|
484 |
+
case 'dcom': // Data COMpression atom
|
485 |
+
$atom_structure['compression_id'] = $atom_data;
|
486 |
+
$atom_structure['compression_text'] = $this->QuicktimeDCOMLookup($atom_data);
|
487 |
+
break;
|
488 |
+
|
489 |
+
|
490 |
+
case 'rdrf': // Reference movie Data ReFerence atom
|
491 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
492 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
|
493 |
+
$atom_structure['flags']['internal_data'] = (bool) ($atom_structure['flags_raw'] & 0x000001);
|
494 |
+
|
495 |
+
$atom_structure['reference_type_name'] = substr($atom_data, 4, 4);
|
496 |
+
$atom_structure['reference_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
|
497 |
+
switch ($atom_structure['reference_type_name']) {
|
498 |
+
case 'url ':
|
499 |
+
$atom_structure['url'] = $this->NoNullString(substr($atom_data, 12));
|
500 |
+
break;
|
501 |
+
|
502 |
+
case 'alis':
|
503 |
+
$atom_structure['file_alias'] = substr($atom_data, 12);
|
504 |
+
break;
|
505 |
+
|
506 |
+
case 'rsrc':
|
507 |
+
$atom_structure['resource_alias'] = substr($atom_data, 12);
|
508 |
+
break;
|
509 |
+
|
510 |
+
default:
|
511 |
+
$atom_structure['data'] = substr($atom_data, 12);
|
512 |
+
break;
|
513 |
+
}
|
514 |
+
break;
|
515 |
+
|
516 |
+
|
517 |
+
case 'rmqu': // Reference Movie QUality atom
|
518 |
+
$atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data);
|
519 |
+
break;
|
520 |
+
|
521 |
+
|
522 |
+
case 'rmcs': // Reference Movie Cpu Speed atom
|
523 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
524 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
525 |
+
$atom_structure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
|
526 |
+
break;
|
527 |
+
|
528 |
+
|
529 |
+
case 'rmvc': // Reference Movie Version Check atom
|
530 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
531 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
532 |
+
$atom_structure['gestalt_selector'] = substr($atom_data, 4, 4);
|
533 |
+
$atom_structure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
|
534 |
+
$atom_structure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
|
535 |
+
$atom_structure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
|
536 |
+
break;
|
537 |
+
|
538 |
+
|
539 |
+
case 'rmcd': // Reference Movie Component check atom
|
540 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
541 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
542 |
+
$atom_structure['component_type'] = substr($atom_data, 4, 4);
|
543 |
+
$atom_structure['component_subtype'] = substr($atom_data, 8, 4);
|
544 |
+
$atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
|
545 |
+
$atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
|
546 |
+
$atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
|
547 |
+
$atom_structure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 4));
|
548 |
+
break;
|
549 |
+
|
550 |
+
|
551 |
+
case 'rmdr': // Reference Movie Data Rate atom
|
552 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
553 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
554 |
+
$atom_structure['data_rate'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
555 |
+
|
556 |
+
$atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10;
|
557 |
+
break;
|
558 |
+
|
559 |
+
|
560 |
+
case 'rmla': // Reference Movie Language Atom
|
561 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
562 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
563 |
+
$atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
|
564 |
+
|
565 |
+
$atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
|
566 |
+
if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
|
567 |
+
$info['comments']['language'][] = $atom_structure['language'];
|
568 |
+
}
|
569 |
+
break;
|
570 |
+
|
571 |
+
|
572 |
+
case 'rmla': // Reference Movie Language Atom
|
573 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
574 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
575 |
+
$atom_structure['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
|
576 |
+
break;
|
577 |
+
|
578 |
+
|
579 |
+
case 'ptv ': // Print To Video - defines a movie's full screen mode
|
580 |
+
// http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm
|
581 |
+
$atom_structure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
|
582 |
+
$atom_structure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); // hardcoded: 0x0000
|
583 |
+
$atom_structure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x0000
|
584 |
+
$atom_structure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 1));
|
585 |
+
$atom_structure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 7, 1));
|
586 |
+
|
587 |
+
$atom_structure['flags']['play_on_open'] = (bool) $atom_structure['play_on_open_flag'];
|
588 |
+
$atom_structure['flags']['slide_show'] = (bool) $atom_structure['slide_show_flag'];
|
589 |
+
|
590 |
+
$ptv_lookup[0] = 'normal';
|
591 |
+
$ptv_lookup[1] = 'double';
|
592 |
+
$ptv_lookup[2] = 'half';
|
593 |
+
$ptv_lookup[3] = 'full';
|
594 |
+
$ptv_lookup[4] = 'current';
|
595 |
+
if (isset($ptv_lookup[$atom_structure['display_size_raw']])) {
|
596 |
+
$atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']];
|
597 |
+
} else {
|
598 |
+
$info['warning'][] = 'unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')';
|
599 |
+
}
|
600 |
+
break;
|
601 |
+
|
602 |
+
|
603 |
+
case 'stsd': // Sample Table Sample Description atom
|
604 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
605 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
606 |
+
$atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
607 |
+
$stsdEntriesDataOffset = 8;
|
608 |
+
for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
609 |
+
$atom_structure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 4));
|
610 |
+
$stsdEntriesDataOffset += 4;
|
611 |
+
$atom_structure['sample_description_table'][$i]['data_format'] = substr($atom_data, $stsdEntriesDataOffset, 4);
|
612 |
+
$stsdEntriesDataOffset += 4;
|
613 |
+
$atom_structure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 6));
|
614 |
+
$stsdEntriesDataOffset += 6;
|
615 |
+
$atom_structure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 2));
|
616 |
+
$stsdEntriesDataOffset += 2;
|
617 |
+
$atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));
|
618 |
+
$stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);
|
619 |
+
|
620 |
+
$atom_structure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 0, 2));
|
621 |
+
$atom_structure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 2, 2));
|
622 |
+
$atom_structure['sample_description_table'][$i]['encoder_vendor'] = substr($atom_structure['sample_description_table'][$i]['data'], 4, 4);
|
623 |
+
|
624 |
+
switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) {
|
625 |
+
|
626 |
+
case "\x00\x00\x00\x00":
|
627 |
+
// audio tracks
|
628 |
+
$atom_structure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 2));
|
629 |
+
$atom_structure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 10, 2));
|
630 |
+
$atom_structure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 2));
|
631 |
+
$atom_structure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 14, 2));
|
632 |
+
$atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4));
|
633 |
+
|
634 |
+
// video tracks
|
635 |
+
// http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
|
636 |
+
$atom_structure['sample_description_table'][$i]['temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));
|
637 |
+
$atom_structure['sample_description_table'][$i]['spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));
|
638 |
+
$atom_structure['sample_description_table'][$i]['width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));
|
639 |
+
$atom_structure['sample_description_table'][$i]['height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));
|
640 |
+
$atom_structure['sample_description_table'][$i]['resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));
|
641 |
+
$atom_structure['sample_description_table'][$i]['resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));
|
642 |
+
$atom_structure['sample_description_table'][$i]['data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 4));
|
643 |
+
$atom_structure['sample_description_table'][$i]['frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 36, 2));
|
644 |
+
$atom_structure['sample_description_table'][$i]['compressor_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 38, 4);
|
645 |
+
$atom_structure['sample_description_table'][$i]['pixel_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 42, 2));
|
646 |
+
$atom_structure['sample_description_table'][$i]['color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 44, 2));
|
647 |
+
|
648 |
+
switch ($atom_structure['sample_description_table'][$i]['data_format']) {
|
649 |
+
case '2vuY':
|
650 |
+
case 'avc1':
|
651 |
+
case 'cvid':
|
652 |
+
case 'dvc ':
|
653 |
+
case 'dvcp':
|
654 |
+
case 'gif ':
|
655 |
+
case 'h263':
|
656 |
+
case 'jpeg':
|
657 |
+
case 'kpcd':
|
658 |
+
case 'mjpa':
|
659 |
+
case 'mjpb':
|
660 |
+
case 'mp4v':
|
661 |
+
case 'png ':
|
662 |
+
case 'raw ':
|
663 |
+
case 'rle ':
|
664 |
+
case 'rpza':
|
665 |
+
case 'smc ':
|
666 |
+
case 'SVQ1':
|
667 |
+
case 'SVQ3':
|
668 |
+
case 'tiff':
|
669 |
+
case 'v210':
|
670 |
+
case 'v216':
|
671 |
+
case 'v308':
|
672 |
+
case 'v408':
|
673 |
+
case 'v410':
|
674 |
+
case 'yuv2':
|
675 |
+
$info['fileformat'] = 'mp4';
|
676 |
+
$info['video']['fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
|
677 |
+
// http://www.getid3.org/phpBB3/viewtopic.php?t=1550
|
678 |
+
//if ((!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($atom_structure['sample_description_table'][$i]['width'])) && (empty($info['video']['resolution_x']) || empty($info['video']['resolution_y']) || (number_format($info['video']['resolution_x'], 6) != number_format(round($info['video']['resolution_x']), 6)) || (number_format($info['video']['resolution_y'], 6) != number_format(round($info['video']['resolution_y']), 6)))) { // ugly check for floating point numbers
|
679 |
+
if (!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($atom_structure['sample_description_table'][$i]['height'])) {
|
680 |
+
// assume that values stored here are more important than values stored in [tkhd] atom
|
681 |
+
$info['video']['resolution_x'] = $atom_structure['sample_description_table'][$i]['width'];
|
682 |
+
$info['video']['resolution_y'] = $atom_structure['sample_description_table'][$i]['height'];
|
683 |
+
$info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];
|
684 |
+
$info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];
|
685 |
+
}
|
686 |
+
break;
|
687 |
+
|
688 |
+
case 'qtvr':
|
689 |
+
$info['video']['dataformat'] = 'quicktimevr';
|
690 |
+
break;
|
691 |
+
|
692 |
+
case 'mp4a':
|
693 |
+
default:
|
694 |
+
$info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
|
695 |
+
$info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate'];
|
696 |
+
$info['quicktime']['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels'];
|
697 |
+
$info['quicktime']['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth'];
|
698 |
+
$info['audio']['codec'] = $info['quicktime']['audio']['codec'];
|
699 |
+
$info['audio']['sample_rate'] = $info['quicktime']['audio']['sample_rate'];
|
700 |
+
$info['audio']['channels'] = $info['quicktime']['audio']['channels'];
|
701 |
+
$info['audio']['bits_per_sample'] = $info['quicktime']['audio']['bit_depth'];
|
702 |
+
switch ($atom_structure['sample_description_table'][$i]['data_format']) {
|
703 |
+
case 'raw ': // PCM
|
704 |
+
case 'alac': // Apple Lossless Audio Codec
|
705 |
+
$info['audio']['lossless'] = true;
|
706 |
+
break;
|
707 |
+
default:
|
708 |
+
$info['audio']['lossless'] = false;
|
709 |
+
break;
|
710 |
+
}
|
711 |
+
break;
|
712 |
+
}
|
713 |
+
break;
|
714 |
+
|
715 |
+
default:
|
716 |
+
switch ($atom_structure['sample_description_table'][$i]['data_format']) {
|
717 |
+
case 'mp4s':
|
718 |
+
$info['fileformat'] = 'mp4';
|
719 |
+
break;
|
720 |
+
|
721 |
+
default:
|
722 |
+
// video atom
|
723 |
+
$atom_structure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));
|
724 |
+
$atom_structure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));
|
725 |
+
$atom_structure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));
|
726 |
+
$atom_structure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));
|
727 |
+
$atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4));
|
728 |
+
$atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));
|
729 |
+
$atom_structure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));
|
730 |
+
$atom_structure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 2));
|
731 |
+
$atom_structure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 34, 1));
|
732 |
+
$atom_structure['sample_description_table'][$i]['video_encoder_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 35, $atom_structure['sample_description_table'][$i]['video_encoder_name_len']);
|
733 |
+
$atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2));
|
734 |
+
$atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2));
|
735 |
+
|
736 |
+
$atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color');
|
737 |
+
$atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']);
|
738 |
+
|
739 |
+
if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') {
|
740 |
+
$info['quicktime']['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
|
741 |
+
$info['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
|
742 |
+
$info['quicktime']['video']['codec'] = (($atom_structure['sample_description_table'][$i]['video_encoder_name_len'] > 0) ? $atom_structure['sample_description_table'][$i]['video_encoder_name'] : $atom_structure['sample_description_table'][$i]['data_format']);
|
743 |
+
$info['quicktime']['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'];
|
744 |
+
$info['quicktime']['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name'];
|
745 |
+
|
746 |
+
$info['video']['codec'] = $info['quicktime']['video']['codec'];
|
747 |
+
$info['video']['bits_per_sample'] = $info['quicktime']['video']['color_depth'];
|
748 |
+
}
|
749 |
+
$info['video']['lossless'] = false;
|
750 |
+
$info['video']['pixel_aspect_ratio'] = (float) 1;
|
751 |
+
break;
|
752 |
+
}
|
753 |
+
break;
|
754 |
+
}
|
755 |
+
switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) {
|
756 |
+
case 'mp4a':
|
757 |
+
$info['audio']['dataformat'] = 'mp4';
|
758 |
+
$info['quicktime']['audio']['codec'] = 'mp4';
|
759 |
+
break;
|
760 |
+
|
761 |
+
case '3ivx':
|
762 |
+
case '3iv1':
|
763 |
+
case '3iv2':
|
764 |
+
$info['video']['dataformat'] = '3ivx';
|
765 |
+
break;
|
766 |
+
|
767 |
+
case 'xvid':
|
768 |
+
$info['video']['dataformat'] = 'xvid';
|
769 |
+
break;
|
770 |
+
|
771 |
+
case 'mp4v':
|
772 |
+
$info['video']['dataformat'] = 'mpeg4';
|
773 |
+
break;
|
774 |
+
|
775 |
+
case 'divx':
|
776 |
+
case 'div1':
|
777 |
+
case 'div2':
|
778 |
+
case 'div3':
|
779 |
+
case 'div4':
|
780 |
+
case 'div5':
|
781 |
+
case 'div6':
|
782 |
+
$info['video']['dataformat'] = 'divx';
|
783 |
+
break;
|
784 |
+
|
785 |
+
default:
|
786 |
+
// do nothing
|
787 |
+
break;
|
788 |
+
}
|
789 |
+
unset($atom_structure['sample_description_table'][$i]['data']);
|
790 |
+
}
|
791 |
+
break;
|
792 |
+
|
793 |
+
|
794 |
+
case 'stts': // Sample Table Time-to-Sample atom
|
795 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
796 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
797 |
+
$atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
798 |
+
$sttsEntriesDataOffset = 8;
|
799 |
+
//$FrameRateCalculatorArray = array();
|
800 |
+
$frames_count = 0;
|
801 |
+
|
802 |
+
$max_stts_entries_to_scan = min(floor($this->getid3->memory_limit / 10000), $atom_structure['number_entries']);
|
803 |
+
if ($max_stts_entries_to_scan < $atom_structure['number_entries']) {
|
804 |
+
$info['warning'][] = 'QuickTime atom "stts" has '.$atom_structure['number_entries'].' but only scanning the first '.$max_stts_entries_to_scan.' entries due to limited PHP memory available ('.floor($this->getid3->memory_limit / 1048576).'MB).';
|
805 |
+
}
|
806 |
+
for ($i = 0; $i < $max_stts_entries_to_scan; $i++) {
|
807 |
+
$atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
|
808 |
+
$sttsEntriesDataOffset += 4;
|
809 |
+
$atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
|
810 |
+
$sttsEntriesDataOffset += 4;
|
811 |
+
|
812 |
+
$frames_count += $atom_structure['time_to_sample_table'][$i]['sample_count'];
|
813 |
+
|
814 |
+
// THIS SECTION REPLACED WITH CODE IN "stbl" ATOM
|
815 |
+
//if (!empty($info['quicktime']['time_scale']) && ($atom_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) {
|
816 |
+
// $stts_new_framerate = $info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'];
|
817 |
+
// if ($stts_new_framerate <= 60) {
|
818 |
+
// // some atoms have durations of "1" giving a very large framerate, which probably is not right
|
819 |
+
// $info['video']['frame_rate'] = max($info['video']['frame_rate'], $stts_new_framerate);
|
820 |
+
// }
|
821 |
+
//}
|
822 |
+
//
|
823 |
+
//$FrameRateCalculatorArray[($info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count'];
|
824 |
+
}
|
825 |
+
$info['quicktime']['stts_framecount'][] = $frames_count;
|
826 |
+
//$sttsFramesTotal = 0;
|
827 |
+
//$sttsSecondsTotal = 0;
|
828 |
+
//foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) {
|
829 |
+
// if (($frames_per_second > 60) || ($frames_per_second < 1)) {
|
830 |
+
// // not video FPS information, probably audio information
|
831 |
+
// $sttsFramesTotal = 0;
|
832 |
+
// $sttsSecondsTotal = 0;
|
833 |
+
// break;
|
834 |
+
// }
|
835 |
+
// $sttsFramesTotal += $frame_count;
|
836 |
+
// $sttsSecondsTotal += $frame_count / $frames_per_second;
|
837 |
+
//}
|
838 |
+
//if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) {
|
839 |
+
// if (($sttsFramesTotal / $sttsSecondsTotal) > $info['video']['frame_rate']) {
|
840 |
+
// $info['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal;
|
841 |
+
// }
|
842 |
+
//}
|
843 |
+
break;
|
844 |
+
|
845 |
+
|
846 |
+
case 'stss': // Sample Table Sync Sample (key frames) atom
|
847 |
+
if ($ParseAllPossibleAtoms) {
|
848 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
849 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
850 |
+
$atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
851 |
+
$stssEntriesDataOffset = 8;
|
852 |
+
for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
853 |
+
$atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stssEntriesDataOffset, 4));
|
854 |
+
$stssEntriesDataOffset += 4;
|
855 |
+
}
|
856 |
+
}
|
857 |
+
break;
|
858 |
+
|
859 |
+
|
860 |
+
case 'stsc': // Sample Table Sample-to-Chunk atom
|
861 |
+
if ($ParseAllPossibleAtoms) {
|
862 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
863 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
864 |
+
$atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
865 |
+
$stscEntriesDataOffset = 8;
|
866 |
+
for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
867 |
+
$atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
|
868 |
+
$stscEntriesDataOffset += 4;
|
869 |
+
$atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
|
870 |
+
$stscEntriesDataOffset += 4;
|
871 |
+
$atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
|
872 |
+
$stscEntriesDataOffset += 4;
|
873 |
+
}
|
874 |
+
}
|
875 |
+
break;
|
876 |
+
|
877 |
+
|
878 |
+
case 'stsz': // Sample Table SiZe atom
|
879 |
+
if ($ParseAllPossibleAtoms) {
|
880 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
881 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
882 |
+
$atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
883 |
+
$atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
|
884 |
+
$stszEntriesDataOffset = 12;
|
885 |
+
if ($atom_structure['sample_size'] == 0) {
|
886 |
+
for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
887 |
+
$atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stszEntriesDataOffset, 4));
|
888 |
+
$stszEntriesDataOffset += 4;
|
889 |
+
}
|
890 |
+
}
|
891 |
+
}
|
892 |
+
break;
|
893 |
+
|
894 |
+
|
895 |
+
case 'stco': // Sample Table Chunk Offset atom
|
896 |
+
if ($ParseAllPossibleAtoms) {
|
897 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
898 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
899 |
+
$atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
900 |
+
$stcoEntriesDataOffset = 8;
|
901 |
+
for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
902 |
+
$atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 4));
|
903 |
+
$stcoEntriesDataOffset += 4;
|
904 |
+
}
|
905 |
+
}
|
906 |
+
break;
|
907 |
+
|
908 |
+
|
909 |
+
case 'co64': // Chunk Offset 64-bit (version of "stco" that supports > 2GB files)
|
910 |
+
if ($ParseAllPossibleAtoms) {
|
911 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
912 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
913 |
+
$atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
914 |
+
$stcoEntriesDataOffset = 8;
|
915 |
+
for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
916 |
+
$atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 8));
|
917 |
+
$stcoEntriesDataOffset += 8;
|
918 |
+
}
|
919 |
+
}
|
920 |
+
break;
|
921 |
+
|
922 |
+
|
923 |
+
case 'dref': // Data REFerence atom
|
924 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
925 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
926 |
+
$atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
927 |
+
$drefDataOffset = 8;
|
928 |
+
for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
|
929 |
+
$atom_structure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 4));
|
930 |
+
$drefDataOffset += 4;
|
931 |
+
$atom_structure['data_references'][$i]['type'] = substr($atom_data, $drefDataOffset, 4);
|
932 |
+
$drefDataOffset += 4;
|
933 |
+
$atom_structure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 1));
|
934 |
+
$drefDataOffset += 1;
|
935 |
+
$atom_structure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 3)); // hardcoded: 0x0000
|
936 |
+
$drefDataOffset += 3;
|
937 |
+
$atom_structure['data_references'][$i]['data'] = substr($atom_data, $drefDataOffset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));
|
938 |
+
$drefDataOffset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);
|
939 |
+
|
940 |
+
$atom_structure['data_references'][$i]['flags']['self_reference'] = (bool) ($atom_structure['data_references'][$i]['flags_raw'] & 0x001);
|
941 |
+
}
|
942 |
+
break;
|
943 |
+
|
944 |
+
|
945 |
+
case 'gmin': // base Media INformation atom
|
946 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
947 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
948 |
+
$atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
|
949 |
+
$atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
|
950 |
+
$atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
|
951 |
+
$atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
|
952 |
+
$atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 2));
|
953 |
+
$atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
|
954 |
+
break;
|
955 |
+
|
956 |
+
|
957 |
+
case 'smhd': // Sound Media information HeaDer atom
|
958 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
959 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
960 |
+
$atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
|
961 |
+
$atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
|
962 |
+
break;
|
963 |
+
|
964 |
+
|
965 |
+
case 'vmhd': // Video Media information HeaDer atom
|
966 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
967 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
|
968 |
+
$atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
|
969 |
+
$atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
|
970 |
+
$atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
|
971 |
+
$atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
|
972 |
+
|
973 |
+
$atom_structure['flags']['no_lean_ahead'] = (bool) ($atom_structure['flags_raw'] & 0x001);
|
974 |
+
break;
|
975 |
+
|
976 |
+
|
977 |
+
case 'hdlr': // HanDLeR reference atom
|
978 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
979 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
980 |
+
$atom_structure['component_type'] = substr($atom_data, 4, 4);
|
981 |
+
$atom_structure['component_subtype'] = substr($atom_data, 8, 4);
|
982 |
+
$atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
|
983 |
+
$atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
|
984 |
+
$atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
|
985 |
+
$atom_structure['component_name'] = $this->Pascal2String(substr($atom_data, 24));
|
986 |
+
|
987 |
+
if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) {
|
988 |
+
$info['video']['dataformat'] = 'quicktimevr';
|
989 |
+
}
|
990 |
+
break;
|
991 |
+
|
992 |
+
|
993 |
+
case 'mdhd': // MeDia HeaDer atom
|
994 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
995 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
996 |
+
$atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
997 |
+
$atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
|
998 |
+
$atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
|
999 |
+
$atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
|
1000 |
+
$atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 2));
|
1001 |
+
$atom_structure['quality'] = getid3_lib::BigEndian2Int(substr($atom_data, 22, 2));
|
1002 |
+
|
1003 |
+
if ($atom_structure['time_scale'] == 0) {
|
1004 |
+
$info['error'][] = 'Corrupt Quicktime file: mdhd.time_scale == zero';
|
1005 |
+
return false;
|
1006 |
+
}
|
1007 |
+
$info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
|
1008 |
+
|
1009 |
+
$atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
|
1010 |
+
$atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
|
1011 |
+
$atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
|
1012 |
+
$atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
|
1013 |
+
if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
|
1014 |
+
$info['comments']['language'][] = $atom_structure['language'];
|
1015 |
+
}
|
1016 |
+
break;
|
1017 |
+
|
1018 |
+
|
1019 |
+
case 'pnot': // Preview atom
|
1020 |
+
$atom_structure['modification_date'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // "standard Macintosh format"
|
1021 |
+
$atom_structure['version_number'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x00
|
1022 |
+
$atom_structure['atom_type'] = substr($atom_data, 6, 4); // usually: 'PICT'
|
1023 |
+
$atom_structure['atom_index'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); // usually: 0x01
|
1024 |
+
|
1025 |
+
$atom_structure['modification_date_unix'] = getid3_lib::DateMac2Unix($atom_structure['modification_date']);
|
1026 |
+
break;
|
1027 |
+
|
1028 |
+
|
1029 |
+
case 'crgn': // Clipping ReGioN atom
|
1030 |
+
$atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box,
|
1031 |
+
$atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields
|
1032 |
+
$atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region.
|
1033 |
+
break;
|
1034 |
+
|
1035 |
+
|
1036 |
+
case 'load': // track LOAD settings atom
|
1037 |
+
$atom_structure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
|
1038 |
+
$atom_structure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
1039 |
+
$atom_structure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
|
1040 |
+
$atom_structure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
|
1041 |
+
|
1042 |
+
$atom_structure['default_hints']['double_buffer'] = (bool) ($atom_structure['default_hints_raw'] & 0x0020);
|
1043 |
+
$atom_structure['default_hints']['high_quality'] = (bool) ($atom_structure['default_hints_raw'] & 0x0100);
|
1044 |
+
break;
|
1045 |
+
|
1046 |
+
|
1047 |
+
case 'tmcd': // TiMe CoDe atom
|
1048 |
+
case 'chap': // CHAPter list atom
|
1049 |
+
case 'sync': // SYNChronization atom
|
1050 |
+
case 'scpt': // tranSCriPT atom
|
1051 |
+
case 'ssrc': // non-primary SouRCe atom
|
1052 |
+
for ($i = 0; $i < strlen($atom_data); $i += 4) {
|
1053 |
+
@$atom_structure['track_id'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));
|
1054 |
+
}
|
1055 |
+
break;
|
1056 |
+
|
1057 |
+
|
1058 |
+
case 'elst': // Edit LiST atom
|
1059 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
1060 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
1061 |
+
$atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
1062 |
+
for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) {
|
1063 |
+
$atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4));
|
1064 |
+
$atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4));
|
1065 |
+
$atom_structure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4));
|
1066 |
+
}
|
1067 |
+
break;
|
1068 |
+
|
1069 |
+
|
1070 |
+
case 'kmat': // compressed MATte atom
|
1071 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
1072 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
|
1073 |
+
$atom_structure['matte_data_raw'] = substr($atom_data, 4);
|
1074 |
+
break;
|
1075 |
+
|
1076 |
+
|
1077 |
+
case 'ctab': // Color TABle atom
|
1078 |
+
$atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000
|
1079 |
+
$atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000
|
1080 |
+
$atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1;
|
1081 |
+
for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) {
|
1082 |
+
$atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2));
|
1083 |
+
$atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2));
|
1084 |
+
$atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2));
|
1085 |
+
$atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2));
|
1086 |
+
}
|
1087 |
+
break;
|
1088 |
+
|
1089 |
+
|
1090 |
+
case 'mvhd': // MoVie HeaDer atom
|
1091 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
1092 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
|
1093 |
+
$atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
1094 |
+
$atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
|
1095 |
+
$atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
|
1096 |
+
$atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
|
1097 |
+
$atom_structure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 20, 4));
|
1098 |
+
$atom_structure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 24, 2));
|
1099 |
+
$atom_structure['reserved'] = substr($atom_data, 26, 10);
|
1100 |
+
$atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 36, 4));
|
1101 |
+
$atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
|
1102 |
+
$atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 44, 4));
|
1103 |
+
$atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4));
|
1104 |
+
$atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
|
1105 |
+
$atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 56, 4));
|
1106 |
+
$atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4));
|
1107 |
+
$atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));
|
1108 |
+
$atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4));
|
1109 |
+
$atom_structure['preview_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 72, 4));
|
1110 |
+
$atom_structure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 76, 4));
|
1111 |
+
$atom_structure['poster_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 80, 4));
|
1112 |
+
$atom_structure['selection_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 84, 4));
|
1113 |
+
$atom_structure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 88, 4));
|
1114 |
+
$atom_structure['current_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 92, 4));
|
1115 |
+
$atom_structure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 96, 4));
|
1116 |
+
|
1117 |
+
if ($atom_structure['time_scale'] == 0) {
|
1118 |
+
$info['error'][] = 'Corrupt Quicktime file: mvhd.time_scale == zero';
|
1119 |
+
return false;
|
1120 |
+
}
|
1121 |
+
$atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
|
1122 |
+
$atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
|
1123 |
+
$info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
|
1124 |
+
$info['quicktime']['display_scale'] = $atom_structure['matrix_a'];
|
1125 |
+
$info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
|
1126 |
+
break;
|
1127 |
+
|
1128 |
+
|
1129 |
+
case 'tkhd': // TracK HeaDer atom
|
1130 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
1131 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
|
1132 |
+
$atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
1133 |
+
$atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
|
1134 |
+
$atom_structure['trackid'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
|
1135 |
+
$atom_structure['reserved1'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
|
1136 |
+
$atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
|
1137 |
+
$atom_structure['reserved2'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 8));
|
1138 |
+
$atom_structure['layer'] = getid3_lib::BigEndian2Int(substr($atom_data, 32, 2));
|
1139 |
+
$atom_structure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atom_data, 34, 2));
|
1140 |
+
$atom_structure['volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 36, 2));
|
1141 |
+
$atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2));
|
1142 |
+
// http://developer.apple.com/library/mac/#documentation/QuickTime/RM/MovieBasics/MTEditing/K-Chapter/11MatrixFunctions.html
|
1143 |
+
// http://developer.apple.com/library/mac/#documentation/QuickTime/qtff/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-18737
|
1144 |
+
$atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
|
1145 |
+
$atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 44, 4));
|
1146 |
+
$atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 48, 4));
|
1147 |
+
$atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
|
1148 |
+
$atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 56, 4));
|
1149 |
+
$atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 60, 4));
|
1150 |
+
$atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));
|
1151 |
+
$atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 68, 4));
|
1152 |
+
$atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 72, 4));
|
1153 |
+
$atom_structure['width'] = getid3_lib::FixedPoint16_16(substr($atom_data, 76, 4));
|
1154 |
+
$atom_structure['height'] = getid3_lib::FixedPoint16_16(substr($atom_data, 80, 4));
|
1155 |
+
$atom_structure['flags']['enabled'] = (bool) ($atom_structure['flags_raw'] & 0x0001);
|
1156 |
+
$atom_structure['flags']['in_movie'] = (bool) ($atom_structure['flags_raw'] & 0x0002);
|
1157 |
+
$atom_structure['flags']['in_preview'] = (bool) ($atom_structure['flags_raw'] & 0x0004);
|
1158 |
+
$atom_structure['flags']['in_poster'] = (bool) ($atom_structure['flags_raw'] & 0x0008);
|
1159 |
+
$atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
|
1160 |
+
$atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
|
1161 |
+
|
1162 |
+
if ($atom_structure['flags']['enabled'] == 1) {
|
1163 |
+
if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) {
|
1164 |
+
$info['video']['resolution_x'] = $atom_structure['width'];
|
1165 |
+
$info['video']['resolution_y'] = $atom_structure['height'];
|
1166 |
+
}
|
1167 |
+
$info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']);
|
1168 |
+
$info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']);
|
1169 |
+
$info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];
|
1170 |
+
$info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];
|
1171 |
+
} else {
|
1172 |
+
// see: http://www.getid3.org/phpBB3/viewtopic.php?t=1295
|
1173 |
+
//if (isset($info['video']['resolution_x'])) { unset($info['video']['resolution_x']); }
|
1174 |
+
//if (isset($info['video']['resolution_y'])) { unset($info['video']['resolution_y']); }
|
1175 |
+
//if (isset($info['quicktime']['video'])) { unset($info['quicktime']['video']); }
|
1176 |
+
}
|
1177 |
+
break;
|
1178 |
+
|
1179 |
+
|
1180 |
+
case 'iods': // Initial Object DeScriptor atom
|
1181 |
+
// http://www.koders.com/c/fid1FAB3E762903DC482D8A246D4A4BF9F28E049594.aspx?s=windows.h
|
1182 |
+
// http://libquicktime.sourcearchive.com/documentation/1.0.2plus-pdebian/iods_8c-source.html
|
1183 |
+
$offset = 0;
|
1184 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
|
1185 |
+
$offset += 1;
|
1186 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 3));
|
1187 |
+
$offset += 3;
|
1188 |
+
$atom_structure['mp4_iod_tag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
|
1189 |
+
$offset += 1;
|
1190 |
+
$atom_structure['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
|
1191 |
+
//$offset already adjusted by quicktime_read_mp4_descr_length()
|
1192 |
+
$atom_structure['object_descriptor_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2));
|
1193 |
+
$offset += 2;
|
1194 |
+
$atom_structure['od_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
|
1195 |
+
$offset += 1;
|
1196 |
+
$atom_structure['scene_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
|
1197 |
+
$offset += 1;
|
1198 |
+
$atom_structure['audio_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
|
1199 |
+
$offset += 1;
|
1200 |
+
$atom_structure['video_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
|
1201 |
+
$offset += 1;
|
1202 |
+
$atom_structure['graphics_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
|
1203 |
+
$offset += 1;
|
1204 |
+
|
1205 |
+
$atom_structure['num_iods_tracks'] = ($atom_structure['length'] - 7) / 6; // 6 bytes would only be right if all tracks use 1-byte length fields
|
1206 |
+
for ($i = 0; $i < $atom_structure['num_iods_tracks']; $i++) {
|
1207 |
+
$atom_structure['track'][$i]['ES_ID_IncTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
|
1208 |
+
$offset += 1;
|
1209 |
+
$atom_structure['track'][$i]['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
|
1210 |
+
//$offset already adjusted by quicktime_read_mp4_descr_length()
|
1211 |
+
$atom_structure['track'][$i]['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4));
|
1212 |
+
$offset += 4;
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
$atom_structure['audio_profile_name'] = $this->QuicktimeIODSaudioProfileName($atom_structure['audio_profile_id']);
|
1216 |
+
$atom_structure['video_profile_name'] = $this->QuicktimeIODSvideoProfileName($atom_structure['video_profile_id']);
|
1217 |
+
break;
|
1218 |
+
|
1219 |
+
case 'ftyp': // FileTYPe (?) atom (for MP4 it seems)
|
1220 |
+
$atom_structure['signature'] = substr($atom_data, 0, 4);
|
1221 |
+
$atom_structure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
|
1222 |
+
$atom_structure['fourcc'] = substr($atom_data, 8, 4);
|
1223 |
+
break;
|
1224 |
+
|
1225 |
+
case 'mdat': // Media DATa atom
|
1226 |
+
// 'mdat' contains the actual data for the audio/video, possibly also subtitles
|
1227 |
+
|
1228 |
+
/* due to lack of known documentation, this is a kludge implementation. If you know of documentation on how mdat is properly structed, please send it to info@getid3.org */
|
1229 |
+
|
1230 |
+
// first, skip any 'wide' padding, and second 'mdat' header (with specified size of zero?)
|
1231 |
+
$mdat_offset = 0;
|
1232 |
+
while (true) {
|
1233 |
+
if (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x08".'wide') {
|
1234 |
+
$mdat_offset += 8;
|
1235 |
+
} elseif (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x00".'mdat') {
|
1236 |
+
$mdat_offset += 8;
|
1237 |
+
} else {
|
1238 |
+
break;
|
1239 |
+
}
|
1240 |
+
}
|
1241 |
+
|
1242 |
+
// check to see if it looks like chapter titles, in the form of unterminated strings with a leading 16-bit size field
|
1243 |
+
while (($chapter_string_length = getid3_lib::BigEndian2Int(substr($atom_data, $mdat_offset, 2)))
|
1244 |
+
&& ($chapter_string_length < 1000)
|
1245 |
+
&& ($chapter_string_length <= (strlen($atom_data) - $mdat_offset - 2))
|
1246 |
+
&& preg_match('#^[\x20-\xFF]+$#', substr($atom_data, $mdat_offset + 2, $chapter_string_length), $chapter_matches)) {
|
1247 |
+
$mdat_offset += (2 + $chapter_string_length);
|
1248 |
+
@$info['quicktime']['comments']['chapters'][] = $chapter_matches[0];
|
1249 |
+
}
|
1250 |
+
|
1251 |
+
|
1252 |
+
|
1253 |
+
if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) {
|
1254 |
+
|
1255 |
+
$info['avdataoffset'] = $atom_structure['offset'] + 8; // $info['quicktime'][$atomname]['offset'] + 8;
|
1256 |
+
$OldAVDataEnd = $info['avdataend'];
|
1257 |
+
$info['avdataend'] = $atom_structure['offset'] + $atom_structure['size']; // $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];
|
1258 |
+
|
1259 |
+
$getid3_temp = new getID3();
|
1260 |
+
$getid3_temp->openfile($this->getid3->filename);
|
1261 |
+
$getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
|
1262 |
+
$getid3_temp->info['avdataend'] = $info['avdataend'];
|
1263 |
+
$getid3_mp3 = new getid3_mp3($getid3_temp);
|
1264 |
+
if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode($this->fread(4)))) {
|
1265 |
+
$getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
|
1266 |
+
if (!empty($getid3_temp->info['warning'])) {
|
1267 |
+
foreach ($getid3_temp->info['warning'] as $value) {
|
1268 |
+
$info['warning'][] = $value;
|
1269 |
+
}
|
1270 |
+
}
|
1271 |
+
if (!empty($getid3_temp->info['mpeg'])) {
|
1272 |
+
$info['mpeg'] = $getid3_temp->info['mpeg'];
|
1273 |
+
if (isset($info['mpeg']['audio'])) {
|
1274 |
+
$info['audio']['dataformat'] = 'mp3';
|
1275 |
+
$info['audio']['codec'] = (!empty($info['mpeg']['audio']['encoder']) ? $info['mpeg']['audio']['encoder'] : (!empty($info['mpeg']['audio']['codec']) ? $info['mpeg']['audio']['codec'] : (!empty($info['mpeg']['audio']['LAME']) ? 'LAME' :'mp3')));
|
1276 |
+
$info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
|
1277 |
+
$info['audio']['channels'] = $info['mpeg']['audio']['channels'];
|
1278 |
+
$info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
|
1279 |
+
$info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
|
1280 |
+
$info['bitrate'] = $info['audio']['bitrate'];
|
1281 |
+
}
|
1282 |
+
}
|
1283 |
+
}
|
1284 |
+
unset($getid3_mp3, $getid3_temp);
|
1285 |
+
$info['avdataend'] = $OldAVDataEnd;
|
1286 |
+
unset($OldAVDataEnd);
|
1287 |
+
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
unset($mdat_offset, $chapter_string_length, $chapter_matches);
|
1291 |
+
break;
|
1292 |
+
|
1293 |
+
case 'free': // FREE space atom
|
1294 |
+
case 'skip': // SKIP atom
|
1295 |
+
case 'wide': // 64-bit expansion placeholder atom
|
1296 |
+
// 'free', 'skip' and 'wide' are just padding, contains no useful data at all
|
1297 |
+
|
1298 |
+
// When writing QuickTime files, it is sometimes necessary to update an atom's size.
|
1299 |
+
// It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom
|
1300 |
+
// is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime
|
1301 |
+
// puts an 8-byte placeholder atom before any atoms it may have to update the size of.
|
1302 |
+
// In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the
|
1303 |
+
// placeholder atom can be overwritten to obtain the necessary 8 extra bytes.
|
1304 |
+
// The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ).
|
1305 |
+
break;
|
1306 |
+
|
1307 |
+
|
1308 |
+
case 'nsav': // NoSAVe atom
|
1309 |
+
// http://developer.apple.com/technotes/tn/tn2038.html
|
1310 |
+
$atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
|
1311 |
+
break;
|
1312 |
+
|
1313 |
+
case 'ctyp': // Controller TYPe atom (seen on QTVR)
|
1314 |
+
// http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt
|
1315 |
+
// some controller names are:
|
1316 |
+
// 0x00 + 'std' for linear movie
|
1317 |
+
// 'none' for no controls
|
1318 |
+
$atom_structure['ctyp'] = substr($atom_data, 0, 4);
|
1319 |
+
$info['quicktime']['controller'] = $atom_structure['ctyp'];
|
1320 |
+
switch ($atom_structure['ctyp']) {
|
1321 |
+
case 'qtvr':
|
1322 |
+
$info['video']['dataformat'] = 'quicktimevr';
|
1323 |
+
break;
|
1324 |
+
}
|
1325 |
+
break;
|
1326 |
+
|
1327 |
+
case 'pano': // PANOrama track (seen on QTVR)
|
1328 |
+
$atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
|
1329 |
+
break;
|
1330 |
+
|
1331 |
+
case 'hint': // HINT track
|
1332 |
+
case 'hinf': //
|
1333 |
+
case 'hinv': //
|
1334 |
+
case 'hnti': //
|
1335 |
+
$info['quicktime']['hinting'] = true;
|
1336 |
+
break;
|
1337 |
+
|
1338 |
+
case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR)
|
1339 |
+
for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) {
|
1340 |
+
$atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));
|
1341 |
+
}
|
1342 |
+
break;
|
1343 |
+
|
1344 |
+
|
1345 |
+
// Observed-but-not-handled atom types are just listed here to prevent warnings being generated
|
1346 |
+
case 'FXTC': // Something to do with Adobe After Effects (?)
|
1347 |
+
case 'PrmA':
|
1348 |
+
case 'code':
|
1349 |
+
case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
|
1350 |
+
case 'tapt': // TrackApertureModeDimensionsAID - http://developer.apple.com/documentation/QuickTime/Reference/QT7-1_Update_Reference/Constants/Constants.html
|
1351 |
+
// tapt seems to be used to compute the video size [http://www.getid3.org/phpBB3/viewtopic.php?t=838]
|
1352 |
+
// * http://lists.apple.com/archives/quicktime-api/2006/Aug/msg00014.html
|
1353 |
+
// * http://handbrake.fr/irclogs/handbrake-dev/handbrake-dev20080128_pg2.html
|
1354 |
+
case 'ctts':// STCompositionOffsetAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
|
1355 |
+
case 'cslg':// STCompositionShiftLeastGreatestAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
|
1356 |
+
case 'sdtp':// STSampleDependencyAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
|
1357 |
+
case 'stps':// STPartialSyncSampleAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
|
1358 |
+
//$atom_structure['data'] = $atom_data;
|
1359 |
+
break;
|
1360 |
+
|
1361 |
+
case "\xA9".'xyz': // GPS latitude+longitude+altitude
|
1362 |
+
$atom_structure['data'] = $atom_data;
|
1363 |
+
if (preg_match('#([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)?/$#i', $atom_data, $matches)) {
|
1364 |
+
@list($all, $latitude, $longitude, $altitude) = $matches;
|
1365 |
+
$info['quicktime']['comments']['gps_latitude'][] = floatval($latitude);
|
1366 |
+
$info['quicktime']['comments']['gps_longitude'][] = floatval($longitude);
|
1367 |
+
if (!empty($altitude)) {
|
1368 |
+
$info['quicktime']['comments']['gps_altitude'][] = floatval($altitude);
|
1369 |
+
}
|
1370 |
+
} else {
|
1371 |
+
$info['warning'][] = 'QuickTime atom "©xyz" data does not match expected data pattern at offset '.$baseoffset.'. Please report as getID3() bug.';
|
1372 |
+
}
|
1373 |
+
break;
|
1374 |
+
|
1375 |
+
case 'NCDT':
|
1376 |
+
// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
|
1377 |
+
// Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
|
1378 |
+
$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 4, $atomHierarchy, $ParseAllPossibleAtoms);
|
1379 |
+
break;
|
1380 |
+
case 'NCTH': // Nikon Camera THumbnail image
|
1381 |
+
case 'NCVW': // Nikon Camera preVieW image
|
1382 |
+
// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
|
1383 |
+
if (preg_match('/^\xFF\xD8\xFF/', $atom_data)) {
|
1384 |
+
$atom_structure['data'] = $atom_data;
|
1385 |
+
$atom_structure['image_mime'] = 'image/jpeg';
|
1386 |
+
$atom_structure['description'] = (($atomname == 'NCTH') ? 'Nikon Camera Thumbnail Image' : (($atomname == 'NCVW') ? 'Nikon Camera Preview Image' : 'Nikon preview image'));
|
1387 |
+
$info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_data, 'description'=>$atom_structure['description']);
|
1388 |
+
}
|
1389 |
+
break;
|
1390 |
+
case 'NCTG': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
|
1391 |
+
$atom_structure['data'] = $this->QuicktimeParseNikonNCTG($atom_data);
|
1392 |
+
break;
|
1393 |
+
case 'NCHD': // Nikon:MakerNoteVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
|
1394 |
+
case 'NCDB': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
|
1395 |
+
case 'CNCV': // Canon:CompressorVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html
|
1396 |
+
$atom_structure['data'] = $atom_data;
|
1397 |
+
break;
|
1398 |
+
|
1399 |
+
case "\x00\x00\x00\x00":
|
1400 |
+
case 'meta': // METAdata atom
|
1401 |
+
// some kind of metacontainer, may contain a big data dump such as:
|
1402 |
+
// mdta keys mdtacom.apple.quicktime.make (mdtacom.apple.quicktime.creationdate ,mdtacom.apple.quicktime.location.ISO6709 $mdtacom.apple.quicktime.software !mdtacom.apple.quicktime.model ilst data DEApple 0 (data DE2011-05-11T17:54:04+0200 2 *data DE+52.4936+013.3897+040.247/ data DE4.3.1 data DEiPhone 4
|
1403 |
+
// http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
|
1404 |
+
|
1405 |
+
$atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
|
1406 |
+
$atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
|
1407 |
+
$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_data, 4), $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
|
1408 |
+
//$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
|
1409 |
+
break;
|
1410 |
+
|
1411 |
+
case 'data': // metaDATA atom
|
1412 |
+
// seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in sample I have), remainder is useful data
|
1413 |
+
$atom_structure['language'] = substr($atom_data, 4 + 0, 2);
|
1414 |
+
$atom_structure['unknown'] = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2));
|
1415 |
+
$atom_structure['data'] = substr($atom_data, 4 + 4);
|
1416 |
+
break;
|
1417 |
+
|
1418 |
+
default:
|
1419 |
+
$info['warning'][] = 'Unknown QuickTime atom type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" ('.trim(getid3_lib::PrintHexBytes($atomname)).') at offset '.$baseoffset;
|
1420 |
+
$atom_structure['data'] = $atom_data;
|
1421 |
+
break;
|
1422 |
+
}
|
1423 |
+
array_pop($atomHierarchy);
|
1424 |
+
return $atom_structure;
|
1425 |
+
}
|
1426 |
+
|
1427 |
+
public function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
|
1428 |
+
//echo 'QuicktimeParseContainerAtom('.substr($atom_data, 4, 4).') @ '.$baseoffset.'<br><br>';
|
1429 |
+
$atom_structure = false;
|
1430 |
+
$subatomoffset = 0;
|
1431 |
+
$subatomcounter = 0;
|
1432 |
+
if ((strlen($atom_data) == 4) && (getid3_lib::BigEndian2Int($atom_data) == 0x00000000)) {
|
1433 |
+
return false;
|
1434 |
+
}
|
1435 |
+
while ($subatomoffset < strlen($atom_data)) {
|
1436 |
+
$subatomsize = getid3_lib::BigEndian2Int(substr($atom_data, $subatomoffset + 0, 4));
|
1437 |
+
$subatomname = substr($atom_data, $subatomoffset + 4, 4);
|
1438 |
+
$subatomdata = substr($atom_data, $subatomoffset + 8, $subatomsize - 8);
|
1439 |
+
if ($subatomsize == 0) {
|
1440 |
+
// Furthermore, for historical reasons the list of atoms is optionally
|
1441 |
+
// terminated by a 32-bit integer set to 0. If you are writing a program
|
1442 |
+
// to read user data atoms, you should allow for the terminating 0.
|
1443 |
+
return $atom_structure;
|
1444 |
+
}
|
1445 |
+
|
1446 |
+
$atom_structure[$subatomcounter] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms);
|
1447 |
+
|
1448 |
+
$subatomoffset += $subatomsize;
|
1449 |
+
$subatomcounter++;
|
1450 |
+
}
|
1451 |
+
return $atom_structure;
|
1452 |
+
}
|
1453 |
+
|
1454 |
+
|
1455 |
+
public function quicktime_read_mp4_descr_length($data, &$offset) {
|
1456 |
+
// http://libquicktime.sourcearchive.com/documentation/2:1.0.2plus-pdebian-2build1/esds_8c-source.html
|
1457 |
+
$num_bytes = 0;
|
1458 |
+
$length = 0;
|
1459 |
+
do {
|
1460 |
+
$b = ord(substr($data, $offset++, 1));
|
1461 |
+
$length = ($length << 7) | ($b & 0x7F);
|
1462 |
+
} while (($b & 0x80) && ($num_bytes++ < 4));
|
1463 |
+
return $length;
|
1464 |
+
}
|
1465 |
+
|
1466 |
+
|
1467 |
+
public function QuicktimeLanguageLookup($languageid) {
|
1468 |
+
// http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-34353
|
1469 |
+
static $QuicktimeLanguageLookup = array();
|
1470 |
+
if (empty($QuicktimeLanguageLookup)) {
|
1471 |
+
$QuicktimeLanguageLookup[0] = 'English';
|
1472 |
+
$QuicktimeLanguageLookup[1] = 'French';
|
1473 |
+
$QuicktimeLanguageLookup[2] = 'German';
|
1474 |
+
$QuicktimeLanguageLookup[3] = 'Italian';
|
1475 |
+
$QuicktimeLanguageLookup[4] = 'Dutch';
|
1476 |
+
$QuicktimeLanguageLookup[5] = 'Swedish';
|
1477 |
+
$QuicktimeLanguageLookup[6] = 'Spanish';
|
1478 |
+
$QuicktimeLanguageLookup[7] = 'Danish';
|
1479 |
+
$QuicktimeLanguageLookup[8] = 'Portuguese';
|
1480 |
+
$QuicktimeLanguageLookup[9] = 'Norwegian';
|
1481 |
+
$QuicktimeLanguageLookup[10] = 'Hebrew';
|
1482 |
+
$QuicktimeLanguageLookup[11] = 'Japanese';
|
1483 |
+
$QuicktimeLanguageLookup[12] = 'Arabic';
|
1484 |
+
$QuicktimeLanguageLookup[13] = 'Finnish';
|
1485 |
+
$QuicktimeLanguageLookup[14] = 'Greek';
|
1486 |
+
$QuicktimeLanguageLookup[15] = 'Icelandic';
|
1487 |
+
$QuicktimeLanguageLookup[16] = 'Maltese';
|
1488 |
+
$QuicktimeLanguageLookup[17] = 'Turkish';
|
1489 |
+
$QuicktimeLanguageLookup[18] = 'Croatian';
|
1490 |
+
$QuicktimeLanguageLookup[19] = 'Chinese (Traditional)';
|
1491 |
+
$QuicktimeLanguageLookup[20] = 'Urdu';
|
1492 |
+
$QuicktimeLanguageLookup[21] = 'Hindi';
|
1493 |
+
$QuicktimeLanguageLookup[22] = 'Thai';
|
1494 |
+
$QuicktimeLanguageLookup[23] = 'Korean';
|
1495 |
+
$QuicktimeLanguageLookup[24] = 'Lithuanian';
|
1496 |
+
$QuicktimeLanguageLookup[25] = 'Polish';
|
1497 |
+
$QuicktimeLanguageLookup[26] = 'Hungarian';
|
1498 |
+
$QuicktimeLanguageLookup[27] = 'Estonian';
|
1499 |
+
$QuicktimeLanguageLookup[28] = 'Lettish';
|
1500 |
+
$QuicktimeLanguageLookup[28] = 'Latvian';
|
1501 |
+
$QuicktimeLanguageLookup[29] = 'Saamisk';
|
1502 |
+
$QuicktimeLanguageLookup[29] = 'Lappish';
|
1503 |
+
$QuicktimeLanguageLookup[30] = 'Faeroese';
|
1504 |
+
$QuicktimeLanguageLookup[31] = 'Farsi';
|
1505 |
+
$QuicktimeLanguageLookup[31] = 'Persian';
|
1506 |
+
$QuicktimeLanguageLookup[32] = 'Russian';
|
1507 |
+
$QuicktimeLanguageLookup[33] = 'Chinese (Simplified)';
|
1508 |
+
$QuicktimeLanguageLookup[34] = 'Flemish';
|
1509 |
+
$QuicktimeLanguageLookup[35] = 'Irish';
|
1510 |
+
$QuicktimeLanguageLookup[36] = 'Albanian';
|
1511 |
+
$QuicktimeLanguageLookup[37] = 'Romanian';
|
1512 |
+
$QuicktimeLanguageLookup[38] = 'Czech';
|
1513 |
+
$QuicktimeLanguageLookup[39] = 'Slovak';
|
1514 |
+
$QuicktimeLanguageLookup[40] = 'Slovenian';
|
1515 |
+
$QuicktimeLanguageLookup[41] = 'Yiddish';
|
1516 |
+
$QuicktimeLanguageLookup[42] = 'Serbian';
|
1517 |
+
$QuicktimeLanguageLookup[43] = 'Macedonian';
|
1518 |
+
$QuicktimeLanguageLookup[44] = 'Bulgarian';
|
1519 |
+
$QuicktimeLanguageLookup[45] = 'Ukrainian';
|
1520 |
+
$QuicktimeLanguageLookup[46] = 'Byelorussian';
|
1521 |
+
$QuicktimeLanguageLookup[47] = 'Uzbek';
|
1522 |
+
$QuicktimeLanguageLookup[48] = 'Kazakh';
|
1523 |
+
$QuicktimeLanguageLookup[49] = 'Azerbaijani';
|
1524 |
+
$QuicktimeLanguageLookup[50] = 'AzerbaijanAr';
|
1525 |
+
$QuicktimeLanguageLookup[51] = 'Armenian';
|
1526 |
+
$QuicktimeLanguageLookup[52] = 'Georgian';
|
1527 |
+
$QuicktimeLanguageLookup[53] = 'Moldavian';
|
1528 |
+
$QuicktimeLanguageLookup[54] = 'Kirghiz';
|
1529 |
+
$QuicktimeLanguageLookup[55] = 'Tajiki';
|
1530 |
+
$QuicktimeLanguageLookup[56] = 'Turkmen';
|
1531 |
+
$QuicktimeLanguageLookup[57] = 'Mongolian';
|
1532 |
+
$QuicktimeLanguageLookup[58] = 'MongolianCyr';
|
1533 |
+
$QuicktimeLanguageLookup[59] = 'Pashto';
|
1534 |
+
$QuicktimeLanguageLookup[60] = 'Kurdish';
|
1535 |
+
$QuicktimeLanguageLookup[61] = 'Kashmiri';
|
1536 |
+
$QuicktimeLanguageLookup[62] = 'Sindhi';
|
1537 |
+
$QuicktimeLanguageLookup[63] = 'Tibetan';
|
1538 |
+
$QuicktimeLanguageLookup[64] = 'Nepali';
|
1539 |
+
$QuicktimeLanguageLookup[65] = 'Sanskrit';
|
1540 |
+
$QuicktimeLanguageLookup[66] = 'Marathi';
|
1541 |
+
$QuicktimeLanguageLookup[67] = 'Bengali';
|
1542 |
+
$QuicktimeLanguageLookup[68] = 'Assamese';
|
1543 |
+
$QuicktimeLanguageLookup[69] = 'Gujarati';
|
1544 |
+
$QuicktimeLanguageLookup[70] = 'Punjabi';
|
1545 |
+
$QuicktimeLanguageLookup[71] = 'Oriya';
|
1546 |
+
$QuicktimeLanguageLookup[72] = 'Malayalam';
|
1547 |
+
$QuicktimeLanguageLookup[73] = 'Kannada';
|
1548 |
+
$QuicktimeLanguageLookup[74] = 'Tamil';
|
1549 |
+
$QuicktimeLanguageLookup[75] = 'Telugu';
|
1550 |
+
$QuicktimeLanguageLookup[76] = 'Sinhalese';
|
1551 |
+
$QuicktimeLanguageLookup[77] = 'Burmese';
|
1552 |
+
$QuicktimeLanguageLookup[78] = 'Khmer';
|
1553 |
+
$QuicktimeLanguageLookup[79] = 'Lao';
|
1554 |
+
$QuicktimeLanguageLookup[80] = 'Vietnamese';
|
1555 |
+
$QuicktimeLanguageLookup[81] = 'Indonesian';
|
1556 |
+
$QuicktimeLanguageLookup[82] = 'Tagalog';
|
1557 |
+
$QuicktimeLanguageLookup[83] = 'MalayRoman';
|
1558 |
+
$QuicktimeLanguageLookup[84] = 'MalayArabic';
|
1559 |
+
$QuicktimeLanguageLookup[85] = 'Amharic';
|
1560 |
+
$QuicktimeLanguageLookup[86] = 'Tigrinya';
|
1561 |
+
$QuicktimeLanguageLookup[87] = 'Galla';
|
1562 |
+
$QuicktimeLanguageLookup[87] = 'Oromo';
|
1563 |
+
$QuicktimeLanguageLookup[88] = 'Somali';
|
1564 |
+
$QuicktimeLanguageLookup[89] = 'Swahili';
|
1565 |
+
$QuicktimeLanguageLookup[90] = 'Ruanda';
|
1566 |
+
$QuicktimeLanguageLookup[91] = 'Rundi';
|
1567 |
+
$QuicktimeLanguageLookup[92] = 'Chewa';
|
1568 |
+
$QuicktimeLanguageLookup[93] = 'Malagasy';
|
1569 |
+
$QuicktimeLanguageLookup[94] = 'Esperanto';
|
1570 |
+
$QuicktimeLanguageLookup[128] = 'Welsh';
|
1571 |
+
$QuicktimeLanguageLookup[129] = 'Basque';
|
1572 |
+
$QuicktimeLanguageLookup[130] = 'Catalan';
|
1573 |
+
$QuicktimeLanguageLookup[131] = 'Latin';
|
1574 |
+
$QuicktimeLanguageLookup[132] = 'Quechua';
|
1575 |
+
$QuicktimeLanguageLookup[133] = 'Guarani';
|
1576 |
+
$QuicktimeLanguageLookup[134] = 'Aymara';
|
1577 |
+
$QuicktimeLanguageLookup[135] = 'Tatar';
|
1578 |
+
$QuicktimeLanguageLookup[136] = 'Uighur';
|
1579 |
+
$QuicktimeLanguageLookup[137] = 'Dzongkha';
|
1580 |
+
$QuicktimeLanguageLookup[138] = 'JavaneseRom';
|
1581 |
+
$QuicktimeLanguageLookup[32767] = 'Unspecified';
|
1582 |
+
}
|
1583 |
+
if (($languageid > 138) && ($languageid < 32767)) {
|
1584 |
+
/*
|
1585 |
+
ISO Language Codes - http://www.loc.gov/standards/iso639-2/php/code_list.php
|
1586 |
+
Because the language codes specified by ISO 639-2/T are three characters long, they must be packed to fit into a 16-bit field.
|
1587 |
+
The packing algorithm must map each of the three characters, which are always lowercase, into a 5-bit integer and then concatenate
|
1588 |
+
these integers into the least significant 15 bits of a 16-bit integer, leaving the 16-bit integer's most significant bit set to zero.
|
1589 |
+
|
1590 |
+
One algorithm for performing this packing is to treat each ISO character as a 16-bit integer. Subtract 0x60 from the first character
|
1591 |
+
and multiply by 2^10 (0x400), subtract 0x60 from the second character and multiply by 2^5 (0x20), subtract 0x60 from the third character,
|
1592 |
+
and add the three 16-bit values. This will result in a single 16-bit value with the three codes correctly packed into the 15 least
|
1593 |
+
significant bits and the most significant bit set to zero.
|
1594 |
+
*/
|
1595 |
+
$iso_language_id = '';
|
1596 |
+
$iso_language_id .= chr((($languageid & 0x7C00) >> 10) + 0x60);
|
1597 |
+
$iso_language_id .= chr((($languageid & 0x03E0) >> 5) + 0x60);
|
1598 |
+
$iso_language_id .= chr((($languageid & 0x001F) >> 0) + 0x60);
|
1599 |
+
$QuicktimeLanguageLookup[$languageid] = getid3_id3v2::LanguageLookup($iso_language_id);
|
1600 |
+
}
|
1601 |
+
return (isset($QuicktimeLanguageLookup[$languageid]) ? $QuicktimeLanguageLookup[$languageid] : 'invalid');
|
1602 |
+
}
|
1603 |
+
|
1604 |
+
public function QuicktimeVideoCodecLookup($codecid) {
|
1605 |
+
static $QuicktimeVideoCodecLookup = array();
|
1606 |
+
if (empty($QuicktimeVideoCodecLookup)) {
|
1607 |
+
$QuicktimeVideoCodecLookup['.SGI'] = 'SGI';
|
1608 |
+
$QuicktimeVideoCodecLookup['3IV1'] = '3ivx MPEG-4 v1';
|
1609 |
+
$QuicktimeVideoCodecLookup['3IV2'] = '3ivx MPEG-4 v2';
|
1610 |
+
$QuicktimeVideoCodecLookup['3IVX'] = '3ivx MPEG-4';
|
1611 |
+
$QuicktimeVideoCodecLookup['8BPS'] = 'Planar RGB';
|
1612 |
+
$QuicktimeVideoCodecLookup['avc1'] = 'H.264/MPEG-4 AVC';
|
1613 |
+
$QuicktimeVideoCodecLookup['avr '] = 'AVR-JPEG';
|
1614 |
+
$QuicktimeVideoCodecLookup['b16g'] = '16Gray';
|
1615 |
+
$QuicktimeVideoCodecLookup['b32a'] = '32AlphaGray';
|
1616 |
+
$QuicktimeVideoCodecLookup['b48r'] = '48RGB';
|
1617 |
+
$QuicktimeVideoCodecLookup['b64a'] = '64ARGB';
|
1618 |
+
$QuicktimeVideoCodecLookup['base'] = 'Base';
|
1619 |
+
$QuicktimeVideoCodecLookup['clou'] = 'Cloud';
|
1620 |
+
$QuicktimeVideoCodecLookup['cmyk'] = 'CMYK';
|
1621 |
+
$QuicktimeVideoCodecLookup['cvid'] = 'Cinepak';
|
1622 |
+
$QuicktimeVideoCodecLookup['dmb1'] = 'OpenDML JPEG';
|
1623 |
+
$QuicktimeVideoCodecLookup['dvc '] = 'DVC-NTSC';
|
1624 |
+
$QuicktimeVideoCodecLookup['dvcp'] = 'DVC-PAL';
|
1625 |
+
$QuicktimeVideoCodecLookup['dvpn'] = 'DVCPro-NTSC';
|
1626 |
+
$QuicktimeVideoCodecLookup['dvpp'] = 'DVCPro-PAL';
|
1627 |
+
$QuicktimeVideoCodecLookup['fire'] = 'Fire';
|
1628 |
+
$QuicktimeVideoCodecLookup['flic'] = 'FLC';
|
1629 |
+
$QuicktimeVideoCodecLookup['gif '] = 'GIF';
|
1630 |
+
$QuicktimeVideoCodecLookup['h261'] = 'H261';
|
1631 |
+
$QuicktimeVideoCodecLookup['h263'] = 'H263';
|
1632 |
+
$QuicktimeVideoCodecLookup['IV41'] = 'Indeo4';
|
1633 |
+
$QuicktimeVideoCodecLookup['jpeg'] = 'JPEG';
|
1634 |
+
$QuicktimeVideoCodecLookup['kpcd'] = 'PhotoCD';
|
1635 |
+
$QuicktimeVideoCodecLookup['mjpa'] = 'Motion JPEG-A';
|
1636 |
+
$QuicktimeVideoCodecLookup['mjpb'] = 'Motion JPEG-B';
|
1637 |
+
$QuicktimeVideoCodecLookup['msvc'] = 'Microsoft Video1';
|
1638 |
+
$QuicktimeVideoCodecLookup['myuv'] = 'MPEG YUV420';
|
1639 |
+
$QuicktimeVideoCodecLookup['path'] = 'Vector';
|
1640 |
+
$QuicktimeVideoCodecLookup['png '] = 'PNG';
|
1641 |
+
$QuicktimeVideoCodecLookup['PNTG'] = 'MacPaint';
|
1642 |
+
$QuicktimeVideoCodecLookup['qdgx'] = 'QuickDrawGX';
|
1643 |
+
$QuicktimeVideoCodecLookup['qdrw'] = 'QuickDraw';
|
1644 |
+
$QuicktimeVideoCodecLookup['raw '] = 'RAW';
|
1645 |
+
$QuicktimeVideoCodecLookup['ripl'] = 'WaterRipple';
|
1646 |
+
$QuicktimeVideoCodecLookup['rpza'] = 'Video';
|
1647 |
+
$QuicktimeVideoCodecLookup['smc '] = 'Graphics';
|
1648 |
+
$QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 1';
|
1649 |
+
$QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 3';
|
1650 |
+
$QuicktimeVideoCodecLookup['syv9'] = 'Sorenson YUV9';
|
1651 |
+
$QuicktimeVideoCodecLookup['tga '] = 'Targa';
|
1652 |
+
$QuicktimeVideoCodecLookup['tiff'] = 'TIFF';
|
1653 |
+
$QuicktimeVideoCodecLookup['WRAW'] = 'Windows RAW';
|
1654 |
+
$QuicktimeVideoCodecLookup['WRLE'] = 'BMP';
|
1655 |
+
$QuicktimeVideoCodecLookup['y420'] = 'YUV420';
|
1656 |
+
$QuicktimeVideoCodecLookup['yuv2'] = 'ComponentVideo';
|
1657 |
+
$QuicktimeVideoCodecLookup['yuvs'] = 'ComponentVideoUnsigned';
|
1658 |
+
$QuicktimeVideoCodecLookup['yuvu'] = 'ComponentVideoSigned';
|
1659 |
+
}
|
1660 |
+
return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : '');
|
1661 |
+
}
|
1662 |
+
|
1663 |
+
public function QuicktimeAudioCodecLookup($codecid) {
|
1664 |
+
static $QuicktimeAudioCodecLookup = array();
|
1665 |
+
if (empty($QuicktimeAudioCodecLookup)) {
|
1666 |
+
$QuicktimeAudioCodecLookup['.mp3'] = 'Fraunhofer MPEG Layer-III alias';
|
1667 |
+
$QuicktimeAudioCodecLookup['aac '] = 'ISO/IEC 14496-3 AAC';
|
1668 |
+
$QuicktimeAudioCodecLookup['agsm'] = 'Apple GSM 10:1';
|
1669 |
+
$QuicktimeAudioCodecLookup['alac'] = 'Apple Lossless Audio Codec';
|
1670 |
+
$QuicktimeAudioCodecLookup['alaw'] = 'A-law 2:1';
|
1671 |
+
$QuicktimeAudioCodecLookup['conv'] = 'Sample Format';
|
1672 |
+
$QuicktimeAudioCodecLookup['dvca'] = 'DV';
|
1673 |
+
$QuicktimeAudioCodecLookup['dvi '] = 'DV 4:1';
|
1674 |
+
$QuicktimeAudioCodecLookup['eqal'] = 'Frequency Equalizer';
|
1675 |
+
$QuicktimeAudioCodecLookup['fl32'] = '32-bit Floating Point';
|
1676 |
+
$QuicktimeAudioCodecLookup['fl64'] = '64-bit Floating Point';
|
1677 |
+
$QuicktimeAudioCodecLookup['ima4'] = 'Interactive Multimedia Association 4:1';
|
1678 |
+
$QuicktimeAudioCodecLookup['in24'] = '24-bit Integer';
|
1679 |
+
$QuicktimeAudioCodecLookup['in32'] = '32-bit Integer';
|
1680 |
+
$QuicktimeAudioCodecLookup['lpc '] = 'LPC 23:1';
|
1681 |
+
$QuicktimeAudioCodecLookup['MAC3'] = 'Macintosh Audio Compression/Expansion (MACE) 3:1';
|
1682 |
+
$QuicktimeAudioCodecLookup['MAC6'] = 'Macintosh Audio Compression/Expansion (MACE) 6:1';
|
1683 |
+
$QuicktimeAudioCodecLookup['mixb'] = '8-bit Mixer';
|
1684 |
+
$QuicktimeAudioCodecLookup['mixw'] = '16-bit Mixer';
|
1685 |
+
$QuicktimeAudioCodecLookup['mp4a'] = 'ISO/IEC 14496-3 AAC';
|
1686 |
+
$QuicktimeAudioCodecLookup['MS'."\x00\x02"] = 'Microsoft ADPCM';
|
1687 |
+
$QuicktimeAudioCodecLookup['MS'."\x00\x11"] = 'DV IMA';
|
1688 |
+
$QuicktimeAudioCodecLookup['MS'."\x00\x55"] = 'Fraunhofer MPEG Layer III';
|
1689 |
+
$QuicktimeAudioCodecLookup['NONE'] = 'No Encoding';
|
1690 |
+
$QuicktimeAudioCodecLookup['Qclp'] = 'Qualcomm PureVoice';
|
1691 |
+
$QuicktimeAudioCodecLookup['QDM2'] = 'QDesign Music 2';
|
1692 |
+
$QuicktimeAudioCodecLookup['QDMC'] = 'QDesign Music 1';
|
1693 |
+
$QuicktimeAudioCodecLookup['ratb'] = '8-bit Rate';
|
1694 |
+
$QuicktimeAudioCodecLookup['ratw'] = '16-bit Rate';
|
1695 |
+
$QuicktimeAudioCodecLookup['raw '] = 'raw PCM';
|
1696 |
+
$QuicktimeAudioCodecLookup['sour'] = 'Sound Source';
|
1697 |
+
$QuicktimeAudioCodecLookup['sowt'] = 'signed/two\'s complement (Little Endian)';
|
1698 |
+
$QuicktimeAudioCodecLookup['str1'] = 'Iomega MPEG layer II';
|
1699 |
+
$QuicktimeAudioCodecLookup['str2'] = 'Iomega MPEG *layer II';
|
1700 |
+
$QuicktimeAudioCodecLookup['str3'] = 'Iomega MPEG **layer II';
|
1701 |
+
$QuicktimeAudioCodecLookup['str4'] = 'Iomega MPEG ***layer II';
|
1702 |
+
$QuicktimeAudioCodecLookup['twos'] = 'signed/two\'s complement (Big Endian)';
|
1703 |
+
$QuicktimeAudioCodecLookup['ulaw'] = 'mu-law 2:1';
|
1704 |
+
}
|
1705 |
+
return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : '');
|
1706 |
+
}
|
1707 |
+
|
1708 |
+
public function QuicktimeDCOMLookup($compressionid) {
|
1709 |
+
static $QuicktimeDCOMLookup = array();
|
1710 |
+
if (empty($QuicktimeDCOMLookup)) {
|
1711 |
+
$QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate';
|
1712 |
+
$QuicktimeDCOMLookup['adec'] = 'Apple Compression';
|
1713 |
+
}
|
1714 |
+
return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : '');
|
1715 |
+
}
|
1716 |
+
|
1717 |
+
public function QuicktimeColorNameLookup($colordepthid) {
|
1718 |
+
static $QuicktimeColorNameLookup = array();
|
1719 |
+
if (empty($QuicktimeColorNameLookup)) {
|
1720 |
+
$QuicktimeColorNameLookup[1] = '2-color (monochrome)';
|
1721 |
+
$QuicktimeColorNameLookup[2] = '4-color';
|
1722 |
+
$QuicktimeColorNameLookup[4] = '16-color';
|
1723 |
+
$QuicktimeColorNameLookup[8] = '256-color';
|
1724 |
+
$QuicktimeColorNameLookup[16] = 'thousands (16-bit color)';
|
1725 |
+
$QuicktimeColorNameLookup[24] = 'millions (24-bit color)';
|
1726 |
+
$QuicktimeColorNameLookup[32] = 'millions+ (32-bit color)';
|
1727 |
+
$QuicktimeColorNameLookup[33] = 'black & white';
|
1728 |
+
$QuicktimeColorNameLookup[34] = '4-gray';
|
1729 |
+
$QuicktimeColorNameLookup[36] = '16-gray';
|
1730 |
+
$QuicktimeColorNameLookup[40] = '256-gray';
|
1731 |
+
}
|
1732 |
+
return (isset($QuicktimeColorNameLookup[$colordepthid]) ? $QuicktimeColorNameLookup[$colordepthid] : 'invalid');
|
1733 |
+
}
|
1734 |
+
|
1735 |
+
public function QuicktimeSTIKLookup($stik) {
|
1736 |
+
static $QuicktimeSTIKLookup = array();
|
1737 |
+
if (empty($QuicktimeSTIKLookup)) {
|
1738 |
+
$QuicktimeSTIKLookup[0] = 'Movie';
|
1739 |
+
$QuicktimeSTIKLookup[1] = 'Normal';
|
1740 |
+
$QuicktimeSTIKLookup[2] = 'Audiobook';
|
1741 |
+
$QuicktimeSTIKLookup[5] = 'Whacked Bookmark';
|
1742 |
+
$QuicktimeSTIKLookup[6] = 'Music Video';
|
1743 |
+
$QuicktimeSTIKLookup[9] = 'Short Film';
|
1744 |
+
$QuicktimeSTIKLookup[10] = 'TV Show';
|
1745 |
+
$QuicktimeSTIKLookup[11] = 'Booklet';
|
1746 |
+
$QuicktimeSTIKLookup[14] = 'Ringtone';
|
1747 |
+
$QuicktimeSTIKLookup[21] = 'Podcast';
|
1748 |
+
}
|
1749 |
+
return (isset($QuicktimeSTIKLookup[$stik]) ? $QuicktimeSTIKLookup[$stik] : 'invalid');
|
1750 |
+
}
|
1751 |
+
|
1752 |
+
public function QuicktimeIODSaudioProfileName($audio_profile_id) {
|
1753 |
+
static $QuicktimeIODSaudioProfileNameLookup = array();
|
1754 |
+
if (empty($QuicktimeIODSaudioProfileNameLookup)) {
|
1755 |
+
$QuicktimeIODSaudioProfileNameLookup = array(
|
1756 |
+
0x00 => 'ISO Reserved (0x00)',
|
1757 |
+
0x01 => 'Main Audio Profile @ Level 1',
|
1758 |
+
0x02 => 'Main Audio Profile @ Level 2',
|
1759 |
+
0x03 => 'Main Audio Profile @ Level 3',
|
1760 |
+
0x04 => 'Main Audio Profile @ Level 4',
|
1761 |
+
0x05 => 'Scalable Audio Profile @ Level 1',
|
1762 |
+
0x06 => 'Scalable Audio Profile @ Level 2',
|
1763 |
+
0x07 => 'Scalable Audio Profile @ Level 3',
|
1764 |
+
0x08 => 'Scalable Audio Profile @ Level 4',
|
1765 |
+
0x09 => 'Speech Audio Profile @ Level 1',
|
1766 |
+
0x0A => 'Speech Audio Profile @ Level 2',
|
1767 |
+
0x0B => 'Synthetic Audio Profile @ Level 1',
|
1768 |
+
0x0C => 'Synthetic Audio Profile @ Level 2',
|
1769 |
+
0x0D => 'Synthetic Audio Profile @ Level 3',
|
1770 |
+
0x0E => 'High Quality Audio Profile @ Level 1',
|
1771 |
+
0x0F => 'High Quality Audio Profile @ Level 2',
|
1772 |
+
0x10 => 'High Quality Audio Profile @ Level 3',
|
1773 |
+
0x11 => 'High Quality Audio Profile @ Level 4',
|
1774 |
+
0x12 => 'High Quality Audio Profile @ Level 5',
|
1775 |
+
0x13 => 'High Quality Audio Profile @ Level 6',
|
1776 |
+
0x14 => 'High Quality Audio Profile @ Level 7',
|
1777 |
+
0x15 => 'High Quality Audio Profile @ Level 8',
|
1778 |
+
0x16 => 'Low Delay Audio Profile @ Level 1',
|
1779 |
+
0x17 => 'Low Delay Audio Profile @ Level 2',
|
1780 |
+
0x18 => 'Low Delay Audio Profile @ Level 3',
|
1781 |
+
0x19 => 'Low Delay Audio Profile @ Level 4',
|
1782 |
+
0x1A => 'Low Delay Audio Profile @ Level 5',
|
1783 |
+
0x1B => 'Low Delay Audio Profile @ Level 6',
|
1784 |
+
0x1C => 'Low Delay Audio Profile @ Level 7',
|
1785 |
+
0x1D => 'Low Delay Audio Profile @ Level 8',
|
1786 |
+
0x1E => 'Natural Audio Profile @ Level 1',
|
1787 |
+
0x1F => 'Natural Audio Profile @ Level 2',
|
1788 |
+
0x20 => 'Natural Audio Profile @ Level 3',
|
1789 |
+
0x21 => 'Natural Audio Profile @ Level 4',
|
1790 |
+
0x22 => 'Mobile Audio Internetworking Profile @ Level 1',
|
1791 |
+
0x23 => 'Mobile Audio Internetworking Profile @ Level 2',
|
1792 |
+
0x24 => 'Mobile Audio Internetworking Profile @ Level 3',
|
1793 |
+
0x25 => 'Mobile Audio Internetworking Profile @ Level 4',
|
1794 |
+
0x26 => 'Mobile Audio Internetworking Profile @ Level 5',
|
1795 |
+
0x27 => 'Mobile Audio Internetworking Profile @ Level 6',
|
1796 |
+
0x28 => 'AAC Profile @ Level 1',
|
1797 |
+
0x29 => 'AAC Profile @ Level 2',
|
1798 |
+
0x2A => 'AAC Profile @ Level 4',
|
1799 |
+
0x2B => 'AAC Profile @ Level 5',
|
1800 |
+
0x2C => 'High Efficiency AAC Profile @ Level 2',
|
1801 |
+
0x2D => 'High Efficiency AAC Profile @ Level 3',
|
1802 |
+
0x2E => 'High Efficiency AAC Profile @ Level 4',
|
1803 |
+
0x2F => 'High Efficiency AAC Profile @ Level 5',
|
1804 |
+
0xFE => 'Not part of MPEG-4 audio profiles',
|
1805 |
+
0xFF => 'No audio capability required',
|
1806 |
+
);
|
1807 |
+
}
|
1808 |
+
return (isset($QuicktimeIODSaudioProfileNameLookup[$audio_profile_id]) ? $QuicktimeIODSaudioProfileNameLookup[$audio_profile_id] : 'ISO Reserved / User Private');
|
1809 |
+
}
|
1810 |
+
|
1811 |
+
|
1812 |
+
public function QuicktimeIODSvideoProfileName($video_profile_id) {
|
1813 |
+
static $QuicktimeIODSvideoProfileNameLookup = array();
|
1814 |
+
if (empty($QuicktimeIODSvideoProfileNameLookup)) {
|
1815 |
+
$QuicktimeIODSvideoProfileNameLookup = array(
|
1816 |
+
0x00 => 'Reserved (0x00) Profile',
|
1817 |
+
0x01 => 'Simple Profile @ Level 1',
|
1818 |
+
0x02 => 'Simple Profile @ Level 2',
|
1819 |
+
0x03 => 'Simple Profile @ Level 3',
|
1820 |
+
0x08 => 'Simple Profile @ Level 0',
|
1821 |
+
0x10 => 'Simple Scalable Profile @ Level 0',
|
1822 |
+
0x11 => 'Simple Scalable Profile @ Level 1',
|
1823 |
+
0x12 => 'Simple Scalable Profile @ Level 2',
|
1824 |
+
0x15 => 'AVC/H264 Profile',
|
1825 |
+
0x21 => 'Core Profile @ Level 1',
|
1826 |
+
0x22 => 'Core Profile @ Level 2',
|
1827 |
+
0x32 => 'Main Profile @ Level 2',
|
1828 |
+
0x33 => 'Main Profile @ Level 3',
|
1829 |
+
0x34 => 'Main Profile @ Level 4',
|
1830 |
+
0x42 => 'N-bit Profile @ Level 2',
|
1831 |
+
0x51 => 'Scalable Texture Profile @ Level 1',
|
1832 |
+
0x61 => 'Simple Face Animation Profile @ Level 1',
|
1833 |
+
0x62 => 'Simple Face Animation Profile @ Level 2',
|
1834 |
+
0x63 => 'Simple FBA Profile @ Level 1',
|
1835 |
+
0x64 => 'Simple FBA Profile @ Level 2',
|
1836 |
+
0x71 => 'Basic Animated Texture Profile @ Level 1',
|
1837 |
+
0x72 => 'Basic Animated Texture Profile @ Level 2',
|
1838 |
+
0x81 => 'Hybrid Profile @ Level 1',
|
1839 |
+
0x82 => 'Hybrid Profile @ Level 2',
|
1840 |
+
0x91 => 'Advanced Real Time Simple Profile @ Level 1',
|
1841 |
+
0x92 => 'Advanced Real Time Simple Profile @ Level 2',
|
1842 |
+
0x93 => 'Advanced Real Time Simple Profile @ Level 3',
|
1843 |
+
0x94 => 'Advanced Real Time Simple Profile @ Level 4',
|
1844 |
+
0xA1 => 'Core Scalable Profile @ Level1',
|
1845 |
+
0xA2 => 'Core Scalable Profile @ Level2',
|
1846 |
+
0xA3 => 'Core Scalable Profile @ Level3',
|
1847 |
+
0xB1 => 'Advanced Coding Efficiency Profile @ Level 1',
|
1848 |
+
0xB2 => 'Advanced Coding Efficiency Profile @ Level 2',
|
1849 |
+
0xB3 => 'Advanced Coding Efficiency Profile @ Level 3',
|
1850 |
+
0xB4 => 'Advanced Coding Efficiency Profile @ Level 4',
|
1851 |
+
0xC1 => 'Advanced Core Profile @ Level 1',
|
1852 |
+
0xC2 => 'Advanced Core Profile @ Level 2',
|
1853 |
+
0xD1 => 'Advanced Scalable Texture @ Level1',
|
1854 |
+
0xD2 => 'Advanced Scalable Texture @ Level2',
|
1855 |
+
0xE1 => 'Simple Studio Profile @ Level 1',
|
1856 |
+
0xE2 => 'Simple Studio Profile @ Level 2',
|
1857 |
+
0xE3 => 'Simple Studio Profile @ Level 3',
|
1858 |
+
0xE4 => 'Simple Studio Profile @ Level 4',
|
1859 |
+
0xE5 => 'Core Studio Profile @ Level 1',
|
1860 |
+
0xE6 => 'Core Studio Profile @ Level 2',
|
1861 |
+
0xE7 => 'Core Studio Profile @ Level 3',
|
1862 |
+
0xE8 => 'Core Studio Profile @ Level 4',
|
1863 |
+
0xF0 => 'Advanced Simple Profile @ Level 0',
|
1864 |
+
0xF1 => 'Advanced Simple Profile @ Level 1',
|
1865 |
+
0xF2 => 'Advanced Simple Profile @ Level 2',
|
1866 |
+
0xF3 => 'Advanced Simple Profile @ Level 3',
|
1867 |
+
0xF4 => 'Advanced Simple Profile @ Level 4',
|
1868 |
+
0xF5 => 'Advanced Simple Profile @ Level 5',
|
1869 |
+
0xF7 => 'Advanced Simple Profile @ Level 3b',
|
1870 |
+
0xF8 => 'Fine Granularity Scalable Profile @ Level 0',
|
1871 |
+
0xF9 => 'Fine Granularity Scalable Profile @ Level 1',
|
1872 |
+
0xFA => 'Fine Granularity Scalable Profile @ Level 2',
|
1873 |
+
0xFB => 'Fine Granularity Scalable Profile @ Level 3',
|
1874 |
+
0xFC => 'Fine Granularity Scalable Profile @ Level 4',
|
1875 |
+
0xFD => 'Fine Granularity Scalable Profile @ Level 5',
|
1876 |
+
0xFE => 'Not part of MPEG-4 Visual profiles',
|
1877 |
+
0xFF => 'No visual capability required',
|
1878 |
+
);
|
1879 |
+
}
|
1880 |
+
return (isset($QuicktimeIODSvideoProfileNameLookup[$video_profile_id]) ? $QuicktimeIODSvideoProfileNameLookup[$video_profile_id] : 'ISO Reserved Profile');
|
1881 |
+
}
|
1882 |
+
|
1883 |
+
|
1884 |
+
public function QuicktimeContentRatingLookup($rtng) {
|
1885 |
+
static $QuicktimeContentRatingLookup = array();
|
1886 |
+
if (empty($QuicktimeContentRatingLookup)) {
|
1887 |
+
$QuicktimeContentRatingLookup[0] = 'None';
|
1888 |
+
$QuicktimeContentRatingLookup[2] = 'Clean';
|
1889 |
+
$QuicktimeContentRatingLookup[4] = 'Explicit';
|
1890 |
+
}
|
1891 |
+
return (isset($QuicktimeContentRatingLookup[$rtng]) ? $QuicktimeContentRatingLookup[$rtng] : 'invalid');
|
1892 |
+
}
|
1893 |
+
|
1894 |
+
public function QuicktimeStoreAccountTypeLookup($akid) {
|
1895 |
+
static $QuicktimeStoreAccountTypeLookup = array();
|
1896 |
+
if (empty($QuicktimeStoreAccountTypeLookup)) {
|
1897 |
+
$QuicktimeStoreAccountTypeLookup[0] = 'iTunes';
|
1898 |
+
$QuicktimeStoreAccountTypeLookup[1] = 'AOL';
|
1899 |
+
}
|
1900 |
+
return (isset($QuicktimeStoreAccountTypeLookup[$akid]) ? $QuicktimeStoreAccountTypeLookup[$akid] : 'invalid');
|
1901 |
+
}
|
1902 |
+
|
1903 |
+
public function QuicktimeStoreFrontCodeLookup($sfid) {
|
1904 |
+
static $QuicktimeStoreFrontCodeLookup = array();
|
1905 |
+
if (empty($QuicktimeStoreFrontCodeLookup)) {
|
1906 |
+
$QuicktimeStoreFrontCodeLookup[143460] = 'Australia';
|
1907 |
+
$QuicktimeStoreFrontCodeLookup[143445] = 'Austria';
|
1908 |
+
$QuicktimeStoreFrontCodeLookup[143446] = 'Belgium';
|
1909 |
+
$QuicktimeStoreFrontCodeLookup[143455] = 'Canada';
|
1910 |
+
$QuicktimeStoreFrontCodeLookup[143458] = 'Denmark';
|
1911 |
+
$QuicktimeStoreFrontCodeLookup[143447] = 'Finland';
|
1912 |
+
$QuicktimeStoreFrontCodeLookup[143442] = 'France';
|
1913 |
+
$QuicktimeStoreFrontCodeLookup[143443] = 'Germany';
|
1914 |
+
$QuicktimeStoreFrontCodeLookup[143448] = 'Greece';
|
1915 |
+
$QuicktimeStoreFrontCodeLookup[143449] = 'Ireland';
|
1916 |
+
$QuicktimeStoreFrontCodeLookup[143450] = 'Italy';
|
1917 |
+
$QuicktimeStoreFrontCodeLookup[143462] = 'Japan';
|
1918 |
+
$QuicktimeStoreFrontCodeLookup[143451] = 'Luxembourg';
|
1919 |
+
$QuicktimeStoreFrontCodeLookup[143452] = 'Netherlands';
|
1920 |
+
$QuicktimeStoreFrontCodeLookup[143461] = 'New Zealand';
|
1921 |
+
$QuicktimeStoreFrontCodeLookup[143457] = 'Norway';
|
1922 |
+
$QuicktimeStoreFrontCodeLookup[143453] = 'Portugal';
|
1923 |
+
$QuicktimeStoreFrontCodeLookup[143454] = 'Spain';
|
1924 |
+
$QuicktimeStoreFrontCodeLookup[143456] = 'Sweden';
|
1925 |
+
$QuicktimeStoreFrontCodeLookup[143459] = 'Switzerland';
|
1926 |
+
$QuicktimeStoreFrontCodeLookup[143444] = 'United Kingdom';
|
1927 |
+
$QuicktimeStoreFrontCodeLookup[143441] = 'United States';
|
1928 |
+
}
|
1929 |
+
return (isset($QuicktimeStoreFrontCodeLookup[$sfid]) ? $QuicktimeStoreFrontCodeLookup[$sfid] : 'invalid');
|
1930 |
+
}
|
1931 |
+
|
1932 |
+
public function QuicktimeParseNikonNCTG($atom_data) {
|
1933 |
+
// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
|
1934 |
+
// Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
|
1935 |
+
// Data is stored as records of:
|
1936 |
+
// * 4 bytes record type
|
1937 |
+
// * 2 bytes size of data field type:
|
1938 |
+
// 0x0001 = flag (size field *= 1-byte)
|
1939 |
+
// 0x0002 = char (size field *= 1-byte)
|
1940 |
+
// 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB
|
1941 |
+
// 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD
|
1942 |
+
// 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together
|
1943 |
+
// 0x0007 = bytes (size field *= 1-byte), values are stored as ??????
|
1944 |
+
// 0x0008 = ????? (size field *= 2-byte), values are stored as ??????
|
1945 |
+
// * 2 bytes data size field
|
1946 |
+
// * ? bytes data (string data may be null-padded; datestamp fields are in the format "2011:05:25 20:24:15")
|
1947 |
+
// all integers are stored BigEndian
|
1948 |
+
|
1949 |
+
$NCTGtagName = array(
|
1950 |
+
0x00000001 => 'Make',
|
1951 |
+
0x00000002 => 'Model',
|
1952 |
+
0x00000003 => 'Software',
|
1953 |
+
0x00000011 => 'CreateDate',
|
1954 |
+
0x00000012 => 'DateTimeOriginal',
|
1955 |
+
0x00000013 => 'FrameCount',
|
1956 |
+
0x00000016 => 'FrameRate',
|
1957 |
+
0x00000022 => 'FrameWidth',
|
1958 |
+
0x00000023 => 'FrameHeight',
|
1959 |
+
0x00000032 => 'AudioChannels',
|
1960 |
+
0x00000033 => 'AudioBitsPerSample',
|
1961 |
+
0x00000034 => 'AudioSampleRate',
|
1962 |
+
0x02000001 => 'MakerNoteVersion',
|
1963 |
+
0x02000005 => 'WhiteBalance',
|
1964 |
+
0x0200000b => 'WhiteBalanceFineTune',
|
1965 |
+
0x0200001e => 'ColorSpace',
|
1966 |
+
0x02000023 => 'PictureControlData',
|
1967 |
+
0x02000024 => 'WorldTime',
|
1968 |
+
0x02000032 => 'UnknownInfo',
|
1969 |
+
0x02000083 => 'LensType',
|
1970 |
+
0x02000084 => 'Lens',
|
1971 |
+
);
|
1972 |
+
|
1973 |
+
$offset = 0;
|
1974 |
+
$datalength = strlen($atom_data);
|
1975 |
+
$parsed = array();
|
1976 |
+
while ($offset < $datalength) {
|
1977 |
+
//echo getid3_lib::PrintHexBytes(substr($atom_data, $offset, 4)).'<br>';
|
1978 |
+
$record_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4)); $offset += 4;
|
1979 |
+
$data_size_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2;
|
1980 |
+
$data_size = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2;
|
1981 |
+
switch ($data_size_type) {
|
1982 |
+
case 0x0001: // 0x0001 = flag (size field *= 1-byte)
|
1983 |
+
$data = getid3_lib::BigEndian2Int(substr($atom_data, $offset, $data_size * 1));
|
1984 |
+
$offset += ($data_size * 1);
|
1985 |
+
break;
|
1986 |
+
case 0x0002: // 0x0002 = char (size field *= 1-byte)
|
1987 |
+
$data = substr($atom_data, $offset, $data_size * 1);
|
1988 |
+
$offset += ($data_size * 1);
|
1989 |
+
$data = rtrim($data, "\x00");
|
1990 |
+
break;
|
1991 |
+
case 0x0003: // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB
|
1992 |
+
$data = '';
|
1993 |
+
for ($i = $data_size - 1; $i >= 0; $i--) {
|
1994 |
+
$data .= substr($atom_data, $offset + ($i * 2), 2);
|
1995 |
+
}
|
1996 |
+
$data = getid3_lib::BigEndian2Int($data);
|
1997 |
+
$offset += ($data_size * 2);
|
1998 |
+
break;
|
1999 |
+
case 0x0004: // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD
|
2000 |
+
$data = '';
|
2001 |
+
for ($i = $data_size - 1; $i >= 0; $i--) {
|
2002 |
+
$data .= substr($atom_data, $offset + ($i * 4), 4);
|
2003 |
+
}
|
2004 |
+
$data = getid3_lib::BigEndian2Int($data);
|
2005 |
+
$offset += ($data_size * 4);
|
2006 |
+
break;
|
2007 |
+
case 0x0005: // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together
|
2008 |
+
$data = array();
|
2009 |
+
for ($i = 0; $i < $data_size; $i++) {
|
2010 |
+
$numerator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 0, 4));
|
2011 |
+
$denomninator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 4, 4));
|
2012 |
+
if ($denomninator == 0) {
|
2013 |
+
$data[$i] = false;
|
2014 |
+
} else {
|
2015 |
+
$data[$i] = (double) $numerator / $denomninator;
|
2016 |
+
}
|
2017 |
+
}
|
2018 |
+
$offset += (8 * $data_size);
|
2019 |
+
if (count($data) == 1) {
|
2020 |
+
$data = $data[0];
|
2021 |
+
}
|
2022 |
+
break;
|
2023 |
+
case 0x0007: // 0x0007 = bytes (size field *= 1-byte), values are stored as ??????
|
2024 |
+
$data = substr($atom_data, $offset, $data_size * 1);
|
2025 |
+
$offset += ($data_size * 1);
|
2026 |
+
break;
|
2027 |
+
case 0x0008: // 0x0008 = ????? (size field *= 2-byte), values are stored as ??????
|
2028 |
+
$data = substr($atom_data, $offset, $data_size * 2);
|
2029 |
+
$offset += ($data_size * 2);
|
2030 |
+
break;
|
2031 |
+
default:
|
2032 |
+
echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br>';
|
2033 |
+
break 2;
|
2034 |
+
}
|
2035 |
+
|
2036 |
+
switch ($record_type) {
|
2037 |
+
case 0x00000011: // CreateDate
|
2038 |
+
case 0x00000012: // DateTimeOriginal
|
2039 |
+
$data = strtotime($data);
|
2040 |
+
break;
|
2041 |
+
case 0x0200001e: // ColorSpace
|
2042 |
+
switch ($data) {
|
2043 |
+
case 1:
|
2044 |
+
$data = 'sRGB';
|
2045 |
+
break;
|
2046 |
+
case 2:
|
2047 |
+
$data = 'Adobe RGB';
|
2048 |
+
break;
|
2049 |
+
}
|
2050 |
+
break;
|
2051 |
+
case 0x02000023: // PictureControlData
|
2052 |
+
$PictureControlAdjust = array(0=>'default', 1=>'quick', 2=>'full');
|
2053 |
+
$FilterEffect = array(0x80=>'off', 0x81=>'yellow', 0x82=>'orange', 0x83=>'red', 0x84=>'green', 0xff=>'n/a');
|
2054 |
+
$ToningEffect = array(0x80=>'b&w', 0x81=>'sepia', 0x82=>'cyanotype', 0x83=>'red', 0x84=>'yellow', 0x85=>'green', 0x86=>'blue-green', 0x87=>'blue', 0x88=>'purple-blue', 0x89=>'red-purple', 0xff=>'n/a');
|
2055 |
+
$data = array(
|
2056 |
+
'PictureControlVersion' => substr($data, 0, 4),
|
2057 |
+
'PictureControlName' => rtrim(substr($data, 4, 20), "\x00"),
|
2058 |
+
'PictureControlBase' => rtrim(substr($data, 24, 20), "\x00"),
|
2059 |
+
//'?' => substr($data, 44, 4),
|
2060 |
+
'PictureControlAdjust' => $PictureControlAdjust[ord(substr($data, 48, 1))],
|
2061 |
+
'PictureControlQuickAdjust' => ord(substr($data, 49, 1)),
|
2062 |
+
'Sharpness' => ord(substr($data, 50, 1)),
|
2063 |
+
'Contrast' => ord(substr($data, 51, 1)),
|
2064 |
+
'Brightness' => ord(substr($data, 52, 1)),
|
2065 |
+
'Saturation' => ord(substr($data, 53, 1)),
|
2066 |
+
'HueAdjustment' => ord(substr($data, 54, 1)),
|
2067 |
+
'FilterEffect' => $FilterEffect[ord(substr($data, 55, 1))],
|
2068 |
+
'ToningEffect' => $ToningEffect[ord(substr($data, 56, 1))],
|
2069 |
+
'ToningSaturation' => ord(substr($data, 57, 1)),
|
2070 |
+
);
|
2071 |
+
break;
|
2072 |
+
case 0x02000024: // WorldTime
|
2073 |
+
// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#WorldTime
|
2074 |
+
// timezone is stored as offset from GMT in minutes
|
2075 |
+
$timezone = getid3_lib::BigEndian2Int(substr($data, 0, 2));
|
2076 |
+
if ($timezone & 0x8000) {
|
2077 |
+
$timezone = 0 - (0x10000 - $timezone);
|
2078 |
+
}
|
2079 |
+
$timezone /= 60;
|
2080 |
+
|
2081 |
+
$dst = (bool) getid3_lib::BigEndian2Int(substr($data, 2, 1));
|
2082 |
+
switch (getid3_lib::BigEndian2Int(substr($data, 3, 1))) {
|
2083 |
+
case 2:
|
2084 |
+
$datedisplayformat = 'D/M/Y'; break;
|
2085 |
+
case 1:
|
2086 |
+
$datedisplayformat = 'M/D/Y'; break;
|
2087 |
+
case 0:
|
2088 |
+
default:
|
2089 |
+
$datedisplayformat = 'Y/M/D'; break;
|
2090 |
+
}
|
2091 |
+
|
2092 |
+
$data = array('timezone'=>floatval($timezone), 'dst'=>$dst, 'display'=>$datedisplayformat);
|
2093 |
+
break;
|
2094 |
+
case 0x02000083: // LensType
|
2095 |
+
$data = array(
|
2096 |
+
//'_' => $data,
|
2097 |
+
'mf' => (bool) ($data & 0x01),
|
2098 |
+
'd' => (bool) ($data & 0x02),
|
2099 |
+
'g' => (bool) ($data & 0x04),
|
2100 |
+
'vr' => (bool) ($data & 0x08),
|
2101 |
+
);
|
2102 |
+
break;
|
2103 |
+
}
|
2104 |
+
$tag_name = (isset($NCTGtagName[$record_type]) ? $NCTGtagName[$record_type] : '0x'.str_pad(dechex($record_type), 8, '0', STR_PAD_LEFT));
|
2105 |
+
$parsed[$tag_name] = $data;
|
2106 |
+
}
|
2107 |
+
return $parsed;
|
2108 |
+
}
|
2109 |
+
|
2110 |
+
|
2111 |
+
public function CopyToAppropriateCommentsSection($keyname, $data, $boxname='') {
|
2112 |
+
static $handyatomtranslatorarray = array();
|
2113 |
+
if (empty($handyatomtranslatorarray)) {
|
2114 |
+
$handyatomtranslatorarray["\xA9".'cpy'] = 'copyright';
|
2115 |
+
$handyatomtranslatorarray["\xA9".'day'] = 'creation_date'; // iTunes 4.0
|
2116 |
+
$handyatomtranslatorarray["\xA9".'dir'] = 'director';
|
2117 |
+
$handyatomtranslatorarray["\xA9".'ed1'] = 'edit1';
|
2118 |
+
$handyatomtranslatorarray["\xA9".'ed2'] = 'edit2';
|
2119 |
+
$handyatomtranslatorarray["\xA9".'ed3'] = 'edit3';
|
2120 |
+
$handyatomtranslatorarray["\xA9".'ed4'] = 'edit4';
|
2121 |
+
$handyatomtranslatorarray["\xA9".'ed5'] = 'edit5';
|
2122 |
+
$handyatomtranslatorarray["\xA9".'ed6'] = 'edit6';
|
2123 |
+
$handyatomtranslatorarray["\xA9".'ed7'] = 'edit7';
|
2124 |
+
$handyatomtranslatorarray["\xA9".'ed8'] = 'edit8';
|
2125 |
+
$handyatomtranslatorarray["\xA9".'ed9'] = 'edit9';
|
2126 |
+
$handyatomtranslatorarray["\xA9".'fmt'] = 'format';
|
2127 |
+
$handyatomtranslatorarray["\xA9".'inf'] = 'information';
|
2128 |
+
$handyatomtranslatorarray["\xA9".'prd'] = 'producer';
|
2129 |
+
$handyatomtranslatorarray["\xA9".'prf'] = 'performers';
|
2130 |
+
$handyatomtranslatorarray["\xA9".'req'] = 'system_requirements';
|
2131 |
+
$handyatomtranslatorarray["\xA9".'src'] = 'source_credit';
|
2132 |
+
$handyatomtranslatorarray["\xA9".'wrt'] = 'writer';
|
2133 |
+
|
2134 |
+
// http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt
|
2135 |
+
$handyatomtranslatorarray["\xA9".'nam'] = 'title'; // iTunes 4.0
|
2136 |
+
$handyatomtranslatorarray["\xA9".'cmt'] = 'comment'; // iTunes 4.0
|
2137 |
+
$handyatomtranslatorarray["\xA9".'wrn'] = 'warning';
|
2138 |
+
$handyatomtranslatorarray["\xA9".'hst'] = 'host_computer';
|
2139 |
+
$handyatomtranslatorarray["\xA9".'mak'] = 'make';
|
2140 |
+
$handyatomtranslatorarray["\xA9".'mod'] = 'model';
|
2141 |
+
$handyatomtranslatorarray["\xA9".'PRD'] = 'product';
|
2142 |
+
$handyatomtranslatorarray["\xA9".'swr'] = 'software';
|
2143 |
+
$handyatomtranslatorarray["\xA9".'aut'] = 'author';
|
2144 |
+
$handyatomtranslatorarray["\xA9".'ART'] = 'artist';
|
2145 |
+
$handyatomtranslatorarray["\xA9".'trk'] = 'track';
|
2146 |
+
$handyatomtranslatorarray["\xA9".'alb'] = 'album'; // iTunes 4.0
|
2147 |
+
$handyatomtranslatorarray["\xA9".'com'] = 'comment';
|
2148 |
+
$handyatomtranslatorarray["\xA9".'gen'] = 'genre'; // iTunes 4.0
|
2149 |
+
$handyatomtranslatorarray["\xA9".'ope'] = 'composer';
|
2150 |
+
$handyatomtranslatorarray["\xA9".'url'] = 'url';
|
2151 |
+
$handyatomtranslatorarray["\xA9".'enc'] = 'encoder';
|
2152 |
+
|
2153 |
+
// http://atomicparsley.sourceforge.net/mpeg-4files.html
|
2154 |
+
$handyatomtranslatorarray["\xA9".'art'] = 'artist'; // iTunes 4.0
|
2155 |
+
$handyatomtranslatorarray['aART'] = 'album_artist';
|
2156 |
+
$handyatomtranslatorarray['trkn'] = 'track_number'; // iTunes 4.0
|
2157 |
+
$handyatomtranslatorarray['disk'] = 'disc_number'; // iTunes 4.0
|
2158 |
+
$handyatomtranslatorarray['gnre'] = 'genre'; // iTunes 4.0
|
2159 |
+
$handyatomtranslatorarray["\xA9".'too'] = 'encoder'; // iTunes 4.0
|
2160 |
+
$handyatomtranslatorarray['tmpo'] = 'bpm'; // iTunes 4.0
|
2161 |
+
$handyatomtranslatorarray['cprt'] = 'copyright'; // iTunes 4.0?
|
2162 |
+
$handyatomtranslatorarray['cpil'] = 'compilation'; // iTunes 4.0
|
2163 |
+
$handyatomtranslatorarray['covr'] = 'picture'; // iTunes 4.0
|
2164 |
+
$handyatomtranslatorarray['rtng'] = 'rating'; // iTunes 4.0
|
2165 |
+
$handyatomtranslatorarray["\xA9".'grp'] = 'grouping'; // iTunes 4.2
|
2166 |
+
$handyatomtranslatorarray['stik'] = 'stik'; // iTunes 4.9
|
2167 |
+
$handyatomtranslatorarray['pcst'] = 'podcast'; // iTunes 4.9
|
2168 |
+
$handyatomtranslatorarray['catg'] = 'category'; // iTunes 4.9
|
2169 |
+
$handyatomtranslatorarray['keyw'] = 'keyword'; // iTunes 4.9
|
2170 |
+
$handyatomtranslatorarray['purl'] = 'podcast_url'; // iTunes 4.9
|
2171 |
+
$handyatomtranslatorarray['egid'] = 'episode_guid'; // iTunes 4.9
|
2172 |
+
$handyatomtranslatorarray['desc'] = 'description'; // iTunes 5.0
|
2173 |
+
$handyatomtranslatorarray["\xA9".'lyr'] = 'lyrics'; // iTunes 5.0
|
2174 |
+
$handyatomtranslatorarray['tvnn'] = 'tv_network_name'; // iTunes 6.0
|
2175 |
+
$handyatomtranslatorarray['tvsh'] = 'tv_show_name'; // iTunes 6.0
|
2176 |
+
$handyatomtranslatorarray['tvsn'] = 'tv_season'; // iTunes 6.0
|
2177 |
+
$handyatomtranslatorarray['tves'] = 'tv_episode'; // iTunes 6.0
|
2178 |
+
$handyatomtranslatorarray['purd'] = 'purchase_date'; // iTunes 6.0.2
|
2179 |
+
$handyatomtranslatorarray['pgap'] = 'gapless_playback'; // iTunes 7.0
|
2180 |
+
|
2181 |
+
// http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt
|
2182 |
+
|
2183 |
+
|
2184 |
+
|
2185 |
+
// boxnames:
|
2186 |
+
/*
|
2187 |
+
$handyatomtranslatorarray['iTunSMPB'] = 'iTunSMPB';
|
2188 |
+
$handyatomtranslatorarray['iTunNORM'] = 'iTunNORM';
|
2189 |
+
$handyatomtranslatorarray['Encoding Params'] = 'Encoding Params';
|
2190 |
+
$handyatomtranslatorarray['replaygain_track_gain'] = 'replaygain_track_gain';
|
2191 |
+
$handyatomtranslatorarray['replaygain_track_peak'] = 'replaygain_track_peak';
|
2192 |
+
$handyatomtranslatorarray['replaygain_track_minmax'] = 'replaygain_track_minmax';
|
2193 |
+
$handyatomtranslatorarray['MusicIP PUID'] = 'MusicIP PUID';
|
2194 |
+
$handyatomtranslatorarray['MusicBrainz Artist Id'] = 'MusicBrainz Artist Id';
|
2195 |
+
$handyatomtranslatorarray['MusicBrainz Album Id'] = 'MusicBrainz Album Id';
|
2196 |
+
$handyatomtranslatorarray['MusicBrainz Album Artist Id'] = 'MusicBrainz Album Artist Id';
|
2197 |
+
$handyatomtranslatorarray['MusicBrainz Track Id'] = 'MusicBrainz Track Id';
|
2198 |
+
$handyatomtranslatorarray['MusicBrainz Disc Id'] = 'MusicBrainz Disc Id';
|
2199 |
+
|
2200 |
+
// http://age.hobba.nl/audio/tag_frame_reference.html
|
2201 |
+
$handyatomtranslatorarray['PLAY_COUNTER'] = 'play_counter'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355
|
2202 |
+
$handyatomtranslatorarray['MEDIATYPE'] = 'mediatype'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355
|
2203 |
+
*/
|
2204 |
+
}
|
2205 |
+
$info = &$this->getid3->info;
|
2206 |
+
$comment_key = '';
|
2207 |
+
if ($boxname && ($boxname != $keyname)) {
|
2208 |
+
$comment_key = (isset($handyatomtranslatorarray[$boxname]) ? $handyatomtranslatorarray[$boxname] : $boxname);
|
2209 |
+
} elseif (isset($handyatomtranslatorarray[$keyname])) {
|
2210 |
+
$comment_key = $handyatomtranslatorarray[$keyname];
|
2211 |
+
}
|
2212 |
+
if ($comment_key) {
|
2213 |
+
if ($comment_key == 'picture') {
|
2214 |
+
if (!is_array($data)) {
|
2215 |
+
$image_mime = '';
|
2216 |
+
if (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $data)) {
|
2217 |
+
$image_mime = 'image/png';
|
2218 |
+
} elseif (preg_match('#^\xFF\xD8\xFF#', $data)) {
|
2219 |
+
$image_mime = 'image/jpeg';
|
2220 |
+
} elseif (preg_match('#^GIF#', $data)) {
|
2221 |
+
$image_mime = 'image/gif';
|
2222 |
+
} elseif (preg_match('#^BM#', $data)) {
|
2223 |
+
$image_mime = 'image/bmp';
|
2224 |
+
}
|
2225 |
+
$data = array('data'=>$data, 'image_mime'=>$image_mime);
|
2226 |
+
}
|
2227 |
+
}
|
2228 |
+
$info['quicktime']['comments'][$comment_key][] = $data;
|
2229 |
+
}
|
2230 |
+
return true;
|
2231 |
+
}
|
2232 |
+
|
2233 |
+
public function NoNullString($nullterminatedstring) {
|
2234 |
+
// remove the single null terminator on null terminated strings
|
2235 |
+
if (substr($nullterminatedstring, strlen($nullterminatedstring) - 1, 1) === "\x00") {
|
2236 |
+
return substr($nullterminatedstring, 0, strlen($nullterminatedstring) - 1);
|
2237 |
+
}
|
2238 |
+
return $nullterminatedstring;
|
2239 |
+
}
|
2240 |
+
|
2241 |
+
public function Pascal2String($pascalstring) {
|
2242 |
+
// Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string
|
2243 |
+
return substr($pascalstring, 1);
|
2244 |
+
}
|
2245 |
+
|
2246 |
+
}
|
getid3/module.audio-video.riff.php
CHANGED
@@ -1,2409 +1,2586 @@
|
|
1 |
-
<?php
|
2 |
-
/////////////////////////////////////////////////////////////////
|
3 |
-
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
-
// available at http://getid3.sourceforge.net //
|
5 |
-
// or http://www.getid3.org //
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
//
|
11 |
-
// module
|
12 |
-
//
|
13 |
-
//
|
14 |
-
//
|
15 |
-
//
|
16 |
-
// module.audio.
|
17 |
-
//
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
$
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
$
|
40 |
-
|
41 |
-
|
42 |
-
$
|
43 |
-
$
|
44 |
-
|
45 |
-
|
46 |
-
$
|
47 |
-
$
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
$
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
$
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
$thisfile_audio['
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
}
|
196 |
-
$
|
197 |
-
$
|
198 |
-
$thisfile_audio['streams'][$streamindex]
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
$
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
$
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
$
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
$
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
$
|
257 |
-
|
258 |
-
$
|
259 |
-
$
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
$
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
$
|
279 |
-
$
|
280 |
-
|
281 |
-
|
282 |
-
if (
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
$
|
296 |
-
$
|
297 |
-
$
|
298 |
-
$
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
$
|
311 |
-
$
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
$
|
317 |
-
|
318 |
-
$
|
319 |
-
$
|
320 |
-
$
|
321 |
-
|
322 |
-
|
323 |
-
$
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
$
|
328 |
-
|
329 |
-
$
|
330 |
-
$
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
$
|
339 |
-
$
|
340 |
-
$
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
$
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
$
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
if (
|
398 |
-
$
|
399 |
-
|
400 |
-
$
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
$
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
$
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
$
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
//
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
$
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
}
|
556 |
-
}
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
$
|
595 |
-
$
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
}
|
603 |
-
}
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
$
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
$
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
//
|
638 |
-
$
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
$
|
643 |
-
$
|
644 |
-
|
645 |
-
|
646 |
-
$
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
$
|
652 |
-
}
|
653 |
-
|
654 |
-
|
655 |
-
$
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
$
|
736 |
-
$
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
$
|
747 |
-
|
748 |
-
$
|
749 |
-
|
750 |
-
|
751 |
-
$
|
752 |
-
$
|
753 |
-
|
754 |
-
|
755 |
-
$
|
756 |
-
|
757 |
-
$
|
758 |
-
$
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
case
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
$
|
800 |
-
break;
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
$
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
$thisfile_audio['
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
$
|
945 |
-
}
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
$
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
$
|
976 |
-
|
977 |
-
$
|
978 |
-
$
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
$
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
if (
|
1211 |
-
|
1212 |
-
}
|
1213 |
-
if (
|
1214 |
-
|
1215 |
-
}
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
'
|
1227 |
-
|
1228 |
-
'
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
'
|
1257 |
-
'
|
1258 |
-
'
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
'
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
$
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
$
|
1520 |
-
|
1521 |
-
}
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
$
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
$
|
1722 |
-
$
|
1723 |
-
$
|
1724 |
-
$
|
1725 |
-
$
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
$
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/////////////////////////////////////////////////////////////////
|
3 |
+
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
+
// available at http://getid3.sourceforge.net //
|
5 |
+
// or http://www.getid3.org //
|
6 |
+
// also https://github.com/JamesHeinrich/getID3 //
|
7 |
+
/////////////////////////////////////////////////////////////////
|
8 |
+
// See readme.txt for more details //
|
9 |
+
/////////////////////////////////////////////////////////////////
|
10 |
+
// //
|
11 |
+
// module.audio-video.riff.php //
|
12 |
+
// module for analyzing RIFF files //
|
13 |
+
// multiple formats supported by this module: //
|
14 |
+
// Wave, AVI, AIFF/AIFC, (MP3,AC3)/RIFF, Wavpack v3, 8SVX //
|
15 |
+
// dependencies: module.audio.mp3.php //
|
16 |
+
// module.audio.ac3.php //
|
17 |
+
// module.audio.dts.php //
|
18 |
+
// ///
|
19 |
+
/////////////////////////////////////////////////////////////////
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @todo Parse AC-3/DTS audio inside WAVE correctly
|
23 |
+
* @todo Rewrite RIFF parser totally
|
24 |
+
*/
|
25 |
+
|
26 |
+
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
|
27 |
+
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, true);
|
28 |
+
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.dts.php', __FILE__, true);
|
29 |
+
|
30 |
+
class getid3_riff extends getid3_handler {
|
31 |
+
|
32 |
+
protected $container = 'riff'; // default
|
33 |
+
|
34 |
+
public function Analyze() {
|
35 |
+
$info = &$this->getid3->info;
|
36 |
+
|
37 |
+
// initialize these values to an empty array, otherwise they default to NULL
|
38 |
+
// and you can't append array values to a NULL value
|
39 |
+
$info['riff'] = array('raw'=>array());
|
40 |
+
|
41 |
+
// Shortcuts
|
42 |
+
$thisfile_riff = &$info['riff'];
|
43 |
+
$thisfile_riff_raw = &$thisfile_riff['raw'];
|
44 |
+
$thisfile_audio = &$info['audio'];
|
45 |
+
$thisfile_video = &$info['video'];
|
46 |
+
$thisfile_audio_dataformat = &$thisfile_audio['dataformat'];
|
47 |
+
$thisfile_riff_audio = &$thisfile_riff['audio'];
|
48 |
+
$thisfile_riff_video = &$thisfile_riff['video'];
|
49 |
+
|
50 |
+
$Original['avdataoffset'] = $info['avdataoffset'];
|
51 |
+
$Original['avdataend'] = $info['avdataend'];
|
52 |
+
|
53 |
+
$this->fseek($info['avdataoffset']);
|
54 |
+
$RIFFheader = $this->fread(12);
|
55 |
+
$offset = $this->ftell();
|
56 |
+
$RIFFtype = substr($RIFFheader, 0, 4);
|
57 |
+
$RIFFsize = substr($RIFFheader, 4, 4);
|
58 |
+
$RIFFsubtype = substr($RIFFheader, 8, 4);
|
59 |
+
|
60 |
+
switch ($RIFFtype) {
|
61 |
+
|
62 |
+
case 'FORM': // AIFF, AIFC
|
63 |
+
//$info['fileformat'] = 'aiff';
|
64 |
+
$this->container = 'aiff';
|
65 |
+
$thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);
|
66 |
+
$thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4));
|
67 |
+
break;
|
68 |
+
|
69 |
+
case 'RIFF': // AVI, WAV, etc
|
70 |
+
case 'SDSS': // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
|
71 |
+
case 'RMP3': // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s
|
72 |
+
//$info['fileformat'] = 'riff';
|
73 |
+
$this->container = 'riff';
|
74 |
+
$thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);
|
75 |
+
if ($RIFFsubtype == 'RMP3') {
|
76 |
+
// RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s
|
77 |
+
$RIFFsubtype = 'WAVE';
|
78 |
+
}
|
79 |
+
if ($RIFFsubtype != 'AMV ') {
|
80 |
+
// AMV files are RIFF-AVI files with parts of the spec deliberately broken, such as chunk size fields hardcoded to zero (because players known in hardware that these fields are always a certain size
|
81 |
+
// Handled separately in ParseRIFFAMV()
|
82 |
+
$thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4));
|
83 |
+
}
|
84 |
+
if (($info['avdataend'] - $info['filesize']) == 1) {
|
85 |
+
// LiteWave appears to incorrectly *not* pad actual output file
|
86 |
+
// to nearest WORD boundary so may appear to be short by one
|
87 |
+
// byte, in which case - skip warning
|
88 |
+
$info['avdataend'] = $info['filesize'];
|
89 |
+
}
|
90 |
+
|
91 |
+
$nextRIFFoffset = $Original['avdataoffset'] + 8 + $thisfile_riff['header_size']; // 8 = "RIFF" + 32-bit offset
|
92 |
+
while ($nextRIFFoffset < min($info['filesize'], $info['avdataend'])) {
|
93 |
+
try {
|
94 |
+
$this->fseek($nextRIFFoffset);
|
95 |
+
} catch (getid3_exception $e) {
|
96 |
+
if ($e->getCode() == 10) {
|
97 |
+
//$this->warning('RIFF parser: '.$e->getMessage());
|
98 |
+
$this->error('AVI extends beyond '.round(PHP_INT_MAX / 1073741824).'GB and PHP filesystem functions cannot read that far, playtime may be wrong');
|
99 |
+
$this->warning('[avdataend] value may be incorrect, multiple AVIX chunks may be present');
|
100 |
+
break;
|
101 |
+
} else {
|
102 |
+
throw $e;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
$nextRIFFheader = $this->fread(12);
|
106 |
+
if ($nextRIFFoffset == ($info['avdataend'] - 1)) {
|
107 |
+
if (substr($nextRIFFheader, 0, 1) == "\x00") {
|
108 |
+
// RIFF padded to WORD boundary, we're actually already at the end
|
109 |
+
break;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
$nextRIFFheaderID = substr($nextRIFFheader, 0, 4);
|
113 |
+
$nextRIFFsize = $this->EitherEndian2Int(substr($nextRIFFheader, 4, 4));
|
114 |
+
$nextRIFFtype = substr($nextRIFFheader, 8, 4);
|
115 |
+
$chunkdata = array();
|
116 |
+
$chunkdata['offset'] = $nextRIFFoffset + 8;
|
117 |
+
$chunkdata['size'] = $nextRIFFsize;
|
118 |
+
$nextRIFFoffset = $chunkdata['offset'] + $chunkdata['size'];
|
119 |
+
|
120 |
+
switch ($nextRIFFheaderID) {
|
121 |
+
case 'RIFF':
|
122 |
+
$chunkdata['chunks'] = $this->ParseRIFF($chunkdata['offset'] + 4, $nextRIFFoffset);
|
123 |
+
if (!isset($thisfile_riff[$nextRIFFtype])) {
|
124 |
+
$thisfile_riff[$nextRIFFtype] = array();
|
125 |
+
}
|
126 |
+
$thisfile_riff[$nextRIFFtype][] = $chunkdata;
|
127 |
+
break;
|
128 |
+
|
129 |
+
case 'AMV ':
|
130 |
+
unset($info['riff']);
|
131 |
+
$info['amv'] = $this->ParseRIFFAMV($chunkdata['offset'] + 4, $nextRIFFoffset);
|
132 |
+
break;
|
133 |
+
|
134 |
+
case 'JUNK':
|
135 |
+
// ignore
|
136 |
+
$thisfile_riff[$nextRIFFheaderID][] = $chunkdata;
|
137 |
+
break;
|
138 |
+
|
139 |
+
case 'IDVX':
|
140 |
+
$info['divxtag']['comments'] = self::ParseDIVXTAG($this->fread($chunkdata['size']));
|
141 |
+
break;
|
142 |
+
|
143 |
+
default:
|
144 |
+
if ($info['filesize'] == ($chunkdata['offset'] - 8 + 128)) {
|
145 |
+
$DIVXTAG = $nextRIFFheader.$this->fread(128 - 12);
|
146 |
+
if (substr($DIVXTAG, -7) == 'DIVXTAG') {
|
147 |
+
// 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
|
148 |
+
$this->warning('Found wrongly-structured DIVXTAG at offset '.($this->ftell() - 128).', parsing anyway');
|
149 |
+
$info['divxtag']['comments'] = self::ParseDIVXTAG($DIVXTAG);
|
150 |
+
break 2;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
$this->warning('Expecting "RIFF|JUNK|IDVX" at '.$nextRIFFoffset.', found "'.$nextRIFFheaderID.'" ('.getid3_lib::PrintHexBytes($nextRIFFheaderID).') - skipping rest of file');
|
154 |
+
break 2;
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
}
|
159 |
+
if ($RIFFsubtype == 'WAVE') {
|
160 |
+
$thisfile_riff_WAVE = &$thisfile_riff['WAVE'];
|
161 |
+
}
|
162 |
+
break;
|
163 |
+
|
164 |
+
default:
|
165 |
+
$this->error('Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "'.$RIFFsubtype.'" instead');
|
166 |
+
//unset($info['fileformat']);
|
167 |
+
return false;
|
168 |
+
}
|
169 |
+
|
170 |
+
$streamindex = 0;
|
171 |
+
switch ($RIFFsubtype) {
|
172 |
+
|
173 |
+
// http://en.wikipedia.org/wiki/Wav
|
174 |
+
case 'WAVE':
|
175 |
+
$info['fileformat'] = 'wav';
|
176 |
+
|
177 |
+
if (empty($thisfile_audio['bitrate_mode'])) {
|
178 |
+
$thisfile_audio['bitrate_mode'] = 'cbr';
|
179 |
+
}
|
180 |
+
if (empty($thisfile_audio_dataformat)) {
|
181 |
+
$thisfile_audio_dataformat = 'wav';
|
182 |
+
}
|
183 |
+
|
184 |
+
if (isset($thisfile_riff_WAVE['data'][0]['offset'])) {
|
185 |
+
$info['avdataoffset'] = $thisfile_riff_WAVE['data'][0]['offset'] + 8;
|
186 |
+
$info['avdataend'] = $info['avdataoffset'] + $thisfile_riff_WAVE['data'][0]['size'];
|
187 |
+
}
|
188 |
+
if (isset($thisfile_riff_WAVE['fmt '][0]['data'])) {
|
189 |
+
|
190 |
+
$thisfile_riff_audio[$streamindex] = self::parseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']);
|
191 |
+
$thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
|
192 |
+
if (!isset($thisfile_riff_audio[$streamindex]['bitrate']) || ($thisfile_riff_audio[$streamindex]['bitrate'] == 0)) {
|
193 |
+
$info['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';
|
194 |
+
return false;
|
195 |
+
}
|
196 |
+
$thisfile_riff_raw['fmt '] = $thisfile_riff_audio[$streamindex]['raw'];
|
197 |
+
unset($thisfile_riff_audio[$streamindex]['raw']);
|
198 |
+
$thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex];
|
199 |
+
|
200 |
+
$thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
|
201 |
+
if (substr($thisfile_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
|
202 |
+
$info['warning'][] = 'Audio codec = '.$thisfile_audio['codec'];
|
203 |
+
}
|
204 |
+
$thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
|
205 |
+
|
206 |
+
if (empty($info['playtime_seconds'])) { // may already be set (e.g. DTS-WAV)
|
207 |
+
$info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $thisfile_audio['bitrate']);
|
208 |
+
}
|
209 |
+
|
210 |
+
$thisfile_audio['lossless'] = false;
|
211 |
+
if (isset($thisfile_riff_WAVE['data'][0]['offset']) && isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
|
212 |
+
switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
|
213 |
+
|
214 |
+
case 0x0001: // PCM
|
215 |
+
$thisfile_audio['lossless'] = true;
|
216 |
+
break;
|
217 |
+
|
218 |
+
case 0x2000: // AC-3
|
219 |
+
$thisfile_audio_dataformat = 'ac3';
|
220 |
+
break;
|
221 |
+
|
222 |
+
default:
|
223 |
+
// do nothing
|
224 |
+
break;
|
225 |
+
|
226 |
+
}
|
227 |
+
}
|
228 |
+
$thisfile_audio['streams'][$streamindex]['wformattag'] = $thisfile_audio['wformattag'];
|
229 |
+
$thisfile_audio['streams'][$streamindex]['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
|
230 |
+
$thisfile_audio['streams'][$streamindex]['lossless'] = $thisfile_audio['lossless'];
|
231 |
+
$thisfile_audio['streams'][$streamindex]['dataformat'] = $thisfile_audio_dataformat;
|
232 |
+
}
|
233 |
+
|
234 |
+
if (isset($thisfile_riff_WAVE['rgad'][0]['data'])) {
|
235 |
+
|
236 |
+
// shortcuts
|
237 |
+
$rgadData = &$thisfile_riff_WAVE['rgad'][0]['data'];
|
238 |
+
$thisfile_riff_raw['rgad'] = array('track'=>array(), 'album'=>array());
|
239 |
+
$thisfile_riff_raw_rgad = &$thisfile_riff_raw['rgad'];
|
240 |
+
$thisfile_riff_raw_rgad_track = &$thisfile_riff_raw_rgad['track'];
|
241 |
+
$thisfile_riff_raw_rgad_album = &$thisfile_riff_raw_rgad['album'];
|
242 |
+
|
243 |
+
$thisfile_riff_raw_rgad['fPeakAmplitude'] = getid3_lib::LittleEndian2Float(substr($rgadData, 0, 4));
|
244 |
+
$thisfile_riff_raw_rgad['nRadioRgAdjust'] = $this->EitherEndian2Int(substr($rgadData, 4, 2));
|
245 |
+
$thisfile_riff_raw_rgad['nAudiophileRgAdjust'] = $this->EitherEndian2Int(substr($rgadData, 6, 2));
|
246 |
+
|
247 |
+
$nRadioRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
|
248 |
+
$nAudiophileRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
|
249 |
+
$thisfile_riff_raw_rgad_track['name'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 0, 3));
|
250 |
+
$thisfile_riff_raw_rgad_track['originator'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 3, 3));
|
251 |
+
$thisfile_riff_raw_rgad_track['signbit'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 6, 1));
|
252 |
+
$thisfile_riff_raw_rgad_track['adjustment'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 7, 9));
|
253 |
+
$thisfile_riff_raw_rgad_album['name'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 0, 3));
|
254 |
+
$thisfile_riff_raw_rgad_album['originator'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 3, 3));
|
255 |
+
$thisfile_riff_raw_rgad_album['signbit'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 6, 1));
|
256 |
+
$thisfile_riff_raw_rgad_album['adjustment'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 7, 9));
|
257 |
+
|
258 |
+
$thisfile_riff['rgad']['peakamplitude'] = $thisfile_riff_raw_rgad['fPeakAmplitude'];
|
259 |
+
if (($thisfile_riff_raw_rgad_track['name'] != 0) && ($thisfile_riff_raw_rgad_track['originator'] != 0)) {
|
260 |
+
$thisfile_riff['rgad']['track']['name'] = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_track['name']);
|
261 |
+
$thisfile_riff['rgad']['track']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_track['originator']);
|
262 |
+
$thisfile_riff['rgad']['track']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_track['adjustment'], $thisfile_riff_raw_rgad_track['signbit']);
|
263 |
+
}
|
264 |
+
if (($thisfile_riff_raw_rgad_album['name'] != 0) && ($thisfile_riff_raw_rgad_album['originator'] != 0)) {
|
265 |
+
$thisfile_riff['rgad']['album']['name'] = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_album['name']);
|
266 |
+
$thisfile_riff['rgad']['album']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_album['originator']);
|
267 |
+
$thisfile_riff['rgad']['album']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_album['adjustment'], $thisfile_riff_raw_rgad_album['signbit']);
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
if (isset($thisfile_riff_WAVE['fact'][0]['data'])) {
|
272 |
+
$thisfile_riff_raw['fact']['NumberOfSamples'] = $this->EitherEndian2Int(substr($thisfile_riff_WAVE['fact'][0]['data'], 0, 4));
|
273 |
+
|
274 |
+
// This should be a good way of calculating exact playtime,
|
275 |
+
// but some sample files have had incorrect number of samples,
|
276 |
+
// so cannot use this method
|
277 |
+
|
278 |
+
// if (!empty($thisfile_riff_raw['fmt ']['nSamplesPerSec'])) {
|
279 |
+
// $info['playtime_seconds'] = (float) $thisfile_riff_raw['fact']['NumberOfSamples'] / $thisfile_riff_raw['fmt ']['nSamplesPerSec'];
|
280 |
+
// }
|
281 |
+
}
|
282 |
+
if (!empty($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'])) {
|
283 |
+
$thisfile_audio['bitrate'] = getid3_lib::CastAsInt($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'] * 8);
|
284 |
+
}
|
285 |
+
|
286 |
+
if (isset($thisfile_riff_WAVE['bext'][0]['data'])) {
|
287 |
+
// shortcut
|
288 |
+
$thisfile_riff_WAVE_bext_0 = &$thisfile_riff_WAVE['bext'][0];
|
289 |
+
|
290 |
+
$thisfile_riff_WAVE_bext_0['title'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 0, 256));
|
291 |
+
$thisfile_riff_WAVE_bext_0['author'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 256, 32));
|
292 |
+
$thisfile_riff_WAVE_bext_0['reference'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 288, 32));
|
293 |
+
$thisfile_riff_WAVE_bext_0['origin_date'] = substr($thisfile_riff_WAVE_bext_0['data'], 320, 10);
|
294 |
+
$thisfile_riff_WAVE_bext_0['origin_time'] = substr($thisfile_riff_WAVE_bext_0['data'], 330, 8);
|
295 |
+
$thisfile_riff_WAVE_bext_0['time_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 338, 8));
|
296 |
+
$thisfile_riff_WAVE_bext_0['bwf_version'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 346, 1));
|
297 |
+
$thisfile_riff_WAVE_bext_0['reserved'] = substr($thisfile_riff_WAVE_bext_0['data'], 347, 254);
|
298 |
+
$thisfile_riff_WAVE_bext_0['coding_history'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601)));
|
299 |
+
if (preg_match('#^([0-9]{4}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_date'], $matches_bext_date)) {
|
300 |
+
if (preg_match('#^([0-9]{2}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_time'], $matches_bext_time)) {
|
301 |
+
list($dummy, $bext_timestamp['year'], $bext_timestamp['month'], $bext_timestamp['day']) = $matches_bext_date;
|
302 |
+
list($dummy, $bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second']) = $matches_bext_time;
|
303 |
+
$thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime($bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second'], $bext_timestamp['month'], $bext_timestamp['day'], $bext_timestamp['year']);
|
304 |
+
} else {
|
305 |
+
$info['warning'][] = 'RIFF.WAVE.BEXT.origin_time is invalid';
|
306 |
+
}
|
307 |
+
} else {
|
308 |
+
$info['warning'][] = 'RIFF.WAVE.BEXT.origin_date is invalid';
|
309 |
+
}
|
310 |
+
$thisfile_riff['comments']['author'][] = $thisfile_riff_WAVE_bext_0['author'];
|
311 |
+
$thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_bext_0['title'];
|
312 |
+
}
|
313 |
+
|
314 |
+
if (isset($thisfile_riff_WAVE['MEXT'][0]['data'])) {
|
315 |
+
// shortcut
|
316 |
+
$thisfile_riff_WAVE_MEXT_0 = &$thisfile_riff_WAVE['MEXT'][0];
|
317 |
+
|
318 |
+
$thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 0, 2));
|
319 |
+
$thisfile_riff_WAVE_MEXT_0['flags']['homogenous'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0001);
|
320 |
+
if ($thisfile_riff_WAVE_MEXT_0['flags']['homogenous']) {
|
321 |
+
$thisfile_riff_WAVE_MEXT_0['flags']['padding'] = ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0002) ? false : true;
|
322 |
+
$thisfile_riff_WAVE_MEXT_0['flags']['22_or_44'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0004);
|
323 |
+
$thisfile_riff_WAVE_MEXT_0['flags']['free_format'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0008);
|
324 |
+
|
325 |
+
$thisfile_riff_WAVE_MEXT_0['nominal_frame_size'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 2, 2));
|
326 |
+
}
|
327 |
+
$thisfile_riff_WAVE_MEXT_0['anciliary_data_length'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 6, 2));
|
328 |
+
$thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 8, 2));
|
329 |
+
$thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_left'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x0001);
|
330 |
+
$thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_free'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x0002);
|
331 |
+
$thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_right'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x0004);
|
332 |
+
}
|
333 |
+
|
334 |
+
if (isset($thisfile_riff_WAVE['cart'][0]['data'])) {
|
335 |
+
// shortcut
|
336 |
+
$thisfile_riff_WAVE_cart_0 = &$thisfile_riff_WAVE['cart'][0];
|
337 |
+
|
338 |
+
$thisfile_riff_WAVE_cart_0['version'] = substr($thisfile_riff_WAVE_cart_0['data'], 0, 4);
|
339 |
+
$thisfile_riff_WAVE_cart_0['title'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 4, 64));
|
340 |
+
$thisfile_riff_WAVE_cart_0['artist'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 68, 64));
|
341 |
+
$thisfile_riff_WAVE_cart_0['cut_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 132, 64));
|
342 |
+
$thisfile_riff_WAVE_cart_0['client_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 196, 64));
|
343 |
+
$thisfile_riff_WAVE_cart_0['category'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 260, 64));
|
344 |
+
$thisfile_riff_WAVE_cart_0['classification'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 324, 64));
|
345 |
+
$thisfile_riff_WAVE_cart_0['out_cue'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 388, 64));
|
346 |
+
$thisfile_riff_WAVE_cart_0['start_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 452, 10));
|
347 |
+
$thisfile_riff_WAVE_cart_0['start_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 462, 8));
|
348 |
+
$thisfile_riff_WAVE_cart_0['end_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 470, 10));
|
349 |
+
$thisfile_riff_WAVE_cart_0['end_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 480, 8));
|
350 |
+
$thisfile_riff_WAVE_cart_0['producer_app_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 488, 64));
|
351 |
+
$thisfile_riff_WAVE_cart_0['producer_app_version'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 552, 64));
|
352 |
+
$thisfile_riff_WAVE_cart_0['user_defined_text'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 616, 64));
|
353 |
+
$thisfile_riff_WAVE_cart_0['zero_db_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_cart_0['data'], 680, 4), true);
|
354 |
+
for ($i = 0; $i < 8; $i++) {
|
355 |
+
$thisfile_riff_WAVE_cart_0['post_time'][$i]['usage_fourcc'] = substr($thisfile_riff_WAVE_cart_0['data'], 684 + ($i * 8), 4);
|
356 |
+
$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));
|
357 |
+
}
|
358 |
+
$thisfile_riff_WAVE_cart_0['url'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 748, 1024));
|
359 |
+
$thisfile_riff_WAVE_cart_0['tag_text'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_cart_0['data'], 1772)));
|
360 |
+
|
361 |
+
$thisfile_riff['comments']['artist'][] = $thisfile_riff_WAVE_cart_0['artist'];
|
362 |
+
$thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_cart_0['title'];
|
363 |
+
}
|
364 |
+
|
365 |
+
if (isset($thisfile_riff_WAVE['SNDM'][0]['data'])) {
|
366 |
+
// SoundMiner metadata
|
367 |
+
|
368 |
+
// shortcuts
|
369 |
+
$thisfile_riff_WAVE_SNDM_0 = &$thisfile_riff_WAVE['SNDM'][0];
|
370 |
+
$thisfile_riff_WAVE_SNDM_0_data = &$thisfile_riff_WAVE_SNDM_0['data'];
|
371 |
+
$SNDM_startoffset = 0;
|
372 |
+
$SNDM_endoffset = $thisfile_riff_WAVE_SNDM_0['size'];
|
373 |
+
|
374 |
+
while ($SNDM_startoffset < $SNDM_endoffset) {
|
375 |
+
$SNDM_thisTagOffset = 0;
|
376 |
+
$SNDM_thisTagSize = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 4));
|
377 |
+
$SNDM_thisTagOffset += 4;
|
378 |
+
$SNDM_thisTagKey = substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 4);
|
379 |
+
$SNDM_thisTagOffset += 4;
|
380 |
+
$SNDM_thisTagDataSize = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 2));
|
381 |
+
$SNDM_thisTagOffset += 2;
|
382 |
+
$SNDM_thisTagDataFlags = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 2));
|
383 |
+
$SNDM_thisTagOffset += 2;
|
384 |
+
$SNDM_thisTagDataText = substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, $SNDM_thisTagDataSize);
|
385 |
+
$SNDM_thisTagOffset += $SNDM_thisTagDataSize;
|
386 |
+
|
387 |
+
if ($SNDM_thisTagSize != (4 + 4 + 2 + 2 + $SNDM_thisTagDataSize)) {
|
388 |
+
$info['warning'][] = 'RIFF.WAVE.SNDM.data contains tag not expected length (expected: '.$SNDM_thisTagSize.', found: '.(4 + 4 + 2 + 2 + $SNDM_thisTagDataSize).') at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')';
|
389 |
+
break;
|
390 |
+
} elseif ($SNDM_thisTagSize <= 0) {
|
391 |
+
$info['warning'][] = 'RIFF.WAVE.SNDM.data contains zero-size tag at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')';
|
392 |
+
break;
|
393 |
+
}
|
394 |
+
$SNDM_startoffset += $SNDM_thisTagSize;
|
395 |
+
|
396 |
+
$thisfile_riff_WAVE_SNDM_0['parsed_raw'][$SNDM_thisTagKey] = $SNDM_thisTagDataText;
|
397 |
+
if ($parsedkey = self::waveSNDMtagLookup($SNDM_thisTagKey)) {
|
398 |
+
$thisfile_riff_WAVE_SNDM_0['parsed'][$parsedkey] = $SNDM_thisTagDataText;
|
399 |
+
} else {
|
400 |
+
$info['warning'][] = 'RIFF.WAVE.SNDM contains unknown tag "'.$SNDM_thisTagKey.'" at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')';
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
$tagmapping = array(
|
405 |
+
'tracktitle'=>'title',
|
406 |
+
'category' =>'genre',
|
407 |
+
'cdtitle' =>'album',
|
408 |
+
'tracktitle'=>'title',
|
409 |
+
);
|
410 |
+
foreach ($tagmapping as $fromkey => $tokey) {
|
411 |
+
if (isset($thisfile_riff_WAVE_SNDM_0['parsed'][$fromkey])) {
|
412 |
+
$thisfile_riff['comments'][$tokey][] = $thisfile_riff_WAVE_SNDM_0['parsed'][$fromkey];
|
413 |
+
}
|
414 |
+
}
|
415 |
+
}
|
416 |
+
|
417 |
+
if (isset($thisfile_riff_WAVE['iXML'][0]['data'])) {
|
418 |
+
// requires functions simplexml_load_string and get_object_vars
|
419 |
+
if ($parsedXML = getid3_lib::XML2array($thisfile_riff_WAVE['iXML'][0]['data'])) {
|
420 |
+
$thisfile_riff_WAVE['iXML'][0]['parsed'] = $parsedXML;
|
421 |
+
if (isset($parsedXML['SPEED']['MASTER_SPEED'])) {
|
422 |
+
@list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['MASTER_SPEED']);
|
423 |
+
$thisfile_riff_WAVE['iXML'][0]['master_speed'] = $numerator / ($denominator ? $denominator : 1000);
|
424 |
+
}
|
425 |
+
if (isset($parsedXML['SPEED']['TIMECODE_RATE'])) {
|
426 |
+
@list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['TIMECODE_RATE']);
|
427 |
+
$thisfile_riff_WAVE['iXML'][0]['timecode_rate'] = $numerator / ($denominator ? $denominator : 1000);
|
428 |
+
}
|
429 |
+
if (isset($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO']) && !empty($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) && !empty($thisfile_riff_WAVE['iXML'][0]['timecode_rate'])) {
|
430 |
+
$samples_since_midnight = floatval(ltrim($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_HI'].$parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO'], '0'));
|
431 |
+
$thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] = $samples_since_midnight / $parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE'];
|
432 |
+
$h = floor( $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] / 3600);
|
433 |
+
$m = floor(($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - ($h * 3600)) / 60);
|
434 |
+
$s = floor( $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - ($h * 3600) - ($m * 60));
|
435 |
+
$f = ($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - ($h * 3600) - ($m * 60) - $s) * $thisfile_riff_WAVE['iXML'][0]['timecode_rate'];
|
436 |
+
$thisfile_riff_WAVE['iXML'][0]['timecode_string'] = sprintf('%02d:%02d:%02d:%05.2f', $h, $m, $s, $f);
|
437 |
+
$thisfile_riff_WAVE['iXML'][0]['timecode_string_round'] = sprintf('%02d:%02d:%02d:%02d', $h, $m, $s, round($f));
|
438 |
+
}
|
439 |
+
unset($parsedXML);
|
440 |
+
}
|
441 |
+
}
|
442 |
+
|
443 |
+
|
444 |
+
|
445 |
+
if (!isset($thisfile_audio['bitrate']) && isset($thisfile_riff_audio[$streamindex]['bitrate'])) {
|
446 |
+
$thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
|
447 |
+
$info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $thisfile_audio['bitrate']);
|
448 |
+
}
|
449 |
+
|
450 |
+
if (!empty($info['wavpack'])) {
|
451 |
+
$thisfile_audio_dataformat = 'wavpack';
|
452 |
+
$thisfile_audio['bitrate_mode'] = 'vbr';
|
453 |
+
$thisfile_audio['encoder'] = 'WavPack v'.$info['wavpack']['version'];
|
454 |
+
|
455 |
+
// Reset to the way it was - RIFF parsing will have messed this up
|
456 |
+
$info['avdataend'] = $Original['avdataend'];
|
457 |
+
$thisfile_audio['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
|
458 |
+
|
459 |
+
$this->fseek($info['avdataoffset'] - 44);
|
460 |
+
$RIFFdata = $this->fread(44);
|
461 |
+
$OrignalRIFFheaderSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 4, 4)) + 8;
|
462 |
+
$OrignalRIFFdataSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 40, 4)) + 44;
|
463 |
+
|
464 |
+
if ($OrignalRIFFheaderSize > $OrignalRIFFdataSize) {
|
465 |
+
$info['avdataend'] -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
|
466 |
+
$this->fseek($info['avdataend']);
|
467 |
+
$RIFFdata .= $this->fread($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
|
468 |
+
}
|
469 |
+
|
470 |
+
// move the data chunk after all other chunks (if any)
|
471 |
+
// so that the RIFF parser doesn't see EOF when trying
|
472 |
+
// to skip over the data chunk
|
473 |
+
$RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8);
|
474 |
+
$getid3_riff = new getid3_riff($this->getid3);
|
475 |
+
$getid3_riff->ParseRIFFdata($RIFFdata);
|
476 |
+
unset($getid3_riff);
|
477 |
+
}
|
478 |
+
|
479 |
+
if (isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
|
480 |
+
switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
|
481 |
+
case 0x0001: // PCM
|
482 |
+
if (!empty($info['ac3'])) {
|
483 |
+
// Dolby Digital WAV files masquerade as PCM-WAV, but they're not
|
484 |
+
$thisfile_audio['wformattag'] = 0x2000;
|
485 |
+
$thisfile_audio['codec'] = self::wFormatTagLookup($thisfile_audio['wformattag']);
|
486 |
+
$thisfile_audio['lossless'] = false;
|
487 |
+
$thisfile_audio['bitrate'] = $info['ac3']['bitrate'];
|
488 |
+
$thisfile_audio['sample_rate'] = $info['ac3']['sample_rate'];
|
489 |
+
}
|
490 |
+
if (!empty($info['dts'])) {
|
491 |
+
// Dolby DTS files masquerade as PCM-WAV, but they're not
|
492 |
+
$thisfile_audio['wformattag'] = 0x2001;
|
493 |
+
$thisfile_audio['codec'] = self::wFormatTagLookup($thisfile_audio['wformattag']);
|
494 |
+
$thisfile_audio['lossless'] = false;
|
495 |
+
$thisfile_audio['bitrate'] = $info['dts']['bitrate'];
|
496 |
+
$thisfile_audio['sample_rate'] = $info['dts']['sample_rate'];
|
497 |
+
}
|
498 |
+
break;
|
499 |
+
case 0x08AE: // ClearJump LiteWave
|
500 |
+
$thisfile_audio['bitrate_mode'] = 'vbr';
|
501 |
+
$thisfile_audio_dataformat = 'litewave';
|
502 |
+
|
503 |
+
//typedef struct tagSLwFormat {
|
504 |
+
// WORD m_wCompFormat; // low byte defines compression method, high byte is compression flags
|
505 |
+
// DWORD m_dwScale; // scale factor for lossy compression
|
506 |
+
// DWORD m_dwBlockSize; // number of samples in encoded blocks
|
507 |
+
// WORD m_wQuality; // alias for the scale factor
|
508 |
+
// WORD m_wMarkDistance; // distance between marks in bytes
|
509 |
+
// WORD m_wReserved;
|
510 |
+
//
|
511 |
+
// //following paramters are ignored if CF_FILESRC is not set
|
512 |
+
// DWORD m_dwOrgSize; // original file size in bytes
|
513 |
+
// WORD m_bFactExists; // indicates if 'fact' chunk exists in the original file
|
514 |
+
// DWORD m_dwRiffChunkSize; // riff chunk size in the original file
|
515 |
+
//
|
516 |
+
// PCMWAVEFORMAT m_OrgWf; // original wave format
|
517 |
+
// }SLwFormat, *PSLwFormat;
|
518 |
+
|
519 |
+
// shortcut
|
520 |
+
$thisfile_riff['litewave']['raw'] = array();
|
521 |
+
$riff_litewave = &$thisfile_riff['litewave'];
|
522 |
+
$riff_litewave_raw = &$riff_litewave['raw'];
|
523 |
+
|
524 |
+
$flags = array(
|
525 |
+
'compression_method' => 1,
|
526 |
+
'compression_flags' => 1,
|
527 |
+
'm_dwScale' => 4,
|
528 |
+
'm_dwBlockSize' => 4,
|
529 |
+
'm_wQuality' => 2,
|
530 |
+
'm_wMarkDistance' => 2,
|
531 |
+
'm_wReserved' => 2,
|
532 |
+
'm_dwOrgSize' => 4,
|
533 |
+
'm_bFactExists' => 2,
|
534 |
+
'm_dwRiffChunkSize' => 4,
|
535 |
+
);
|
536 |
+
$litewave_offset = 18;
|
537 |
+
foreach ($flags as $flag => $length) {
|
538 |
+
$riff_litewave_raw[$flag] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], $litewave_offset, $length));
|
539 |
+
$litewave_offset += $length;
|
540 |
+
}
|
541 |
+
|
542 |
+
//$riff_litewave['quality_factor'] = intval(round((2000 - $riff_litewave_raw['m_dwScale']) / 20));
|
543 |
+
$riff_litewave['quality_factor'] = $riff_litewave_raw['m_wQuality'];
|
544 |
+
|
545 |
+
$riff_litewave['flags']['raw_source'] = ($riff_litewave_raw['compression_flags'] & 0x01) ? false : true;
|
546 |
+
$riff_litewave['flags']['vbr_blocksize'] = ($riff_litewave_raw['compression_flags'] & 0x02) ? false : true;
|
547 |
+
$riff_litewave['flags']['seekpoints'] = (bool) ($riff_litewave_raw['compression_flags'] & 0x04);
|
548 |
+
|
549 |
+
$thisfile_audio['lossless'] = (($riff_litewave_raw['m_wQuality'] == 100) ? true : false);
|
550 |
+
$thisfile_audio['encoder_options'] = '-q'.$riff_litewave['quality_factor'];
|
551 |
+
break;
|
552 |
+
|
553 |
+
default:
|
554 |
+
break;
|
555 |
+
}
|
556 |
+
}
|
557 |
+
if ($info['avdataend'] > $info['filesize']) {
|
558 |
+
switch (!empty($thisfile_audio_dataformat) ? $thisfile_audio_dataformat : '') {
|
559 |
+
case 'wavpack': // WavPack
|
560 |
+
case 'lpac': // LPAC
|
561 |
+
case 'ofr': // OptimFROG
|
562 |
+
case 'ofs': // OptimFROG DualStream
|
563 |
+
// lossless compressed audio formats that keep original RIFF headers - skip warning
|
564 |
+
break;
|
565 |
+
|
566 |
+
case 'litewave':
|
567 |
+
if (($info['avdataend'] - $info['filesize']) == 1) {
|
568 |
+
// LiteWave appears to incorrectly *not* pad actual output file
|
569 |
+
// to nearest WORD boundary so may appear to be short by one
|
570 |
+
// byte, in which case - skip warning
|
571 |
+
} else {
|
572 |
+
// Short by more than one byte, throw warning
|
573 |
+
$info['warning'][] = 'Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' (short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])).' bytes)';
|
574 |
+
$info['avdataend'] = $info['filesize'];
|
575 |
+
}
|
576 |
+
break;
|
577 |
+
|
578 |
+
default:
|
579 |
+
if ((($info['avdataend'] - $info['filesize']) == 1) && (($thisfile_riff[$RIFFsubtype]['data'][0]['size'] % 2) == 0) && ((($info['filesize'] - $info['avdataoffset']) % 2) == 1)) {
|
580 |
+
// output file appears to be incorrectly *not* padded to nearest WORD boundary
|
581 |
+
// Output less severe warning
|
582 |
+
$info['warning'][] = 'File should probably be padded to nearest WORD boundary, but it is not (expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' therefore short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])).' bytes)';
|
583 |
+
$info['avdataend'] = $info['filesize'];
|
584 |
+
} else {
|
585 |
+
// Short by more than one byte, throw warning
|
586 |
+
$info['warning'][] = 'Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' (short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])).' bytes)';
|
587 |
+
$info['avdataend'] = $info['filesize'];
|
588 |
+
}
|
589 |
+
break;
|
590 |
+
}
|
591 |
+
}
|
592 |
+
if (!empty($info['mpeg']['audio']['LAME']['audio_bytes'])) {
|
593 |
+
if ((($info['avdataend'] - $info['avdataoffset']) - $info['mpeg']['audio']['LAME']['audio_bytes']) == 1) {
|
594 |
+
$info['avdataend']--;
|
595 |
+
$info['warning'][] = 'Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored';
|
596 |
+
}
|
597 |
+
}
|
598 |
+
if (isset($thisfile_audio_dataformat) && ($thisfile_audio_dataformat == 'ac3')) {
|
599 |
+
unset($thisfile_audio['bits_per_sample']);
|
600 |
+
if (!empty($info['ac3']['bitrate']) && ($info['ac3']['bitrate'] != $thisfile_audio['bitrate'])) {
|
601 |
+
$thisfile_audio['bitrate'] = $info['ac3']['bitrate'];
|
602 |
+
}
|
603 |
+
}
|
604 |
+
break;
|
605 |
+
|
606 |
+
// http://en.wikipedia.org/wiki/Audio_Video_Interleave
|
607 |
+
case 'AVI ':
|
608 |
+
$info['fileformat'] = 'avi';
|
609 |
+
$info['mime_type'] = 'video/avi';
|
610 |
+
|
611 |
+
$thisfile_video['bitrate_mode'] = 'vbr'; // maybe not, but probably
|
612 |
+
$thisfile_video['dataformat'] = 'avi';
|
613 |
+
|
614 |
+
if (isset($thisfile_riff[$RIFFsubtype]['movi']['offset'])) {
|
615 |
+
$info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['movi']['offset'] + 8;
|
616 |
+
if (isset($thisfile_riff['AVIX'])) {
|
617 |
+
$info['avdataend'] = $thisfile_riff['AVIX'][(count($thisfile_riff['AVIX']) - 1)]['chunks']['movi']['offset'] + $thisfile_riff['AVIX'][(count($thisfile_riff['AVIX']) - 1)]['chunks']['movi']['size'];
|
618 |
+
} else {
|
619 |
+
$info['avdataend'] = $thisfile_riff['AVI ']['movi']['offset'] + $thisfile_riff['AVI ']['movi']['size'];
|
620 |
+
}
|
621 |
+
if ($info['avdataend'] > $info['filesize']) {
|
622 |
+
$info['warning'][] = 'Probably truncated file - expecting '.($info['avdataend'] - $info['avdataoffset']).' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' (short by '.($info['avdataend'] - $info['filesize']).' bytes)';
|
623 |
+
$info['avdataend'] = $info['filesize'];
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
if (isset($thisfile_riff['AVI ']['hdrl']['strl']['indx'])) {
|
628 |
+
//$bIndexType = array(
|
629 |
+
// 0x00 => 'AVI_INDEX_OF_INDEXES',
|
630 |
+
// 0x01 => 'AVI_INDEX_OF_CHUNKS',
|
631 |
+
// 0x80 => 'AVI_INDEX_IS_DATA',
|
632 |
+
//);
|
633 |
+
//$bIndexSubtype = array(
|
634 |
+
// 0x01 => array(
|
635 |
+
// 0x01 => 'AVI_INDEX_2FIELD',
|
636 |
+
// ),
|
637 |
+
//);
|
638 |
+
foreach ($thisfile_riff['AVI ']['hdrl']['strl']['indx'] as $streamnumber => $steamdataarray) {
|
639 |
+
$ahsisd = &$thisfile_riff['AVI ']['hdrl']['strl']['indx'][$streamnumber]['data'];
|
640 |
+
|
641 |
+
$thisfile_riff_raw['indx'][$streamnumber]['wLongsPerEntry'] = $this->EitherEndian2Int(substr($ahsisd, 0, 2));
|
642 |
+
$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType'] = $this->EitherEndian2Int(substr($ahsisd, 2, 1));
|
643 |
+
$thisfile_riff_raw['indx'][$streamnumber]['bIndexType'] = $this->EitherEndian2Int(substr($ahsisd, 3, 1));
|
644 |
+
$thisfile_riff_raw['indx'][$streamnumber]['nEntriesInUse'] = $this->EitherEndian2Int(substr($ahsisd, 4, 4));
|
645 |
+
$thisfile_riff_raw['indx'][$streamnumber]['dwChunkId'] = substr($ahsisd, 8, 4);
|
646 |
+
$thisfile_riff_raw['indx'][$streamnumber]['dwReserved'] = $this->EitherEndian2Int(substr($ahsisd, 12, 4));
|
647 |
+
|
648 |
+
//$thisfile_riff_raw['indx'][$streamnumber]['bIndexType_name'] = $bIndexType[$thisfile_riff_raw['indx'][$streamnumber]['bIndexType']];
|
649 |
+
//$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType_name'] = $bIndexSubtype[$thisfile_riff_raw['indx'][$streamnumber]['bIndexType']][$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType']];
|
650 |
+
|
651 |
+
unset($ahsisd);
|
652 |
+
}
|
653 |
+
}
|
654 |
+
if (isset($thisfile_riff['AVI ']['hdrl']['avih'][$streamindex]['data'])) {
|
655 |
+
$avihData = $thisfile_riff['AVI ']['hdrl']['avih'][$streamindex]['data'];
|
656 |
+
|
657 |
+
// shortcut
|
658 |
+
$thisfile_riff_raw['avih'] = array();
|
659 |
+
$thisfile_riff_raw_avih = &$thisfile_riff_raw['avih'];
|
660 |
+
|
661 |
+
$thisfile_riff_raw_avih['dwMicroSecPerFrame'] = $this->EitherEndian2Int(substr($avihData, 0, 4)); // frame display rate (or 0L)
|
662 |
+
if ($thisfile_riff_raw_avih['dwMicroSecPerFrame'] == 0) {
|
663 |
+
$info['error'][] = 'Corrupt RIFF file: avih.dwMicroSecPerFrame == zero';
|
664 |
+
return false;
|
665 |
+
}
|
666 |
+
|
667 |
+
$flags = array(
|
668 |
+
'dwMaxBytesPerSec', // max. transfer rate
|
669 |
+
'dwPaddingGranularity', // pad to multiples of this size; normally 2K.
|
670 |
+
'dwFlags', // the ever-present flags
|
671 |
+
'dwTotalFrames', // # frames in file
|
672 |
+
'dwInitialFrames', //
|
673 |
+
'dwStreams', //
|
674 |
+
'dwSuggestedBufferSize', //
|
675 |
+
'dwWidth', //
|
676 |
+
'dwHeight', //
|
677 |
+
'dwScale', //
|
678 |
+
'dwRate', //
|
679 |
+
'dwStart', //
|
680 |
+
'dwLength', //
|
681 |
+
);
|
682 |
+
$avih_offset = 4;
|
683 |
+
foreach ($flags as $flag) {
|
684 |
+
$thisfile_riff_raw_avih[$flag] = $this->EitherEndian2Int(substr($avihData, $avih_offset, 4));
|
685 |
+
$avih_offset += 4;
|
686 |
+
}
|
687 |
+
|
688 |
+
$flags = array(
|
689 |
+
'hasindex' => 0x00000010,
|
690 |
+
'mustuseindex' => 0x00000020,
|
691 |
+
'interleaved' => 0x00000100,
|
692 |
+
'trustcktype' => 0x00000800,
|
693 |
+
'capturedfile' => 0x00010000,
|
694 |
+
'copyrighted' => 0x00020010,
|
695 |
+
);
|
696 |
+
foreach ($flags as $flag => $value) {
|
697 |
+
$thisfile_riff_raw_avih['flags'][$flag] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & $value);
|
698 |
+
}
|
699 |
+
|
700 |
+
// shortcut
|
701 |
+
$thisfile_riff_video[$streamindex] = array();
|
702 |
+
$thisfile_riff_video_current = &$thisfile_riff_video[$streamindex];
|
703 |
+
|
704 |
+
if ($thisfile_riff_raw_avih['dwWidth'] > 0) {
|
705 |
+
$thisfile_riff_video_current['frame_width'] = $thisfile_riff_raw_avih['dwWidth'];
|
706 |
+
$thisfile_video['resolution_x'] = $thisfile_riff_video_current['frame_width'];
|
707 |
+
}
|
708 |
+
if ($thisfile_riff_raw_avih['dwHeight'] > 0) {
|
709 |
+
$thisfile_riff_video_current['frame_height'] = $thisfile_riff_raw_avih['dwHeight'];
|
710 |
+
$thisfile_video['resolution_y'] = $thisfile_riff_video_current['frame_height'];
|
711 |
+
}
|
712 |
+
if ($thisfile_riff_raw_avih['dwTotalFrames'] > 0) {
|
713 |
+
$thisfile_riff_video_current['total_frames'] = $thisfile_riff_raw_avih['dwTotalFrames'];
|
714 |
+
$thisfile_video['total_frames'] = $thisfile_riff_video_current['total_frames'];
|
715 |
+
}
|
716 |
+
|
717 |
+
$thisfile_riff_video_current['frame_rate'] = round(1000000 / $thisfile_riff_raw_avih['dwMicroSecPerFrame'], 3);
|
718 |
+
$thisfile_video['frame_rate'] = $thisfile_riff_video_current['frame_rate'];
|
719 |
+
}
|
720 |
+
if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) {
|
721 |
+
if (is_array($thisfile_riff['AVI ']['hdrl']['strl']['strh'])) {
|
722 |
+
for ($i = 0; $i < count($thisfile_riff['AVI ']['hdrl']['strl']['strh']); $i++) {
|
723 |
+
if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'])) {
|
724 |
+
$strhData = $thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'];
|
725 |
+
$strhfccType = substr($strhData, 0, 4);
|
726 |
+
|
727 |
+
if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) {
|
728 |
+
$strfData = $thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'];
|
729 |
+
|
730 |
+
// shortcut
|
731 |
+
$thisfile_riff_raw_strf_strhfccType_streamindex = &$thisfile_riff_raw['strf'][$strhfccType][$streamindex];
|
732 |
+
|
733 |
+
switch ($strhfccType) {
|
734 |
+
case 'auds':
|
735 |
+
$thisfile_audio['bitrate_mode'] = 'cbr';
|
736 |
+
$thisfile_audio_dataformat = 'wav';
|
737 |
+
if (isset($thisfile_riff_audio) && is_array($thisfile_riff_audio)) {
|
738 |
+
$streamindex = count($thisfile_riff_audio);
|
739 |
+
}
|
740 |
+
|
741 |
+
$thisfile_riff_audio[$streamindex] = self::parseWAVEFORMATex($strfData);
|
742 |
+
$thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
|
743 |
+
|
744 |
+
// shortcut
|
745 |
+
$thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex];
|
746 |
+
$thisfile_audio_streams_currentstream = &$thisfile_audio['streams'][$streamindex];
|
747 |
+
|
748 |
+
if ($thisfile_audio_streams_currentstream['bits_per_sample'] == 0) {
|
749 |
+
unset($thisfile_audio_streams_currentstream['bits_per_sample']);
|
750 |
+
}
|
751 |
+
$thisfile_audio_streams_currentstream['wformattag'] = $thisfile_audio_streams_currentstream['raw']['wFormatTag'];
|
752 |
+
unset($thisfile_audio_streams_currentstream['raw']);
|
753 |
+
|
754 |
+
// shortcut
|
755 |
+
$thisfile_riff_raw['strf'][$strhfccType][$streamindex] = $thisfile_riff_audio[$streamindex]['raw'];
|
756 |
+
|
757 |
+
unset($thisfile_riff_audio[$streamindex]['raw']);
|
758 |
+
$thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
|
759 |
+
|
760 |
+
$thisfile_audio['lossless'] = false;
|
761 |
+
switch ($thisfile_riff_raw_strf_strhfccType_streamindex['wFormatTag']) {
|
762 |
+
case 0x0001: // PCM
|
763 |
+
$thisfile_audio_dataformat = 'wav';
|
764 |
+
$thisfile_audio['lossless'] = true;
|
765 |
+
break;
|
766 |
+
|
767 |
+
case 0x0050: // MPEG Layer 2 or Layer 1
|
768 |
+
$thisfile_audio_dataformat = 'mp2'; // Assume Layer-2
|
769 |
+
break;
|
770 |
+
|
771 |
+
case 0x0055: // MPEG Layer 3
|
772 |
+
$thisfile_audio_dataformat = 'mp3';
|
773 |
+
break;
|
774 |
+
|
775 |
+
case 0x00FF: // AAC
|
776 |
+
$thisfile_audio_dataformat = 'aac';
|
777 |
+
break;
|
778 |
+
|
779 |
+
case 0x0161: // Windows Media v7 / v8 / v9
|
780 |
+
case 0x0162: // Windows Media Professional v9
|
781 |
+
case 0x0163: // Windows Media Lossess v9
|
782 |
+
$thisfile_audio_dataformat = 'wma';
|
783 |
+
break;
|
784 |
+
|
785 |
+
case 0x2000: // AC-3
|
786 |
+
$thisfile_audio_dataformat = 'ac3';
|
787 |
+
break;
|
788 |
+
|
789 |
+
case 0x2001: // DTS
|
790 |
+
$thisfile_audio_dataformat = 'dts';
|
791 |
+
break;
|
792 |
+
|
793 |
+
default:
|
794 |
+
$thisfile_audio_dataformat = 'wav';
|
795 |
+
break;
|
796 |
+
}
|
797 |
+
$thisfile_audio_streams_currentstream['dataformat'] = $thisfile_audio_dataformat;
|
798 |
+
$thisfile_audio_streams_currentstream['lossless'] = $thisfile_audio['lossless'];
|
799 |
+
$thisfile_audio_streams_currentstream['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
|
800 |
+
break;
|
801 |
+
|
802 |
+
|
803 |
+
case 'iavs':
|
804 |
+
case 'vids':
|
805 |
+
// shortcut
|
806 |
+
$thisfile_riff_raw['strh'][$i] = array();
|
807 |
+
$thisfile_riff_raw_strh_current = &$thisfile_riff_raw['strh'][$i];
|
808 |
+
|
809 |
+
$thisfile_riff_raw_strh_current['fccType'] = substr($strhData, 0, 4); // same as $strhfccType;
|
810 |
+
$thisfile_riff_raw_strh_current['fccHandler'] = substr($strhData, 4, 4);
|
811 |
+
$thisfile_riff_raw_strh_current['dwFlags'] = $this->EitherEndian2Int(substr($strhData, 8, 4)); // Contains AVITF_* flags
|
812 |
+
$thisfile_riff_raw_strh_current['wPriority'] = $this->EitherEndian2Int(substr($strhData, 12, 2));
|
813 |
+
$thisfile_riff_raw_strh_current['wLanguage'] = $this->EitherEndian2Int(substr($strhData, 14, 2));
|
814 |
+
$thisfile_riff_raw_strh_current['dwInitialFrames'] = $this->EitherEndian2Int(substr($strhData, 16, 4));
|
815 |
+
$thisfile_riff_raw_strh_current['dwScale'] = $this->EitherEndian2Int(substr($strhData, 20, 4));
|
816 |
+
$thisfile_riff_raw_strh_current['dwRate'] = $this->EitherEndian2Int(substr($strhData, 24, 4));
|
817 |
+
$thisfile_riff_raw_strh_current['dwStart'] = $this->EitherEndian2Int(substr($strhData, 28, 4));
|
818 |
+
$thisfile_riff_raw_strh_current['dwLength'] = $this->EitherEndian2Int(substr($strhData, 32, 4));
|
819 |
+
$thisfile_riff_raw_strh_current['dwSuggestedBufferSize'] = $this->EitherEndian2Int(substr($strhData, 36, 4));
|
820 |
+
$thisfile_riff_raw_strh_current['dwQuality'] = $this->EitherEndian2Int(substr($strhData, 40, 4));
|
821 |
+
$thisfile_riff_raw_strh_current['dwSampleSize'] = $this->EitherEndian2Int(substr($strhData, 44, 4));
|
822 |
+
$thisfile_riff_raw_strh_current['rcFrame'] = $this->EitherEndian2Int(substr($strhData, 48, 4));
|
823 |
+
|
824 |
+
$thisfile_riff_video_current['codec'] = self::fourccLookup($thisfile_riff_raw_strh_current['fccHandler']);
|
825 |
+
$thisfile_video['fourcc'] = $thisfile_riff_raw_strh_current['fccHandler'];
|
826 |
+
if (!$thisfile_riff_video_current['codec'] && isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) && self::fourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
|
827 |
+
$thisfile_riff_video_current['codec'] = self::fourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']);
|
828 |
+
$thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'];
|
829 |
+
}
|
830 |
+
$thisfile_video['codec'] = $thisfile_riff_video_current['codec'];
|
831 |
+
$thisfile_video['pixel_aspect_ratio'] = (float) 1;
|
832 |
+
switch ($thisfile_riff_raw_strh_current['fccHandler']) {
|
833 |
+
case 'HFYU': // Huffman Lossless Codec
|
834 |
+
case 'IRAW': // Intel YUV Uncompressed
|
835 |
+
case 'YUY2': // Uncompressed YUV 4:2:2
|
836 |
+
$thisfile_video['lossless'] = true;
|
837 |
+
break;
|
838 |
+
|
839 |
+
default:
|
840 |
+
$thisfile_video['lossless'] = false;
|
841 |
+
break;
|
842 |
+
}
|
843 |
+
|
844 |
+
switch ($strhfccType) {
|
845 |
+
case 'vids':
|
846 |
+
$thisfile_riff_raw_strf_strhfccType_streamindex = self::ParseBITMAPINFOHEADER(substr($strfData, 0, 40), ($this->container == 'riff'));
|
847 |
+
$thisfile_video['bits_per_sample'] = $thisfile_riff_raw_strf_strhfccType_streamindex['biBitCount'];
|
848 |
+
|
849 |
+
if ($thisfile_riff_video_current['codec'] == 'DV') {
|
850 |
+
$thisfile_riff_video_current['dv_type'] = 2;
|
851 |
+
}
|
852 |
+
break;
|
853 |
+
|
854 |
+
case 'iavs':
|
855 |
+
$thisfile_riff_video_current['dv_type'] = 1;
|
856 |
+
break;
|
857 |
+
}
|
858 |
+
break;
|
859 |
+
|
860 |
+
default:
|
861 |
+
$info['warning'][] = 'Unhandled fccType for stream ('.$i.'): "'.$strhfccType.'"';
|
862 |
+
break;
|
863 |
+
|
864 |
+
}
|
865 |
+
}
|
866 |
+
}
|
867 |
+
|
868 |
+
if (isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
|
869 |
+
|
870 |
+
$thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'];
|
871 |
+
if (self::fourccLookup($thisfile_video['fourcc'])) {
|
872 |
+
$thisfile_riff_video_current['codec'] = self::fourccLookup($thisfile_video['fourcc']);
|
873 |
+
$thisfile_video['codec'] = $thisfile_riff_video_current['codec'];
|
874 |
+
}
|
875 |
+
|
876 |
+
switch ($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) {
|
877 |
+
case 'HFYU': // Huffman Lossless Codec
|
878 |
+
case 'IRAW': // Intel YUV Uncompressed
|
879 |
+
case 'YUY2': // Uncompressed YUV 4:2:2
|
880 |
+
$thisfile_video['lossless'] = true;
|
881 |
+
//$thisfile_video['bits_per_sample'] = 24;
|
882 |
+
break;
|
883 |
+
|
884 |
+
default:
|
885 |
+
$thisfile_video['lossless'] = false;
|
886 |
+
//$thisfile_video['bits_per_sample'] = 24;
|
887 |
+
break;
|
888 |
+
}
|
889 |
+
|
890 |
+
}
|
891 |
+
}
|
892 |
+
}
|
893 |
+
}
|
894 |
+
break;
|
895 |
+
|
896 |
+
|
897 |
+
case 'AMV ':
|
898 |
+
$info['fileformat'] = 'amv';
|
899 |
+
$info['mime_type'] = 'video/amv';
|
900 |
+
|
901 |
+
$thisfile_video['bitrate_mode'] = 'vbr'; // it's MJPEG, presumably contant-quality encoding, thereby VBR
|
902 |
+
$thisfile_video['dataformat'] = 'mjpeg';
|
903 |
+
$thisfile_video['codec'] = 'mjpeg';
|
904 |
+
$thisfile_video['lossless'] = false;
|
905 |
+
$thisfile_video['bits_per_sample'] = 24;
|
906 |
+
|
907 |
+
$thisfile_audio['dataformat'] = 'adpcm';
|
908 |
+
$thisfile_audio['lossless'] = false;
|
909 |
+
break;
|
910 |
+
|
911 |
+
|
912 |
+
// http://en.wikipedia.org/wiki/CD-DA
|
913 |
+
case 'CDDA':
|
914 |
+
$info['fileformat'] = 'cda';
|
915 |
+
unset($info['mime_type']);
|
916 |
+
|
917 |
+
$thisfile_audio_dataformat = 'cda';
|
918 |
+
|
919 |
+
$info['avdataoffset'] = 44;
|
920 |
+
|
921 |
+
if (isset($thisfile_riff['CDDA']['fmt '][0]['data'])) {
|
922 |
+
// shortcut
|
923 |
+
$thisfile_riff_CDDA_fmt_0 = &$thisfile_riff['CDDA']['fmt '][0];
|
924 |
+
|
925 |
+
$thisfile_riff_CDDA_fmt_0['unknown1'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 0, 2));
|
926 |
+
$thisfile_riff_CDDA_fmt_0['track_num'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 2, 2));
|
927 |
+
$thisfile_riff_CDDA_fmt_0['disc_id'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 4, 4));
|
928 |
+
$thisfile_riff_CDDA_fmt_0['start_offset_frame'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 8, 4));
|
929 |
+
$thisfile_riff_CDDA_fmt_0['playtime_frames'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 12, 4));
|
930 |
+
$thisfile_riff_CDDA_fmt_0['unknown6'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 16, 4));
|
931 |
+
$thisfile_riff_CDDA_fmt_0['unknown7'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 20, 4));
|
932 |
+
|
933 |
+
$thisfile_riff_CDDA_fmt_0['start_offset_seconds'] = (float) $thisfile_riff_CDDA_fmt_0['start_offset_frame'] / 75;
|
934 |
+
$thisfile_riff_CDDA_fmt_0['playtime_seconds'] = (float) $thisfile_riff_CDDA_fmt_0['playtime_frames'] / 75;
|
935 |
+
$info['comments']['track'] = $thisfile_riff_CDDA_fmt_0['track_num'];
|
936 |
+
$info['playtime_seconds'] = $thisfile_riff_CDDA_fmt_0['playtime_seconds'];
|
937 |
+
|
938 |
+
// hardcoded data for CD-audio
|
939 |
+
$thisfile_audio['lossless'] = true;
|
940 |
+
$thisfile_audio['sample_rate'] = 44100;
|
941 |
+
$thisfile_audio['channels'] = 2;
|
942 |
+
$thisfile_audio['bits_per_sample'] = 16;
|
943 |
+
$thisfile_audio['bitrate'] = $thisfile_audio['sample_rate'] * $thisfile_audio['channels'] * $thisfile_audio['bits_per_sample'];
|
944 |
+
$thisfile_audio['bitrate_mode'] = 'cbr';
|
945 |
+
}
|
946 |
+
break;
|
947 |
+
|
948 |
+
// http://en.wikipedia.org/wiki/AIFF
|
949 |
+
case 'AIFF':
|
950 |
+
case 'AIFC':
|
951 |
+
$info['fileformat'] = 'aiff';
|
952 |
+
$info['mime_type'] = 'audio/x-aiff';
|
953 |
+
|
954 |
+
$thisfile_audio['bitrate_mode'] = 'cbr';
|
955 |
+
$thisfile_audio_dataformat = 'aiff';
|
956 |
+
$thisfile_audio['lossless'] = true;
|
957 |
+
|
958 |
+
if (isset($thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'])) {
|
959 |
+
$info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'] + 8;
|
960 |
+
$info['avdataend'] = $info['avdataoffset'] + $thisfile_riff[$RIFFsubtype]['SSND'][0]['size'];
|
961 |
+
if ($info['avdataend'] > $info['filesize']) {
|
962 |
+
if (($info['avdataend'] == ($info['filesize'] + 1)) && (($info['filesize'] % 2) == 1)) {
|
963 |
+
// structures rounded to 2-byte boundary, but dumb encoders
|
964 |
+
// forget to pad end of file to make this actually work
|
965 |
+
} else {
|
966 |
+
$info['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['SSND'][0]['size'].' bytes of audio data, only '.($info['filesize'] - $info['avdataoffset']).' bytes found';
|
967 |
+
}
|
968 |
+
$info['avdataend'] = $info['filesize'];
|
969 |
+
}
|
970 |
+
}
|
971 |
+
|
972 |
+
if (isset($thisfile_riff[$RIFFsubtype]['COMM'][0]['data'])) {
|
973 |
+
|
974 |
+
// shortcut
|
975 |
+
$thisfile_riff_RIFFsubtype_COMM_0_data = &$thisfile_riff[$RIFFsubtype]['COMM'][0]['data'];
|
976 |
+
|
977 |
+
$thisfile_riff_audio['channels'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 0, 2), true);
|
978 |
+
$thisfile_riff_audio['total_samples'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 2, 4), false);
|
979 |
+
$thisfile_riff_audio['bits_per_sample'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 6, 2), true);
|
980 |
+
$thisfile_riff_audio['sample_rate'] = (int) getid3_lib::BigEndian2Float(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 8, 10));
|
981 |
+
|
982 |
+
if ($thisfile_riff[$RIFFsubtype]['COMM'][0]['size'] > 18) {
|
983 |
+
$thisfile_riff_audio['codec_fourcc'] = substr($thisfile_riff_RIFFsubtype_COMM_0_data, 18, 4);
|
984 |
+
$CodecNameSize = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 22, 1), false);
|
985 |
+
$thisfile_riff_audio['codec_name'] = substr($thisfile_riff_RIFFsubtype_COMM_0_data, 23, $CodecNameSize);
|
986 |
+
switch ($thisfile_riff_audio['codec_name']) {
|
987 |
+
case 'NONE':
|
988 |
+
$thisfile_audio['codec'] = 'Pulse Code Modulation (PCM)';
|
989 |
+
$thisfile_audio['lossless'] = true;
|
990 |
+
break;
|
991 |
+
|
992 |
+
case '':
|
993 |
+
switch ($thisfile_riff_audio['codec_fourcc']) {
|
994 |
+
// http://developer.apple.com/qa/snd/snd07.html
|
995 |
+
case 'sowt':
|
996 |
+
$thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM';
|
997 |
+
$thisfile_audio['lossless'] = true;
|
998 |
+
break;
|
999 |
+
|
1000 |
+
case 'twos':
|
1001 |
+
$thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Big-Endian PCM';
|
1002 |
+
$thisfile_audio['lossless'] = true;
|
1003 |
+
break;
|
1004 |
+
|
1005 |
+
default:
|
1006 |
+
break;
|
1007 |
+
}
|
1008 |
+
break;
|
1009 |
+
|
1010 |
+
default:
|
1011 |
+
$thisfile_audio['codec'] = $thisfile_riff_audio['codec_name'];
|
1012 |
+
$thisfile_audio['lossless'] = false;
|
1013 |
+
break;
|
1014 |
+
}
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
$thisfile_audio['channels'] = $thisfile_riff_audio['channels'];
|
1018 |
+
if ($thisfile_riff_audio['bits_per_sample'] > 0) {
|
1019 |
+
$thisfile_audio['bits_per_sample'] = $thisfile_riff_audio['bits_per_sample'];
|
1020 |
+
}
|
1021 |
+
$thisfile_audio['sample_rate'] = $thisfile_riff_audio['sample_rate'];
|
1022 |
+
if ($thisfile_audio['sample_rate'] == 0) {
|
1023 |
+
$info['error'][] = 'Corrupted AIFF file: sample_rate == zero';
|
1024 |
+
return false;
|
1025 |
+
}
|
1026 |
+
$info['playtime_seconds'] = $thisfile_riff_audio['total_samples'] / $thisfile_audio['sample_rate'];
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
if (isset($thisfile_riff[$RIFFsubtype]['COMT'])) {
|
1030 |
+
$offset = 0;
|
1031 |
+
$CommentCount = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);
|
1032 |
+
$offset += 2;
|
1033 |
+
for ($i = 0; $i < $CommentCount; $i++) {
|
1034 |
+
$info['comments_raw'][$i]['timestamp'] = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 4), false);
|
1035 |
+
$offset += 4;
|
1036 |
+
$info['comments_raw'][$i]['marker_id'] = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), true);
|
1037 |
+
$offset += 2;
|
1038 |
+
$CommentLength = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);
|
1039 |
+
$offset += 2;
|
1040 |
+
$info['comments_raw'][$i]['comment'] = substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, $CommentLength);
|
1041 |
+
$offset += $CommentLength;
|
1042 |
+
|
1043 |
+
$info['comments_raw'][$i]['timestamp_unix'] = getid3_lib::DateMac2Unix($info['comments_raw'][$i]['timestamp']);
|
1044 |
+
$thisfile_riff['comments']['comment'][] = $info['comments_raw'][$i]['comment'];
|
1045 |
+
}
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
$CommentsChunkNames = array('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment');
|
1049 |
+
foreach ($CommentsChunkNames as $key => $value) {
|
1050 |
+
if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) {
|
1051 |
+
$thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];
|
1052 |
+
}
|
1053 |
+
}
|
1054 |
+
/*
|
1055 |
+
if (isset($thisfile_riff[$RIFFsubtype]['ID3 '])) {
|
1056 |
+
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true);
|
1057 |
+
$getid3_temp = new getID3();
|
1058 |
+
$getid3_temp->openfile($this->getid3->filename);
|
1059 |
+
$getid3_id3v2 = new getid3_id3v2($getid3_temp);
|
1060 |
+
$getid3_id3v2->StartingOffset = $thisfile_riff[$RIFFsubtype]['ID3 '][0]['offset'] + 8;
|
1061 |
+
if ($thisfile_riff[$RIFFsubtype]['ID3 '][0]['valid'] = $getid3_id3v2->Analyze()) {
|
1062 |
+
$info['id3v2'] = $getid3_temp->info['id3v2'];
|
1063 |
+
}
|
1064 |
+
unset($getid3_temp, $getid3_id3v2);
|
1065 |
+
}
|
1066 |
+
*/
|
1067 |
+
break;
|
1068 |
+
|
1069 |
+
// http://en.wikipedia.org/wiki/8SVX
|
1070 |
+
case '8SVX':
|
1071 |
+
$info['fileformat'] = '8svx';
|
1072 |
+
$info['mime_type'] = 'audio/8svx';
|
1073 |
+
|
1074 |
+
$thisfile_audio['bitrate_mode'] = 'cbr';
|
1075 |
+
$thisfile_audio_dataformat = '8svx';
|
1076 |
+
$thisfile_audio['bits_per_sample'] = 8;
|
1077 |
+
$thisfile_audio['channels'] = 1; // overridden below, if need be
|
1078 |
+
|
1079 |
+
if (isset($thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'])) {
|
1080 |
+
$info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'] + 8;
|
1081 |
+
$info['avdataend'] = $info['avdataoffset'] + $thisfile_riff[$RIFFsubtype]['BODY'][0]['size'];
|
1082 |
+
if ($info['avdataend'] > $info['filesize']) {
|
1083 |
+
$info['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['BODY'][0]['size'].' bytes of audio data, only '.($info['filesize'] - $info['avdataoffset']).' bytes found';
|
1084 |
+
}
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
if (isset($thisfile_riff[$RIFFsubtype]['VHDR'][0]['offset'])) {
|
1088 |
+
// shortcut
|
1089 |
+
$thisfile_riff_RIFFsubtype_VHDR_0 = &$thisfile_riff[$RIFFsubtype]['VHDR'][0];
|
1090 |
+
|
1091 |
+
$thisfile_riff_RIFFsubtype_VHDR_0['oneShotHiSamples'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 0, 4));
|
1092 |
+
$thisfile_riff_RIFFsubtype_VHDR_0['repeatHiSamples'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 4, 4));
|
1093 |
+
$thisfile_riff_RIFFsubtype_VHDR_0['samplesPerHiCycle'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 8, 4));
|
1094 |
+
$thisfile_riff_RIFFsubtype_VHDR_0['samplesPerSec'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 12, 2));
|
1095 |
+
$thisfile_riff_RIFFsubtype_VHDR_0['ctOctave'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 14, 1));
|
1096 |
+
$thisfile_riff_RIFFsubtype_VHDR_0['sCompression'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 15, 1));
|
1097 |
+
$thisfile_riff_RIFFsubtype_VHDR_0['Volume'] = getid3_lib::FixedPoint16_16(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 16, 4));
|
1098 |
+
|
1099 |
+
$thisfile_audio['sample_rate'] = $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerSec'];
|
1100 |
+
|
1101 |
+
switch ($thisfile_riff_RIFFsubtype_VHDR_0['sCompression']) {
|
1102 |
+
case 0:
|
1103 |
+
$thisfile_audio['codec'] = 'Pulse Code Modulation (PCM)';
|
1104 |
+
$thisfile_audio['lossless'] = true;
|
1105 |
+
$ActualBitsPerSample = 8;
|
1106 |
+
break;
|
1107 |
+
|
1108 |
+
case 1:
|
1109 |
+
$thisfile_audio['codec'] = 'Fibonacci-delta encoding';
|
1110 |
+
$thisfile_audio['lossless'] = false;
|
1111 |
+
$ActualBitsPerSample = 4;
|
1112 |
+
break;
|
1113 |
+
|
1114 |
+
default:
|
1115 |
+
$info['warning'][] = 'Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "'.sCompression.'"';
|
1116 |
+
break;
|
1117 |
+
}
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
if (isset($thisfile_riff[$RIFFsubtype]['CHAN'][0]['data'])) {
|
1121 |
+
$ChannelsIndex = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['CHAN'][0]['data'], 0, 4));
|
1122 |
+
switch ($ChannelsIndex) {
|
1123 |
+
case 6: // Stereo
|
1124 |
+
$thisfile_audio['channels'] = 2;
|
1125 |
+
break;
|
1126 |
+
|
1127 |
+
case 2: // Left channel only
|
1128 |
+
case 4: // Right channel only
|
1129 |
+
$thisfile_audio['channels'] = 1;
|
1130 |
+
break;
|
1131 |
+
|
1132 |
+
default:
|
1133 |
+
$info['warning'][] = 'Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "'.$ChannelsIndex.'"';
|
1134 |
+
break;
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
}
|
1138 |
+
|
1139 |
+
$CommentsChunkNames = array('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment');
|
1140 |
+
foreach ($CommentsChunkNames as $key => $value) {
|
1141 |
+
if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) {
|
1142 |
+
$thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];
|
1143 |
+
}
|
1144 |
+
}
|
1145 |
+
|
1146 |
+
$thisfile_audio['bitrate'] = $thisfile_audio['sample_rate'] * $ActualBitsPerSample * $thisfile_audio['channels'];
|
1147 |
+
if (!empty($thisfile_audio['bitrate'])) {
|
1148 |
+
$info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) / ($thisfile_audio['bitrate'] / 8);
|
1149 |
+
}
|
1150 |
+
break;
|
1151 |
+
|
1152 |
+
case 'CDXA':
|
1153 |
+
$info['fileformat'] = 'vcd'; // Asume Video CD
|
1154 |
+
$info['mime_type'] = 'video/mpeg';
|
1155 |
+
|
1156 |
+
if (!empty($thisfile_riff['CDXA']['data'][0]['size'])) {
|
1157 |
+
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.mpeg.php', __FILE__, true);
|
1158 |
+
|
1159 |
+
$getid3_temp = new getID3();
|
1160 |
+
$getid3_temp->openfile($this->getid3->filename);
|
1161 |
+
$getid3_mpeg = new getid3_mpeg($getid3_temp);
|
1162 |
+
$getid3_mpeg->Analyze();
|
1163 |
+
if (empty($getid3_temp->info['error'])) {
|
1164 |
+
$info['audio'] = $getid3_temp->info['audio'];
|
1165 |
+
$info['video'] = $getid3_temp->info['video'];
|
1166 |
+
$info['mpeg'] = $getid3_temp->info['mpeg'];
|
1167 |
+
$info['warning'] = $getid3_temp->info['warning'];
|
1168 |
+
}
|
1169 |
+
unset($getid3_temp, $getid3_mpeg);
|
1170 |
+
}
|
1171 |
+
break;
|
1172 |
+
|
1173 |
+
|
1174 |
+
default:
|
1175 |
+
$info['error'][] = 'Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "'.$RIFFsubtype.'" instead';
|
1176 |
+
//unset($info['fileformat']);
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
switch ($RIFFsubtype) {
|
1180 |
+
case 'WAVE':
|
1181 |
+
case 'AIFF':
|
1182 |
+
case 'AIFC':
|
1183 |
+
$ID3v2_key_good = 'id3 ';
|
1184 |
+
$ID3v2_keys_bad = array('ID3 ', 'tag ');
|
1185 |
+
foreach ($ID3v2_keys_bad as $ID3v2_key_bad) {
|
1186 |
+
if (isset($thisfile_riff[$RIFFsubtype][$ID3v2_key_bad]) && !array_key_exists($ID3v2_key_good, $thisfile_riff[$RIFFsubtype])) {
|
1187 |
+
$thisfile_riff[$RIFFsubtype][$ID3v2_key_good] = $thisfile_riff[$RIFFsubtype][$ID3v2_key_bad];
|
1188 |
+
$info['warning'][] = 'mapping "'.$ID3v2_key_bad.'" chunk to "'.$ID3v2_key_good.'"';
|
1189 |
+
}
|
1190 |
+
}
|
1191 |
+
|
1192 |
+
if (isset($thisfile_riff[$RIFFsubtype]['id3 '])) {
|
1193 |
+
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true);
|
1194 |
+
|
1195 |
+
$getid3_temp = new getID3();
|
1196 |
+
$getid3_temp->openfile($this->getid3->filename);
|
1197 |
+
$getid3_id3v2 = new getid3_id3v2($getid3_temp);
|
1198 |
+
$getid3_id3v2->StartingOffset = $thisfile_riff[$RIFFsubtype]['id3 '][0]['offset'] + 8;
|
1199 |
+
if ($thisfile_riff[$RIFFsubtype]['id3 '][0]['valid'] = $getid3_id3v2->Analyze()) {
|
1200 |
+
$info['id3v2'] = $getid3_temp->info['id3v2'];
|
1201 |
+
}
|
1202 |
+
unset($getid3_temp, $getid3_id3v2);
|
1203 |
+
}
|
1204 |
+
break;
|
1205 |
+
}
|
1206 |
+
|
1207 |
+
if (isset($thisfile_riff_WAVE['DISP']) && is_array($thisfile_riff_WAVE['DISP'])) {
|
1208 |
+
$thisfile_riff['comments']['title'][] = trim(substr($thisfile_riff_WAVE['DISP'][count($thisfile_riff_WAVE['DISP']) - 1]['data'], 4));
|
1209 |
+
}
|
1210 |
+
if (isset($thisfile_riff_WAVE['INFO']) && is_array($thisfile_riff_WAVE['INFO'])) {
|
1211 |
+
self::parseComments($thisfile_riff_WAVE['INFO'], $thisfile_riff['comments']);
|
1212 |
+
}
|
1213 |
+
if (isset($thisfile_riff['AVI ']['INFO']) && is_array($thisfile_riff['AVI ']['INFO'])) {
|
1214 |
+
self::parseComments($thisfile_riff['AVI ']['INFO'], $thisfile_riff['comments']);
|
1215 |
+
}
|
1216 |
+
|
1217 |
+
if (empty($thisfile_audio['encoder']) && !empty($info['mpeg']['audio']['LAME']['short_version'])) {
|
1218 |
+
$thisfile_audio['encoder'] = $info['mpeg']['audio']['LAME']['short_version'];
|
1219 |
+
}
|
1220 |
+
|
1221 |
+
if (!isset($info['playtime_seconds'])) {
|
1222 |
+
$info['playtime_seconds'] = 0;
|
1223 |
+
}
|
1224 |
+
if (isset($thisfile_riff_raw['strh'][0]['dwLength']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) {
|
1225 |
+
// needed for >2GB AVIs where 'avih' chunk only lists number of frames in that chunk, not entire movie
|
1226 |
+
$info['playtime_seconds'] = $thisfile_riff_raw['strh'][0]['dwLength'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
|
1227 |
+
} elseif (isset($thisfile_riff_raw['avih']['dwTotalFrames']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) {
|
1228 |
+
$info['playtime_seconds'] = $thisfile_riff_raw['avih']['dwTotalFrames'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
if ($info['playtime_seconds'] > 0) {
|
1232 |
+
if (isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {
|
1233 |
+
|
1234 |
+
if (!isset($info['bitrate'])) {
|
1235 |
+
$info['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8);
|
1236 |
+
}
|
1237 |
+
|
1238 |
+
} elseif (isset($thisfile_riff_audio) && !isset($thisfile_riff_video)) {
|
1239 |
+
|
1240 |
+
if (!isset($thisfile_audio['bitrate'])) {
|
1241 |
+
$thisfile_audio['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8);
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
} elseif (!isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {
|
1245 |
+
|
1246 |
+
if (!isset($thisfile_video['bitrate'])) {
|
1247 |
+
$thisfile_video['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8);
|
1248 |
+
}
|
1249 |
+
|
1250 |
+
}
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
|
1254 |
+
if (isset($thisfile_riff_video) && isset($thisfile_audio['bitrate']) && ($thisfile_audio['bitrate'] > 0) && ($info['playtime_seconds'] > 0)) {
|
1255 |
+
|
1256 |
+
$info['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8);
|
1257 |
+
$thisfile_audio['bitrate'] = 0;
|
1258 |
+
$thisfile_video['bitrate'] = $info['bitrate'];
|
1259 |
+
foreach ($thisfile_riff_audio as $channelnumber => $audioinfoarray) {
|
1260 |
+
$thisfile_video['bitrate'] -= $audioinfoarray['bitrate'];
|
1261 |
+
$thisfile_audio['bitrate'] += $audioinfoarray['bitrate'];
|
1262 |
+
}
|
1263 |
+
if ($thisfile_video['bitrate'] <= 0) {
|
1264 |
+
unset($thisfile_video['bitrate']);
|
1265 |
+
}
|
1266 |
+
if ($thisfile_audio['bitrate'] <= 0) {
|
1267 |
+
unset($thisfile_audio['bitrate']);
|
1268 |
+
}
|
1269 |
+
}
|
1270 |
+
|
1271 |
+
if (isset($info['mpeg']['audio'])) {
|
1272 |
+
$thisfile_audio_dataformat = 'mp'.$info['mpeg']['audio']['layer'];
|
1273 |
+
$thisfile_audio['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
|
1274 |
+
$thisfile_audio['channels'] = $info['mpeg']['audio']['channels'];
|
1275 |
+
$thisfile_audio['bitrate'] = $info['mpeg']['audio']['bitrate'];
|
1276 |
+
$thisfile_audio['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
|
1277 |
+
if (!empty($info['mpeg']['audio']['codec'])) {
|
1278 |
+
$thisfile_audio['codec'] = $info['mpeg']['audio']['codec'].' '.$thisfile_audio['codec'];
|
1279 |
+
}
|
1280 |
+
if (!empty($thisfile_audio['streams'])) {
|
1281 |
+
foreach ($thisfile_audio['streams'] as $streamnumber => $streamdata) {
|
1282 |
+
if ($streamdata['dataformat'] == $thisfile_audio_dataformat) {
|
1283 |
+
$thisfile_audio['streams'][$streamnumber]['sample_rate'] = $thisfile_audio['sample_rate'];
|
1284 |
+
$thisfile_audio['streams'][$streamnumber]['channels'] = $thisfile_audio['channels'];
|
1285 |
+
$thisfile_audio['streams'][$streamnumber]['bitrate'] = $thisfile_audio['bitrate'];
|
1286 |
+
$thisfile_audio['streams'][$streamnumber]['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
|
1287 |
+
$thisfile_audio['streams'][$streamnumber]['codec'] = $thisfile_audio['codec'];
|
1288 |
+
}
|
1289 |
+
}
|
1290 |
+
}
|
1291 |
+
$getid3_mp3 = new getid3_mp3($this->getid3);
|
1292 |
+
$thisfile_audio['encoder_options'] = $getid3_mp3->GuessEncoderOptions();
|
1293 |
+
unset($getid3_mp3);
|
1294 |
+
}
|
1295 |
+
|
1296 |
+
|
1297 |
+
if (!empty($thisfile_riff_raw['fmt ']['wBitsPerSample']) && ($thisfile_riff_raw['fmt ']['wBitsPerSample'] > 0)) {
|
1298 |
+
switch ($thisfile_audio_dataformat) {
|
1299 |
+
case 'ac3':
|
1300 |
+
// ignore bits_per_sample
|
1301 |
+
break;
|
1302 |
+
|
1303 |
+
default:
|
1304 |
+
$thisfile_audio['bits_per_sample'] = $thisfile_riff_raw['fmt ']['wBitsPerSample'];
|
1305 |
+
break;
|
1306 |
+
}
|
1307 |
+
}
|
1308 |
+
|
1309 |
+
|
1310 |
+
if (empty($thisfile_riff_raw)) {
|
1311 |
+
unset($thisfile_riff['raw']);
|
1312 |
+
}
|
1313 |
+
if (empty($thisfile_riff_audio)) {
|
1314 |
+
unset($thisfile_riff['audio']);
|
1315 |
+
}
|
1316 |
+
if (empty($thisfile_riff_video)) {
|
1317 |
+
unset($thisfile_riff['video']);
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
return true;
|
1321 |
+
}
|
1322 |
+
|
1323 |
+
public function ParseRIFFAMV($startoffset, $maxoffset) {
|
1324 |
+
// AMV files are RIFF-AVI files with parts of the spec deliberately broken, such as chunk size fields hardcoded to zero (because players known in hardware that these fields are always a certain size
|
1325 |
+
|
1326 |
+
// https://code.google.com/p/amv-codec-tools/wiki/AmvDocumentation
|
1327 |
+
//typedef struct _amvmainheader {
|
1328 |
+
//FOURCC fcc; // 'amvh'
|
1329 |
+
//DWORD cb;
|
1330 |
+
//DWORD dwMicroSecPerFrame;
|
1331 |
+
//BYTE reserve[28];
|
1332 |
+
//DWORD dwWidth;
|
1333 |
+
//DWORD dwHeight;
|
1334 |
+
//DWORD dwSpeed;
|
1335 |
+
//DWORD reserve0;
|
1336 |
+
//DWORD reserve1;
|
1337 |
+
//BYTE bTimeSec;
|
1338 |
+
//BYTE bTimeMin;
|
1339 |
+
//WORD wTimeHour;
|
1340 |
+
//} AMVMAINHEADER;
|
1341 |
+
|
1342 |
+
$info = &$this->getid3->info;
|
1343 |
+
$RIFFchunk = false;
|
1344 |
+
|
1345 |
+
try {
|
1346 |
+
|
1347 |
+
$this->fseek($startoffset);
|
1348 |
+
$maxoffset = min($maxoffset, $info['avdataend']);
|
1349 |
+
$AMVheader = $this->fread(284);
|
1350 |
+
if (substr($AMVheader, 0, 8) != 'hdrlamvh') {
|
1351 |
+
throw new Exception('expecting "hdrlamv" at offset '.($startoffset + 0).', found "'.substr($AMVheader, 0, 8).'"');
|
1352 |
+
}
|
1353 |
+
if (substr($AMVheader, 8, 4) != "\x38\x00\x00\x00") { // "amvh" chunk size, hardcoded to 0x38 = 56 bytes
|
1354 |
+
throw new Exception('expecting "0x38000000" at offset '.($startoffset + 8).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 8, 4)).'"');
|
1355 |
+
}
|
1356 |
+
$RIFFchunk = array();
|
1357 |
+
$RIFFchunk['amvh']['us_per_frame'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 12, 4));
|
1358 |
+
$RIFFchunk['amvh']['reserved28'] = substr($AMVheader, 16, 28); // null? reserved?
|
1359 |
+
$RIFFchunk['amvh']['resolution_x'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 44, 4));
|
1360 |
+
$RIFFchunk['amvh']['resolution_y'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 48, 4));
|
1361 |
+
$RIFFchunk['amvh']['frame_rate_int'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 52, 4));
|
1362 |
+
$RIFFchunk['amvh']['reserved0'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 56, 4)); // 1? reserved?
|
1363 |
+
$RIFFchunk['amvh']['reserved1'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 60, 4)); // 0? reserved?
|
1364 |
+
$RIFFchunk['amvh']['runtime_sec'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 64, 1));
|
1365 |
+
$RIFFchunk['amvh']['runtime_min'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 65, 1));
|
1366 |
+
$RIFFchunk['amvh']['runtime_hrs'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 66, 2));
|
1367 |
+
|
1368 |
+
$info['video']['frame_rate'] = 1000000 / $RIFFchunk['amvh']['us_per_frame'];
|
1369 |
+
$info['video']['resolution_x'] = $RIFFchunk['amvh']['resolution_x'];
|
1370 |
+
$info['video']['resolution_y'] = $RIFFchunk['amvh']['resolution_y'];
|
1371 |
+
$info['playtime_seconds'] = ($RIFFchunk['amvh']['runtime_hrs'] * 3600) + ($RIFFchunk['amvh']['runtime_min'] * 60) + $RIFFchunk['amvh']['runtime_sec'];
|
1372 |
+
|
1373 |
+
// the rest is all hardcoded(?) and does not appear to be useful until you get to audio info at offset 256, even then everything is probably hardcoded
|
1374 |
+
|
1375 |
+
if (substr($AMVheader, 68, 20) != 'LIST'."\x00\x00\x00\x00".'strlstrh'."\x38\x00\x00\x00") {
|
1376 |
+
throw new Exception('expecting "LIST<0x00000000>strlstrh<0x38000000>" at offset '.($startoffset + 68).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 68, 20)).'"');
|
1377 |
+
}
|
1378 |
+
// followed by 56 bytes of null: substr($AMVheader, 88, 56) -> 144
|
1379 |
+
if (substr($AMVheader, 144, 8) != 'strf'."\x24\x00\x00\x00") {
|
1380 |
+
throw new Exception('expecting "strf<0x24000000>" at offset '.($startoffset + 144).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 144, 8)).'"');
|
1381 |
+
}
|
1382 |
+
// followed by 36 bytes of null: substr($AMVheader, 144, 36) -> 180
|
1383 |
+
|
1384 |
+
if (substr($AMVheader, 188, 20) != 'LIST'."\x00\x00\x00\x00".'strlstrh'."\x30\x00\x00\x00") {
|
1385 |
+
throw new Exception('expecting "LIST<0x00000000>strlstrh<0x30000000>" at offset '.($startoffset + 188).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 188, 20)).'"');
|
1386 |
+
}
|
1387 |
+
// followed by 48 bytes of null: substr($AMVheader, 208, 48) -> 256
|
1388 |
+
if (substr($AMVheader, 256, 8) != 'strf'."\x14\x00\x00\x00") {
|
1389 |
+
throw new Exception('expecting "strf<0x14000000>" at offset '.($startoffset + 256).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 256, 8)).'"');
|
1390 |
+
}
|
1391 |
+
// followed by 20 bytes of a modified WAVEFORMATEX:
|
1392 |
+
// typedef struct {
|
1393 |
+
// WORD wFormatTag; //(Fixme: this is equal to PCM's 0x01 format code)
|
1394 |
+
// WORD nChannels; //(Fixme: this is always 1)
|
1395 |
+
// DWORD nSamplesPerSec; //(Fixme: for all known sample files this is equal to 22050)
|
1396 |
+
// DWORD nAvgBytesPerSec; //(Fixme: for all known sample files this is equal to 44100)
|
1397 |
+
// WORD nBlockAlign; //(Fixme: this seems to be 2 in AMV files, is this correct ?)
|
1398 |
+
// WORD wBitsPerSample; //(Fixme: this seems to be 16 in AMV files instead of the expected 4)
|
1399 |
+
// WORD cbSize; //(Fixme: this seems to be 0 in AMV files)
|
1400 |
+
// WORD reserved;
|
1401 |
+
// } WAVEFORMATEX;
|
1402 |
+
$RIFFchunk['strf']['wformattag'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 264, 2));
|
1403 |
+
$RIFFchunk['strf']['nchannels'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 266, 2));
|
1404 |
+
$RIFFchunk['strf']['nsamplespersec'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 268, 4));
|
1405 |
+
$RIFFchunk['strf']['navgbytespersec'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 272, 4));
|
1406 |
+
$RIFFchunk['strf']['nblockalign'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 276, 2));
|
1407 |
+
$RIFFchunk['strf']['wbitspersample'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 278, 2));
|
1408 |
+
$RIFFchunk['strf']['cbsize'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 280, 2));
|
1409 |
+
$RIFFchunk['strf']['reserved'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 282, 2));
|
1410 |
+
|
1411 |
+
|
1412 |
+
$info['audio']['lossless'] = false;
|
1413 |
+
$info['audio']['sample_rate'] = $RIFFchunk['strf']['nsamplespersec'];
|
1414 |
+
$info['audio']['channels'] = $RIFFchunk['strf']['nchannels'];
|
1415 |
+
$info['audio']['bits_per_sample'] = $RIFFchunk['strf']['wbitspersample'];
|
1416 |
+
$info['audio']['bitrate'] = $info['audio']['sample_rate'] * $info['audio']['channels'] * $info['audio']['bits_per_sample'];
|
1417 |
+
$info['audio']['bitrate_mode'] = 'cbr';
|
1418 |
+
|
1419 |
+
|
1420 |
+
} catch (getid3_exception $e) {
|
1421 |
+
if ($e->getCode() == 10) {
|
1422 |
+
$this->warning('RIFFAMV parser: '.$e->getMessage());
|
1423 |
+
} else {
|
1424 |
+
throw $e;
|
1425 |
+
}
|
1426 |
+
}
|
1427 |
+
|
1428 |
+
return $RIFFchunk;
|
1429 |
+
}
|
1430 |
+
|
1431 |
+
|
1432 |
+
public function ParseRIFF($startoffset, $maxoffset) {
|
1433 |
+
$info = &$this->getid3->info;
|
1434 |
+
|
1435 |
+
$RIFFchunk = false;
|
1436 |
+
$FoundAllChunksWeNeed = false;
|
1437 |
+
|
1438 |
+
try {
|
1439 |
+
$this->fseek($startoffset);
|
1440 |
+
$maxoffset = min($maxoffset, $info['avdataend']);
|
1441 |
+
while ($this->ftell() < $maxoffset) {
|
1442 |
+
$chunknamesize = $this->fread(8);
|
1443 |
+
//$chunkname = substr($chunknamesize, 0, 4);
|
1444 |
+
$chunkname = str_replace("\x00", '_', substr($chunknamesize, 0, 4)); // note: chunk names of 4 null bytes do appear to be legal (has been observed inside INFO and PRMI chunks, for example), but makes traversing array keys more difficult
|
1445 |
+
$chunksize = $this->EitherEndian2Int(substr($chunknamesize, 4, 4));
|
1446 |
+
//if (strlen(trim($chunkname, "\x00")) < 4) {
|
1447 |
+
if (strlen($chunkname) < 4) {
|
1448 |
+
$this->error('Expecting chunk name at offset '.($this->ftell() - 8).' but found nothing. Aborting RIFF parsing.');
|
1449 |
+
break;
|
1450 |
+
}
|
1451 |
+
if (($chunksize == 0) && ($chunkname != 'JUNK')) {
|
1452 |
+
$this->warning('Chunk ('.$chunkname.') size at offset '.($this->ftell() - 4).' is zero. Aborting RIFF parsing.');
|
1453 |
+
break;
|
1454 |
+
}
|
1455 |
+
if (($chunksize % 2) != 0) {
|
1456 |
+
// all structures are packed on word boundaries
|
1457 |
+
$chunksize++;
|
1458 |
+
}
|
1459 |
+
|
1460 |
+
switch ($chunkname) {
|
1461 |
+
case 'LIST':
|
1462 |
+
$listname = $this->fread(4);
|
1463 |
+
if (preg_match('#^(movi|rec )$#i', $listname)) {
|
1464 |
+
$RIFFchunk[$listname]['offset'] = $this->ftell() - 4;
|
1465 |
+
$RIFFchunk[$listname]['size'] = $chunksize;
|
1466 |
+
|
1467 |
+
if (!$FoundAllChunksWeNeed) {
|
1468 |
+
$WhereWeWere = $this->ftell();
|
1469 |
+
$AudioChunkHeader = $this->fread(12);
|
1470 |
+
$AudioChunkStreamNum = substr($AudioChunkHeader, 0, 2);
|
1471 |
+
$AudioChunkStreamType = substr($AudioChunkHeader, 2, 2);
|
1472 |
+
$AudioChunkSize = getid3_lib::LittleEndian2Int(substr($AudioChunkHeader, 4, 4));
|
1473 |
+
|
1474 |
+
if ($AudioChunkStreamType == 'wb') {
|
1475 |
+
$FirstFourBytes = substr($AudioChunkHeader, 8, 4);
|
1476 |
+
if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', $FirstFourBytes)) {
|
1477 |
+
// MP3
|
1478 |
+
if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) {
|
1479 |
+
$getid3_temp = new getID3();
|
1480 |
+
$getid3_temp->openfile($this->getid3->filename);
|
1481 |
+
$getid3_temp->info['avdataoffset'] = $this->ftell() - 4;
|
1482 |
+
$getid3_temp->info['avdataend'] = $this->ftell() + $AudioChunkSize;
|
1483 |
+
$getid3_mp3 = new getid3_mp3($getid3_temp, __CLASS__);
|
1484 |
+
$getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
|
1485 |
+
if (isset($getid3_temp->info['mpeg']['audio'])) {
|
1486 |
+
$info['mpeg']['audio'] = $getid3_temp->info['mpeg']['audio'];
|
1487 |
+
$info['audio'] = $getid3_temp->info['audio'];
|
1488 |
+
$info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer'];
|
1489 |
+
$info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
|
1490 |
+
$info['audio']['channels'] = $info['mpeg']['audio']['channels'];
|
1491 |
+
$info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
|
1492 |
+
$info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
|
1493 |
+
//$info['bitrate'] = $info['audio']['bitrate'];
|
1494 |
+
}
|
1495 |
+
unset($getid3_temp, $getid3_mp3);
|
1496 |
+
}
|
1497 |
+
|
1498 |
+
} elseif (strpos($FirstFourBytes, getid3_ac3::syncword) === 0) {
|
1499 |
+
|
1500 |
+
// AC3
|
1501 |
+
$getid3_temp = new getID3();
|
1502 |
+
$getid3_temp->openfile($this->getid3->filename);
|
1503 |
+
$getid3_temp->info['avdataoffset'] = $this->ftell() - 4;
|
1504 |
+
$getid3_temp->info['avdataend'] = $this->ftell() + $AudioChunkSize;
|
1505 |
+
$getid3_ac3 = new getid3_ac3($getid3_temp);
|
1506 |
+
$getid3_ac3->Analyze();
|
1507 |
+
if (empty($getid3_temp->info['error'])) {
|
1508 |
+
$info['audio'] = $getid3_temp->info['audio'];
|
1509 |
+
$info['ac3'] = $getid3_temp->info['ac3'];
|
1510 |
+
if (!empty($getid3_temp->info['warning'])) {
|
1511 |
+
foreach ($getid3_temp->info['warning'] as $key => $value) {
|
1512 |
+
$info['warning'][] = $value;
|
1513 |
+
}
|
1514 |
+
}
|
1515 |
+
}
|
1516 |
+
unset($getid3_temp, $getid3_ac3);
|
1517 |
+
}
|
1518 |
+
}
|
1519 |
+
$FoundAllChunksWeNeed = true;
|
1520 |
+
$this->fseek($WhereWeWere);
|
1521 |
+
}
|
1522 |
+
$this->fseek($chunksize - 4, SEEK_CUR);
|
1523 |
+
|
1524 |
+
} else {
|
1525 |
+
|
1526 |
+
if (!isset($RIFFchunk[$listname])) {
|
1527 |
+
$RIFFchunk[$listname] = array();
|
1528 |
+
}
|
1529 |
+
$LISTchunkParent = $listname;
|
1530 |
+
$LISTchunkMaxOffset = $this->ftell() - 4 + $chunksize;
|
1531 |
+
if ($parsedChunk = $this->ParseRIFF($this->ftell(), $LISTchunkMaxOffset)) {
|
1532 |
+
$RIFFchunk[$listname] = array_merge_recursive($RIFFchunk[$listname], $parsedChunk);
|
1533 |
+
}
|
1534 |
+
|
1535 |
+
}
|
1536 |
+
break;
|
1537 |
+
|
1538 |
+
default:
|
1539 |
+
if (preg_match('#^[0-9]{2}(wb|pc|dc|db)$#', $chunkname)) {
|
1540 |
+
$this->fseek($chunksize, SEEK_CUR);
|
1541 |
+
break;
|
1542 |
+
}
|
1543 |
+
$thisindex = 0;
|
1544 |
+
if (isset($RIFFchunk[$chunkname]) && is_array($RIFFchunk[$chunkname])) {
|
1545 |
+
$thisindex = count($RIFFchunk[$chunkname]);
|
1546 |
+
}
|
1547 |
+
$RIFFchunk[$chunkname][$thisindex]['offset'] = $this->ftell() - 8;
|
1548 |
+
$RIFFchunk[$chunkname][$thisindex]['size'] = $chunksize;
|
1549 |
+
switch ($chunkname) {
|
1550 |
+
case 'data':
|
1551 |
+
$info['avdataoffset'] = $this->ftell();
|
1552 |
+
$info['avdataend'] = $info['avdataoffset'] + $chunksize;
|
1553 |
+
|
1554 |
+
$testData = $this->fread(36);
|
1555 |
+
if ($testData === '') {
|
1556 |
+
break;
|
1557 |
+
}
|
1558 |
+
if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', substr($testData, 0, 4))) {
|
1559 |
+
|
1560 |
+
// Probably is MP3 data
|
1561 |
+
if (getid3_mp3::MPEGaudioHeaderBytesValid(substr($testData, 0, 4))) {
|
1562 |
+
$getid3_temp = new getID3();
|
1563 |
+
$getid3_temp->openfile($this->getid3->filename);
|
1564 |
+
$getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
|
1565 |
+
$getid3_temp->info['avdataend'] = $info['avdataend'];
|
1566 |
+
$getid3_mp3 = new getid3_mp3($getid3_temp, __CLASS__);
|
1567 |
+
$getid3_mp3->getOnlyMPEGaudioInfo($info['avdataoffset'], false);
|
1568 |
+
if (empty($getid3_temp->info['error'])) {
|
1569 |
+
$info['audio'] = $getid3_temp->info['audio'];
|
1570 |
+
$info['mpeg'] = $getid3_temp->info['mpeg'];
|
1571 |
+
}
|
1572 |
+
unset($getid3_temp, $getid3_mp3);
|
1573 |
+
}
|
1574 |
+
|
1575 |
+
} elseif (($isRegularAC3 = (substr($testData, 0, 2) == getid3_ac3::syncword)) || substr($testData, 8, 2) == strrev(getid3_ac3::syncword)) {
|
1576 |
+
|
1577 |
+
// This is probably AC-3 data
|
1578 |
+
$getid3_temp = new getID3();
|
1579 |
+
if ($isRegularAC3) {
|
1580 |
+
$getid3_temp->openfile($this->getid3->filename);
|
1581 |
+
$getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
|
1582 |
+
$getid3_temp->info['avdataend'] = $info['avdataend'];
|
1583 |
+
}
|
1584 |
+
$getid3_ac3 = new getid3_ac3($getid3_temp);
|
1585 |
+
if ($isRegularAC3) {
|
1586 |
+
$getid3_ac3->Analyze();
|
1587 |
+
} else {
|
1588 |
+
// Dolby Digital WAV
|
1589 |
+
// AC-3 content, but not encoded in same format as normal AC-3 file
|
1590 |
+
// For one thing, byte order is swapped
|
1591 |
+
$ac3_data = '';
|
1592 |
+
for ($i = 0; $i < 28; $i += 2) {
|
1593 |
+
$ac3_data .= substr($testData, 8 + $i + 1, 1);
|
1594 |
+
$ac3_data .= substr($testData, 8 + $i + 0, 1);
|
1595 |
+
}
|
1596 |
+
$getid3_ac3->AnalyzeString($ac3_data);
|
1597 |
+
}
|
1598 |
+
|
1599 |
+
if (empty($getid3_temp->info['error'])) {
|
1600 |
+
$info['audio'] = $getid3_temp->info['audio'];
|
1601 |
+
$info['ac3'] = $getid3_temp->info['ac3'];
|
1602 |
+
if (!empty($getid3_temp->info['warning'])) {
|
1603 |
+
foreach ($getid3_temp->info['warning'] as $newerror) {
|
1604 |
+
$this->warning('getid3_ac3() says: ['.$newerror.']');
|
1605 |
+
}
|
1606 |
+
}
|
1607 |
+
}
|
1608 |
+
unset($getid3_temp, $getid3_ac3);
|
1609 |
+
|
1610 |
+
} elseif (preg_match('/^('.implode('|', array_map('preg_quote', getid3_dts::$syncwords)).')/', $testData)) {
|
1611 |
+
|
1612 |
+
// This is probably DTS data
|
1613 |
+
$getid3_temp = new getID3();
|
1614 |
+
$getid3_temp->openfile($this->getid3->filename);
|
1615 |
+
$getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
|
1616 |
+
$getid3_dts = new getid3_dts($getid3_temp);
|
1617 |
+
$getid3_dts->Analyze();
|
1618 |
+
if (empty($getid3_temp->info['error'])) {
|
1619 |
+
$info['audio'] = $getid3_temp->info['audio'];
|
1620 |
+
$info['dts'] = $getid3_temp->info['dts'];
|
1621 |
+
$info['playtime_seconds'] = $getid3_temp->info['playtime_seconds']; // may not match RIFF calculations since DTS-WAV often used 14/16 bit-word packing
|
1622 |
+
if (!empty($getid3_temp->info['warning'])) {
|
1623 |
+
foreach ($getid3_temp->info['warning'] as $newerror) {
|
1624 |
+
$this->warning('getid3_dts() says: ['.$newerror.']');
|
1625 |
+
}
|
1626 |
+
}
|
1627 |
+
}
|
1628 |
+
|
1629 |
+
unset($getid3_temp, $getid3_dts);
|
1630 |
+
|
1631 |
+
} elseif (substr($testData, 0, 4) == 'wvpk') {
|
1632 |
+
|
1633 |
+
// This is WavPack data
|
1634 |
+
$info['wavpack']['offset'] = $info['avdataoffset'];
|
1635 |
+
$info['wavpack']['size'] = getid3_lib::LittleEndian2Int(substr($testData, 4, 4));
|
1636 |
+
$this->parseWavPackHeader(substr($testData, 8, 28));
|
1637 |
+
|
1638 |
+
} else {
|
1639 |
+
// This is some other kind of data (quite possibly just PCM)
|
1640 |
+
// do nothing special, just skip it
|
1641 |
+
}
|
1642 |
+
$nextoffset = $info['avdataend'];
|
1643 |
+
$this->fseek($nextoffset);
|
1644 |
+
break;
|
1645 |
+
|
1646 |
+
case 'iXML':
|
1647 |
+
case 'bext':
|
1648 |
+
case 'cart':
|
1649 |
+
case 'fmt ':
|
1650 |
+
case 'strh':
|
1651 |
+
case 'strf':
|
1652 |
+
case 'indx':
|
1653 |
+
case 'MEXT':
|
1654 |
+
case 'DISP':
|
1655 |
+
// always read data in
|
1656 |
+
case 'JUNK':
|
1657 |
+
// should be: never read data in
|
1658 |
+
// but some programs write their version strings in a JUNK chunk (e.g. VirtualDub, AVIdemux, etc)
|
1659 |
+
if ($chunksize < 1048576) {
|
1660 |
+
if ($chunksize > 0) {
|
1661 |
+
$RIFFchunk[$chunkname][$thisindex]['data'] = $this->fread($chunksize);
|
1662 |
+
if ($chunkname == 'JUNK') {
|
1663 |
+
if (preg_match('#^([\\x20-\\x7F]+)#', $RIFFchunk[$chunkname][$thisindex]['data'], $matches)) {
|
1664 |
+
// only keep text characters [chr(32)-chr(127)]
|
1665 |
+
$info['riff']['comments']['junk'][] = trim($matches[1]);
|
1666 |
+
}
|
1667 |
+
// but if nothing there, ignore
|
1668 |
+
// remove the key in either case
|
1669 |
+
unset($RIFFchunk[$chunkname][$thisindex]['data']);
|
1670 |
+
}
|
1671 |
+
}
|
1672 |
+
} else {
|
1673 |
+
$this->warning('Chunk "'.$chunkname.'" at offset '.$this->ftell().' is unexpectedly larger than 1MB (claims to be '.number_format($chunksize).' bytes), skipping data');
|
1674 |
+
$this->fseek($chunksize, SEEK_CUR);
|
1675 |
+
}
|
1676 |
+
break;
|
1677 |
+
|
1678 |
+
//case 'IDVX':
|
1679 |
+
// $info['divxtag']['comments'] = self::ParseDIVXTAG($this->fread($chunksize));
|
1680 |
+
// break;
|
1681 |
+
|
1682 |
+
default:
|
1683 |
+
if (!empty($LISTchunkParent) && (($RIFFchunk[$chunkname][$thisindex]['offset'] + $RIFFchunk[$chunkname][$thisindex]['size']) <= $LISTchunkMaxOffset)) {
|
1684 |
+
$RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
|
1685 |
+
$RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['size'] = $RIFFchunk[$chunkname][$thisindex]['size'];
|
1686 |
+
unset($RIFFchunk[$chunkname][$thisindex]['offset']);
|
1687 |
+
unset($RIFFchunk[$chunkname][$thisindex]['size']);
|
1688 |
+
if (isset($RIFFchunk[$chunkname][$thisindex]) && empty($RIFFchunk[$chunkname][$thisindex])) {
|
1689 |
+
unset($RIFFchunk[$chunkname][$thisindex]);
|
1690 |
+
}
|
1691 |
+
if (isset($RIFFchunk[$chunkname]) && empty($RIFFchunk[$chunkname])) {
|
1692 |
+
unset($RIFFchunk[$chunkname]);
|
1693 |
+
}
|
1694 |
+
$RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['data'] = $this->fread($chunksize);
|
1695 |
+
} elseif ($chunksize < 2048) {
|
1696 |
+
// only read data in if smaller than 2kB
|
1697 |
+
$RIFFchunk[$chunkname][$thisindex]['data'] = $this->fread($chunksize);
|
1698 |
+
} else {
|
1699 |
+
$this->fseek($chunksize, SEEK_CUR);
|
1700 |
+
}
|
1701 |
+
break;
|
1702 |
+
}
|
1703 |
+
break;
|
1704 |
+
}
|
1705 |
+
}
|
1706 |
+
|
1707 |
+
} catch (getid3_exception $e) {
|
1708 |
+
if ($e->getCode() == 10) {
|
1709 |
+
$this->warning('RIFF parser: '.$e->getMessage());
|
1710 |
+
} else {
|
1711 |
+
throw $e;
|
1712 |
+
}
|
1713 |
+
}
|
1714 |
+
|
1715 |
+
return $RIFFchunk;
|
1716 |
+
}
|
1717 |
+
|
1718 |
+
public function ParseRIFFdata(&$RIFFdata) {
|
1719 |
+
$info = &$this->getid3->info;
|
1720 |
+
if ($RIFFdata) {
|
1721 |
+
$tempfile = tempnam(GETID3_TEMP_DIR, 'getID3');
|
1722 |
+
$fp_temp = fopen($tempfile, 'wb');
|
1723 |
+
$RIFFdataLength = strlen($RIFFdata);
|
1724 |
+
$NewLengthString = getid3_lib::LittleEndian2String($RIFFdataLength, 4);
|
1725 |
+
for ($i = 0; $i < 4; $i++) {
|
1726 |
+
$RIFFdata[($i + 4)] = $NewLengthString[$i];
|
1727 |
+
}
|
1728 |
+
fwrite($fp_temp, $RIFFdata);
|
1729 |
+
fclose($fp_temp);
|
1730 |
+
|
1731 |
+
$getid3_temp = new getID3();
|
1732 |
+
$getid3_temp->openfile($tempfile);
|
1733 |
+
$getid3_temp->info['filesize'] = $RIFFdataLength;
|
1734 |
+
$getid3_temp->info['filenamepath'] = $info['filenamepath'];
|
1735 |
+
$getid3_temp->info['tags'] = $info['tags'];
|
1736 |
+
$getid3_temp->info['warning'] = $info['warning'];
|
1737 |
+
$getid3_temp->info['error'] = $info['error'];
|
1738 |
+
$getid3_temp->info['comments'] = $info['comments'];
|
1739 |
+
$getid3_temp->info['audio'] = (isset($info['audio']) ? $info['audio'] : array());
|
1740 |
+
$getid3_temp->info['video'] = (isset($info['video']) ? $info['video'] : array());
|
1741 |
+
$getid3_riff = new getid3_riff($getid3_temp);
|
1742 |
+
$getid3_riff->Analyze();
|
1743 |
+
|
1744 |
+
$info['riff'] = $getid3_temp->info['riff'];
|
1745 |
+
$info['warning'] = $getid3_temp->info['warning'];
|
1746 |
+
$info['error'] = $getid3_temp->info['error'];
|
1747 |
+
$info['tags'] = $getid3_temp->info['tags'];
|
1748 |
+
$info['comments'] = $getid3_temp->info['comments'];
|
1749 |
+
unset($getid3_riff, $getid3_temp);
|
1750 |
+
unlink($tempfile);
|
1751 |
+
}
|
1752 |
+
return false;
|
1753 |
+
}
|
1754 |
+
|
1755 |
+
public static function parseComments(&$RIFFinfoArray, &$CommentsTargetArray) {
|
1756 |
+
$RIFFinfoKeyLookup = array(
|
1757 |
+
'IARL'=>'archivallocation',
|
1758 |
+
'IART'=>'artist',
|
1759 |
+
'ICDS'=>'costumedesigner',
|
1760 |
+
'ICMS'=>'commissionedby',
|
1761 |
+
'ICMT'=>'comment',
|
1762 |
+
'ICNT'=>'country',
|
1763 |
+
'ICOP'=>'copyright',
|
1764 |
+
'ICRD'=>'creationdate',
|
1765 |
+
'IDIM'=>'dimensions',
|
1766 |
+
'IDIT'=>'digitizationdate',
|
1767 |
+
'IDPI'=>'resolution',
|
1768 |
+
'IDST'=>'distributor',
|
1769 |
+
'IEDT'=>'editor',
|
1770 |
+
'IENG'=>'engineers',
|
1771 |
+
'IFRM'=>'accountofparts',
|
1772 |
+
'IGNR'=>'genre',
|
1773 |
+
'IKEY'=>'keywords',
|
1774 |
+
'ILGT'=>'lightness',
|
1775 |
+
'ILNG'=>'language',
|
1776 |
+
'IMED'=>'orignalmedium',
|
1777 |
+
'IMUS'=>'composer',
|
1778 |
+
'INAM'=>'title',
|
1779 |
+
'IPDS'=>'productiondesigner',
|
1780 |
+
'IPLT'=>'palette',
|
1781 |
+
'IPRD'=>'product',
|
1782 |
+
'IPRO'=>'producer',
|
1783 |
+
'IPRT'=>'part',
|
1784 |
+
'IRTD'=>'rating',
|
1785 |
+
'ISBJ'=>'subject',
|
1786 |
+
'ISFT'=>'software',
|
1787 |
+
'ISGN'=>'secondarygenre',
|
1788 |
+
'ISHP'=>'sharpness',
|
1789 |
+
'ISRC'=>'sourcesupplier',
|
1790 |
+
'ISRF'=>'digitizationsource',
|
1791 |
+
'ISTD'=>'productionstudio',
|
1792 |
+
'ISTR'=>'starring',
|
1793 |
+
'ITCH'=>'encoded_by',
|
1794 |
+
'IWEB'=>'url',
|
1795 |
+
'IWRI'=>'writer',
|
1796 |
+
'____'=>'comment',
|
1797 |
+
);
|
1798 |
+
foreach ($RIFFinfoKeyLookup as $key => $value) {
|
1799 |
+
if (isset($RIFFinfoArray[$key])) {
|
1800 |
+
foreach ($RIFFinfoArray[$key] as $commentid => $commentdata) {
|
1801 |
+
if (trim($commentdata['data']) != '') {
|
1802 |
+
if (isset($CommentsTargetArray[$value])) {
|
1803 |
+
$CommentsTargetArray[$value][] = trim($commentdata['data']);
|
1804 |
+
} else {
|
1805 |
+
$CommentsTargetArray[$value] = array(trim($commentdata['data']));
|
1806 |
+
}
|
1807 |
+
}
|
1808 |
+
}
|
1809 |
+
}
|
1810 |
+
}
|
1811 |
+
return true;
|
1812 |
+
}
|
1813 |
+
|
1814 |
+
public static function parseWAVEFORMATex($WaveFormatExData) {
|
1815 |
+
// shortcut
|
1816 |
+
$WaveFormatEx['raw'] = array();
|
1817 |
+
$WaveFormatEx_raw = &$WaveFormatEx['raw'];
|
1818 |
+
|
1819 |
+
$WaveFormatEx_raw['wFormatTag'] = substr($WaveFormatExData, 0, 2);
|
1820 |
+
$WaveFormatEx_raw['nChannels'] = substr($WaveFormatExData, 2, 2);
|
1821 |
+
$WaveFormatEx_raw['nSamplesPerSec'] = substr($WaveFormatExData, 4, 4);
|
1822 |
+
$WaveFormatEx_raw['nAvgBytesPerSec'] = substr($WaveFormatExData, 8, 4);
|
1823 |
+
$WaveFormatEx_raw['nBlockAlign'] = substr($WaveFormatExData, 12, 2);
|
1824 |
+
$WaveFormatEx_raw['wBitsPerSample'] = substr($WaveFormatExData, 14, 2);
|
1825 |
+
if (strlen($WaveFormatExData) > 16) {
|
1826 |
+
$WaveFormatEx_raw['cbSize'] = substr($WaveFormatExData, 16, 2);
|
1827 |
+
}
|
1828 |
+
$WaveFormatEx_raw = array_map('getid3_lib::LittleEndian2Int', $WaveFormatEx_raw);
|
1829 |
+
|
1830 |
+
$WaveFormatEx['codec'] = self::wFormatTagLookup($WaveFormatEx_raw['wFormatTag']);
|
1831 |
+
$WaveFormatEx['channels'] = $WaveFormatEx_raw['nChannels'];
|
1832 |
+
$WaveFormatEx['sample_rate'] = $WaveFormatEx_raw['nSamplesPerSec'];
|
1833 |
+
$WaveFormatEx['bitrate'] = $WaveFormatEx_raw['nAvgBytesPerSec'] * 8;
|
1834 |
+
$WaveFormatEx['bits_per_sample'] = $WaveFormatEx_raw['wBitsPerSample'];
|
1835 |
+
|
1836 |
+
return $WaveFormatEx;
|
1837 |
+
}
|
1838 |
+
|
1839 |
+
public function parseWavPackHeader($WavPackChunkData) {
|
1840 |
+
// typedef struct {
|
1841 |
+
// char ckID [4];
|
1842 |
+
// long ckSize;
|
1843 |
+
// short version;
|
1844 |
+
// short bits; // added for version 2.00
|
1845 |
+
// short flags, shift; // added for version 3.00
|
1846 |
+
// long total_samples, crc, crc2;
|
1847 |
+
// char extension [4], extra_bc, extras [3];
|
1848 |
+
// } WavpackHeader;
|
1849 |
+
|
1850 |
+
// shortcut
|
1851 |
+
$info = &$this->getid3->info;
|
1852 |
+
$info['wavpack'] = array();
|
1853 |
+
$thisfile_wavpack = &$info['wavpack'];
|
1854 |
+
|
1855 |
+
$thisfile_wavpack['version'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 0, 2));
|
1856 |
+
if ($thisfile_wavpack['version'] >= 2) {
|
1857 |
+
$thisfile_wavpack['bits'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 2, 2));
|
1858 |
+
}
|
1859 |
+
if ($thisfile_wavpack['version'] >= 3) {
|
1860 |
+
$thisfile_wavpack['flags_raw'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 4, 2));
|
1861 |
+
$thisfile_wavpack['shift'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 6, 2));
|
1862 |
+
$thisfile_wavpack['total_samples'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 8, 4));
|
1863 |
+
$thisfile_wavpack['crc1'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 12, 4));
|
1864 |
+
$thisfile_wavpack['crc2'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 16, 4));
|
1865 |
+
$thisfile_wavpack['extension'] = substr($WavPackChunkData, 20, 4);
|
1866 |
+
$thisfile_wavpack['extra_bc'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 24, 1));
|
1867 |
+
for ($i = 0; $i <= 2; $i++) {
|
1868 |
+
$thisfile_wavpack['extras'][] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 25 + $i, 1));
|
1869 |
+
}
|
1870 |
+
|
1871 |
+
// shortcut
|
1872 |
+
$thisfile_wavpack['flags'] = array();
|
1873 |
+
$thisfile_wavpack_flags = &$thisfile_wavpack['flags'];
|
1874 |
+
|
1875 |
+
$thisfile_wavpack_flags['mono'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000001);
|
1876 |
+
$thisfile_wavpack_flags['fast_mode'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000002);
|
1877 |
+
$thisfile_wavpack_flags['raw_mode'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000004);
|
1878 |
+
$thisfile_wavpack_flags['calc_noise'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000008);
|
1879 |
+
$thisfile_wavpack_flags['high_quality'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000010);
|
1880 |
+
$thisfile_wavpack_flags['3_byte_samples'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000020);
|
1881 |
+
$thisfile_wavpack_flags['over_20_bits'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000040);
|
1882 |
+
$thisfile_wavpack_flags['use_wvc'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000080);
|
1883 |
+
$thisfile_wavpack_flags['noiseshaping'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000100);
|
1884 |
+
$thisfile_wavpack_flags['very_fast_mode'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000200);
|
1885 |
+
$thisfile_wavpack_flags['new_high_quality'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000400);
|
1886 |
+
$thisfile_wavpack_flags['cancel_extreme'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000800);
|
1887 |
+
$thisfile_wavpack_flags['cross_decorrelation'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x001000);
|
1888 |
+
$thisfile_wavpack_flags['new_decorrelation'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x002000);
|
1889 |
+
$thisfile_wavpack_flags['joint_stereo'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x004000);
|
1890 |
+
$thisfile_wavpack_flags['extra_decorrelation'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x008000);
|
1891 |
+
$thisfile_wavpack_flags['override_noiseshape'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x010000);
|
1892 |
+
$thisfile_wavpack_flags['override_jointstereo'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x020000);
|
1893 |
+
$thisfile_wavpack_flags['copy_source_filetime'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x040000);
|
1894 |
+
$thisfile_wavpack_flags['create_exe'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x080000);
|
1895 |
+
}
|
1896 |
+
|
1897 |
+
return true;
|
1898 |
+
}
|
1899 |
+
|
1900 |
+
public static function ParseBITMAPINFOHEADER($BITMAPINFOHEADER, $littleEndian=true) {
|
1901 |
+
|
1902 |
+
$parsed['biSize'] = substr($BITMAPINFOHEADER, 0, 4); // number of bytes required by the BITMAPINFOHEADER structure
|
1903 |
+
$parsed['biWidth'] = substr($BITMAPINFOHEADER, 4, 4); // width of the bitmap in pixels
|
1904 |
+
$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
|
1905 |
+
$parsed['biPlanes'] = substr($BITMAPINFOHEADER, 12, 2); // number of color planes on the target device. In most cases this value must be set to 1
|
1906 |
+
$parsed['biBitCount'] = substr($BITMAPINFOHEADER, 14, 2); // Specifies the number of bits per pixels
|
1907 |
+
$parsed['biSizeImage'] = substr($BITMAPINFOHEADER, 20, 4); // size of the bitmap data section of the image (the actual pixel data, excluding BITMAPINFOHEADER and RGBQUAD structures)
|
1908 |
+
$parsed['biXPelsPerMeter'] = substr($BITMAPINFOHEADER, 24, 4); // horizontal resolution, in pixels per metre, of the target device
|
1909 |
+
$parsed['biYPelsPerMeter'] = substr($BITMAPINFOHEADER, 28, 4); // vertical resolution, in pixels per metre, of the target device
|
1910 |
+
$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
|
1911 |
+
$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
|
1912 |
+
$parsed = array_map('getid3_lib::'.($littleEndian ? 'Little' : 'Big').'Endian2Int', $parsed);
|
1913 |
+
|
1914 |
+
$parsed['fourcc'] = substr($BITMAPINFOHEADER, 16, 4); // compression identifier
|
1915 |
+
|
1916 |
+
return $parsed;
|
1917 |
+
}
|
1918 |
+
|
1919 |
+
public static function ParseDIVXTAG($DIVXTAG, $raw=false) {
|
1920 |
+
// structure from "IDivX" source, Form1.frm, by "Greg Frazier of Daemonic Software Group", email: gfrazier@icestorm.net, web: http://dsg.cjb.net/
|
1921 |
+
// source available at http://files.divx-digest.com/download/c663efe7ef8ad2e90bf4af4d3ea6188a/on0SWN2r/edit/IDivX.zip
|
1922 |
+
// 'Byte Layout: '1111111111111111
|
1923 |
+
// '32 for Movie - 1 '1111111111111111
|
1924 |
+
// '28 for Author - 6 '6666666666666666
|
1925 |
+
// '4 for year - 2 '6666666666662222
|
1926 |
+
// '3 for genre - 3 '7777777777777777
|
1927 |
+
// '48 for Comments - 7 '7777777777777777
|
1928 |
+
// '1 for Rating - 4 '7777777777777777
|
1929 |
+
// '5 for Future Additions - 0 '333400000DIVXTAG
|
1930 |
+
// '128 bytes total
|
1931 |
+
|
1932 |
+
static $DIVXTAGgenre = array(
|
1933 |
+
0 => 'Action',
|
1934 |
+
1 => 'Action/Adventure',
|
1935 |
+
2 => 'Adventure',
|
1936 |
+
3 => 'Adult',
|
1937 |
+
4 => 'Anime',
|
1938 |
+
5 => 'Cartoon',
|
1939 |
+
6 => 'Claymation',
|
1940 |
+
7 => 'Comedy',
|
1941 |
+
8 => 'Commercial',
|
1942 |
+
9 => 'Documentary',
|
1943 |
+
10 => 'Drama',
|
1944 |
+
11 => 'Home Video',
|
1945 |
+
12 => 'Horror',
|
1946 |
+
13 => 'Infomercial',
|
1947 |
+
14 => 'Interactive',
|
1948 |
+
15 => 'Mystery',
|
1949 |
+
16 => 'Music Video',
|
1950 |
+
17 => 'Other',
|
1951 |
+
18 => 'Religion',
|
1952 |
+
19 => 'Sci Fi',
|
1953 |
+
20 => 'Thriller',
|
1954 |
+
21 => 'Western',
|
1955 |
+
),
|
1956 |
+
$DIVXTAGrating = array(
|
1957 |
+
0 => 'Unrated',
|
1958 |
+
1 => 'G',
|
1959 |
+
2 => 'PG',
|
1960 |
+
3 => 'PG-13',
|
1961 |
+
4 => 'R',
|
1962 |
+
5 => 'NC-17',
|
1963 |
+
);
|
1964 |
+
|
1965 |
+
$parsed['title'] = trim(substr($DIVXTAG, 0, 32));
|
1966 |
+
$parsed['artist'] = trim(substr($DIVXTAG, 32, 28));
|
1967 |
+
$parsed['year'] = intval(trim(substr($DIVXTAG, 60, 4)));
|
1968 |
+
$parsed['comment'] = trim(substr($DIVXTAG, 64, 48));
|
1969 |
+
$parsed['genre_id'] = intval(trim(substr($DIVXTAG, 112, 3)));
|
1970 |
+
$parsed['rating_id'] = ord(substr($DIVXTAG, 115, 1));
|
1971 |
+
//$parsed['padding'] = substr($DIVXTAG, 116, 5); // 5-byte null
|
1972 |
+
//$parsed['magic'] = substr($DIVXTAG, 121, 7); // "DIVXTAG"
|
1973 |
+
|
1974 |
+
$parsed['genre'] = (isset($DIVXTAGgenre[$parsed['genre_id']]) ? $DIVXTAGgenre[$parsed['genre_id']] : $parsed['genre_id']);
|
1975 |
+
$parsed['rating'] = (isset($DIVXTAGrating[$parsed['rating_id']]) ? $DIVXTAGrating[$parsed['rating_id']] : $parsed['rating_id']);
|
1976 |
+
|
1977 |
+
if (!$raw) {
|
1978 |
+
unset($parsed['genre_id'], $parsed['rating_id']);
|
1979 |
+
foreach ($parsed as $key => $value) {
|
1980 |
+
if (!$value === '') {
|
1981 |
+
unset($parsed['key']);
|
1982 |
+
}
|
1983 |
+
}
|
1984 |
+
}
|
1985 |
+
|
1986 |
+
foreach ($parsed as $tag => $value) {
|
1987 |
+
$parsed[$tag] = array($value);
|
1988 |
+
}
|
1989 |
+
|
1990 |
+
return $parsed;
|
1991 |
+
}
|
1992 |
+
|
1993 |
+
public static function waveSNDMtagLookup($tagshortname) {
|
1994 |
+
$begin = __LINE__;
|
1995 |
+
|
1996 |
+
/** This is not a comment!
|
1997 |
+
|
1998 |
+
©kwd keywords
|
1999 |
+
©BPM bpm
|
2000 |
+
©trt tracktitle
|
2001 |
+
©des description
|
2002 |
+
©gen category
|
2003 |
+
©fin featuredinstrument
|
2004 |
+
©LID longid
|
2005 |
+
©bex bwdescription
|
2006 |
+
©pub publisher
|
2007 |
+
©cdt cdtitle
|
2008 |
+
©alb library
|
2009 |
+
©com composer
|
2010 |
+
|
2011 |
+
*/
|
2012 |
+
|
2013 |
+
return getid3_lib::EmbeddedLookup($tagshortname, $begin, __LINE__, __FILE__, 'riff-sndm');
|
2014 |
+
}
|
2015 |
+
|
2016 |
+
public static function wFormatTagLookup($wFormatTag) {
|
2017 |
+
|
2018 |
+
$begin = __LINE__;
|
2019 |
+
|
2020 |
+
/** This is not a comment!
|
2021 |
+
|
2022 |
+
0x0000 Microsoft Unknown Wave Format
|
2023 |
+
0x0001 Pulse Code Modulation (PCM)
|
2024 |
+
0x0002 Microsoft ADPCM
|
2025 |
+
0x0003 IEEE Float
|
2026 |
+
0x0004 Compaq Computer VSELP
|
2027 |
+
0x0005 IBM CVSD
|
2028 |
+
0x0006 Microsoft A-Law
|
2029 |
+
0x0007 Microsoft mu-Law
|
2030 |
+
0x0008 Microsoft DTS
|
2031 |
+
0x0010 OKI ADPCM
|
2032 |
+
0x0011 Intel DVI/IMA ADPCM
|
2033 |
+
0x0012 Videologic MediaSpace ADPCM
|
2034 |
+
0x0013 Sierra Semiconductor ADPCM
|
2035 |
+
0x0014 Antex Electronics G.723 ADPCM
|
2036 |
+
0x0015 DSP Solutions DigiSTD
|
2037 |
+
0x0016 DSP Solutions DigiFIX
|
2038 |
+
0x0017 Dialogic OKI ADPCM
|
2039 |
+
0x0018 MediaVision ADPCM
|
2040 |
+
0x0019 Hewlett-Packard CU
|
2041 |
+
0x0020 Yamaha ADPCM
|
2042 |
+
0x0021 Speech Compression Sonarc
|
2043 |
+
0x0022 DSP Group TrueSpeech
|
2044 |
+
0x0023 Echo Speech EchoSC1
|
2045 |
+
0x0024 Audiofile AF36
|
2046 |
+
0x0025 Audio Processing Technology APTX
|
2047 |
+
0x0026 AudioFile AF10
|
2048 |
+
0x0027 Prosody 1612
|
2049 |
+
0x0028 LRC
|
2050 |
+
0x0030 Dolby AC2
|
2051 |
+
0x0031 Microsoft GSM 6.10
|
2052 |
+
0x0032 MSNAudio
|
2053 |
+
0x0033 Antex Electronics ADPCME
|
2054 |
+
0x0034 Control Resources VQLPC
|
2055 |
+
0x0035 DSP Solutions DigiREAL
|
2056 |
+
0x0036 DSP Solutions DigiADPCM
|
2057 |
+
0x0037 Control Resources CR10
|
2058 |
+
0x0038 Natural MicroSystems VBXADPCM
|
2059 |
+
0x0039 Crystal Semiconductor IMA ADPCM
|
2060 |
+
0x003A EchoSC3
|
2061 |
+
0x003B Rockwell ADPCM
|
2062 |
+
0x003C Rockwell Digit LK
|
2063 |
+
0x003D Xebec
|
2064 |
+
0x0040 Antex Electronics G.721 ADPCM
|
2065 |
+
0x0041 G.728 CELP
|
2066 |
+
0x0042 MSG723
|
2067 |
+
0x0050 MPEG Layer-2 or Layer-1
|
2068 |
+
0x0052 RT24
|
2069 |
+
0x0053 PAC
|
2070 |
+
0x0055 MPEG Layer-3
|
2071 |
+
0x0059 Lucent G.723
|
2072 |
+
0x0060 Cirrus
|
2073 |
+
0x0061 ESPCM
|
2074 |
+
0x0062 Voxware
|
2075 |
+
0x0063 Canopus Atrac
|
2076 |
+
0x0064 G.726 ADPCM
|
2077 |
+
0x0065 G.722 ADPCM
|
2078 |
+
0x0066 DSAT
|
2079 |
+
0x0067 DSAT Display
|
2080 |
+
0x0069 Voxware Byte Aligned
|
2081 |
+
0x0070 Voxware AC8
|
2082 |
+
0x0071 Voxware AC10
|
2083 |
+
0x0072 Voxware AC16
|
2084 |
+
0x0073 Voxware AC20
|
2085 |
+
0x0074 Voxware MetaVoice
|
2086 |
+
0x0075 Voxware MetaSound
|
2087 |
+
0x0076 Voxware RT29HW
|
2088 |
+
0x0077 Voxware VR12
|
2089 |
+
0x0078 Voxware VR18
|
2090 |
+
0x0079 Voxware TQ40
|
2091 |
+
0x0080 Softsound
|
2092 |
+
0x0081 Voxware TQ60
|
2093 |
+
0x0082 MSRT24
|
2094 |
+
0x0083 G.729A
|
2095 |
+
0x0084 MVI MV12
|
2096 |
+
0x0085 DF G.726
|
2097 |
+
0x0086 DF GSM610
|
2098 |
+
0x0088 ISIAudio
|
2099 |
+
0x0089 Onlive
|
2100 |
+
0x0091 SBC24
|
2101 |
+
0x0092 Dolby AC3 SPDIF
|
2102 |
+
0x0093 MediaSonic G.723
|
2103 |
+
0x0094 Aculab PLC Prosody 8kbps
|
2104 |
+
0x0097 ZyXEL ADPCM
|
2105 |
+
0x0098 Philips LPCBB
|
2106 |
+
0x0099 Packed
|
2107 |
+
0x00FF AAC
|
2108 |
+
0x0100 Rhetorex ADPCM
|
2109 |
+
0x0101 IBM mu-law
|
2110 |
+
0x0102 IBM A-law
|
2111 |
+
0x0103 IBM AVC Adaptive Differential Pulse Code Modulation (ADPCM)
|
2112 |
+
0x0111 Vivo G.723
|
2113 |
+
0x0112 Vivo Siren
|
2114 |
+
0x0123 Digital G.723
|
2115 |
+
0x0125 Sanyo LD ADPCM
|
2116 |
+
0x0130 Sipro Lab Telecom ACELP NET
|
2117 |
+
0x0131 Sipro Lab Telecom ACELP 4800
|
2118 |
+
0x0132 Sipro Lab Telecom ACELP 8V3
|
2119 |
+
0x0133 Sipro Lab Telecom G.729
|
2120 |
+
0x0134 Sipro Lab Telecom G.729A
|
2121 |
+
0x0135 Sipro Lab Telecom Kelvin
|
2122 |
+
0x0140 Windows Media Video V8
|
2123 |
+
0x0150 Qualcomm PureVoice
|
2124 |
+
0x0151 Qualcomm HalfRate
|
2125 |
+
0x0155 Ring Zero Systems TUB GSM
|
2126 |
+
0x0160 Microsoft Audio 1
|
2127 |
+
0x0161 Windows Media Audio V7 / V8 / V9
|
2128 |
+
0x0162 Windows Media Audio Professional V9
|
2129 |
+
0x0163 Windows Media Audio Lossless V9
|
2130 |
+
0x0200 Creative Labs ADPCM
|
2131 |
+
0x0202 Creative Labs Fastspeech8
|
2132 |
+
0x0203 Creative Labs Fastspeech10
|
2133 |
+
0x0210 UHER Informatic GmbH ADPCM
|
2134 |
+
0x0220 Quarterdeck
|
2135 |
+
0x0230 I-link Worldwide VC
|
2136 |
+
0x0240 Aureal RAW Sport
|
2137 |
+
0x0250 Interactive Products HSX
|
2138 |
+
0x0251 Interactive Products RPELP
|
2139 |
+
0x0260 Consistent Software CS2
|
2140 |
+
0x0270 Sony SCX
|
2141 |
+
0x0300 Fujitsu FM Towns Snd
|
2142 |
+
0x0400 BTV Digital
|
2143 |
+
0x0401 Intel Music Coder
|
2144 |
+
0x0450 QDesign Music
|
2145 |
+
0x0680 VME VMPCM
|
2146 |
+
0x0681 AT&T Labs TPC
|
2147 |
+
0x08AE ClearJump LiteWave
|
2148 |
+
0x1000 Olivetti GSM
|
2149 |
+
0x1001 Olivetti ADPCM
|
2150 |
+
0x1002 Olivetti CELP
|
2151 |
+
0x1003 Olivetti SBC
|
2152 |
+
0x1004 Olivetti OPR
|
2153 |
+
0x1100 Lernout & Hauspie Codec (0x1100)
|
2154 |
+
0x1101 Lernout & Hauspie CELP Codec (0x1101)
|
2155 |
+
0x1102 Lernout & Hauspie SBC Codec (0x1102)
|
2156 |
+
0x1103 Lernout & Hauspie SBC Codec (0x1103)
|
2157 |
+
0x1104 Lernout & Hauspie SBC Codec (0x1104)
|
2158 |
+
0x1400 Norris
|
2159 |
+
0x1401 AT&T ISIAudio
|
2160 |
+
0x1500 Soundspace Music Compression
|
2161 |
+
0x181C VoxWare RT24 Speech
|
2162 |
+
0x1FC4 NCT Soft ALF2CD (www.nctsoft.com)
|
2163 |
+
0x2000 Dolby AC3
|
2164 |
+
0x2001 Dolby DTS
|
2165 |
+
0x2002 WAVE_FORMAT_14_4
|
2166 |
+
0x2003 WAVE_FORMAT_28_8
|
2167 |
+
0x2004 WAVE_FORMAT_COOK
|
2168 |
+
0x2005 WAVE_FORMAT_DNET
|
2169 |
+
0x674F Ogg Vorbis 1
|
2170 |
+
0x6750 Ogg Vorbis 2
|
2171 |
+
0x6751 Ogg Vorbis 3
|
2172 |
+
0x676F Ogg Vorbis 1+
|
2173 |
+
0x6770 Ogg Vorbis 2+
|
2174 |
+
0x6771 Ogg Vorbis 3+
|
2175 |
+
0x7A21 GSM-AMR (CBR, no SID)
|
2176 |
+
0x7A22 GSM-AMR (VBR, including SID)
|
2177 |
+
0xFFFE WAVE_FORMAT_EXTENSIBLE
|
2178 |
+
0xFFFF WAVE_FORMAT_DEVELOPMENT
|
2179 |
+
|
2180 |
+
*/
|
2181 |
+
|
2182 |
+
return getid3_lib::EmbeddedLookup('0x'.str_pad(strtoupper(dechex($wFormatTag)), 4, '0', STR_PAD_LEFT), $begin, __LINE__, __FILE__, 'riff-wFormatTag');
|
2183 |
+
}
|
2184 |
+
|
2185 |
+
public static function fourccLookup($fourcc) {
|
2186 |
+
|
2187 |
+
$begin = __LINE__;
|
2188 |
+
|
2189 |
+
/** This is not a comment!
|
2190 |
+
|
2191 |
+
swot http://developer.apple.com/qa/snd/snd07.html
|
2192 |
+
____ No Codec (____)
|
2193 |
+
_BIT BI_BITFIELDS (Raw RGB)
|
2194 |
+
_JPG JPEG compressed
|
2195 |
+
_PNG PNG compressed W3C/ISO/IEC (RFC-2083)
|
2196 |
+
_RAW Full Frames (Uncompressed)
|
2197 |
+
_RGB Raw RGB Bitmap
|
2198 |
+
_RL4 RLE 4bpp RGB
|
2199 |
+
_RL8 RLE 8bpp RGB
|
2200 |
+
3IV1 3ivx MPEG-4 v1
|
2201 |
+
3IV2 3ivx MPEG-4 v2
|
2202 |
+
3IVX 3ivx MPEG-4
|
2203 |
+
AASC Autodesk Animator
|
2204 |
+
ABYR Kensington ?ABYR?
|
2205 |
+
AEMI Array Microsystems VideoONE MPEG1-I Capture
|
2206 |
+
AFLC Autodesk Animator FLC
|
2207 |
+
AFLI Autodesk Animator FLI
|
2208 |
+
AMPG Array Microsystems VideoONE MPEG
|
2209 |
+
ANIM Intel RDX (ANIM)
|
2210 |
+
AP41 AngelPotion Definitive
|
2211 |
+
ASV1 Asus Video v1
|
2212 |
+
ASV2 Asus Video v2
|
2213 |
+
ASVX Asus Video 2.0 (audio)
|
2214 |
+
AUR2 AuraVision Aura 2 Codec - YUV 4:2:2
|
2215 |
+
AURA AuraVision Aura 1 Codec - YUV 4:1:1
|
2216 |
+
AVDJ Independent JPEG Group\'s codec (AVDJ)
|
2217 |
+
AVRN Independent JPEG Group\'s codec (AVRN)
|
2218 |
+
AYUV 4:4:4 YUV (AYUV)
|
2219 |
+
AZPR Quicktime Apple Video (AZPR)
|
2220 |
+
BGR Raw RGB32
|
2221 |
+
BLZ0 Blizzard DivX MPEG-4
|
2222 |
+
BTVC Conexant Composite Video
|
2223 |
+
BINK RAD Game Tools Bink Video
|
2224 |
+
BT20 Conexant Prosumer Video
|
2225 |
+
BTCV Conexant Composite Video Codec
|
2226 |
+
BW10 Data Translation Broadway MPEG Capture
|
2227 |
+
CC12 Intel YUV12
|
2228 |
+
CDVC Canopus DV
|
2229 |
+
CFCC Digital Processing Systems DPS Perception
|
2230 |
+
CGDI Microsoft Office 97 Camcorder Video
|
2231 |
+
CHAM Winnov Caviara Champagne
|
2232 |
+
CJPG Creative WebCam JPEG
|
2233 |
+
CLJR Cirrus Logic YUV 4:1:1
|
2234 |
+
CMYK Common Data Format in Printing (Colorgraph)
|
2235 |
+
CPLA Weitek 4:2:0 YUV Planar
|
2236 |
+
CRAM Microsoft Video 1 (CRAM)
|
2237 |
+
cvid Radius Cinepak
|
2238 |
+
CVID Radius Cinepak
|
2239 |
+
CWLT Microsoft Color WLT DIB
|
2240 |
+
CYUV Creative Labs YUV
|
2241 |
+
CYUY ATI YUV
|
2242 |
+
D261 H.261
|
2243 |
+
D263 H.263
|
2244 |
+
DIB Device Independent Bitmap
|
2245 |
+
DIV1 FFmpeg OpenDivX
|
2246 |
+
DIV2 Microsoft MPEG-4 v1/v2
|
2247 |
+
DIV3 DivX ;-) MPEG-4 v3.x Low-Motion
|
2248 |
+
DIV4 DivX ;-) MPEG-4 v3.x Fast-Motion
|
2249 |
+
DIV5 DivX MPEG-4 v5.x
|
2250 |
+
DIV6 DivX ;-) (MS MPEG-4 v3.x)
|
2251 |
+
DIVX DivX MPEG-4 v4 (OpenDivX / Project Mayo)
|
2252 |
+
divx DivX MPEG-4
|
2253 |
+
DMB1 Matrox Rainbow Runner hardware MJPEG
|
2254 |
+
DMB2 Paradigm MJPEG
|
2255 |
+
DSVD ?DSVD?
|
2256 |
+
DUCK Duck TrueMotion 1.0
|
2257 |
+
DPS0 DPS/Leitch Reality Motion JPEG
|
2258 |
+
DPSC DPS/Leitch PAR Motion JPEG
|
2259 |
+
DV25 Matrox DVCPRO codec
|
2260 |
+
DV50 Matrox DVCPRO50 codec
|
2261 |
+
DVC IEC 61834 and SMPTE 314M (DVC/DV Video)
|
2262 |
+
DVCP IEC 61834 and SMPTE 314M (DVC/DV Video)
|
2263 |
+
DVHD IEC Standard DV 1125 lines @ 30fps / 1250 lines @ 25fps
|
2264 |
+
DVMA Darim Vision DVMPEG (dummy for MPEG compressor) (www.darvision.com)
|
2265 |
+
DVSL IEC Standard DV compressed in SD (SDL)
|
2266 |
+
DVAN ?DVAN?
|
2267 |
+
DVE2 InSoft DVE-2 Videoconferencing
|
2268 |
+
dvsd IEC 61834 and SMPTE 314M DVC/DV Video
|
2269 |
+
DVSD IEC 61834 and SMPTE 314M DVC/DV Video
|
2270 |
+
DVX1 Lucent DVX1000SP Video Decoder
|
2271 |
+
DVX2 Lucent DVX2000S Video Decoder
|
2272 |
+
DVX3 Lucent DVX3000S Video Decoder
|
2273 |
+
DX50 DivX v5
|
2274 |
+
DXT1 Microsoft DirectX Compressed Texture (DXT1)
|
2275 |
+
DXT2 Microsoft DirectX Compressed Texture (DXT2)
|
2276 |
+
DXT3 Microsoft DirectX Compressed Texture (DXT3)
|
2277 |
+
DXT4 Microsoft DirectX Compressed Texture (DXT4)
|
2278 |
+
DXT5 Microsoft DirectX Compressed Texture (DXT5)
|
2279 |
+
DXTC Microsoft DirectX Compressed Texture (DXTC)
|
2280 |
+
DXTn Microsoft DirectX Compressed Texture (DXTn)
|
2281 |
+
EM2V Etymonix MPEG-2 I-frame (www.etymonix.com)
|
2282 |
+
EKQ0 Elsa ?EKQ0?
|
2283 |
+
ELK0 Elsa ?ELK0?
|
2284 |
+
ESCP Eidos Escape
|
2285 |
+
ETV1 eTreppid Video ETV1
|
2286 |
+
ETV2 eTreppid Video ETV2
|
2287 |
+
ETVC eTreppid Video ETVC
|
2288 |
+
FLIC Autodesk FLI/FLC Animation
|
2289 |
+
FLV1 Sorenson Spark
|
2290 |
+
FLV4 On2 TrueMotion VP6
|
2291 |
+
FRWT Darim Vision Forward Motion JPEG (www.darvision.com)
|
2292 |
+
FRWU Darim Vision Forward Uncompressed (www.darvision.com)
|
2293 |
+
FLJP D-Vision Field Encoded Motion JPEG
|
2294 |
+
FPS1 FRAPS v1
|
2295 |
+
FRWA SoftLab-Nsk Forward Motion JPEG w/ alpha channel
|
2296 |
+
FRWD SoftLab-Nsk Forward Motion JPEG
|
2297 |
+
FVF1 Iterated Systems Fractal Video Frame
|
2298 |
+
GLZW Motion LZW (gabest@freemail.hu)
|
2299 |
+
GPEG Motion JPEG (gabest@freemail.hu)
|
2300 |
+
GWLT Microsoft Greyscale WLT DIB
|
2301 |
+
H260 Intel ITU H.260 Videoconferencing
|
2302 |
+
H261 Intel ITU H.261 Videoconferencing
|
2303 |
+
H262 Intel ITU H.262 Videoconferencing
|
2304 |
+
H263 Intel ITU H.263 Videoconferencing
|
2305 |
+
H264 Intel ITU H.264 Videoconferencing
|
2306 |
+
H265 Intel ITU H.265 Videoconferencing
|
2307 |
+
H266 Intel ITU H.266 Videoconferencing
|
2308 |
+
H267 Intel ITU H.267 Videoconferencing
|
2309 |
+
H268 Intel ITU H.268 Videoconferencing
|
2310 |
+
H269 Intel ITU H.269 Videoconferencing
|
2311 |
+
HFYU Huffman Lossless Codec
|
2312 |
+
HMCR Rendition Motion Compensation Format (HMCR)
|
2313 |
+
HMRR Rendition Motion Compensation Format (HMRR)
|
2314 |
+
I263 FFmpeg I263 decoder
|
2315 |
+
IF09 Indeo YVU9 ("YVU9 with additional delta-frame info after the U plane")
|
2316 |
+
IUYV Interlaced version of UYVY (www.leadtools.com)
|
2317 |
+
IY41 Interlaced version of Y41P (www.leadtools.com)
|
2318 |
+
IYU1 12 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec IEEE standard
|
2319 |
+
IYU2 24 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec IEEE standard
|
2320 |
+
IYUV Planar YUV format (8-bpp Y plane, followed by 8-bpp 2×2 U and V planes)
|
2321 |
+
i263 Intel ITU H.263 Videoconferencing (i263)
|
2322 |
+
I420 Intel Indeo 4
|
2323 |
+
IAN Intel Indeo 4 (RDX)
|
2324 |
+
ICLB InSoft CellB Videoconferencing
|
2325 |
+
IGOR Power DVD
|
2326 |
+
IJPG Intergraph JPEG
|
2327 |
+
ILVC Intel Layered Video
|
2328 |
+
ILVR ITU-T H.263+
|
2329 |
+
IPDV I-O Data Device Giga AVI DV Codec
|
2330 |
+
IR21 Intel Indeo 2.1
|
2331 |
+
IRAW Intel YUV Uncompressed
|
2332 |
+
IV30 Intel Indeo 3.0
|
2333 |
+
IV31 Intel Indeo 3.1
|
2334 |
+
IV32 Ligos Indeo 3.2
|
2335 |
+
IV33 Ligos Indeo 3.3
|
2336 |
+
IV34 Ligos Indeo 3.4
|
2337 |
+
IV35 Ligos Indeo 3.5
|
2338 |
+
IV36 Ligos Indeo 3.6
|
2339 |
+
IV37 Ligos Indeo 3.7
|
2340 |
+
IV38 Ligos Indeo 3.8
|
2341 |
+
IV39 Ligos Indeo 3.9
|
2342 |
+
IV40 Ligos Indeo Interactive 4.0
|
2343 |
+
IV41 Ligos Indeo Interactive 4.1
|
2344 |
+
IV42 Ligos Indeo Interactive 4.2
|
2345 |
+
IV43 Ligos Indeo Interactive 4.3
|
2346 |
+
IV44 Ligos Indeo Interactive 4.4
|
2347 |
+
IV45 Ligos Indeo Interactive 4.5
|
2348 |
+
IV46 Ligos Indeo Interactive 4.6
|
2349 |
+
IV47 Ligos Indeo Interactive 4.7
|
2350 |
+
IV48 Ligos Indeo Interactive 4.8
|
2351 |
+
IV49 Ligos Indeo Interactive 4.9
|
2352 |
+
IV50 Ligos Indeo Interactive 5.0
|
2353 |
+
JBYR Kensington ?JBYR?
|
2354 |
+
JPEG Still Image JPEG DIB
|
2355 |
+
JPGL Pegasus Lossless Motion JPEG
|
2356 |
+
KMVC Team17 Software Karl Morton\'s Video Codec
|
2357 |
+
LSVM Vianet Lighting Strike Vmail (Streaming) (www.vianet.com)
|
2358 |
+
LEAD LEAD Video Codec
|
2359 |
+
Ljpg LEAD MJPEG Codec
|
2360 |
+
MDVD Alex MicroDVD Video (hacked MS MPEG-4) (www.tiasoft.de)
|
2361 |
+
MJPA Morgan Motion JPEG (MJPA) (www.morgan-multimedia.com)
|
2362 |
+
MJPB Morgan Motion JPEG (MJPB) (www.morgan-multimedia.com)
|
2363 |
+
MMES Matrox MPEG-2 I-frame
|
2364 |
+
MP2v Microsoft S-Mpeg 4 version 1 (MP2v)
|
2365 |
+
MP42 Microsoft S-Mpeg 4 version 2 (MP42)
|
2366 |
+
MP43 Microsoft S-Mpeg 4 version 3 (MP43)
|
2367 |
+
MP4S Microsoft S-Mpeg 4 version 3 (MP4S)
|
2368 |
+
MP4V FFmpeg MPEG-4
|
2369 |
+
MPG1 FFmpeg MPEG 1/2
|
2370 |
+
MPG2 FFmpeg MPEG 1/2
|
2371 |
+
MPG3 FFmpeg DivX ;-) (MS MPEG-4 v3)
|
2372 |
+
MPG4 Microsoft MPEG-4
|
2373 |
+
MPGI Sigma Designs MPEG
|
2374 |
+
MPNG PNG images decoder
|
2375 |
+
MSS1 Microsoft Windows Screen Video
|
2376 |
+
MSZH LCL (Lossless Codec Library) (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm)
|
2377 |
+
M261 Microsoft H.261
|
2378 |
+
M263 Microsoft H.263
|
2379 |
+
M4S2 Microsoft Fully Compliant MPEG-4 v2 simple profile (M4S2)
|
2380 |
+
m4s2 Microsoft Fully Compliant MPEG-4 v2 simple profile (m4s2)
|
2381 |
+
MC12 ATI Motion Compensation Format (MC12)
|
2382 |
+
MCAM ATI Motion Compensation Format (MCAM)
|
2383 |
+
MJ2C Morgan Multimedia Motion JPEG2000
|
2384 |
+
mJPG IBM Motion JPEG w/ Huffman Tables
|
2385 |
+
MJPG Microsoft Motion JPEG DIB
|
2386 |
+
MP42 Microsoft MPEG-4 (low-motion)
|
2387 |
+
MP43 Microsoft MPEG-4 (fast-motion)
|
2388 |
+
MP4S Microsoft MPEG-4 (MP4S)
|
2389 |
+
mp4s Microsoft MPEG-4 (mp4s)
|
2390 |
+
MPEG Chromatic Research MPEG-1 Video I-Frame
|
2391 |
+
MPG4 Microsoft MPEG-4 Video High Speed Compressor
|
2392 |
+
MPGI Sigma Designs MPEG
|
2393 |
+
MRCA FAST Multimedia Martin Regen Codec
|
2394 |
+
MRLE Microsoft Run Length Encoding
|
2395 |
+
MSVC Microsoft Video 1
|
2396 |
+
MTX1 Matrox ?MTX1?
|
2397 |
+
MTX2 Matrox ?MTX2?
|
2398 |
+
MTX3 Matrox ?MTX3?
|
2399 |
+
MTX4 Matrox ?MTX4?
|
2400 |
+
MTX5 Matrox ?MTX5?
|
2401 |
+
MTX6 Matrox ?MTX6?
|
2402 |
+
MTX7 Matrox ?MTX7?
|
2403 |
+
MTX8 Matrox ?MTX8?
|
2404 |
+
MTX9 Matrox ?MTX9?
|
2405 |
+
MV12 Motion Pixels Codec (old)
|
2406 |
+
MWV1 Aware Motion Wavelets
|
2407 |
+
nAVI SMR Codec (hack of Microsoft MPEG-4) (IRC #shadowrealm)
|
2408 |
+
NT00 NewTek LightWave HDTV YUV w/ Alpha (www.newtek.com)
|
2409 |
+
NUV1 NuppelVideo
|
2410 |
+
NTN1 Nogatech Video Compression 1
|
2411 |
+
NVS0 nVidia GeForce Texture (NVS0)
|
2412 |
+
NVS1 nVidia GeForce Texture (NVS1)
|
2413 |
+
NVS2 nVidia GeForce Texture (NVS2)
|
2414 |
+
NVS3 nVidia GeForce Texture (NVS3)
|
2415 |
+
NVS4 nVidia GeForce Texture (NVS4)
|
2416 |
+
NVS5 nVidia GeForce Texture (NVS5)
|
2417 |
+
NVT0 nVidia GeForce Texture (NVT0)
|
2418 |
+
NVT1 nVidia GeForce Texture (NVT1)
|
2419 |
+
NVT2 nVidia GeForce Texture (NVT2)
|
2420 |
+
NVT3 nVidia GeForce Texture (NVT3)
|
2421 |
+
NVT4 nVidia GeForce Texture (NVT4)
|
2422 |
+
NVT5 nVidia GeForce Texture (NVT5)
|
2423 |
+
PIXL MiroXL, Pinnacle PCTV
|
2424 |
+
PDVC I-O Data Device Digital Video Capture DV codec
|
2425 |
+
PGVV Radius Video Vision
|
2426 |
+
PHMO IBM Photomotion
|
2427 |
+
PIM1 MPEG Realtime (Pinnacle Cards)
|
2428 |
+
PIM2 Pegasus Imaging ?PIM2?
|
2429 |
+
PIMJ Pegasus Imaging Lossless JPEG
|
2430 |
+
PVEZ Horizons Technology PowerEZ
|
2431 |
+
PVMM PacketVideo Corporation MPEG-4
|
2432 |
+
PVW2 Pegasus Imaging Wavelet Compression
|
2433 |
+
Q1.0 Q-Team\'s QPEG 1.0 (www.q-team.de)
|
2434 |
+
Q1.1 Q-Team\'s QPEG 1.1 (www.q-team.de)
|
2435 |
+
QPEG Q-Team QPEG 1.0
|
2436 |
+
qpeq Q-Team QPEG 1.1
|
2437 |
+
RGB Raw BGR32
|
2438 |
+
RGBA Raw RGB w/ Alpha
|
2439 |
+
RMP4 REALmagic MPEG-4 (unauthorized XVID copy) (www.sigmadesigns.com)
|
2440 |
+
ROQV Id RoQ File Video Decoder
|
2441 |
+
RPZA Quicktime Apple Video (RPZA)
|
2442 |
+
RUD0 Rududu video codec (http://rududu.ifrance.com/rududu/)
|
2443 |
+
RV10 RealVideo 1.0 (aka RealVideo 5.0)
|
2444 |
+
RV13 RealVideo 1.0 (RV13)
|
2445 |
+
RV20 RealVideo G2
|
2446 |
+
RV30 RealVideo 8
|
2447 |
+
RV40 RealVideo 9
|
2448 |
+
RGBT Raw RGB w/ Transparency
|
2449 |
+
RLE Microsoft Run Length Encoder
|
2450 |
+
RLE4 Run Length Encoded (4bpp, 16-color)
|
2451 |
+
RLE8 Run Length Encoded (8bpp, 256-color)
|
2452 |
+
RT21 Intel Indeo RealTime Video 2.1
|
2453 |
+
rv20 RealVideo G2
|
2454 |
+
rv30 RealVideo 8
|
2455 |
+
RVX Intel RDX (RVX )
|
2456 |
+
SMC Apple Graphics (SMC )
|
2457 |
+
SP54 Logitech Sunplus Sp54 Codec for Mustek GSmart Mini 2
|
2458 |
+
SPIG Radius Spigot
|
2459 |
+
SVQ3 Sorenson Video 3 (Apple Quicktime 5)
|
2460 |
+
s422 Tekram VideoCap C210 YUV 4:2:2
|
2461 |
+
SDCC Sun Communication Digital Camera Codec
|
2462 |
+
SFMC CrystalNet Surface Fitting Method
|
2463 |
+
SMSC Radius SMSC
|
2464 |
+
SMSD Radius SMSD
|
2465 |
+
smsv WorldConnect Wavelet Video
|
2466 |
+
SPIG Radius Spigot
|
2467 |
+
SPLC Splash Studios ACM Audio Codec (www.splashstudios.net)
|
2468 |
+
SQZ2 Microsoft VXTreme Video Codec V2
|
2469 |
+
STVA ST Microelectronics CMOS Imager Data (Bayer)
|
2470 |
+
STVB ST Microelectronics CMOS Imager Data (Nudged Bayer)
|
2471 |
+
STVC ST Microelectronics CMOS Imager Data (Bunched)
|
2472 |
+
STVX ST Microelectronics CMOS Imager Data (Extended CODEC Data Format)
|
2473 |
+
STVY ST Microelectronics CMOS Imager Data (Extended CODEC Data Format with Correction Data)
|
2474 |
+
SV10 Sorenson Video R1
|
2475 |
+
SVQ1 Sorenson Video
|
2476 |
+
T420 Toshiba YUV 4:2:0
|
2477 |
+
TM2A Duck TrueMotion Archiver 2.0 (www.duck.com)
|
2478 |
+
TVJP Pinnacle/Truevision Targa 2000 board (TVJP)
|
2479 |
+
TVMJ Pinnacle/Truevision Targa 2000 board (TVMJ)
|
2480 |
+
TY0N Tecomac Low-Bit Rate Codec (www.tecomac.com)
|
2481 |
+
TY2C Trident Decompression Driver
|
2482 |
+
TLMS TeraLogic Motion Intraframe Codec (TLMS)
|
2483 |
+
TLST TeraLogic Motion Intraframe Codec (TLST)
|
2484 |
+
TM20 Duck TrueMotion 2.0
|
2485 |
+
TM2X Duck TrueMotion 2X
|
2486 |
+
TMIC TeraLogic Motion Intraframe Codec (TMIC)
|
2487 |
+
TMOT Horizons Technology TrueMotion S
|
2488 |
+
tmot Horizons TrueMotion Video Compression
|
2489 |
+
TR20 Duck TrueMotion RealTime 2.0
|
2490 |
+
TSCC TechSmith Screen Capture Codec
|
2491 |
+
TV10 Tecomac Low-Bit Rate Codec
|
2492 |
+
TY2N Trident ?TY2N?
|
2493 |
+
U263 UB Video H.263/H.263+/H.263++ Decoder
|
2494 |
+
UMP4 UB Video MPEG 4 (www.ubvideo.com)
|
2495 |
+
UYNV Nvidia UYVY packed 4:2:2
|
2496 |
+
UYVP Evans & Sutherland YCbCr 4:2:2 extended precision
|
2497 |
+
UCOD eMajix.com ClearVideo
|
2498 |
+
ULTI IBM Ultimotion
|
2499 |
+
UYVY UYVY packed 4:2:2
|
2500 |
+
V261 Lucent VX2000S
|
2501 |
+
VIFP VFAPI Reader Codec (www.yks.ne.jp/~hori/)
|
2502 |
+
VIV1 FFmpeg H263+ decoder
|
2503 |
+
VIV2 Vivo H.263
|
2504 |
+
VQC2 Vector-quantised codec 2 (research) http://eprints.ecs.soton.ac.uk/archive/00001310/01/VTC97-js.pdf)
|
2505 |
+
VTLP Alaris VideoGramPiX
|
2506 |
+
VYU9 ATI YUV (VYU9)
|
2507 |
+
VYUY ATI YUV (VYUY)
|
2508 |
+
V261 Lucent VX2000S
|
2509 |
+
V422 Vitec Multimedia 24-bit YUV 4:2:2 Format
|
2510 |
+
V655 Vitec Multimedia 16-bit YUV 4:2:2 Format
|
2511 |
+
VCR1 ATI Video Codec 1
|
2512 |
+
VCR2 ATI Video Codec 2
|
2513 |
+
VCR3 ATI VCR 3.0
|
2514 |
+
VCR4 ATI VCR 4.0
|
2515 |
+
VCR5 ATI VCR 5.0
|
2516 |
+
VCR6 ATI VCR 6.0
|
2517 |
+
VCR7 ATI VCR 7.0
|
2518 |
+
VCR8 ATI VCR 8.0
|
2519 |
+
VCR9 ATI VCR 9.0
|
2520 |
+
VDCT Vitec Multimedia Video Maker Pro DIB
|
2521 |
+
VDOM VDOnet VDOWave
|
2522 |
+
VDOW VDOnet VDOLive (H.263)
|
2523 |
+
VDTZ Darim Vison VideoTizer YUV
|
2524 |
+
VGPX Alaris VideoGramPiX
|
2525 |
+
VIDS Vitec Multimedia YUV 4:2:2 CCIR 601 for V422
|
2526 |
+
VIVO Vivo H.263 v2.00
|
2527 |
+
vivo Vivo H.263
|
2528 |
+
VIXL Miro/Pinnacle Video XL
|
2529 |
+
VLV1 VideoLogic/PURE Digital Videologic Capture
|
2530 |
+
VP30 On2 VP3.0
|
2531 |
+
VP31 On2 VP3.1
|
2532 |
+
VP6F On2 TrueMotion VP6
|
2533 |
+
VX1K Lucent VX1000S Video Codec
|
2534 |
+
VX2K Lucent VX2000S Video Codec
|
2535 |
+
VXSP Lucent VX1000SP Video Codec
|
2536 |
+
WBVC Winbond W9960
|
2537 |
+
WHAM Microsoft Video 1 (WHAM)
|
2538 |
+
WINX Winnov Software Compression
|
2539 |
+
WJPG AverMedia Winbond JPEG
|
2540 |
+
WMV1 Windows Media Video V7
|
2541 |
+
WMV2 Windows Media Video V8
|
2542 |
+
WMV3 Windows Media Video V9
|
2543 |
+
WNV1 Winnov Hardware Compression
|
2544 |
+
XYZP Extended PAL format XYZ palette (www.riff.org)
|
2545 |
+
x263 Xirlink H.263
|
2546 |
+
XLV0 NetXL Video Decoder
|
2547 |
+
XMPG Xing MPEG (I-Frame only)
|
2548 |
+
XVID XviD MPEG-4 (www.xvid.org)
|
2549 |
+
XXAN ?XXAN?
|
2550 |
+
YU92 Intel YUV (YU92)
|
2551 |
+
YUNV Nvidia Uncompressed YUV 4:2:2
|
2552 |
+
YUVP Extended PAL format YUV palette (www.riff.org)
|
2553 |
+
Y211 YUV 2:1:1 Packed
|
2554 |
+
Y411 YUV 4:1:1 Packed
|
2555 |
+
Y41B Weitek YUV 4:1:1 Planar
|
2556 |
+
Y41P Brooktree PC1 YUV 4:1:1 Packed
|
2557 |
+
Y41T Brooktree PC1 YUV 4:1:1 with transparency
|
2558 |
+
Y42B Weitek YUV 4:2:2 Planar
|
2559 |
+
Y42T Brooktree UYUV 4:2:2 with transparency
|
2560 |
+
Y422 ADS Technologies Copy of UYVY used in Pyro WebCam firewire camera
|
2561 |
+
Y800 Simple, single Y plane for monochrome images
|
2562 |
+
Y8 Grayscale video
|
2563 |
+
YC12 Intel YUV 12 codec
|
2564 |
+
YUV8 Winnov Caviar YUV8
|
2565 |
+
YUV9 Intel YUV9
|
2566 |
+
YUY2 Uncompressed YUV 4:2:2
|
2567 |
+
YUYV Canopus YUV
|
2568 |
+
YV12 YVU12 Planar
|
2569 |
+
YVU9 Intel YVU9 Planar (8-bpp Y plane, followed by 8-bpp 4x4 U and V planes)
|
2570 |
+
YVYU YVYU 4:2:2 Packed
|
2571 |
+
ZLIB Lossless Codec Library zlib compression (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm)
|
2572 |
+
ZPEG Metheus Video Zipper
|
2573 |
+
|
2574 |
+
*/
|
2575 |
+
|
2576 |
+
return getid3_lib::EmbeddedLookup($fourcc, $begin, __LINE__, __FILE__, 'riff-fourcc');
|
2577 |
+
}
|
2578 |
+
|
2579 |
+
private function EitherEndian2Int($byteword, $signed=false) {
|
2580 |
+
if ($this->container == 'riff') {
|
2581 |
+
return getid3_lib::LittleEndian2Int($byteword, $signed);
|
2582 |
+
}
|
2583 |
+
return getid3_lib::BigEndian2Int($byteword, false, $signed);
|
2584 |
+
}
|
2585 |
+
|
2586 |
+
}
|
getid3/module.audio.aac.php
CHANGED
@@ -1,515 +1,513 @@
|
|
1 |
-
<?php
|
2 |
-
/////////////////////////////////////////////////////////////////
|
3 |
-
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
-
// available at http://getid3.sourceforge.net //
|
5 |
-
// or http://www.getid3.org //
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
//
|
11 |
-
// module
|
12 |
-
//
|
13 |
-
//
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
$info
|
35 |
-
$info['
|
36 |
-
$info['audio']['
|
37 |
-
|
38 |
-
|
39 |
-
$
|
40 |
-
$
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
//
|
48 |
-
//
|
49 |
-
//
|
50 |
-
//
|
51 |
-
//
|
52 |
-
//
|
53 |
-
//
|
54 |
-
//
|
55 |
-
//
|
56 |
-
//
|
57 |
-
//
|
58 |
-
//
|
59 |
-
//
|
60 |
-
//
|
61 |
-
//
|
62 |
-
//
|
63 |
-
|
64 |
-
|
65 |
-
$
|
66 |
-
|
67 |
-
|
68 |
-
$
|
69 |
-
$
|
70 |
-
|
71 |
-
|
72 |
-
$bitoffset
|
73 |
-
|
74 |
-
|
75 |
-
$bitoffset
|
76 |
-
|
77 |
-
|
78 |
-
$bitoffset
|
79 |
-
$
|
80 |
-
$bitoffset
|
81 |
-
$
|
82 |
-
$bitoffset
|
83 |
-
|
84 |
-
|
85 |
-
$info['
|
86 |
-
$bitoffset
|
87 |
-
|
88 |
-
|
89 |
-
$info['
|
90 |
-
$bitoffset
|
91 |
-
$
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
$bitoffset
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
//
|
107 |
-
//
|
108 |
-
//
|
109 |
-
//
|
110 |
-
//
|
111 |
-
//
|
112 |
-
//
|
113 |
-
//
|
114 |
-
//
|
115 |
-
//
|
116 |
-
//
|
117 |
-
//
|
118 |
-
//
|
119 |
-
//
|
120 |
-
//
|
121 |
-
//
|
122 |
-
//
|
123 |
-
//
|
124 |
-
//
|
125 |
-
//
|
126 |
-
//
|
127 |
-
//
|
128 |
-
//
|
129 |
-
//
|
130 |
-
//
|
131 |
-
//
|
132 |
-
//
|
133 |
-
//
|
134 |
-
//
|
135 |
-
//
|
136 |
-
//
|
137 |
-
//
|
138 |
-
//
|
139 |
-
//
|
140 |
-
//
|
141 |
-
//
|
142 |
-
//
|
143 |
-
//
|
144 |
-
//
|
145 |
-
//
|
146 |
-
//
|
147 |
-
//
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
$bitoffset
|
152 |
-
|
153 |
-
|
154 |
-
$bitoffset
|
155 |
-
$
|
156 |
-
$bitoffset
|
157 |
-
$
|
158 |
-
$bitoffset
|
159 |
-
$
|
160 |
-
$bitoffset
|
161 |
-
$
|
162 |
-
$bitoffset
|
163 |
-
$
|
164 |
-
$bitoffset
|
165 |
-
$
|
166 |
-
$bitoffset
|
167 |
-
$
|
168 |
-
$bitoffset
|
169 |
-
$
|
170 |
-
$bitoffset
|
171 |
-
$
|
172 |
-
$bitoffset
|
173 |
-
|
174 |
-
|
175 |
-
$bitoffset
|
176 |
-
|
177 |
-
|
178 |
-
$bitoffset
|
179 |
-
|
180 |
-
|
181 |
-
$bitoffset
|
182 |
-
|
183 |
-
|
184 |
-
$bitoffset
|
185 |
-
|
186 |
-
|
187 |
-
$bitoffset
|
188 |
-
$
|
189 |
-
$bitoffset
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
$bitoffset
|
194 |
-
$
|
195 |
-
$bitoffset
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
$bitoffset
|
200 |
-
$
|
201 |
-
$bitoffset
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
$bitoffset
|
206 |
-
$
|
207 |
-
$bitoffset
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
$bitoffset
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
$bitoffset
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
$bitoffset
|
220 |
-
$
|
221 |
-
$bitoffset
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
$bitoffset
|
228 |
-
$
|
229 |
-
$bitoffset
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
$info['aac']['
|
234 |
-
$info['
|
235 |
-
$info['audio']['
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
unset($info['
|
252 |
-
$info['
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
//
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
// http://
|
269 |
-
|
270 |
-
|
271 |
-
//
|
272 |
-
//
|
273 |
-
//
|
274 |
-
//
|
275 |
-
//
|
276 |
-
//
|
277 |
-
//
|
278 |
-
//
|
279 |
-
//
|
280 |
-
//
|
281 |
-
//
|
282 |
-
|
283 |
-
|
284 |
-
//
|
285 |
-
//
|
286 |
-
//
|
287 |
-
//
|
288 |
-
//
|
289 |
-
|
290 |
-
|
291 |
-
//
|
292 |
-
|
293 |
-
|
294 |
-
$
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
//
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
$
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
$
|
328 |
-
$
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
//
|
335 |
-
//
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
$info['
|
344 |
-
$info['
|
345 |
-
|
346 |
-
|
347 |
-
$info['aac']['header']['raw']['
|
348 |
-
$info['aac']['header']['raw']['
|
349 |
-
|
350 |
-
|
351 |
-
$info['aac']['header']['raw']['
|
352 |
-
$info['aac']['header']['raw']['
|
353 |
-
$info['aac']['header']['raw']['
|
354 |
-
$info['aac']['header']['raw']['
|
355 |
-
$info['aac']['header']['raw']['
|
356 |
-
$info['aac']['header']['raw']['
|
357 |
-
$info['aac']['header']['raw']['
|
358 |
-
$info['aac']['header']['raw']['
|
359 |
-
|
360 |
-
|
361 |
-
$info['aac']['header']['
|
362 |
-
$info['aac']['header']['
|
363 |
-
$info['aac']['header']['
|
364 |
-
$info['aac']['header']['
|
365 |
-
$info['aac']['header']['
|
366 |
-
$info['aac']['header']['
|
367 |
-
$info['aac']['header']['
|
368 |
-
|
369 |
-
|
370 |
-
$info['aac'][$framenumber]['
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
$info['audio']['
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
$
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
$info['
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
$AACsampleRateLookup[
|
450 |
-
$AACsampleRateLookup[
|
451 |
-
$AACsampleRateLookup[
|
452 |
-
$AACsampleRateLookup[
|
453 |
-
$AACsampleRateLookup[
|
454 |
-
$AACsampleRateLookup[
|
455 |
-
$AACsampleRateLookup[
|
456 |
-
$AACsampleRateLookup[
|
457 |
-
$AACsampleRateLookup[
|
458 |
-
$AACsampleRateLookup[
|
459 |
-
$AACsampleRateLookup[
|
460 |
-
$AACsampleRateLookup[
|
461 |
-
$AACsampleRateLookup[
|
462 |
-
$AACsampleRateLookup[
|
463 |
-
$AACsampleRateLookup[
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
$AACprofileLookup[2][
|
473 |
-
$AACprofileLookup[2][
|
474 |
-
$AACprofileLookup[2][
|
475 |
-
$AACprofileLookup[
|
476 |
-
$AACprofileLookup[4][
|
477 |
-
$AACprofileLookup[4][
|
478 |
-
$AACprofileLookup[4][
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
?>
|
1 |
+
<?php
|
2 |
+
/////////////////////////////////////////////////////////////////
|
3 |
+
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
+
// available at http://getid3.sourceforge.net //
|
5 |
+
// or http://www.getid3.org //
|
6 |
+
// also https://github.com/JamesHeinrich/getID3 //
|
7 |
+
/////////////////////////////////////////////////////////////////
|
8 |
+
// See readme.txt for more details //
|
9 |
+
/////////////////////////////////////////////////////////////////
|
10 |
+
// //
|
11 |
+
// module.audio.aac.php //
|
12 |
+
// module for analyzing AAC Audio files //
|
13 |
+
// dependencies: NONE //
|
14 |
+
// ///
|
15 |
+
/////////////////////////////////////////////////////////////////
|
16 |
+
|
17 |
+
|
18 |
+
class getid3_aac extends getid3_handler
|
19 |
+
{
|
20 |
+
public function Analyze() {
|
21 |
+
$info = &$this->getid3->info;
|
22 |
+
$this->fseek($info['avdataoffset']);
|
23 |
+
if ($this->fread(4) == 'ADIF') {
|
24 |
+
$this->getAACADIFheaderFilepointer();
|
25 |
+
} else {
|
26 |
+
$this->getAACADTSheaderFilepointer();
|
27 |
+
}
|
28 |
+
return true;
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
public function getAACADIFheaderFilepointer() {
|
34 |
+
$info = &$this->getid3->info;
|
35 |
+
$info['fileformat'] = 'aac';
|
36 |
+
$info['audio']['dataformat'] = 'aac';
|
37 |
+
$info['audio']['lossless'] = false;
|
38 |
+
|
39 |
+
$this->fseek($info['avdataoffset']);
|
40 |
+
$AACheader = $this->fread(1024);
|
41 |
+
$offset = 0;
|
42 |
+
|
43 |
+
if (substr($AACheader, 0, 4) == 'ADIF') {
|
44 |
+
|
45 |
+
// http://faac.sourceforge.net/wiki/index.php?page=ADIF
|
46 |
+
|
47 |
+
// http://libmpeg.org/mpeg4/doc/w2203tfs.pdf
|
48 |
+
// adif_header() {
|
49 |
+
// adif_id 32
|
50 |
+
// copyright_id_present 1
|
51 |
+
// if( copyright_id_present )
|
52 |
+
// copyright_id 72
|
53 |
+
// original_copy 1
|
54 |
+
// home 1
|
55 |
+
// bitstream_type 1
|
56 |
+
// bitrate 23
|
57 |
+
// num_program_config_elements 4
|
58 |
+
// for (i = 0; i < num_program_config_elements + 1; i++ ) {
|
59 |
+
// if( bitstream_type == '0' )
|
60 |
+
// adif_buffer_fullness 20
|
61 |
+
// program_config_element()
|
62 |
+
// }
|
63 |
+
// }
|
64 |
+
|
65 |
+
$AACheaderBitstream = getid3_lib::BigEndian2Bin($AACheader);
|
66 |
+
$bitoffset = 0;
|
67 |
+
|
68 |
+
$info['aac']['header_type'] = 'ADIF';
|
69 |
+
$bitoffset += 32;
|
70 |
+
$info['aac']['header']['mpeg_version'] = 4;
|
71 |
+
|
72 |
+
$info['aac']['header']['copyright'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
|
73 |
+
$bitoffset += 1;
|
74 |
+
if ($info['aac']['header']['copyright']) {
|
75 |
+
$info['aac']['header']['copyright_id'] = getid3_lib::Bin2String(substr($AACheaderBitstream, $bitoffset, 72));
|
76 |
+
$bitoffset += 72;
|
77 |
+
}
|
78 |
+
$info['aac']['header']['original_copy'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
|
79 |
+
$bitoffset += 1;
|
80 |
+
$info['aac']['header']['home'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
|
81 |
+
$bitoffset += 1;
|
82 |
+
$info['aac']['header']['is_vbr'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) == '1');
|
83 |
+
$bitoffset += 1;
|
84 |
+
if ($info['aac']['header']['is_vbr']) {
|
85 |
+
$info['audio']['bitrate_mode'] = 'vbr';
|
86 |
+
$info['aac']['header']['bitrate_max'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 23));
|
87 |
+
$bitoffset += 23;
|
88 |
+
} else {
|
89 |
+
$info['audio']['bitrate_mode'] = 'cbr';
|
90 |
+
$info['aac']['header']['bitrate'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 23));
|
91 |
+
$bitoffset += 23;
|
92 |
+
$info['audio']['bitrate'] = $info['aac']['header']['bitrate'];
|
93 |
+
}
|
94 |
+
if ($info['audio']['bitrate'] == 0) {
|
95 |
+
$info['error'][] = 'Corrupt AAC file: bitrate_audio == zero';
|
96 |
+
return false;
|
97 |
+
}
|
98 |
+
$info['aac']['header']['num_program_configs'] = 1 + getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
99 |
+
$bitoffset += 4;
|
100 |
+
|
101 |
+
for ($i = 0; $i < $info['aac']['header']['num_program_configs']; $i++) {
|
102 |
+
// http://www.audiocoding.com/wiki/index.php?page=program_config_element
|
103 |
+
|
104 |
+
// buffer_fullness 20
|
105 |
+
|
106 |
+
// element_instance_tag 4
|
107 |
+
// object_type 2
|
108 |
+
// sampling_frequency_index 4
|
109 |
+
// num_front_channel_elements 4
|
110 |
+
// num_side_channel_elements 4
|
111 |
+
// num_back_channel_elements 4
|
112 |
+
// num_lfe_channel_elements 2
|
113 |
+
// num_assoc_data_elements 3
|
114 |
+
// num_valid_cc_elements 4
|
115 |
+
// mono_mixdown_present 1
|
116 |
+
// mono_mixdown_element_number 4 if mono_mixdown_present == 1
|
117 |
+
// stereo_mixdown_present 1
|
118 |
+
// stereo_mixdown_element_number 4 if stereo_mixdown_present == 1
|
119 |
+
// matrix_mixdown_idx_present 1
|
120 |
+
// matrix_mixdown_idx 2 if matrix_mixdown_idx_present == 1
|
121 |
+
// pseudo_surround_enable 1 if matrix_mixdown_idx_present == 1
|
122 |
+
// for (i = 0; i < num_front_channel_elements; i++) {
|
123 |
+
// front_element_is_cpe[i] 1
|
124 |
+
// front_element_tag_select[i] 4
|
125 |
+
// }
|
126 |
+
// for (i = 0; i < num_side_channel_elements; i++) {
|
127 |
+
// side_element_is_cpe[i] 1
|
128 |
+
// side_element_tag_select[i] 4
|
129 |
+
// }
|
130 |
+
// for (i = 0; i < num_back_channel_elements; i++) {
|
131 |
+
// back_element_is_cpe[i] 1
|
132 |
+
// back_element_tag_select[i] 4
|
133 |
+
// }
|
134 |
+
// for (i = 0; i < num_lfe_channel_elements; i++) {
|
135 |
+
// lfe_element_tag_select[i] 4
|
136 |
+
// }
|
137 |
+
// for (i = 0; i < num_assoc_data_elements; i++) {
|
138 |
+
// assoc_data_element_tag_select[i] 4
|
139 |
+
// }
|
140 |
+
// for (i = 0; i < num_valid_cc_elements; i++) {
|
141 |
+
// cc_element_is_ind_sw[i] 1
|
142 |
+
// valid_cc_element_tag_select[i] 4
|
143 |
+
// }
|
144 |
+
// byte_alignment() VAR
|
145 |
+
// comment_field_bytes 8
|
146 |
+
// for (i = 0; i < comment_field_bytes; i++) {
|
147 |
+
// comment_field_data[i] 8
|
148 |
+
// }
|
149 |
+
|
150 |
+
if (!$info['aac']['header']['is_vbr']) {
|
151 |
+
$info['aac']['program_configs'][$i]['buffer_fullness'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 20));
|
152 |
+
$bitoffset += 20;
|
153 |
+
}
|
154 |
+
$info['aac']['program_configs'][$i]['element_instance_tag'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
155 |
+
$bitoffset += 4;
|
156 |
+
$info['aac']['program_configs'][$i]['object_type'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
|
157 |
+
$bitoffset += 2;
|
158 |
+
$info['aac']['program_configs'][$i]['sampling_frequency_index'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
159 |
+
$bitoffset += 4;
|
160 |
+
$info['aac']['program_configs'][$i]['num_front_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
161 |
+
$bitoffset += 4;
|
162 |
+
$info['aac']['program_configs'][$i]['num_side_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
163 |
+
$bitoffset += 4;
|
164 |
+
$info['aac']['program_configs'][$i]['num_back_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
165 |
+
$bitoffset += 4;
|
166 |
+
$info['aac']['program_configs'][$i]['num_lfe_channel_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
|
167 |
+
$bitoffset += 2;
|
168 |
+
$info['aac']['program_configs'][$i]['num_assoc_data_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 3));
|
169 |
+
$bitoffset += 3;
|
170 |
+
$info['aac']['program_configs'][$i]['num_valid_cc_elements'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
171 |
+
$bitoffset += 4;
|
172 |
+
$info['aac']['program_configs'][$i]['mono_mixdown_present'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
|
173 |
+
$bitoffset += 1;
|
174 |
+
if ($info['aac']['program_configs'][$i]['mono_mixdown_present']) {
|
175 |
+
$info['aac']['program_configs'][$i]['mono_mixdown_element_number'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
176 |
+
$bitoffset += 4;
|
177 |
+
}
|
178 |
+
$info['aac']['program_configs'][$i]['stereo_mixdown_present'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
|
179 |
+
$bitoffset += 1;
|
180 |
+
if ($info['aac']['program_configs'][$i]['stereo_mixdown_present']) {
|
181 |
+
$info['aac']['program_configs'][$i]['stereo_mixdown_element_number'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
182 |
+
$bitoffset += 4;
|
183 |
+
}
|
184 |
+
$info['aac']['program_configs'][$i]['matrix_mixdown_idx_present'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
|
185 |
+
$bitoffset += 1;
|
186 |
+
if ($info['aac']['program_configs'][$i]['matrix_mixdown_idx_present']) {
|
187 |
+
$info['aac']['program_configs'][$i]['matrix_mixdown_idx'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
|
188 |
+
$bitoffset += 2;
|
189 |
+
$info['aac']['program_configs'][$i]['pseudo_surround_enable'] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
|
190 |
+
$bitoffset += 1;
|
191 |
+
}
|
192 |
+
for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_front_channel_elements']; $j++) {
|
193 |
+
$info['aac']['program_configs'][$i]['front_element_is_cpe'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
|
194 |
+
$bitoffset += 1;
|
195 |
+
$info['aac']['program_configs'][$i]['front_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
196 |
+
$bitoffset += 4;
|
197 |
+
}
|
198 |
+
for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_side_channel_elements']; $j++) {
|
199 |
+
$info['aac']['program_configs'][$i]['side_element_is_cpe'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
|
200 |
+
$bitoffset += 1;
|
201 |
+
$info['aac']['program_configs'][$i]['side_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
202 |
+
$bitoffset += 4;
|
203 |
+
}
|
204 |
+
for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_back_channel_elements']; $j++) {
|
205 |
+
$info['aac']['program_configs'][$i]['back_element_is_cpe'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
|
206 |
+
$bitoffset += 1;
|
207 |
+
$info['aac']['program_configs'][$i]['back_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
208 |
+
$bitoffset += 4;
|
209 |
+
}
|
210 |
+
for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_lfe_channel_elements']; $j++) {
|
211 |
+
$info['aac']['program_configs'][$i]['lfe_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
212 |
+
$bitoffset += 4;
|
213 |
+
}
|
214 |
+
for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_assoc_data_elements']; $j++) {
|
215 |
+
$info['aac']['program_configs'][$i]['assoc_data_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
216 |
+
$bitoffset += 4;
|
217 |
+
}
|
218 |
+
for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_valid_cc_elements']; $j++) {
|
219 |
+
$info['aac']['program_configs'][$i]['cc_element_is_ind_sw'][$j] = (bool) getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
|
220 |
+
$bitoffset += 1;
|
221 |
+
$info['aac']['program_configs'][$i]['valid_cc_element_tag_select'][$j] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
|
222 |
+
$bitoffset += 4;
|
223 |
+
}
|
224 |
+
|
225 |
+
$bitoffset = ceil($bitoffset / 8) * 8;
|
226 |
+
|
227 |
+
$info['aac']['program_configs'][$i]['comment_field_bytes'] = getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 8));
|
228 |
+
$bitoffset += 8;
|
229 |
+
$info['aac']['program_configs'][$i]['comment_field'] = getid3_lib::Bin2String(substr($AACheaderBitstream, $bitoffset, 8 * $info['aac']['program_configs'][$i]['comment_field_bytes']));
|
230 |
+
$bitoffset += 8 * $info['aac']['program_configs'][$i]['comment_field_bytes'];
|
231 |
+
|
232 |
+
|
233 |
+
$info['aac']['header']['profile'] = self::AACprofileLookup($info['aac']['program_configs'][$i]['object_type'], $info['aac']['header']['mpeg_version']);
|
234 |
+
$info['aac']['program_configs'][$i]['sampling_frequency'] = self::AACsampleRateLookup($info['aac']['program_configs'][$i]['sampling_frequency_index']);
|
235 |
+
$info['audio']['sample_rate'] = $info['aac']['program_configs'][$i]['sampling_frequency'];
|
236 |
+
$info['audio']['channels'] = self::AACchannelCountCalculate($info['aac']['program_configs'][$i]);
|
237 |
+
if ($info['aac']['program_configs'][$i]['comment_field']) {
|
238 |
+
$info['aac']['comments'][] = $info['aac']['program_configs'][$i]['comment_field'];
|
239 |
+
}
|
240 |
+
}
|
241 |
+
$info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['audio']['bitrate'];
|
242 |
+
|
243 |
+
$info['audio']['encoder_options'] = $info['aac']['header_type'].' '.$info['aac']['header']['profile'];
|
244 |
+
|
245 |
+
|
246 |
+
|
247 |
+
return true;
|
248 |
+
|
249 |
+
} else {
|
250 |
+
|
251 |
+
unset($info['fileformat']);
|
252 |
+
unset($info['aac']);
|
253 |
+
$info['error'][] = 'AAC-ADIF synch not found at offset '.$info['avdataoffset'].' (expected "ADIF", found "'.substr($AACheader, 0, 4).'" instead)';
|
254 |
+
return false;
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
|
261 |
+
public function getAACADTSheaderFilepointer($MaxFramesToScan=1000000, $ReturnExtendedInfo=false) {
|
262 |
+
$info = &$this->getid3->info;
|
263 |
+
|
264 |
+
// based loosely on code from AACfile by Jurgen Faul <jfaulØgmx.de>
|
265 |
+
// http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
|
266 |
+
|
267 |
+
|
268 |
+
// http://faac.sourceforge.net/wiki/index.php?page=ADTS // dead link
|
269 |
+
// http://wiki.multimedia.cx/index.php?title=ADTS
|
270 |
+
|
271 |
+
// * ADTS Fixed Header: these don't change from frame to frame
|
272 |
+
// syncword 12 always: '111111111111'
|
273 |
+
// ID 1 0: MPEG-4, 1: MPEG-2
|
274 |
+
// MPEG layer 2 If you send AAC in MPEG-TS, set to 0
|
275 |
+
// protection_absent 1 0: CRC present; 1: no CRC
|
276 |
+
// profile 2 0: AAC Main; 1: AAC LC (Low Complexity); 2: AAC SSR (Scalable Sample Rate); 3: AAC LTP (Long Term Prediction)
|
277 |
+
// sampling_frequency_index 4 15 not allowed
|
278 |
+
// private_bit 1 usually 0
|
279 |
+
// channel_configuration 3
|
280 |
+
// original/copy 1 0: original; 1: copy
|
281 |
+
// home 1 usually 0
|
282 |
+
// emphasis 2 only if ID == 0 (ie MPEG-4) // not present in some documentation?
|
283 |
+
|
284 |
+
// * ADTS Variable Header: these can change from frame to frame
|
285 |
+
// copyright_identification_bit 1
|
286 |
+
// copyright_identification_start 1
|
287 |
+
// aac_frame_length 13 length of the frame including header (in bytes)
|
288 |
+
// adts_buffer_fullness 11 0x7FF indicates VBR
|
289 |
+
// no_raw_data_blocks_in_frame 2
|
290 |
+
|
291 |
+
// * ADTS Error check
|
292 |
+
// crc_check 16 only if protection_absent == 0
|
293 |
+
|
294 |
+
$byteoffset = $info['avdataoffset'];
|
295 |
+
$framenumber = 0;
|
296 |
+
|
297 |
+
// Init bit pattern array
|
298 |
+
static $decbin = array();
|
299 |
+
|
300 |
+
// Populate $bindec
|
301 |
+
for ($i = 0; $i < 256; $i++) {
|
302 |
+
$decbin[chr($i)] = str_pad(decbin($i), 8, '0', STR_PAD_LEFT);
|
303 |
+
}
|
304 |
+
|
305 |
+
// used to calculate bitrate below
|
306 |
+
$BitrateCache = array();
|
307 |
+
|
308 |
+
|
309 |
+
while (true) {
|
310 |
+
// breaks out when end-of-file encountered, or invalid data found,
|
311 |
+
// or MaxFramesToScan frames have been scanned
|
312 |
+
|
313 |
+
if (!getid3_lib::intValueSupported($byteoffset)) {
|
314 |
+
$info['warning'][] = 'Unable to parse AAC file beyond '.$this->ftell().' (PHP does not support file operations beyond '.round(PHP_INT_MAX / 1073741824).'GB)';
|
315 |
+
return false;
|
316 |
+
}
|
317 |
+
$this->fseek($byteoffset);
|
318 |
+
|
319 |
+
// First get substring
|
320 |
+
$substring = $this->fread(9); // header is 7 bytes (or 9 if CRC is present)
|
321 |
+
$substringlength = strlen($substring);
|
322 |
+
if ($substringlength != 9) {
|
323 |
+
$info['error'][] = 'Failed to read 7 bytes at offset '.($this->ftell() - $substringlength).' (only read '.$substringlength.' bytes)';
|
324 |
+
return false;
|
325 |
+
}
|
326 |
+
// this would be easier with 64-bit math, but split it up to allow for 32-bit:
|
327 |
+
$header1 = getid3_lib::BigEndian2Int(substr($substring, 0, 2));
|
328 |
+
$header2 = getid3_lib::BigEndian2Int(substr($substring, 2, 4));
|
329 |
+
$header3 = getid3_lib::BigEndian2Int(substr($substring, 6, 1));
|
330 |
+
|
331 |
+
$info['aac']['header']['raw']['syncword'] = ($header1 & 0xFFF0) >> 4;
|
332 |
+
if ($info['aac']['header']['raw']['syncword'] != 0x0FFF) {
|
333 |
+
$info['error'][] = 'Synch pattern (0x0FFF) not found at offset '.($this->ftell() - $substringlength).' (found 0x0'.strtoupper(dechex($info['aac']['header']['raw']['syncword'])).' instead)';
|
334 |
+
//if ($info['fileformat'] == 'aac') {
|
335 |
+
// return true;
|
336 |
+
//}
|
337 |
+
unset($info['aac']);
|
338 |
+
return false;
|
339 |
+
}
|
340 |
+
|
341 |
+
// Gather info for first frame only - this takes time to do 1000 times!
|
342 |
+
if ($framenumber == 0) {
|
343 |
+
$info['aac']['header_type'] = 'ADTS';
|
344 |
+
$info['fileformat'] = 'aac';
|
345 |
+
$info['audio']['dataformat'] = 'aac';
|
346 |
+
|
347 |
+
$info['aac']['header']['raw']['mpeg_version'] = ($header1 & 0x0008) >> 3;
|
348 |
+
$info['aac']['header']['raw']['mpeg_layer'] = ($header1 & 0x0006) >> 1;
|
349 |
+
$info['aac']['header']['raw']['protection_absent'] = ($header1 & 0x0001) >> 0;
|
350 |
+
|
351 |
+
$info['aac']['header']['raw']['profile_code'] = ($header2 & 0xC0000000) >> 30;
|
352 |
+
$info['aac']['header']['raw']['sample_rate_code'] = ($header2 & 0x3C000000) >> 26;
|
353 |
+
$info['aac']['header']['raw']['private_stream'] = ($header2 & 0x02000000) >> 25;
|
354 |
+
$info['aac']['header']['raw']['channels_code'] = ($header2 & 0x01C00000) >> 22;
|
355 |
+
$info['aac']['header']['raw']['original'] = ($header2 & 0x00200000) >> 21;
|
356 |
+
$info['aac']['header']['raw']['home'] = ($header2 & 0x00100000) >> 20;
|
357 |
+
$info['aac']['header']['raw']['copyright_stream'] = ($header2 & 0x00080000) >> 19;
|
358 |
+
$info['aac']['header']['raw']['copyright_start'] = ($header2 & 0x00040000) >> 18;
|
359 |
+
$info['aac']['header']['raw']['frame_length'] = ($header2 & 0x0003FFE0) >> 5;
|
360 |
+
|
361 |
+
$info['aac']['header']['mpeg_version'] = ($info['aac']['header']['raw']['mpeg_version'] ? 2 : 4);
|
362 |
+
$info['aac']['header']['crc_present'] = ($info['aac']['header']['raw']['protection_absent'] ? false: true);
|
363 |
+
$info['aac']['header']['profile'] = self::AACprofileLookup($info['aac']['header']['raw']['profile_code'], $info['aac']['header']['mpeg_version']);
|
364 |
+
$info['aac']['header']['sample_frequency'] = self::AACsampleRateLookup($info['aac']['header']['raw']['sample_rate_code']);
|
365 |
+
$info['aac']['header']['private'] = (bool) $info['aac']['header']['raw']['private_stream'];
|
366 |
+
$info['aac']['header']['original'] = (bool) $info['aac']['header']['raw']['original'];
|
367 |
+
$info['aac']['header']['home'] = (bool) $info['aac']['header']['raw']['home'];
|
368 |
+
$info['aac']['header']['channels'] = (($info['aac']['header']['raw']['channels_code'] == 7) ? 8 : $info['aac']['header']['raw']['channels_code']);
|
369 |
+
if ($ReturnExtendedInfo) {
|
370 |
+
$info['aac'][$framenumber]['copyright_id_bit'] = (bool) $info['aac']['header']['raw']['copyright_stream'];
|
371 |
+
$info['aac'][$framenumber]['copyright_id_start'] = (bool) $info['aac']['header']['raw']['copyright_start'];
|
372 |
+
}
|
373 |
+
|
374 |
+
if ($info['aac']['header']['raw']['mpeg_layer'] != 0) {
|
375 |
+
$info['warning'][] = 'Layer error - expected "0", found "'.$info['aac']['header']['raw']['mpeg_layer'].'" instead';
|
376 |
+
}
|
377 |
+
if ($info['aac']['header']['sample_frequency'] == 0) {
|
378 |
+
$info['error'][] = 'Corrupt AAC file: sample_frequency == zero';
|
379 |
+
return false;
|
380 |
+
}
|
381 |
+
|
382 |
+
$info['audio']['sample_rate'] = $info['aac']['header']['sample_frequency'];
|
383 |
+
$info['audio']['channels'] = $info['aac']['header']['channels'];
|
384 |
+
}
|
385 |
+
|
386 |
+
$FrameLength = ($header2 & 0x0003FFE0) >> 5;
|
387 |
+
|
388 |
+
if (!isset($BitrateCache[$FrameLength])) {
|
389 |
+
$BitrateCache[$FrameLength] = ($info['aac']['header']['sample_frequency'] / 1024) * $FrameLength * 8;
|
390 |
+
}
|
391 |
+
getid3_lib::safe_inc($info['aac']['bitrate_distribution'][$BitrateCache[$FrameLength]], 1);
|
392 |
+
|
393 |
+
$info['aac'][$framenumber]['aac_frame_length'] = $FrameLength;
|
394 |
+
|
395 |
+
$info['aac'][$framenumber]['adts_buffer_fullness'] = (($header2 & 0x0000001F) << 6) & (($header3 & 0xFC) >> 2);
|
396 |
+
if ($info['aac'][$framenumber]['adts_buffer_fullness'] == 0x07FF) {
|
397 |
+
$info['audio']['bitrate_mode'] = 'vbr';
|
398 |
+
} else {
|
399 |
+
$info['audio']['bitrate_mode'] = 'cbr';
|
400 |
+
}
|
401 |
+
$info['aac'][$framenumber]['num_raw_data_blocks'] = (($header3 & 0x03) >> 0);
|
402 |
+
|
403 |
+
if ($info['aac']['header']['crc_present']) {
|
404 |
+
//$info['aac'][$framenumber]['crc'] = getid3_lib::BigEndian2Int(substr($substring, 7, 2);
|
405 |
+
}
|
406 |
+
|
407 |
+
if (!$ReturnExtendedInfo) {
|
408 |
+
unset($info['aac'][$framenumber]);
|
409 |
+
}
|
410 |
+
|
411 |
+
/*
|
412 |
+
$rounded_precision = 5000;
|
413 |
+
$info['aac']['bitrate_distribution_rounded'] = array();
|
414 |
+
foreach ($info['aac']['bitrate_distribution'] as $bitrate => $count) {
|
415 |
+
$rounded_bitrate = round($bitrate / $rounded_precision) * $rounded_precision;
|
416 |
+
getid3_lib::safe_inc($info['aac']['bitrate_distribution_rounded'][$rounded_bitrate], $count);
|
417 |
+
}
|
418 |
+
ksort($info['aac']['bitrate_distribution_rounded']);
|
419 |
+
*/
|
420 |
+
|
421 |
+
$byteoffset += $FrameLength;
|
422 |
+
if ((++$framenumber < $MaxFramesToScan) && (($byteoffset + 10) < $info['avdataend'])) {
|
423 |
+
|
424 |
+
// keep scanning
|
425 |
+
|
426 |
+
} else {
|
427 |
+
|
428 |
+
$info['aac']['frames'] = $framenumber;
|
429 |
+
$info['playtime_seconds'] = ($info['avdataend'] / $byteoffset) * (($framenumber * 1024) / $info['aac']['header']['sample_frequency']); // (1 / % of file scanned) * (samples / (samples/sec)) = seconds
|
430 |
+
if ($info['playtime_seconds'] == 0) {
|
431 |
+
$info['error'][] = 'Corrupt AAC file: playtime_seconds == zero';
|
432 |
+
return false;
|
433 |
+
}
|
434 |
+
$info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
|
435 |
+
ksort($info['aac']['bitrate_distribution']);
|
436 |
+
|
437 |
+
$info['audio']['encoder_options'] = $info['aac']['header_type'].' '.$info['aac']['header']['profile'];
|
438 |
+
|
439 |
+
return true;
|
440 |
+
|
441 |
+
}
|
442 |
+
}
|
443 |
+
// should never get here.
|
444 |
+
}
|
445 |
+
|
446 |
+
public static function AACsampleRateLookup($samplerateid) {
|
447 |
+
static $AACsampleRateLookup = array();
|
448 |
+
if (empty($AACsampleRateLookup)) {
|
449 |
+
$AACsampleRateLookup[0] = 96000;
|
450 |
+
$AACsampleRateLookup[1] = 88200;
|
451 |
+
$AACsampleRateLookup[2] = 64000;
|
452 |
+
$AACsampleRateLookup[3] = 48000;
|
453 |
+
$AACsampleRateLookup[4] = 44100;
|
454 |
+
$AACsampleRateLookup[5] = 32000;
|
455 |
+
$AACsampleRateLookup[6] = 24000;
|
456 |
+
$AACsampleRateLookup[7] = 22050;
|
457 |
+
$AACsampleRateLookup[8] = 16000;
|
458 |
+
$AACsampleRateLookup[9] = 12000;
|
459 |
+
$AACsampleRateLookup[10] = 11025;
|
460 |
+
$AACsampleRateLookup[11] = 8000;
|
461 |
+
$AACsampleRateLookup[12] = 0;
|
462 |
+
$AACsampleRateLookup[13] = 0;
|
463 |
+
$AACsampleRateLookup[14] = 0;
|
464 |
+
$AACsampleRateLookup[15] = 0;
|
465 |
+
}
|
466 |
+
return (isset($AACsampleRateLookup[$samplerateid]) ? $AACsampleRateLookup[$samplerateid] : 'invalid');
|
467 |
+
}
|
468 |
+
|
469 |
+
public static function AACprofileLookup($profileid, $mpegversion) {
|
470 |
+
static $AACprofileLookup = array();
|
471 |
+
if (empty($AACprofileLookup)) {
|
472 |
+
$AACprofileLookup[2][0] = 'Main profile';
|
473 |
+
$AACprofileLookup[2][1] = 'Low Complexity profile (LC)';
|
474 |
+
$AACprofileLookup[2][2] = 'Scalable Sample Rate profile (SSR)';
|
475 |
+
$AACprofileLookup[2][3] = '(reserved)';
|
476 |
+
$AACprofileLookup[4][0] = 'AAC_MAIN';
|
477 |
+
$AACprofileLookup[4][1] = 'AAC_LC';
|
478 |
+
$AACprofileLookup[4][2] = 'AAC_SSR';
|
479 |
+
$AACprofileLookup[4][3] = 'AAC_LTP';
|
480 |
+
}
|
481 |
+
return (isset($AACprofileLookup[$mpegversion][$profileid]) ? $AACprofileLookup[$mpegversion][$profileid] : 'invalid');
|
482 |
+
}
|
483 |
+
|
484 |
+
public static function AACchannelCountCalculate($program_configs) {
|
485 |
+
$channels = 0;
|
486 |
+
for ($i = 0; $i < $program_configs['num_front_channel_elements']; $i++) {
|
487 |
+
$channels++;
|
488 |
+
if ($program_configs['front_element_is_cpe'][$i]) {
|
489 |
+
// each front element is channel pair (CPE = Channel Pair Element)
|
490 |
+
$channels++;
|
491 |
+
}
|
492 |
+
}
|
493 |
+
for ($i = 0; $i < $program_configs['num_side_channel_elements']; $i++) {
|
494 |
+
$channels++;
|
495 |
+
if ($program_configs['side_element_is_cpe'][$i]) {
|
496 |
+
// each side element is channel pair (CPE = Channel Pair Element)
|
497 |
+
$channels++;
|
498 |
+
}
|
499 |
+
}
|
500 |
+
for ($i = 0; $i < $program_configs['num_back_channel_elements']; $i++) {
|
501 |
+
$channels++;
|
502 |
+
if ($program_configs['back_element_is_cpe'][$i]) {
|
503 |
+
// each back element is channel pair (CPE = Channel Pair Element)
|
504 |
+
$channels++;
|
505 |
+
}
|
506 |
+
}
|
507 |
+
for ($i = 0; $i < $program_configs['num_lfe_channel_elements']; $i++) {
|
508 |
+
$channels++;
|
509 |
+
}
|
510 |
+
return $channels;
|
511 |
+
}
|
512 |
+
|
513 |
+
}
|
|
|
|
getid3/module.audio.flac.php
ADDED
@@ -0,0 +1,443 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/////////////////////////////////////////////////////////////////
|
3 |
+
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
+
// available at http://getid3.sourceforge.net //
|
5 |
+
// or http://www.getid3.org //
|
6 |
+
// also https://github.com/JamesHeinrich/getID3 //
|
7 |
+
/////////////////////////////////////////////////////////////////
|
8 |
+
// See readme.txt for more details //
|
9 |
+
/////////////////////////////////////////////////////////////////
|
10 |
+
// //
|
11 |
+
// module.audio.flac.php //
|
12 |
+
// module for analyzing FLAC and OggFLAC audio files //
|
13 |
+
// dependencies: module.audio.ogg.php //
|
14 |
+
// ///
|
15 |
+
/////////////////////////////////////////////////////////////////
|
16 |
+
|
17 |
+
|
18 |
+
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, true);
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @tutorial http://flac.sourceforge.net/format.html
|
22 |
+
*/
|
23 |
+
class getid3_flac extends getid3_handler
|
24 |
+
{
|
25 |
+
const syncword = 'fLaC';
|
26 |
+
|
27 |
+
public function Analyze() {
|
28 |
+
$info = &$this->getid3->info;
|
29 |
+
|
30 |
+
$this->fseek($info['avdataoffset']);
|
31 |
+
$StreamMarker = $this->fread(4);
|
32 |
+
if ($StreamMarker != self::syncword) {
|
33 |
+
return $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::syncword).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($StreamMarker).'"');
|
34 |
+
}
|
35 |
+
$info['fileformat'] = 'flac';
|
36 |
+
$info['audio']['dataformat'] = 'flac';
|
37 |
+
$info['audio']['bitrate_mode'] = 'vbr';
|
38 |
+
$info['audio']['lossless'] = true;
|
39 |
+
|
40 |
+
// parse flac container
|
41 |
+
return $this->parseMETAdata();
|
42 |
+
}
|
43 |
+
|
44 |
+
public function parseMETAdata() {
|
45 |
+
$info = &$this->getid3->info;
|
46 |
+
do {
|
47 |
+
$BlockOffset = $this->ftell();
|
48 |
+
$BlockHeader = $this->fread(4);
|
49 |
+
$LBFBT = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1));
|
50 |
+
$LastBlockFlag = (bool) ($LBFBT & 0x80);
|
51 |
+
$BlockType = ($LBFBT & 0x7F);
|
52 |
+
$BlockLength = getid3_lib::BigEndian2Int(substr($BlockHeader, 1, 3));
|
53 |
+
$BlockTypeText = self::metaBlockTypeLookup($BlockType);
|
54 |
+
|
55 |
+
if (($BlockOffset + 4 + $BlockLength) > $info['avdataend']) {
|
56 |
+
$this->error('METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockTypeText.') at offset '.$BlockOffset.' extends beyond end of file');
|
57 |
+
break;
|
58 |
+
}
|
59 |
+
if ($BlockLength < 1) {
|
60 |
+
$this->error('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockLength.') at offset '.$BlockOffset.' is invalid');
|
61 |
+
break;
|
62 |
+
}
|
63 |
+
|
64 |
+
$info['flac'][$BlockTypeText]['raw'] = array();
|
65 |
+
$BlockTypeText_raw = &$info['flac'][$BlockTypeText]['raw'];
|
66 |
+
|
67 |
+
$BlockTypeText_raw['offset'] = $BlockOffset;
|
68 |
+
$BlockTypeText_raw['last_meta_block'] = $LastBlockFlag;
|
69 |
+
$BlockTypeText_raw['block_type'] = $BlockType;
|
70 |
+
$BlockTypeText_raw['block_type_text'] = $BlockTypeText;
|
71 |
+
$BlockTypeText_raw['block_length'] = $BlockLength;
|
72 |
+
if ($BlockTypeText_raw['block_type'] != 0x06) { // do not read attachment data automatically
|
73 |
+
$BlockTypeText_raw['block_data'] = $this->fread($BlockLength);
|
74 |
+
}
|
75 |
+
|
76 |
+
switch ($BlockTypeText) {
|
77 |
+
case 'STREAMINFO': // 0x00
|
78 |
+
if (!$this->parseSTREAMINFO($BlockTypeText_raw['block_data'])) {
|
79 |
+
return false;
|
80 |
+
}
|
81 |
+
break;
|
82 |
+
|
83 |
+
case 'PADDING': // 0x01
|
84 |
+
unset($info['flac']['PADDING']); // ignore
|
85 |
+
break;
|
86 |
+
|
87 |
+
case 'APPLICATION': // 0x02
|
88 |
+
if (!$this->parseAPPLICATION($BlockTypeText_raw['block_data'])) {
|
89 |
+
return false;
|
90 |
+
}
|
91 |
+
break;
|
92 |
+
|
93 |
+
case 'SEEKTABLE': // 0x03
|
94 |
+
if (!$this->parseSEEKTABLE($BlockTypeText_raw['block_data'])) {
|
95 |
+
return false;
|
96 |
+
}
|
97 |
+
break;
|
98 |
+
|
99 |
+
case 'VORBIS_COMMENT': // 0x04
|
100 |
+
if (!$this->parseVORBIS_COMMENT($BlockTypeText_raw['block_data'])) {
|
101 |
+
return false;
|
102 |
+
}
|
103 |
+
break;
|
104 |
+
|
105 |
+
case 'CUESHEET': // 0x05
|
106 |
+
if (!$this->parseCUESHEET($BlockTypeText_raw['block_data'])) {
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
break;
|
110 |
+
|
111 |
+
case 'PICTURE': // 0x06
|
112 |
+
if (!$this->parsePICTURE()) {
|
113 |
+
return false;
|
114 |
+
}
|
115 |
+
break;
|
116 |
+
|
117 |
+
default:
|
118 |
+
$this->warning('Unhandled METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockType.') at offset '.$BlockOffset);
|
119 |
+
}
|
120 |
+
|
121 |
+
unset($info['flac'][$BlockTypeText]['raw']);
|
122 |
+
$info['avdataoffset'] = $this->ftell();
|
123 |
+
}
|
124 |
+
while ($LastBlockFlag === false);
|
125 |
+
|
126 |
+
// handle tags
|
127 |
+
if (!empty($info['flac']['VORBIS_COMMENT']['comments'])) {
|
128 |
+
$info['flac']['comments'] = $info['flac']['VORBIS_COMMENT']['comments'];
|
129 |
+
}
|
130 |
+
if (!empty($info['flac']['VORBIS_COMMENT']['vendor'])) {
|
131 |
+
$info['audio']['encoder'] = str_replace('reference ', '', $info['flac']['VORBIS_COMMENT']['vendor']);
|
132 |
+
}
|
133 |
+
|
134 |
+
// copy attachments to 'comments' array if nesesary
|
135 |
+
if (isset($info['flac']['PICTURE']) && ($this->getid3->option_save_attachments !== getID3::ATTACHMENTS_NONE)) {
|
136 |
+
foreach ($info['flac']['PICTURE'] as $entry) {
|
137 |
+
if (!empty($entry['data'])) {
|
138 |
+
$info['flac']['comments']['picture'][] = array('image_mime'=>$entry['image_mime'], 'data'=>$entry['data']);
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
if (isset($info['flac']['STREAMINFO'])) {
|
144 |
+
if (!$this->isDependencyFor('matroska')) {
|
145 |
+
$info['flac']['compressed_audio_bytes'] = $info['avdataend'] - $info['avdataoffset'];
|
146 |
+
}
|
147 |
+
$info['flac']['uncompressed_audio_bytes'] = $info['flac']['STREAMINFO']['samples_stream'] * $info['flac']['STREAMINFO']['channels'] * ($info['flac']['STREAMINFO']['bits_per_sample'] / 8);
|
148 |
+
if ($info['flac']['uncompressed_audio_bytes'] == 0) {
|
149 |
+
return $this->error('Corrupt FLAC file: uncompressed_audio_bytes == zero');
|
150 |
+
}
|
151 |
+
if (!empty($info['flac']['compressed_audio_bytes'])) {
|
152 |
+
$info['flac']['compression_ratio'] = $info['flac']['compressed_audio_bytes'] / $info['flac']['uncompressed_audio_bytes'];
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
// set md5_data_source - built into flac 0.5+
|
157 |
+
if (isset($info['flac']['STREAMINFO']['audio_signature'])) {
|
158 |
+
|
159 |
+
if ($info['flac']['STREAMINFO']['audio_signature'] === str_repeat("\x00", 16)) {
|
160 |
+
$this->warning('FLAC STREAMINFO.audio_signature is null (known issue with libOggFLAC)');
|
161 |
+
}
|
162 |
+
else {
|
163 |
+
$info['md5_data_source'] = '';
|
164 |
+
$md5 = $info['flac']['STREAMINFO']['audio_signature'];
|
165 |
+
for ($i = 0; $i < strlen($md5); $i++) {
|
166 |
+
$info['md5_data_source'] .= str_pad(dechex(ord($md5[$i])), 2, '00', STR_PAD_LEFT);
|
167 |
+
}
|
168 |
+
if (!preg_match('/^[0-9a-f]{32}$/', $info['md5_data_source'])) {
|
169 |
+
unset($info['md5_data_source']);
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
if (isset($info['flac']['STREAMINFO']['bits_per_sample'])) {
|
175 |
+
$info['audio']['bits_per_sample'] = $info['flac']['STREAMINFO']['bits_per_sample'];
|
176 |
+
if ($info['audio']['bits_per_sample'] == 8) {
|
177 |
+
// special case
|
178 |
+
// must invert sign bit on all data bytes before MD5'ing to match FLAC's calculated value
|
179 |
+
// MD5sum calculates on unsigned bytes, but FLAC calculated MD5 on 8-bit audio data as signed
|
180 |
+
$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');
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
return true;
|
185 |
+
}
|
186 |
+
|
187 |
+
private function parseSTREAMINFO($BlockData) {
|
188 |
+
$info = &$this->getid3->info;
|
189 |
+
|
190 |
+
$info['flac']['STREAMINFO'] = array();
|
191 |
+
$streaminfo = &$info['flac']['STREAMINFO'];
|
192 |
+
|
193 |
+
$streaminfo['min_block_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 0, 2));
|
194 |
+
$streaminfo['max_block_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 2, 2));
|
195 |
+
$streaminfo['min_frame_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 4, 3));
|
196 |
+
$streaminfo['max_frame_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 7, 3));
|
197 |
+
|
198 |
+
$SRCSBSS = getid3_lib::BigEndian2Bin(substr($BlockData, 10, 8));
|
199 |
+
$streaminfo['sample_rate'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 0, 20));
|
200 |
+
$streaminfo['channels'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 20, 3)) + 1;
|
201 |
+
$streaminfo['bits_per_sample'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 23, 5)) + 1;
|
202 |
+
$streaminfo['samples_stream'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 28, 36));
|
203 |
+
|
204 |
+
$streaminfo['audio_signature'] = substr($BlockData, 18, 16);
|
205 |
+
|
206 |
+
if (!empty($streaminfo['sample_rate'])) {
|
207 |
+
|
208 |
+
$info['audio']['bitrate_mode'] = 'vbr';
|
209 |
+
$info['audio']['sample_rate'] = $streaminfo['sample_rate'];
|
210 |
+
$info['audio']['channels'] = $streaminfo['channels'];
|
211 |
+
$info['audio']['bits_per_sample'] = $streaminfo['bits_per_sample'];
|
212 |
+
$info['playtime_seconds'] = $streaminfo['samples_stream'] / $streaminfo['sample_rate'];
|
213 |
+
if ($info['playtime_seconds'] > 0) {
|
214 |
+
if (!$this->isDependencyFor('matroska')) {
|
215 |
+
$info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
|
216 |
+
}
|
217 |
+
else {
|
218 |
+
$this->warning('Cannot determine audio bitrate because total stream size is unknown');
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
} else {
|
223 |
+
return $this->error('Corrupt METAdata block: STREAMINFO');
|
224 |
+
}
|
225 |
+
|
226 |
+
return true;
|
227 |
+
}
|
228 |
+
|
229 |
+
private function parseAPPLICATION($BlockData) {
|
230 |
+
$info = &$this->getid3->info;
|
231 |
+
|
232 |
+
$ApplicationID = getid3_lib::BigEndian2Int(substr($BlockData, 0, 4));
|
233 |
+
$info['flac']['APPLICATION'][$ApplicationID]['name'] = self::applicationIDLookup($ApplicationID);
|
234 |
+
$info['flac']['APPLICATION'][$ApplicationID]['data'] = substr($BlockData, 4);
|
235 |
+
|
236 |
+
return true;
|
237 |
+
}
|
238 |
+
|
239 |
+
private function parseSEEKTABLE($BlockData) {
|
240 |
+
$info = &$this->getid3->info;
|
241 |
+
|
242 |
+
$offset = 0;
|
243 |
+
$BlockLength = strlen($BlockData);
|
244 |
+
$placeholderpattern = str_repeat("\xFF", 8);
|
245 |
+
while ($offset < $BlockLength) {
|
246 |
+
$SampleNumberString = substr($BlockData, $offset, 8);
|
247 |
+
$offset += 8;
|
248 |
+
if ($SampleNumberString == $placeholderpattern) {
|
249 |
+
|
250 |
+
// placeholder point
|
251 |
+
getid3_lib::safe_inc($info['flac']['SEEKTABLE']['placeholders'], 1);
|
252 |
+
$offset += 10;
|
253 |
+
|
254 |
+
} else {
|
255 |
+
|
256 |
+
$SampleNumber = getid3_lib::BigEndian2Int($SampleNumberString);
|
257 |
+
$info['flac']['SEEKTABLE'][$SampleNumber]['offset'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
|
258 |
+
$offset += 8;
|
259 |
+
$info['flac']['SEEKTABLE'][$SampleNumber]['samples'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 2));
|
260 |
+
$offset += 2;
|
261 |
+
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
return true;
|
266 |
+
}
|
267 |
+
|
268 |
+
private function parseVORBIS_COMMENT($BlockData) {
|
269 |
+
$info = &$this->getid3->info;
|
270 |
+
|
271 |
+
$getid3_ogg = new getid3_ogg($this->getid3);
|
272 |
+
if ($this->isDependencyFor('matroska')) {
|
273 |
+
$getid3_ogg->setStringMode($this->data_string);
|
274 |
+
}
|
275 |
+
$getid3_ogg->ParseVorbisComments();
|
276 |
+
if (isset($info['ogg'])) {
|
277 |
+
unset($info['ogg']['comments_raw']);
|
278 |
+
$info['flac']['VORBIS_COMMENT'] = $info['ogg'];
|
279 |
+
unset($info['ogg']);
|
280 |
+
}
|
281 |
+
|
282 |
+
unset($getid3_ogg);
|
283 |
+
|
284 |
+
return true;
|
285 |
+
}
|
286 |
+
|
287 |
+
private function parseCUESHEET($BlockData) {
|
288 |
+
$info = &$this->getid3->info;
|
289 |
+
$offset = 0;
|
290 |
+
$info['flac']['CUESHEET']['media_catalog_number'] = trim(substr($BlockData, $offset, 128), "\0");
|
291 |
+
$offset += 128;
|
292 |
+
$info['flac']['CUESHEET']['lead_in_samples'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
|
293 |
+
$offset += 8;
|
294 |
+
$info['flac']['CUESHEET']['flags']['is_cd'] = (bool) (getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1)) & 0x80);
|
295 |
+
$offset += 1;
|
296 |
+
|
297 |
+
$offset += 258; // reserved
|
298 |
+
|
299 |
+
$info['flac']['CUESHEET']['number_tracks'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
|
300 |
+
$offset += 1;
|
301 |
+
|
302 |
+
for ($track = 0; $track < $info['flac']['CUESHEET']['number_tracks']; $track++) {
|
303 |
+
$TrackSampleOffset = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
|
304 |
+
$offset += 8;
|
305 |
+
$TrackNumber = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
|
306 |
+
$offset += 1;
|
307 |
+
|
308 |
+
$info['flac']['CUESHEET']['tracks'][$TrackNumber]['sample_offset'] = $TrackSampleOffset;
|
309 |
+
|
310 |
+
$info['flac']['CUESHEET']['tracks'][$TrackNumber]['isrc'] = substr($BlockData, $offset, 12);
|
311 |
+
$offset += 12;
|
312 |
+
|
313 |
+
$TrackFlagsRaw = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
|
314 |
+
$offset += 1;
|
315 |
+
$info['flac']['CUESHEET']['tracks'][$TrackNumber]['flags']['is_audio'] = (bool) ($TrackFlagsRaw & 0x80);
|
316 |
+
$info['flac']['CUESHEET']['tracks'][$TrackNumber]['flags']['pre_emphasis'] = (bool) ($TrackFlagsRaw & 0x40);
|
317 |
+
|
318 |
+
$offset += 13; // reserved
|
319 |
+
|
320 |
+
$info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
|
321 |
+
$offset += 1;
|
322 |
+
|
323 |
+
for ($index = 0; $index < $info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points']; $index++) {
|
324 |
+
$IndexSampleOffset = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8));
|
325 |
+
$offset += 8;
|
326 |
+
$IndexNumber = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1));
|
327 |
+
$offset += 1;
|
328 |
+
|
329 |
+
$offset += 3; // reserved
|
330 |
+
|
331 |
+
$info['flac']['CUESHEET']['tracks'][$TrackNumber]['indexes'][$IndexNumber] = $IndexSampleOffset;
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
+
return true;
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Parse METADATA_BLOCK_PICTURE flac structure and extract attachment
|
340 |
+
* External usage: audio.ogg
|
341 |
+
*/
|
342 |
+
public function parsePICTURE() {
|
343 |
+
$info = &$this->getid3->info;
|
344 |
+
|
345 |
+
$picture['typeid'] = getid3_lib::BigEndian2Int($this->fread(4));
|
346 |
+
$picture['type'] = self::pictureTypeLookup($picture['typeid']);
|
347 |
+
$picture['image_mime'] = $this->fread(getid3_lib::BigEndian2Int($this->fread(4)));
|
348 |
+
$descr_length = getid3_lib::BigEndian2Int($this->fread(4));
|
349 |
+
if ($descr_length) {
|
350 |
+
$picture['description'] = $this->fread($descr_length);
|
351 |
+
}
|
352 |
+
$picture['width'] = getid3_lib::BigEndian2Int($this->fread(4));
|
353 |
+
$picture['height'] = getid3_lib::BigEndian2Int($this->fread(4));
|
354 |
+
$picture['color_depth'] = getid3_lib::BigEndian2Int($this->fread(4));
|
355 |
+
$picture['colors_indexed'] = getid3_lib::BigEndian2Int($this->fread(4));
|
356 |
+
$data_length = getid3_lib::BigEndian2Int($this->fread(4));
|
357 |
+
|
358 |
+
if ($picture['image_mime'] == '-->') {
|
359 |
+
$picture['data'] = $this->fread($data_length);
|
360 |
+
} else {
|
361 |
+
$picture['data'] = $this->saveAttachment(
|
362 |
+
str_replace('/', '_', $picture['type']).'_'.$this->ftell(),
|
363 |
+
$this->ftell(),
|
364 |
+
$data_length,
|
365 |
+
$picture['image_mime']);
|
366 |
+
}
|
367 |
+
|
368 |
+
$info['flac']['PICTURE'][] = $picture;
|
369 |
+
|
370 |
+
return true;
|
371 |
+
}
|
372 |
+
|
373 |
+
public static function metaBlockTypeLookup($blocktype) {
|
374 |
+
static $lookup = array(
|
375 |
+
0 => 'STREAMINFO',
|
376 |
+
1 => 'PADDING',
|
377 |
+
2 => 'APPLICATION',
|
378 |
+
3 => 'SEEKTABLE',
|
379 |
+
4 => 'VORBIS_COMMENT',
|
380 |
+
5 => 'CUESHEET',
|
381 |
+
6 => 'PICTURE',
|
382 |
+
);
|
383 |
+
return (isset($lookup[$blocktype]) ? $lookup[$blocktype] : 'reserved');
|
384 |
+
}
|
385 |
+
|
386 |
+
public static function applicationIDLookup($applicationid) {
|
387 |
+
// http://flac.sourceforge.net/id.html
|
388 |
+
static $lookup = array(
|
389 |
+
0x41544348 => 'FlacFile', // "ATCH"
|
390 |
+
0x42534F4C => 'beSolo', // "BSOL"
|
391 |
+
0x42554753 => 'Bugs Player', // "BUGS"
|
392 |
+
0x43756573 => 'GoldWave cue points (specification)', // "Cues"
|
393 |
+
0x46696361 => 'CUE Splitter', // "Fica"
|
394 |
+
0x46746F6C => 'flac-tools', // "Ftol"
|
395 |
+
0x4D4F5442 => 'MOTB MetaCzar', // "MOTB"
|
396 |
+
0x4D505345 => 'MP3 Stream Editor', // "MPSE"
|
397 |
+
0x4D754D4C => 'MusicML: Music Metadata Language', // "MuML"
|
398 |
+
0x52494646 => 'Sound Devices RIFF chunk storage', // "RIFF"
|
399 |
+
0x5346464C => 'Sound Font FLAC', // "SFFL"
|
400 |
+
0x534F4E59 => 'Sony Creative Software', // "SONY"
|
401 |
+
0x5351455A => 'flacsqueeze', // "SQEZ"
|
402 |
+
0x54745776 => 'TwistedWave', // "TtWv"
|
403 |
+
0x55495453 => 'UITS Embedding tools', // "UITS"
|
404 |
+
0x61696666 => 'FLAC AIFF chunk storage', // "aiff"
|
405 |
+
0x696D6167 => 'flac-image application for storing arbitrary files in APPLICATION metadata blocks', // "imag"
|
406 |
+
0x7065656D => 'Parseable Embedded Extensible Metadata (specification)', // "peem"
|
407 |
+
0x71667374 => 'QFLAC Studio', // "qfst"
|
408 |
+
0x72696666 => 'FLAC RIFF chunk storage', // "riff"
|
409 |
+
0x74756E65 => 'TagTuner', // "tune"
|
410 |
+
0x78626174 => 'XBAT', // "xbat"
|
411 |
+
0x786D6364 => 'xmcd', // "xmcd"
|
412 |
+
);
|
413 |
+
return (isset($lookup[$applicationid]) ? $lookup[$applicationid] : 'reserved');
|
414 |
+
}
|
415 |
+
|
416 |
+
public static function pictureTypeLookup($type_id) {
|
417 |
+
static $lookup = array (
|
418 |
+
0 => 'Other',
|
419 |
+
1 => '32x32 pixels \'file icon\' (PNG only)',
|
420 |
+
2 => 'Other file icon',
|
421 |
+
3 => 'Cover (front)',
|
422 |
+
4 => 'Cover (back)',
|
423 |
+
5 => 'Leaflet page',
|
424 |
+
6 => 'Media (e.g. label side of CD)',
|
425 |
+
7 => 'Lead artist/lead performer/soloist',
|
426 |
+
8 => 'Artist/performer',
|
427 |
+
9 => 'Conductor',
|
428 |
+
10 => 'Band/Orchestra',
|
429 |
+
11 => 'Composer',
|
430 |
+
12 => 'Lyricist/text writer',
|
431 |
+
13 => 'Recording Location',
|
432 |
+
14 => 'During recording',
|
433 |
+
15 => 'During performance',
|
434 |
+
16 => 'Movie/video screen capture',
|
435 |
+
17 => 'A bright coloured fish',
|
436 |
+
18 => 'Illustration',
|
437 |
+
19 => 'Band/artist logotype',
|
438 |
+
20 => 'Publisher/Studio logotype',
|
439 |
+
);
|
440 |
+
return (isset($lookup[$type_id]) ? $lookup[$type_id] : 'reserved');
|
441 |
+
}
|
442 |
+
|
443 |
+
}
|
getid3/module.audio.mp3.php
CHANGED
@@ -1,2011 +1,2012 @@
|
|
1 |
-
<?php
|
2 |
-
/////////////////////////////////////////////////////////////////
|
3 |
-
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
-
// available at http://getid3.sourceforge.net //
|
5 |
-
// or http://www.getid3.org //
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
//
|
11 |
-
// module
|
12 |
-
//
|
13 |
-
//
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
//
|
19 |
-
//
|
20 |
-
//
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
$
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
$
|
63 |
-
$
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
$
|
69 |
-
$
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
//
|
91 |
-
// or a
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
$
|
100 |
-
|
101 |
-
|
102 |
-
case '
|
103 |
-
|
104 |
-
//
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
case
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
case '
|
131 |
-
case '
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
unset($info['
|
144 |
-
unset($info['
|
145 |
-
unset($info['
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
$info['
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
$KnownEncoderValues[0xFF][58][1][1][3][2][
|
192 |
-
$KnownEncoderValues[0xFF][
|
193 |
-
$KnownEncoderValues[
|
194 |
-
$KnownEncoderValues['**'][78][3][2][3][2][
|
195 |
-
$KnownEncoderValues['**'][78][3][
|
196 |
-
$KnownEncoderValues['**'][78][
|
197 |
-
$KnownEncoderValues['**'][78][4][2][3][2][
|
198 |
-
$KnownEncoderValues['**'][78][
|
199 |
-
$KnownEncoderValues['**'][78][3][
|
200 |
-
$KnownEncoderValues['**'][78][
|
201 |
-
$KnownEncoderValues['**'][78][4][
|
202 |
-
$KnownEncoderValues['**'][
|
203 |
-
$KnownEncoderValues['**'][88][4][1][3][3][
|
204 |
-
$KnownEncoderValues['**'][
|
205 |
-
$KnownEncoderValues['**'][
|
206 |
-
$KnownEncoderValues['**'][68][
|
207 |
-
|
208 |
-
|
209 |
-
$KnownEncoderValues[0xFF][
|
210 |
-
$KnownEncoderValues[0xFF][58][2][1][3][2][
|
211 |
-
$KnownEncoderValues[0xFF][
|
212 |
-
$KnownEncoderValues[
|
213 |
-
$KnownEncoderValues[0xC0][
|
214 |
-
$KnownEncoderValues[0xC0][58][2][2][3][2][
|
215 |
-
$KnownEncoderValues[0xC0][
|
216 |
-
$KnownEncoderValues[
|
217 |
-
$KnownEncoderValues[0xA0][
|
218 |
-
$KnownEncoderValues[0xA0][
|
219 |
-
$KnownEncoderValues[
|
220 |
-
$KnownEncoderValues[0x80][67][1][1][3][2][
|
221 |
-
$KnownEncoderValues[
|
222 |
-
$KnownEncoderValues[0x70][
|
223 |
-
$KnownEncoderValues[0x70][
|
224 |
-
$KnownEncoderValues[
|
225 |
-
$KnownEncoderValues[0x38][
|
226 |
-
$KnownEncoderValues[0x38][57][2][1][0][4][
|
227 |
-
$KnownEncoderValues[
|
228 |
-
$KnownEncoderValues[0x28][65][1][1][0][2][
|
229 |
-
$KnownEncoderValues[0x28][
|
230 |
-
$KnownEncoderValues[0x28][
|
231 |
-
$KnownEncoderValues[0x28][57][2][1][0][4][
|
232 |
-
$KnownEncoderValues[0x28][57][2][1][0][4][
|
233 |
-
$KnownEncoderValues[
|
234 |
-
$KnownEncoderValues[0x18][58][2][2][0][2][
|
235 |
-
$KnownEncoderValues[0x18][
|
236 |
-
$KnownEncoderValues[0x18][57][2][1][0][4][
|
237 |
-
$KnownEncoderValues[0x18][57][2][1][0][4][
|
238 |
-
$KnownEncoderValues[
|
239 |
-
$KnownEncoderValues[0x10][58][2][2][0][2][
|
240 |
-
$KnownEncoderValues[0x10][
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
//
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
$
|
259 |
-
$
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
case '--
|
300 |
-
case '--
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
case '
|
307 |
-
case '
|
308 |
-
case '
|
309 |
-
case '
|
310 |
-
case '
|
311 |
-
case 'fast
|
312 |
-
case 'fast
|
313 |
-
case 'fast
|
314 |
-
case 'fast
|
315 |
-
case '
|
316 |
-
|
317 |
-
|
318 |
-
'insane|
|
319 |
-
'
|
320 |
-
'
|
321 |
-
'
|
322 |
-
'extreme|
|
323 |
-
'
|
324 |
-
'fast extreme|
|
325 |
-
'
|
326 |
-
'
|
327 |
-
'
|
328 |
-
'r3mix|
|
329 |
-
'r3mix|
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
case
|
355 |
-
case
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
case '--
|
360 |
-
|
361 |
-
|
362 |
-
case '
|
363 |
-
case '
|
364 |
-
case '
|
365 |
-
case '
|
366 |
-
case '
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
'mw-
|
374 |
-
'mw-us|
|
375 |
-
'mw-us|
|
376 |
-
'
|
377 |
-
'phone|
|
378 |
-
'
|
379 |
-
'
|
380 |
-
'fm|32000'
|
381 |
-
'
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
static $
|
410 |
-
static $
|
411 |
-
static $
|
412 |
-
static $
|
413 |
-
static $
|
414 |
-
static $
|
415 |
-
|
416 |
-
|
417 |
-
$
|
418 |
-
$
|
419 |
-
$
|
420 |
-
$
|
421 |
-
$
|
422 |
-
$
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
//
|
434 |
-
//
|
435 |
-
//
|
436 |
-
//
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
$
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
$thisfile_mpeg_audio['
|
471 |
-
|
472 |
-
|
473 |
-
$thisfile_mpeg_audio['
|
474 |
-
$thisfile_mpeg_audio['
|
475 |
-
$thisfile_mpeg_audio['
|
476 |
-
$thisfile_mpeg_audio['
|
477 |
-
$thisfile_mpeg_audio['
|
478 |
-
$thisfile_mpeg_audio['
|
479 |
-
$thisfile_mpeg_audio['
|
480 |
-
$thisfile_mpeg_audio['
|
481 |
-
|
482 |
-
|
483 |
-
$info['audio']['
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
$
|
494 |
-
|
495 |
-
|
496 |
-
$thisfile_mpeg_audio['
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
//
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
case '
|
521 |
-
case '
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
//
|
561 |
-
|
562 |
-
|
563 |
-
$thisfile_mpeg_audio['
|
564 |
-
$
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
$thisfile_mpeg_audio['
|
572 |
-
$thisfile_mpeg_audio['
|
573 |
-
$thisfile_mpeg_audio['
|
574 |
-
$thisfile_mpeg_audio['
|
575 |
-
$thisfile_mpeg_audio['
|
576 |
-
$thisfile_mpeg_audio['
|
577 |
-
$thisfile_mpeg_audio['
|
578 |
-
$thisfile_mpeg_audio['
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
$
|
586 |
-
$
|
587 |
-
$thisfile_mpeg_audio['
|
588 |
-
$
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
//
|
596 |
-
|
597 |
-
|
598 |
-
$
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
// '
|
603 |
-
// 'Info'
|
604 |
-
|
605 |
-
|
606 |
-
//
|
607 |
-
//
|
608 |
-
//
|
609 |
-
//
|
610 |
-
//
|
611 |
-
//
|
612 |
-
//
|
613 |
-
//
|
614 |
-
//
|
615 |
-
//
|
616 |
-
//
|
617 |
-
//
|
618 |
-
//
|
619 |
-
//
|
620 |
-
//
|
621 |
-
//
|
622 |
-
//
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
//
|
627 |
-
|
628 |
-
$thisfile_mpeg_audio['
|
629 |
-
|
630 |
-
//
|
631 |
-
// $
|
632 |
-
//
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
$thisfile_mpeg_audio['xing_flags']['
|
638 |
-
$thisfile_mpeg_audio['xing_flags']['
|
639 |
-
$thisfile_mpeg_audio['xing_flags']['
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
if (!empty($thisfile_mpeg_audio['VBR_frames']) && !empty($thisfile_mpeg_audio['VBR_bytes'])) {
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
$
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
$thisfile_mpeg_audio_lame['
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
//
|
695 |
-
|
696 |
-
|
697 |
-
//
|
698 |
-
//
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
$
|
704 |
-
$
|
705 |
-
$
|
706 |
-
$
|
707 |
-
$
|
708 |
-
|
709 |
-
|
710 |
-
//
|
711 |
-
//
|
712 |
-
|
713 |
-
$
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
$
|
723 |
-
$
|
724 |
-
$
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
//
|
731 |
-
//
|
732 |
-
|
733 |
-
|
734 |
-
//
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
//
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
$thisfile_mpeg_audio_lame_raw['
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
$thisfile_mpeg_audio_lame_RGAD_track['raw']['
|
755 |
-
$thisfile_mpeg_audio_lame_RGAD_track['raw']['
|
756 |
-
$thisfile_mpeg_audio_lame_RGAD_track['raw']['
|
757 |
-
$thisfile_mpeg_audio_lame_RGAD_track['
|
758 |
-
$thisfile_mpeg_audio_lame_RGAD_track['
|
759 |
-
$thisfile_mpeg_audio_lame_RGAD_track['
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
$info['replay_gain']['track']['
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
$thisfile_mpeg_audio_lame_RGAD_album['raw']['
|
773 |
-
$thisfile_mpeg_audio_lame_RGAD_album['raw']['
|
774 |
-
$thisfile_mpeg_audio_lame_RGAD_album['raw']['
|
775 |
-
$thisfile_mpeg_audio_lame_RGAD_album['
|
776 |
-
$thisfile_mpeg_audio_lame_RGAD_album['
|
777 |
-
$thisfile_mpeg_audio_lame_RGAD_album['
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
$info['replay_gain']['album']['
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
$
|
795 |
-
$thisfile_mpeg_audio_lame['encoding_flags']['
|
796 |
-
$thisfile_mpeg_audio_lame['encoding_flags']['
|
797 |
-
$thisfile_mpeg_audio_lame['encoding_flags']['
|
798 |
-
$thisfile_mpeg_audio_lame['
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
$
|
813 |
-
$thisfile_mpeg_audio_lame['
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
$
|
818 |
-
$thisfile_mpeg_audio_lame_raw['
|
819 |
-
$thisfile_mpeg_audio_lame_raw['
|
820 |
-
$thisfile_mpeg_audio_lame_raw['
|
821 |
-
$
|
822 |
-
$thisfile_mpeg_audio_lame['
|
823 |
-
$thisfile_mpeg_audio_lame['
|
824 |
-
$thisfile_mpeg_audio_lame['
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
$
|
829 |
-
$thisfile_mpeg_audio_lame['
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
$
|
836 |
-
$thisfile_mpeg_audio_lame['
|
837 |
-
$thisfile_mpeg_audio_lame['
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
$
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
$thisfile_mpeg_audio['
|
862 |
-
$
|
863 |
-
|
864 |
-
//
|
865 |
-
//
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
$
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
$
|
899 |
-
}
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
//
|
906 |
-
//
|
907 |
-
|
908 |
-
//
|
909 |
-
//
|
910 |
-
|
911 |
-
//
|
912 |
-
} else {
|
913 |
-
|
914 |
-
}
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
//
|
928 |
-
$info['audio']['bitrate'] = (($framebytelength - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) /
|
929 |
-
}
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
$thisfile_mpeg_audio['
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
//
|
971 |
-
//
|
972 |
-
//
|
973 |
-
//
|
974 |
-
//
|
975 |
-
//
|
976 |
-
//
|
977 |
-
//
|
978 |
-
//
|
979 |
-
//
|
980 |
-
//
|
981 |
-
// $
|
982 |
-
//
|
983 |
-
//
|
984 |
-
//
|
985 |
-
//
|
986 |
-
//
|
987 |
-
//
|
988 |
-
//
|
989 |
-
//
|
990 |
-
//
|
991 |
-
//
|
992 |
-
//
|
993 |
-
// $
|
994 |
-
//
|
995 |
-
//
|
996 |
-
//
|
997 |
-
//
|
998 |
-
//
|
999 |
-
//
|
1000 |
-
//
|
1001 |
-
//
|
1002 |
-
//
|
1003 |
-
//
|
1004 |
-
//
|
1005 |
-
//
|
1006 |
-
//
|
1007 |
-
//
|
1008 |
-
//
|
1009 |
-
//
|
1010 |
-
//
|
1011 |
-
//
|
1012 |
-
// $SideInfoOffset
|
1013 |
-
// $
|
1014 |
-
// $SideInfoOffset
|
1015 |
-
//
|
1016 |
-
//
|
1017 |
-
//
|
1018 |
-
//
|
1019 |
-
// $thisfile_mpeg_audio['scalefac_compress'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset,
|
1020 |
-
// $SideInfoOffset +=
|
1021 |
-
// }
|
1022 |
-
//
|
1023 |
-
//
|
1024 |
-
//
|
1025 |
-
//
|
1026 |
-
//
|
1027 |
-
//
|
1028 |
-
//
|
1029 |
-
//
|
1030 |
-
// $SideInfoOffset
|
1031 |
-
//
|
1032 |
-
//
|
1033 |
-
//
|
1034 |
-
//
|
1035 |
-
//
|
1036 |
-
//
|
1037 |
-
//
|
1038 |
-
//
|
1039 |
-
//
|
1040 |
-
//
|
1041 |
-
//
|
1042 |
-
//
|
1043 |
-
//
|
1044 |
-
//
|
1045 |
-
//
|
1046 |
-
//
|
1047 |
-
//
|
1048 |
-
//
|
1049 |
-
//
|
1050 |
-
//
|
1051 |
-
//
|
1052 |
-
//
|
1053 |
-
// $SideInfoOffset
|
1054 |
-
// $
|
1055 |
-
//
|
1056 |
-
//
|
1057 |
-
//
|
1058 |
-
//
|
1059 |
-
//
|
1060 |
-
//
|
1061 |
-
//
|
1062 |
-
//
|
1063 |
-
//
|
1064 |
-
// $SideInfoOffset
|
1065 |
-
//
|
1066 |
-
//
|
1067 |
-
//
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
}
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
$
|
1123 |
-
|
1124 |
-
$
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
}
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
if (
|
1138 |
-
$framelength = $
|
1139 |
-
}
|
1140 |
-
if (
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
if (
|
1150 |
-
$framelength = $
|
1151 |
-
}
|
1152 |
-
if (
|
1153 |
-
$
|
1154 |
-
|
1155 |
-
|
1156 |
-
$info['
|
1157 |
-
|
1158 |
-
|
1159 |
-
$
|
1160 |
-
$
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
//
|
1176 |
-
$ActualFrameLengthValues[] =
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
$
|
1181 |
-
|
1182 |
-
|
1183 |
-
$
|
1184 |
-
|
1185 |
-
}
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
$
|
1190 |
-
}
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
$
|
1200 |
-
$
|
1201 |
-
$
|
1202 |
-
$
|
1203 |
-
$
|
1204 |
-
$
|
1205 |
-
$
|
1206 |
-
$
|
1207 |
-
$
|
1208 |
-
$
|
1209 |
-
$
|
1210 |
-
$
|
1211 |
-
$
|
1212 |
-
$
|
1213 |
-
$
|
1214 |
-
$Distribution['
|
1215 |
-
$Distribution['
|
1216 |
-
|
1217 |
-
$
|
1218 |
-
|
1219 |
-
|
1220 |
-
$
|
1221 |
-
$
|
1222 |
-
|
1223 |
-
$
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
if ($head4
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
}
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
}
|
1242 |
-
if (!isset($
|
1243 |
-
$
|
1244 |
-
}
|
1245 |
-
if ($MPEGaudioHeaderValidCache[$head4]) {
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
$
|
1252 |
-
$
|
1253 |
-
$
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
$
|
1258 |
-
$
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
if (!isset($
|
1269 |
-
$
|
1270 |
-
}
|
1271 |
-
if ($MPEGaudioHeaderValidCache[$next4]) {
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
getid3_lib::safe_inc($Distribution['
|
1278 |
-
getid3_lib::safe_inc($Distribution['
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
}
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
$
|
1305 |
-
$info['mpeg']['audio']['
|
1306 |
-
$info['mpeg']['audio']['
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
if (count($Distribution['
|
1311 |
-
$info['error'][] = 'Corrupt file - more than one MPEG
|
1312 |
-
}
|
1313 |
-
if (count($Distribution['
|
1314 |
-
$info['error'][] = 'Corrupt file - more than one MPEG
|
1315 |
-
}
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
$info['audio']['
|
1334 |
-
$info['audio']['
|
1335 |
-
|
1336 |
-
$info['audio']['
|
1337 |
-
$info['
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
if (isset($info['
|
1377 |
-
unset($info['
|
1378 |
-
}
|
1379 |
-
if (
|
1380 |
-
unset($info['mpeg']);
|
1381 |
-
}
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
if (isset($info['
|
1391 |
-
unset($info['
|
1392 |
-
}
|
1393 |
-
if (isset($info['mpeg']
|
1394 |
-
unset($info['mpeg']);
|
1395 |
-
}
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
case '
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
$info
|
1437 |
-
$
|
1438 |
-
|
1439 |
-
$
|
1440 |
-
$
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
$info['
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
$
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
$
|
1484 |
-
|
1485 |
-
|
1486 |
-
$
|
1487 |
-
$
|
1488 |
-
$
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
$
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
$
|
1533 |
-
|
1534 |
-
}
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
}
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
$info['
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
}
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
if (isset($info['
|
1604 |
-
unset($info['
|
1605 |
-
}
|
1606 |
-
if (isset($info['mpeg']
|
1607 |
-
unset($info['mpeg']);
|
1608 |
-
}
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
static $
|
1699 |
-
static $
|
1700 |
-
static $
|
1701 |
-
static $
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
$
|
1707 |
-
$
|
1708 |
-
$
|
1709 |
-
$
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
}
|
1718 |
-
|
1719 |
-
|
1720 |
-
}
|
1721 |
-
|
1722 |
-
|
1723 |
-
}
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
//
|
1756 |
-
// $rawarray['
|
1757 |
-
// $rawarray['
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
//
|
1767 |
-
//
|
1768 |
-
//
|
1769 |
-
//
|
1770 |
-
//
|
1771 |
-
//
|
1772 |
-
//
|
1773 |
-
//
|
1774 |
-
//
|
1775 |
-
//
|
1776 |
-
//
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
$MPEGrawHeader['
|
1786 |
-
$MPEGrawHeader['
|
1787 |
-
$MPEGrawHeader['
|
1788 |
-
$MPEGrawHeader['
|
1789 |
-
$MPEGrawHeader['
|
1790 |
-
$MPEGrawHeader['
|
1791 |
-
$MPEGrawHeader['
|
1792 |
-
$MPEGrawHeader['
|
1793 |
-
$MPEGrawHeader['
|
1794 |
-
$MPEGrawHeader['
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
$
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
$bit_rate_table[$round_bit_rate]
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
case '
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
$LAMEpresetUsedLookup[
|
1985 |
-
$LAMEpresetUsedLookup[
|
1986 |
-
$LAMEpresetUsedLookup[
|
1987 |
-
$LAMEpresetUsedLookup[
|
1988 |
-
$LAMEpresetUsedLookup[
|
1989 |
-
|
1990 |
-
|
1991 |
-
$LAMEpresetUsedLookup[
|
1992 |
-
|
1993 |
-
|
1994 |
-
$LAMEpresetUsedLookup[
|
1995 |
-
$LAMEpresetUsedLookup[
|
1996 |
-
|
1997 |
-
$LAMEpresetUsedLookup[
|
1998 |
-
$LAMEpresetUsedLookup[
|
1999 |
-
$LAMEpresetUsedLookup[
|
2000 |
-
$LAMEpresetUsedLookup[
|
2001 |
-
$LAMEpresetUsedLookup[
|
2002 |
-
$LAMEpresetUsedLookup[
|
2003 |
-
$LAMEpresetUsedLookup[
|
2004 |
-
$LAMEpresetUsedLookup[
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
|
1 |
+
<?php
|
2 |
+
/////////////////////////////////////////////////////////////////
|
3 |
+
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
+
// available at http://getid3.sourceforge.net //
|
5 |
+
// or http://www.getid3.org //
|
6 |
+
// also https://github.com/JamesHeinrich/getID3 //
|
7 |
+
/////////////////////////////////////////////////////////////////
|
8 |
+
// See readme.txt for more details //
|
9 |
+
/////////////////////////////////////////////////////////////////
|
10 |
+
// //
|
11 |
+
// module.audio.mp3.php //
|
12 |
+
// module for analyzing MP3 files //
|
13 |
+
// dependencies: NONE //
|
14 |
+
// ///
|
15 |
+
/////////////////////////////////////////////////////////////////
|
16 |
+
|
17 |
+
|
18 |
+
// number of frames to scan to determine if MPEG-audio sequence is valid
|
19 |
+
// Lower this number to 5-20 for faster scanning
|
20 |
+
// Increase this number to 50+ for most accurate detection of valid VBR/CBR
|
21 |
+
// mpeg-audio streams
|
22 |
+
define('GETID3_MP3_VALID_CHECK_FRAMES', 35);
|
23 |
+
|
24 |
+
|
25 |
+
class getid3_mp3 extends getid3_handler
|
26 |
+
{
|
27 |
+
|
28 |
+
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
|
29 |
+
|
30 |
+
public function Analyze() {
|
31 |
+
$info = &$this->getid3->info;
|
32 |
+
|
33 |
+
$initialOffset = $info['avdataoffset'];
|
34 |
+
|
35 |
+
if (!$this->getOnlyMPEGaudioInfo($info['avdataoffset'])) {
|
36 |
+
if ($this->allow_bruteforce) {
|
37 |
+
$info['error'][] = 'Rescanning file in BruteForce mode';
|
38 |
+
$this->getOnlyMPEGaudioInfoBruteForce($this->getid3->fp, $info);
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
if (isset($info['mpeg']['audio']['bitrate_mode'])) {
|
44 |
+
$info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
|
45 |
+
}
|
46 |
+
|
47 |
+
if (((isset($info['id3v2']['headerlength']) && ($info['avdataoffset'] > $info['id3v2']['headerlength'])) || (!isset($info['id3v2']) && ($info['avdataoffset'] > 0) && ($info['avdataoffset'] != $initialOffset)))) {
|
48 |
+
|
49 |
+
$synchoffsetwarning = 'Unknown data before synch ';
|
50 |
+
if (isset($info['id3v2']['headerlength'])) {
|
51 |
+
$synchoffsetwarning .= '(ID3v2 header ends at '.$info['id3v2']['headerlength'].', then '.($info['avdataoffset'] - $info['id3v2']['headerlength']).' bytes garbage, ';
|
52 |
+
} elseif ($initialOffset > 0) {
|
53 |
+
$synchoffsetwarning .= '(should be at '.$initialOffset.', ';
|
54 |
+
} else {
|
55 |
+
$synchoffsetwarning .= '(should be at beginning of file, ';
|
56 |
+
}
|
57 |
+
$synchoffsetwarning .= 'synch detected at '.$info['avdataoffset'].')';
|
58 |
+
if (isset($info['audio']['bitrate_mode']) && ($info['audio']['bitrate_mode'] == 'cbr')) {
|
59 |
+
|
60 |
+
if (!empty($info['id3v2']['headerlength']) && (($info['avdataoffset'] - $info['id3v2']['headerlength']) == $info['mpeg']['audio']['framelength'])) {
|
61 |
+
|
62 |
+
$synchoffsetwarning .= '. This is a known problem with some versions of LAME (3.90-3.92) DLL in CBR mode.';
|
63 |
+
$info['audio']['codec'] = 'LAME';
|
64 |
+
$CurrentDataLAMEversionString = 'LAME3.';
|
65 |
+
|
66 |
+
} elseif (empty($info['id3v2']['headerlength']) && ($info['avdataoffset'] == $info['mpeg']['audio']['framelength'])) {
|
67 |
+
|
68 |
+
$synchoffsetwarning .= '. This is a known problem with some versions of LAME (3.90 - 3.92) DLL in CBR mode.';
|
69 |
+
$info['audio']['codec'] = 'LAME';
|
70 |
+
$CurrentDataLAMEversionString = 'LAME3.';
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
$info['warning'][] = $synchoffsetwarning;
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
if (isset($info['mpeg']['audio']['LAME'])) {
|
80 |
+
$info['audio']['codec'] = 'LAME';
|
81 |
+
if (!empty($info['mpeg']['audio']['LAME']['long_version'])) {
|
82 |
+
$info['audio']['encoder'] = rtrim($info['mpeg']['audio']['LAME']['long_version'], "\x00");
|
83 |
+
} elseif (!empty($info['mpeg']['audio']['LAME']['short_version'])) {
|
84 |
+
$info['audio']['encoder'] = rtrim($info['mpeg']['audio']['LAME']['short_version'], "\x00");
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
$CurrentDataLAMEversionString = (!empty($CurrentDataLAMEversionString) ? $CurrentDataLAMEversionString : (isset($info['audio']['encoder']) ? $info['audio']['encoder'] : ''));
|
89 |
+
if (!empty($CurrentDataLAMEversionString) && (substr($CurrentDataLAMEversionString, 0, 6) == 'LAME3.') && !preg_match('[0-9\)]', substr($CurrentDataLAMEversionString, -1))) {
|
90 |
+
// a version number of LAME that does not end with a number like "LAME3.92"
|
91 |
+
// or with a closing parenthesis like "LAME3.88 (alpha)"
|
92 |
+
// or a version of LAME with the LAMEtag-not-filled-in-DLL-mode bug (3.90-3.92)
|
93 |
+
|
94 |
+
// not sure what the actual last frame length will be, but will be less than or equal to 1441
|
95 |
+
$PossiblyLongerLAMEversion_FrameLength = 1441;
|
96 |
+
|
97 |
+
// Not sure what version of LAME this is - look in padding of last frame for longer version string
|
98 |
+
$PossibleLAMEversionStringOffset = $info['avdataend'] - $PossiblyLongerLAMEversion_FrameLength;
|
99 |
+
$this->fseek($PossibleLAMEversionStringOffset);
|
100 |
+
$PossiblyLongerLAMEversion_Data = $this->fread($PossiblyLongerLAMEversion_FrameLength);
|
101 |
+
switch (substr($CurrentDataLAMEversionString, -1)) {
|
102 |
+
case 'a':
|
103 |
+
case 'b':
|
104 |
+
// "LAME3.94a" will have a longer version string of "LAME3.94 (alpha)" for example
|
105 |
+
// need to trim off "a" to match longer string
|
106 |
+
$CurrentDataLAMEversionString = substr($CurrentDataLAMEversionString, 0, -1);
|
107 |
+
break;
|
108 |
+
}
|
109 |
+
if (($PossiblyLongerLAMEversion_String = strstr($PossiblyLongerLAMEversion_Data, $CurrentDataLAMEversionString)) !== false) {
|
110 |
+
if (substr($PossiblyLongerLAMEversion_String, 0, strlen($CurrentDataLAMEversionString)) == $CurrentDataLAMEversionString) {
|
111 |
+
$PossiblyLongerLAMEversion_NewString = substr($PossiblyLongerLAMEversion_String, 0, strspn($PossiblyLongerLAMEversion_String, 'LAME0123456789., (abcdefghijklmnopqrstuvwxyzJFSOND)')); //"LAME3.90.3" "LAME3.87 (beta 1, Sep 27 2000)" "LAME3.88 (beta)"
|
112 |
+
if (empty($info['audio']['encoder']) || (strlen($PossiblyLongerLAMEversion_NewString) > strlen($info['audio']['encoder']))) {
|
113 |
+
$info['audio']['encoder'] = $PossiblyLongerLAMEversion_NewString;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
if (!empty($info['audio']['encoder'])) {
|
119 |
+
$info['audio']['encoder'] = rtrim($info['audio']['encoder'], "\x00 ");
|
120 |
+
}
|
121 |
+
|
122 |
+
switch (isset($info['mpeg']['audio']['layer']) ? $info['mpeg']['audio']['layer'] : '') {
|
123 |
+
case 1:
|
124 |
+
case 2:
|
125 |
+
$info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer'];
|
126 |
+
break;
|
127 |
+
}
|
128 |
+
if (isset($info['fileformat']) && ($info['fileformat'] == 'mp3')) {
|
129 |
+
switch ($info['audio']['dataformat']) {
|
130 |
+
case 'mp1':
|
131 |
+
case 'mp2':
|
132 |
+
case 'mp3':
|
133 |
+
$info['fileformat'] = $info['audio']['dataformat'];
|
134 |
+
break;
|
135 |
+
|
136 |
+
default:
|
137 |
+
$info['warning'][] = 'Expecting [audio][dataformat] to be mp1/mp2/mp3 when fileformat == mp3, [audio][dataformat] actually "'.$info['audio']['dataformat'].'"';
|
138 |
+
break;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
if (empty($info['fileformat'])) {
|
143 |
+
unset($info['fileformat']);
|
144 |
+
unset($info['audio']['bitrate_mode']);
|
145 |
+
unset($info['avdataoffset']);
|
146 |
+
unset($info['avdataend']);
|
147 |
+
return false;
|
148 |
+
}
|
149 |
+
|
150 |
+
$info['mime_type'] = 'audio/mpeg';
|
151 |
+
$info['audio']['lossless'] = false;
|
152 |
+
|
153 |
+
// Calculate playtime
|
154 |
+
if (!isset($info['playtime_seconds']) && isset($info['audio']['bitrate']) && ($info['audio']['bitrate'] > 0)) {
|
155 |
+
$info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['audio']['bitrate'];
|
156 |
+
}
|
157 |
+
|
158 |
+
$info['audio']['encoder_options'] = $this->GuessEncoderOptions();
|
159 |
+
|
160 |
+
return true;
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
public function GuessEncoderOptions() {
|
165 |
+
// shortcuts
|
166 |
+
$info = &$this->getid3->info;
|
167 |
+
if (!empty($info['mpeg']['audio'])) {
|
168 |
+
$thisfile_mpeg_audio = &$info['mpeg']['audio'];
|
169 |
+
if (!empty($thisfile_mpeg_audio['LAME'])) {
|
170 |
+
$thisfile_mpeg_audio_lame = &$thisfile_mpeg_audio['LAME'];
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
$encoder_options = '';
|
175 |
+
static $NamedPresetBitrates = array(16, 24, 40, 56, 112, 128, 160, 192, 256);
|
176 |
+
|
177 |
+
if (isset($thisfile_mpeg_audio['VBR_method']) && ($thisfile_mpeg_audio['VBR_method'] == 'Fraunhofer') && !empty($thisfile_mpeg_audio['VBR_quality'])) {
|
178 |
+
|
179 |
+
$encoder_options = 'VBR q'.$thisfile_mpeg_audio['VBR_quality'];
|
180 |
+
|
181 |
+
} elseif (!empty($thisfile_mpeg_audio_lame['preset_used']) && (!in_array($thisfile_mpeg_audio_lame['preset_used_id'], $NamedPresetBitrates))) {
|
182 |
+
|
183 |
+
$encoder_options = $thisfile_mpeg_audio_lame['preset_used'];
|
184 |
+
|
185 |
+
} elseif (!empty($thisfile_mpeg_audio_lame['vbr_quality'])) {
|
186 |
+
|
187 |
+
static $KnownEncoderValues = array();
|
188 |
+
if (empty($KnownEncoderValues)) {
|
189 |
+
|
190 |
+
//$KnownEncoderValues[abrbitrate_minbitrate][vbr_quality][raw_vbr_method][raw_noise_shaping][raw_stereo_mode][ath_type][lowpass_frequency] = 'preset name';
|
191 |
+
$KnownEncoderValues[0xFF][58][1][1][3][2][20500] = '--alt-preset insane'; // 3.90, 3.90.1, 3.92
|
192 |
+
$KnownEncoderValues[0xFF][58][1][1][3][2][20600] = '--alt-preset insane'; // 3.90.2, 3.90.3, 3.91
|
193 |
+
$KnownEncoderValues[0xFF][57][1][1][3][4][20500] = '--alt-preset insane'; // 3.94, 3.95
|
194 |
+
$KnownEncoderValues['**'][78][3][2][3][2][19500] = '--alt-preset extreme'; // 3.90, 3.90.1, 3.92
|
195 |
+
$KnownEncoderValues['**'][78][3][2][3][2][19600] = '--alt-preset extreme'; // 3.90.2, 3.91
|
196 |
+
$KnownEncoderValues['**'][78][3][1][3][2][19600] = '--alt-preset extreme'; // 3.90.3
|
197 |
+
$KnownEncoderValues['**'][78][4][2][3][2][19500] = '--alt-preset fast extreme'; // 3.90, 3.90.1, 3.92
|
198 |
+
$KnownEncoderValues['**'][78][4][2][3][2][19600] = '--alt-preset fast extreme'; // 3.90.2, 3.90.3, 3.91
|
199 |
+
$KnownEncoderValues['**'][78][3][2][3][4][19000] = '--alt-preset standard'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92
|
200 |
+
$KnownEncoderValues['**'][78][3][1][3][4][19000] = '--alt-preset standard'; // 3.90.3
|
201 |
+
$KnownEncoderValues['**'][78][4][2][3][4][19000] = '--alt-preset fast standard'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92
|
202 |
+
$KnownEncoderValues['**'][78][4][1][3][4][19000] = '--alt-preset fast standard'; // 3.90.3
|
203 |
+
$KnownEncoderValues['**'][88][4][1][3][3][19500] = '--r3mix'; // 3.90, 3.90.1, 3.92
|
204 |
+
$KnownEncoderValues['**'][88][4][1][3][3][19600] = '--r3mix'; // 3.90.2, 3.90.3, 3.91
|
205 |
+
$KnownEncoderValues['**'][67][4][1][3][4][18000] = '--r3mix'; // 3.94, 3.95
|
206 |
+
$KnownEncoderValues['**'][68][3][2][3][4][18000] = '--alt-preset medium'; // 3.90.3
|
207 |
+
$KnownEncoderValues['**'][68][4][2][3][4][18000] = '--alt-preset fast medium'; // 3.90.3
|
208 |
+
|
209 |
+
$KnownEncoderValues[0xFF][99][1][1][1][2][0] = '--preset studio'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92
|
210 |
+
$KnownEncoderValues[0xFF][58][2][1][3][2][20600] = '--preset studio'; // 3.90.3, 3.93.1
|
211 |
+
$KnownEncoderValues[0xFF][58][2][1][3][2][20500] = '--preset studio'; // 3.93
|
212 |
+
$KnownEncoderValues[0xFF][57][2][1][3][4][20500] = '--preset studio'; // 3.94, 3.95
|
213 |
+
$KnownEncoderValues[0xC0][88][1][1][1][2][0] = '--preset cd'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92
|
214 |
+
$KnownEncoderValues[0xC0][58][2][2][3][2][19600] = '--preset cd'; // 3.90.3, 3.93.1
|
215 |
+
$KnownEncoderValues[0xC0][58][2][2][3][2][19500] = '--preset cd'; // 3.93
|
216 |
+
$KnownEncoderValues[0xC0][57][2][1][3][4][19500] = '--preset cd'; // 3.94, 3.95
|
217 |
+
$KnownEncoderValues[0xA0][78][1][1][3][2][18000] = '--preset hifi'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92
|
218 |
+
$KnownEncoderValues[0xA0][58][2][2][3][2][18000] = '--preset hifi'; // 3.90.3, 3.93, 3.93.1
|
219 |
+
$KnownEncoderValues[0xA0][57][2][1][3][4][18000] = '--preset hifi'; // 3.94, 3.95
|
220 |
+
$KnownEncoderValues[0x80][67][1][1][3][2][18000] = '--preset tape'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92
|
221 |
+
$KnownEncoderValues[0x80][67][1][1][3][2][15000] = '--preset radio'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92
|
222 |
+
$KnownEncoderValues[0x70][67][1][1][3][2][15000] = '--preset fm'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92
|
223 |
+
$KnownEncoderValues[0x70][58][2][2][3][2][16000] = '--preset tape/radio/fm'; // 3.90.3, 3.93, 3.93.1
|
224 |
+
$KnownEncoderValues[0x70][57][2][1][3][4][16000] = '--preset tape/radio/fm'; // 3.94, 3.95
|
225 |
+
$KnownEncoderValues[0x38][58][2][2][0][2][10000] = '--preset voice'; // 3.90.3, 3.93, 3.93.1
|
226 |
+
$KnownEncoderValues[0x38][57][2][1][0][4][15000] = '--preset voice'; // 3.94, 3.95
|
227 |
+
$KnownEncoderValues[0x38][57][2][1][0][4][16000] = '--preset voice'; // 3.94a14
|
228 |
+
$KnownEncoderValues[0x28][65][1][1][0][2][7500] = '--preset mw-us'; // 3.90, 3.90.1, 3.92
|
229 |
+
$KnownEncoderValues[0x28][65][1][1][0][2][7600] = '--preset mw-us'; // 3.90.2, 3.91
|
230 |
+
$KnownEncoderValues[0x28][58][2][2][0][2][7000] = '--preset mw-us'; // 3.90.3, 3.93, 3.93.1
|
231 |
+
$KnownEncoderValues[0x28][57][2][1][0][4][10500] = '--preset mw-us'; // 3.94, 3.95
|
232 |
+
$KnownEncoderValues[0x28][57][2][1][0][4][11200] = '--preset mw-us'; // 3.94a14
|
233 |
+
$KnownEncoderValues[0x28][57][2][1][0][4][8800] = '--preset mw-us'; // 3.94a15
|
234 |
+
$KnownEncoderValues[0x18][58][2][2][0][2][4000] = '--preset phon+/lw/mw-eu/sw'; // 3.90.3, 3.93.1
|
235 |
+
$KnownEncoderValues[0x18][58][2][2][0][2][3900] = '--preset phon+/lw/mw-eu/sw'; // 3.93
|
236 |
+
$KnownEncoderValues[0x18][57][2][1][0][4][5900] = '--preset phon+/lw/mw-eu/sw'; // 3.94, 3.95
|
237 |
+
$KnownEncoderValues[0x18][57][2][1][0][4][6200] = '--preset phon+/lw/mw-eu/sw'; // 3.94a14
|
238 |
+
$KnownEncoderValues[0x18][57][2][1][0][4][3200] = '--preset phon+/lw/mw-eu/sw'; // 3.94a15
|
239 |
+
$KnownEncoderValues[0x10][58][2][2][0][2][3800] = '--preset phone'; // 3.90.3, 3.93.1
|
240 |
+
$KnownEncoderValues[0x10][58][2][2][0][2][3700] = '--preset phone'; // 3.93
|
241 |
+
$KnownEncoderValues[0x10][57][2][1][0][4][5600] = '--preset phone'; // 3.94, 3.95
|
242 |
+
}
|
243 |
+
|
244 |
+
if (isset($KnownEncoderValues[$thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate']][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']])) {
|
245 |
+
|
246 |
+
$encoder_options = $KnownEncoderValues[$thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate']][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']];
|
247 |
+
|
248 |
+
} elseif (isset($KnownEncoderValues['**'][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']])) {
|
249 |
+
|
250 |
+
$encoder_options = $KnownEncoderValues['**'][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']];
|
251 |
+
|
252 |
+
} elseif ($info['audio']['bitrate_mode'] == 'vbr') {
|
253 |
+
|
254 |
+
// http://gabriel.mp3-tech.org/mp3infotag.html
|
255 |
+
// int Quality = (100 - 10 * gfp->VBR_q - gfp->quality)h
|
256 |
+
|
257 |
+
|
258 |
+
$LAME_V_value = 10 - ceil($thisfile_mpeg_audio_lame['vbr_quality'] / 10);
|
259 |
+
$LAME_q_value = 100 - $thisfile_mpeg_audio_lame['vbr_quality'] - ($LAME_V_value * 10);
|
260 |
+
$encoder_options = '-V'.$LAME_V_value.' -q'.$LAME_q_value;
|
261 |
+
|
262 |
+
} elseif ($info['audio']['bitrate_mode'] == 'cbr') {
|
263 |
+
|
264 |
+
$encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000);
|
265 |
+
|
266 |
+
} else {
|
267 |
+
|
268 |
+
$encoder_options = strtoupper($info['audio']['bitrate_mode']);
|
269 |
+
|
270 |
+
}
|
271 |
+
|
272 |
+
} elseif (!empty($thisfile_mpeg_audio_lame['bitrate_abr'])) {
|
273 |
+
|
274 |
+
$encoder_options = 'ABR'.$thisfile_mpeg_audio_lame['bitrate_abr'];
|
275 |
+
|
276 |
+
} elseif (!empty($info['audio']['bitrate'])) {
|
277 |
+
|
278 |
+
if ($info['audio']['bitrate_mode'] == 'cbr') {
|
279 |
+
$encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000);
|
280 |
+
} else {
|
281 |
+
$encoder_options = strtoupper($info['audio']['bitrate_mode']);
|
282 |
+
}
|
283 |
+
|
284 |
+
}
|
285 |
+
if (!empty($thisfile_mpeg_audio_lame['bitrate_min'])) {
|
286 |
+
$encoder_options .= ' -b'.$thisfile_mpeg_audio_lame['bitrate_min'];
|
287 |
+
}
|
288 |
+
|
289 |
+
if (!empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev']) || !empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_next'])) {
|
290 |
+
$encoder_options .= ' --nogap';
|
291 |
+
}
|
292 |
+
|
293 |
+
if (!empty($thisfile_mpeg_audio_lame['lowpass_frequency'])) {
|
294 |
+
$ExplodedOptions = explode(' ', $encoder_options, 4);
|
295 |
+
if ($ExplodedOptions[0] == '--r3mix') {
|
296 |
+
$ExplodedOptions[1] = 'r3mix';
|
297 |
+
}
|
298 |
+
switch ($ExplodedOptions[0]) {
|
299 |
+
case '--preset':
|
300 |
+
case '--alt-preset':
|
301 |
+
case '--r3mix':
|
302 |
+
if ($ExplodedOptions[1] == 'fast') {
|
303 |
+
$ExplodedOptions[1] .= ' '.$ExplodedOptions[2];
|
304 |
+
}
|
305 |
+
switch ($ExplodedOptions[1]) {
|
306 |
+
case 'portable':
|
307 |
+
case 'medium':
|
308 |
+
case 'standard':
|
309 |
+
case 'extreme':
|
310 |
+
case 'insane':
|
311 |
+
case 'fast portable':
|
312 |
+
case 'fast medium':
|
313 |
+
case 'fast standard':
|
314 |
+
case 'fast extreme':
|
315 |
+
case 'fast insane':
|
316 |
+
case 'r3mix':
|
317 |
+
static $ExpectedLowpass = array(
|
318 |
+
'insane|20500' => 20500,
|
319 |
+
'insane|20600' => 20600, // 3.90.2, 3.90.3, 3.91
|
320 |
+
'medium|18000' => 18000,
|
321 |
+
'fast medium|18000' => 18000,
|
322 |
+
'extreme|19500' => 19500, // 3.90, 3.90.1, 3.92, 3.95
|
323 |
+
'extreme|19600' => 19600, // 3.90.2, 3.90.3, 3.91, 3.93.1
|
324 |
+
'fast extreme|19500' => 19500, // 3.90, 3.90.1, 3.92, 3.95
|
325 |
+
'fast extreme|19600' => 19600, // 3.90.2, 3.90.3, 3.91, 3.93.1
|
326 |
+
'standard|19000' => 19000,
|
327 |
+
'fast standard|19000' => 19000,
|
328 |
+
'r3mix|19500' => 19500, // 3.90, 3.90.1, 3.92
|
329 |
+
'r3mix|19600' => 19600, // 3.90.2, 3.90.3, 3.91
|
330 |
+
'r3mix|18000' => 18000, // 3.94, 3.95
|
331 |
+
);
|
332 |
+
if (!isset($ExpectedLowpass[$ExplodedOptions[1].'|'.$thisfile_mpeg_audio_lame['lowpass_frequency']]) && ($thisfile_mpeg_audio_lame['lowpass_frequency'] < 22050) && (round($thisfile_mpeg_audio_lame['lowpass_frequency'] / 1000) < round($thisfile_mpeg_audio['sample_rate'] / 2000))) {
|
333 |
+
$encoder_options .= ' --lowpass '.$thisfile_mpeg_audio_lame['lowpass_frequency'];
|
334 |
+
}
|
335 |
+
break;
|
336 |
+
|
337 |
+
default:
|
338 |
+
break;
|
339 |
+
}
|
340 |
+
break;
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
if (isset($thisfile_mpeg_audio_lame['raw']['source_sample_freq'])) {
|
345 |
+
if (($thisfile_mpeg_audio['sample_rate'] == 44100) && ($thisfile_mpeg_audio_lame['raw']['source_sample_freq'] != 1)) {
|
346 |
+
$encoder_options .= ' --resample 44100';
|
347 |
+
} elseif (($thisfile_mpeg_audio['sample_rate'] == 48000) && ($thisfile_mpeg_audio_lame['raw']['source_sample_freq'] != 2)) {
|
348 |
+
$encoder_options .= ' --resample 48000';
|
349 |
+
} elseif ($thisfile_mpeg_audio['sample_rate'] < 44100) {
|
350 |
+
switch ($thisfile_mpeg_audio_lame['raw']['source_sample_freq']) {
|
351 |
+
case 0: // <= 32000
|
352 |
+
// may or may not be same as source frequency - ignore
|
353 |
+
break;
|
354 |
+
case 1: // 44100
|
355 |
+
case 2: // 48000
|
356 |
+
case 3: // 48000+
|
357 |
+
$ExplodedOptions = explode(' ', $encoder_options, 4);
|
358 |
+
switch ($ExplodedOptions[0]) {
|
359 |
+
case '--preset':
|
360 |
+
case '--alt-preset':
|
361 |
+
switch ($ExplodedOptions[1]) {
|
362 |
+
case 'fast':
|
363 |
+
case 'portable':
|
364 |
+
case 'medium':
|
365 |
+
case 'standard':
|
366 |
+
case 'extreme':
|
367 |
+
case 'insane':
|
368 |
+
$encoder_options .= ' --resample '.$thisfile_mpeg_audio['sample_rate'];
|
369 |
+
break;
|
370 |
+
|
371 |
+
default:
|
372 |
+
static $ExpectedResampledRate = array(
|
373 |
+
'phon+/lw/mw-eu/sw|16000' => 16000,
|
374 |
+
'mw-us|24000' => 24000, // 3.95
|
375 |
+
'mw-us|32000' => 32000, // 3.93
|
376 |
+
'mw-us|16000' => 16000, // 3.92
|
377 |
+
'phone|16000' => 16000,
|
378 |
+
'phone|11025' => 11025, // 3.94a15
|
379 |
+
'radio|32000' => 32000, // 3.94a15
|
380 |
+
'fm/radio|32000' => 32000, // 3.92
|
381 |
+
'fm|32000' => 32000, // 3.90
|
382 |
+
'voice|32000' => 32000);
|
383 |
+
if (!isset($ExpectedResampledRate[$ExplodedOptions[1].'|'.$thisfile_mpeg_audio['sample_rate']])) {
|
384 |
+
$encoder_options .= ' --resample '.$thisfile_mpeg_audio['sample_rate'];
|
385 |
+
}
|
386 |
+
break;
|
387 |
+
}
|
388 |
+
break;
|
389 |
+
|
390 |
+
case '--r3mix':
|
391 |
+
default:
|
392 |
+
$encoder_options .= ' --resample '.$thisfile_mpeg_audio['sample_rate'];
|
393 |
+
break;
|
394 |
+
}
|
395 |
+
break;
|
396 |
+
}
|
397 |
+
}
|
398 |
+
}
|
399 |
+
if (empty($encoder_options) && !empty($info['audio']['bitrate']) && !empty($info['audio']['bitrate_mode'])) {
|
400 |
+
//$encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000);
|
401 |
+
$encoder_options = strtoupper($info['audio']['bitrate_mode']);
|
402 |
+
}
|
403 |
+
|
404 |
+
return $encoder_options;
|
405 |
+
}
|
406 |
+
|
407 |
+
|
408 |
+
public function decodeMPEGaudioHeader($offset, &$info, $recursivesearch=true, $ScanAsCBR=false, $FastMPEGheaderScan=false) {
|
409 |
+
static $MPEGaudioVersionLookup;
|
410 |
+
static $MPEGaudioLayerLookup;
|
411 |
+
static $MPEGaudioBitrateLookup;
|
412 |
+
static $MPEGaudioFrequencyLookup;
|
413 |
+
static $MPEGaudioChannelModeLookup;
|
414 |
+
static $MPEGaudioModeExtensionLookup;
|
415 |
+
static $MPEGaudioEmphasisLookup;
|
416 |
+
if (empty($MPEGaudioVersionLookup)) {
|
417 |
+
$MPEGaudioVersionLookup = self::MPEGaudioVersionArray();
|
418 |
+
$MPEGaudioLayerLookup = self::MPEGaudioLayerArray();
|
419 |
+
$MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray();
|
420 |
+
$MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray();
|
421 |
+
$MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray();
|
422 |
+
$MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray();
|
423 |
+
$MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray();
|
424 |
+
}
|
425 |
+
|
426 |
+
if ($this->fseek($offset) != 0) {
|
427 |
+
$info['error'][] = 'decodeMPEGaudioHeader() failed to seek to next offset at '.$offset;
|
428 |
+
return false;
|
429 |
+
}
|
430 |
+
//$headerstring = $this->fread(1441); // worst-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame
|
431 |
+
$headerstring = $this->fread(226); // LAME header at offset 36 + 190 bytes of Xing/LAME data
|
432 |
+
|
433 |
+
// MP3 audio frame structure:
|
434 |
+
// $aa $aa $aa $aa [$bb $bb] $cc...
|
435 |
+
// where $aa..$aa is the four-byte mpeg-audio header (below)
|
436 |
+
// $bb $bb is the optional 2-byte CRC
|
437 |
+
// and $cc... is the audio data
|
438 |
+
|
439 |
+
$head4 = substr($headerstring, 0, 4);
|
440 |
+
|
441 |
+
static $MPEGaudioHeaderDecodeCache = array();
|
442 |
+
if (isset($MPEGaudioHeaderDecodeCache[$head4])) {
|
443 |
+
$MPEGheaderRawArray = $MPEGaudioHeaderDecodeCache[$head4];
|
444 |
+
} else {
|
445 |
+
$MPEGheaderRawArray = self::MPEGaudioHeaderDecode($head4);
|
446 |
+
$MPEGaudioHeaderDecodeCache[$head4] = $MPEGheaderRawArray;
|
447 |
+
}
|
448 |
+
|
449 |
+
static $MPEGaudioHeaderValidCache = array();
|
450 |
+
if (!isset($MPEGaudioHeaderValidCache[$head4])) { // Not in cache
|
451 |
+
//$MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGheaderRawArray, false, true); // allow badly-formatted freeformat (from LAME 3.90 - 3.93.1)
|
452 |
+
$MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGheaderRawArray, false, false);
|
453 |
+
}
|
454 |
+
|
455 |
+
// shortcut
|
456 |
+
if (!isset($info['mpeg']['audio'])) {
|
457 |
+
$info['mpeg']['audio'] = array();
|
458 |
+
}
|
459 |
+
$thisfile_mpeg_audio = &$info['mpeg']['audio'];
|
460 |
+
|
461 |
+
|
462 |
+
if ($MPEGaudioHeaderValidCache[$head4]) {
|
463 |
+
$thisfile_mpeg_audio['raw'] = $MPEGheaderRawArray;
|
464 |
+
} else {
|
465 |
+
$info['error'][] = 'Invalid MPEG audio header ('.getid3_lib::PrintHexBytes($head4).') at offset '.$offset;
|
466 |
+
return false;
|
467 |
+
}
|
468 |
+
|
469 |
+
if (!$FastMPEGheaderScan) {
|
470 |
+
$thisfile_mpeg_audio['version'] = $MPEGaudioVersionLookup[$thisfile_mpeg_audio['raw']['version']];
|
471 |
+
$thisfile_mpeg_audio['layer'] = $MPEGaudioLayerLookup[$thisfile_mpeg_audio['raw']['layer']];
|
472 |
+
|
473 |
+
$thisfile_mpeg_audio['channelmode'] = $MPEGaudioChannelModeLookup[$thisfile_mpeg_audio['raw']['channelmode']];
|
474 |
+
$thisfile_mpeg_audio['channels'] = (($thisfile_mpeg_audio['channelmode'] == 'mono') ? 1 : 2);
|
475 |
+
$thisfile_mpeg_audio['sample_rate'] = $MPEGaudioFrequencyLookup[$thisfile_mpeg_audio['version']][$thisfile_mpeg_audio['raw']['sample_rate']];
|
476 |
+
$thisfile_mpeg_audio['protection'] = !$thisfile_mpeg_audio['raw']['protection'];
|
477 |
+
$thisfile_mpeg_audio['private'] = (bool) $thisfile_mpeg_audio['raw']['private'];
|
478 |
+
$thisfile_mpeg_audio['modeextension'] = $MPEGaudioModeExtensionLookup[$thisfile_mpeg_audio['layer']][$thisfile_mpeg_audio['raw']['modeextension']];
|
479 |
+
$thisfile_mpeg_audio['copyright'] = (bool) $thisfile_mpeg_audio['raw']['copyright'];
|
480 |
+
$thisfile_mpeg_audio['original'] = (bool) $thisfile_mpeg_audio['raw']['original'];
|
481 |
+
$thisfile_mpeg_audio['emphasis'] = $MPEGaudioEmphasisLookup[$thisfile_mpeg_audio['raw']['emphasis']];
|
482 |
+
|
483 |
+
$info['audio']['channels'] = $thisfile_mpeg_audio['channels'];
|
484 |
+
$info['audio']['sample_rate'] = $thisfile_mpeg_audio['sample_rate'];
|
485 |
+
|
486 |
+
if ($thisfile_mpeg_audio['protection']) {
|
487 |
+
$thisfile_mpeg_audio['crc'] = getid3_lib::BigEndian2Int(substr($headerstring, 4, 2));
|
488 |
+
}
|
489 |
+
}
|
490 |
+
|
491 |
+
if ($thisfile_mpeg_audio['raw']['bitrate'] == 15) {
|
492 |
+
// http://www.hydrogenaudio.org/?act=ST&f=16&t=9682&st=0
|
493 |
+
$info['warning'][] = 'Invalid bitrate index (15), this is a known bug in free-format MP3s encoded by LAME v3.90 - 3.93.1';
|
494 |
+
$thisfile_mpeg_audio['raw']['bitrate'] = 0;
|
495 |
+
}
|
496 |
+
$thisfile_mpeg_audio['padding'] = (bool) $thisfile_mpeg_audio['raw']['padding'];
|
497 |
+
$thisfile_mpeg_audio['bitrate'] = $MPEGaudioBitrateLookup[$thisfile_mpeg_audio['version']][$thisfile_mpeg_audio['layer']][$thisfile_mpeg_audio['raw']['bitrate']];
|
498 |
+
|
499 |
+
if (($thisfile_mpeg_audio['bitrate'] == 'free') && ($offset == $info['avdataoffset'])) {
|
500 |
+
// only skip multiple frame check if free-format bitstream found at beginning of file
|
501 |
+
// otherwise is quite possibly simply corrupted data
|
502 |
+
$recursivesearch = false;
|
503 |
+
}
|
504 |
+
|
505 |
+
// For Layer 2 there are some combinations of bitrate and mode which are not allowed.
|
506 |
+
if (!$FastMPEGheaderScan && ($thisfile_mpeg_audio['layer'] == '2')) {
|
507 |
+
|
508 |
+
$info['audio']['dataformat'] = 'mp2';
|
509 |
+
switch ($thisfile_mpeg_audio['channelmode']) {
|
510 |
+
|
511 |
+
case 'mono':
|
512 |
+
if (($thisfile_mpeg_audio['bitrate'] == 'free') || ($thisfile_mpeg_audio['bitrate'] <= 192000)) {
|
513 |
+
// these are ok
|
514 |
+
} else {
|
515 |
+
$info['error'][] = $thisfile_mpeg_audio['bitrate'].'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio['channelmode'].'.';
|
516 |
+
return false;
|
517 |
+
}
|
518 |
+
break;
|
519 |
+
|
520 |
+
case 'stereo':
|
521 |
+
case 'joint stereo':
|
522 |
+
case 'dual channel':
|
523 |
+
if (($thisfile_mpeg_audio['bitrate'] == 'free') || ($thisfile_mpeg_audio['bitrate'] == 64000) || ($thisfile_mpeg_audio['bitrate'] >= 96000)) {
|
524 |
+
// these are ok
|
525 |
+
} else {
|
526 |
+
$info['error'][] = intval(round($thisfile_mpeg_audio['bitrate'] / 1000)).'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio['channelmode'].'.';
|
527 |
+
return false;
|
528 |
+
}
|
529 |
+
break;
|
530 |
+
|
531 |
+
}
|
532 |
+
|
533 |
+
}
|
534 |
+
|
535 |
+
|
536 |
+
if ($info['audio']['sample_rate'] > 0) {
|
537 |
+
$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']);
|
538 |
+
}
|
539 |
+
|
540 |
+
$nextframetestoffset = $offset + 1;
|
541 |
+
if ($thisfile_mpeg_audio['bitrate'] != 'free') {
|
542 |
+
|
543 |
+
$info['audio']['bitrate'] = $thisfile_mpeg_audio['bitrate'];
|
544 |
+
|
545 |
+
if (isset($thisfile_mpeg_audio['framelength'])) {
|
546 |
+
$nextframetestoffset = $offset + $thisfile_mpeg_audio['framelength'];
|
547 |
+
} else {
|
548 |
+
$info['error'][] = 'Frame at offset('.$offset.') is has an invalid frame length.';
|
549 |
+
return false;
|
550 |
+
}
|
551 |
+
|
552 |
+
}
|
553 |
+
|
554 |
+
$ExpectedNumberOfAudioBytes = 0;
|
555 |
+
|
556 |
+
////////////////////////////////////////////////////////////////////////////////////
|
557 |
+
// Variable-bitrate headers
|
558 |
+
|
559 |
+
if (substr($headerstring, 4 + 32, 4) == 'VBRI') {
|
560 |
+
// Fraunhofer VBR header is hardcoded 'VBRI' at offset 0x24 (36)
|
561 |
+
// specs taken from http://minnie.tuhs.org/pipermail/mp3encoder/2001-January/001800.html
|
562 |
+
|
563 |
+
$thisfile_mpeg_audio['bitrate_mode'] = 'vbr';
|
564 |
+
$thisfile_mpeg_audio['VBR_method'] = 'Fraunhofer';
|
565 |
+
$info['audio']['codec'] = 'Fraunhofer';
|
566 |
+
|
567 |
+
$SideInfoData = substr($headerstring, 4 + 2, 32);
|
568 |
+
|
569 |
+
$FraunhoferVBROffset = 36;
|
570 |
+
|
571 |
+
$thisfile_mpeg_audio['VBR_encoder_version'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 4, 2)); // VbriVersion
|
572 |
+
$thisfile_mpeg_audio['VBR_encoder_delay'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 6, 2)); // VbriDelay
|
573 |
+
$thisfile_mpeg_audio['VBR_quality'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 8, 2)); // VbriQuality
|
574 |
+
$thisfile_mpeg_audio['VBR_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 10, 4)); // VbriStreamBytes
|
575 |
+
$thisfile_mpeg_audio['VBR_frames'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 14, 4)); // VbriStreamFrames
|
576 |
+
$thisfile_mpeg_audio['VBR_seek_offsets'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 18, 2)); // VbriTableSize
|
577 |
+
$thisfile_mpeg_audio['VBR_seek_scale'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 20, 2)); // VbriTableScale
|
578 |
+
$thisfile_mpeg_audio['VBR_entry_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 22, 2)); // VbriEntryBytes
|
579 |
+
$thisfile_mpeg_audio['VBR_entry_frames'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 24, 2)); // VbriEntryFrames
|
580 |
+
|
581 |
+
$ExpectedNumberOfAudioBytes = $thisfile_mpeg_audio['VBR_bytes'];
|
582 |
+
|
583 |
+
$previousbyteoffset = $offset;
|
584 |
+
for ($i = 0; $i < $thisfile_mpeg_audio['VBR_seek_offsets']; $i++) {
|
585 |
+
$Fraunhofer_OffsetN = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset, $thisfile_mpeg_audio['VBR_entry_bytes']));
|
586 |
+
$FraunhoferVBROffset += $thisfile_mpeg_audio['VBR_entry_bytes'];
|
587 |
+
$thisfile_mpeg_audio['VBR_offsets_relative'][$i] = ($Fraunhofer_OffsetN * $thisfile_mpeg_audio['VBR_seek_scale']);
|
588 |
+
$thisfile_mpeg_audio['VBR_offsets_absolute'][$i] = ($Fraunhofer_OffsetN * $thisfile_mpeg_audio['VBR_seek_scale']) + $previousbyteoffset;
|
589 |
+
$previousbyteoffset += $Fraunhofer_OffsetN;
|
590 |
+
}
|
591 |
+
|
592 |
+
|
593 |
+
} else {
|
594 |
+
|
595 |
+
// Xing VBR header is hardcoded 'Xing' at a offset 0x0D (13), 0x15 (21) or 0x24 (36)
|
596 |
+
// depending on MPEG layer and number of channels
|
597 |
+
|
598 |
+
$VBRidOffset = self::XingVBRidOffset($thisfile_mpeg_audio['version'], $thisfile_mpeg_audio['channelmode']);
|
599 |
+
$SideInfoData = substr($headerstring, 4 + 2, $VBRidOffset - 4);
|
600 |
+
|
601 |
+
if ((substr($headerstring, $VBRidOffset, strlen('Xing')) == 'Xing') || (substr($headerstring, $VBRidOffset, strlen('Info')) == 'Info')) {
|
602 |
+
// 'Xing' is traditional Xing VBR frame
|
603 |
+
// 'Info' is LAME-encoded CBR (This was done to avoid CBR files to be recognized as traditional Xing VBR files by some decoders.)
|
604 |
+
// 'Info' *can* legally be used to specify a VBR file as well, however.
|
605 |
+
|
606 |
+
// http://www.multiweb.cz/twoinches/MP3inside.htm
|
607 |
+
//00..03 = "Xing" or "Info"
|
608 |
+
//04..07 = Flags:
|
609 |
+
// 0x01 Frames Flag set if value for number of frames in file is stored
|
610 |
+
// 0x02 Bytes Flag set if value for filesize in bytes is stored
|
611 |
+
// 0x04 TOC Flag set if values for TOC are stored
|
612 |
+
// 0x08 VBR Scale Flag set if values for VBR scale is stored
|
613 |
+
//08..11 Frames: Number of frames in file (including the first Xing/Info one)
|
614 |
+
//12..15 Bytes: File length in Bytes
|
615 |
+
//16..115 TOC (Table of Contents):
|
616 |
+
// Contains of 100 indexes (one Byte length) for easier lookup in file. Approximately solves problem with moving inside file.
|
617 |
+
// Each Byte has a value according this formula:
|
618 |
+
// (TOC[i] / 256) * fileLenInBytes
|
619 |
+
// So if song lasts eg. 240 sec. and you want to jump to 60. sec. (and file is 5 000 000 Bytes length) you can use:
|
620 |
+
// TOC[(60/240)*100] = TOC[25]
|
621 |
+
// and corresponding Byte in file is then approximately at:
|
622 |
+
// (TOC[25]/256) * 5000000
|
623 |
+
//116..119 VBR Scale
|
624 |
+
|
625 |
+
|
626 |
+
// should be safe to leave this at 'vbr' and let it be overriden to 'cbr' if a CBR preset/mode is used by LAME
|
627 |
+
// if (substr($headerstring, $VBRidOffset, strlen('Info')) == 'Xing') {
|
628 |
+
$thisfile_mpeg_audio['bitrate_mode'] = 'vbr';
|
629 |
+
$thisfile_mpeg_audio['VBR_method'] = 'Xing';
|
630 |
+
// } else {
|
631 |
+
// $ScanAsCBR = true;
|
632 |
+
// $thisfile_mpeg_audio['bitrate_mode'] = 'cbr';
|
633 |
+
// }
|
634 |
+
|
635 |
+
$thisfile_mpeg_audio['xing_flags_raw'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 4, 4));
|
636 |
+
|
637 |
+
$thisfile_mpeg_audio['xing_flags']['frames'] = (bool) ($thisfile_mpeg_audio['xing_flags_raw'] & 0x00000001);
|
638 |
+
$thisfile_mpeg_audio['xing_flags']['bytes'] = (bool) ($thisfile_mpeg_audio['xing_flags_raw'] & 0x00000002);
|
639 |
+
$thisfile_mpeg_audio['xing_flags']['toc'] = (bool) ($thisfile_mpeg_audio['xing_flags_raw'] & 0x00000004);
|
640 |
+
$thisfile_mpeg_audio['xing_flags']['vbr_scale'] = (bool) ($thisfile_mpeg_audio['xing_flags_raw'] & 0x00000008);
|
641 |
+
|
642 |
+
if ($thisfile_mpeg_audio['xing_flags']['frames']) {
|
643 |
+
$thisfile_mpeg_audio['VBR_frames'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 8, 4));
|
644 |
+
//$thisfile_mpeg_audio['VBR_frames']--; // don't count header Xing/Info frame
|
645 |
+
}
|
646 |
+
if ($thisfile_mpeg_audio['xing_flags']['bytes']) {
|
647 |
+
$thisfile_mpeg_audio['VBR_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 12, 4));
|
648 |
+
}
|
649 |
+
|
650 |
+
//if (($thisfile_mpeg_audio['bitrate'] == 'free') && !empty($thisfile_mpeg_audio['VBR_frames']) && !empty($thisfile_mpeg_audio['VBR_bytes'])) {
|
651 |
+
if (!empty($thisfile_mpeg_audio['VBR_frames']) && !empty($thisfile_mpeg_audio['VBR_bytes'])) {
|
652 |
+
|
653 |
+
$framelengthfloat = $thisfile_mpeg_audio['VBR_bytes'] / $thisfile_mpeg_audio['VBR_frames'];
|
654 |
+
|
655 |
+
if ($thisfile_mpeg_audio['layer'] == '1') {
|
656 |
+
// BitRate = (((FrameLengthInBytes / 4) - Padding) * SampleRate) / 12
|
657 |
+
//$info['audio']['bitrate'] = ((($framelengthfloat / 4) - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 12;
|
658 |
+
$info['audio']['bitrate'] = ($framelengthfloat / 4) * $thisfile_mpeg_audio['sample_rate'] * (2 / $info['audio']['channels']) / 12;
|
659 |
+
} else {
|
660 |
+
// Bitrate = ((FrameLengthInBytes - Padding) * SampleRate) / 144
|
661 |
+
//$info['audio']['bitrate'] = (($framelengthfloat - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 144;
|
662 |
+
$info['audio']['bitrate'] = $framelengthfloat * $thisfile_mpeg_audio['sample_rate'] * (2 / $info['audio']['channels']) / 144;
|
663 |
+
}
|
664 |
+
$thisfile_mpeg_audio['framelength'] = floor($framelengthfloat);
|
665 |
+
}
|
666 |
+
|
667 |
+
if ($thisfile_mpeg_audio['xing_flags']['toc']) {
|
668 |
+
$LAMEtocData = substr($headerstring, $VBRidOffset + 16, 100);
|
669 |
+
for ($i = 0; $i < 100; $i++) {
|
670 |
+
$thisfile_mpeg_audio['toc'][$i] = ord($LAMEtocData{$i});
|
671 |
+
}
|
672 |
+
}
|
673 |
+
if ($thisfile_mpeg_audio['xing_flags']['vbr_scale']) {
|
674 |
+
$thisfile_mpeg_audio['VBR_scale'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 116, 4));
|
675 |
+
}
|
676 |
+
|
677 |
+
|
678 |
+
// http://gabriel.mp3-tech.org/mp3infotag.html
|
679 |
+
if (substr($headerstring, $VBRidOffset + 120, 4) == 'LAME') {
|
680 |
+
|
681 |
+
// shortcut
|
682 |
+
$thisfile_mpeg_audio['LAME'] = array();
|
683 |
+
$thisfile_mpeg_audio_lame = &$thisfile_mpeg_audio['LAME'];
|
684 |
+
|
685 |
+
|
686 |
+
$thisfile_mpeg_audio_lame['long_version'] = substr($headerstring, $VBRidOffset + 120, 20);
|
687 |
+
$thisfile_mpeg_audio_lame['short_version'] = substr($thisfile_mpeg_audio_lame['long_version'], 0, 9);
|
688 |
+
|
689 |
+
if ($thisfile_mpeg_audio_lame['short_version'] >= 'LAME3.90') {
|
690 |
+
|
691 |
+
// extra 11 chars are not part of version string when LAMEtag present
|
692 |
+
unset($thisfile_mpeg_audio_lame['long_version']);
|
693 |
+
|
694 |
+
// It the LAME tag was only introduced in LAME v3.90
|
695 |
+
// http://www.hydrogenaudio.org/?act=ST&f=15&t=9933
|
696 |
+
|
697 |
+
// Offsets of various bytes in http://gabriel.mp3-tech.org/mp3infotag.html
|
698 |
+
// are assuming a 'Xing' identifier offset of 0x24, which is the case for
|
699 |
+
// MPEG-1 non-mono, but not for other combinations
|
700 |
+
$LAMEtagOffsetContant = $VBRidOffset - 0x24;
|
701 |
+
|
702 |
+
// shortcuts
|
703 |
+
$thisfile_mpeg_audio_lame['RGAD'] = array('track'=>array(), 'album'=>array());
|
704 |
+
$thisfile_mpeg_audio_lame_RGAD = &$thisfile_mpeg_audio_lame['RGAD'];
|
705 |
+
$thisfile_mpeg_audio_lame_RGAD_track = &$thisfile_mpeg_audio_lame_RGAD['track'];
|
706 |
+
$thisfile_mpeg_audio_lame_RGAD_album = &$thisfile_mpeg_audio_lame_RGAD['album'];
|
707 |
+
$thisfile_mpeg_audio_lame['raw'] = array();
|
708 |
+
$thisfile_mpeg_audio_lame_raw = &$thisfile_mpeg_audio_lame['raw'];
|
709 |
+
|
710 |
+
// byte $9B VBR Quality
|
711 |
+
// This field is there to indicate a quality level, although the scale was not precised in the original Xing specifications.
|
712 |
+
// Actually overwrites original Xing bytes
|
713 |
+
unset($thisfile_mpeg_audio['VBR_scale']);
|
714 |
+
$thisfile_mpeg_audio_lame['vbr_quality'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0x9B, 1));
|
715 |
+
|
716 |
+
// bytes $9C-$A4 Encoder short VersionString
|
717 |
+
$thisfile_mpeg_audio_lame['short_version'] = substr($headerstring, $LAMEtagOffsetContant + 0x9C, 9);
|
718 |
+
|
719 |
+
// byte $A5 Info Tag revision + VBR method
|
720 |
+
$LAMEtagRevisionVBRmethod = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA5, 1));
|
721 |
+
|
722 |
+
$thisfile_mpeg_audio_lame['tag_revision'] = ($LAMEtagRevisionVBRmethod & 0xF0) >> 4;
|
723 |
+
$thisfile_mpeg_audio_lame_raw['vbr_method'] = $LAMEtagRevisionVBRmethod & 0x0F;
|
724 |
+
$thisfile_mpeg_audio_lame['vbr_method'] = self::LAMEvbrMethodLookup($thisfile_mpeg_audio_lame_raw['vbr_method']);
|
725 |
+
$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'
|
726 |
+
|
727 |
+
// byte $A6 Lowpass filter value
|
728 |
+
$thisfile_mpeg_audio_lame['lowpass_frequency'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA6, 1)) * 100;
|
729 |
+
|
730 |
+
// bytes $A7-$AE Replay Gain
|
731 |
+
// http://privatewww.essex.ac.uk/~djmrob/replaygain/rg_data_format.html
|
732 |
+
// bytes $A7-$AA : 32 bit floating point "Peak signal amplitude"
|
733 |
+
if ($thisfile_mpeg_audio_lame['short_version'] >= 'LAME3.94b') {
|
734 |
+
// LAME 3.94a16 and later - 9.23 fixed point
|
735 |
+
// ie 0x0059E2EE / (2^23) = 5890798 / 8388608 = 0.7022378444671630859375
|
736 |
+
$thisfile_mpeg_audio_lame_RGAD['peak_amplitude'] = (float) ((getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA7, 4))) / 8388608);
|
737 |
+
} else {
|
738 |
+
// LAME 3.94a15 and earlier - 32-bit floating point
|
739 |
+
// Actually 3.94a16 will fall in here too and be WRONG, but is hard to detect 3.94a16 vs 3.94a15
|
740 |
+
$thisfile_mpeg_audio_lame_RGAD['peak_amplitude'] = getid3_lib::LittleEndian2Float(substr($headerstring, $LAMEtagOffsetContant + 0xA7, 4));
|
741 |
+
}
|
742 |
+
if ($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'] == 0) {
|
743 |
+
unset($thisfile_mpeg_audio_lame_RGAD['peak_amplitude']);
|
744 |
+
} else {
|
745 |
+
$thisfile_mpeg_audio_lame_RGAD['peak_db'] = getid3_lib::RGADamplitude2dB($thisfile_mpeg_audio_lame_RGAD['peak_amplitude']);
|
746 |
+
}
|
747 |
+
|
748 |
+
$thisfile_mpeg_audio_lame_raw['RGAD_track'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAB, 2));
|
749 |
+
$thisfile_mpeg_audio_lame_raw['RGAD_album'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAD, 2));
|
750 |
+
|
751 |
+
|
752 |
+
if ($thisfile_mpeg_audio_lame_raw['RGAD_track'] != 0) {
|
753 |
+
|
754 |
+
$thisfile_mpeg_audio_lame_RGAD_track['raw']['name'] = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0xE000) >> 13;
|
755 |
+
$thisfile_mpeg_audio_lame_RGAD_track['raw']['originator'] = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x1C00) >> 10;
|
756 |
+
$thisfile_mpeg_audio_lame_RGAD_track['raw']['sign_bit'] = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x0200) >> 9;
|
757 |
+
$thisfile_mpeg_audio_lame_RGAD_track['raw']['gain_adjust'] = $thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x01FF;
|
758 |
+
$thisfile_mpeg_audio_lame_RGAD_track['name'] = getid3_lib::RGADnameLookup($thisfile_mpeg_audio_lame_RGAD_track['raw']['name']);
|
759 |
+
$thisfile_mpeg_audio_lame_RGAD_track['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_mpeg_audio_lame_RGAD_track['raw']['originator']);
|
760 |
+
$thisfile_mpeg_audio_lame_RGAD_track['gain_db'] = getid3_lib::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_track['raw']['gain_adjust'], $thisfile_mpeg_audio_lame_RGAD_track['raw']['sign_bit']);
|
761 |
+
|
762 |
+
if (!empty($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'])) {
|
763 |
+
$info['replay_gain']['track']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude'];
|
764 |
+
}
|
765 |
+
$info['replay_gain']['track']['originator'] = $thisfile_mpeg_audio_lame_RGAD_track['originator'];
|
766 |
+
$info['replay_gain']['track']['adjustment'] = $thisfile_mpeg_audio_lame_RGAD_track['gain_db'];
|
767 |
+
} else {
|
768 |
+
unset($thisfile_mpeg_audio_lame_RGAD['track']);
|
769 |
+
}
|
770 |
+
if ($thisfile_mpeg_audio_lame_raw['RGAD_album'] != 0) {
|
771 |
+
|
772 |
+
$thisfile_mpeg_audio_lame_RGAD_album['raw']['name'] = ($thisfile_mpeg_audio_lame_raw['RGAD_album'] & 0xE000) >> 13;
|
773 |
+
$thisfile_mpeg_audio_lame_RGAD_album['raw']['originator'] = ($thisfile_mpeg_audio_lame_raw['RGAD_album'] & 0x1C00) >> 10;
|
774 |
+
$thisfile_mpeg_audio_lame_RGAD_album['raw']['sign_bit'] = ($thisfile_mpeg_audio_lame_raw['RGAD_album'] & 0x0200) >> 9;
|
775 |
+
$thisfile_mpeg_audio_lame_RGAD_album['raw']['gain_adjust'] = $thisfile_mpeg_audio_lame_raw['RGAD_album'] & 0x01FF;
|
776 |
+
$thisfile_mpeg_audio_lame_RGAD_album['name'] = getid3_lib::RGADnameLookup($thisfile_mpeg_audio_lame_RGAD_album['raw']['name']);
|
777 |
+
$thisfile_mpeg_audio_lame_RGAD_album['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_mpeg_audio_lame_RGAD_album['raw']['originator']);
|
778 |
+
$thisfile_mpeg_audio_lame_RGAD_album['gain_db'] = getid3_lib::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_album['raw']['gain_adjust'], $thisfile_mpeg_audio_lame_RGAD_album['raw']['sign_bit']);
|
779 |
+
|
780 |
+
if (!empty($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'])) {
|
781 |
+
$info['replay_gain']['album']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude'];
|
782 |
+
}
|
783 |
+
$info['replay_gain']['album']['originator'] = $thisfile_mpeg_audio_lame_RGAD_album['originator'];
|
784 |
+
$info['replay_gain']['album']['adjustment'] = $thisfile_mpeg_audio_lame_RGAD_album['gain_db'];
|
785 |
+
} else {
|
786 |
+
unset($thisfile_mpeg_audio_lame_RGAD['album']);
|
787 |
+
}
|
788 |
+
if (empty($thisfile_mpeg_audio_lame_RGAD)) {
|
789 |
+
unset($thisfile_mpeg_audio_lame['RGAD']);
|
790 |
+
}
|
791 |
+
|
792 |
+
|
793 |
+
// byte $AF Encoding flags + ATH Type
|
794 |
+
$EncodingFlagsATHtype = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAF, 1));
|
795 |
+
$thisfile_mpeg_audio_lame['encoding_flags']['nspsytune'] = (bool) ($EncodingFlagsATHtype & 0x10);
|
796 |
+
$thisfile_mpeg_audio_lame['encoding_flags']['nssafejoint'] = (bool) ($EncodingFlagsATHtype & 0x20);
|
797 |
+
$thisfile_mpeg_audio_lame['encoding_flags']['nogap_next'] = (bool) ($EncodingFlagsATHtype & 0x40);
|
798 |
+
$thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev'] = (bool) ($EncodingFlagsATHtype & 0x80);
|
799 |
+
$thisfile_mpeg_audio_lame['ath_type'] = $EncodingFlagsATHtype & 0x0F;
|
800 |
+
|
801 |
+
// byte $B0 if ABR {specified bitrate} else {minimal bitrate}
|
802 |
+
$thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB0, 1));
|
803 |
+
if ($thisfile_mpeg_audio_lame_raw['vbr_method'] == 2) { // Average BitRate (ABR)
|
804 |
+
$thisfile_mpeg_audio_lame['bitrate_abr'] = $thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate'];
|
805 |
+
} elseif ($thisfile_mpeg_audio_lame_raw['vbr_method'] == 1) { // Constant BitRate (CBR)
|
806 |
+
// ignore
|
807 |
+
} elseif ($thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate'] > 0) { // Variable BitRate (VBR) - minimum bitrate
|
808 |
+
$thisfile_mpeg_audio_lame['bitrate_min'] = $thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate'];
|
809 |
+
}
|
810 |
+
|
811 |
+
// bytes $B1-$B3 Encoder delays
|
812 |
+
$EncoderDelays = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB1, 3));
|
813 |
+
$thisfile_mpeg_audio_lame['encoder_delay'] = ($EncoderDelays & 0xFFF000) >> 12;
|
814 |
+
$thisfile_mpeg_audio_lame['end_padding'] = $EncoderDelays & 0x000FFF;
|
815 |
+
|
816 |
+
// byte $B4 Misc
|
817 |
+
$MiscByte = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB4, 1));
|
818 |
+
$thisfile_mpeg_audio_lame_raw['noise_shaping'] = ($MiscByte & 0x03);
|
819 |
+
$thisfile_mpeg_audio_lame_raw['stereo_mode'] = ($MiscByte & 0x1C) >> 2;
|
820 |
+
$thisfile_mpeg_audio_lame_raw['not_optimal_quality'] = ($MiscByte & 0x20) >> 5;
|
821 |
+
$thisfile_mpeg_audio_lame_raw['source_sample_freq'] = ($MiscByte & 0xC0) >> 6;
|
822 |
+
$thisfile_mpeg_audio_lame['noise_shaping'] = $thisfile_mpeg_audio_lame_raw['noise_shaping'];
|
823 |
+
$thisfile_mpeg_audio_lame['stereo_mode'] = self::LAMEmiscStereoModeLookup($thisfile_mpeg_audio_lame_raw['stereo_mode']);
|
824 |
+
$thisfile_mpeg_audio_lame['not_optimal_quality'] = (bool) $thisfile_mpeg_audio_lame_raw['not_optimal_quality'];
|
825 |
+
$thisfile_mpeg_audio_lame['source_sample_freq'] = self::LAMEmiscSourceSampleFrequencyLookup($thisfile_mpeg_audio_lame_raw['source_sample_freq']);
|
826 |
+
|
827 |
+
// byte $B5 MP3 Gain
|
828 |
+
$thisfile_mpeg_audio_lame_raw['mp3_gain'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB5, 1), false, true);
|
829 |
+
$thisfile_mpeg_audio_lame['mp3_gain_db'] = (getid3_lib::RGADamplitude2dB(2) / 4) * $thisfile_mpeg_audio_lame_raw['mp3_gain'];
|
830 |
+
$thisfile_mpeg_audio_lame['mp3_gain_factor'] = pow(2, ($thisfile_mpeg_audio_lame['mp3_gain_db'] / 6));
|
831 |
+
|
832 |
+
// bytes $B6-$B7 Preset and surround info
|
833 |
+
$PresetSurroundBytes = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB6, 2));
|
834 |
+
// Reserved = ($PresetSurroundBytes & 0xC000);
|
835 |
+
$thisfile_mpeg_audio_lame_raw['surround_info'] = ($PresetSurroundBytes & 0x3800);
|
836 |
+
$thisfile_mpeg_audio_lame['surround_info'] = self::LAMEsurroundInfoLookup($thisfile_mpeg_audio_lame_raw['surround_info']);
|
837 |
+
$thisfile_mpeg_audio_lame['preset_used_id'] = ($PresetSurroundBytes & 0x07FF);
|
838 |
+
$thisfile_mpeg_audio_lame['preset_used'] = self::LAMEpresetUsedLookup($thisfile_mpeg_audio_lame);
|
839 |
+
if (!empty($thisfile_mpeg_audio_lame['preset_used_id']) && empty($thisfile_mpeg_audio_lame['preset_used'])) {
|
840 |
+
$info['warning'][] = 'Unknown LAME preset used ('.$thisfile_mpeg_audio_lame['preset_used_id'].') - please report to info@getid3.org';
|
841 |
+
}
|
842 |
+
if (($thisfile_mpeg_audio_lame['short_version'] == 'LAME3.90.') && !empty($thisfile_mpeg_audio_lame['preset_used_id'])) {
|
843 |
+
// this may change if 3.90.4 ever comes out
|
844 |
+
$thisfile_mpeg_audio_lame['short_version'] = 'LAME3.90.3';
|
845 |
+
}
|
846 |
+
|
847 |
+
// bytes $B8-$BB MusicLength
|
848 |
+
$thisfile_mpeg_audio_lame['audio_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB8, 4));
|
849 |
+
$ExpectedNumberOfAudioBytes = (($thisfile_mpeg_audio_lame['audio_bytes'] > 0) ? $thisfile_mpeg_audio_lame['audio_bytes'] : $thisfile_mpeg_audio['VBR_bytes']);
|
850 |
+
|
851 |
+
// bytes $BC-$BD MusicCRC
|
852 |
+
$thisfile_mpeg_audio_lame['music_crc'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xBC, 2));
|
853 |
+
|
854 |
+
// bytes $BE-$BF CRC-16 of Info Tag
|
855 |
+
$thisfile_mpeg_audio_lame['lame_tag_crc'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xBE, 2));
|
856 |
+
|
857 |
+
|
858 |
+
// LAME CBR
|
859 |
+
if ($thisfile_mpeg_audio_lame_raw['vbr_method'] == 1) {
|
860 |
+
|
861 |
+
$thisfile_mpeg_audio['bitrate_mode'] = 'cbr';
|
862 |
+
$thisfile_mpeg_audio['bitrate'] = self::ClosestStandardMP3Bitrate($thisfile_mpeg_audio['bitrate']);
|
863 |
+
$info['audio']['bitrate'] = $thisfile_mpeg_audio['bitrate'];
|
864 |
+
//if (empty($thisfile_mpeg_audio['bitrate']) || (!empty($thisfile_mpeg_audio_lame['bitrate_min']) && ($thisfile_mpeg_audio_lame['bitrate_min'] != 255))) {
|
865 |
+
// $thisfile_mpeg_audio['bitrate'] = $thisfile_mpeg_audio_lame['bitrate_min'];
|
866 |
+
//}
|
867 |
+
|
868 |
+
}
|
869 |
+
|
870 |
+
}
|
871 |
+
}
|
872 |
+
|
873 |
+
} else {
|
874 |
+
|
875 |
+
// not Fraunhofer or Xing VBR methods, most likely CBR (but could be VBR with no header)
|
876 |
+
$thisfile_mpeg_audio['bitrate_mode'] = 'cbr';
|
877 |
+
if ($recursivesearch) {
|
878 |
+
$thisfile_mpeg_audio['bitrate_mode'] = 'vbr';
|
879 |
+
if ($this->RecursiveFrameScanning($offset, $nextframetestoffset, true)) {
|
880 |
+
$recursivesearch = false;
|
881 |
+
$thisfile_mpeg_audio['bitrate_mode'] = 'cbr';
|
882 |
+
}
|
883 |
+
if ($thisfile_mpeg_audio['bitrate_mode'] == 'vbr') {
|
884 |
+
$info['warning'][] = 'VBR file with no VBR header. Bitrate values calculated from actual frame bitrates.';
|
885 |
+
}
|
886 |
+
}
|
887 |
+
|
888 |
+
}
|
889 |
+
|
890 |
+
}
|
891 |
+
|
892 |
+
if (($ExpectedNumberOfAudioBytes > 0) && ($ExpectedNumberOfAudioBytes != ($info['avdataend'] - $info['avdataoffset']))) {
|
893 |
+
if ($ExpectedNumberOfAudioBytes > ($info['avdataend'] - $info['avdataoffset'])) {
|
894 |
+
if ($this->isDependencyFor('matroska') || $this->isDependencyFor('riff')) {
|
895 |
+
// ignore, audio data is broken into chunks so will always be data "missing"
|
896 |
+
}
|
897 |
+
elseif (($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])) == 1) {
|
898 |
+
$this->warning('Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)');
|
899 |
+
}
|
900 |
+
else {
|
901 |
+
$this->warning('Probable truncated file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, only found '.($info['avdataend'] - $info['avdataoffset']).' (short by '.($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])).' bytes)');
|
902 |
+
}
|
903 |
+
} else {
|
904 |
+
if ((($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes) == 1) {
|
905 |
+
// $prenullbytefileoffset = $this->ftell();
|
906 |
+
// $this->fseek($info['avdataend']);
|
907 |
+
// $PossibleNullByte = $this->fread(1);
|
908 |
+
// $this->fseek($prenullbytefileoffset);
|
909 |
+
// if ($PossibleNullByte === "\x00") {
|
910 |
+
$info['avdataend']--;
|
911 |
+
// $info['warning'][] = 'Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored';
|
912 |
+
// } else {
|
913 |
+
// $info['warning'][] = 'Too much data in file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, found '.($info['avdataend'] - $info['avdataoffset']).' ('.(($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes).' bytes too many)';
|
914 |
+
// }
|
915 |
+
} else {
|
916 |
+
$info['warning'][] = 'Too much data in file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, found '.($info['avdataend'] - $info['avdataoffset']).' ('.(($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes).' bytes too many)';
|
917 |
+
}
|
918 |
+
}
|
919 |
+
}
|
920 |
+
|
921 |
+
if (($thisfile_mpeg_audio['bitrate'] == 'free') && empty($info['audio']['bitrate'])) {
|
922 |
+
if (($offset == $info['avdataoffset']) && empty($thisfile_mpeg_audio['VBR_frames'])) {
|
923 |
+
$framebytelength = $this->FreeFormatFrameLength($offset, true);
|
924 |
+
if ($framebytelength > 0) {
|
925 |
+
$thisfile_mpeg_audio['framelength'] = $framebytelength;
|
926 |
+
if ($thisfile_mpeg_audio['layer'] == '1') {
|
927 |
+
// BitRate = (((FrameLengthInBytes / 4) - Padding) * SampleRate) / 12
|
928 |
+
$info['audio']['bitrate'] = ((($framebytelength / 4) - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 12;
|
929 |
+
} else {
|
930 |
+
// Bitrate = ((FrameLengthInBytes - Padding) * SampleRate) / 144
|
931 |
+
$info['audio']['bitrate'] = (($framebytelength - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 144;
|
932 |
+
}
|
933 |
+
} else {
|
934 |
+
$info['error'][] = 'Error calculating frame length of free-format MP3 without Xing/LAME header';
|
935 |
+
}
|
936 |
+
}
|
937 |
+
}
|
938 |
+
|
939 |
+
if (isset($thisfile_mpeg_audio['VBR_frames']) ? $thisfile_mpeg_audio['VBR_frames'] : '') {
|
940 |
+
switch ($thisfile_mpeg_audio['bitrate_mode']) {
|
941 |
+
case 'vbr':
|
942 |
+
case 'abr':
|
943 |
+
$bytes_per_frame = 1152;
|
944 |
+
if (($thisfile_mpeg_audio['version'] == '1') && ($thisfile_mpeg_audio['layer'] == 1)) {
|
945 |
+
$bytes_per_frame = 384;
|
946 |
+
} elseif ((($thisfile_mpeg_audio['version'] == '2') || ($thisfile_mpeg_audio['version'] == '2.5')) && ($thisfile_mpeg_audio['layer'] == 3)) {
|
947 |
+
$bytes_per_frame = 576;
|
948 |
+
}
|
949 |
+
$thisfile_mpeg_audio['VBR_bitrate'] = (isset($thisfile_mpeg_audio['VBR_bytes']) ? (($thisfile_mpeg_audio['VBR_bytes'] / $thisfile_mpeg_audio['VBR_frames']) * 8) * ($info['audio']['sample_rate'] / $bytes_per_frame) : 0);
|
950 |
+
if ($thisfile_mpeg_audio['VBR_bitrate'] > 0) {
|
951 |
+
$info['audio']['bitrate'] = $thisfile_mpeg_audio['VBR_bitrate'];
|
952 |
+
$thisfile_mpeg_audio['bitrate'] = $thisfile_mpeg_audio['VBR_bitrate']; // to avoid confusion
|
953 |
+
}
|
954 |
+
break;
|
955 |
+
}
|
956 |
+
}
|
957 |
+
|
958 |
+
// End variable-bitrate headers
|
959 |
+
////////////////////////////////////////////////////////////////////////////////////
|
960 |
+
|
961 |
+
if ($recursivesearch) {
|
962 |
+
|
963 |
+
if (!$this->RecursiveFrameScanning($offset, $nextframetestoffset, $ScanAsCBR)) {
|
964 |
+
return false;
|
965 |
+
}
|
966 |
+
|
967 |
+
}
|
968 |
+
|
969 |
+
|
970 |
+
//if (false) {
|
971 |
+
// // experimental side info parsing section - not returning anything useful yet
|
972 |
+
//
|
973 |
+
// $SideInfoBitstream = getid3_lib::BigEndian2Bin($SideInfoData);
|
974 |
+
// $SideInfoOffset = 0;
|
975 |
+
//
|
976 |
+
// if ($thisfile_mpeg_audio['version'] == '1') {
|
977 |
+
// if ($thisfile_mpeg_audio['channelmode'] == 'mono') {
|
978 |
+
// // MPEG-1 (mono)
|
979 |
+
// $thisfile_mpeg_audio['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 9);
|
980 |
+
// $SideInfoOffset += 9;
|
981 |
+
// $SideInfoOffset += 5;
|
982 |
+
// } else {
|
983 |
+
// // MPEG-1 (stereo, joint-stereo, dual-channel)
|
984 |
+
// $thisfile_mpeg_audio['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 9);
|
985 |
+
// $SideInfoOffset += 9;
|
986 |
+
// $SideInfoOffset += 3;
|
987 |
+
// }
|
988 |
+
// } else { // 2 or 2.5
|
989 |
+
// if ($thisfile_mpeg_audio['channelmode'] == 'mono') {
|
990 |
+
// // MPEG-2, MPEG-2.5 (mono)
|
991 |
+
// $thisfile_mpeg_audio['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 8);
|
992 |
+
// $SideInfoOffset += 8;
|
993 |
+
// $SideInfoOffset += 1;
|
994 |
+
// } else {
|
995 |
+
// // MPEG-2, MPEG-2.5 (stereo, joint-stereo, dual-channel)
|
996 |
+
// $thisfile_mpeg_audio['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 8);
|
997 |
+
// $SideInfoOffset += 8;
|
998 |
+
// $SideInfoOffset += 2;
|
999 |
+
// }
|
1000 |
+
// }
|
1001 |
+
//
|
1002 |
+
// if ($thisfile_mpeg_audio['version'] == '1') {
|
1003 |
+
// for ($channel = 0; $channel < $info['audio']['channels']; $channel++) {
|
1004 |
+
// for ($scfsi_band = 0; $scfsi_band < 4; $scfsi_band++) {
|
1005 |
+
// $thisfile_mpeg_audio['scfsi'][$channel][$scfsi_band] = substr($SideInfoBitstream, $SideInfoOffset, 1);
|
1006 |
+
// $SideInfoOffset += 2;
|
1007 |
+
// }
|
1008 |
+
// }
|
1009 |
+
// }
|
1010 |
+
// for ($granule = 0; $granule < (($thisfile_mpeg_audio['version'] == '1') ? 2 : 1); $granule++) {
|
1011 |
+
// for ($channel = 0; $channel < $info['audio']['channels']; $channel++) {
|
1012 |
+
// $thisfile_mpeg_audio['part2_3_length'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 12);
|
1013 |
+
// $SideInfoOffset += 12;
|
1014 |
+
// $thisfile_mpeg_audio['big_values'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 9);
|
1015 |
+
// $SideInfoOffset += 9;
|
1016 |
+
// $thisfile_mpeg_audio['global_gain'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 8);
|
1017 |
+
// $SideInfoOffset += 8;
|
1018 |
+
// if ($thisfile_mpeg_audio['version'] == '1') {
|
1019 |
+
// $thisfile_mpeg_audio['scalefac_compress'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 4);
|
1020 |
+
// $SideInfoOffset += 4;
|
1021 |
+
// } else {
|
1022 |
+
// $thisfile_mpeg_audio['scalefac_compress'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 9);
|
1023 |
+
// $SideInfoOffset += 9;
|
1024 |
+
// }
|
1025 |
+
// $thisfile_mpeg_audio['window_switching_flag'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1);
|
1026 |
+
// $SideInfoOffset += 1;
|
1027 |
+
//
|
1028 |
+
// if ($thisfile_mpeg_audio['window_switching_flag'][$granule][$channel] == '1') {
|
1029 |
+
//
|
1030 |
+
// $thisfile_mpeg_audio['block_type'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 2);
|
1031 |
+
// $SideInfoOffset += 2;
|
1032 |
+
// $thisfile_mpeg_audio['mixed_block_flag'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1);
|
1033 |
+
// $SideInfoOffset += 1;
|
1034 |
+
//
|
1035 |
+
// for ($region = 0; $region < 2; $region++) {
|
1036 |
+
// $thisfile_mpeg_audio['table_select'][$granule][$channel][$region] = substr($SideInfoBitstream, $SideInfoOffset, 5);
|
1037 |
+
// $SideInfoOffset += 5;
|
1038 |
+
// }
|
1039 |
+
// $thisfile_mpeg_audio['table_select'][$granule][$channel][2] = 0;
|
1040 |
+
//
|
1041 |
+
// for ($window = 0; $window < 3; $window++) {
|
1042 |
+
// $thisfile_mpeg_audio['subblock_gain'][$granule][$channel][$window] = substr($SideInfoBitstream, $SideInfoOffset, 3);
|
1043 |
+
// $SideInfoOffset += 3;
|
1044 |
+
// }
|
1045 |
+
//
|
1046 |
+
// } else {
|
1047 |
+
//
|
1048 |
+
// for ($region = 0; $region < 3; $region++) {
|
1049 |
+
// $thisfile_mpeg_audio['table_select'][$granule][$channel][$region] = substr($SideInfoBitstream, $SideInfoOffset, 5);
|
1050 |
+
// $SideInfoOffset += 5;
|
1051 |
+
// }
|
1052 |
+
//
|
1053 |
+
// $thisfile_mpeg_audio['region0_count'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 4);
|
1054 |
+
// $SideInfoOffset += 4;
|
1055 |
+
// $thisfile_mpeg_audio['region1_count'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 3);
|
1056 |
+
// $SideInfoOffset += 3;
|
1057 |
+
// $thisfile_mpeg_audio['block_type'][$granule][$channel] = 0;
|
1058 |
+
// }
|
1059 |
+
//
|
1060 |
+
// if ($thisfile_mpeg_audio['version'] == '1') {
|
1061 |
+
// $thisfile_mpeg_audio['preflag'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1);
|
1062 |
+
// $SideInfoOffset += 1;
|
1063 |
+
// }
|
1064 |
+
// $thisfile_mpeg_audio['scalefac_scale'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1);
|
1065 |
+
// $SideInfoOffset += 1;
|
1066 |
+
// $thisfile_mpeg_audio['count1table_select'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1);
|
1067 |
+
// $SideInfoOffset += 1;
|
1068 |
+
// }
|
1069 |
+
// }
|
1070 |
+
//}
|
1071 |
+
|
1072 |
+
return true;
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
public function RecursiveFrameScanning(&$offset, &$nextframetestoffset, $ScanAsCBR) {
|
1076 |
+
$info = &$this->getid3->info;
|
1077 |
+
$firstframetestarray = array('error'=>'', 'warning'=>'', 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']);
|
1078 |
+
$this->decodeMPEGaudioHeader($offset, $firstframetestarray, false);
|
1079 |
+
|
1080 |
+
for ($i = 0; $i < GETID3_MP3_VALID_CHECK_FRAMES; $i++) {
|
1081 |
+
// check next GETID3_MP3_VALID_CHECK_FRAMES frames for validity, to make sure we haven't run across a false synch
|
1082 |
+
if (($nextframetestoffset + 4) >= $info['avdataend']) {
|
1083 |
+
// end of file
|
1084 |
+
return true;
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
$nextframetestarray = array('error'=>'', 'warning'=>'', 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']);
|
1088 |
+
if ($this->decodeMPEGaudioHeader($nextframetestoffset, $nextframetestarray, false)) {
|
1089 |
+
if ($ScanAsCBR) {
|
1090 |
+
// force CBR mode, used for trying to pick out invalid audio streams with valid(?) VBR headers, or VBR streams with no VBR header
|
1091 |
+
if (!isset($nextframetestarray['mpeg']['audio']['bitrate']) || !isset($firstframetestarray['mpeg']['audio']['bitrate']) || ($nextframetestarray['mpeg']['audio']['bitrate'] != $firstframetestarray['mpeg']['audio']['bitrate'])) {
|
1092 |
+
return false;
|
1093 |
+
}
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
|
1097 |
+
// next frame is OK, get ready to check the one after that
|
1098 |
+
if (isset($nextframetestarray['mpeg']['audio']['framelength']) && ($nextframetestarray['mpeg']['audio']['framelength'] > 0)) {
|
1099 |
+
$nextframetestoffset += $nextframetestarray['mpeg']['audio']['framelength'];
|
1100 |
+
} else {
|
1101 |
+
$info['error'][] = 'Frame at offset ('.$offset.') is has an invalid frame length.';
|
1102 |
+
return false;
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
} elseif (!empty($firstframetestarray['mpeg']['audio']['framelength']) && (($nextframetestoffset + $firstframetestarray['mpeg']['audio']['framelength']) > $info['avdataend'])) {
|
1106 |
+
|
1107 |
+
// it's not the end of the file, but there's not enough data left for another frame, so assume it's garbage/padding and return OK
|
1108 |
+
return true;
|
1109 |
+
|
1110 |
+
} else {
|
1111 |
+
|
1112 |
+
// next frame is not valid, note the error and fail, so scanning can contiue for a valid frame sequence
|
1113 |
+
$info['warning'][] = 'Frame at offset ('.$offset.') is valid, but the next one at ('.$nextframetestoffset.') is not.';
|
1114 |
+
|
1115 |
+
return false;
|
1116 |
+
}
|
1117 |
+
}
|
1118 |
+
return true;
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
public function FreeFormatFrameLength($offset, $deepscan=false) {
|
1122 |
+
$info = &$this->getid3->info;
|
1123 |
+
|
1124 |
+
$this->fseek($offset);
|
1125 |
+
$MPEGaudioData = $this->fread(32768);
|
1126 |
+
|
1127 |
+
$SyncPattern1 = substr($MPEGaudioData, 0, 4);
|
1128 |
+
// may be different pattern due to padding
|
1129 |
+
$SyncPattern2 = $SyncPattern1{0}.$SyncPattern1{1}.chr(ord($SyncPattern1{2}) | 0x02).$SyncPattern1{3};
|
1130 |
+
if ($SyncPattern2 === $SyncPattern1) {
|
1131 |
+
$SyncPattern2 = $SyncPattern1{0}.$SyncPattern1{1}.chr(ord($SyncPattern1{2}) & 0xFD).$SyncPattern1{3};
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
$framelength = false;
|
1135 |
+
$framelength1 = strpos($MPEGaudioData, $SyncPattern1, 4);
|
1136 |
+
$framelength2 = strpos($MPEGaudioData, $SyncPattern2, 4);
|
1137 |
+
if ($framelength1 > 4) {
|
1138 |
+
$framelength = $framelength1;
|
1139 |
+
}
|
1140 |
+
if (($framelength2 > 4) && ($framelength2 < $framelength1)) {
|
1141 |
+
$framelength = $framelength2;
|
1142 |
+
}
|
1143 |
+
if (!$framelength) {
|
1144 |
+
|
1145 |
+
// LAME 3.88 has a different value for modeextension on the first frame vs the rest
|
1146 |
+
$framelength1 = strpos($MPEGaudioData, substr($SyncPattern1, 0, 3), 4);
|
1147 |
+
$framelength2 = strpos($MPEGaudioData, substr($SyncPattern2, 0, 3), 4);
|
1148 |
+
|
1149 |
+
if ($framelength1 > 4) {
|
1150 |
+
$framelength = $framelength1;
|
1151 |
+
}
|
1152 |
+
if (($framelength2 > 4) && ($framelength2 < $framelength1)) {
|
1153 |
+
$framelength = $framelength2;
|
1154 |
+
}
|
1155 |
+
if (!$framelength) {
|
1156 |
+
$info['error'][] = 'Cannot find next free-format synch pattern ('.getid3_lib::PrintHexBytes($SyncPattern1).' or '.getid3_lib::PrintHexBytes($SyncPattern2).') after offset '.$offset;
|
1157 |
+
return false;
|
1158 |
+
} else {
|
1159 |
+
$info['warning'][] = 'ModeExtension varies between first frame and other frames (known free-format issue in LAME 3.88)';
|
1160 |
+
$info['audio']['codec'] = 'LAME';
|
1161 |
+
$info['audio']['encoder'] = 'LAME3.88';
|
1162 |
+
$SyncPattern1 = substr($SyncPattern1, 0, 3);
|
1163 |
+
$SyncPattern2 = substr($SyncPattern2, 0, 3);
|
1164 |
+
}
|
1165 |
+
}
|
1166 |
+
|
1167 |
+
if ($deepscan) {
|
1168 |
+
|
1169 |
+
$ActualFrameLengthValues = array();
|
1170 |
+
$nextoffset = $offset + $framelength;
|
1171 |
+
while ($nextoffset < ($info['avdataend'] - 6)) {
|
1172 |
+
$this->fseek($nextoffset - 1);
|
1173 |
+
$NextSyncPattern = $this->fread(6);
|
1174 |
+
if ((substr($NextSyncPattern, 1, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 1, strlen($SyncPattern2)) == $SyncPattern2)) {
|
1175 |
+
// good - found where expected
|
1176 |
+
$ActualFrameLengthValues[] = $framelength;
|
1177 |
+
} elseif ((substr($NextSyncPattern, 0, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 0, strlen($SyncPattern2)) == $SyncPattern2)) {
|
1178 |
+
// ok - found one byte earlier than expected (last frame wasn't padded, first frame was)
|
1179 |
+
$ActualFrameLengthValues[] = ($framelength - 1);
|
1180 |
+
$nextoffset--;
|
1181 |
+
} elseif ((substr($NextSyncPattern, 2, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 2, strlen($SyncPattern2)) == $SyncPattern2)) {
|
1182 |
+
// ok - found one byte later than expected (last frame was padded, first frame wasn't)
|
1183 |
+
$ActualFrameLengthValues[] = ($framelength + 1);
|
1184 |
+
$nextoffset++;
|
1185 |
+
} else {
|
1186 |
+
$info['error'][] = 'Did not find expected free-format sync pattern at offset '.$nextoffset;
|
1187 |
+
return false;
|
1188 |
+
}
|
1189 |
+
$nextoffset += $framelength;
|
1190 |
+
}
|
1191 |
+
if (count($ActualFrameLengthValues) > 0) {
|
1192 |
+
$framelength = intval(round(array_sum($ActualFrameLengthValues) / count($ActualFrameLengthValues)));
|
1193 |
+
}
|
1194 |
+
}
|
1195 |
+
return $framelength;
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
public function getOnlyMPEGaudioInfoBruteForce() {
|
1199 |
+
$MPEGaudioHeaderDecodeCache = array();
|
1200 |
+
$MPEGaudioHeaderValidCache = array();
|
1201 |
+
$MPEGaudioHeaderLengthCache = array();
|
1202 |
+
$MPEGaudioVersionLookup = self::MPEGaudioVersionArray();
|
1203 |
+
$MPEGaudioLayerLookup = self::MPEGaudioLayerArray();
|
1204 |
+
$MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray();
|
1205 |
+
$MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray();
|
1206 |
+
$MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray();
|
1207 |
+
$MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray();
|
1208 |
+
$MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray();
|
1209 |
+
$LongMPEGversionLookup = array();
|
1210 |
+
$LongMPEGlayerLookup = array();
|
1211 |
+
$LongMPEGbitrateLookup = array();
|
1212 |
+
$LongMPEGpaddingLookup = array();
|
1213 |
+
$LongMPEGfrequencyLookup = array();
|
1214 |
+
$Distribution['bitrate'] = array();
|
1215 |
+
$Distribution['frequency'] = array();
|
1216 |
+
$Distribution['layer'] = array();
|
1217 |
+
$Distribution['version'] = array();
|
1218 |
+
$Distribution['padding'] = array();
|
1219 |
+
|
1220 |
+
$info = &$this->getid3->info;
|
1221 |
+
$this->fseek($info['avdataoffset']);
|
1222 |
+
|
1223 |
+
$max_frames_scan = 5000;
|
1224 |
+
$frames_scanned = 0;
|
1225 |
+
|
1226 |
+
$previousvalidframe = $info['avdataoffset'];
|
1227 |
+
while ($this->ftell() < $info['avdataend']) {
|
1228 |
+
set_time_limit(30);
|
1229 |
+
$head4 = $this->fread(4);
|
1230 |
+
if (strlen($head4) < 4) {
|
1231 |
+
break;
|
1232 |
+
}
|
1233 |
+
if ($head4{0} != "\xFF") {
|
1234 |
+
for ($i = 1; $i < 4; $i++) {
|
1235 |
+
if ($head4{$i} == "\xFF") {
|
1236 |
+
$this->fseek($i - 4, SEEK_CUR);
|
1237 |
+
continue 2;
|
1238 |
+
}
|
1239 |
+
}
|
1240 |
+
continue;
|
1241 |
+
}
|
1242 |
+
if (!isset($MPEGaudioHeaderDecodeCache[$head4])) {
|
1243 |
+
$MPEGaudioHeaderDecodeCache[$head4] = self::MPEGaudioHeaderDecode($head4);
|
1244 |
+
}
|
1245 |
+
if (!isset($MPEGaudioHeaderValidCache[$head4])) {
|
1246 |
+
$MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$head4], false, false);
|
1247 |
+
}
|
1248 |
+
if ($MPEGaudioHeaderValidCache[$head4]) {
|
1249 |
+
|
1250 |
+
if (!isset($MPEGaudioHeaderLengthCache[$head4])) {
|
1251 |
+
$LongMPEGversionLookup[$head4] = $MPEGaudioVersionLookup[$MPEGaudioHeaderDecodeCache[$head4]['version']];
|
1252 |
+
$LongMPEGlayerLookup[$head4] = $MPEGaudioLayerLookup[$MPEGaudioHeaderDecodeCache[$head4]['layer']];
|
1253 |
+
$LongMPEGbitrateLookup[$head4] = $MPEGaudioBitrateLookup[$LongMPEGversionLookup[$head4]][$LongMPEGlayerLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['bitrate']];
|
1254 |
+
$LongMPEGpaddingLookup[$head4] = (bool) $MPEGaudioHeaderDecodeCache[$head4]['padding'];
|
1255 |
+
$LongMPEGfrequencyLookup[$head4] = $MPEGaudioFrequencyLookup[$LongMPEGversionLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['sample_rate']];
|
1256 |
+
$MPEGaudioHeaderLengthCache[$head4] = self::MPEGaudioFrameLength(
|
1257 |
+
$LongMPEGbitrateLookup[$head4],
|
1258 |
+
$LongMPEGversionLookup[$head4],
|
1259 |
+
$LongMPEGlayerLookup[$head4],
|
1260 |
+
$LongMPEGpaddingLookup[$head4],
|
1261 |
+
$LongMPEGfrequencyLookup[$head4]);
|
1262 |
+
}
|
1263 |
+
if ($MPEGaudioHeaderLengthCache[$head4] > 4) {
|
1264 |
+
$WhereWeWere = $this->ftell();
|
1265 |
+
$this->fseek($MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR);
|
1266 |
+
$next4 = $this->fread(4);
|
1267 |
+
if ($next4{0} == "\xFF") {
|
1268 |
+
if (!isset($MPEGaudioHeaderDecodeCache[$next4])) {
|
1269 |
+
$MPEGaudioHeaderDecodeCache[$next4] = self::MPEGaudioHeaderDecode($next4);
|
1270 |
+
}
|
1271 |
+
if (!isset($MPEGaudioHeaderValidCache[$next4])) {
|
1272 |
+
$MPEGaudioHeaderValidCache[$next4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false);
|
1273 |
+
}
|
1274 |
+
if ($MPEGaudioHeaderValidCache[$next4]) {
|
1275 |
+
$this->fseek(-4, SEEK_CUR);
|
1276 |
+
|
1277 |
+
getid3_lib::safe_inc($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]);
|
1278 |
+
getid3_lib::safe_inc($Distribution['layer'][$LongMPEGlayerLookup[$head4]]);
|
1279 |
+
getid3_lib::safe_inc($Distribution['version'][$LongMPEGversionLookup[$head4]]);
|
1280 |
+
getid3_lib::safe_inc($Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]);
|
1281 |
+
getid3_lib::safe_inc($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]);
|
1282 |
+
if ($max_frames_scan && (++$frames_scanned >= $max_frames_scan)) {
|
1283 |
+
$pct_data_scanned = ($this->ftell() - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']);
|
1284 |
+
$info['warning'][] = 'too many MPEG audio frames to scan, only scanned first '.$max_frames_scan.' frames ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.';
|
1285 |
+
foreach ($Distribution as $key1 => $value1) {
|
1286 |
+
foreach ($value1 as $key2 => $value2) {
|
1287 |
+
$Distribution[$key1][$key2] = round($value2 / $pct_data_scanned);
|
1288 |
+
}
|
1289 |
+
}
|
1290 |
+
break;
|
1291 |
+
}
|
1292 |
+
continue;
|
1293 |
+
}
|
1294 |
+
}
|
1295 |
+
unset($next4);
|
1296 |
+
$this->fseek($WhereWeWere - 3);
|
1297 |
+
}
|
1298 |
+
|
1299 |
+
}
|
1300 |
+
}
|
1301 |
+
foreach ($Distribution as $key => $value) {
|
1302 |
+
ksort($Distribution[$key], SORT_NUMERIC);
|
1303 |
+
}
|
1304 |
+
ksort($Distribution['version'], SORT_STRING);
|
1305 |
+
$info['mpeg']['audio']['bitrate_distribution'] = $Distribution['bitrate'];
|
1306 |
+
$info['mpeg']['audio']['frequency_distribution'] = $Distribution['frequency'];
|
1307 |
+
$info['mpeg']['audio']['layer_distribution'] = $Distribution['layer'];
|
1308 |
+
$info['mpeg']['audio']['version_distribution'] = $Distribution['version'];
|
1309 |
+
$info['mpeg']['audio']['padding_distribution'] = $Distribution['padding'];
|
1310 |
+
if (count($Distribution['version']) > 1) {
|
1311 |
+
$info['error'][] = 'Corrupt file - more than one MPEG version detected';
|
1312 |
+
}
|
1313 |
+
if (count($Distribution['layer']) > 1) {
|
1314 |
+
$info['error'][] = 'Corrupt file - more than one MPEG layer detected';
|
1315 |
+
}
|
1316 |
+
if (count($Distribution['frequency']) > 1) {
|
1317 |
+
$info['error'][] = 'Corrupt file - more than one MPEG sample rate detected';
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
|
1321 |
+
$bittotal = 0;
|
1322 |
+
foreach ($Distribution['bitrate'] as $bitratevalue => $bitratecount) {
|
1323 |
+
if ($bitratevalue != 'free') {
|
1324 |
+
$bittotal += ($bitratevalue * $bitratecount);
|
1325 |
+
}
|
1326 |
+
}
|
1327 |
+
$info['mpeg']['audio']['frame_count'] = array_sum($Distribution['bitrate']);
|
1328 |
+
if ($info['mpeg']['audio']['frame_count'] == 0) {
|
1329 |
+
$info['error'][] = 'no MPEG audio frames found';
|
1330 |
+
return false;
|
1331 |
+
}
|
1332 |
+
$info['mpeg']['audio']['bitrate'] = ($bittotal / $info['mpeg']['audio']['frame_count']);
|
1333 |
+
$info['mpeg']['audio']['bitrate_mode'] = ((count($Distribution['bitrate']) > 0) ? 'vbr' : 'cbr');
|
1334 |
+
$info['mpeg']['audio']['sample_rate'] = getid3_lib::array_max($Distribution['frequency'], true);
|
1335 |
+
|
1336 |
+
$info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
|
1337 |
+
$info['audio']['bitrate_mode'] = $info['mpeg']['audio']['bitrate_mode'];
|
1338 |
+
$info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
|
1339 |
+
$info['audio']['dataformat'] = 'mp'.getid3_lib::array_max($Distribution['layer'], true);
|
1340 |
+
$info['fileformat'] = $info['audio']['dataformat'];
|
1341 |
+
|
1342 |
+
return true;
|
1343 |
+
}
|
1344 |
+
|
1345 |
+
|
1346 |
+
public function getOnlyMPEGaudioInfo($avdataoffset, $BitrateHistogram=false) {
|
1347 |
+
// looks for synch, decodes MPEG audio header
|
1348 |
+
|
1349 |
+
$info = &$this->getid3->info;
|
1350 |
+
|
1351 |
+
static $MPEGaudioVersionLookup;
|
1352 |
+
static $MPEGaudioLayerLookup;
|
1353 |
+
static $MPEGaudioBitrateLookup;
|
1354 |
+
if (empty($MPEGaudioVersionLookup)) {
|
1355 |
+
$MPEGaudioVersionLookup = self::MPEGaudioVersionArray();
|
1356 |
+
$MPEGaudioLayerLookup = self::MPEGaudioLayerArray();
|
1357 |
+
$MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray();
|
1358 |
+
|
1359 |
+
}
|
1360 |
+
|
1361 |
+
$this->fseek($avdataoffset);
|
1362 |
+
$sync_seek_buffer_size = min(128 * 1024, $info['avdataend'] - $avdataoffset);
|
1363 |
+
if ($sync_seek_buffer_size <= 0) {
|
1364 |
+
$info['error'][] = 'Invalid $sync_seek_buffer_size at offset '.$avdataoffset;
|
1365 |
+
return false;
|
1366 |
+
}
|
1367 |
+
$header = $this->fread($sync_seek_buffer_size);
|
1368 |
+
$sync_seek_buffer_size = strlen($header);
|
1369 |
+
$SynchSeekOffset = 0;
|
1370 |
+
while ($SynchSeekOffset < $sync_seek_buffer_size) {
|
1371 |
+
if ((($avdataoffset + $SynchSeekOffset) < $info['avdataend']) && !feof($this->getid3->fp)) {
|
1372 |
+
|
1373 |
+
if ($SynchSeekOffset > $sync_seek_buffer_size) {
|
1374 |
+
// if a synch's not found within the first 128k bytes, then give up
|
1375 |
+
$info['error'][] = 'Could not find valid MPEG audio synch within the first '.round($sync_seek_buffer_size / 1024).'kB';
|
1376 |
+
if (isset($info['audio']['bitrate'])) {
|
1377 |
+
unset($info['audio']['bitrate']);
|
1378 |
+
}
|
1379 |
+
if (isset($info['mpeg']['audio'])) {
|
1380 |
+
unset($info['mpeg']['audio']);
|
1381 |
+
}
|
1382 |
+
if (empty($info['mpeg'])) {
|
1383 |
+
unset($info['mpeg']);
|
1384 |
+
}
|
1385 |
+
return false;
|
1386 |
+
|
1387 |
+
} elseif (feof($this->getid3->fp)) {
|
1388 |
+
|
1389 |
+
$info['error'][] = 'Could not find valid MPEG audio synch before end of file';
|
1390 |
+
if (isset($info['audio']['bitrate'])) {
|
1391 |
+
unset($info['audio']['bitrate']);
|
1392 |
+
}
|
1393 |
+
if (isset($info['mpeg']['audio'])) {
|
1394 |
+
unset($info['mpeg']['audio']);
|
1395 |
+
}
|
1396 |
+
if (isset($info['mpeg']) && (!is_array($info['mpeg']) || (count($info['mpeg']) == 0))) {
|
1397 |
+
unset($info['mpeg']);
|
1398 |
+
}
|
1399 |
+
return false;
|
1400 |
+
}
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
if (($SynchSeekOffset + 1) >= strlen($header)) {
|
1404 |
+
$info['error'][] = 'Could not find valid MPEG synch before end of file';
|
1405 |
+
return false;
|
1406 |
+
}
|
1407 |
+
|
1408 |
+
if (($header{$SynchSeekOffset} == "\xFF") && ($header{($SynchSeekOffset + 1)} > "\xE0")) { // synch detected
|
1409 |
+
if (!isset($FirstFrameThisfileInfo) && !isset($info['mpeg']['audio'])) {
|
1410 |
+
$FirstFrameThisfileInfo = $info;
|
1411 |
+
$FirstFrameAVDataOffset = $avdataoffset + $SynchSeekOffset;
|
1412 |
+
if (!$this->decodeMPEGaudioHeader($FirstFrameAVDataOffset, $FirstFrameThisfileInfo, false)) {
|
1413 |
+
// if this is the first valid MPEG-audio frame, save it in case it's a VBR header frame and there's
|
1414 |
+
// garbage between this frame and a valid sequence of MPEG-audio frames, to be restored below
|
1415 |
+
unset($FirstFrameThisfileInfo);
|
1416 |
+
}
|
1417 |
+
}
|
1418 |
+
|
1419 |
+
$dummy = $info; // only overwrite real data if valid header found
|
1420 |
+
if ($this->decodeMPEGaudioHeader($avdataoffset + $SynchSeekOffset, $dummy, true)) {
|
1421 |
+
$info = $dummy;
|
1422 |
+
$info['avdataoffset'] = $avdataoffset + $SynchSeekOffset;
|
1423 |
+
switch (isset($info['fileformat']) ? $info['fileformat'] : '') {
|
1424 |
+
case '':
|
1425 |
+
case 'id3':
|
1426 |
+
case 'ape':
|
1427 |
+
case 'mp3':
|
1428 |
+
$info['fileformat'] = 'mp3';
|
1429 |
+
$info['audio']['dataformat'] = 'mp3';
|
1430 |
+
break;
|
1431 |
+
}
|
1432 |
+
if (isset($FirstFrameThisfileInfo['mpeg']['audio']['bitrate_mode']) && ($FirstFrameThisfileInfo['mpeg']['audio']['bitrate_mode'] == 'vbr')) {
|
1433 |
+
if (!(abs($info['audio']['bitrate'] - $FirstFrameThisfileInfo['audio']['bitrate']) <= 1)) {
|
1434 |
+
// If there is garbage data between a valid VBR header frame and a sequence
|
1435 |
+
// of valid MPEG-audio frames the VBR data is no longer discarded.
|
1436 |
+
$info = $FirstFrameThisfileInfo;
|
1437 |
+
$info['avdataoffset'] = $FirstFrameAVDataOffset;
|
1438 |
+
$info['fileformat'] = 'mp3';
|
1439 |
+
$info['audio']['dataformat'] = 'mp3';
|
1440 |
+
$dummy = $info;
|
1441 |
+
unset($dummy['mpeg']['audio']);
|
1442 |
+
$GarbageOffsetStart = $FirstFrameAVDataOffset + $FirstFrameThisfileInfo['mpeg']['audio']['framelength'];
|
1443 |
+
$GarbageOffsetEnd = $avdataoffset + $SynchSeekOffset;
|
1444 |
+
if ($this->decodeMPEGaudioHeader($GarbageOffsetEnd, $dummy, true, true)) {
|
1445 |
+
$info = $dummy;
|
1446 |
+
$info['avdataoffset'] = $GarbageOffsetEnd;
|
1447 |
+
$info['warning'][] = 'apparently-valid VBR header not used because could not find '.GETID3_MP3_VALID_CHECK_FRAMES.' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).' bytes between '.$GarbageOffsetStart.' and '.$GarbageOffsetEnd.'), but did find valid CBR stream starting at '.$GarbageOffsetEnd;
|
1448 |
+
} else {
|
1449 |
+
$info['warning'][] = 'using data from VBR header even though could not find '.GETID3_MP3_VALID_CHECK_FRAMES.' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).' bytes between '.$GarbageOffsetStart.' and '.$GarbageOffsetEnd.')';
|
1450 |
+
}
|
1451 |
+
}
|
1452 |
+
}
|
1453 |
+
if (isset($info['mpeg']['audio']['bitrate_mode']) && ($info['mpeg']['audio']['bitrate_mode'] == 'vbr') && !isset($info['mpeg']['audio']['VBR_method'])) {
|
1454 |
+
// VBR file with no VBR header
|
1455 |
+
$BitrateHistogram = true;
|
1456 |
+
}
|
1457 |
+
|
1458 |
+
if ($BitrateHistogram) {
|
1459 |
+
|
1460 |
+
$info['mpeg']['audio']['stereo_distribution'] = array('stereo'=>0, 'joint stereo'=>0, 'dual channel'=>0, 'mono'=>0);
|
1461 |
+
$info['mpeg']['audio']['version_distribution'] = array('1'=>0, '2'=>0, '2.5'=>0);
|
1462 |
+
|
1463 |
+
if ($info['mpeg']['audio']['version'] == '1') {
|
1464 |
+
if ($info['mpeg']['audio']['layer'] == 3) {
|
1465 |
+
$info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 40000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 320000=>0);
|
1466 |
+
} elseif ($info['mpeg']['audio']['layer'] == 2) {
|
1467 |
+
$info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 320000=>0, 384000=>0);
|
1468 |
+
} elseif ($info['mpeg']['audio']['layer'] == 1) {
|
1469 |
+
$info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 64000=>0, 96000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 288000=>0, 320000=>0, 352000=>0, 384000=>0, 416000=>0, 448000=>0);
|
1470 |
+
}
|
1471 |
+
} elseif ($info['mpeg']['audio']['layer'] == 1) {
|
1472 |
+
$info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 144000=>0, 160000=>0, 176000=>0, 192000=>0, 224000=>0, 256000=>0);
|
1473 |
+
} else {
|
1474 |
+
$info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 8000=>0, 16000=>0, 24000=>0, 32000=>0, 40000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 144000=>0, 160000=>0);
|
1475 |
+
}
|
1476 |
+
|
1477 |
+
$dummy = array('error'=>$info['error'], 'warning'=>$info['warning'], 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']);
|
1478 |
+
$synchstartoffset = $info['avdataoffset'];
|
1479 |
+
$this->fseek($info['avdataoffset']);
|
1480 |
+
|
1481 |
+
// you can play with these numbers:
|
1482 |
+
$max_frames_scan = 50000;
|
1483 |
+
$max_scan_segments = 10;
|
1484 |
+
|
1485 |
+
// don't play with these numbers:
|
1486 |
+
$FastMode = false;
|
1487 |
+
$SynchErrorsFound = 0;
|
1488 |
+
$frames_scanned = 0;
|
1489 |
+
$this_scan_segment = 0;
|
1490 |
+
$frames_scan_per_segment = ceil($max_frames_scan / $max_scan_segments);
|
1491 |
+
$pct_data_scanned = 0;
|
1492 |
+
for ($current_segment = 0; $current_segment < $max_scan_segments; $current_segment++) {
|
1493 |
+
$frames_scanned_this_segment = 0;
|
1494 |
+
if ($this->ftell() >= $info['avdataend']) {
|
1495 |
+
break;
|
1496 |
+
}
|
1497 |
+
$scan_start_offset[$current_segment] = max($this->ftell(), $info['avdataoffset'] + round($current_segment * (($info['avdataend'] - $info['avdataoffset']) / $max_scan_segments)));
|
1498 |
+
if ($current_segment > 0) {
|
1499 |
+
$this->fseek($scan_start_offset[$current_segment]);
|
1500 |
+
$buffer_4k = $this->fread(4096);
|
1501 |
+
for ($j = 0; $j < (strlen($buffer_4k) - 4); $j++) {
|
1502 |
+
if (($buffer_4k{$j} == "\xFF") && ($buffer_4k{($j + 1)} > "\xE0")) { // synch detected
|
1503 |
+
if ($this->decodeMPEGaudioHeader($scan_start_offset[$current_segment] + $j, $dummy, false, false, $FastMode)) {
|
1504 |
+
$calculated_next_offset = $scan_start_offset[$current_segment] + $j + $dummy['mpeg']['audio']['framelength'];
|
1505 |
+
if ($this->decodeMPEGaudioHeader($calculated_next_offset, $dummy, false, false, $FastMode)) {
|
1506 |
+
$scan_start_offset[$current_segment] += $j;
|
1507 |
+
break;
|
1508 |
+
}
|
1509 |
+
}
|
1510 |
+
}
|
1511 |
+
}
|
1512 |
+
}
|
1513 |
+
$synchstartoffset = $scan_start_offset[$current_segment];
|
1514 |
+
while ($this->decodeMPEGaudioHeader($synchstartoffset, $dummy, false, false, $FastMode)) {
|
1515 |
+
$FastMode = true;
|
1516 |
+
$thisframebitrate = $MPEGaudioBitrateLookup[$MPEGaudioVersionLookup[$dummy['mpeg']['audio']['raw']['version']]][$MPEGaudioLayerLookup[$dummy['mpeg']['audio']['raw']['layer']]][$dummy['mpeg']['audio']['raw']['bitrate']];
|
1517 |
+
|
1518 |
+
if (empty($dummy['mpeg']['audio']['framelength'])) {
|
1519 |
+
$SynchErrorsFound++;
|
1520 |
+
$synchstartoffset++;
|
1521 |
+
} else {
|
1522 |
+
getid3_lib::safe_inc($info['mpeg']['audio']['bitrate_distribution'][$thisframebitrate]);
|
1523 |
+
getid3_lib::safe_inc($info['mpeg']['audio']['stereo_distribution'][$dummy['mpeg']['audio']['channelmode']]);
|
1524 |
+
getid3_lib::safe_inc($info['mpeg']['audio']['version_distribution'][$dummy['mpeg']['audio']['version']]);
|
1525 |
+
$synchstartoffset += $dummy['mpeg']['audio']['framelength'];
|
1526 |
+
}
|
1527 |
+
$frames_scanned++;
|
1528 |
+
if ($frames_scan_per_segment && (++$frames_scanned_this_segment >= $frames_scan_per_segment)) {
|
1529 |
+
$this_pct_scanned = ($this->ftell() - $scan_start_offset[$current_segment]) / ($info['avdataend'] - $info['avdataoffset']);
|
1530 |
+
if (($current_segment == 0) && (($this_pct_scanned * $max_scan_segments) >= 1)) {
|
1531 |
+
// file likely contains < $max_frames_scan, just scan as one segment
|
1532 |
+
$max_scan_segments = 1;
|
1533 |
+
$frames_scan_per_segment = $max_frames_scan;
|
1534 |
+
} else {
|
1535 |
+
$pct_data_scanned += $this_pct_scanned;
|
1536 |
+
break;
|
1537 |
+
}
|
1538 |
+
}
|
1539 |
+
}
|
1540 |
+
}
|
1541 |
+
if ($pct_data_scanned > 0) {
|
1542 |
+
$info['warning'][] = 'too many MPEG audio frames to scan, only scanned '.$frames_scanned.' frames in '.$max_scan_segments.' segments ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.';
|
1543 |
+
foreach ($info['mpeg']['audio'] as $key1 => $value1) {
|
1544 |
+
if (!preg_match('#_distribution$#i', $key1)) {
|
1545 |
+
continue;
|
1546 |
+
}
|
1547 |
+
foreach ($value1 as $key2 => $value2) {
|
1548 |
+
$info['mpeg']['audio'][$key1][$key2] = round($value2 / $pct_data_scanned);
|
1549 |
+
}
|
1550 |
+
}
|
1551 |
+
}
|
1552 |
+
|
1553 |
+
if ($SynchErrorsFound > 0) {
|
1554 |
+
$info['warning'][] = 'Found '.$SynchErrorsFound.' synch errors in histogram analysis';
|
1555 |
+
//return false;
|
1556 |
+
}
|
1557 |
+
|
1558 |
+
$bittotal = 0;
|
1559 |
+
$framecounter = 0;
|
1560 |
+
foreach ($info['mpeg']['audio']['bitrate_distribution'] as $bitratevalue => $bitratecount) {
|
1561 |
+
$framecounter += $bitratecount;
|
1562 |
+
if ($bitratevalue != 'free') {
|
1563 |
+
$bittotal += ($bitratevalue * $bitratecount);
|
1564 |
+
}
|
1565 |
+
}
|
1566 |
+
if ($framecounter == 0) {
|
1567 |
+
$info['error'][] = 'Corrupt MP3 file: framecounter == zero';
|
1568 |
+
return false;
|
1569 |
+
}
|
1570 |
+
$info['mpeg']['audio']['frame_count'] = getid3_lib::CastAsInt($framecounter);
|
1571 |
+
$info['mpeg']['audio']['bitrate'] = ($bittotal / $framecounter);
|
1572 |
+
|
1573 |
+
$info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
|
1574 |
+
|
1575 |
+
|
1576 |
+
// Definitively set VBR vs CBR, even if the Xing/LAME/VBRI header says differently
|
1577 |
+
$distinct_bitrates = 0;
|
1578 |
+
foreach ($info['mpeg']['audio']['bitrate_distribution'] as $bitrate_value => $bitrate_count) {
|
1579 |
+
if ($bitrate_count > 0) {
|
1580 |
+
$distinct_bitrates++;
|
1581 |
+
}
|
1582 |
+
}
|
1583 |
+
if ($distinct_bitrates > 1) {
|
1584 |
+
$info['mpeg']['audio']['bitrate_mode'] = 'vbr';
|
1585 |
+
} else {
|
1586 |
+
$info['mpeg']['audio']['bitrate_mode'] = 'cbr';
|
1587 |
+
}
|
1588 |
+
$info['audio']['bitrate_mode'] = $info['mpeg']['audio']['bitrate_mode'];
|
1589 |
+
|
1590 |
+
}
|
1591 |
+
|
1592 |
+
break; // exit while()
|
1593 |
+
}
|
1594 |
+
}
|
1595 |
+
|
1596 |
+
$SynchSeekOffset++;
|
1597 |
+
if (($avdataoffset + $SynchSeekOffset) >= $info['avdataend']) {
|
1598 |
+
// end of file/data
|
1599 |
+
|
1600 |
+
if (empty($info['mpeg']['audio'])) {
|
1601 |
+
|
1602 |
+
$info['error'][] = 'could not find valid MPEG synch before end of file';
|
1603 |
+
if (isset($info['audio']['bitrate'])) {
|
1604 |
+
unset($info['audio']['bitrate']);
|
1605 |
+
}
|
1606 |
+
if (isset($info['mpeg']['audio'])) {
|
1607 |
+
unset($info['mpeg']['audio']);
|
1608 |
+
}
|
1609 |
+
if (isset($info['mpeg']) && (!is_array($info['mpeg']) || empty($info['mpeg']))) {
|
1610 |
+
unset($info['mpeg']);
|
1611 |
+
}
|
1612 |
+
return false;
|
1613 |
+
|
1614 |
+
}
|
1615 |
+
break;
|
1616 |
+
}
|
1617 |
+
|
1618 |
+
}
|
1619 |
+
$info['audio']['channels'] = $info['mpeg']['audio']['channels'];
|
1620 |
+
$info['audio']['channelmode'] = $info['mpeg']['audio']['channelmode'];
|
1621 |
+
$info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
|
1622 |
+
return true;
|
1623 |
+
}
|
1624 |
+
|
1625 |
+
|
1626 |
+
public static function MPEGaudioVersionArray() {
|
1627 |
+
static $MPEGaudioVersion = array('2.5', false, '2', '1');
|
1628 |
+
return $MPEGaudioVersion;
|
1629 |
+
}
|
1630 |
+
|
1631 |
+
public static function MPEGaudioLayerArray() {
|
1632 |
+
static $MPEGaudioLayer = array(false, 3, 2, 1);
|
1633 |
+
return $MPEGaudioLayer;
|
1634 |
+
}
|
1635 |
+
|
1636 |
+
public static function MPEGaudioBitrateArray() {
|
1637 |
+
static $MPEGaudioBitrate;
|
1638 |
+
if (empty($MPEGaudioBitrate)) {
|
1639 |
+
$MPEGaudioBitrate = array (
|
1640 |
+
'1' => array (1 => array('free', 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000),
|
1641 |
+
2 => array('free', 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000),
|
1642 |
+
3 => array('free', 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000)
|
1643 |
+
),
|
1644 |
+
|
1645 |
+
'2' => array (1 => array('free', 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 176000, 192000, 224000, 256000),
|
1646 |
+
2 => array('free', 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000),
|
1647 |
+
)
|
1648 |
+
);
|
1649 |
+
$MPEGaudioBitrate['2'][3] = $MPEGaudioBitrate['2'][2];
|
1650 |
+
$MPEGaudioBitrate['2.5'] = $MPEGaudioBitrate['2'];
|
1651 |
+
}
|
1652 |
+
return $MPEGaudioBitrate;
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
public static function MPEGaudioFrequencyArray() {
|
1656 |
+
static $MPEGaudioFrequency;
|
1657 |
+
if (empty($MPEGaudioFrequency)) {
|
1658 |
+
$MPEGaudioFrequency = array (
|
1659 |
+
'1' => array(44100, 48000, 32000),
|
1660 |
+
'2' => array(22050, 24000, 16000),
|
1661 |
+
'2.5' => array(11025, 12000, 8000)
|
1662 |
+
);
|
1663 |
+
}
|
1664 |
+
return $MPEGaudioFrequency;
|
1665 |
+
}
|
1666 |
+
|
1667 |
+
public static function MPEGaudioChannelModeArray() {
|
1668 |
+
static $MPEGaudioChannelMode = array('stereo', 'joint stereo', 'dual channel', 'mono');
|
1669 |
+
return $MPEGaudioChannelMode;
|
1670 |
+
}
|
1671 |
+
|
1672 |
+
public static function MPEGaudioModeExtensionArray() {
|
1673 |
+
static $MPEGaudioModeExtension;
|
1674 |
+
if (empty($MPEGaudioModeExtension)) {
|
1675 |
+
$MPEGaudioModeExtension = array (
|
1676 |
+
1 => array('4-31', '8-31', '12-31', '16-31'),
|
1677 |
+
2 => array('4-31', '8-31', '12-31', '16-31'),
|
1678 |
+
3 => array('', 'IS', 'MS', 'IS+MS')
|
1679 |
+
);
|
1680 |
+
}
|
1681 |
+
return $MPEGaudioModeExtension;
|
1682 |
+
}
|
1683 |
+
|
1684 |
+
public static function MPEGaudioEmphasisArray() {
|
1685 |
+
static $MPEGaudioEmphasis = array('none', '50/15ms', false, 'CCIT J.17');
|
1686 |
+
return $MPEGaudioEmphasis;
|
1687 |
+
}
|
1688 |
+
|
1689 |
+
public static function MPEGaudioHeaderBytesValid($head4, $allowBitrate15=false) {
|
1690 |
+
return self::MPEGaudioHeaderValid(self::MPEGaudioHeaderDecode($head4), false, $allowBitrate15);
|
1691 |
+
}
|
1692 |
+
|
1693 |
+
public static function MPEGaudioHeaderValid($rawarray, $echoerrors=false, $allowBitrate15=false) {
|
1694 |
+
if (($rawarray['synch'] & 0x0FFE) != 0x0FFE) {
|
1695 |
+
return false;
|
1696 |
+
}
|
1697 |
+
|
1698 |
+
static $MPEGaudioVersionLookup;
|
1699 |
+
static $MPEGaudioLayerLookup;
|
1700 |
+
static $MPEGaudioBitrateLookup;
|
1701 |
+
static $MPEGaudioFrequencyLookup;
|
1702 |
+
static $MPEGaudioChannelModeLookup;
|
1703 |
+
static $MPEGaudioModeExtensionLookup;
|
1704 |
+
static $MPEGaudioEmphasisLookup;
|
1705 |
+
if (empty($MPEGaudioVersionLookup)) {
|
1706 |
+
$MPEGaudioVersionLookup = self::MPEGaudioVersionArray();
|
1707 |
+
$MPEGaudioLayerLookup = self::MPEGaudioLayerArray();
|
1708 |
+
$MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray();
|
1709 |
+
$MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray();
|
1710 |
+
$MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray();
|
1711 |
+
$MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray();
|
1712 |
+
$MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray();
|
1713 |
+
}
|
1714 |
+
|
1715 |
+
if (isset($MPEGaudioVersionLookup[$rawarray['version']])) {
|
1716 |
+
$decodedVersion = $MPEGaudioVersionLookup[$rawarray['version']];
|
1717 |
+
} else {
|
1718 |
+
echo ($echoerrors ? "\n".'invalid Version ('.$rawarray['version'].')' : '');
|
1719 |
+
return false;
|
1720 |
+
}
|
1721 |
+
if (isset($MPEGaudioLayerLookup[$rawarray['layer']])) {
|
1722 |
+
$decodedLayer = $MPEGaudioLayerLookup[$rawarray['layer']];
|
1723 |
+
} else {
|
1724 |
+
echo ($echoerrors ? "\n".'invalid Layer ('.$rawarray['layer'].')' : '');
|
1725 |
+
return false;
|
1726 |
+
}
|
1727 |
+
if (!isset($MPEGaudioBitrateLookup[$decodedVersion][$decodedLayer][$rawarray['bitrate']])) {
|
1728 |
+
echo ($echoerrors ? "\n".'invalid Bitrate ('.$rawarray['bitrate'].')' : '');
|
1729 |
+
if ($rawarray['bitrate'] == 15) {
|
1730 |
+
// known issue in LAME 3.90 - 3.93.1 where free-format has bitrate ID of 15 instead of 0
|
1731 |
+
// let it go through here otherwise file will not be identified
|
1732 |
+
if (!$allowBitrate15) {
|
1733 |
+
return false;
|
1734 |
+
}
|
1735 |
+
} else {
|
1736 |
+
return false;
|
1737 |
+
}
|
1738 |
+
}
|
1739 |
+
if (!isset($MPEGaudioFrequencyLookup[$decodedVersion][$rawarray['sample_rate']])) {
|
1740 |
+
echo ($echoerrors ? "\n".'invalid Frequency ('.$rawarray['sample_rate'].')' : '');
|
1741 |
+
return false;
|
1742 |
+
}
|
1743 |
+
if (!isset($MPEGaudioChannelModeLookup[$rawarray['channelmode']])) {
|
1744 |
+
echo ($echoerrors ? "\n".'invalid ChannelMode ('.$rawarray['channelmode'].')' : '');
|
1745 |
+
return false;
|
1746 |
+
}
|
1747 |
+
if (!isset($MPEGaudioModeExtensionLookup[$decodedLayer][$rawarray['modeextension']])) {
|
1748 |
+
echo ($echoerrors ? "\n".'invalid Mode Extension ('.$rawarray['modeextension'].')' : '');
|
1749 |
+
return false;
|
1750 |
+
}
|
1751 |
+
if (!isset($MPEGaudioEmphasisLookup[$rawarray['emphasis']])) {
|
1752 |
+
echo ($echoerrors ? "\n".'invalid Emphasis ('.$rawarray['emphasis'].')' : '');
|
1753 |
+
return false;
|
1754 |
+
}
|
1755 |
+
// These are just either set or not set, you can't mess that up :)
|
1756 |
+
// $rawarray['protection'];
|
1757 |
+
// $rawarray['padding'];
|
1758 |
+
// $rawarray['private'];
|
1759 |
+
// $rawarray['copyright'];
|
1760 |
+
// $rawarray['original'];
|
1761 |
+
|
1762 |
+
return true;
|
1763 |
+
}
|
1764 |
+
|
1765 |
+
public static function MPEGaudioHeaderDecode($Header4Bytes) {
|
1766 |
+
// AAAA AAAA AAAB BCCD EEEE FFGH IIJJ KLMM
|
1767 |
+
// A - Frame sync (all bits set)
|
1768 |
+
// B - MPEG Audio version ID
|
1769 |
+
// C - Layer description
|
1770 |
+
// D - Protection bit
|
1771 |
+
// E - Bitrate index
|
1772 |
+
// F - Sampling rate frequency index
|
1773 |
+
// G - Padding bit
|
1774 |
+
// H - Private bit
|
1775 |
+
// I - Channel Mode
|
1776 |
+
// J - Mode extension (Only if Joint stereo)
|
1777 |
+
// K - Copyright
|
1778 |
+
// L - Original
|
1779 |
+
// M - Emphasis
|
1780 |
+
|
1781 |
+
if (strlen($Header4Bytes) != 4) {
|
1782 |
+
return false;
|
1783 |
+
}
|
1784 |
+
|
1785 |
+
$MPEGrawHeader['synch'] = (getid3_lib::BigEndian2Int(substr($Header4Bytes, 0, 2)) & 0xFFE0) >> 4;
|
1786 |
+
$MPEGrawHeader['version'] = (ord($Header4Bytes{1}) & 0x18) >> 3; // BB
|
1787 |
+
$MPEGrawHeader['layer'] = (ord($Header4Bytes{1}) & 0x06) >> 1; // CC
|
1788 |
+
$MPEGrawHeader['protection'] = (ord($Header4Bytes{1}) & 0x01); // D
|
1789 |
+
$MPEGrawHeader['bitrate'] = (ord($Header4Bytes{2}) & 0xF0) >> 4; // EEEE
|
1790 |
+
$MPEGrawHeader['sample_rate'] = (ord($Header4Bytes{2}) & 0x0C) >> 2; // FF
|
1791 |
+
$MPEGrawHeader['padding'] = (ord($Header4Bytes{2}) & 0x02) >> 1; // G
|
1792 |
+
$MPEGrawHeader['private'] = (ord($Header4Bytes{2}) & 0x01); // H
|
1793 |
+
$MPEGrawHeader['channelmode'] = (ord($Header4Bytes{3}) & 0xC0) >> 6; // II
|
1794 |
+
$MPEGrawHeader['modeextension'] = (ord($Header4Bytes{3}) & 0x30) >> 4; // JJ
|
1795 |
+
$MPEGrawHeader['copyright'] = (ord($Header4Bytes{3}) & 0x08) >> 3; // K
|
1796 |
+
$MPEGrawHeader['original'] = (ord($Header4Bytes{3}) & 0x04) >> 2; // L
|
1797 |
+
$MPEGrawHeader['emphasis'] = (ord($Header4Bytes{3}) & 0x03); // MM
|
1798 |
+
|
1799 |
+
return $MPEGrawHeader;
|
1800 |
+
}
|
1801 |
+
|
1802 |
+
public static function MPEGaudioFrameLength(&$bitrate, &$version, &$layer, $padding, &$samplerate) {
|
1803 |
+
static $AudioFrameLengthCache = array();
|
1804 |
+
|
1805 |
+
if (!isset($AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate])) {
|
1806 |
+
$AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate] = false;
|
1807 |
+
if ($bitrate != 'free') {
|
1808 |
+
|
1809 |
+
if ($version == '1') {
|
1810 |
+
|
1811 |
+
if ($layer == '1') {
|
1812 |
+
|
1813 |
+
// For Layer I slot is 32 bits long
|
1814 |
+
$FrameLengthCoefficient = 48;
|
1815 |
+
$SlotLength = 4;
|
1816 |
+
|
1817 |
+
} else { // Layer 2 / 3
|
1818 |
+
|
1819 |
+
// for Layer 2 and Layer 3 slot is 8 bits long.
|
1820 |
+
$FrameLengthCoefficient = 144;
|
1821 |
+
$SlotLength = 1;
|
1822 |
+
|
1823 |
+
}
|
1824 |
+
|
1825 |
+
} else { // MPEG-2 / MPEG-2.5
|
1826 |
+
|
1827 |
+
if ($layer == '1') {
|
1828 |
+
|
1829 |
+
// For Layer I slot is 32 bits long
|
1830 |
+
$FrameLengthCoefficient = 24;
|
1831 |
+
$SlotLength = 4;
|
1832 |
+
|
1833 |
+
} elseif ($layer == '2') {
|
1834 |
+
|
1835 |
+
// for Layer 2 and Layer 3 slot is 8 bits long.
|
1836 |
+
$FrameLengthCoefficient = 144;
|
1837 |
+
$SlotLength = 1;
|
1838 |
+
|
1839 |
+
} else { // layer 3
|
1840 |
+
|
1841 |
+
// for Layer 2 and Layer 3 slot is 8 bits long.
|
1842 |
+
$FrameLengthCoefficient = 72;
|
1843 |
+
$SlotLength = 1;
|
1844 |
+
|
1845 |
+
}
|
1846 |
+
|
1847 |
+
}
|
1848 |
+
|
1849 |
+
// FrameLengthInBytes = ((Coefficient * BitRate) / SampleRate) + Padding
|
1850 |
+
if ($samplerate > 0) {
|
1851 |
+
$NewFramelength = ($FrameLengthCoefficient * $bitrate) / $samplerate;
|
1852 |
+
$NewFramelength = floor($NewFramelength / $SlotLength) * $SlotLength; // round to next-lower multiple of SlotLength (1 byte for Layer 2/3, 4 bytes for Layer I)
|
1853 |
+
if ($padding) {
|
1854 |
+
$NewFramelength += $SlotLength;
|
1855 |
+
}
|
1856 |
+
$AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate] = (int) $NewFramelength;
|
1857 |
+
}
|
1858 |
+
}
|
1859 |
+
}
|
1860 |
+
return $AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate];
|
1861 |
+
}
|
1862 |
+
|
1863 |
+
public static function ClosestStandardMP3Bitrate($bit_rate) {
|
1864 |
+
static $standard_bit_rates = array (320000, 256000, 224000, 192000, 160000, 128000, 112000, 96000, 80000, 64000, 56000, 48000, 40000, 32000, 24000, 16000, 8000);
|
1865 |
+
static $bit_rate_table = array (0=>'-');
|
1866 |
+
$round_bit_rate = intval(round($bit_rate, -3));
|
1867 |
+
if (!isset($bit_rate_table[$round_bit_rate])) {
|
1868 |
+
if ($round_bit_rate > max($standard_bit_rates)) {
|
1869 |
+
$bit_rate_table[$round_bit_rate] = round($bit_rate, 2 - strlen($bit_rate));
|
1870 |
+
} else {
|
1871 |
+
$bit_rate_table[$round_bit_rate] = max($standard_bit_rates);
|
1872 |
+
foreach ($standard_bit_rates as $standard_bit_rate) {
|
1873 |
+
if ($round_bit_rate >= $standard_bit_rate + (($bit_rate_table[$round_bit_rate] - $standard_bit_rate) / 2)) {
|
1874 |
+
break;
|
1875 |
+
}
|
1876 |
+
$bit_rate_table[$round_bit_rate] = $standard_bit_rate;
|
1877 |
+
}
|
1878 |
+
}
|
1879 |
+
}
|
1880 |
+
return $bit_rate_table[$round_bit_rate];
|
1881 |
+
}
|
1882 |
+
|
1883 |
+
public static function XingVBRidOffset($version, $channelmode) {
|
1884 |
+
static $XingVBRidOffsetCache = array();
|
1885 |
+
if (empty($XingVBRidOffset)) {
|
1886 |
+
$XingVBRidOffset = array (
|
1887 |
+
'1' => array ('mono' => 0x15, // 4 + 17 = 21
|
1888 |
+
'stereo' => 0x24, // 4 + 32 = 36
|
1889 |
+
'joint stereo' => 0x24,
|
1890 |
+
'dual channel' => 0x24
|
1891 |
+
),
|
1892 |
+
|
1893 |
+
'2' => array ('mono' => 0x0D, // 4 + 9 = 13
|
1894 |
+
'stereo' => 0x15, // 4 + 17 = 21
|
1895 |
+
'joint stereo' => 0x15,
|
1896 |
+
'dual channel' => 0x15
|
1897 |
+
),
|
1898 |
+
|
1899 |
+
'2.5' => array ('mono' => 0x15,
|
1900 |
+
'stereo' => 0x15,
|
1901 |
+
'joint stereo' => 0x15,
|
1902 |
+
'dual channel' => 0x15
|
1903 |
+
)
|
1904 |
+
);
|
1905 |
+
}
|
1906 |
+
return $XingVBRidOffset[$version][$channelmode];
|
1907 |
+
}
|
1908 |
+
|
1909 |
+
public static function LAMEvbrMethodLookup($VBRmethodID) {
|
1910 |
+
static $LAMEvbrMethodLookup = array(
|
1911 |
+
0x00 => 'unknown',
|
1912 |
+
0x01 => 'cbr',
|
1913 |
+
0x02 => 'abr',
|
1914 |
+
0x03 => 'vbr-old / vbr-rh',
|
1915 |
+
0x04 => 'vbr-new / vbr-mtrh',
|
1916 |
+
0x05 => 'vbr-mt',
|
1917 |
+
0x06 => 'vbr (full vbr method 4)',
|
1918 |
+
0x08 => 'cbr (constant bitrate 2 pass)',
|
1919 |
+
0x09 => 'abr (2 pass)',
|
1920 |
+
0x0F => 'reserved'
|
1921 |
+
);
|
1922 |
+
return (isset($LAMEvbrMethodLookup[$VBRmethodID]) ? $LAMEvbrMethodLookup[$VBRmethodID] : '');
|
1923 |
+
}
|
1924 |
+
|
1925 |
+
public static function LAMEmiscStereoModeLookup($StereoModeID) {
|
1926 |
+
static $LAMEmiscStereoModeLookup = array(
|
1927 |
+
0 => 'mono',
|
1928 |
+
1 => 'stereo',
|
1929 |
+
2 => 'dual mono',
|
1930 |
+
3 => 'joint stereo',
|
1931 |
+
4 => 'forced stereo',
|
1932 |
+
5 => 'auto',
|
1933 |
+
6 => 'intensity stereo',
|
1934 |
+
7 => 'other'
|
1935 |
+
);
|
1936 |
+
return (isset($LAMEmiscStereoModeLookup[$StereoModeID]) ? $LAMEmiscStereoModeLookup[$StereoModeID] : '');
|
1937 |
+
}
|
1938 |
+
|
1939 |
+
public static function LAMEmiscSourceSampleFrequencyLookup($SourceSampleFrequencyID) {
|
1940 |
+
static $LAMEmiscSourceSampleFrequencyLookup = array(
|
1941 |
+
0 => '<= 32 kHz',
|
1942 |
+
1 => '44.1 kHz',
|
1943 |
+
2 => '48 kHz',
|
1944 |
+
3 => '> 48kHz'
|
1945 |
+
);
|
1946 |
+
return (isset($LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID]) ? $LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID] : '');
|
1947 |
+
}
|
1948 |
+
|
1949 |
+
public static function LAMEsurroundInfoLookup($SurroundInfoID) {
|
1950 |
+
static $LAMEsurroundInfoLookup = array(
|
1951 |
+
0 => 'no surround info',
|
1952 |
+
1 => 'DPL encoding',
|
1953 |
+
2 => 'DPL2 encoding',
|
1954 |
+
3 => 'Ambisonic encoding'
|
1955 |
+
);
|
1956 |
+
return (isset($LAMEsurroundInfoLookup[$SurroundInfoID]) ? $LAMEsurroundInfoLookup[$SurroundInfoID] : 'reserved');
|
1957 |
+
}
|
1958 |
+
|
1959 |
+
public static function LAMEpresetUsedLookup($LAMEtag) {
|
1960 |
+
|
1961 |
+
if ($LAMEtag['preset_used_id'] == 0) {
|
1962 |
+
// no preset used (LAME >=3.93)
|
1963 |
+
// no preset recorded (LAME <3.93)
|
1964 |
+
return '';
|
1965 |
+
}
|
1966 |
+
$LAMEpresetUsedLookup = array();
|
1967 |
+
|
1968 |
+
///// THIS PART CANNOT BE STATIC .
|
1969 |
+
for ($i = 8; $i <= 320; $i++) {
|
1970 |
+
switch ($LAMEtag['vbr_method']) {
|
1971 |
+
case 'cbr':
|
1972 |
+
$LAMEpresetUsedLookup[$i] = '--alt-preset '.$LAMEtag['vbr_method'].' '.$i;
|
1973 |
+
break;
|
1974 |
+
case 'abr':
|
1975 |
+
default: // other VBR modes shouldn't be here(?)
|
1976 |
+
$LAMEpresetUsedLookup[$i] = '--alt-preset '.$i;
|
1977 |
+
break;
|
1978 |
+
}
|
1979 |
+
}
|
1980 |
+
|
1981 |
+
// named old-style presets (studio, phone, voice, etc) are handled in GuessEncoderOptions()
|
1982 |
+
|
1983 |
+
// named alt-presets
|
1984 |
+
$LAMEpresetUsedLookup[1000] = '--r3mix';
|
1985 |
+
$LAMEpresetUsedLookup[1001] = '--alt-preset standard';
|
1986 |
+
$LAMEpresetUsedLookup[1002] = '--alt-preset extreme';
|
1987 |
+
$LAMEpresetUsedLookup[1003] = '--alt-preset insane';
|
1988 |
+
$LAMEpresetUsedLookup[1004] = '--alt-preset fast standard';
|
1989 |
+
$LAMEpresetUsedLookup[1005] = '--alt-preset fast extreme';
|
1990 |
+
$LAMEpresetUsedLookup[1006] = '--alt-preset medium';
|
1991 |
+
$LAMEpresetUsedLookup[1007] = '--alt-preset fast medium';
|
1992 |
+
|
1993 |
+
// LAME 3.94 additions/changes
|
1994 |
+
$LAMEpresetUsedLookup[1010] = '--preset portable'; // 3.94a15 Oct 21 2003
|
1995 |
+
$LAMEpresetUsedLookup[1015] = '--preset radio'; // 3.94a15 Oct 21 2003
|
1996 |
+
|
1997 |
+
$LAMEpresetUsedLookup[320] = '--preset insane'; // 3.94a15 Nov 12 2003
|
1998 |
+
$LAMEpresetUsedLookup[410] = '-V9';
|
1999 |
+
$LAMEpresetUsedLookup[420] = '-V8';
|
2000 |
+
$LAMEpresetUsedLookup[440] = '-V6';
|
2001 |
+
$LAMEpresetUsedLookup[430] = '--preset radio'; // 3.94a15 Nov 12 2003
|
2002 |
+
$LAMEpresetUsedLookup[450] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'portable'; // 3.94a15 Nov 12 2003
|
2003 |
+
$LAMEpresetUsedLookup[460] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'medium'; // 3.94a15 Nov 12 2003
|
2004 |
+
$LAMEpresetUsedLookup[470] = '--r3mix'; // 3.94b1 Dec 18 2003
|
2005 |
+
$LAMEpresetUsedLookup[480] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'standard'; // 3.94a15 Nov 12 2003
|
2006 |
+
$LAMEpresetUsedLookup[490] = '-V1';
|
2007 |
+
$LAMEpresetUsedLookup[500] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'extreme'; // 3.94a15 Nov 12 2003
|
2008 |
+
|
2009 |
+
return (isset($LAMEpresetUsedLookup[$LAMEtag['preset_used_id']]) ? $LAMEpresetUsedLookup[$LAMEtag['preset_used_id']] : 'new/unknown preset: '.$LAMEtag['preset_used_id'].' - report to info@getid3.org');
|
2010 |
+
}
|
2011 |
+
|
2012 |
+
}
|
getid3/module.audio.ogg.php
ADDED
@@ -0,0 +1,756 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/////////////////////////////////////////////////////////////////
|
3 |
+
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
+
// available at http://getid3.sourceforge.net //
|
5 |
+
// or http://www.getid3.org //
|
6 |
+
// also https://github.com/JamesHeinrich/getID3 //
|
7 |
+
/////////////////////////////////////////////////////////////////
|
8 |
+
// See readme.txt for more details //
|
9 |
+
/////////////////////////////////////////////////////////////////
|
10 |
+
// //
|
11 |
+
// module.audio.ogg.php //
|
12 |
+
// module for analyzing Ogg Vorbis, OggFLAC and Speex files //
|
13 |
+
// dependencies: module.audio.flac.php //
|
14 |
+
// ///
|
15 |
+
/////////////////////////////////////////////////////////////////
|
16 |
+
|
17 |
+
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.flac.php', __FILE__, true);
|
18 |
+
|
19 |
+
class getid3_ogg extends getid3_handler
|
20 |
+
{
|
21 |
+
// http://xiph.org/vorbis/doc/Vorbis_I_spec.html
|
22 |
+
public function Analyze() {
|
23 |
+
$info = &$this->getid3->info;
|
24 |
+
|
25 |
+
$info['fileformat'] = 'ogg';
|
26 |
+
|
27 |
+
// Warn about illegal tags - only vorbiscomments are allowed
|
28 |
+
if (isset($info['id3v2'])) {
|
29 |
+
$info['warning'][] = 'Illegal ID3v2 tag present.';
|
30 |
+
}
|
31 |
+
if (isset($info['id3v1'])) {
|
32 |
+
$info['warning'][] = 'Illegal ID3v1 tag present.';
|
33 |
+
}
|
34 |
+
if (isset($info['ape'])) {
|
35 |
+
$info['warning'][] = 'Illegal APE tag present.';
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
// Page 1 - Stream Header
|
40 |
+
|
41 |
+
$this->fseek($info['avdataoffset']);
|
42 |
+
|
43 |
+
$oggpageinfo = $this->ParseOggPageHeader();
|
44 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
|
45 |
+
|
46 |
+
if ($this->ftell() >= $this->getid3->fread_buffer_size()) {
|
47 |
+
$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?)';
|
48 |
+
unset($info['fileformat']);
|
49 |
+
unset($info['ogg']);
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
$filedata = $this->fread($oggpageinfo['page_length']);
|
54 |
+
$filedataoffset = 0;
|
55 |
+
|
56 |
+
if (substr($filedata, 0, 4) == 'fLaC') {
|
57 |
+
|
58 |
+
$info['audio']['dataformat'] = 'flac';
|
59 |
+
$info['audio']['bitrate_mode'] = 'vbr';
|
60 |
+
$info['audio']['lossless'] = true;
|
61 |
+
|
62 |
+
} elseif (substr($filedata, 1, 6) == 'vorbis') {
|
63 |
+
|
64 |
+
$this->ParseVorbisPageHeader($filedata, $filedataoffset, $oggpageinfo);
|
65 |
+
|
66 |
+
} elseif (substr($filedata, 0, 8) == 'Speex ') {
|
67 |
+
|
68 |
+
// http://www.speex.org/manual/node10.html
|
69 |
+
|
70 |
+
$info['audio']['dataformat'] = 'speex';
|
71 |
+
$info['mime_type'] = 'audio/speex';
|
72 |
+
$info['audio']['bitrate_mode'] = 'abr';
|
73 |
+
$info['audio']['lossless'] = false;
|
74 |
+
|
75 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_string'] = substr($filedata, $filedataoffset, 8); // hard-coded to 'Speex '
|
76 |
+
$filedataoffset += 8;
|
77 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version'] = substr($filedata, $filedataoffset, 20);
|
78 |
+
$filedataoffset += 20;
|
79 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version_id'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
80 |
+
$filedataoffset += 4;
|
81 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['header_size'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
82 |
+
$filedataoffset += 4;
|
83 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
84 |
+
$filedataoffset += 4;
|
85 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
86 |
+
$filedataoffset += 4;
|
87 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode_bitstream_version'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
88 |
+
$filedataoffset += 4;
|
89 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
90 |
+
$filedataoffset += 4;
|
91 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['bitrate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
92 |
+
$filedataoffset += 4;
|
93 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['framesize'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
94 |
+
$filedataoffset += 4;
|
95 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['vbr'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
96 |
+
$filedataoffset += 4;
|
97 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['frames_per_packet'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
98 |
+
$filedataoffset += 4;
|
99 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['extra_headers'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
100 |
+
$filedataoffset += 4;
|
101 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['reserved1'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
102 |
+
$filedataoffset += 4;
|
103 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['reserved2'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
104 |
+
$filedataoffset += 4;
|
105 |
+
|
106 |
+
$info['speex']['speex_version'] = trim($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version']);
|
107 |
+
$info['speex']['sample_rate'] = $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate'];
|
108 |
+
$info['speex']['channels'] = $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels'];
|
109 |
+
$info['speex']['vbr'] = (bool) $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['vbr'];
|
110 |
+
$info['speex']['band_type'] = $this->SpeexBandModeLookup($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode']);
|
111 |
+
|
112 |
+
$info['audio']['sample_rate'] = $info['speex']['sample_rate'];
|
113 |
+
$info['audio']['channels'] = $info['speex']['channels'];
|
114 |
+
if ($info['speex']['vbr']) {
|
115 |
+
$info['audio']['bitrate_mode'] = 'vbr';
|
116 |
+
}
|
117 |
+
|
118 |
+
} elseif (substr($filedata, 0, 7) == "\x80".'theora') {
|
119 |
+
|
120 |
+
// http://www.theora.org/doc/Theora.pdf (section 6.2)
|
121 |
+
|
122 |
+
$info['ogg']['pageheader']['theora']['theora_magic'] = substr($filedata, $filedataoffset, 7); // hard-coded to "\x80.'theora'
|
123 |
+
$filedataoffset += 7;
|
124 |
+
$info['ogg']['pageheader']['theora']['version_major'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
|
125 |
+
$filedataoffset += 1;
|
126 |
+
$info['ogg']['pageheader']['theora']['version_minor'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
|
127 |
+
$filedataoffset += 1;
|
128 |
+
$info['ogg']['pageheader']['theora']['version_revision'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
|
129 |
+
$filedataoffset += 1;
|
130 |
+
$info['ogg']['pageheader']['theora']['frame_width_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2));
|
131 |
+
$filedataoffset += 2;
|
132 |
+
$info['ogg']['pageheader']['theora']['frame_height_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2));
|
133 |
+
$filedataoffset += 2;
|
134 |
+
$info['ogg']['pageheader']['theora']['resolution_x'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3));
|
135 |
+
$filedataoffset += 3;
|
136 |
+
$info['ogg']['pageheader']['theora']['resolution_y'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3));
|
137 |
+
$filedataoffset += 3;
|
138 |
+
$info['ogg']['pageheader']['theora']['picture_offset_x'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
|
139 |
+
$filedataoffset += 1;
|
140 |
+
$info['ogg']['pageheader']['theora']['picture_offset_y'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
|
141 |
+
$filedataoffset += 1;
|
142 |
+
$info['ogg']['pageheader']['theora']['frame_rate_numerator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4));
|
143 |
+
$filedataoffset += 4;
|
144 |
+
$info['ogg']['pageheader']['theora']['frame_rate_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4));
|
145 |
+
$filedataoffset += 4;
|
146 |
+
$info['ogg']['pageheader']['theora']['pixel_aspect_numerator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3));
|
147 |
+
$filedataoffset += 3;
|
148 |
+
$info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3));
|
149 |
+
$filedataoffset += 3;
|
150 |
+
$info['ogg']['pageheader']['theora']['color_space_id'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1));
|
151 |
+
$filedataoffset += 1;
|
152 |
+
$info['ogg']['pageheader']['theora']['nominal_bitrate'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3));
|
153 |
+
$filedataoffset += 3;
|
154 |
+
$info['ogg']['pageheader']['theora']['flags'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2));
|
155 |
+
$filedataoffset += 2;
|
156 |
+
|
157 |
+
$info['ogg']['pageheader']['theora']['quality'] = ($info['ogg']['pageheader']['theora']['flags'] & 0xFC00) >> 10;
|
158 |
+
$info['ogg']['pageheader']['theora']['kfg_shift'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x03E0) >> 5;
|
159 |
+
$info['ogg']['pageheader']['theora']['pixel_format_id'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0018) >> 3;
|
160 |
+
$info['ogg']['pageheader']['theora']['reserved'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0007) >> 0; // should be 0
|
161 |
+
$info['ogg']['pageheader']['theora']['color_space'] = self::TheoraColorSpace($info['ogg']['pageheader']['theora']['color_space_id']);
|
162 |
+
$info['ogg']['pageheader']['theora']['pixel_format'] = self::TheoraPixelFormat($info['ogg']['pageheader']['theora']['pixel_format_id']);
|
163 |
+
|
164 |
+
$info['video']['dataformat'] = 'theora';
|
165 |
+
$info['mime_type'] = 'video/ogg';
|
166 |
+
//$info['audio']['bitrate_mode'] = 'abr';
|
167 |
+
//$info['audio']['lossless'] = false;
|
168 |
+
$info['video']['resolution_x'] = $info['ogg']['pageheader']['theora']['resolution_x'];
|
169 |
+
$info['video']['resolution_y'] = $info['ogg']['pageheader']['theora']['resolution_y'];
|
170 |
+
if ($info['ogg']['pageheader']['theora']['frame_rate_denominator'] > 0) {
|
171 |
+
$info['video']['frame_rate'] = (float) $info['ogg']['pageheader']['theora']['frame_rate_numerator'] / $info['ogg']['pageheader']['theora']['frame_rate_denominator'];
|
172 |
+
}
|
173 |
+
if ($info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] > 0) {
|
174 |
+
$info['video']['pixel_aspect_ratio'] = (float) $info['ogg']['pageheader']['theora']['pixel_aspect_numerator'] / $info['ogg']['pageheader']['theora']['pixel_aspect_denominator'];
|
175 |
+
}
|
176 |
+
$info['warning'][] = 'Ogg Theora (v3) not fully supported in this version of getID3 ['.$this->getid3->version().'] -- bitrate, playtime and all audio data are currently unavailable';
|
177 |
+
|
178 |
+
|
179 |
+
} elseif (substr($filedata, 0, 8) == "fishead\x00") {
|
180 |
+
|
181 |
+
// Ogg Skeleton version 3.0 Format Specification
|
182 |
+
// http://xiph.org/ogg/doc/skeleton.html
|
183 |
+
$filedataoffset += 8;
|
184 |
+
$info['ogg']['skeleton']['fishead']['raw']['version_major'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2));
|
185 |
+
$filedataoffset += 2;
|
186 |
+
$info['ogg']['skeleton']['fishead']['raw']['version_minor'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2));
|
187 |
+
$filedataoffset += 2;
|
188 |
+
$info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
|
189 |
+
$filedataoffset += 8;
|
190 |
+
$info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
|
191 |
+
$filedataoffset += 8;
|
192 |
+
$info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
|
193 |
+
$filedataoffset += 8;
|
194 |
+
$info['ogg']['skeleton']['fishead']['raw']['basetime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
|
195 |
+
$filedataoffset += 8;
|
196 |
+
$info['ogg']['skeleton']['fishead']['raw']['utc'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 20));
|
197 |
+
$filedataoffset += 20;
|
198 |
+
|
199 |
+
$info['ogg']['skeleton']['fishead']['version'] = $info['ogg']['skeleton']['fishead']['raw']['version_major'].'.'.$info['ogg']['skeleton']['fishead']['raw']['version_minor'];
|
200 |
+
$info['ogg']['skeleton']['fishead']['presentationtime'] = $info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'];
|
201 |
+
$info['ogg']['skeleton']['fishead']['basetime'] = $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator'];
|
202 |
+
$info['ogg']['skeleton']['fishead']['utc'] = $info['ogg']['skeleton']['fishead']['raw']['utc'];
|
203 |
+
|
204 |
+
|
205 |
+
$counter = 0;
|
206 |
+
do {
|
207 |
+
$oggpageinfo = $this->ParseOggPageHeader();
|
208 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno'].'.'.$counter++] = $oggpageinfo;
|
209 |
+
$filedata = $this->fread($oggpageinfo['page_length']);
|
210 |
+
$this->fseek($oggpageinfo['page_end_offset']);
|
211 |
+
|
212 |
+
if (substr($filedata, 0, 8) == "fisbone\x00") {
|
213 |
+
|
214 |
+
$filedataoffset = 8;
|
215 |
+
$info['ogg']['skeleton']['fisbone']['raw']['message_header_offset'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
216 |
+
$filedataoffset += 4;
|
217 |
+
$info['ogg']['skeleton']['fisbone']['raw']['serial_number'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
218 |
+
$filedataoffset += 4;
|
219 |
+
$info['ogg']['skeleton']['fisbone']['raw']['number_header_packets'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
220 |
+
$filedataoffset += 4;
|
221 |
+
$info['ogg']['skeleton']['fisbone']['raw']['granulerate_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
|
222 |
+
$filedataoffset += 8;
|
223 |
+
$info['ogg']['skeleton']['fisbone']['raw']['granulerate_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
|
224 |
+
$filedataoffset += 8;
|
225 |
+
$info['ogg']['skeleton']['fisbone']['raw']['basegranule'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
|
226 |
+
$filedataoffset += 8;
|
227 |
+
$info['ogg']['skeleton']['fisbone']['raw']['preroll'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
228 |
+
$filedataoffset += 4;
|
229 |
+
$info['ogg']['skeleton']['fisbone']['raw']['granuleshift'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
|
230 |
+
$filedataoffset += 1;
|
231 |
+
$info['ogg']['skeleton']['fisbone']['raw']['padding'] = substr($filedata, $filedataoffset, 3);
|
232 |
+
$filedataoffset += 3;
|
233 |
+
|
234 |
+
} elseif (substr($filedata, 1, 6) == 'theora') {
|
235 |
+
|
236 |
+
$info['video']['dataformat'] = 'theora1';
|
237 |
+
$info['error'][] = 'Ogg Theora (v1) not correctly handled in this version of getID3 ['.$this->getid3->version().']';
|
238 |
+
//break;
|
239 |
+
|
240 |
+
} elseif (substr($filedata, 1, 6) == 'vorbis') {
|
241 |
+
|
242 |
+
$this->ParseVorbisPageHeader($filedata, $filedataoffset, $oggpageinfo);
|
243 |
+
|
244 |
+
} else {
|
245 |
+
$info['error'][] = 'unexpected';
|
246 |
+
//break;
|
247 |
+
}
|
248 |
+
//} while ($oggpageinfo['page_seqno'] == 0);
|
249 |
+
} while (($oggpageinfo['page_seqno'] == 0) && (substr($filedata, 0, 8) != "fisbone\x00"));
|
250 |
+
|
251 |
+
$this->fseek($oggpageinfo['page_start_offset']);
|
252 |
+
|
253 |
+
$info['error'][] = 'Ogg Skeleton not correctly handled in this version of getID3 ['.$this->getid3->version().']';
|
254 |
+
//return false;
|
255 |
+
|
256 |
+
} else {
|
257 |
+
|
258 |
+
$info['error'][] = 'Expecting either "Speex " or "vorbis" identifier strings, found "'.substr($filedata, 0, 8).'"';
|
259 |
+
unset($info['ogg']);
|
260 |
+
unset($info['mime_type']);
|
261 |
+
return false;
|
262 |
+
|
263 |
+
}
|
264 |
+
|
265 |
+
// Page 2 - Comment Header
|
266 |
+
$oggpageinfo = $this->ParseOggPageHeader();
|
267 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
|
268 |
+
|
269 |
+
switch ($info['audio']['dataformat']) {
|
270 |
+
case 'vorbis':
|
271 |
+
$filedata = $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
|
272 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, 0, 1));
|
273 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 1, 6); // hard-coded to 'vorbis'
|
274 |
+
|
275 |
+
$this->ParseVorbisComments();
|
276 |
+
break;
|
277 |
+
|
278 |
+
case 'flac':
|
279 |
+
$flac = new getid3_flac($this->getid3);
|
280 |
+
if (!$flac->parseMETAdata()) {
|
281 |
+
$info['error'][] = 'Failed to parse FLAC headers';
|
282 |
+
return false;
|
283 |
+
}
|
284 |
+
unset($flac);
|
285 |
+
break;
|
286 |
+
|
287 |
+
case 'speex':
|
288 |
+
$this->fseek($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length'], SEEK_CUR);
|
289 |
+
$this->ParseVorbisComments();
|
290 |
+
break;
|
291 |
+
}
|
292 |
+
|
293 |
+
|
294 |
+
// Last Page - Number of Samples
|
295 |
+
if (!getid3_lib::intValueSupported($info['avdataend'])) {
|
296 |
+
|
297 |
+
$info['warning'][] = 'Unable to parse Ogg end chunk file (PHP does not support file operations beyond '.round(PHP_INT_MAX / 1073741824).'GB)';
|
298 |
+
|
299 |
+
} else {
|
300 |
+
|
301 |
+
$this->fseek(max($info['avdataend'] - $this->getid3->fread_buffer_size(), 0));
|
302 |
+
$LastChunkOfOgg = strrev($this->fread($this->getid3->fread_buffer_size()));
|
303 |
+
if ($LastOggSpostion = strpos($LastChunkOfOgg, 'SggO')) {
|
304 |
+
$this->fseek($info['avdataend'] - ($LastOggSpostion + strlen('SggO')));
|
305 |
+
$info['avdataend'] = $this->ftell();
|
306 |
+
$info['ogg']['pageheader']['eos'] = $this->ParseOggPageHeader();
|
307 |
+
$info['ogg']['samples'] = $info['ogg']['pageheader']['eos']['pcm_abs_position'];
|
308 |
+
if ($info['ogg']['samples'] == 0) {
|
309 |
+
$info['error'][] = 'Corrupt Ogg file: eos.number of samples == zero';
|
310 |
+
return false;
|
311 |
+
}
|
312 |
+
if (!empty($info['audio']['sample_rate'])) {
|
313 |
+
$info['ogg']['bitrate_average'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['ogg']['samples'] / $info['audio']['sample_rate']);
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
}
|
318 |
+
|
319 |
+
if (!empty($info['ogg']['bitrate_average'])) {
|
320 |
+
$info['audio']['bitrate'] = $info['ogg']['bitrate_average'];
|
321 |
+
} elseif (!empty($info['ogg']['bitrate_nominal'])) {
|
322 |
+
$info['audio']['bitrate'] = $info['ogg']['bitrate_nominal'];
|
323 |
+
} elseif (!empty($info['ogg']['bitrate_min']) && !empty($info['ogg']['bitrate_max'])) {
|
324 |
+
$info['audio']['bitrate'] = ($info['ogg']['bitrate_min'] + $info['ogg']['bitrate_max']) / 2;
|
325 |
+
}
|
326 |
+
if (isset($info['audio']['bitrate']) && !isset($info['playtime_seconds'])) {
|
327 |
+
if ($info['audio']['bitrate'] == 0) {
|
328 |
+
$info['error'][] = 'Corrupt Ogg file: bitrate_audio == zero';
|
329 |
+
return false;
|
330 |
+
}
|
331 |
+
$info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $info['audio']['bitrate']);
|
332 |
+
}
|
333 |
+
|
334 |
+
if (isset($info['ogg']['vendor'])) {
|
335 |
+
$info['audio']['encoder'] = preg_replace('/^Encoded with /', '', $info['ogg']['vendor']);
|
336 |
+
|
337 |
+
// Vorbis only
|
338 |
+
if ($info['audio']['dataformat'] == 'vorbis') {
|
339 |
+
|
340 |
+
// Vorbis 1.0 starts with Xiph.Org
|
341 |
+
if (preg_match('/^Xiph.Org/', $info['audio']['encoder'])) {
|
342 |
+
|
343 |
+
if ($info['audio']['bitrate_mode'] == 'abr') {
|
344 |
+
|
345 |
+
// Set -b 128 on abr files
|
346 |
+
$info['audio']['encoder_options'] = '-b '.round($info['ogg']['bitrate_nominal'] / 1000);
|
347 |
+
|
348 |
+
} elseif (($info['audio']['bitrate_mode'] == 'vbr') && ($info['audio']['channels'] == 2) && ($info['audio']['sample_rate'] >= 44100) && ($info['audio']['sample_rate'] <= 48000)) {
|
349 |
+
// Set -q N on vbr files
|
350 |
+
$info['audio']['encoder_options'] = '-q '.$this->get_quality_from_nominal_bitrate($info['ogg']['bitrate_nominal']);
|
351 |
+
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
if (empty($info['audio']['encoder_options']) && !empty($info['ogg']['bitrate_nominal'])) {
|
356 |
+
$info['audio']['encoder_options'] = 'Nominal bitrate: '.intval(round($info['ogg']['bitrate_nominal'] / 1000)).'kbps';
|
357 |
+
}
|
358 |
+
}
|
359 |
+
}
|
360 |
+
|
361 |
+
return true;
|
362 |
+
}
|
363 |
+
|
364 |
+
public function ParseVorbisPageHeader(&$filedata, &$filedataoffset, &$oggpageinfo) {
|
365 |
+
$info = &$this->getid3->info;
|
366 |
+
$info['audio']['dataformat'] = 'vorbis';
|
367 |
+
$info['audio']['lossless'] = false;
|
368 |
+
|
369 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
|
370 |
+
$filedataoffset += 1;
|
371 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, $filedataoffset, 6); // hard-coded to 'vorbis'
|
372 |
+
$filedataoffset += 6;
|
373 |
+
$info['ogg']['bitstreamversion'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
374 |
+
$filedataoffset += 4;
|
375 |
+
$info['ogg']['numberofchannels'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
|
376 |
+
$filedataoffset += 1;
|
377 |
+
$info['audio']['channels'] = $info['ogg']['numberofchannels'];
|
378 |
+
$info['ogg']['samplerate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
379 |
+
$filedataoffset += 4;
|
380 |
+
if ($info['ogg']['samplerate'] == 0) {
|
381 |
+
$info['error'][] = 'Corrupt Ogg file: sample rate == zero';
|
382 |
+
return false;
|
383 |
+
}
|
384 |
+
$info['audio']['sample_rate'] = $info['ogg']['samplerate'];
|
385 |
+
$info['ogg']['samples'] = 0; // filled in later
|
386 |
+
$info['ogg']['bitrate_average'] = 0; // filled in later
|
387 |
+
$info['ogg']['bitrate_max'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
388 |
+
$filedataoffset += 4;
|
389 |
+
$info['ogg']['bitrate_nominal'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
390 |
+
$filedataoffset += 4;
|
391 |
+
$info['ogg']['bitrate_min'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
392 |
+
$filedataoffset += 4;
|
393 |
+
$info['ogg']['blocksize_small'] = pow(2, getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0x0F);
|
394 |
+
$info['ogg']['blocksize_large'] = pow(2, (getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0xF0) >> 4);
|
395 |
+
$info['ogg']['stop_bit'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); // must be 1, marks end of packet
|
396 |
+
|
397 |
+
$info['audio']['bitrate_mode'] = 'vbr'; // overridden if actually abr
|
398 |
+
if ($info['ogg']['bitrate_max'] == 0xFFFFFFFF) {
|
399 |
+
unset($info['ogg']['bitrate_max']);
|
400 |
+
$info['audio']['bitrate_mode'] = 'abr';
|
401 |
+
}
|
402 |
+
if ($info['ogg']['bitrate_nominal'] == 0xFFFFFFFF) {
|
403 |
+
unset($info['ogg']['bitrate_nominal']);
|
404 |
+
}
|
405 |
+
if ($info['ogg']['bitrate_min'] == 0xFFFFFFFF) {
|
406 |
+
unset($info['ogg']['bitrate_min']);
|
407 |
+
$info['audio']['bitrate_mode'] = 'abr';
|
408 |
+
}
|
409 |
+
return true;
|
410 |
+
}
|
411 |
+
|
412 |
+
public function ParseOggPageHeader() {
|
413 |
+
// http://xiph.org/ogg/vorbis/doc/framing.html
|
414 |
+
$oggheader['page_start_offset'] = $this->ftell(); // where we started from in the file
|
415 |
+
|
416 |
+
$filedata = $this->fread($this->getid3->fread_buffer_size());
|
417 |
+
$filedataoffset = 0;
|
418 |
+
while ((substr($filedata, $filedataoffset++, 4) != 'OggS')) {
|
419 |
+
if (($this->ftell() - $oggheader['page_start_offset']) >= $this->getid3->fread_buffer_size()) {
|
420 |
+
// should be found before here
|
421 |
+
return false;
|
422 |
+
}
|
423 |
+
if ((($filedataoffset + 28) > strlen($filedata)) || (strlen($filedata) < 28)) {
|
424 |
+
if ($this->feof() || (($filedata .= $this->fread($this->getid3->fread_buffer_size())) === false)) {
|
425 |
+
// get some more data, unless eof, in which case fail
|
426 |
+
return false;
|
427 |
+
}
|
428 |
+
}
|
429 |
+
}
|
430 |
+
$filedataoffset += strlen('OggS') - 1; // page, delimited by 'OggS'
|
431 |
+
|
432 |
+
$oggheader['stream_structver'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
|
433 |
+
$filedataoffset += 1;
|
434 |
+
$oggheader['flags_raw'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
|
435 |
+
$filedataoffset += 1;
|
436 |
+
$oggheader['flags']['fresh'] = (bool) ($oggheader['flags_raw'] & 0x01); // fresh packet
|
437 |
+
$oggheader['flags']['bos'] = (bool) ($oggheader['flags_raw'] & 0x02); // first page of logical bitstream (bos)
|
438 |
+
$oggheader['flags']['eos'] = (bool) ($oggheader['flags_raw'] & 0x04); // last page of logical bitstream (eos)
|
439 |
+
|
440 |
+
$oggheader['pcm_abs_position'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
|
441 |
+
$filedataoffset += 8;
|
442 |
+
$oggheader['stream_serialno'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
443 |
+
$filedataoffset += 4;
|
444 |
+
$oggheader['page_seqno'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
445 |
+
$filedataoffset += 4;
|
446 |
+
$oggheader['page_checksum'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
|
447 |
+
$filedataoffset += 4;
|
448 |
+
$oggheader['page_segments'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
|
449 |
+
$filedataoffset += 1;
|
450 |
+
$oggheader['page_length'] = 0;
|
451 |
+
for ($i = 0; $i < $oggheader['page_segments']; $i++) {
|
452 |
+
$oggheader['segment_table'][$i] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
|
453 |
+
$filedataoffset += 1;
|
454 |
+
$oggheader['page_length'] += $oggheader['segment_table'][$i];
|
455 |
+
}
|
456 |
+
$oggheader['header_end_offset'] = $oggheader['page_start_offset'] + $filedataoffset;
|
457 |
+
$oggheader['page_end_offset'] = $oggheader['header_end_offset'] + $oggheader['page_length'];
|
458 |
+
$this->fseek($oggheader['header_end_offset']);
|
459 |
+
|
460 |
+
return $oggheader;
|
461 |
+
}
|
462 |
+
|
463 |
+
// http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810005
|
464 |
+
public function ParseVorbisComments() {
|
465 |
+
$info = &$this->getid3->info;
|
466 |
+
|
467 |
+
$OriginalOffset = $this->ftell();
|
468 |
+
$commentdataoffset = 0;
|
469 |
+
$VorbisCommentPage = 1;
|
470 |
+
|
471 |
+
switch ($info['audio']['dataformat']) {
|
472 |
+
case 'vorbis':
|
473 |
+
case 'speex':
|
474 |
+
$CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block
|
475 |
+
$this->fseek($CommentStartOffset);
|
476 |
+
$commentdataoffset = 27 + $info['ogg']['pageheader'][$VorbisCommentPage]['page_segments'];
|
477 |
+
$commentdata = $this->fread(self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset);
|
478 |
+
|
479 |
+
if ($info['audio']['dataformat'] == 'vorbis') {
|
480 |
+
$commentdataoffset += (strlen('vorbis') + 1);
|
481 |
+
}
|
482 |
+
break;
|
483 |
+
|
484 |
+
case 'flac':
|
485 |
+
$CommentStartOffset = $info['flac']['VORBIS_COMMENT']['raw']['offset'] + 4;
|
486 |
+
$this->fseek($CommentStartOffset);
|
487 |
+
$commentdata = $this->fread($info['flac']['VORBIS_COMMENT']['raw']['block_length']);
|
488 |
+
break;
|
489 |
+
|
490 |
+
default:
|
491 |
+
return false;
|
492 |
+
}
|
493 |
+
|
494 |
+
$VendorSize = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
|
495 |
+
$commentdataoffset += 4;
|
496 |
+
|
497 |
+
$info['ogg']['vendor'] = substr($commentdata, $commentdataoffset, $VendorSize);
|
498 |
+
$commentdataoffset += $VendorSize;
|
499 |
+
|
500 |
+
$CommentsCount = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
|
501 |
+
$commentdataoffset += 4;
|
502 |
+
$info['avdataoffset'] = $CommentStartOffset + $commentdataoffset;
|
503 |
+
|
504 |
+
$basicfields = array('TITLE', 'ARTIST', 'ALBUM', 'TRACKNUMBER', 'GENRE', 'DATE', 'DESCRIPTION', 'COMMENT');
|
505 |
+
$ThisFileInfo_ogg_comments_raw = &$info['ogg']['comments_raw'];
|
506 |
+
for ($i = 0; $i < $CommentsCount; $i++) {
|
507 |
+
|
508 |
+
$ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] = $CommentStartOffset + $commentdataoffset;
|
509 |
+
|
510 |
+
if ($this->ftell() < ($ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + 4)) {
|
511 |
+
if ($oggpageinfo = $this->ParseOggPageHeader()) {
|
512 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
|
513 |
+
|
514 |
+
$VorbisCommentPage++;
|
515 |
+
|
516 |
+
// First, save what we haven't read yet
|
517 |
+
$AsYetUnusedData = substr($commentdata, $commentdataoffset);
|
518 |
+
|
519 |
+
// Then take that data off the end
|
520 |
+
$commentdata = substr($commentdata, 0, $commentdataoffset);
|
521 |
+
|
522 |
+
// Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct
|
523 |
+
$commentdata .= str_repeat("\x00", 27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
|
524 |
+
$commentdataoffset += (27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
|
525 |
+
|
526 |
+
// Finally, stick the unused data back on the end
|
527 |
+
$commentdata .= $AsYetUnusedData;
|
528 |
+
|
529 |
+
//$commentdata .= $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
|
530 |
+
$commentdata .= $this->fread($this->OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1));
|
531 |
+
}
|
532 |
+
|
533 |
+
}
|
534 |
+
$ThisFileInfo_ogg_comments_raw[$i]['size'] = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
|
535 |
+
|
536 |
+
// replace avdataoffset with position just after the last vorbiscomment
|
537 |
+
$info['avdataoffset'] = $ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + $ThisFileInfo_ogg_comments_raw[$i]['size'] + 4;
|
538 |
+
|
539 |
+
$commentdataoffset += 4;
|
540 |
+
while ((strlen($commentdata) - $commentdataoffset) < $ThisFileInfo_ogg_comments_raw[$i]['size']) {
|
541 |
+
if (($ThisFileInfo_ogg_comments_raw[$i]['size'] > $info['avdataend']) || ($ThisFileInfo_ogg_comments_raw[$i]['size'] < 0)) {
|
542 |
+
$info['warning'][] = 'Invalid Ogg comment size (comment #'.$i.', claims to be '.number_format($ThisFileInfo_ogg_comments_raw[$i]['size']).' bytes) - aborting reading comments';
|
543 |
+
break 2;
|
544 |
+
}
|
545 |
+
|
546 |
+
$VorbisCommentPage++;
|
547 |
+
|
548 |
+
$oggpageinfo = $this->ParseOggPageHeader();
|
549 |
+
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
|
550 |
+
|
551 |
+
// First, save what we haven't read yet
|
552 |
+
$AsYetUnusedData = substr($commentdata, $commentdataoffset);
|
553 |
+
|
554 |
+
// Then take that data off the end
|
555 |
+
$commentdata = substr($commentdata, 0, $commentdataoffset);
|
556 |
+
|
557 |
+
// Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct
|
558 |
+
$commentdata .= str_repeat("\x00", 27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
|
559 |
+
$commentdataoffset += (27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
|
560 |
+
|
561 |
+
// Finally, stick the unused data back on the end
|
562 |
+
$commentdata .= $AsYetUnusedData;
|
563 |
+
|
564 |
+
//$commentdata .= $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
|
565 |
+
if (!isset($info['ogg']['pageheader'][$VorbisCommentPage])) {
|
566 |
+
$info['warning'][] = 'undefined Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.$this->ftell();
|
567 |
+
break;
|
568 |
+
}
|
569 |
+
$readlength = self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1);
|
570 |
+
if ($readlength <= 0) {
|
571 |
+
$info['warning'][] = 'invalid length Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.$this->ftell();
|
572 |
+
break;
|
573 |
+
}
|
574 |
+
$commentdata .= $this->fread($readlength);
|
575 |
+
|
576 |
+
//$filebaseoffset += $oggpageinfo['header_end_offset'] - $oggpageinfo['page_start_offset'];
|
577 |
+
}
|
578 |
+
$ThisFileInfo_ogg_comments_raw[$i]['offset'] = $commentdataoffset;
|
579 |
+
$commentstring = substr($commentdata, $commentdataoffset, $ThisFileInfo_ogg_comments_raw[$i]['size']);
|
580 |
+
$commentdataoffset += $ThisFileInfo_ogg_comments_raw[$i]['size'];
|
581 |
+
|
582 |
+
if (!$commentstring) {
|
583 |
+
|
584 |
+
// no comment?
|
585 |
+
$info['warning'][] = 'Blank Ogg comment ['.$i.']';
|
586 |
+
|
587 |
+
} elseif (strstr($commentstring, '=')) {
|
588 |
+
|
589 |
+
$commentexploded = explode('=', $commentstring, 2);
|
590 |
+
$ThisFileInfo_ogg_comments_raw[$i]['key'] = strtoupper($commentexploded[0]);
|
591 |
+
$ThisFileInfo_ogg_comments_raw[$i]['value'] = (isset($commentexploded[1]) ? $commentexploded[1] : '');
|
592 |
+
|
593 |
+
if ($ThisFileInfo_ogg_comments_raw[$i]['key'] == 'METADATA_BLOCK_PICTURE') {
|
594 |
+
|
595 |
+
// http://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
|
596 |
+
// 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.
|
597 |
+
// http://flac.sourceforge.net/format.html#metadata_block_picture
|
598 |
+
$flac = new getid3_flac($this->getid3);
|
599 |
+
$flac->setStringMode(base64_decode($ThisFileInfo_ogg_comments_raw[$i]['value']));
|
600 |
+
$flac->parsePICTURE();
|
601 |
+
$info['ogg']['comments']['picture'][] = $flac->getid3->info['flac']['PICTURE'][0];
|
602 |
+
unset($flac);
|
603 |
+
|
604 |
+
} elseif ($ThisFileInfo_ogg_comments_raw[$i]['key'] == 'COVERART') {
|
605 |
+
|
606 |
+
$data = base64_decode($ThisFileInfo_ogg_comments_raw[$i]['value']);
|
607 |
+
$this->notice('Found deprecated COVERART tag, it should be replaced in honor of METADATA_BLOCK_PICTURE structure');
|
608 |
+
/** @todo use 'coverartmime' where available */
|
609 |
+
$imageinfo = getid3_lib::GetDataImageSize($data);
|
610 |
+
if ($imageinfo === false || !isset($imageinfo['mime'])) {
|
611 |
+
$this->warning('COVERART vorbiscomment tag contains invalid image');
|
612 |
+
continue;
|
613 |
+
}
|
614 |
+
|
615 |
+
$ogg = new self($this->getid3);
|
616 |
+
$ogg->setStringMode($data);
|
617 |
+
$info['ogg']['comments']['picture'][] = array(
|
618 |
+
'image_mime' => $imageinfo['mime'],
|
619 |
+
'data' => $ogg->saveAttachment('coverart', 0, strlen($data), $imageinfo['mime']),
|
620 |
+
);
|
621 |
+
unset($ogg);
|
622 |
+
|
623 |
+
} else {
|
624 |
+
|
625 |
+
$info['ogg']['comments'][strtolower($ThisFileInfo_ogg_comments_raw[$i]['key'])][] = $ThisFileInfo_ogg_comments_raw[$i]['value'];
|
626 |
+
|
627 |
+
}
|
628 |
+
|
629 |
+
} else {
|
630 |
+
|
631 |
+
$info['warning'][] = '[known problem with CDex >= v1.40, < v1.50b7] Invalid Ogg comment name/value pair ['.$i.']: '.$commentstring;
|
632 |
+
|
633 |
+
}
|
634 |
+
unset($ThisFileInfo_ogg_comments_raw[$i]);
|
635 |
+
}
|
636 |
+
unset($ThisFileInfo_ogg_comments_raw);
|
637 |
+
|
638 |
+
|
639 |
+
// Replay Gain Adjustment
|
640 |
+
// http://privatewww.essex.ac.uk/~djmrob/replaygain/
|
641 |
+
if (isset($info['ogg']['comments']) && is_array($info['ogg']['comments'])) {
|
642 |
+
foreach ($info['ogg']['comments'] as $index => $commentvalue) {
|
643 |
+
switch ($index) {
|
644 |
+
case 'rg_audiophile':
|
645 |
+
case 'replaygain_album_gain':
|
646 |
+
$info['replay_gain']['album']['adjustment'] = (double) $commentvalue[0];
|
647 |
+
unset($info['ogg']['comments'][$index]);
|
648 |
+
break;
|
649 |
+
|
650 |
+
case 'rg_radio':
|
651 |
+
case 'replaygain_track_gain':
|
652 |
+
$info['replay_gain']['track']['adjustment'] = (double) $commentvalue[0];
|
653 |
+
unset($info['ogg']['comments'][$index]);
|
654 |
+
break;
|
655 |
+
|
656 |
+
case 'replaygain_album_peak':
|
657 |
+
$info['replay_gain']['album']['peak'] = (double) $commentvalue[0];
|
658 |
+
unset($info['ogg']['comments'][$index]);
|
659 |
+
break;
|
660 |
+
|
661 |
+
case 'rg_peak':
|
662 |
+
case 'replaygain_track_peak':
|
663 |
+
$info['replay_gain']['track']['peak'] = (double) $commentvalue[0];
|
664 |
+
unset($info['ogg']['comments'][$index]);
|
665 |
+
break;
|
666 |
+
|
667 |
+
case 'replaygain_reference_loudness':
|
668 |
+
$info['replay_gain']['reference_volume'] = (double) $commentvalue[0];
|
669 |
+
unset($info['ogg']['comments'][$index]);
|
670 |
+
break;
|
671 |
+
|
672 |
+
default:
|
673 |
+
// do nothing
|
674 |
+
break;
|
675 |
+
}
|
676 |
+
}
|
677 |
+
}
|
678 |
+
|
679 |
+
$this->fseek($OriginalOffset);
|
680 |
+
|
681 |
+
return true;
|
682 |
+
}
|
683 |
+
|
684 |
+
public static function SpeexBandModeLookup($mode) {
|
685 |
+
static $SpeexBandModeLookup = array();
|
686 |
+
if (empty($SpeexBandModeLookup)) {
|
687 |
+
$SpeexBandModeLookup[0] = 'narrow';
|
688 |
+
$SpeexBandModeLookup[1] = 'wide';
|
689 |
+
$SpeexBandModeLookup[2] = 'ultra-wide';
|
690 |
+
}
|
691 |
+
return (isset($SpeexBandModeLookup[$mode]) ? $SpeexBandModeLookup[$mode] : null);
|
692 |
+
}
|
693 |
+
|
694 |
+
|
695 |
+
public static function OggPageSegmentLength($OggInfoArray, $SegmentNumber=1) {
|
696 |
+
for ($i = 0; $i < $SegmentNumber; $i++) {
|
697 |
+
$segmentlength = 0;
|
698 |
+
foreach ($OggInfoArray['segment_table'] as $key => $value) {
|
699 |
+
$segmentlength += $value;
|
700 |
+
if ($value < 255) {
|
701 |
+
break;
|
702 |
+
}
|
703 |
+
}
|
704 |
+
}
|
705 |
+
return $segmentlength;
|
706 |
+
}
|
707 |
+
|
708 |
+
|
709 |
+
public static function get_quality_from_nominal_bitrate($nominal_bitrate) {
|
710 |
+
|
711 |
+
// decrease precision
|
712 |
+
$nominal_bitrate = $nominal_bitrate / 1000;
|
713 |
+
|
714 |
+
if ($nominal_bitrate < 128) {
|
715 |
+
// q-1 to q4
|
716 |
+
$qval = ($nominal_bitrate - 64) / 16;
|
717 |
+
} elseif ($nominal_bitrate < 256) {
|
718 |
+
// q4 to q8
|
719 |
+
$qval = $nominal_bitrate / 32;
|
720 |
+
} elseif ($nominal_bitrate < 320) {
|
721 |
+
// q8 to q9
|
722 |
+
$qval = ($nominal_bitrate + 256) / 64;
|
723 |
+
} else {
|
724 |
+
// q9 to q10
|
725 |
+
$qval = ($nominal_bitrate + 1300) / 180;
|
726 |
+
}
|
727 |
+
//return $qval; // 5.031324
|
728 |
+
//return intval($qval); // 5
|
729 |
+
return round($qval, 1); // 5 or 4.9
|
730 |
+
}
|
731 |
+
|
732 |
+
public static function TheoraColorSpace($colorspace_id) {
|
733 |
+
// http://www.theora.org/doc/Theora.pdf (table 6.3)
|
734 |
+
static $TheoraColorSpaceLookup = array();
|
735 |
+
if (empty($TheoraColorSpaceLookup)) {
|
736 |
+
$TheoraColorSpaceLookup[0] = 'Undefined';
|
737 |
+
$TheoraColorSpaceLookup[1] = 'Rec. 470M';
|
738 |
+
$TheoraColorSpaceLookup[2] = 'Rec. 470BG';
|
739 |
+
$TheoraColorSpaceLookup[3] = 'Reserved';
|
740 |
+
}
|
741 |
+
return (isset($TheoraColorSpaceLookup[$colorspace_id]) ? $TheoraColorSpaceLookup[$colorspace_id] : null);
|
742 |
+
}
|
743 |
+
|
744 |
+
public static function TheoraPixelFormat($pixelformat_id) {
|
745 |
+
// http://www.theora.org/doc/Theora.pdf (table 6.4)
|
746 |
+
static $TheoraPixelFormatLookup = array();
|
747 |
+
if (empty($TheoraPixelFormatLookup)) {
|
748 |
+
$TheoraPixelFormatLookup[0] = '4:2:0';
|
749 |
+
$TheoraPixelFormatLookup[1] = 'Reserved';
|
750 |
+
$TheoraPixelFormatLookup[2] = '4:2:2';
|
751 |
+
$TheoraPixelFormatLookup[3] = '4:4:4';
|
752 |
+
}
|
753 |
+
return (isset($TheoraPixelFormatLookup[$pixelformat_id]) ? $TheoraPixelFormatLookup[$pixelformat_id] : null);
|
754 |
+
}
|
755 |
+
|
756 |
+
}
|
getid3/module.tag.apetag.php
CHANGED
@@ -1,372 +1,371 @@
|
|
1 |
-
<?php
|
2 |
-
/////////////////////////////////////////////////////////////////
|
3 |
-
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
-
// available at http://getid3.sourceforge.net //
|
5 |
-
// or http://www.getid3.org //
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
//
|
11 |
-
// module
|
12 |
-
//
|
13 |
-
//
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
$
|
31 |
-
$
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
$
|
37 |
-
|
38 |
-
|
39 |
-
if (
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
} elseif (
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
}
|
60 |
-
if (!isset($info['ape']['tag_offset_end'])) {
|
61 |
-
|
62 |
-
// APE tag not found
|
63 |
-
unset($info['ape']);
|
64 |
-
return false;
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
// shortcut
|
69 |
-
$thisfile_ape = &$info['ape'];
|
70 |
-
|
71 |
-
fseek($this->getid3->fp, $thisfile_ape['tag_offset_end'] - $apetagheadersize, SEEK_SET);
|
72 |
-
$APEfooterData = fread($this->getid3->fp, 32);
|
73 |
-
if (!($thisfile_ape['footer'] = $this->parseAPEheaderFooter($APEfooterData))) {
|
74 |
-
$info['error'][] = 'Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end'];
|
75 |
-
return false;
|
76 |
-
}
|
77 |
-
|
78 |
-
if (isset($thisfile_ape['footer']['flags']['header']) && $thisfile_ape['footer']['flags']['header']) {
|
79 |
-
fseek($this->getid3->fp, $thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'] - $apetagheadersize, SEEK_SET);
|
80 |
-
$thisfile_ape['tag_offset_start'] = ftell($this->getid3->fp);
|
81 |
-
$APEtagData = fread($this->getid3->fp, $thisfile_ape['footer']['raw']['tagsize'] + $apetagheadersize);
|
82 |
-
} else {
|
83 |
-
$thisfile_ape['tag_offset_start'] = $thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'];
|
84 |
-
fseek($this->getid3->fp, $thisfile_ape['tag_offset_start'], SEEK_SET);
|
85 |
-
$APEtagData = fread($this->getid3->fp, $thisfile_ape['footer']['raw']['tagsize']);
|
86 |
-
}
|
87 |
-
$info['avdataend'] = $thisfile_ape['tag_offset_start'];
|
88 |
-
|
89 |
-
if (isset($info['id3v1']['tag_offset_start']) && ($info['id3v1']['tag_offset_start'] < $thisfile_ape['tag_offset_end'])) {
|
90 |
-
$info['warning'][] = 'ID3v1 tag information ignored since it appears to be a false synch in APEtag data';
|
91 |
-
unset($info['id3v1']);
|
92 |
-
foreach ($info['warning'] as $key => $value) {
|
93 |
-
if ($value == 'Some ID3v1 fields do not use NULL characters for padding') {
|
94 |
-
unset($info['warning'][$key]);
|
95 |
-
sort($info['warning']);
|
96 |
-
break;
|
97 |
-
}
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
$offset = 0;
|
102 |
-
if (isset($thisfile_ape['footer']['flags']['header']) && $thisfile_ape['footer']['flags']['header']) {
|
103 |
-
if ($thisfile_ape['header'] = $this->parseAPEheaderFooter(substr($APEtagData, 0, $apetagheadersize))) {
|
104 |
-
$offset += $apetagheadersize;
|
105 |
-
} else {
|
106 |
-
$info['error'][] = 'Error parsing APE header at offset '.$thisfile_ape['tag_offset_start'];
|
107 |
-
return false;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
// shortcut
|
112 |
-
$info['replay_gain'] = array();
|
113 |
-
$thisfile_replaygain = &$info['replay_gain'];
|
114 |
-
|
115 |
-
for ($i = 0; $i < $thisfile_ape['footer']['raw']['tag_items']; $i++) {
|
116 |
-
$value_size = getid3_lib::LittleEndian2Int(substr($APEtagData, $offset, 4));
|
117 |
-
$offset += 4;
|
118 |
-
$item_flags = getid3_lib::LittleEndian2Int(substr($APEtagData, $offset, 4));
|
119 |
-
$offset += 4;
|
120 |
-
if (strstr(substr($APEtagData, $offset), "\x00") === false) {
|
121 |
-
$info['error'][] = 'Cannot find null-byte (0x00) seperator between ItemKey #'.$i.' and value. ItemKey starts '.$offset.' bytes into the APE tag, at file offset '.($thisfile_ape['tag_offset_start'] + $offset);
|
122 |
-
return false;
|
123 |
-
}
|
124 |
-
$ItemKeyLength = strpos($APEtagData, "\x00", $offset) - $offset;
|
125 |
-
$item_key = strtolower(substr($APEtagData, $offset, $ItemKeyLength));
|
126 |
-
|
127 |
-
// shortcut
|
128 |
-
$thisfile_ape['items'][$item_key] = array();
|
129 |
-
$thisfile_ape_items_current = &$thisfile_ape['items'][$item_key];
|
130 |
-
|
131 |
-
$thisfile_ape_items_current['offset'] = $thisfile_ape['tag_offset_start'] + $offset;
|
132 |
-
|
133 |
-
$offset += ($ItemKeyLength + 1); // skip 0x00 terminator
|
134 |
-
$thisfile_ape_items_current['data'] = substr($APEtagData, $offset, $value_size);
|
135 |
-
$offset += $value_size;
|
136 |
-
|
137 |
-
$thisfile_ape_items_current['flags'] = $this->parseAPEtagFlags($item_flags);
|
138 |
-
switch ($thisfile_ape_items_current['flags']['item_contents_raw']) {
|
139 |
-
case 0: // UTF-8
|
140 |
-
case 3: // Locator (URL, filename, etc), UTF-8 encoded
|
141 |
-
$thisfile_ape_items_current['data'] = explode("\x00", trim($thisfile_ape_items_current['data']));
|
142 |
-
break;
|
143 |
-
|
144 |
-
default: // binary data
|
145 |
-
break;
|
146 |
-
}
|
147 |
-
|
148 |
-
switch (strtolower($item_key)) {
|
149 |
-
case 'replaygain_track_gain':
|
150 |
-
$thisfile_replaygain['track']['adjustment'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero!
|
151 |
-
$thisfile_replaygain['track']['originator'] = 'unspecified';
|
152 |
-
break;
|
153 |
-
|
154 |
-
case 'replaygain_track_peak':
|
155 |
-
$thisfile_replaygain['track']['peak'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero!
|
156 |
-
$thisfile_replaygain['track']['originator'] = 'unspecified';
|
157 |
-
if ($thisfile_replaygain['track']['peak'] <= 0) {
|
158 |
-
$info['warning'][] = 'ReplayGain Track peak from APEtag appears invalid: '.$thisfile_replaygain['track']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")';
|
159 |
-
}
|
160 |
-
break;
|
161 |
-
|
162 |
-
case 'replaygain_album_gain':
|
163 |
-
$thisfile_replaygain['album']['adjustment'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero!
|
164 |
-
$thisfile_replaygain['album']['originator'] = 'unspecified';
|
165 |
-
break;
|
166 |
-
|
167 |
-
case 'replaygain_album_peak':
|
168 |
-
$thisfile_replaygain['album']['peak'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero!
|
169 |
-
$thisfile_replaygain['album']['originator'] = 'unspecified';
|
170 |
-
if ($thisfile_replaygain['album']['peak'] <= 0) {
|
171 |
-
$info['warning'][] = 'ReplayGain Album peak from APEtag appears invalid: '.$thisfile_replaygain['album']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")';
|
172 |
-
}
|
173 |
-
break;
|
174 |
-
|
175 |
-
case 'mp3gain_undo':
|
176 |
-
list($mp3gain_undo_left, $mp3gain_undo_right, $mp3gain_undo_wrap) = explode(',', $thisfile_ape_items_current['data'][0]);
|
177 |
-
$thisfile_replaygain['mp3gain']['undo_left'] = intval($mp3gain_undo_left);
|
178 |
-
$thisfile_replaygain['mp3gain']['undo_right'] = intval($mp3gain_undo_right);
|
179 |
-
$thisfile_replaygain['mp3gain']['undo_wrap'] = (($mp3gain_undo_wrap == 'Y') ? true : false);
|
180 |
-
break;
|
181 |
-
|
182 |
-
case 'mp3gain_minmax':
|
183 |
-
list($mp3gain_globalgain_min, $mp3gain_globalgain_max) = explode(',', $thisfile_ape_items_current['data'][0]);
|
184 |
-
$thisfile_replaygain['mp3gain']['globalgain_track_min'] = intval($mp3gain_globalgain_min);
|
185 |
-
$thisfile_replaygain['mp3gain']['globalgain_track_max'] = intval($mp3gain_globalgain_max);
|
186 |
-
break;
|
187 |
-
|
188 |
-
case 'mp3gain_album_minmax':
|
189 |
-
list($mp3gain_globalgain_album_min, $mp3gain_globalgain_album_max) = explode(',', $thisfile_ape_items_current['data'][0]);
|
190 |
-
$thisfile_replaygain['mp3gain']['globalgain_album_min'] = intval($mp3gain_globalgain_album_min);
|
191 |
-
$thisfile_replaygain['mp3gain']['globalgain_album_max'] = intval($mp3gain_globalgain_album_max);
|
192 |
-
break;
|
193 |
-
|
194 |
-
case 'tracknumber':
|
195 |
-
if (is_array($thisfile_ape_items_current['data'])) {
|
196 |
-
foreach ($thisfile_ape_items_current['data'] as $comment) {
|
197 |
-
$thisfile_ape['comments']['track'][] = $comment;
|
198 |
-
}
|
199 |
-
}
|
200 |
-
break;
|
201 |
-
|
202 |
-
case 'cover art (artist)':
|
203 |
-
case 'cover art (back)':
|
204 |
-
case 'cover art (band logo)':
|
205 |
-
case 'cover art (band)':
|
206 |
-
case 'cover art (colored fish)':
|
207 |
-
case 'cover art (composer)':
|
208 |
-
case 'cover art (conductor)':
|
209 |
-
case 'cover art (front)':
|
210 |
-
case 'cover art (icon)':
|
211 |
-
case 'cover art (illustration)':
|
212 |
-
case 'cover art (lead)':
|
213 |
-
case 'cover art (leaflet)':
|
214 |
-
case 'cover art (lyricist)':
|
215 |
-
case 'cover art (media)':
|
216 |
-
case 'cover art (movie scene)':
|
217 |
-
case 'cover art (other icon)':
|
218 |
-
case 'cover art (other)':
|
219 |
-
case 'cover art (performance)':
|
220 |
-
case 'cover art (publisher logo)':
|
221 |
-
case 'cover art (recording)':
|
222 |
-
case 'cover art (studio)':
|
223 |
-
// list of possible cover arts from http://taglib-sharp.sourcearchive.com/documentation/2.0.3.0-2/Ape_2Tag_8cs-source.html
|
224 |
-
list($thisfile_ape_items_current['filename'], $thisfile_ape_items_current['data']) = explode("\x00", $thisfile_ape_items_current['data'], 2);
|
225 |
-
$thisfile_ape_items_current['data_offset'] = $thisfile_ape_items_current['offset'] + strlen($thisfile_ape_items_current['filename']."\x00");
|
226 |
-
$thisfile_ape_items_current['data_length'] = strlen($thisfile_ape_items_current['data']);
|
227 |
-
|
228 |
-
$thisfile_ape_items_current['image_mime'] = '';
|
229 |
-
$imageinfo = array();
|
230 |
-
$imagechunkcheck = getid3_lib::GetDataImageSize($thisfile_ape_items_current['data'], $imageinfo);
|
231 |
-
$thisfile_ape_items_current['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
|
232 |
-
|
233 |
-
do {
|
234 |
-
if ($this->inline_attachments === false) {
|
235 |
-
// skip entirely
|
236 |
-
unset($thisfile_ape_items_current['data']);
|
237 |
-
break;
|
238 |
-
}
|
239 |
-
if ($this->inline_attachments === true) {
|
240 |
-
// great
|
241 |
-
} elseif (is_int($this->inline_attachments)) {
|
242 |
-
if ($this->inline_attachments < $thisfile_ape_items_current['data_length']) {
|
243 |
-
// too big, skip
|
244 |
-
$info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' is too large to process inline ('.number_format($thisfile_ape_items_current['data_length']).' bytes)';
|
245 |
-
unset($thisfile_ape_items_current['data']);
|
246 |
-
break;
|
247 |
-
}
|
248 |
-
} elseif (is_string($this->inline_attachments)) {
|
249 |
-
$this->inline_attachments = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->inline_attachments), DIRECTORY_SEPARATOR);
|
250 |
-
if (!is_dir($this->inline_attachments) || !is_writable($this->inline_attachments)) {
|
251 |
-
// cannot write, skip
|
252 |
-
$info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$this->inline_attachments.'" (not writable)';
|
253 |
-
unset($thisfile_ape_items_current['data']);
|
254 |
-
break;
|
255 |
-
}
|
256 |
-
}
|
257 |
-
// if we get this far, must be OK
|
258 |
-
if (is_string($this->inline_attachments)) {
|
259 |
-
$destination_filename = $this->inline_attachments.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$thisfile_ape_items_current['data_offset'];
|
260 |
-
if (!file_exists($destination_filename) || is_writable($destination_filename)) {
|
261 |
-
file_put_contents($destination_filename, $thisfile_ape_items_current['data']);
|
262 |
-
} else {
|
263 |
-
$info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$destination_filename.'" (not writable)';
|
264 |
-
}
|
265 |
-
$thisfile_ape_items_current['data_filename'] = $destination_filename;
|
266 |
-
unset($thisfile_ape_items_current['data']);
|
267 |
-
} else {
|
268 |
-
if (!isset($info['ape']['comments']['picture'])) {
|
269 |
-
$info['ape']['comments']['picture'] = array();
|
270 |
-
}
|
271 |
-
$info['ape']['comments']['picture'][] = array('data'=>$thisfile_ape_items_current['data'], 'image_mime'=>$thisfile_ape_items_current['image_mime']);
|
272 |
-
}
|
273 |
-
} while (false);
|
274 |
-
break;
|
275 |
-
|
276 |
-
default:
|
277 |
-
if (is_array($thisfile_ape_items_current['data'])) {
|
278 |
-
foreach ($thisfile_ape_items_current['data'] as $comment) {
|
279 |
-
$thisfile_ape['comments'][strtolower($item_key)][] = $comment;
|
280 |
-
}
|
281 |
-
}
|
282 |
-
break;
|
283 |
-
}
|
284 |
-
|
285 |
-
}
|
286 |
-
if (empty($thisfile_replaygain)) {
|
287 |
-
unset($info['replay_gain']);
|
288 |
-
}
|
289 |
-
return true;
|
290 |
-
}
|
291 |
-
|
292 |
-
function parseAPEheaderFooter($APEheaderFooterData) {
|
293 |
-
// http://www.uni-jena.de/~pfk/mpp/sv8/apeheader.html
|
294 |
-
|
295 |
-
// shortcut
|
296 |
-
$headerfooterinfo['raw'] = array();
|
297 |
-
$headerfooterinfo_raw = &$headerfooterinfo['raw'];
|
298 |
-
|
299 |
-
$headerfooterinfo_raw['footer_tag'] = substr($APEheaderFooterData, 0, 8);
|
300 |
-
if ($headerfooterinfo_raw['footer_tag'] != 'APETAGEX') {
|
301 |
-
return false;
|
302 |
-
}
|
303 |
-
$headerfooterinfo_raw['version'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 8, 4));
|
304 |
-
$headerfooterinfo_raw['tagsize'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 12, 4));
|
305 |
-
$headerfooterinfo_raw['tag_items'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 16, 4));
|
306 |
-
$headerfooterinfo_raw['global_flags'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 20, 4));
|
307 |
-
$headerfooterinfo_raw['reserved'] = substr($APEheaderFooterData, 24, 8);
|
308 |
-
|
309 |
-
$headerfooterinfo['tag_version'] = $headerfooterinfo_raw['version'] / 1000;
|
310 |
-
if ($headerfooterinfo['tag_version'] >= 2) {
|
311 |
-
$headerfooterinfo['flags'] = $this->parseAPEtagFlags($headerfooterinfo_raw['global_flags']);
|
312 |
-
}
|
313 |
-
return $headerfooterinfo;
|
314 |
-
}
|
315 |
-
|
316 |
-
function parseAPEtagFlags($rawflagint) {
|
317 |
-
// "Note: APE Tags 1.0 do not use any of the APE Tag flags.
|
318 |
-
// All are set to zero on creation and ignored on reading."
|
319 |
-
// http://www.uni-jena.de/~pfk/mpp/sv8/apetagflags.html
|
320 |
-
$flags['header'] = (bool) ($rawflagint & 0x80000000);
|
321 |
-
$flags['footer'] = (bool) ($rawflagint & 0x40000000);
|
322 |
-
$flags['this_is_header'] = (bool) ($rawflagint & 0x20000000);
|
323 |
-
$flags['item_contents_raw'] = ($rawflagint & 0x00000006) >> 1;
|
324 |
-
$flags['read_only'] = (bool) ($rawflagint & 0x00000001);
|
325 |
-
|
326 |
-
$flags['item_contents'] = $this->APEcontentTypeFlagLookup($flags['item_contents_raw']);
|
327 |
-
|
328 |
-
return $flags;
|
329 |
-
}
|
330 |
-
|
331 |
-
function APEcontentTypeFlagLookup($contenttypeid) {
|
332 |
-
static $APEcontentTypeFlagLookup = array(
|
333 |
-
0 => 'utf-8',
|
334 |
-
1 => 'binary',
|
335 |
-
2 => 'external',
|
336 |
-
3 => 'reserved'
|
337 |
-
);
|
338 |
-
return (isset($APEcontentTypeFlagLookup[$contenttypeid]) ? $APEcontentTypeFlagLookup[$contenttypeid] : 'invalid');
|
339 |
-
}
|
340 |
-
|
341 |
-
function APEtagItemIsUTF8Lookup($itemkey) {
|
342 |
-
static $APEtagItemIsUTF8Lookup = array(
|
343 |
-
'title',
|
344 |
-
'subtitle',
|
345 |
-
'artist',
|
346 |
-
'album',
|
347 |
-
'debut album',
|
348 |
-
'publisher',
|
349 |
-
'conductor',
|
350 |
-
'track',
|
351 |
-
'composer',
|
352 |
-
'comment',
|
353 |
-
'copyright',
|
354 |
-
'publicationright',
|
355 |
-
'file',
|
356 |
-
'year',
|
357 |
-
'record date',
|
358 |
-
'record location',
|
359 |
-
'genre',
|
360 |
-
'media',
|
361 |
-
'related',
|
362 |
-
'isrc',
|
363 |
-
'abstract',
|
364 |
-
'language',
|
365 |
-
'bibliography'
|
366 |
-
);
|
367 |
-
return in_array(strtolower($itemkey), $APEtagItemIsUTF8Lookup);
|
368 |
-
}
|
369 |
-
|
370 |
-
}
|
371 |
-
|
372 |
-
?>
|
1 |
+
<?php
|
2 |
+
/////////////////////////////////////////////////////////////////
|
3 |
+
/// getID3() by James Heinrich <info@getid3.org> //
|
4 |
+
// available at http://getid3.sourceforge.net //
|
5 |
+
// or http://www.getid3.org //
|
6 |
+
// also https://github.com/JamesHeinrich/getID3 //
|
7 |
+
/////////////////////////////////////////////////////////////////
|
8 |
+
// See readme.txt for more details //
|
9 |
+
/////////////////////////////////////////////////////////////////
|
10 |
+
// //
|
11 |
+
// module.tag.apetag.php //
|
12 |
+
// module for analyzing APE tags //
|
13 |
+
// dependencies: NONE //
|
14 |
+
// ///
|
15 |
+
/////////////////////////////////////////////////////////////////
|
16 |
+
|
17 |
+
class getid3_apetag extends getid3_handler
|
18 |
+
{
|
19 |
+
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
|
20 |
+
public $overrideendoffset = 0;
|
21 |
+
|
22 |
+
public function Analyze() {
|
23 |
+
$info = &$this->getid3->info;
|
24 |
+
|
25 |
+
if (!getid3_lib::intValueSupported($info['filesize'])) {
|
26 |
+
$info['warning'][] = 'Unable to check for APEtags because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
|
30 |
+
$id3v1tagsize = 128;
|
31 |
+
$apetagheadersize = 32;
|
32 |
+
$lyrics3tagsize = 10;
|
33 |
+
|
34 |
+
if ($this->overrideendoffset == 0) {
|
35 |
+
|
36 |
+
$this->fseek(0 - $id3v1tagsize - $apetagheadersize - $lyrics3tagsize, SEEK_END);
|
37 |
+
$APEfooterID3v1 = $this->fread($id3v1tagsize + $apetagheadersize + $lyrics3tagsize);
|
38 |
+
|
39 |
+
//if (preg_match('/APETAGEX.{24}TAG.{125}$/i', $APEfooterID3v1)) {
|
40 |
+
if (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $id3v1tagsize - $apetagheadersize, 8) == 'APETAGEX') {
|
41 |
+
|
42 |
+
// APE tag found before ID3v1
|
43 |
+
$info['ape']['tag_offset_end'] = $info['filesize'] - $id3v1tagsize;
|
44 |
+
|
45 |
+
//} elseif (preg_match('/APETAGEX.{24}$/i', $APEfooterID3v1)) {
|
46 |
+
} elseif (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $apetagheadersize, 8) == 'APETAGEX') {
|
47 |
+
|
48 |
+
// APE tag found, no ID3v1
|
49 |
+
$info['ape']['tag_offset_end'] = $info['filesize'];
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
} else {
|
54 |
+
|
55 |
+
$this->fseek($this->overrideendoffset - $apetagheadersize);
|
56 |
+
if ($this->fread(8) == 'APETAGEX') {
|
57 |
+
$info['ape']['tag_offset_en
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|