Total Complexity | 408 |
Total Lines | 3163 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like getid3_id3v2 often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use getid3_id3v2, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
26 | class getid3_id3v2 extends getid3_handler |
||
27 | { |
||
28 | |||
29 | public $option_starting_offset = 0; |
||
30 | |||
31 | public function Analyze() |
||
32 | { |
||
33 | $getid3 = $this->getid3; |
||
34 | |||
35 | // dependency |
||
36 | $getid3->include_module('tag.id3v1'); |
||
37 | |||
38 | if ($getid3->option_tags_images) { |
||
39 | $getid3->include_module('lib.image_size'); |
||
40 | } |
||
41 | |||
42 | // Overall tag structure: |
||
43 | // +-----------------------------+ |
||
44 | // | Header (10 bytes) | |
||
45 | // +-----------------------------+ |
||
46 | // | Extended Header | |
||
47 | // | (variable length, OPTIONAL) | |
||
48 | // +-----------------------------+ |
||
49 | // | Frames (variable length) | |
||
50 | // +-----------------------------+ |
||
51 | // | Padding | |
||
52 | // | (variable length, OPTIONAL) | |
||
53 | // +-----------------------------+ |
||
54 | // | Footer (10 bytes, OPTIONAL) | |
||
55 | // +-----------------------------+ |
||
56 | // |
||
57 | // Header |
||
58 | // ID3v2/file identifier "ID3" |
||
59 | // ID3v2 version $04 00 |
||
60 | // ID3v2 flags (%ab000000 in v2.2, %abc00000 in v2.3, %abcd0000 in v2.4.x) |
||
61 | // ID3v2 size 4 * %0xxxxxxx |
||
62 | |||
63 | // shortcuts |
||
64 | $getid3->info['id3v2']['header'] = true; |
||
65 | $info_id3v2 = &$getid3->info['id3v2']; |
||
66 | $info_id3v2['flags'] = []; |
||
67 | $info_id3v2_flags = &$info_id3v2['flags']; |
||
68 | |||
69 | $this->fseek($this->option_starting_offset, SEEK_SET); |
||
70 | $header = $this->fread(10); |
||
71 | if ('ID3' == substr($header, 0, 3) && 10 == strlen($header)) { |
||
72 | $info_id3v2['majorversion'] = ord($header{3}); |
||
73 | $info_id3v2['minorversion'] = ord($header{4}); |
||
74 | |||
75 | // shortcut |
||
76 | $id3v2_major_version = &$info_id3v2['majorversion']; |
||
77 | } else { |
||
78 | unset($getid3->info['id3v2']); |
||
79 | return false; |
||
80 | } |
||
81 | |||
82 | if ($id3v2_major_version > 4) { // this script probably won't correctly parse ID3v2.5.x and above (if it ever exists) |
||
83 | throw new getid3_exception('this script only parses up to ID3v2.4.x - this tag is ID3v2.' . $id3v2_major_version . '.' . $info_id3v2['minorversion']); |
||
84 | } |
||
85 | |||
86 | $id3_flags = ord($header{5}); |
||
87 | switch ($id3v2_major_version) { |
||
88 | case 2: |
||
89 | // %ab000000 in v2.2 |
||
90 | $info_id3v2_flags['unsynch'] = (bool)($id3_flags & 0x80); // a - Unsynchronisation |
||
91 | $info_id3v2_flags['compression'] = (bool)($id3_flags & 0x40); // b - Compression |
||
92 | break; |
||
93 | |||
94 | case 3: |
||
95 | // %abc00000 in v2.3 |
||
96 | $info_id3v2_flags['unsynch'] = (bool)($id3_flags & 0x80); // a - Unsynchronisation |
||
97 | $info_id3v2_flags['exthead'] = (bool)($id3_flags & 0x40); // b - Extended header |
||
98 | $info_id3v2_flags['experim'] = (bool)($id3_flags & 0x20); // c - Experimental indicator |
||
99 | break; |
||
100 | |||
101 | case 4: |
||
102 | // %abcd0000 in v2.4 |
||
103 | $info_id3v2_flags['unsynch'] = (bool)($id3_flags & 0x80); // a - Unsynchronisation |
||
104 | $info_id3v2_flags['exthead'] = (bool)($id3_flags & 0x40); // b - Extended header |
||
105 | $info_id3v2_flags['experim'] = (bool)($id3_flags & 0x20); // c - Experimental indicator |
||
106 | $info_id3v2_flags['isfooter'] = (bool)($id3_flags & 0x10); // d - Footer present |
||
107 | break; |
||
108 | } |
||
109 | |||
110 | $info_id3v2['headerlength'] = getid3_lib::BigEndianSyncSafe2Int(substr($header, 6, 4)) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length |
||
111 | |||
112 | $info_id3v2['tag_offset_start'] = $this->option_starting_offset; |
||
113 | $info_id3v2['tag_offset_end'] = $info_id3v2['tag_offset_start'] + $info_id3v2['headerlength']; |
||
114 | |||
115 | // Frames |
||
116 | |||
117 | // All ID3v2 frames consists of one frame header followed by one or more |
||
118 | // fields containing the actual information. The header is always 10 |
||
119 | // bytes and laid out as follows: |
||
120 | // |
||
121 | // Frame ID $xx xx xx xx (four characters) |
||
122 | // Size 4 * %0xxxxxxx |
||
123 | // Flags $xx xx |
||
124 | |||
125 | $size_of_frames = $info_id3v2['headerlength'] - 10; // not including 10-byte initial header |
||
126 | if (@$info_id3v2['exthead']['length']) { |
||
127 | $size_of_frames -= ($info_id3v2['exthead']['length'] + 4); |
||
128 | } |
||
129 | |||
130 | if (@$info_id3v2_flags['isfooter']) { |
||
131 | $size_of_frames -= 10; // footer takes last 10 bytes of ID3v2 header, after frame data, before audio |
||
132 | } |
||
133 | |||
134 | if ($size_of_frames > 0) { |
||
135 | $frame_data = $this->fread($size_of_frames); // read all frames from file into $frame_data variable |
||
136 | |||
137 | // if entire frame data is unsynched, de-unsynch it now (ID3v2.3.x) |
||
138 | if (@$info_id3v2_flags['unsynch'] && ($id3v2_major_version <= 3)) { |
||
139 | $frame_data = str_replace("\xFF\x00", "\xFF", $frame_data); |
||
140 | } |
||
141 | |||
142 | // [in ID3v2.4.0] Unsynchronisation [S:6.1] is done on frame level, instead |
||
143 | // of on tag level, making it easier to skip frames, increasing the streamability |
||
144 | // of the tag. The unsynchronisation flag in the header [S:3.1] indicates that |
||
145 | // there exists an unsynchronised frame, while the new unsynchronisation flag in |
||
146 | // the frame header [S:4.1.2] indicates unsynchronisation. |
||
147 | |||
148 | //$frame_data_offset = 10 + (@$info_id3v2['exthead']['length'] ? $info_id3v2['exthead']['length'] + 4 : 0); // how many bytes into the stream - start from after the 10-byte header (and extended header length+4, if present) |
||
149 | $frame_data_offset = 10; // how many bytes into the stream - start from after the 10-byte header |
||
150 | |||
151 | // Extended Header |
||
152 | if (@$info_id3v2_flags['exthead']) { |
||
153 | $extended_header_offset = 0; |
||
154 | |||
155 | if (3 == $id3v2_major_version) { |
||
156 | // v2.3 definition: |
||
157 | //Extended header size $xx xx xx xx // 32-bit integer |
||
158 | //Extended Flags $xx xx |
||
159 | // %x0000000 %00000000 // v2.3 |
||
160 | // x - CRC data present |
||
161 | //Size of padding $xx xx xx xx |
||
162 | |||
163 | $info_id3v2['exthead']['length'] = getid3_lib::BigEndian2Int(substr($frame_data, $extended_header_offset, 4), 0); |
||
164 | $extended_header_offset += 4; |
||
165 | |||
166 | $info_id3v2['exthead']['flag_bytes'] = 2; |
||
167 | $info_id3v2['exthead']['flag_raw'] = getid3_lib::BigEndian2Int(substr($frame_data, $extended_header_offset, $info_id3v2['exthead']['flag_bytes'])); |
||
168 | $extended_header_offset += $info_id3v2['exthead']['flag_bytes']; |
||
169 | |||
170 | $info_id3v2['exthead']['flags']['crc'] = (bool)($info_id3v2['exthead']['flag_raw'] & 0x8000); |
||
171 | |||
172 | $info_id3v2['exthead']['padding_size'] = getid3_lib::BigEndian2Int(substr($frame_data, $extended_header_offset, 4)); |
||
173 | $extended_header_offset += 4; |
||
174 | |||
175 | if ($info_id3v2['exthead']['flags']['crc']) { |
||
176 | $info_id3v2['exthead']['flag_data']['crc'] = getid3_lib::BigEndian2Int(substr($frame_data, $extended_header_offset, 4)); |
||
177 | $extended_header_offset += 4; |
||
178 | } |
||
179 | $extended_header_offset += $info_id3v2['exthead']['padding_size']; |
||
180 | } elseif (4 == $id3v2_major_version) { |
||
181 | // v2.4 definition: |
||
182 | //Extended header size 4 * %0xxxxxxx // 28-bit synchsafe integer |
||
183 | //Number of flag bytes $01 |
||
184 | //Extended Flags $xx |
||
185 | // %0bcd0000 // v2.4 |
||
186 | // b - Tag is an update |
||
187 | // Flag data length $00 |
||
188 | // c - CRC data present |
||
189 | // Flag data length $05 |
||
190 | // Total frame CRC 5 * %0xxxxxxx |
||
191 | // d - Tag restrictions |
||
192 | // Flag data length $01 |
||
193 | |||
194 | $info_id3v2['exthead']['length'] = getid3_lib::BigEndian2Int(substr($frame_data, $extended_header_offset, 4), 1); |
||
195 | $extended_header_offset += 4; |
||
196 | |||
197 | $info_id3v2['exthead']['flag_bytes'] = 1; |
||
198 | $info_id3v2['exthead']['flag_raw'] = getid3_lib::BigEndian2Int(substr($frame_data, $extended_header_offset, $info_id3v2['exthead']['flag_bytes'])); |
||
199 | $extended_header_offset += $info_id3v2['exthead']['flag_bytes']; |
||
200 | |||
201 | $info_id3v2['exthead']['flags']['update'] = (bool)($info_id3v2['exthead']['flag_raw'] & 0x4000); |
||
202 | $info_id3v2['exthead']['flags']['crc'] = (bool)($info_id3v2['exthead']['flag_raw'] & 0x2000); |
||
203 | $info_id3v2['exthead']['flags']['restrictions'] = (bool)($info_id3v2['exthead']['flag_raw'] & 0x1000); |
||
204 | |||
205 | if ($info_id3v2['exthead']['flags']['crc']) { |
||
206 | $info_id3v2['exthead']['flag_data']['crc'] = getid3_lib::BigEndian2Int(substr($frame_data, $extended_header_offset, 5), 1); |
||
207 | $extended_header_offset += 5; |
||
208 | } |
||
209 | if ($info_id3v2['exthead']['flags']['restrictions']) { |
||
210 | // %ppqrrstt |
||
211 | $restrictions_raw = getid3_lib::BigEndian2Int(substr($frame_data, $extended_header_offset, 1)); |
||
212 | $extended_header_offset += 1; |
||
213 | $info_id3v2['exthead']['flags']['restrictions']['tagsize'] = ($restrictions_raw && 0xC0) >> 6; // p - Tag size restrictions |
||
214 | $info_id3v2['exthead']['flags']['restrictions']['textenc'] = ($restrictions_raw && 0x20) >> 5; // q - Text encoding restrictions |
||
215 | $info_id3v2['exthead']['flags']['restrictions']['textsize'] = ($restrictions_raw && 0x18) >> 3; // r - Text fields size restrictions |
||
216 | $info_id3v2['exthead']['flags']['restrictions']['imgenc'] = ($restrictions_raw && 0x04) >> 2; // s - Image encoding restrictions |
||
217 | $info_id3v2['exthead']['flags']['restrictions']['imgsize'] = ($restrictions_raw && 0x03) >> 0; // t - Image size restrictions |
||
218 | } |
||
219 | } |
||
220 | $frame_data_offset += $extended_header_offset; |
||
221 | $frame_data = substr($frame_data, $extended_header_offset); |
||
222 | } // end extended header |
||
223 | |||
224 | while (isset($frame_data) && (strlen($frame_data) > 0)) { // cycle through until no more frame data is left to parse |
||
225 | if (strlen($frame_data) <= (2 == $id3v2_major_version ? 6 : 10)) { |
||
226 | // insufficient room left in ID3v2 header for actual data - must be padding |
||
227 | $info_id3v2['padding']['start'] = $frame_data_offset; |
||
228 | $info_id3v2['padding']['length'] = strlen($frame_data); |
||
229 | $info_id3v2['padding']['valid'] = true; |
||
230 | for ($i = 0; $i < $info_id3v2['padding']['length']; $i++) { |
||
231 | if ("\x00" != $frame_data{$i}) { |
||
232 | $info_id3v2['padding']['valid'] = false; |
||
233 | $info_id3v2['padding']['errorpos'] = $info_id3v2['padding']['start'] + $i; |
||
234 | $getid3->warning('Invalid ID3v2 padding found at offset ' . $info_id3v2['padding']['errorpos'] . ' (the remaining ' . ($info_id3v2['padding']['length'] - $i) . ' bytes are considered invalid)'); |
||
235 | break; |
||
236 | } |
||
237 | } |
||
238 | break; // skip rest of ID3v2 header |
||
239 | } |
||
240 | |||
241 | if (2 == $id3v2_major_version) { |
||
242 | // Frame ID $xx xx xx (three characters) |
||
243 | // Size $xx xx xx (24-bit integer) |
||
244 | // Flags $xx xx |
||
245 | |||
246 | $frame_header = substr($frame_data, 0, 6); // take next 6 bytes for header |
||
247 | $frame_data = substr($frame_data, 6); // and leave the rest in $frame_data |
||
248 | $frame_name = substr($frame_header, 0, 3); |
||
249 | $frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 3, 3)); |
||
250 | $frame_flags = 0; // not used for anything in ID3v2.2, just set to avoid E_NOTICEs |
||
251 | |||
252 | } elseif ($id3v2_major_version > 2) { |
||
253 | // Frame ID $xx xx xx xx (four characters) |
||
254 | // Size $xx xx xx xx (32-bit integer in v2.3, 28-bit synchsafe in v2.4+) |
||
255 | // Flags $xx xx |
||
256 | |||
257 | $frame_header = substr($frame_data, 0, 10); // take next 10 bytes for header |
||
258 | $frame_data = substr($frame_data, 10); // and leave the rest in $frame_data |
||
259 | |||
260 | $frame_name = substr($frame_header, 0, 4); |
||
261 | |||
262 | if (3 == $id3v2_major_version) { |
||
263 | $frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 4, 4)); // 32-bit integer |
||
264 | |||
265 | } else { // ID3v2.4+ |
||
266 | $frame_size = getid3_lib::BigEndianSyncSafe2Int(substr($frame_header, 4, 4)); // 32-bit synchsafe integer (28-bit value) |
||
267 | } |
||
268 | |||
269 | if ($frame_size < (strlen($frame_data) + 4)) { |
||
270 | $nextFrameID = substr($frame_data, $frame_size, 4); |
||
271 | if (getid3_id3v2::IsValidID3v2FrameName($nextFrameID, $id3v2_major_version)) { |
||
|
|||
272 | // next frame is OK |
||
273 | } elseif (($frame_name == "\x00" . 'MP3') || ($frame_name == "\x00\x00" . 'MP') || (' MP3' == $frame_name) || ('MP3e' == $frame_name)) { |
||
274 | // MP3ext known broken frames - "ok" for the purposes of this test |
||
275 | } elseif ((4 == $id3v2_major_version) && (getid3_id3v2::IsValidID3v2FrameName(substr($frame_data, getid3_lib::BigEndian2Int(substr($frame_header, 4, 4)), 4), 3))) { |
||
276 | $getid3->warning('ID3v2 tag written as ID3v2.4, but with non-synchsafe integers (ID3v2.3 style). Older versions of (Helium2; iTunes) are known culprits of this. Tag has been parsed as ID3v2.3'); |
||
277 | $id3v2_major_version = 3; |
||
278 | $frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 4, 4)); // 32-bit integer |
||
279 | } |
||
280 | } |
||
281 | |||
282 | $frame_flags = getid3_lib::BigEndian2Int(substr($frame_header, 8, 2)); |
||
283 | } |
||
284 | |||
285 | if (((2 == $id3v2_major_version) && ("\x00\x00\x00" == $frame_name)) || ("\x00\x00\x00\x00" == $frame_name)) { |
||
286 | // padding encountered |
||
287 | |||
288 | $info_id3v2['padding']['start'] = $frame_data_offset; |
||
289 | $info_id3v2['padding']['length'] = strlen($frame_header) + strlen($frame_data); |
||
290 | $info_id3v2['padding']['valid'] = true; |
||
291 | |||
292 | $len = strlen($frame_data); |
||
293 | for ($i = 0; $i < $len; $i++) { |
||
294 | if ("\x00" != $frame_data{$i}) { |
||
295 | $info_id3v2['padding']['valid'] = false; |
||
296 | $info_id3v2['padding']['errorpos'] = $info_id3v2['padding']['start'] + $i; |
||
297 | $getid3->warning('Invalid ID3v2 padding found at offset ' . $info_id3v2['padding']['errorpos'] . ' (the remaining ' . ($info_id3v2['padding']['length'] - $i) . ' bytes are considered invalid)'); |
||
298 | break; |
||
299 | } |
||
300 | } |
||
301 | break; // skip rest of ID3v2 header |
||
302 | } |
||
303 | |||
304 | if ('COM ' == $frame_name) { |
||
305 | $getid3->warning( |
||
306 | 'error parsing "' |
||
307 | . $frame_name |
||
308 | . '" (' |
||
309 | . $frame_data_offset |
||
310 | . ' bytes into the ID3v2.' |
||
311 | . $id3v2_major_version |
||
312 | . ' tag). (ERROR: IsValidID3v2FrameName("' |
||
313 | . str_replace("\x00", ' ', $frame_name) |
||
314 | . '", ' |
||
315 | . $id3v2_major_version |
||
316 | . '))). [Note: this particular error has been known to happen with tags edited by iTunes (versions "X v2.0.3", "v3.0.1" are known-guilty, probably others too)]' |
||
317 | ); |
||
318 | $frame_name = 'COMM'; |
||
319 | } |
||
320 | if (($frame_size <= strlen($frame_data)) && (getid3_id3v2::IsValidID3v2FrameName($frame_name, $id3v2_major_version))) { |
||
321 | unset($parsed_frame); |
||
322 | $parsed_frame['frame_name'] = $frame_name; |
||
323 | $parsed_frame['frame_flags_raw'] = $frame_flags; |
||
324 | $parsed_frame['data'] = substr($frame_data, 0, $frame_size); |
||
325 | $parsed_frame['datalength'] = (int)($frame_size); |
||
326 | $parsed_frame['dataoffset'] = $frame_data_offset; |
||
327 | |||
328 | $this->ParseID3v2Frame($parsed_frame); |
||
329 | $info_id3v2[$frame_name][] = $parsed_frame; |
||
330 | |||
331 | $frame_data = substr($frame_data, $frame_size); |
||
332 | } else { // invalid frame length or FrameID |
||
333 | |||
334 | if ($frame_size <= strlen($frame_data)) { |
||
335 | if (getid3_id3v2::IsValidID3v2FrameName(substr($frame_data, $frame_size, 4), $id3v2_major_version)) { |
||
336 | // next frame is valid, just skip the current frame |
||
337 | $frame_data = substr($frame_data, $frame_size); |
||
338 | $getid3->warning('Next ID3v2 frame is valid, skipping current frame.'); |
||
339 | } else { |
||
340 | // next frame is invalid too, abort processing |
||
341 | throw new getid3_exception('Next ID3v2 frame is also invalid, aborting processing.'); |
||
342 | } |
||
343 | } elseif ($frame_size == strlen($frame_data)) { |
||
344 | // this is the last frame, just skip |
||
345 | $getid3->warning('This was the last ID3v2 frame.'); |
||
346 | } else { |
||
347 | // next frame is invalid too, abort processing |
||
348 | $frame_data = null; |
||
349 | $getid3->warning('Invalid ID3v2 frame size, aborting.'); |
||
350 | } |
||
351 | if (!getid3_id3v2::IsValidID3v2FrameName($frame_name, $id3v2_major_version)) { |
||
352 | switch ($frame_name) { |
||
353 | case "\x00\x00" . 'MP': |
||
354 | case "\x00" . 'MP3': |
||
355 | case ' MP3': |
||
356 | case 'MP3e': |
||
357 | case "\x00" . 'MP': |
||
358 | case ' MP': |
||
359 | case 'MP3': |
||
360 | $getid3->warning( |
||
361 | 'error parsing "' |
||
362 | . $frame_name |
||
363 | . '" (' |
||
364 | . $frame_data_offset |
||
365 | . ' bytes into the ID3v2.' |
||
366 | . $id3v2_major_version |
||
367 | . ' tag). (ERROR: !IsValidID3v2FrameName("' |
||
368 | . str_replace("\x00", ' ', $frame_name) |
||
369 | . '", ' |
||
370 | . $id3v2_major_version |
||
371 | . '))). [Note: this particular error has been known to happen with tags edited by "MP3ext (www.mutschler.de/mp3ext/)"]' |
||
372 | ); |
||
373 | break; |
||
374 | |||
375 | default: |
||
376 | $getid3->warning('error parsing "' . $frame_name . '" (' . $frame_data_offset . ' bytes into the ID3v2.' . $id3v2_major_version . ' tag). (ERROR: !IsValidID3v2FrameName("' . str_replace("\x00", ' ', $frame_name) . '", ' . $id3v2_major_version . '))).'); |
||
377 | break; |
||
378 | } |
||
379 | } elseif ($frame_size > strlen(@$frame_data)) { |
||
380 | throw new getid3_exception('error parsing "' . $frame_name . '" (' . $frame_data_offset . ' bytes into the ID3v2.' . $id3v2_major_version . ' tag). (ERROR: $frame_size (' . $frame_size . ') > strlen($frame_data) (' . strlen($frame_data) . ')).'); |
||
381 | } else { |
||
382 | throw new getid3_exception('error parsing "' . $frame_name . '" (' . $frame_data_offset . ' bytes into the ID3v2.' . $id3v2_major_version . ' tag).'); |
||
383 | } |
||
384 | } |
||
385 | $frame_data_offset += ($frame_size + (2 == $id3v2_major_version ? 6 : 10)); |
||
386 | } |
||
387 | } |
||
388 | |||
389 | // Footer |
||
390 | |||
391 | // The footer is a copy of the header, but with a different identifier. |
||
392 | // ID3v2 identifier "3DI" |
||
393 | // ID3v2 version $04 00 |
||
394 | // ID3v2 flags %abcd0000 |
||
395 | // ID3v2 size 4 * %0xxxxxxx |
||
396 | |||
397 | if (isset($info_id3v2_flags['isfooter']) && $info_id3v2_flags['isfooter']) { |
||
398 | $footer = fread($getid3->fp, 10); |
||
399 | if ('3DI' == substr($footer, 0, 3)) { |
||
400 | $info_id3v2['footer'] = true; |
||
401 | $info_id3v2['majorversion_footer'] = ord($footer{3}); |
||
402 | $info_id3v2['minorversion_footer'] = ord($footer{4}); |
||
403 | } |
||
404 | if ($info_id3v2['majorversion_footer'] <= 4) { |
||
405 | $id3_flags = ord($footer{5}); |
||
406 | $info_id3v2_flags['unsynch_footer'] = (bool)($id3_flags & 0x80); |
||
407 | $info_id3v2_flags['extfoot_footer'] = (bool)($id3_flags & 0x40); |
||
408 | $info_id3v2_flags['experim_footer'] = (bool)($id3_flags & 0x20); |
||
409 | $info_id3v2_flags['isfooter_footer'] = (bool)($id3_flags & 0x10); |
||
410 | |||
411 | $info_id3v2['footerlength'] = getid3_lib::BigEndianSyncSafe2Int(substr($footer, 6, 4)); |
||
412 | } |
||
413 | } // end footer |
||
414 | |||
415 | if (isset($info_id3v2['comments']['genre'])) { |
||
416 | foreach ($info_id3v2['comments']['genre'] as $key => $value) { |
||
417 | unset($info_id3v2['comments']['genre'][$key]); |
||
418 | $info_id3v2['comments'] = getid3_id3v2::array_merge_noclobber($info_id3v2['comments'], getid3_id3v2::ParseID3v2GenreString($value)); |
||
419 | } |
||
420 | } |
||
421 | |||
422 | if (isset($info_id3v2['comments']['track'])) { |
||
423 | foreach ($info_id3v2['comments']['track'] as $key => $value) { |
||
424 | if (strstr($value, '/')) { |
||
425 | list($info_id3v2['comments']['track'][$key], $info_id3v2['comments']['totaltracks'][$key]) = explode('/', $info_id3v2['comments']['track'][$key]); |
||
426 | } |
||
427 | } |
||
428 | } |
||
429 | |||
430 | // Use year from recording time if year not set |
||
431 | if (!isset($info_id3v2['comments']['year']) && ereg('^([0-9]{4})', @$info_id3v2['comments']['recording_time'][0], $matches)) { |
||
432 | $info_id3v2['comments']['year'] = [$matches[1]]; |
||
433 | } |
||
434 | |||
435 | // Set avdataoffset |
||
436 | $getid3->info['avdataoffset'] = $info_id3v2['headerlength']; |
||
437 | if (isset($info_id3v2['footer'])) { |
||
438 | $getid3->info['avdataoffset'] += 10; |
||
439 | } |
||
440 | |||
441 | return true; |
||
442 | } |
||
443 | |||
444 | private function ParseID3v2Frame(&$parsed_frame) |
||
445 | { |
||
446 | $getid3 = $this->getid3; |
||
447 | |||
448 | $id3v2_major_version = $getid3->info['id3v2']['majorversion']; |
||
449 | |||
450 | $frame_name_long = getid3_id3v2::FrameNameLongLookup($parsed_frame['frame_name']); |
||
451 | if ($frame_name_long) { |
||
452 | $parsed_frame['framenamelong'] = $frame_name_long; |
||
453 | } |
||
454 | |||
455 | $frame_name_short = getid3_id3v2::FrameNameShortLookup($parsed_frame['frame_name']); |
||
456 | if ($frame_name_short) { |
||
457 | $parsed_frame['framenameshort'] = $frame_name_short; |
||
458 | } |
||
459 | |||
460 | if ($id3v2_major_version >= 3) { // frame flags are not part of the ID3v2.2 standard |
||
461 | |||
462 | if (3 == $id3v2_major_version) { |
||
463 | // Frame Header Flags |
||
464 | // %abc00000 %ijk00000 |
||
465 | |||
466 | $parsed_frame['flags']['TagAlterPreservation'] = (bool)($parsed_frame['frame_flags_raw'] & 0x8000); // a - Tag alter preservation |
||
467 | $parsed_frame['flags']['FileAlterPreservation'] = (bool)($parsed_frame['frame_flags_raw'] & 0x4000); // b - File alter preservation |
||
468 | $parsed_frame['flags']['ReadOnly'] = (bool)($parsed_frame['frame_flags_raw'] & 0x2000); // c - Read only |
||
469 | $parsed_frame['flags']['compression'] = (bool)($parsed_frame['frame_flags_raw'] & 0x0080); // i - Compression |
||
470 | $parsed_frame['flags']['Encryption'] = (bool)($parsed_frame['frame_flags_raw'] & 0x0040); // j - Encryption |
||
471 | $parsed_frame['flags']['GroupingIdentity'] = (bool)($parsed_frame['frame_flags_raw'] & 0x0020); // k - Grouping identity |
||
472 | |||
473 | } elseif (4 == $id3v2_major_version) { |
||
474 | // Frame Header Flags |
||
475 | // %0abc0000 %0h00kmnp |
||
476 | |||
477 | $parsed_frame['flags']['TagAlterPreservation'] = (bool)($parsed_frame['frame_flags_raw'] & 0x4000); // a - Tag alter preservation |
||
478 | $parsed_frame['flags']['FileAlterPreservation'] = (bool)($parsed_frame['frame_flags_raw'] & 0x2000); // b - File alter preservation |
||
479 | $parsed_frame['flags']['ReadOnly'] = (bool)($parsed_frame['frame_flags_raw'] & 0x1000); // c - Read only |
||
480 | $parsed_frame['flags']['GroupingIdentity'] = (bool)($parsed_frame['frame_flags_raw'] & 0x0040); // h - Grouping identity |
||
481 | $parsed_frame['flags']['compression'] = (bool)($parsed_frame['frame_flags_raw'] & 0x0008); // k - Compression |
||
482 | $parsed_frame['flags']['Encryption'] = (bool)($parsed_frame['frame_flags_raw'] & 0x0004); // m - Encryption |
||
483 | $parsed_frame['flags']['Unsynchronisation'] = (bool)($parsed_frame['frame_flags_raw'] & 0x0002); // n - Unsynchronisation |
||
484 | $parsed_frame['flags']['DataLengthIndicator'] = (bool)($parsed_frame['frame_flags_raw'] & 0x0001); // p - Data length indicator |
||
485 | |||
486 | // Frame-level de-unsynchronisation - ID3v2.4 |
||
487 | if ($parsed_frame['flags']['Unsynchronisation']) { |
||
488 | $parsed_frame['data'] = str_replace("\xFF\x00", "\xFF", $parsed_frame['data']); |
||
489 | } |
||
490 | } |
||
491 | |||
492 | // Frame-level de-compression |
||
493 | if ($parsed_frame['flags']['compression']) { |
||
494 | $parsed_frame['decompressed_size'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], 0, 4)); |
||
495 | |||
496 | if (!function_exists('gzuncompress')) { |
||
497 | $getid3->warning('gzuncompress() support required to decompress ID3v2 frame "' . $parsed_frame['frame_name'] . '"'); |
||
498 | } elseif ($decompressed_data = @gzuncompress(substr($parsed_frame['data'], 4))) { |
||
499 | $parsed_frame['data'] = $decompressed_data; |
||
500 | } else { |
||
501 | $getid3->warning('gzuncompress() failed on compressed contents of ID3v2 frame "' . $parsed_frame['frame_name'] . '"'); |
||
502 | } |
||
503 | } |
||
504 | } |
||
505 | |||
506 | if (isset($parsed_frame['datalength']) && (0 == $parsed_frame['datalength'])) { |
||
507 | $warning = 'Frame "' . $parsed_frame['frame_name'] . '" at offset ' . $parsed_frame['dataoffset'] . ' has no data portion'; |
||
508 | switch ($parsed_frame['frame_name']) { |
||
509 | case 'WCOM': |
||
510 | $warning .= ' (this is known to happen with files tagged by RioPort)'; |
||
511 | break; |
||
512 | |||
513 | default: |
||
514 | break; |
||
515 | } |
||
516 | $getid3->warning($warning); |
||
517 | return true; |
||
518 | } |
||
519 | |||
520 | if ((($id3v2_major_version >= 3) && ('UFID' == $parsed_frame['frame_name'])) |
||
521 | || // 4.1 UFID Unique file identifier |
||
522 | ((2 == $id3v2_major_version) && ('UFI' == $parsed_frame['frame_name']))) { // 4.1 UFI Unique file identifier |
||
523 | |||
524 | // There may be more than one 'UFID' frame in a tag, |
||
525 | // but only one with the same 'Owner identifier'. |
||
526 | // <Header for 'Unique file identifier', ID: 'UFID'> |
||
527 | // Owner identifier <text string> $00 |
||
528 | // Identifier <up to 64 bytes binary data> |
||
529 | |||
530 | $frame_terminator_pos = strpos($parsed_frame['data'], "\x00"); |
||
531 | $frame_id_string = substr($parsed_frame['data'], 0, $frame_terminator_pos); |
||
532 | $parsed_frame['ownerid'] = $frame_id_string; |
||
533 | $parsed_frame['data'] = substr($parsed_frame['data'], $frame_terminator_pos + strlen("\x00")); |
||
534 | unset($parsed_frame['data']); |
||
535 | return true; |
||
536 | } |
||
537 | |||
538 | if ((($id3v2_major_version >= 3) && ('TXXX' == $parsed_frame['frame_name'])) |
||
539 | || // 4.2.2 TXXX User defined text information frame |
||
540 | ((2 == $id3v2_major_version) && ('TXX' == $parsed_frame['frame_name']))) { // 4.2.2 TXX User defined text information frame |
||
541 | |||
542 | // There may be more than one 'TXXX' frame in each tag, |
||
543 | // but only one with the same description. |
||
544 | // <Header for 'User defined text information frame', ID: 'TXXX'> |
||
545 | // Text encoding $xx |
||
546 | // Description <text string according to encoding> $00 (00) |
||
547 | // Value <text string according to encoding> |
||
548 | |||
549 | $frame_offset = 0; |
||
550 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
551 | |||
552 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
553 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
554 | } |
||
555 | $frame_terminator_pos = @strpos($parsed_frame['data'], getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding), $frame_offset); |
||
556 | if (0 === ord(substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
557 | $frame_terminator_pos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
558 | } |
||
559 | $frame_description = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
560 | if (0 === ord($frame_description)) { |
||
561 | $frame_description = ''; |
||
562 | } |
||
563 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
564 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
565 | |||
566 | $parsed_frame['description'] = $frame_description; |
||
567 | $parsed_frame['data'] = substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding))); |
||
568 | if (!empty($parsed_frame['framenameshort']) && !empty($parsed_frame['data'])) { |
||
569 | $getid3->info['id3v2']['comments'][$parsed_frame['framenameshort']][] = trim($getid3->iconv($parsed_frame['encoding'], 'UTF-8', $parsed_frame['data'])); |
||
570 | } |
||
571 | unset($parsed_frame['data']); |
||
572 | return true; |
||
573 | } |
||
574 | |||
575 | if ('T' == $parsed_frame['frame_name']{0}) { // 4.2. T??[?] Text information frame |
||
576 | |||
577 | // There may only be one text information frame of its kind in an tag. |
||
578 | // <Header for 'Text information frame', ID: 'T000' - 'TZZZ', |
||
579 | // excluding 'TXXX' described in 4.2.6.> |
||
580 | // Text encoding $xx |
||
581 | // Information <text string(s) according to encoding> |
||
582 | |||
583 | $frame_offset = 0; |
||
584 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
585 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
586 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
587 | } |
||
588 | |||
589 | $parsed_frame['data'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
590 | |||
591 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
592 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
593 | |||
594 | if (!empty($parsed_frame['framenameshort']) && !empty($parsed_frame['data'])) { |
||
595 | // remove possible terminating \x00 (put by encoding id or software bug) |
||
596 | $string = $getid3->iconv($parsed_frame['encoding'], 'UTF-8', $parsed_frame['data']); |
||
597 | if ($string[strlen($string) - 1] = "\x00") { |
||
598 | $string = substr($string, 0, strlen($string) - 1); |
||
599 | } |
||
600 | $getid3->info['id3v2']['comments'][$parsed_frame['framenameshort']][] = $string; |
||
601 | unset($string); |
||
602 | } |
||
603 | return true; |
||
604 | } |
||
605 | |||
606 | if ((($id3v2_major_version >= 3) && ('WXXX' == $parsed_frame['frame_name'])) |
||
607 | || // 4.3.2 WXXX User defined URL link frame |
||
608 | ((2 == $id3v2_major_version) && ('WXX' == $parsed_frame['frame_name']))) { // 4.3.2 WXX User defined URL link frame |
||
609 | |||
610 | // There may be more than one 'WXXX' frame in each tag, |
||
611 | // but only one with the same description |
||
612 | // <Header for 'User defined URL link frame', ID: 'WXXX'> |
||
613 | // Text encoding $xx |
||
614 | // Description <text string according to encoding> $00 (00) |
||
615 | // URL <text string> |
||
616 | |||
617 | $frame_offset = 0; |
||
618 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
619 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
620 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
621 | } |
||
622 | $frame_terminator_pos = @strpos($parsed_frame['data'], getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding), $frame_offset); |
||
623 | if (0 === ord(substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
624 | $frame_terminator_pos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
625 | } |
||
626 | $frame_description = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
627 | |||
628 | if (0 === ord($frame_description)) { |
||
629 | $frame_description = ''; |
||
630 | } |
||
631 | $parsed_frame['data'] = substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding))); |
||
632 | |||
633 | $frame_terminator_pos = strpos($parsed_frame['data'], getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)); |
||
634 | if (0 === ord(substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
635 | $frame_terminator_pos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
636 | } |
||
637 | if ($frame_terminator_pos) { |
||
638 | // there are null bytes after the data - this is not according to spec |
||
639 | // only use data up to first null byte |
||
640 | $frame_urldata = (string)substr($parsed_frame['data'], 0, $frame_terminator_pos); |
||
641 | } else { |
||
642 | // no null bytes following data, just use all data |
||
643 | $frame_urldata = (string)$parsed_frame['data']; |
||
644 | } |
||
645 | |||
646 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
647 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
648 | |||
649 | $parsed_frame['url'] = $frame_urldata; |
||
650 | $parsed_frame['description'] = $frame_description; |
||
651 | if (!empty($parsed_frame['framenameshort']) && $parsed_frame['url']) { |
||
652 | $getid3->info['id3v2']['comments'][$parsed_frame['framenameshort']][] = $getid3->iconv($parsed_frame['encoding'], 'UTF-8', $parsed_frame['url']); |
||
653 | } |
||
654 | unset($parsed_frame['data']); |
||
655 | return true; |
||
656 | } |
||
657 | |||
658 | if ('W' == $parsed_frame['frame_name']{0}) { // 4.3. W??? URL link frames |
||
659 | |||
660 | // There may only be one URL link frame of its kind in a tag, |
||
661 | // except when stated otherwise in the frame description |
||
662 | // <Header for 'URL link frame', ID: 'W000' - 'WZZZ', excluding 'WXXX' |
||
663 | // described in 4.3.2.> |
||
664 | // URL <text string> |
||
665 | |||
666 | $parsed_frame['url'] = trim($parsed_frame['data']); |
||
667 | if (!empty($parsed_frame['framenameshort']) && $parsed_frame['url']) { |
||
668 | $getid3->info['id3v2']['comments'][$parsed_frame['framenameshort']][] = $parsed_frame['url']; |
||
669 | } |
||
670 | unset($parsed_frame['data']); |
||
671 | return true; |
||
672 | } |
||
673 | |||
674 | if (((3 == $id3v2_major_version) && ('IPLS' == $parsed_frame['frame_name'])) |
||
675 | || // 4.4 IPLS Involved people list (ID3v2.3 only) |
||
676 | ((2 == $id3v2_major_version) && ('IPL' == $parsed_frame['frame_name']))) { // 4.4 IPL Involved people list (ID3v2.2 only) |
||
677 | |||
678 | // There may only be one 'IPL' frame in each tag |
||
679 | // <Header for 'User defined URL link frame', ID: 'IPL'> |
||
680 | // Text encoding $xx |
||
681 | // People list strings <textstrings> |
||
682 | |||
683 | $frame_offset = 0; |
||
684 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
685 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
686 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
687 | } |
||
688 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
689 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($parsed_frame['encodingid']); |
||
690 | |||
691 | $parsed_frame['data'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
692 | if (!empty($parsed_frame['framenameshort']) && !empty($parsed_frame['data'])) { |
||
693 | $getid3->info['id3v2']['comments'][$parsed_frame['framenameshort']][] = $getid3->iconv($parsed_frame['encoding'], 'UTF-8', $parsed_frame['data']); |
||
694 | } |
||
695 | return true; |
||
696 | } |
||
697 | |||
698 | if ((($id3v2_major_version >= 3) && ('MCDI' == $parsed_frame['frame_name'])) |
||
699 | || // 4.4 MCDI Music CD identifier |
||
700 | ((2 == $id3v2_major_version) && ('MCI' == $parsed_frame['frame_name']))) { // 4.5 MCI Music CD identifier |
||
701 | |||
702 | // There may only be one 'MCDI' frame in each tag |
||
703 | // <Header for 'Music CD identifier', ID: 'MCDI'> |
||
704 | // CD TOC <binary data> |
||
705 | |||
706 | if (!empty($parsed_frame['framenameshort']) && !empty($parsed_frame['data'])) { |
||
707 | $getid3->info['id3v2']['comments'][$parsed_frame['framenameshort']][] = $parsed_frame['data']; |
||
708 | } |
||
709 | return true; |
||
710 | } |
||
711 | |||
712 | if ((($id3v2_major_version >= 3) && ('ETCO' == $parsed_frame['frame_name'])) |
||
713 | || // 4.5 ETCO Event timing codes |
||
714 | ((2 == $id3v2_major_version) && ('ETC' == $parsed_frame['frame_name']))) { // 4.6 ETC Event timing codes |
||
715 | |||
716 | // There may only be one 'ETCO' frame in each tag |
||
717 | // <Header for 'Event timing codes', ID: 'ETCO'> |
||
718 | // Time stamp format $xx |
||
719 | // Where time stamp format is: |
||
720 | // $01 (32-bit value) MPEG frames from beginning of file |
||
721 | // $02 (32-bit value) milliseconds from beginning of file |
||
722 | // Followed by a list of key events in the following format: |
||
723 | // Type of event $xx |
||
724 | // Time stamp $xx (xx ...) |
||
725 | // The 'Time stamp' is set to zero if directly at the beginning of the sound |
||
726 | // or after the previous event. All events MUST be sorted in chronological order. |
||
727 | |||
728 | $frame_offset = 0; |
||
729 | $parsed_frame['timestampformat'] = ord($parsed_frame['data']{$frame_offset++}); |
||
730 | |||
731 | while ($frame_offset < strlen($parsed_frame['data'])) { |
||
732 | $parsed_frame['typeid'] = $parsed_frame['data']{$frame_offset++}; |
||
733 | $parsed_frame['type'] = getid3_id3v2::ETCOEventLookup($parsed_frame['typeid']); |
||
734 | $parsed_frame['timestamp'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 4)); |
||
735 | $frame_offset += 4; |
||
736 | } |
||
737 | unset($parsed_frame['data']); |
||
738 | return true; |
||
739 | } |
||
740 | |||
741 | if ((($id3v2_major_version >= 3) && ('MLLT' == $parsed_frame['frame_name'])) |
||
742 | || // 4.6 MLLT MPEG location lookup table |
||
743 | ((2 == $id3v2_major_version) && ('MLL' == $parsed_frame['frame_name']))) { // 4.7 MLL MPEG location lookup table |
||
744 | |||
745 | // There may only be one 'MLLT' frame in each tag |
||
746 | // <Header for 'Location lookup table', ID: 'MLLT'> |
||
747 | // MPEG frames between reference $xx xx |
||
748 | // Bytes between reference $xx xx xx |
||
749 | // Milliseconds between reference $xx xx xx |
||
750 | // Bits for bytes deviation $xx |
||
751 | // Bits for milliseconds dev. $xx |
||
752 | // Then for every reference the following data is included; |
||
753 | // Deviation in bytes %xxx.... |
||
754 | // Deviation in milliseconds %xxx.... |
||
755 | |||
756 | $frame_offset = 0; |
||
757 | $parsed_frame['framesbetweenreferences'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], 0, 2)); |
||
758 | $parsed_frame['bytesbetweenreferences'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], 2, 3)); |
||
759 | $parsed_frame['msbetweenreferences'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], 5, 3)); |
||
760 | $parsed_frame['bitsforbytesdeviation'] = getid3_lib::BigEndian2Int($parsed_frame['data'][8]); |
||
761 | $parsed_frame['bitsformsdeviation'] = getid3_lib::BigEndian2Int($parsed_frame['data'][9]); |
||
762 | $parsed_frame['data'] = substr($parsed_frame['data'], 10); |
||
763 | |||
764 | while ($frame_offset < strlen($parsed_frame['data'])) { |
||
765 | $deviation_bitstream .= getid3_lib::BigEndian2Bin($parsed_frame['data']{$frame_offset++}); |
||
766 | } |
||
767 | $reference_counter = 0; |
||
768 | while (strlen($deviation_bitstream) > 0) { |
||
769 | $parsed_frame[$reference_counter]['bytedeviation'] = bindec(substr($deviation_bitstream, 0, $parsed_frame['bitsforbytesdeviation'])); |
||
770 | $parsed_frame[$reference_counter]['msdeviation'] = bindec(substr($deviation_bitstream, $parsed_frame['bitsforbytesdeviation'], $parsed_frame['bitsformsdeviation'])); |
||
771 | $deviation_bitstream = substr($deviation_bitstream, $parsed_frame['bitsforbytesdeviation'] + $parsed_frame['bitsformsdeviation']); |
||
772 | $reference_counter++; |
||
773 | } |
||
774 | unset($parsed_frame['data']); |
||
775 | return true; |
||
776 | } |
||
777 | |||
778 | if ((($id3v2_major_version >= 3) && ('SYTC' == $parsed_frame['frame_name'])) |
||
779 | || // 4.7 SYTC Synchronised tempo codes |
||
780 | ((2 == $id3v2_major_version) && ('STC' == $parsed_frame['frame_name']))) { // 4.8 STC Synchronised tempo codes |
||
781 | |||
782 | // There may only be one 'SYTC' frame in each tag |
||
783 | // <Header for 'Synchronised tempo codes', ID: 'SYTC'> |
||
784 | // Time stamp format $xx |
||
785 | // Tempo data <binary data> |
||
786 | // Where time stamp format is: |
||
787 | // $01 (32-bit value) MPEG frames from beginning of file |
||
788 | // $02 (32-bit value) milliseconds from beginning of file |
||
789 | |||
790 | $frame_offset = 0; |
||
791 | $parsed_frame['timestampformat'] = ord($parsed_frame['data']{$frame_offset++}); |
||
792 | $timestamp_counter = 0; |
||
793 | while ($frame_offset < strlen($parsed_frame['data'])) { |
||
794 | $parsed_frame[$timestamp_counter]['tempo'] = ord($parsed_frame['data']{$frame_offset++}); |
||
795 | if (255 == $parsed_frame[$timestamp_counter]['tempo']) { |
||
796 | $parsed_frame[$timestamp_counter]['tempo'] += ord($parsed_frame['data']{$frame_offset++}); |
||
797 | } |
||
798 | $parsed_frame[$timestamp_counter]['timestamp'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 4)); |
||
799 | $frame_offset += 4; |
||
800 | $timestamp_counter++; |
||
801 | } |
||
802 | unset($parsed_frame['data']); |
||
803 | return true; |
||
804 | } |
||
805 | |||
806 | if ((($id3v2_major_version >= 3) && ('USLT' == $parsed_frame['frame_name'])) |
||
807 | || // 4.8 USLT Unsynchronised lyric/text transcription |
||
808 | ((2 == $id3v2_major_version) && ('ULT' == $parsed_frame['frame_name']))) { // 4.9 ULT Unsynchronised lyric/text transcription |
||
809 | |||
810 | // There may be more than one 'Unsynchronised lyrics/text transcription' frame |
||
811 | // in each tag, but only one with the same language and content descriptor. |
||
812 | // <Header for 'Unsynchronised lyrics/text transcription', ID: 'USLT'> |
||
813 | // Text encoding $xx |
||
814 | // Language $xx xx xx |
||
815 | // Content descriptor <text string according to encoding> $00 (00) |
||
816 | // Lyrics/text <full text string according to encoding> |
||
817 | |||
818 | $frame_offset = 0; |
||
819 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
820 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
821 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
822 | } |
||
823 | $frame_language = substr($parsed_frame['data'], $frame_offset, 3); |
||
824 | $frame_offset += 3; |
||
825 | if ($frame_offset > strlen($parsed_frame['data'])) { |
||
826 | $frame_offset = strlen($parsed_frame['data']) - 1; |
||
827 | } |
||
828 | $frame_terminator_pos = @strpos($parsed_frame['data'], getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding), $frame_offset); |
||
829 | if (0 === ord(substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
830 | $frame_terminator_pos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
831 | } |
||
832 | $frame_description = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
833 | if (0 === ord($frame_description)) { |
||
834 | $frame_description = ''; |
||
835 | } |
||
836 | $parsed_frame['data'] = substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding))); |
||
837 | |||
838 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
839 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
840 | |||
841 | $parsed_frame['data'] = $parsed_frame['data']; |
||
842 | $parsed_frame['language'] = $frame_language; |
||
843 | $parsed_frame['languagename'] = getid3_id3v2::LanguageLookup($frame_language, false); |
||
844 | $parsed_frame['description'] = $frame_description; |
||
845 | if (!empty($parsed_frame['framenameshort']) && !empty($parsed_frame['data'])) { |
||
846 | $getid3->info['id3v2']['comments'][$parsed_frame['framenameshort']][] = $getid3->iconv($parsed_frame['encoding'], 'UTF-8', $parsed_frame['data']); |
||
847 | } |
||
848 | unset($parsed_frame['data']); |
||
849 | return true; |
||
850 | } |
||
851 | |||
852 | if ((($id3v2_major_version >= 3) && ('SYLT' == $parsed_frame['frame_name'])) |
||
853 | || // 4.9 SYLT Synchronised lyric/text |
||
854 | ((2 == $id3v2_major_version) && ('SLT' == $parsed_frame['frame_name']))) { // 4.10 SLT Synchronised lyric/text |
||
855 | |||
856 | // There may be more than one 'SYLT' frame in each tag, |
||
857 | // but only one with the same language and content descriptor. |
||
858 | // <Header for 'Synchronised lyrics/text', ID: 'SYLT'> |
||
859 | // Text encoding $xx |
||
860 | // Language $xx xx xx |
||
861 | // Time stamp format $xx |
||
862 | // $01 (32-bit value) MPEG frames from beginning of file |
||
863 | // $02 (32-bit value) milliseconds from beginning of file |
||
864 | // Content type $xx |
||
865 | // Content descriptor <text string according to encoding> $00 (00) |
||
866 | // Terminated text to be synced (typically a syllable) |
||
867 | // Sync identifier (terminator to above string) $00 (00) |
||
868 | // Time stamp $xx (xx ...) |
||
869 | |||
870 | $frame_offset = 0; |
||
871 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
872 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
873 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
874 | } |
||
875 | $frame_language = substr($parsed_frame['data'], $frame_offset, 3); |
||
876 | $frame_offset += 3; |
||
877 | $parsed_frame['timestampformat'] = ord($parsed_frame['data']{$frame_offset++}); |
||
878 | $parsed_frame['contenttypeid'] = ord($parsed_frame['data']{$frame_offset++}); |
||
879 | $parsed_frame['contenttype'] = getid3_id3v2::SYTLContentTypeLookup($parsed_frame['contenttypeid']); |
||
880 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
881 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
882 | |||
883 | $parsed_frame['language'] = $frame_language; |
||
884 | $parsed_frame['languagename'] = getid3_id3v2::LanguageLookup($frame_language, false); |
||
885 | |||
886 | $timestamp_index = 0; |
||
887 | $frame_remaining_data = substr($parsed_frame['data'], $frame_offset); |
||
888 | while (strlen($frame_remaining_data)) { |
||
889 | $frame_offset = 0; |
||
890 | $frame_terminator_pos = strpos($frame_remaining_data, getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)); |
||
891 | if (false === $frame_terminator_pos) { |
||
892 | $frame_remaining_data = ''; |
||
893 | } else { |
||
894 | if (0 === ord(substr($frame_remaining_data, $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
895 | $frame_terminator_pos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
896 | } |
||
897 | $parsed_frame['lyrics'][$timestamp_index]['data'] = substr($frame_remaining_data, $frame_offset, $frame_terminator_pos - $frame_offset); |
||
898 | |||
899 | $frame_remaining_data = substr($frame_remaining_data, $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding))); |
||
900 | if ((0 == $timestamp_index) && (0 != ord($frame_remaining_data{0}))) { |
||
901 | // timestamp probably omitted for first data item |
||
902 | } else { |
||
903 | $parsed_frame['lyrics'][$timestamp_index]['timestamp'] = getid3_lib::BigEndian2Int(substr($frame_remaining_data, 0, 4)); |
||
904 | $frame_remaining_data = substr($frame_remaining_data, 4); |
||
905 | } |
||
906 | $timestamp_index++; |
||
907 | } |
||
908 | } |
||
909 | unset($parsed_frame['data']); |
||
910 | return true; |
||
911 | } |
||
912 | |||
913 | if ((($id3v2_major_version >= 3) && ('COMM' == $parsed_frame['frame_name'])) |
||
914 | || // 4.10 COMM Comments |
||
915 | ((2 == $id3v2_major_version) && ('COM' == $parsed_frame['frame_name']))) { // 4.11 COM Comments |
||
916 | |||
917 | // There may be more than one comment frame in each tag, |
||
918 | // but only one with the same language and content descriptor. |
||
919 | // <Header for 'Comment', ID: 'COMM'> |
||
920 | // Text encoding $xx |
||
921 | // Language $xx xx xx |
||
922 | // Short content descrip. <text string according to encoding> $00 (00) |
||
923 | // The actual text <full text string according to encoding> |
||
924 | |||
925 | if (strlen($parsed_frame['data']) < 5) { |
||
926 | $getid3->warning('Invalid data (too short) for "' . $parsed_frame['frame_name'] . '" frame at offset ' . $parsed_frame['dataoffset']); |
||
927 | return true; |
||
928 | } |
||
929 | |||
930 | $frame_offset = 0; |
||
931 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
932 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
933 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
934 | } |
||
935 | $frame_language = substr($parsed_frame['data'], $frame_offset, 3); |
||
936 | $frame_offset += 3; |
||
937 | $frame_terminator_pos = @strpos($parsed_frame['data'], getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding), $frame_offset); |
||
938 | if (0 === ord(substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
939 | $frame_terminator_pos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
940 | } |
||
941 | $frame_description = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
942 | if (0 === ord($frame_description)) { |
||
943 | $frame_description = ''; |
||
944 | } |
||
945 | $frame_text = (string)substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding))); |
||
946 | |||
947 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
948 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
949 | |||
950 | $parsed_frame['language'] = $frame_language; |
||
951 | $parsed_frame['languagename'] = getid3_id3v2::LanguageLookup($frame_language, false); |
||
952 | $parsed_frame['description'] = $frame_description; |
||
953 | $parsed_frame['data'] = $frame_text; |
||
954 | if (!empty($parsed_frame['framenameshort']) && !empty($parsed_frame['data'])) { |
||
955 | $getid3->info['id3v2']['comments'][$parsed_frame['framenameshort']][] = $getid3->iconv($parsed_frame['encoding'], 'UTF-8', $parsed_frame['data']); |
||
956 | } |
||
957 | return true; |
||
958 | } |
||
959 | |||
960 | if (($id3v2_major_version >= 4) && ('RVA2' == $parsed_frame['frame_name'])) { // 4.11 RVA2 Relative volume adjustment (2) (ID3v2.4+ only) |
||
961 | |||
962 | // There may be more than one 'RVA2' frame in each tag, |
||
963 | // but only one with the same identification string |
||
964 | // <Header for 'Relative volume adjustment (2)', ID: 'RVA2'> |
||
965 | // Identification <text string> $00 |
||
966 | // The 'identification' string is used to identify the situation and/or |
||
967 | // device where this adjustment should apply. The following is then |
||
968 | // repeated for every channel: |
||
969 | // Type of channel $xx |
||
970 | // Volume adjustment $xx xx |
||
971 | // Bits representing peak $xx |
||
972 | // Peak volume $xx (xx ...) |
||
973 | |||
974 | $frame_terminator_pos = strpos($parsed_frame['data'], "\x00"); |
||
975 | $frame_id_string = substr($parsed_frame['data'], 0, $frame_terminator_pos); |
||
976 | if (0 === ord($frame_id_string)) { |
||
977 | $frame_id_string = ''; |
||
978 | } |
||
979 | $frame_remaining_data = substr($parsed_frame['data'], $frame_terminator_pos + strlen("\x00")); |
||
980 | $parsed_frame['description'] = $frame_id_string; |
||
981 | |||
982 | while (strlen($frame_remaining_data)) { |
||
983 | $frame_offset = 0; |
||
984 | $frame_channeltypeid = ord(substr($frame_remaining_data, $frame_offset++, 1)); |
||
985 | $parsed_frame[$frame_channeltypeid]['channeltypeid'] = $frame_channeltypeid; |
||
986 | $parsed_frame[$frame_channeltypeid]['channeltype'] = getid3_id3v2::RVA2ChannelTypeLookup($frame_channeltypeid); |
||
987 | $parsed_frame[$frame_channeltypeid]['volumeadjust'] = getid3_lib::BigEndian2Int(substr($frame_remaining_data, $frame_offset, 2), true); // 16-bit signed |
||
988 | $frame_offset += 2; |
||
989 | $parsed_frame[$frame_channeltypeid]['bitspeakvolume'] = ord(substr($frame_remaining_data, $frame_offset++, 1)); |
||
990 | $frame_bytespeakvolume = ceil($parsed_frame[$frame_channeltypeid]['bitspeakvolume'] / 8); |
||
991 | $parsed_frame[$frame_channeltypeid]['peakvolume'] = getid3_lib::BigEndian2Int(substr($frame_remaining_data, $frame_offset, $frame_bytespeakvolume)); |
||
992 | $frame_remaining_data = substr($frame_remaining_data, $frame_offset + $frame_bytespeakvolume); |
||
993 | } |
||
994 | unset($parsed_frame['data']); |
||
995 | return true; |
||
996 | } |
||
997 | |||
998 | if (((3 == $id3v2_major_version) && ('RVAD' == $parsed_frame['frame_name'])) |
||
999 | || // 4.12 RVAD Relative volume adjustment (ID3v2.3 only) |
||
1000 | ((2 == $id3v2_major_version) && ('RVA' == $parsed_frame['frame_name']))) { // 4.12 RVA Relative volume adjustment (ID3v2.2 only) |
||
1001 | |||
1002 | // There may only be one 'RVA' frame in each tag |
||
1003 | // <Header for 'Relative volume adjustment', ID: 'RVA'> |
||
1004 | // ID3v2.2 => Increment/decrement %000000ba |
||
1005 | // ID3v2.3 => Increment/decrement %00fedcba |
||
1006 | // Bits used for volume descr. $xx |
||
1007 | // Relative volume change, right $xx xx (xx ...) // a |
||
1008 | // Relative volume change, left $xx xx (xx ...) // b |
||
1009 | // Peak volume right $xx xx (xx ...) |
||
1010 | // Peak volume left $xx xx (xx ...) |
||
1011 | // ID3v2.3 only, optional (not present in ID3v2.2): |
||
1012 | // Relative volume change, right back $xx xx (xx ...) // c |
||
1013 | // Relative volume change, left back $xx xx (xx ...) // d |
||
1014 | // Peak volume right back $xx xx (xx ...) |
||
1015 | // Peak volume left back $xx xx (xx ...) |
||
1016 | // ID3v2.3 only, optional (not present in ID3v2.2): |
||
1017 | // Relative volume change, center $xx xx (xx ...) // e |
||
1018 | // Peak volume center $xx xx (xx ...) |
||
1019 | // ID3v2.3 only, optional (not present in ID3v2.2): |
||
1020 | // Relative volume change, bass $xx xx (xx ...) // f |
||
1021 | // Peak volume bass $xx xx (xx ...) |
||
1022 | |||
1023 | $frame_offset = 0; |
||
1024 | $frame_incrdecrflags = getid3_lib::BigEndian2Bin($parsed_frame['data']{$frame_offset++}); |
||
1025 | $parsed_frame['incdec']['right'] = (bool)substr($frame_incrdecrflags, 6, 1); |
||
1026 | $parsed_frame['incdec']['left'] = (bool)substr($frame_incrdecrflags, 7, 1); |
||
1027 | $parsed_frame['bitsvolume'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1028 | $frame_bytesvolume = ceil($parsed_frame['bitsvolume'] / 8); |
||
1029 | $parsed_frame['volumechange']['right'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1030 | if (false === $parsed_frame['incdec']['right']) { |
||
1031 | $parsed_frame['volumechange']['right'] *= -1; |
||
1032 | } |
||
1033 | $frame_offset += $frame_bytesvolume; |
||
1034 | $parsed_frame['volumechange']['left'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1035 | if (false === $parsed_frame['incdec']['left']) { |
||
1036 | $parsed_frame['volumechange']['left'] *= -1; |
||
1037 | } |
||
1038 | $frame_offset += $frame_bytesvolume; |
||
1039 | $parsed_frame['peakvolume']['right'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1040 | $frame_offset += $frame_bytesvolume; |
||
1041 | $parsed_frame['peakvolume']['left'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1042 | $frame_offset += $frame_bytesvolume; |
||
1043 | if (3 == $id3v2_major_version) { |
||
1044 | $parsed_frame['data'] = substr($parsed_frame['data'], $frame_offset); |
||
1045 | if (strlen($parsed_frame['data']) > 0) { |
||
1046 | $parsed_frame['incdec']['rightrear'] = (bool)substr($frame_incrdecrflags, 4, 1); |
||
1047 | $parsed_frame['incdec']['leftrear'] = (bool)substr($frame_incrdecrflags, 5, 1); |
||
1048 | $parsed_frame['volumechange']['rightrear'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1049 | if (false === $parsed_frame['incdec']['rightrear']) { |
||
1050 | $parsed_frame['volumechange']['rightrear'] *= -1; |
||
1051 | } |
||
1052 | $frame_offset += $frame_bytesvolume; |
||
1053 | $parsed_frame['volumechange']['leftrear'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1054 | if (false === $parsed_frame['incdec']['leftrear']) { |
||
1055 | $parsed_frame['volumechange']['leftrear'] *= -1; |
||
1056 | } |
||
1057 | $frame_offset += $frame_bytesvolume; |
||
1058 | $parsed_frame['peakvolume']['rightrear'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1059 | $frame_offset += $frame_bytesvolume; |
||
1060 | $parsed_frame['peakvolume']['leftrear'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1061 | $frame_offset += $frame_bytesvolume; |
||
1062 | } |
||
1063 | $parsed_frame['data'] = substr($parsed_frame['data'], $frame_offset); |
||
1064 | if (strlen($parsed_frame['data']) > 0) { |
||
1065 | $parsed_frame['incdec']['center'] = (bool)substr($frame_incrdecrflags, 3, 1); |
||
1066 | $parsed_frame['volumechange']['center'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1067 | if (false === $parsed_frame['incdec']['center']) { |
||
1068 | $parsed_frame['volumechange']['center'] *= -1; |
||
1069 | } |
||
1070 | $frame_offset += $frame_bytesvolume; |
||
1071 | $parsed_frame['peakvolume']['center'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1072 | $frame_offset += $frame_bytesvolume; |
||
1073 | } |
||
1074 | $parsed_frame['data'] = substr($parsed_frame['data'], $frame_offset); |
||
1075 | if (strlen($parsed_frame['data']) > 0) { |
||
1076 | $parsed_frame['incdec']['bass'] = (bool)substr($frame_incrdecrflags, 2, 1); |
||
1077 | $parsed_frame['volumechange']['bass'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1078 | if (false === $parsed_frame['incdec']['bass']) { |
||
1079 | $parsed_frame['volumechange']['bass'] *= -1; |
||
1080 | } |
||
1081 | $frame_offset += $frame_bytesvolume; |
||
1082 | $parsed_frame['peakvolume']['bass'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesvolume)); |
||
1083 | $frame_offset += $frame_bytesvolume; |
||
1084 | } |
||
1085 | } |
||
1086 | unset($parsed_frame['data']); |
||
1087 | return true; |
||
1088 | } |
||
1089 | |||
1090 | if (($id3v2_major_version >= 4) && ('EQU2' == $parsed_frame['frame_name'])) { // 4.12 EQU2 Equalisation (2) (ID3v2.4+ only) |
||
1091 | |||
1092 | // There may be more than one 'EQU2' frame in each tag, |
||
1093 | // but only one with the same identification string |
||
1094 | // <Header of 'Equalisation (2)', ID: 'EQU2'> |
||
1095 | // Interpolation method $xx |
||
1096 | // $00 Band |
||
1097 | // $01 Linear |
||
1098 | // Identification <text string> $00 |
||
1099 | // The following is then repeated for every adjustment point |
||
1100 | // Frequency $xx xx |
||
1101 | // Volume adjustment $xx xx |
||
1102 | |||
1103 | $frame_offset = 0; |
||
1104 | $frame_interpolationmethod = ord($parsed_frame['data']{$frame_offset++}); |
||
1105 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1106 | $frame_id_string = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1107 | if (0 === ord($frame_id_string)) { |
||
1108 | $frame_id_string = ''; |
||
1109 | } |
||
1110 | $parsed_frame['description'] = $frame_id_string; |
||
1111 | $frame_remaining_data = substr($parsed_frame['data'], $frame_terminator_pos + strlen("\x00")); |
||
1112 | while (strlen($frame_remaining_data)) { |
||
1113 | $frame_frequency = getid3_lib::BigEndian2Int(substr($frame_remaining_data, 0, 2)) / 2; |
||
1114 | $parsed_frame['data'][$frame_frequency] = getid3_lib::BigEndian2Int(substr($frame_remaining_data, 2, 2), true); |
||
1115 | $frame_remaining_data = substr($frame_remaining_data, 4); |
||
1116 | } |
||
1117 | $parsed_frame['interpolationmethod'] = $frame_interpolationmethod; |
||
1118 | unset($parsed_frame['data']); |
||
1119 | return true; |
||
1120 | } |
||
1121 | |||
1122 | if (((3 == $id3v2_major_version) && ('EQUA' == $parsed_frame['frame_name'])) |
||
1123 | || // 4.12 EQUA Equalisation (ID3v2.3 only) |
||
1124 | ((2 == $id3v2_major_version) && ('EQU' == $parsed_frame['frame_name']))) { // 4.13 EQU Equalisation (ID3v2.2 only) |
||
1125 | |||
1126 | // There may only be one 'EQUA' frame in each tag |
||
1127 | // <Header for 'Relative volume adjustment', ID: 'EQU'> |
||
1128 | // Adjustment bits $xx |
||
1129 | // This is followed by 2 bytes + ('adjustment bits' rounded up to the |
||
1130 | // nearest byte) for every equalisation band in the following format, |
||
1131 | // giving a frequency range of 0 - 32767Hz: |
||
1132 | // Increment/decrement %x (MSB of the Frequency) |
||
1133 | // Frequency (lower 15 bits) |
||
1134 | // Adjustment $xx (xx ...) |
||
1135 | |||
1136 | $frame_offset = 0; |
||
1137 | $parsed_frame['adjustmentbits'] = $parsed_frame['data']{$frame_offset++}; |
||
1138 | $frame_adjustment_bytes = ceil($parsed_frame['adjustmentbits'] / 8); |
||
1139 | |||
1140 | $frame_remaining_data = (string)substr($parsed_frame['data'], $frame_offset); |
||
1141 | while (strlen($frame_remaining_data) > 0) { |
||
1142 | $frame_frequencystr = getid3_lib::BigEndian2Bin(substr($frame_remaining_data, 0, 2)); |
||
1143 | $frame_incdec = (bool)substr($frame_frequencystr, 0, 1); |
||
1144 | $frame_frequency = bindec(substr($frame_frequencystr, 1, 15)); |
||
1145 | $parsed_frame[$frame_frequency]['incdec'] = $frame_incdec; |
||
1146 | $parsed_frame[$frame_frequency]['adjustment'] = getid3_lib::BigEndian2Int(substr($frame_remaining_data, 2, $frame_adjustment_bytes)); |
||
1147 | if (false === $parsed_frame[$frame_frequency]['incdec']) { |
||
1148 | $parsed_frame[$frame_frequency]['adjustment'] *= -1; |
||
1149 | } |
||
1150 | $frame_remaining_data = substr($frame_remaining_data, 2 + $frame_adjustment_bytes); |
||
1151 | } |
||
1152 | unset($parsed_frame['data']); |
||
1153 | return true; |
||
1154 | } |
||
1155 | |||
1156 | if ((($id3v2_major_version >= 3) && ('RVRB' == $parsed_frame['frame_name'])) |
||
1157 | || // 4.13 RVRB Reverb |
||
1158 | ((2 == $id3v2_major_version) && ('REV' == $parsed_frame['frame_name']))) { // 4.14 REV Reverb |
||
1159 | |||
1160 | // There may only be one 'RVRB' frame in each tag. |
||
1161 | // <Header for 'Reverb', ID: 'RVRB'> |
||
1162 | // Reverb left (ms) $xx xx |
||
1163 | // Reverb right (ms) $xx xx |
||
1164 | // Reverb bounces, left $xx |
||
1165 | // Reverb bounces, right $xx |
||
1166 | // Reverb feedback, left to left $xx |
||
1167 | // Reverb feedback, left to right $xx |
||
1168 | // Reverb feedback, right to right $xx |
||
1169 | // Reverb feedback, right to left $xx |
||
1170 | // Premix left to right $xx |
||
1171 | // Premix right to left $xx |
||
1172 | |||
1173 | $frame_offset = 0; |
||
1174 | $parsed_frame['left'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 2)); |
||
1175 | $frame_offset += 2; |
||
1176 | $parsed_frame['right'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 2)); |
||
1177 | $frame_offset += 2; |
||
1178 | $parsed_frame['bouncesL'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1179 | $parsed_frame['bouncesR'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1180 | $parsed_frame['feedbackLL'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1181 | $parsed_frame['feedbackLR'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1182 | $parsed_frame['feedbackRR'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1183 | $parsed_frame['feedbackRL'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1184 | $parsed_frame['premixLR'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1185 | $parsed_frame['premixRL'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1186 | unset($parsed_frame['data']); |
||
1187 | return true; |
||
1188 | } |
||
1189 | |||
1190 | if ((($id3v2_major_version >= 3) && ('APIC' == $parsed_frame['frame_name'])) |
||
1191 | || // 4.14 APIC Attached picture |
||
1192 | ((2 == $id3v2_major_version) && ('PIC' == $parsed_frame['frame_name']))) { // 4.15 PIC Attached picture |
||
1193 | |||
1194 | // There may be several pictures attached to one file, |
||
1195 | // each in their individual 'APIC' frame, but only one |
||
1196 | // with the same content descriptor |
||
1197 | // <Header for 'Attached picture', ID: 'APIC'> |
||
1198 | // Text encoding $xx |
||
1199 | // ID3v2.3+ => MIME type <text string> $00 |
||
1200 | // ID3v2.2 => Image format $xx xx xx |
||
1201 | // Picture type $xx |
||
1202 | // Description <text string according to encoding> $00 (00) |
||
1203 | // Picture data <binary data> |
||
1204 | |||
1205 | $frame_offset = 0; |
||
1206 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
1207 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
1208 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
1209 | } |
||
1210 | |||
1211 | if (2 == $id3v2_major_version && strlen($parsed_frame['data']) > $frame_offset) { |
||
1212 | $frame_imagetype = substr($parsed_frame['data'], $frame_offset, 3); |
||
1213 | if ('ima' == strtolower($frame_imagetype)) { |
||
1214 | // complete hack for mp3Rage (www.chaoticsoftware.com) that puts ID3v2.3-formatted |
||
1215 | // MIME type instead of 3-char ID3v2.2-format image type (thanks xbhoff�pacbell*net) |
||
1216 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1217 | $frame_mimetype = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1218 | if (0 === ord($frame_mimetype)) { |
||
1219 | $frame_mimetype = ''; |
||
1220 | } |
||
1221 | $frame_imagetype = strtoupper(str_replace('image/', '', strtolower($frame_mimetype))); |
||
1222 | if ('JPEG' == $frame_imagetype) { |
||
1223 | $frame_imagetype = 'JPG'; |
||
1224 | } |
||
1225 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1226 | } else { |
||
1227 | $frame_offset += 3; |
||
1228 | } |
||
1229 | } |
||
1230 | |||
1231 | if ($id3v2_major_version > 2 && strlen($parsed_frame['data']) > $frame_offset) { |
||
1232 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1233 | $frame_mimetype = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1234 | if (0 === ord($frame_mimetype)) { |
||
1235 | $frame_mimetype = ''; |
||
1236 | } |
||
1237 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1238 | } |
||
1239 | |||
1240 | $frame_picturetype = ord($parsed_frame['data']{$frame_offset++}); |
||
1241 | |||
1242 | $frame_terminator_pos = @strpos($parsed_frame['data'], getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding), $frame_offset); |
||
1243 | if (0 === ord(substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
1244 | $frame_terminator_pos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
1245 | } |
||
1246 | $frame_description = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1247 | if (0 === ord($frame_description)) { |
||
1248 | $frame_description = ''; |
||
1249 | } |
||
1250 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
1251 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
1252 | |||
1253 | if (2 == $id3v2_major_version) { |
||
1254 | $parsed_frame['imagetype'] = $frame_imagetype; |
||
1255 | } else { |
||
1256 | $parsed_frame['mime'] = $frame_mimetype; |
||
1257 | } |
||
1258 | $parsed_frame['picturetypeid'] = $frame_picturetype; |
||
1259 | $parsed_frame['picturetype'] = getid3_id3v2::APICPictureTypeLookup($frame_picturetype); |
||
1260 | $parsed_frame['description'] = $frame_description; |
||
1261 | $parsed_frame['data'] = substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding))); |
||
1262 | |||
1263 | if ($getid3->option_tags_images) { |
||
1264 | $image_chunk_check = getid3_lib_image_size::get($parsed_frame['data']); |
||
1265 | if (($image_chunk_check[2] >= 1) && ($image_chunk_check[2] <= 3)) { |
||
1266 | $parsed_frame['image_mime'] = image_type_to_mime_type($image_chunk_check[2]); |
||
1267 | |||
1268 | if ($image_chunk_check[0]) { |
||
1269 | $parsed_frame['image_width'] = $image_chunk_check[0]; |
||
1270 | } |
||
1271 | |||
1272 | if ($image_chunk_check[1]) { |
||
1273 | $parsed_frame['image_height'] = $image_chunk_check[1]; |
||
1274 | } |
||
1275 | |||
1276 | $parsed_frame['image_bytes'] = strlen($parsed_frame['data']); |
||
1277 | } |
||
1278 | } |
||
1279 | |||
1280 | return true; |
||
1281 | } |
||
1282 | |||
1283 | if ((($id3v2_major_version >= 3) && ('GEOB' == $parsed_frame['frame_name'])) |
||
1284 | || // 4.15 GEOB General encapsulated object |
||
1285 | ((2 == $id3v2_major_version) && ('GEO' == $parsed_frame['frame_name']))) { // 4.16 GEO General encapsulated object |
||
1286 | |||
1287 | // There may be more than one 'GEOB' frame in each tag, |
||
1288 | // but only one with the same content descriptor |
||
1289 | // <Header for 'General encapsulated object', ID: 'GEOB'> |
||
1290 | // Text encoding $xx |
||
1291 | // MIME type <text string> $00 |
||
1292 | // Filename <text string according to encoding> $00 (00) |
||
1293 | // Content description <text string according to encoding> $00 (00) |
||
1294 | // Encapsulated object <binary data> |
||
1295 | |||
1296 | $frame_offset = 0; |
||
1297 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
1298 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
1299 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
1300 | } |
||
1301 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1302 | $frame_mimetype = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1303 | if (0 === ord($frame_mimetype)) { |
||
1304 | $frame_mimetype = ''; |
||
1305 | } |
||
1306 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1307 | |||
1308 | $frame_terminator_pos = @strpos($parsed_frame['data'], getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding), $frame_offset); |
||
1309 | if (0 === ord(substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
1310 | $frame_terminator_pos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
1311 | } |
||
1312 | $frame_filename = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1313 | if (0 === ord($frame_filename)) { |
||
1314 | $frame_filename = ''; |
||
1315 | } |
||
1316 | $frame_offset = $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)); |
||
1317 | |||
1318 | $frame_terminator_pos = @strpos($parsed_frame['data'], getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding), $frame_offset); |
||
1319 | if (0 === ord(substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
1320 | $frame_terminator_pos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
1321 | } |
||
1322 | $frame_description = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1323 | if (0 === ord($frame_description)) { |
||
1324 | $frame_description = ''; |
||
1325 | } |
||
1326 | $frame_offset = $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)); |
||
1327 | |||
1328 | $parsed_frame['objectdata'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
1329 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
1330 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
1331 | |||
1332 | $parsed_frame['mime'] = $frame_mimetype; |
||
1333 | $parsed_frame['filename'] = $frame_filename; |
||
1334 | $parsed_frame['description'] = $frame_description; |
||
1335 | unset($parsed_frame['data']); |
||
1336 | return true; |
||
1337 | } |
||
1338 | |||
1339 | if ((($id3v2_major_version >= 3) && ('PCNT' == $parsed_frame['frame_name'])) |
||
1340 | || // 4.16 PCNT Play counter |
||
1341 | ((2 == $id3v2_major_version) && ('CNT' == $parsed_frame['frame_name']))) { // 4.17 CNT Play counter |
||
1342 | |||
1343 | // There may only be one 'PCNT' frame in each tag. |
||
1344 | // When the counter reaches all one's, one byte is inserted in |
||
1345 | // front of the counter thus making the counter eight bits bigger |
||
1346 | // <Header for 'Play counter', ID: 'PCNT'> |
||
1347 | // Counter $xx xx xx xx (xx ...) |
||
1348 | |||
1349 | $parsed_frame['data'] = getid3_lib::BigEndian2Int($parsed_frame['data']); |
||
1350 | return true; |
||
1351 | } |
||
1352 | |||
1353 | if ((($id3v2_major_version >= 3) && ('POPM' == $parsed_frame['frame_name'])) |
||
1354 | || // 4.17 POPM Popularimeter |
||
1355 | ((2 == $id3v2_major_version) && ('POP' == $parsed_frame['frame_name']))) { // 4.18 POP Popularimeter |
||
1356 | |||
1357 | // There may be more than one 'POPM' frame in each tag, |
||
1358 | // but only one with the same email address |
||
1359 | // <Header for 'Popularimeter', ID: 'POPM'> |
||
1360 | // Email to user <text string> $00 |
||
1361 | // Rating $xx |
||
1362 | // Counter $xx xx xx xx (xx ...) |
||
1363 | |||
1364 | $frame_offset = 0; |
||
1365 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1366 | $frame_email_address = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1367 | if (0 === ord($frame_email_address)) { |
||
1368 | $frame_email_address = ''; |
||
1369 | } |
||
1370 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1371 | $frame_rating = ord($parsed_frame['data']{$frame_offset++}); |
||
1372 | $parsed_frame['data'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset)); |
||
1373 | $parsed_frame['email'] = $frame_email_address; |
||
1374 | $parsed_frame['rating'] = $frame_rating; |
||
1375 | unset($parsed_frame['data']); |
||
1376 | return true; |
||
1377 | } |
||
1378 | |||
1379 | if ((($id3v2_major_version >= 3) && ('RBUF' == $parsed_frame['frame_name'])) |
||
1380 | || // 4.18 RBUF Recommended buffer size |
||
1381 | ((2 == $id3v2_major_version) && ('BUF' == $parsed_frame['frame_name']))) { // 4.19 BUF Recommended buffer size |
||
1382 | |||
1383 | // There may only be one 'RBUF' frame in each tag |
||
1384 | // <Header for 'Recommended buffer size', ID: 'RBUF'> |
||
1385 | // Buffer size $xx xx xx |
||
1386 | // Embedded info flag %0000000x |
||
1387 | // Offset to next tag $xx xx xx xx |
||
1388 | |||
1389 | $frame_offset = 0; |
||
1390 | $parsed_frame['buffersize'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 3)); |
||
1391 | $frame_offset += 3; |
||
1392 | |||
1393 | $frame_embeddedinfoflags = getid3_lib::BigEndian2Bin($parsed_frame['data']{$frame_offset++}); |
||
1394 | $parsed_frame['flags']['embededinfo'] = (bool)substr($frame_embeddedinfoflags, 7, 1); |
||
1395 | $parsed_frame['nexttagoffset'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 4)); |
||
1396 | unset($parsed_frame['data']); |
||
1397 | return true; |
||
1398 | } |
||
1399 | |||
1400 | if ((2 == $id3v2_major_version) && ('CRM' == $parsed_frame['frame_name'])) { // 4.20 Encrypted meta frame (ID3v2.2 only) |
||
1401 | |||
1402 | // There may be more than one 'CRM' frame in a tag, |
||
1403 | // but only one with the same 'owner identifier' |
||
1404 | // <Header for 'Encrypted meta frame', ID: 'CRM'> |
||
1405 | // Owner identifier <textstring> $00 (00) |
||
1406 | // Content/explanation <textstring> $00 (00) |
||
1407 | // Encrypted datablock <binary data> |
||
1408 | |||
1409 | $frame_offset = 0; |
||
1410 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1411 | $frame_owner_id = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1412 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1413 | |||
1414 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1415 | $frame_description = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1416 | if (0 === ord($frame_description)) { |
||
1417 | $frame_description = ''; |
||
1418 | } |
||
1419 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1420 | |||
1421 | $parsed_frame['ownerid'] = $frame_owner_id; |
||
1422 | $parsed_frame['data'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
1423 | $parsed_frame['description'] = $frame_description; |
||
1424 | unset($parsed_frame['data']); |
||
1425 | return true; |
||
1426 | } |
||
1427 | |||
1428 | if ((($id3v2_major_version >= 3) && ('AENC' == $parsed_frame['frame_name'])) |
||
1429 | || // 4.19 AENC Audio encryption |
||
1430 | ((2 == $id3v2_major_version) && ('CRA' == $parsed_frame['frame_name']))) { // 4.21 CRA Audio encryption |
||
1431 | |||
1432 | // There may be more than one 'AENC' frames in a tag, |
||
1433 | // but only one with the same 'Owner identifier' |
||
1434 | // <Header for 'Audio encryption', ID: 'AENC'> |
||
1435 | // Owner identifier <text string> $00 |
||
1436 | // Preview start $xx xx |
||
1437 | // Preview length $xx xx |
||
1438 | // Encryption info <binary data> |
||
1439 | |||
1440 | $frame_offset = 0; |
||
1441 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1442 | $frame_owner_id = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1443 | if (0 === ord($frame_owner_id)) { |
||
1444 | '' == $frame_owner_id; |
||
1445 | } |
||
1446 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1447 | $parsed_frame['ownerid'] = $frame_owner_id; |
||
1448 | $parsed_frame['previewstart'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 2)); |
||
1449 | $frame_offset += 2; |
||
1450 | $parsed_frame['previewlength'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 2)); |
||
1451 | $frame_offset += 2; |
||
1452 | $parsed_frame['encryptioninfo'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
1453 | unset($parsed_frame['data']); |
||
1454 | return true; |
||
1455 | } |
||
1456 | |||
1457 | if ((($id3v2_major_version >= 3) && ('LINK' == $parsed_frame['frame_name'])) |
||
1458 | || // 4.20 LINK Linked information |
||
1459 | ((2 == $id3v2_major_version) && ('LNK' == $parsed_frame['frame_name']))) { // 4.22 LNK Linked information |
||
1460 | |||
1461 | // There may be more than one 'LINK' frame in a tag, |
||
1462 | // but only one with the same contents |
||
1463 | // <Header for 'Linked information', ID: 'LINK'> |
||
1464 | // ID3v2.3+ => Frame identifier $xx xx xx xx |
||
1465 | // ID3v2.2 => Frame identifier $xx xx xx |
||
1466 | // URL <text string> $00 |
||
1467 | // ID and additional data <text string(s)> |
||
1468 | |||
1469 | $frame_offset = 0; |
||
1470 | if (2 == $id3v2_major_version) { |
||
1471 | $parsed_frame['frameid'] = substr($parsed_frame['data'], $frame_offset, 3); |
||
1472 | $frame_offset += 3; |
||
1473 | } else { |
||
1474 | $parsed_frame['frameid'] = substr($parsed_frame['data'], $frame_offset, 4); |
||
1475 | $frame_offset += 4; |
||
1476 | } |
||
1477 | |||
1478 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1479 | $frame_url = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1480 | if (0 === ord($frame_url)) { |
||
1481 | $frame_url = ''; |
||
1482 | } |
||
1483 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1484 | $parsed_frame['url'] = $frame_url; |
||
1485 | |||
1486 | $parsed_frame['additionaldata'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
1487 | if (!empty($parsed_frame['framenameshort']) && $parsed_frame['url']) { |
||
1488 | $getid3->info['id3v2']['comments'][$parsed_frame['framenameshort']][] = utf8_encode($parsed_frame['url']); |
||
1489 | } |
||
1490 | unset($parsed_frame['data']); |
||
1491 | return true; |
||
1492 | } |
||
1493 | |||
1494 | if (($id3v2_major_version >= 3) && ('POSS' == $parsed_frame['frame_name'])) { // 4.21 POSS Position synchronisation frame (ID3v2.3+ only) |
||
1495 | |||
1496 | // There may only be one 'POSS' frame in each tag |
||
1497 | // <Head for 'Position synchronisation', ID: 'POSS'> |
||
1498 | // Time stamp format $xx |
||
1499 | // Position $xx (xx ...) |
||
1500 | |||
1501 | $frame_offset = 0; |
||
1502 | $parsed_frame['timestampformat'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1503 | $parsed_frame['position'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset)); |
||
1504 | unset($parsed_frame['data']); |
||
1505 | return true; |
||
1506 | } |
||
1507 | |||
1508 | if (($id3v2_major_version >= 3) && ('USER' == $parsed_frame['frame_name'])) { // 4.22 USER Terms of use (ID3v2.3+ only) |
||
1509 | |||
1510 | // There may be more than one 'Terms of use' frame in a tag, |
||
1511 | // but only one with the same 'Language' |
||
1512 | // <Header for 'Terms of use frame', ID: 'USER'> |
||
1513 | // Text encoding $xx |
||
1514 | // Language $xx xx xx |
||
1515 | // The actual text <text string according to encoding> |
||
1516 | |||
1517 | $frame_offset = 0; |
||
1518 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
1519 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
1520 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
1521 | } |
||
1522 | $frame_language = substr($parsed_frame['data'], $frame_offset, 3); |
||
1523 | $frame_offset += 3; |
||
1524 | $parsed_frame['language'] = $frame_language; |
||
1525 | $parsed_frame['languagename'] = getid3_id3v2::LanguageLookup($frame_language, false); |
||
1526 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
1527 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
1528 | |||
1529 | $parsed_frame['data'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
1530 | if (!empty($parsed_frame['framenameshort']) && !empty($parsed_frame['data'])) { |
||
1531 | $getid3->info['id3v2']['comments'][$parsed_frame['framenameshort']][] = $getid3->iconv($parsed_frame['encoding'], 'UTF-8', $parsed_frame['data']); |
||
1532 | } |
||
1533 | unset($parsed_frame['data']); |
||
1534 | return true; |
||
1535 | } |
||
1536 | |||
1537 | if (($id3v2_major_version >= 3) && ('OWNE' == $parsed_frame['frame_name'])) { // 4.23 OWNE Ownership frame (ID3v2.3+ only) |
||
1538 | |||
1539 | // There may only be one 'OWNE' frame in a tag |
||
1540 | // <Header for 'Ownership frame', ID: 'OWNE'> |
||
1541 | // Text encoding $xx |
||
1542 | // Price paid <text string> $00 |
||
1543 | // Date of purch. <text string> |
||
1544 | // Seller <text string according to encoding> |
||
1545 | |||
1546 | $frame_offset = 0; |
||
1547 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
1548 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
1549 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
1550 | } |
||
1551 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
1552 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
1553 | |||
1554 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1555 | $frame_pricepaid = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1556 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1557 | |||
1558 | $parsed_frame['pricepaid']['currencyid'] = substr($frame_pricepaid, 0, 3); |
||
1559 | $parsed_frame['pricepaid']['currency'] = getid3_id3v2::LookupCurrencyUnits($parsed_frame['pricepaid']['currencyid']); |
||
1560 | $parsed_frame['pricepaid']['value'] = substr($frame_pricepaid, 3); |
||
1561 | |||
1562 | $parsed_frame['purchasedate'] = substr($parsed_frame['data'], $frame_offset, 8); |
||
1563 | if (!getid3_id3v2::IsValidDateStampString($parsed_frame['purchasedate'])) { |
||
1564 | $parsed_frame['purchasedateunix'] = gmmktime(0, 0, 0, substr($parsed_frame['purchasedate'], 4, 2), substr($parsed_frame['purchasedate'], 6, 2), substr($parsed_frame['purchasedate'], 0, 4)); |
||
1565 | } |
||
1566 | $frame_offset += 8; |
||
1567 | |||
1568 | $parsed_frame['seller'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
1569 | unset($parsed_frame['data']); |
||
1570 | return true; |
||
1571 | } |
||
1572 | |||
1573 | if (($id3v2_major_version >= 3) && ('COMR' == $parsed_frame['frame_name'])) { // 4.24 COMR Commercial frame (ID3v2.3+ only) |
||
1574 | |||
1575 | // There may be more than one 'commercial frame' in a tag, |
||
1576 | // but no two may be identical |
||
1577 | // <Header for 'Commercial frame', ID: 'COMR'> |
||
1578 | // Text encoding $xx |
||
1579 | // Price string <text string> $00 |
||
1580 | // Valid until <text string> |
||
1581 | // Contact URL <text string> $00 |
||
1582 | // Received as $xx |
||
1583 | // Name of seller <text string according to encoding> $00 (00) |
||
1584 | // Description <text string according to encoding> $00 (00) |
||
1585 | // Picture MIME type <string> $00 |
||
1586 | // Seller logo <binary data> |
||
1587 | |||
1588 | $frame_offset = 0; |
||
1589 | $frame_text_encoding = ord($parsed_frame['data']{$frame_offset++}); |
||
1590 | if ((($id3v2_major_version <= 3) && ($frame_text_encoding > 1)) || ((4 == $id3v2_major_version) && ($frame_text_encoding > 3))) { |
||
1591 | $getid3->warning('Invalid text encoding byte (' . $frame_text_encoding . ') in frame "' . $parsed_frame['frame_name'] . '" - defaulting to ISO-8859-1 encoding'); |
||
1592 | } |
||
1593 | |||
1594 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1595 | $frame_price_string = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1596 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1597 | $frame_rawpricearray = explode('/', $frame_price_string); |
||
1598 | foreach ($frame_rawpricearray as $key => $val) { |
||
1599 | $frame_currencyid = substr($val, 0, 3); |
||
1600 | $parsed_frame['price'][$frame_currencyid]['currency'] = getid3_id3v2::LookupCurrencyUnits($frame_currencyid); |
||
1601 | $parsed_frame['price'][$frame_currencyid]['value'] = substr($val, 3); |
||
1602 | } |
||
1603 | |||
1604 | $frame_date_string = substr($parsed_frame['data'], $frame_offset, 8); |
||
1605 | $frame_offset += 8; |
||
1606 | |||
1607 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1608 | $frame_contacturl = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1609 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1610 | |||
1611 | $frame_received_as_id = ord($parsed_frame['data']{$frame_offset++}); |
||
1612 | |||
1613 | $frame_terminator_pos = @strpos($parsed_frame['data'], getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding), $frame_offset); |
||
1614 | if (0 === ord(substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
1615 | $frame_terminator_pos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
1616 | } |
||
1617 | |||
1618 | $frame_sellername = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1619 | if (0 === ord($frame_sellername)) { |
||
1620 | $frame_sellername = ''; |
||
1621 | } |
||
1622 | |||
1623 | $frame_offset = $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)); |
||
1624 | |||
1625 | $frame_terminator_pos = @strpos($parsed_frame['data'], getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding), $frame_offset); |
||
1626 | if (0 === ord(substr($parsed_frame['data'], $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)), 1))) { |
||
1627 | $frame_terminator_pos++; // @strpos() fooled because 2nd byte of Unicode chars are often 0x00 |
||
1628 | } |
||
1629 | |||
1630 | $frame_description = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1631 | if (0 === ord($frame_description)) { |
||
1632 | $frame_description = ''; |
||
1633 | } |
||
1634 | |||
1635 | $frame_offset = $frame_terminator_pos + strlen(getid3_id3v2::TextEncodingTerminatorLookup($frame_text_encoding)); |
||
1636 | |||
1637 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1638 | $frame_mimetype = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1639 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1640 | |||
1641 | $frame_sellerlogo = substr($parsed_frame['data'], $frame_offset); |
||
1642 | |||
1643 | $parsed_frame['encodingid'] = $frame_text_encoding; |
||
1644 | $parsed_frame['encoding'] = $this->TextEncodingNameLookup($frame_text_encoding); |
||
1645 | |||
1646 | $parsed_frame['pricevaliduntil'] = $frame_date_string; |
||
1647 | $parsed_frame['contacturl'] = $frame_contacturl; |
||
1648 | $parsed_frame['receivedasid'] = $frame_received_as_id; |
||
1649 | $parsed_frame['receivedas'] = getid3_id3v2::COMRReceivedAsLookup($frame_received_as_id); |
||
1650 | $parsed_frame['sellername'] = $frame_sellername; |
||
1651 | $parsed_frame['description'] = $frame_description; |
||
1652 | $parsed_frame['mime'] = $frame_mimetype; |
||
1653 | $parsed_frame['logo'] = $frame_sellerlogo; |
||
1654 | unset($parsed_frame['data']); |
||
1655 | } |
||
1656 | |||
1657 | if (($id3v2_major_version >= 3) && ('ENCR' == $parsed_frame['frame_name'])) { // 4.25 ENCR Encryption method registration (ID3v2.3+ only) |
||
1658 | |||
1659 | // There may be several 'ENCR' frames in a tag, |
||
1660 | // but only one containing the same symbol |
||
1661 | // and only one containing the same owner identifier |
||
1662 | // <Header for 'Encryption method registration', ID: 'ENCR'> |
||
1663 | // Owner identifier <text string> $00 |
||
1664 | // Method symbol $xx |
||
1665 | // Encryption data <binary data> |
||
1666 | |||
1667 | $frame_offset = 0; |
||
1668 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1669 | $frame_owner_id = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1670 | if (0 === ord($frame_owner_id)) { |
||
1671 | $frame_owner_id = ''; |
||
1672 | } |
||
1673 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1674 | |||
1675 | $parsed_frame['ownerid'] = $frame_owner_id; |
||
1676 | $parsed_frame['methodsymbol'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1677 | $parsed_frame['data'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
1678 | return true; |
||
1679 | } |
||
1680 | |||
1681 | if (($id3v2_major_version >= 3) && ('GRID' == $parsed_frame['frame_name'])) { // 4.26 GRID Group identification registration (ID3v2.3+ only) |
||
1682 | |||
1683 | // There may be several 'GRID' frames in a tag, |
||
1684 | // but only one containing the same symbol |
||
1685 | // and only one containing the same owner identifier |
||
1686 | // <Header for 'Group ID registration', ID: 'GRID'> |
||
1687 | // Owner identifier <text string> $00 |
||
1688 | // Group symbol $xx |
||
1689 | // Group dependent data <binary data> |
||
1690 | |||
1691 | $frame_offset = 0; |
||
1692 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1693 | $frame_owner_id = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1694 | if (0 === ord($frame_owner_id)) { |
||
1695 | $frame_owner_id = ''; |
||
1696 | } |
||
1697 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1698 | |||
1699 | $parsed_frame['ownerid'] = $frame_owner_id; |
||
1700 | $parsed_frame['groupsymbol'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1701 | $parsed_frame['data'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
1702 | return true; |
||
1703 | } |
||
1704 | |||
1705 | if (($id3v2_major_version >= 3) && ('PRIV' == $parsed_frame['frame_name'])) { // 4.27 PRIV Private frame (ID3v2.3+ only) |
||
1706 | |||
1707 | // The tag may contain more than one 'PRIV' frame |
||
1708 | // but only with different contents |
||
1709 | // <Header for 'Private frame', ID: 'PRIV'> |
||
1710 | // Owner identifier <text string> $00 |
||
1711 | // The private data <binary data> |
||
1712 | |||
1713 | $frame_offset = 0; |
||
1714 | $frame_terminator_pos = @strpos($parsed_frame['data'], "\x00", $frame_offset); |
||
1715 | $frame_owner_id = substr($parsed_frame['data'], $frame_offset, $frame_terminator_pos - $frame_offset); |
||
1716 | if (0 === ord($frame_owner_id)) { |
||
1717 | $frame_owner_id = ''; |
||
1718 | } |
||
1719 | $frame_offset = $frame_terminator_pos + strlen("\x00"); |
||
1720 | |||
1721 | $parsed_frame['ownerid'] = $frame_owner_id; |
||
1722 | $parsed_frame['data'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
1723 | return true; |
||
1724 | } |
||
1725 | |||
1726 | if (($id3v2_major_version >= 4) && ('SIGN' == $parsed_frame['frame_name'])) { // 4.28 SIGN Signature frame (ID3v2.4+ only) |
||
1727 | |||
1728 | // There may be more than one 'signature frame' in a tag, |
||
1729 | // but no two may be identical |
||
1730 | // <Header for 'Signature frame', ID: 'SIGN'> |
||
1731 | // Group symbol $xx |
||
1732 | // Signature <binary data> |
||
1733 | |||
1734 | $frame_offset = 0; |
||
1735 | $parsed_frame['groupsymbol'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1736 | $parsed_frame['data'] = (string)substr($parsed_frame['data'], $frame_offset); |
||
1737 | return true; |
||
1738 | } |
||
1739 | |||
1740 | if (($id3v2_major_version >= 4) && ('SEEK' == $parsed_frame['frame_name'])) { // 4.29 SEEK Seek frame (ID3v2.4+ only) |
||
1741 | |||
1742 | // There may only be one 'seek frame' in a tag |
||
1743 | // <Header for 'Seek frame', ID: 'SEEK'> |
||
1744 | // Minimum offset to next tag $xx xx xx xx |
||
1745 | |||
1746 | $frame_offset = 0; |
||
1747 | $parsed_frame['data'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 4)); |
||
1748 | return true; |
||
1749 | } |
||
1750 | |||
1751 | if (($id3v2_major_version >= 4) && ('ASPI' == $parsed_frame['frame_name'])) { // 4.30 ASPI Audio seek point index (ID3v2.4+ only) |
||
1752 | |||
1753 | // There may only be one 'audio seek point index' frame in a tag |
||
1754 | // <Header for 'Seek Point Index', ID: 'ASPI'> |
||
1755 | // Indexed data start (S) $xx xx xx xx |
||
1756 | // Indexed data length (L) $xx xx xx xx |
||
1757 | // Number of index points (N) $xx xx |
||
1758 | // Bits per index point (b) $xx |
||
1759 | // Then for every index point the following data is included: |
||
1760 | // Fraction at index (Fi) $xx (xx) |
||
1761 | |||
1762 | $frame_offset = 0; |
||
1763 | $parsed_frame['datastart'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 4)); |
||
1764 | $frame_offset += 4; |
||
1765 | $parsed_frame['indexeddatalength'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 4)); |
||
1766 | $frame_offset += 4; |
||
1767 | $parsed_frame['indexpoints'] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 2)); |
||
1768 | $frame_offset += 2; |
||
1769 | $parsed_frame['bitsperpoint'] = ord($parsed_frame['data']{$frame_offset++}); |
||
1770 | $frame_bytesperpoint = ceil($parsed_frame['bitsperpoint'] / 8); |
||
1771 | for ($i = 0; $i < $frame_indexpoints; $i++) { |
||
1772 | $parsed_frame['indexes'][$i] = getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, $frame_bytesperpoint)); |
||
1773 | $frame_offset += $frame_bytesperpoint; |
||
1774 | } |
||
1775 | unset($parsed_frame['data']); |
||
1776 | return true; |
||
1777 | } |
||
1778 | |||
1779 | if (($id3v2_major_version >= 3) && ('RGAD' == $parsed_frame['frame_name'])) { // Replay Gain Adjustment |
||
1780 | |||
1781 | // http://privatewww.essex.ac.uk/~djmrob/replaygain/file_format_id3v2.html |
||
1782 | // There may only be one 'RGAD' frame in a tag |
||
1783 | // <Header for 'Replay Gain Adjustment', ID: 'RGAD'> |
||
1784 | // Peak Amplitude $xx $xx $xx $xx |
||
1785 | // Radio Replay Gain Adjustment %aaabbbcd %dddddddd |
||
1786 | // Audiophile Replay Gain Adjustment %aaabbbcd %dddddddd |
||
1787 | // a - name code |
||
1788 | // b - originator code |
||
1789 | // c - sign bit |
||
1790 | // d - replay gain adjustment |
||
1791 | |||
1792 | $frame_offset = 0; |
||
1793 | |||
1794 | $parsed_frame['peakamplitude'] = (float)getid3_lib::BigEndian2Int(substr($parsed_frame['data'], $frame_offset, 4)); |
||
1795 | $frame_offset += 4; |
||
1796 | |||
1797 | $rg_track_adjustment = decbin(substr($parsed_frame['data'], $frame_offset, 2)); |
||
1798 | $frame_offset += 2; |
||
1799 | |||
1800 | $rg_album_adjustment = decbin(substr($parsed_frame['data'], $frame_offset, 2)); |
||
1801 | $frame_offset += 2; |
||
1802 | |||
1803 | $parsed_frame['raw']['track']['name'] = bindec(substr($rg_track_adjustment, 0, 3)); |
||
1804 | $parsed_frame['raw']['track']['originator'] = bindec(substr($rg_track_adjustment, 3, 3)); |
||
1805 | $parsed_frame['raw']['track']['signbit'] = bindec($rg_track_adjustment[6]); |
||
1806 | $parsed_frame['raw']['track']['adjustment'] = bindec(substr($rg_track_adjustment, 7, 9)); |
||
1807 | $parsed_frame['raw']['album']['name'] = bindec(substr($rg_album_adjustment, 0, 3)); |
||
1808 | $parsed_frame['raw']['album']['originator'] = bindec(substr($rg_album_adjustment, 3, 3)); |
||
1809 | $parsed_frame['raw']['album']['signbit'] = bindec($rg_album_adjustment[6]); |
||
1810 | $parsed_frame['raw']['album']['adjustment'] = bindec(substr($rg_album_adjustment, 7, 9)); |
||
1811 | $parsed_frame['track']['name'] = getid3_lib_replaygain::NameLookup($parsed_frame['raw']['track']['name']); |
||
1812 | $parsed_frame['track']['originator'] = getid3_lib_replaygain::OriginatorLookup($parsed_frame['raw']['track']['originator']); |
||
1813 | $parsed_frame['track']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($parsed_frame['raw']['track']['adjustment'], $parsed_frame['raw']['track']['signbit']); |
||
1814 | $parsed_frame['album']['name'] = getid3_lib_replaygain::NameLookup($parsed_frame['raw']['album']['name']); |
||
1815 | $parsed_frame['album']['originator'] = getid3_lib_replaygain::OriginatorLookup($parsed_frame['raw']['album']['originator']); |
||
1816 | $parsed_frame['album']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($parsed_frame['raw']['album']['adjustment'], $parsed_frame['raw']['album']['signbit']); |
||
1817 | |||
1818 | $getid3->info['replay_gain']['track']['peak'] = $parsed_frame['peakamplitude']; |
||
1819 | $getid3->info['replay_gain']['track']['originator'] = $parsed_frame['track']['originator']; |
||
1820 | $getid3->info['replay_gain']['track']['adjustment'] = $parsed_frame['track']['adjustment']; |
||
1821 | $getid3->info['replay_gain']['album']['originator'] = $parsed_frame['album']['originator']; |
||
1822 | $getid3->info['replay_gain']['album']['adjustment'] = $parsed_frame['album']['adjustment']; |
||
1823 | |||
1824 | unset($parsed_frame['data']); |
||
1825 | return true; |
||
1826 | } |
||
1827 | |||
1828 | return true; |
||
1829 | } |
||
1830 | |||
1831 | private function TextEncodingNameLookup($encoding) |
||
1832 | { |
||
1833 | // Override specification - BRAINDEAD taggers |
||
1834 | if (!$encoding) { |
||
1835 | return $this->getid3->encoding_id3v2; |
||
1836 | } |
||
1837 | |||
1838 | // http://www.id3.org/id3v2.4.0-structure.txt |
||
1839 | static $lookup = [ |
||
1840 | 0 => 'ISO-8859-1', |
||
1841 | 1 => 'UTF-16', |
||
1842 | 2 => 'UTF-16BE', |
||
1843 | 3 => 'UTF-8', |
||
1844 | 255 => 'UTF-16BE' |
||
1845 | ]; |
||
1846 | |||
1847 | return (isset($lookup[$encoding]) ? $lookup[$encoding] : 'ISO-8859-1'); |
||
1848 | } |
||
1849 | |||
1850 | public static function ParseID3v2GenreString($genre_string) |
||
1851 | { |
||
1852 | // Parse genres into arrays of genreName and genreID |
||
1853 | // ID3v2.2.x, ID3v2.3.x: '(21)' or '(4)Eurodisco' or '(51)(39)' or '(55)((I think...)' |
||
1854 | // ID3v2.4.x: '21' $00 'Eurodisco' $00 |
||
1855 | |||
1856 | $genre_string = trim($genre_string); |
||
1857 | $return_array = []; |
||
1858 | if (false !== strpos($genre_string, "\x00")) { |
||
1859 | $unprocessed = trim($genre_string); // trailing nulls will cause an infinite loop. |
||
1860 | $genre_string = ''; |
||
1861 | while (false !== strpos($unprocessed, "\x00")) { |
||
1862 | // convert null-seperated v2.4-format into v2.3 ()-seperated format |
||
1863 | $end_pos = strpos($unprocessed, "\x00"); |
||
1864 | $genre_string .= '(' . substr($unprocessed, 0, $end_pos) . ')'; |
||
1865 | $unprocessed = substr($unprocessed, $end_pos + 1); |
||
1866 | } |
||
1867 | unset($unprocessed); |
||
1868 | } |
||
1869 | if (getid3_id3v1::LookupGenreID($genre_string)) { |
||
1870 | $return_array['genre'][] = $genre_string; |
||
1871 | } else { |
||
1872 | while (false !== strpos($genre_string, '(')) { |
||
1873 | $start_pos = strpos($genre_string, '('); |
||
1874 | $end_pos = strpos($genre_string, ')'); |
||
1875 | if ('(' == substr($genre_string, $start_pos + 1, 1)) { |
||
1876 | $genre_string = substr($genre_string, 0, $start_pos) . substr($genre_string, $start_pos + 1); |
||
1877 | $end_pos--; |
||
1878 | } |
||
1879 | $element = substr($genre_string, $start_pos + 1, $end_pos - ($start_pos + 1)); |
||
1880 | $genre_string = substr($genre_string, 0, $start_pos) . substr($genre_string, $end_pos + 1); |
||
1881 | |||
1882 | if (getid3_id3v1::LookupGenreName($element)) { // $element is a valid genre id/abbreviation |
||
1883 | |||
1884 | if (empty($return_array['genre']) || !in_array(getid3_id3v1::LookupGenreName($element), $return_array['genre'])) { // avoid duplicate entires |
||
1885 | $return_array['genre'][] = getid3_id3v1::LookupGenreName($element); |
||
1886 | } |
||
1887 | } else { |
||
1888 | if (empty($return_array['genre']) || !in_array($element, $return_array['genre'])) { // avoid duplicate entires |
||
1889 | $return_array['genre'][] = $element; |
||
1890 | } |
||
1891 | } |
||
1892 | } |
||
1893 | } |
||
1894 | if ($genre_string) { |
||
1895 | if (empty($return_array['genre']) || !in_array($genre_string, $return_array['genre'])) { // avoid duplicate entires |
||
1896 | $return_array['genre'][] = $genre_string; |
||
1897 | } |
||
1898 | } |
||
1899 | |||
1900 | return $return_array; |
||
1901 | } |
||
1902 | |||
1903 | public static function LookupCurrencyUnits($currency_id) |
||
1904 | { |
||
1905 | static $lookup = [ |
||
1906 | 'AED' => 'Dirhams', |
||
1907 | 'AFA' => 'Afghanis', |
||
1908 | 'ALL' => 'Leke', |
||
1909 | 'AMD' => 'Drams', |
||
1910 | 'ANG' => 'Guilders', |
||
1911 | 'AOA' => 'Kwanza', |
||
1912 | 'ARS' => 'Pesos', |
||
1913 | 'ATS' => 'Schillings', |
||
1914 | 'AUD' => 'Dollars', |
||
1915 | 'AWG' => 'Guilders', |
||
1916 | 'AZM' => 'Manats', |
||
1917 | 'BAM' => 'Convertible Marka', |
||
1918 | 'BBD' => 'Dollars', |
||
1919 | 'BDT' => 'Taka', |
||
1920 | 'BEF' => 'Francs', |
||
1921 | 'BGL' => 'Leva', |
||
1922 | 'BHD' => 'Dinars', |
||
1923 | 'BIF' => 'Francs', |
||
1924 | 'BMD' => 'Dollars', |
||
1925 | 'BND' => 'Dollars', |
||
1926 | 'BOB' => 'Bolivianos', |
||
1927 | 'BRL' => 'Brazil Real', |
||
1928 | 'BSD' => 'Dollars', |
||
1929 | 'BTN' => 'Ngultrum', |
||
1930 | 'BWP' => 'Pulas', |
||
1931 | 'BYR' => 'Rubles', |
||
1932 | 'BZD' => 'Dollars', |
||
1933 | 'CAD' => 'Dollars', |
||
1934 | 'CDF' => 'Congolese Francs', |
||
1935 | 'CHF' => 'Francs', |
||
1936 | 'CLP' => 'Pesos', |
||
1937 | 'CNY' => 'Yuan Renminbi', |
||
1938 | 'COP' => 'Pesos', |
||
1939 | 'CRC' => 'Colones', |
||
1940 | 'CUP' => 'Pesos', |
||
1941 | 'CVE' => 'Escudos', |
||
1942 | 'CYP' => 'Pounds', |
||
1943 | 'CZK' => 'Koruny', |
||
1944 | 'DEM' => 'Deutsche Marks', |
||
1945 | 'DJF' => 'Francs', |
||
1946 | 'DKK' => 'Kroner', |
||
1947 | 'DOP' => 'Pesos', |
||
1948 | 'DZD' => 'Algeria Dinars', |
||
1949 | 'EEK' => 'Krooni', |
||
1950 | 'EGP' => 'Pounds', |
||
1951 | 'ERN' => 'Nakfa', |
||
1952 | 'ESP' => 'Pesetas', |
||
1953 | 'ETB' => 'Birr', |
||
1954 | 'EUR' => 'Euro', |
||
1955 | 'FIM' => 'Markkaa', |
||
1956 | 'FJD' => 'Dollars', |
||
1957 | 'FKP' => 'Pounds', |
||
1958 | 'FRF' => 'Francs', |
||
1959 | 'GBP' => 'Pounds', |
||
1960 | 'GEL' => 'Lari', |
||
1961 | 'GGP' => 'Pounds', |
||
1962 | 'GHC' => 'Cedis', |
||
1963 | 'GIP' => 'Pounds', |
||
1964 | 'GMD' => 'Dalasi', |
||
1965 | 'GNF' => 'Francs', |
||
1966 | 'GRD' => 'Drachmae', |
||
1967 | 'GTQ' => 'Quetzales', |
||
1968 | 'GYD' => 'Dollars', |
||
1969 | 'HKD' => 'Dollars', |
||
1970 | 'HNL' => 'Lempiras', |
||
1971 | 'HRK' => 'Kuna', |
||
1972 | 'HTG' => 'Gourdes', |
||
1973 | 'HUF' => 'Forints', |
||
1974 | 'IDR' => 'Rupiahs', |
||
1975 | 'IEP' => 'Pounds', |
||
1976 | 'ILS' => 'New Shekels', |
||
1977 | 'IMP' => 'Pounds', |
||
1978 | 'INR' => 'Rupees', |
||
1979 | 'IQD' => 'Dinars', |
||
1980 | 'IRR' => 'Rials', |
||
1981 | 'ISK' => 'Kronur', |
||
1982 | 'ITL' => 'Lire', |
||
1983 | 'JEP' => 'Pounds', |
||
1984 | 'JMD' => 'Dollars', |
||
1985 | 'JOD' => 'Dinars', |
||
1986 | 'JPY' => 'Yen', |
||
1987 | 'KES' => 'Shillings', |
||
1988 | 'KGS' => 'Soms', |
||
1989 | 'KHR' => 'Riels', |
||
1990 | 'KMF' => 'Francs', |
||
1991 | 'KPW' => 'Won', |
||
1992 | 'KWD' => 'Dinars', |
||
1993 | 'KYD' => 'Dollars', |
||
1994 | 'KZT' => 'Tenge', |
||
1995 | 'LAK' => 'Kips', |
||
1996 | 'LBP' => 'Pounds', |
||
1997 | 'LKR' => 'Rupees', |
||
1998 | 'LRD' => 'Dollars', |
||
1999 | 'LSL' => 'Maloti', |
||
2000 | 'LTL' => 'Litai', |
||
2001 | 'LUF' => 'Francs', |
||
2002 | 'LVL' => 'Lati', |
||
2003 | 'LYD' => 'Dinars', |
||
2004 | 'MAD' => 'Dirhams', |
||
2005 | 'MDL' => 'Lei', |
||
2006 | 'MGF' => 'Malagasy Francs', |
||
2007 | 'MKD' => 'Denars', |
||
2008 | 'MMK' => 'Kyats', |
||
2009 | 'MNT' => 'Tugriks', |
||
2010 | 'MOP' => 'Patacas', |
||
2011 | 'MRO' => 'Ouguiyas', |
||
2012 | 'MTL' => 'Liri', |
||
2013 | 'MUR' => 'Rupees', |
||
2014 | 'MVR' => 'Rufiyaa', |
||
2015 | 'MWK' => 'Kwachas', |
||
2016 | 'MXN' => 'Pesos', |
||
2017 | 'MYR' => 'Ringgits', |
||
2018 | 'MZM' => 'Meticais', |
||
2019 | 'NAD' => 'Dollars', |
||
2020 | 'NGN' => 'Nairas', |
||
2021 | 'NIO' => 'Gold Cordobas', |
||
2022 | 'NLG' => 'Guilders', |
||
2023 | 'NOK' => 'Krone', |
||
2024 | 'NPR' => 'Nepal Rupees', |
||
2025 | 'NZD' => 'Dollars', |
||
2026 | 'OMR' => 'Rials', |
||
2027 | 'PAB' => 'Balboa', |
||
2028 | 'PEN' => 'Nuevos Soles', |
||
2029 | 'PGK' => 'Kina', |
||
2030 | 'PHP' => 'Pesos', |
||
2031 | 'PKR' => 'Rupees', |
||
2032 | 'PLN' => 'Zlotych', |
||
2033 | 'PTE' => 'Escudos', |
||
2034 | 'PYG' => 'Guarani', |
||
2035 | 'QAR' => 'Rials', |
||
2036 | 'ROL' => 'Lei', |
||
2037 | 'RUR' => 'Rubles', |
||
2038 | 'RWF' => 'Rwanda Francs', |
||
2039 | 'SAR' => 'Riyals', |
||
2040 | 'SBD' => 'Dollars', |
||
2041 | 'SCR' => 'Rupees', |
||
2042 | 'SDD' => 'Dinars', |
||
2043 | 'SEK' => 'Kronor', |
||
2044 | 'SGD' => 'Dollars', |
||
2045 | 'SHP' => 'Pounds', |
||
2046 | 'SIT' => 'Tolars', |
||
2047 | 'SKK' => 'Koruny', |
||
2048 | 'SLL' => 'Leones', |
||
2049 | 'SOS' => 'Shillings', |
||
2050 | 'SPL' => 'Luigini', |
||
2051 | 'SRG' => 'Guilders', |
||
2052 | 'STD' => 'Dobras', |
||
2053 | 'SVC' => 'Colones', |
||
2054 | 'SYP' => 'Pounds', |
||
2055 | 'SZL' => 'Emalangeni', |
||
2056 | 'THB' => 'Baht', |
||
2057 | 'TJR' => 'Rubles', |
||
2058 | 'TMM' => 'Manats', |
||
2059 | 'TND' => 'Dinars', |
||
2060 | 'TOP' => 'Pa\'anga', |
||
2061 | 'TRL' => 'Liras', |
||
2062 | 'TTD' => 'Dollars', |
||
2063 | 'TVD' => 'Tuvalu Dollars', |
||
2064 | 'TWD' => 'New Dollars', |
||
2065 | 'TZS' => 'Shillings', |
||
2066 | 'UAH' => 'Hryvnia', |
||
2067 | 'UGX' => 'Shillings', |
||
2068 | 'USD' => 'Dollars', |
||
2069 | 'UYU' => 'Pesos', |
||
2070 | 'UZS' => 'Sums', |
||
2071 | 'VAL' => 'Lire', |
||
2072 | 'VEB' => 'Bolivares', |
||
2073 | 'VND' => 'Dong', |
||
2074 | 'VUV' => 'Vatu', |
||
2075 | 'WST' => 'Tala', |
||
2076 | 'XAF' => 'Francs', |
||
2077 | 'XAG' => 'Ounces', |
||
2078 | 'XAU' => 'Ounces', |
||
2079 | 'XCD' => 'Dollars', |
||
2080 | 'XDR' => 'Special Drawing Rights', |
||
2081 | 'XPD' => 'Ounces', |
||
2082 | 'XPF' => 'Francs', |
||
2083 | 'XPT' => 'Ounces', |
||
2084 | 'YER' => 'Rials', |
||
2085 | 'YUM' => 'New Dinars', |
||
2086 | 'ZAR' => 'Rand', |
||
2087 | 'ZMK' => 'Kwacha', |
||
2088 | 'ZWD' => 'Zimbabwe Dollars' |
||
2089 | ]; |
||
2090 | |||
2091 | return @$lookup[$currency_id]; |
||
2092 | } |
||
2093 | |||
2094 | public static function LookupCurrencyCountry($currency_id) |
||
2095 | { |
||
2096 | static $lookup = [ |
||
2097 | 'AED' => 'United Arab Emirates', |
||
2098 | 'AFA' => 'Afghanistan', |
||
2099 | 'ALL' => 'Albania', |
||
2100 | 'AMD' => 'Armenia', |
||
2101 | 'ANG' => 'Netherlands Antilles', |
||
2102 | 'AOA' => 'Angola', |
||
2103 | 'ARS' => 'Argentina', |
||
2104 | 'ATS' => 'Austria', |
||
2105 | 'AUD' => 'Australia', |
||
2106 | 'AWG' => 'Aruba', |
||
2107 | 'AZM' => 'Azerbaijan', |
||
2108 | 'BAM' => 'Bosnia and Herzegovina', |
||
2109 | 'BBD' => 'Barbados', |
||
2110 | 'BDT' => 'Bangladesh', |
||
2111 | 'BEF' => 'Belgium', |
||
2112 | 'BGL' => 'Bulgaria', |
||
2113 | 'BHD' => 'Bahrain', |
||
2114 | 'BIF' => 'Burundi', |
||
2115 | 'BMD' => 'Bermuda', |
||
2116 | 'BND' => 'Brunei Darussalam', |
||
2117 | 'BOB' => 'Bolivia', |
||
2118 | 'BRL' => 'Brazil', |
||
2119 | 'BSD' => 'Bahamas', |
||
2120 | 'BTN' => 'Bhutan', |
||
2121 | 'BWP' => 'Botswana', |
||
2122 | 'BYR' => 'Belarus', |
||
2123 | 'BZD' => 'Belize', |
||
2124 | 'CAD' => 'Canada', |
||
2125 | 'CDF' => 'Congo/Kinshasa', |
||
2126 | 'CHF' => 'Switzerland', |
||
2127 | 'CLP' => 'Chile', |
||
2128 | 'CNY' => 'China', |
||
2129 | 'COP' => 'Colombia', |
||
2130 | 'CRC' => 'Costa Rica', |
||
2131 | 'CUP' => 'Cuba', |
||
2132 | 'CVE' => 'Cape Verde', |
||
2133 | 'CYP' => 'Cyprus', |
||
2134 | 'CZK' => 'Czech Republic', |
||
2135 | 'DEM' => 'Germany', |
||
2136 | 'DJF' => 'Djibouti', |
||
2137 | 'DKK' => 'Denmark', |
||
2138 | 'DOP' => 'Dominican Republic', |
||
2139 | 'DZD' => 'Algeria', |
||
2140 | 'EEK' => 'Estonia', |
||
2141 | 'EGP' => 'Egypt', |
||
2142 | 'ERN' => 'Eritrea', |
||
2143 | 'ESP' => 'Spain', |
||
2144 | 'ETB' => 'Ethiopia', |
||
2145 | 'EUR' => 'Euro Member Countries', |
||
2146 | 'FIM' => 'Finland', |
||
2147 | 'FJD' => 'Fiji', |
||
2148 | 'FKP' => 'Falkland Islands (Malvinas)', |
||
2149 | 'FRF' => 'France', |
||
2150 | 'GBP' => 'United Kingdom', |
||
2151 | 'GEL' => 'Georgia', |
||
2152 | 'GGP' => 'Guernsey', |
||
2153 | 'GHC' => 'Ghana', |
||
2154 | 'GIP' => 'Gibraltar', |
||
2155 | 'GMD' => 'Gambia', |
||
2156 | 'GNF' => 'Guinea', |
||
2157 | 'GRD' => 'Greece', |
||
2158 | 'GTQ' => 'Guatemala', |
||
2159 | 'GYD' => 'Guyana', |
||
2160 | 'HKD' => 'Hong Kong', |
||
2161 | 'HNL' => 'Honduras', |
||
2162 | 'HRK' => 'Croatia', |
||
2163 | 'HTG' => 'Haiti', |
||
2164 | 'HUF' => 'Hungary', |
||
2165 | 'IDR' => 'Indonesia', |
||
2166 | 'IEP' => 'Ireland (Eire)', |
||
2167 | 'ILS' => 'Israel', |
||
2168 | 'IMP' => 'Isle of Man', |
||
2169 | 'INR' => 'India', |
||
2170 | 'IQD' => 'Iraq', |
||
2171 | 'IRR' => 'Iran', |
||
2172 | 'ISK' => 'Iceland', |
||
2173 | 'ITL' => 'Italy', |
||
2174 | 'JEP' => 'Jersey', |
||
2175 | 'JMD' => 'Jamaica', |
||
2176 | 'JOD' => 'Jordan', |
||
2177 | 'JPY' => 'Japan', |
||
2178 | 'KES' => 'Kenya', |
||
2179 | 'KGS' => 'Kyrgyzstan', |
||
2180 | 'KHR' => 'Cambodia', |
||
2181 | 'KMF' => 'Comoros', |
||
2182 | 'KPW' => 'Korea', |
||
2183 | 'KWD' => 'Kuwait', |
||
2184 | 'KYD' => 'Cayman Islands', |
||
2185 | 'KZT' => 'Kazakstan', |
||
2186 | 'LAK' => 'Laos', |
||
2187 | 'LBP' => 'Lebanon', |
||
2188 | 'LKR' => 'Sri Lanka', |
||
2189 | 'LRD' => 'Liberia', |
||
2190 | 'LSL' => 'Lesotho', |
||
2191 | 'LTL' => 'Lithuania', |
||
2192 | 'LUF' => 'Luxembourg', |
||
2193 | 'LVL' => 'Latvia', |
||
2194 | 'LYD' => 'Libya', |
||
2195 | 'MAD' => 'Morocco', |
||
2196 | 'MDL' => 'Moldova', |
||
2197 | 'MGF' => 'Madagascar', |
||
2198 | 'MKD' => 'Macedonia', |
||
2199 | 'MMK' => 'Myanmar (Burma)', |
||
2200 | 'MNT' => 'Mongolia', |
||
2201 | 'MOP' => 'Macau', |
||
2202 | 'MRO' => 'Mauritania', |
||
2203 | 'MTL' => 'Malta', |
||
2204 | 'MUR' => 'Mauritius', |
||
2205 | 'MVR' => 'Maldives (Maldive Islands)', |
||
2206 | 'MWK' => 'Malawi', |
||
2207 | 'MXN' => 'Mexico', |
||
2208 | 'MYR' => 'Malaysia', |
||
2209 | 'MZM' => 'Mozambique', |
||
2210 | 'NAD' => 'Namibia', |
||
2211 | 'NGN' => 'Nigeria', |
||
2212 | 'NIO' => 'Nicaragua', |
||
2213 | 'NLG' => 'Netherlands (Holland)', |
||
2214 | 'NOK' => 'Norway', |
||
2215 | 'NPR' => 'Nepal', |
||
2216 | 'NZD' => 'New Zealand', |
||
2217 | 'OMR' => 'Oman', |
||
2218 | 'PAB' => 'Panama', |
||
2219 | 'PEN' => 'Peru', |
||
2220 | 'PGK' => 'Papua New Guinea', |
||
2221 | 'PHP' => 'Philippines', |
||
2222 | 'PKR' => 'Pakistan', |
||
2223 | 'PLN' => 'Poland', |
||
2224 | 'PTE' => 'Portugal', |
||
2225 | 'PYG' => 'Paraguay', |
||
2226 | 'QAR' => 'Qatar', |
||
2227 | 'ROL' => 'Romania', |
||
2228 | 'RUR' => 'Russia', |
||
2229 | 'RWF' => 'Rwanda', |
||
2230 | 'SAR' => 'Saudi Arabia', |
||
2231 | 'SBD' => 'Solomon Islands', |
||
2232 | 'SCR' => 'Seychelles', |
||
2233 | 'SDD' => 'Sudan', |
||
2234 | 'SEK' => 'Sweden', |
||
2235 | 'SGD' => 'Singapore', |
||
2236 | 'SHP' => 'Saint Helena', |
||
2237 | 'SIT' => 'Slovenia', |
||
2238 | 'SKK' => 'Slovakia', |
||
2239 | 'SLL' => 'Sierra Leone', |
||
2240 | 'SOS' => 'Somalia', |
||
2241 | 'SPL' => 'Seborga', |
||
2242 | 'SRG' => 'Suriname', |
||
2243 | 'STD' => 'S�o Tome and Principe', |
||
2244 | 'SVC' => 'El Salvador', |
||
2245 | 'SYP' => 'Syria', |
||
2246 | 'SZL' => 'Swaziland', |
||
2247 | 'THB' => 'Thailand', |
||
2248 | 'TJR' => 'Tajikistan', |
||
2249 | 'TMM' => 'Turkmenistan', |
||
2250 | 'TND' => 'Tunisia', |
||
2251 | 'TOP' => 'Tonga', |
||
2252 | 'TRL' => 'Turkey', |
||
2253 | 'TTD' => 'Trinidad and Tobago', |
||
2254 | 'TVD' => 'Tuvalu', |
||
2255 | 'TWD' => 'Taiwan', |
||
2256 | 'TZS' => 'Tanzania', |
||
2257 | 'UAH' => 'Ukraine', |
||
2258 | 'UGX' => 'Uganda', |
||
2259 | 'USD' => 'United States of America', |
||
2260 | 'UYU' => 'Uruguay', |
||
2261 | 'UZS' => 'Uzbekistan', |
||
2262 | 'VAL' => 'Vatican City', |
||
2263 | 'VEB' => 'Venezuela', |
||
2264 | 'VND' => 'Viet Nam', |
||
2265 | 'VUV' => 'Vanuatu', |
||
2266 | 'WST' => 'Samoa', |
||
2267 | 'XAF' => 'Communaut� Financi�re Africaine', |
||
2268 | 'XAG' => 'Silver', |
||
2269 | 'XAU' => 'Gold', |
||
2270 | 'XCD' => 'East Caribbean', |
||
2271 | 'XDR' => 'International Monetary Fund', |
||
2272 | 'XPD' => 'Palladium', |
||
2273 | 'XPF' => 'Comptoirs Fran�ais du Pacifique', |
||
2274 | 'XPT' => 'Platinum', |
||
2275 | 'YER' => 'Yemen', |
||
2276 | 'YUM' => 'Yugoslavia', |
||
2277 | 'ZAR' => 'South Africa', |
||
2278 | 'ZMK' => 'Zambia', |
||
2279 | 'ZWD' => 'Zimbabwe' |
||
2280 | ]; |
||
2281 | |||
2282 | return @$lookup[$currency_id]; |
||
2283 | } |
||
2284 | |||
2285 | public static function LanguageLookup($language_code, $case_sensitive = false) |
||
2286 | { |
||
2287 | if (!$case_sensitive) { |
||
2288 | $language_code = strtolower($language_code); |
||
2289 | } |
||
2290 | |||
2291 | // http://www.id3.org/id3v2.4.0-structure.txt |
||
2292 | // [4. ID3v2 frame overview] |
||
2293 | // The three byte language field, present in several frames, is used to |
||
2294 | // describe the language of the frame's content, according to ISO-639-2 |
||
2295 | // [ISO-639-2]. The language should be represented in lower case. If the |
||
2296 | // language is not known the string "XXX" should be used. |
||
2297 | |||
2298 | // ISO 639-2 - http://www.id3.org/iso639-2.html |
||
2299 | |||
2300 | static $lookup = [ |
||
2301 | 'XXX' => 'unknown', |
||
2302 | 'xxx' => 'unknown', |
||
2303 | 'aar' => 'Afar', |
||
2304 | 'abk' => 'Abkhazian', |
||
2305 | 'ace' => 'Achinese', |
||
2306 | 'ach' => 'Acoli', |
||
2307 | 'ada' => 'Adangme', |
||
2308 | 'afa' => 'Afro-Asiatic (Other)', |
||
2309 | 'afh' => 'Afrihili', |
||
2310 | 'afr' => 'Afrikaans', |
||
2311 | 'aka' => 'Akan', |
||
2312 | 'akk' => 'Akkadian', |
||
2313 | 'alb' => 'Albanian', |
||
2314 | 'ale' => 'Aleut', |
||
2315 | 'alg' => 'Algonquian Languages', |
||
2316 | 'amh' => 'Amharic', |
||
2317 | 'ang' => 'English, Old (ca. 450-1100)', |
||
2318 | 'apa' => 'Apache Languages', |
||
2319 | 'ara' => 'Arabic', |
||
2320 | 'arc' => 'Aramaic', |
||
2321 | 'arm' => 'Armenian', |
||
2322 | 'arn' => 'Araucanian', |
||
2323 | 'arp' => 'Arapaho', |
||
2324 | 'art' => 'Artificial (Other)', |
||
2325 | 'arw' => 'Arawak', |
||
2326 | 'asm' => 'Assamese', |
||
2327 | 'ath' => 'Athapascan Languages', |
||
2328 | 'ava' => 'Avaric', |
||
2329 | 'ave' => 'Avestan', |
||
2330 | 'awa' => 'Awadhi', |
||
2331 | 'aym' => 'Aymara', |
||
2332 | 'aze' => 'Azerbaijani', |
||
2333 | 'bad' => 'Banda', |
||
2334 | 'bai' => 'Bamileke Languages', |
||
2335 | 'bak' => 'Bashkir', |
||
2336 | 'bal' => 'Baluchi', |
||
2337 | 'bam' => 'Bambara', |
||
2338 | 'ban' => 'Balinese', |
||
2339 | 'baq' => 'Basque', |
||
2340 | 'bas' => 'Basa', |
||
2341 | 'bat' => 'Baltic (Other)', |
||
2342 | 'bej' => 'Beja', |
||
2343 | 'bel' => 'Byelorussian', |
||
2344 | 'bem' => 'Bemba', |
||
2345 | 'ben' => 'Bengali', |
||
2346 | 'ber' => 'Berber (Other)', |
||
2347 | 'bho' => 'Bhojpuri', |
||
2348 | 'bih' => 'Bihari', |
||
2349 | 'bik' => 'Bikol', |
||
2350 | 'bin' => 'Bini', |
||
2351 | 'bis' => 'Bislama', |
||
2352 | 'bla' => 'Siksika', |
||
2353 | 'bnt' => 'Bantu (Other)', |
||
2354 | 'bod' => 'Tibetan', |
||
2355 | 'bra' => 'Braj', |
||
2356 | 'bre' => 'Breton', |
||
2357 | 'bua' => 'Buriat', |
||
2358 | 'bug' => 'Buginese', |
||
2359 | 'bul' => 'Bulgarian', |
||
2360 | 'bur' => 'Burmese', |
||
2361 | 'cad' => 'Caddo', |
||
2362 | 'cai' => 'Central American Indian (Other)', |
||
2363 | 'car' => 'Carib', |
||
2364 | 'cat' => 'Catalan', |
||
2365 | 'cau' => 'Caucasian (Other)', |
||
2366 | 'ceb' => 'Cebuano', |
||
2367 | 'cel' => 'Celtic (Other)', |
||
2368 | 'ces' => 'Czech', |
||
2369 | 'cha' => 'Chamorro', |
||
2370 | 'chb' => 'Chibcha', |
||
2371 | 'che' => 'Chechen', |
||
2372 | 'chg' => 'Chagatai', |
||
2373 | 'chi' => 'Chinese', |
||
2374 | 'chm' => 'Mari', |
||
2375 | 'chn' => 'Chinook jargon', |
||
2376 | 'cho' => 'Choctaw', |
||
2377 | 'chr' => 'Cherokee', |
||
2378 | 'chu' => 'Church Slavic', |
||
2379 | 'chv' => 'Chuvash', |
||
2380 | 'chy' => 'Cheyenne', |
||
2381 | 'cop' => 'Coptic', |
||
2382 | 'cor' => 'Cornish', |
||
2383 | 'cos' => 'Corsican', |
||
2384 | 'cpe' => 'Creoles and Pidgins, English-based (Other)', |
||
2385 | 'cpf' => 'Creoles and Pidgins, French-based (Other)', |
||
2386 | 'cpp' => 'Creoles and Pidgins, Portuguese-based (Other)', |
||
2387 | 'cre' => 'Cree', |
||
2388 | 'crp' => 'Creoles and Pidgins (Other)', |
||
2389 | 'cus' => 'Cushitic (Other)', |
||
2390 | 'cym' => 'Welsh', |
||
2391 | 'cze' => 'Czech', |
||
2392 | 'dak' => 'Dakota', |
||
2393 | 'dan' => 'Danish', |
||
2394 | 'del' => 'Delaware', |
||
2395 | 'deu' => 'German', |
||
2396 | 'din' => 'Dinka', |
||
2397 | 'div' => 'Divehi', |
||
2398 | 'doi' => 'Dogri', |
||
2399 | 'dra' => 'Dravidian (Other)', |
||
2400 | 'dua' => 'Duala', |
||
2401 | 'dum' => 'Dutch, Middle (ca. 1050-1350)', |
||
2402 | 'dut' => 'Dutch', |
||
2403 | 'dyu' => 'Dyula', |
||
2404 | 'dzo' => 'Dzongkha', |
||
2405 | 'efi' => 'Efik', |
||
2406 | 'egy' => 'Egyptian (Ancient)', |
||
2407 | 'eka' => 'Ekajuk', |
||
2408 | 'ell' => 'Greek, Modern (1453-)', |
||
2409 | 'elx' => 'Elamite', |
||
2410 | 'eng' => 'English', |
||
2411 | 'enm' => 'English, Middle (ca. 1100-1500)', |
||
2412 | 'epo' => 'Esperanto', |
||
2413 | 'esk' => 'Eskimo (Other)', |
||
2414 | 'esl' => 'Spanish', |
||
2415 | 'est' => 'Estonian', |
||
2416 | 'eus' => 'Basque', |
||
2417 | 'ewe' => 'Ewe', |
||
2418 | 'ewo' => 'Ewondo', |
||
2419 | 'fan' => 'Fang', |
||
2420 | 'fao' => 'Faroese', |
||
2421 | 'fas' => 'Persian', |
||
2422 | 'fat' => 'Fanti', |
||
2423 | 'fij' => 'Fijian', |
||
2424 | 'fin' => 'Finnish', |
||
2425 | 'fiu' => 'Finno-Ugrian (Other)', |
||
2426 | 'fon' => 'Fon', |
||
2427 | 'fra' => 'French', |
||
2428 | 'fre' => 'French', |
||
2429 | 'frm' => 'French, Middle (ca. 1400-1600)', |
||
2430 | 'fro' => 'French, Old (842- ca. 1400)', |
||
2431 | 'fry' => 'Frisian', |
||
2432 | 'ful' => 'Fulah', |
||
2433 | 'gaa' => 'Ga', |
||
2434 | 'gae' => 'Gaelic (Scots)', |
||
2435 | 'gai' => 'Irish', |
||
2436 | 'gay' => 'Gayo', |
||
2437 | 'gdh' => 'Gaelic (Scots)', |
||
2438 | 'gem' => 'Germanic (Other)', |
||
2439 | 'geo' => 'Georgian', |
||
2440 | 'ger' => 'German', |
||
2441 | 'gez' => 'Geez', |
||
2442 | 'gil' => 'Gilbertese', |
||
2443 | 'glg' => 'Gallegan', |
||
2444 | 'gmh' => 'German, Middle High (ca. 1050-1500)', |
||
2445 | 'goh' => 'German, Old High (ca. 750-1050)', |
||
2446 | 'gon' => 'Gondi', |
||
2447 | 'got' => 'Gothic', |
||
2448 | 'grb' => 'Grebo', |
||
2449 | 'grc' => 'Greek, Ancient (to 1453)', |
||
2450 | 'gre' => 'Greek, Modern (1453-)', |
||
2451 | 'grn' => 'Guarani', |
||
2452 | 'guj' => 'Gujarati', |
||
2453 | 'hai' => 'Haida', |
||
2454 | 'hau' => 'Hausa', |
||
2455 | 'haw' => 'Hawaiian', |
||
2456 | 'heb' => 'Hebrew', |
||
2457 | 'her' => 'Herero', |
||
2458 | 'hil' => 'Hiligaynon', |
||
2459 | 'him' => 'Himachali', |
||
2460 | 'hin' => 'Hindi', |
||
2461 | 'hmo' => 'Hiri Motu', |
||
2462 | 'hun' => 'Hungarian', |
||
2463 | 'hup' => 'Hupa', |
||
2464 | 'hye' => 'Armenian', |
||
2465 | 'iba' => 'Iban', |
||
2466 | 'ibo' => 'Igbo', |
||
2467 | 'ice' => 'Icelandic', |
||
2468 | 'ijo' => 'Ijo', |
||
2469 | 'iku' => 'Inuktitut', |
||
2470 | 'ilo' => 'Iloko', |
||
2471 | 'ina' => 'Interlingua (International Auxiliary language Association)', |
||
2472 | 'inc' => 'Indic (Other)', |
||
2473 | 'ind' => 'Indonesian', |
||
2474 | 'ine' => 'Indo-European (Other)', |
||
2475 | 'ine' => 'Interlingue', |
||
2476 | 'ipk' => 'Inupiak', |
||
2477 | 'ira' => 'Iranian (Other)', |
||
2478 | 'iri' => 'Irish', |
||
2479 | 'iro' => 'Iroquoian uages', |
||
2480 | 'isl' => 'Icelandic', |
||
2481 | 'ita' => 'Italian', |
||
2482 | 'jav' => 'Javanese', |
||
2483 | 'jaw' => 'Javanese', |
||
2484 | 'jpn' => 'Japanese', |
||
2485 | 'jpr' => 'Judeo-Persian', |
||
2486 | 'jrb' => 'Judeo-Arabic', |
||
2487 | 'kaa' => 'Kara-Kalpak', |
||
2488 | 'kab' => 'Kabyle', |
||
2489 | 'kac' => 'Kachin', |
||
2490 | 'kal' => 'Greenlandic', |
||
2491 | 'kam' => 'Kamba', |
||
2492 | 'kan' => 'Kannada', |
||
2493 | 'kar' => 'Karen', |
||
2494 | 'kas' => 'Kashmiri', |
||
2495 | 'kat' => 'Georgian', |
||
2496 | 'kau' => 'Kanuri', |
||
2497 | 'kaw' => 'Kawi', |
||
2498 | 'kaz' => 'Kazakh', |
||
2499 | 'kha' => 'Khasi', |
||
2500 | 'khi' => 'Khoisan (Other)', |
||
2501 | 'khm' => 'Khmer', |
||
2502 | 'kho' => 'Khotanese', |
||
2503 | 'kik' => 'Kikuyu', |
||
2504 | 'kin' => 'Kinyarwanda', |
||
2505 | 'kir' => 'Kirghiz', |
||
2506 | 'kok' => 'Konkani', |
||
2507 | 'kom' => 'Komi', |
||
2508 | 'kon' => 'Kongo', |
||
2509 | 'kor' => 'Korean', |
||
2510 | 'kpe' => 'Kpelle', |
||
2511 | 'kro' => 'Kru', |
||
2512 | 'kru' => 'Kurukh', |
||
2513 | 'kua' => 'Kuanyama', |
||
2514 | 'kum' => 'Kumyk', |
||
2515 | 'kur' => 'Kurdish', |
||
2516 | 'kus' => 'Kusaie', |
||
2517 | 'kut' => 'Kutenai', |
||
2518 | 'lad' => 'Ladino', |
||
2519 | 'lah' => 'Lahnda', |
||
2520 | 'lam' => 'Lamba', |
||
2521 | 'lao' => 'Lao', |
||
2522 | 'lat' => 'Latin', |
||
2523 | 'lav' => 'Latvian', |
||
2524 | 'lez' => 'Lezghian', |
||
2525 | 'lin' => 'Lingala', |
||
2526 | 'lit' => 'Lithuanian', |
||
2527 | 'lol' => 'Mongo', |
||
2528 | 'loz' => 'Lozi', |
||
2529 | 'ltz' => 'Letzeburgesch', |
||
2530 | 'lub' => 'Luba-Katanga', |
||
2531 | 'lug' => 'Ganda', |
||
2532 | 'lui' => 'Luiseno', |
||
2533 | 'lun' => 'Lunda', |
||
2534 | 'luo' => 'Luo (Kenya and Tanzania)', |
||
2535 | 'mac' => 'Macedonian', |
||
2536 | 'mad' => 'Madurese', |
||
2537 | 'mag' => 'Magahi', |
||
2538 | 'mah' => 'Marshall', |
||
2539 | 'mai' => 'Maithili', |
||
2540 | 'mak' => 'Macedonian', |
||
2541 | 'mak' => 'Makasar', |
||
2542 | 'mal' => 'Malayalam', |
||
2543 | 'man' => 'Mandingo', |
||
2544 | 'mao' => 'Maori', |
||
2545 | 'map' => 'Austronesian (Other)', |
||
2546 | 'mar' => 'Marathi', |
||
2547 | 'mas' => 'Masai', |
||
2548 | 'max' => 'Manx', |
||
2549 | 'may' => 'Malay', |
||
2550 | 'men' => 'Mende', |
||
2551 | 'mga' => 'Irish, Middle (900 - 1200)', |
||
2552 | 'mic' => 'Micmac', |
||
2553 | 'min' => 'Minangkabau', |
||
2554 | 'mis' => 'Miscellaneous (Other)', |
||
2555 | 'mkh' => 'Mon-Kmer (Other)', |
||
2556 | 'mlg' => 'Malagasy', |
||
2557 | 'mlt' => 'Maltese', |
||
2558 | 'mni' => 'Manipuri', |
||
2559 | 'mno' => 'Manobo Languages', |
||
2560 | 'moh' => 'Mohawk', |
||
2561 | 'mol' => 'Moldavian', |
||
2562 | 'mon' => 'Mongolian', |
||
2563 | 'mos' => 'Mossi', |
||
2564 | 'mri' => 'Maori', |
||
2565 | 'msa' => 'Malay', |
||
2566 | 'mul' => 'Multiple Languages', |
||
2567 | 'mun' => 'Munda Languages', |
||
2568 | 'mus' => 'Creek', |
||
2569 | 'mwr' => 'Marwari', |
||
2570 | 'mya' => 'Burmese', |
||
2571 | 'myn' => 'Mayan Languages', |
||
2572 | 'nah' => 'Aztec', |
||
2573 | 'nai' => 'North American Indian (Other)', |
||
2574 | 'nau' => 'Nauru', |
||
2575 | 'nav' => 'Navajo', |
||
2576 | 'nbl' => 'Ndebele, South', |
||
2577 | 'nde' => 'Ndebele, North', |
||
2578 | 'ndo' => 'Ndongo', |
||
2579 | 'nep' => 'Nepali', |
||
2580 | 'new' => 'Newari', |
||
2581 | 'nic' => 'Niger-Kordofanian (Other)', |
||
2582 | 'niu' => 'Niuean', |
||
2583 | 'nla' => 'Dutch', |
||
2584 | 'nno' => 'Norwegian (Nynorsk)', |
||
2585 | 'non' => 'Norse, Old', |
||
2586 | 'nor' => 'Norwegian', |
||
2587 | 'nso' => 'Sotho, Northern', |
||
2588 | 'nub' => 'Nubian Languages', |
||
2589 | 'nya' => 'Nyanja', |
||
2590 | 'nym' => 'Nyamwezi', |
||
2591 | 'nyn' => 'Nyankole', |
||
2592 | 'nyo' => 'Nyoro', |
||
2593 | 'nzi' => 'Nzima', |
||
2594 | 'oci' => 'Langue d\'Oc (post 1500)', |
||
2595 | 'oji' => 'Ojibwa', |
||
2596 | 'ori' => 'Oriya', |
||
2597 | 'orm' => 'Oromo', |
||
2598 | 'osa' => 'Osage', |
||
2599 | 'oss' => 'Ossetic', |
||
2600 | 'ota' => 'Turkish, Ottoman (1500 - 1928)', |
||
2601 | 'oto' => 'Otomian Languages', |
||
2602 | 'paa' => 'Papuan-Australian (Other)', |
||
2603 | 'pag' => 'Pangasinan', |
||
2604 | 'pal' => 'Pahlavi', |
||
2605 | 'pam' => 'Pampanga', |
||
2606 | 'pan' => 'Panjabi', |
||
2607 | 'pap' => 'Papiamento', |
||
2608 | 'pau' => 'Palauan', |
||
2609 | 'peo' => 'Persian, Old (ca 600 - 400 B.C.)', |
||
2610 | 'per' => 'Persian', |
||
2611 | 'phn' => 'Phoenician', |
||
2612 | 'pli' => 'Pali', |
||
2613 | 'pol' => 'Polish', |
||
2614 | 'pon' => 'Ponape', |
||
2615 | 'por' => 'Portuguese', |
||
2616 | 'pra' => 'Prakrit uages', |
||
2617 | 'pro' => 'Provencal, Old (to 1500)', |
||
2618 | 'pus' => 'Pushto', |
||
2619 | 'que' => 'Quechua', |
||
2620 | 'raj' => 'Rajasthani', |
||
2621 | 'rar' => 'Rarotongan', |
||
2622 | 'roa' => 'Romance (Other)', |
||
2623 | 'roh' => 'Rhaeto-Romance', |
||
2624 | 'rom' => 'Romany', |
||
2625 | 'ron' => 'Romanian', |
||
2626 | 'rum' => 'Romanian', |
||
2627 | 'run' => 'Rundi', |
||
2628 | 'rus' => 'Russian', |
||
2629 | 'sad' => 'Sandawe', |
||
2630 | 'sag' => 'Sango', |
||
2631 | 'sah' => 'Yakut', |
||
2632 | 'sai' => 'South American Indian (Other)', |
||
2633 | 'sal' => 'Salishan Languages', |
||
2634 | 'sam' => 'Samaritan Aramaic', |
||
2635 | 'san' => 'Sanskrit', |
||
2636 | 'sco' => 'Scots', |
||
2637 | 'scr' => 'Serbo-Croatian', |
||
2638 | 'sel' => 'Selkup', |
||
2639 | 'sem' => 'Semitic (Other)', |
||
2640 | 'sga' => 'Irish, Old (to 900)', |
||
2641 | 'shn' => 'Shan', |
||
2642 | 'sid' => 'Sidamo', |
||
2643 | 'sin' => 'Singhalese', |
||
2644 | 'sio' => 'Siouan Languages', |
||
2645 | 'sit' => 'Sino-Tibetan (Other)', |
||
2646 | 'sla' => 'Slavic (Other)', |
||
2647 | 'slk' => 'Slovak', |
||
2648 | 'slo' => 'Slovak', |
||
2649 | 'slv' => 'Slovenian', |
||
2650 | 'smi' => 'Sami Languages', |
||
2651 | 'smo' => 'Samoan', |
||
2652 | 'sna' => 'Shona', |
||
2653 | 'snd' => 'Sindhi', |
||
2654 | 'sog' => 'Sogdian', |
||
2655 | 'som' => 'Somali', |
||
2656 | 'son' => 'Songhai', |
||
2657 | 'sot' => 'Sotho, Southern', |
||
2658 | 'spa' => 'Spanish', |
||
2659 | 'sqi' => 'Albanian', |
||
2660 | 'srd' => 'Sardinian', |
||
2661 | 'srr' => 'Serer', |
||
2662 | 'ssa' => 'Nilo-Saharan (Other)', |
||
2663 | 'ssw' => 'Siswant', |
||
2664 | 'ssw' => 'Swazi', |
||
2665 | 'suk' => 'Sukuma', |
||
2666 | 'sun' => 'Sudanese', |
||
2667 | 'sus' => 'Susu', |
||
2668 | 'sux' => 'Sumerian', |
||
2669 | 'sve' => 'Swedish', |
||
2670 | 'swa' => 'Swahili', |
||
2671 | 'swe' => 'Swedish', |
||
2672 | 'syr' => 'Syriac', |
||
2673 | 'tah' => 'Tahitian', |
||
2674 | 'tam' => 'Tamil', |
||
2675 | 'tat' => 'Tatar', |
||
2676 | 'tel' => 'Telugu', |
||
2677 | 'tem' => 'Timne', |
||
2678 | 'ter' => 'Tereno', |
||
2679 | 'tgk' => 'Tajik', |
||
2680 | 'tgl' => 'Tagalog', |
||
2681 | 'tha' => 'Thai', |
||
2682 | 'tib' => 'Tibetan', |
||
2683 | 'tig' => 'Tigre', |
||
2684 | 'tir' => 'Tigrinya', |
||
2685 | 'tiv' => 'Tivi', |
||
2686 | 'tli' => 'Tlingit', |
||
2687 | 'tmh' => 'Tamashek', |
||
2688 | 'tog' => 'Tonga (Nyasa)', |
||
2689 | 'ton' => 'Tonga (Tonga Islands)', |
||
2690 | 'tru' => 'Truk', |
||
2691 | 'tsi' => 'Tsimshian', |
||
2692 | 'tsn' => 'Tswana', |
||
2693 | 'tso' => 'Tsonga', |
||
2694 | 'tuk' => 'Turkmen', |
||
2695 | 'tum' => 'Tumbuka', |
||
2696 | 'tur' => 'Turkish', |
||
2697 | 'tut' => 'Altaic (Other)', |
||
2698 | 'twi' => 'Twi', |
||
2699 | 'tyv' => 'Tuvinian', |
||
2700 | 'uga' => 'Ugaritic', |
||
2701 | 'uig' => 'Uighur', |
||
2702 | 'ukr' => 'Ukrainian', |
||
2703 | 'umb' => 'Umbundu', |
||
2704 | 'und' => 'Undetermined', |
||
2705 | 'urd' => 'Urdu', |
||
2706 | 'uzb' => 'Uzbek', |
||
2707 | 'vai' => 'Vai', |
||
2708 | 'ven' => 'Venda', |
||
2709 | 'vie' => 'Vietnamese', |
||
2710 | 'vol' => 'Volap�k', |
||
2711 | 'vot' => 'Votic', |
||
2712 | 'wak' => 'Wakashan Languages', |
||
2713 | 'wal' => 'Walamo', |
||
2714 | 'war' => 'Waray', |
||
2715 | 'was' => 'Washo', |
||
2716 | 'wel' => 'Welsh', |
||
2717 | 'wen' => 'Sorbian Languages', |
||
2718 | 'wol' => 'Wolof', |
||
2719 | 'xho' => 'Xhosa', |
||
2720 | 'yao' => 'Yao', |
||
2721 | 'yap' => 'Yap', |
||
2722 | 'yid' => 'Yiddish', |
||
2723 | 'yor' => 'Yoruba', |
||
2724 | 'zap' => 'Zapotec', |
||
2725 | 'zen' => 'Zenaga', |
||
2726 | 'zha' => 'Zhuang', |
||
2727 | 'zho' => 'Chinese', |
||
2728 | 'zul' => 'Zulu', |
||
2729 | 'zun' => 'Zuni' |
||
2730 | ]; |
||
2731 | |||
2732 | return @$lookup[$language_code]; |
||
2733 | } |
||
2734 | |||
2735 | public static function ETCOEventLookup($index) |
||
2736 | { |
||
2737 | if (($index >= 0x17) && ($index <= 0xDF)) { |
||
2738 | return 'reserved for future use'; |
||
2739 | } |
||
2740 | if (($index >= 0xE0) && ($index <= 0xEF)) { |
||
2741 | return 'not predefined synch 0-F'; |
||
2742 | } |
||
2743 | if (($index >= 0xF0) && ($index <= 0xFC)) { |
||
2744 | return 'reserved for future use'; |
||
2745 | } |
||
2746 | |||
2747 | static $lookup = [ |
||
2748 | 0x00 => 'padding (has no meaning)', |
||
2749 | 0x01 => 'end of initial silence', |
||
2750 | 0x02 => 'intro start', |
||
2751 | 0x03 => 'main part start', |
||
2752 | 0x04 => 'outro start', |
||
2753 | 0x05 => 'outro end', |
||
2754 | 0x06 => 'verse start', |
||
2755 | 0x07 => 'refrain start', |
||
2756 | 0x08 => 'interlude start', |
||
2757 | 0x09 => 'theme start', |
||
2758 | 0x0A => 'variation start', |
||
2759 | 0x0B => 'key change', |
||
2760 | 0x0C => 'time change', |
||
2761 | 0x0D => 'momentary unwanted noise (Snap, Crackle & Pop)', |
||
2762 | 0x0E => 'sustained noise', |
||
2763 | 0x0F => 'sustained noise end', |
||
2764 | 0x10 => 'intro end', |
||
2765 | 0x11 => 'main part end', |
||
2766 | 0x12 => 'verse end', |
||
2767 | 0x13 => 'refrain end', |
||
2768 | 0x14 => 'theme end', |
||
2769 | 0x15 => 'profanity', |
||
2770 | 0x16 => 'profanity end', |
||
2771 | 0xFD => 'audio end (start of silence)', |
||
2772 | 0xFE => 'audio file ends', |
||
2773 | 0xFF => 'one more byte of events follows' |
||
2774 | ]; |
||
2775 | |||
2776 | return @$lookup[$index]; |
||
2777 | } |
||
2778 | |||
2779 | public static function SYTLContentTypeLookup($index) |
||
2780 | { |
||
2781 | static $lookup = [ |
||
2782 | 0x00 => 'other', |
||
2783 | 0x01 => 'lyrics', |
||
2784 | 0x02 => 'text transcription', |
||
2785 | 0x03 => 'movement/part name', // (e.g. 'Adagio') |
||
2786 | 0x04 => 'events', // (e.g. 'Don Quijote enters the stage') |
||
2787 | 0x05 => 'chord', // (e.g. 'Bb F Fsus') |
||
2788 | 0x06 => 'trivia/\'pop up\' information', |
||
2789 | 0x07 => 'URLs to webpages', |
||
2790 | 0x08 => 'URLs to images' |
||
2791 | ]; |
||
2792 | |||
2793 | return @$lookup[$index]; |
||
2794 | } |
||
2795 | |||
2796 | public static function APICPictureTypeLookup($index, $return_array = false) |
||
2797 | { |
||
2798 | static $lookup = [ |
||
2799 | 0x00 => 'Other', |
||
2800 | 0x01 => '32x32 pixels \'file icon\' (PNG only)', |
||
2801 | 0x02 => 'Other file icon', |
||
2802 | 0x03 => 'Cover (front)', |
||
2803 | 0x04 => 'Cover (back)', |
||
2804 | 0x05 => 'Leaflet page', |
||
2805 | 0x06 => 'Media (e.g. label side of CD)', |
||
2806 | 0x07 => 'Lead artist/lead performer/soloist', |
||
2807 | 0x08 => 'Artist/performer', |
||
2808 | 0x09 => 'Conductor', |
||
2809 | 0x0A => 'Band/Orchestra', |
||
2810 | 0x0B => 'Composer', |
||
2811 | 0x0C => 'Lyricist/text writer', |
||
2812 | 0x0D => 'Recording Location', |
||
2813 | 0x0E => 'During recording', |
||
2814 | 0x0F => 'During performance', |
||
2815 | 0x10 => 'Movie/video screen capture', |
||
2816 | 0x11 => 'A bright coloured fish', |
||
2817 | 0x12 => 'Illustration', |
||
2818 | 0x13 => 'Band/artist logotype', |
||
2819 | 0x14 => 'Publisher/Studio logotype' |
||
2820 | ]; |
||
2821 | |||
2822 | if ($return_array) { |
||
2823 | return $lookup; |
||
2824 | } |
||
2825 | return @$lookup[$index]; |
||
2826 | } |
||
2827 | |||
2828 | public static function COMRReceivedAsLookup($index) |
||
2829 | { |
||
2830 | static $lookup = [ |
||
2831 | 0x00 => 'Other', |
||
2832 | 0x01 => 'Standard CD album with other songs', |
||
2833 | 0x02 => 'Compressed audio on CD', |
||
2834 | 0x03 => 'File over the Internet', |
||
2835 | 0x04 => 'Stream over the Internet', |
||
2836 | 0x05 => 'As note sheets', |
||
2837 | 0x06 => 'As note sheets in a book with other sheets', |
||
2838 | 0x07 => 'Music on other media', |
||
2839 | 0x08 => 'Non-musical merchandise' |
||
2840 | ]; |
||
2841 | |||
2842 | return (isset($lookup[$index]) ? $lookup[$index] : ''); |
||
2843 | } |
||
2844 | |||
2845 | public static function RVA2ChannelTypeLookup($index) |
||
2846 | { |
||
2847 | static $lookup = [ |
||
2848 | 0x00 => 'Other', |
||
2849 | 0x01 => 'Master volume', |
||
2850 | 0x02 => 'Front right', |
||
2851 | 0x03 => 'Front left', |
||
2852 | 0x04 => 'Back right', |
||
2853 | 0x05 => 'Back left', |
||
2854 | 0x06 => 'Front centre', |
||
2855 | 0x07 => 'Back centre', |
||
2856 | 0x08 => 'Subwoofer' |
||
2857 | ]; |
||
2858 | |||
2859 | return @$lookup[$index]; |
||
2860 | } |
||
2861 | |||
2862 | public static function FrameNameLongLookup($frame_name) |
||
2863 | { |
||
2864 | static $lookup = [ |
||
2865 | 'AENC' => 'Audio encryption', |
||
2866 | 'APIC' => 'Attached picture', |
||
2867 | 'ASPI' => 'Audio seek point index', |
||
2868 | 'BUF' => 'Recommended buffer size', |
||
2869 | 'CNT' => 'Play counter', |
||
2870 | 'COM' => 'Comments', |
||
2871 | 'COMM' => 'Comments', |
||
2872 | 'COMR' => 'Commercial frame', |
||
2873 | 'CRA' => 'Audio encryption', |
||
2874 | 'CRM' => 'Encrypted meta frame', |
||
2875 | 'ENCR' => 'Encryption method registration', |
||
2876 | 'EQU' => 'Equalisation', |
||
2877 | 'EQU2' => 'Equalisation (2)', |
||
2878 | 'EQUA' => 'Equalisation', |
||
2879 | 'ETC' => 'Event timing codes', |
||
2880 | 'ETCO' => 'Event timing codes', |
||
2881 | 'GEO' => 'General encapsulated object', |
||
2882 | 'GEOB' => 'General encapsulated object', |
||
2883 | 'GRID' => 'Group identification registration', |
||
2884 | 'IPL' => 'Involved people list', |
||
2885 | 'IPLS' => 'Involved people list', |
||
2886 | 'LINK' => 'Linked information', |
||
2887 | 'LNK' => 'Linked information', |
||
2888 | 'MCDI' => 'Music CD identifier', |
||
2889 | 'MCI' => 'Music CD Identifier', |
||
2890 | 'MLL' => 'MPEG location lookup table', |
||
2891 | 'MLLT' => 'MPEG location lookup table', |
||
2892 | 'OWNE' => 'Ownership frame', |
||
2893 | 'PCNT' => 'Play counter', |
||
2894 | 'PIC' => 'Attached picture', |
||
2895 | 'POP' => 'Popularimeter', |
||
2896 | 'POPM' => 'Popularimeter', |
||
2897 | 'POSS' => 'Position synchronisation frame', |
||
2898 | 'PRIV' => 'Private frame', |
||
2899 | 'RBUF' => 'Recommended buffer size', |
||
2900 | 'REV' => 'Reverb', |
||
2901 | 'RVA' => 'Relative volume adjustment', |
||
2902 | 'RVA2' => 'Relative volume adjustment (2)', |
||
2903 | 'RVAD' => 'Relative volume adjustment', |
||
2904 | 'RVRB' => 'Reverb', |
||
2905 | 'SEEK' => 'Seek frame', |
||
2906 | 'SIGN' => 'Signature frame', |
||
2907 | 'SLT' => 'Synchronised lyric/text', |
||
2908 | 'STC' => 'Synced tempo codes', |
||
2909 | 'SYLT' => 'Synchronised lyric/text', |
||
2910 | 'SYTC' => 'Synchronised tempo codes', |
||
2911 | 'TAL' => 'Album/Movie/Show title', |
||
2912 | 'TALB' => 'Album/Movie/Show title', |
||
2913 | 'TBP' => 'BPM (Beats Per Minute)', |
||
2914 | 'TBPM' => 'BPM (beats per minute)', |
||
2915 | 'TCM' => 'Composer', |
||
2916 | 'TCO' => 'Content type', |
||
2917 | 'TCOM' => 'Composer', |
||
2918 | 'TCON' => 'Content type', |
||
2919 | 'TCOP' => 'Copyright message', |
||
2920 | 'TCR' => 'Copyright message', |
||
2921 | 'TDA' => 'Date', |
||
2922 | 'TDAT' => 'Date', |
||
2923 | 'TDEN' => 'Encoding time', |
||
2924 | 'TDLY' => 'Playlist delay', |
||
2925 | 'TDOR' => 'Original release time', |
||
2926 | 'TDRC' => 'Recording time', |
||
2927 | 'TDRL' => 'Release time', |
||
2928 | 'TDTG' => 'Tagging time', |
||
2929 | 'TDY' => 'Playlist delay', |
||
2930 | 'TEN' => 'Encoded by', |
||
2931 | 'TENC' => 'Encoded by', |
||
2932 | 'TEXT' => 'Lyricist/Text writer', |
||
2933 | 'TFLT' => 'File type', |
||
2934 | 'TFT' => 'File type', |
||
2935 | 'TIM' => 'Time', |
||
2936 | 'TIME' => 'Time', |
||
2937 | 'TIPL' => 'Involved people list', |
||
2938 | 'TIT1' => 'Content group description', |
||
2939 | 'TIT2' => 'Title/songname/content description', |
||
2940 | 'TIT3' => 'Subtitle/Description refinement', |
||
2941 | 'TKE' => 'Initial key', |
||
2942 | 'TKEY' => 'Initial key', |
||
2943 | 'TLA' => 'Language(s)', |
||
2944 | 'TLAN' => 'Language(s)', |
||
2945 | 'TLE' => 'Length', |
||
2946 | 'TLEN' => 'Length', |
||
2947 | 'TMCL' => 'Musician credits list', |
||
2948 | 'TMED' => 'Media type', |
||
2949 | 'TMOO' => 'Mood', |
||
2950 | 'TMT' => 'Media type', |
||
2951 | 'TOA' => 'Original artist(s)/performer(s)', |
||
2952 | 'TOAL' => 'Original album/movie/show title', |
||
2953 | 'TOF' => 'Original filename', |
||
2954 | 'TOFN' => 'Original filename', |
||
2955 | 'TOL' => 'Original Lyricist(s)/text writer(s)', |
||
2956 | 'TOLY' => 'Original lyricist(s)/text writer(s)', |
||
2957 | 'TOPE' => 'Original artist(s)/performer(s)', |
||
2958 | 'TOR' => 'Original release year', |
||
2959 | 'TORY' => 'Original release year', |
||
2960 | 'TOT' => 'Original album/Movie/Show title', |
||
2961 | 'TOWN' => 'File owner/licensee', |
||
2962 | 'TP1' => 'Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group', |
||
2963 | 'TP2' => 'Band/Orchestra/Accompaniment', |
||
2964 | 'TP3' => 'Conductor/Performer refinement', |
||
2965 | 'TP4' => 'Interpreted, remixed, or otherwise modified by', |
||
2966 | 'TPA' => 'Part of a set', |
||
2967 | 'TPB' => 'Publisher', |
||
2968 | 'TPE1' => 'Lead performer(s)/Soloist(s)', |
||
2969 | 'TPE2' => 'Band/orchestra/accompaniment', |
||
2970 | 'TPE3' => 'Conductor/performer refinement', |
||
2971 | 'TPE4' => 'Interpreted, remixed, or otherwise modified by', |
||
2972 | 'TPOS' => 'Part of a set', |
||
2973 | 'TPRO' => 'Produced notice', |
||
2974 | 'TPUB' => 'Publisher', |
||
2975 | 'TRC' => 'ISRC (International Standard Recording Code)', |
||
2976 | 'TRCK' => 'Track number/Position in set', |
||
2977 | 'TRD' => 'Recording dates', |
||
2978 | 'TRDA' => 'Recording dates', |
||
2979 | 'TRK' => 'Track number/Position in set', |
||
2980 | 'TRSN' => 'Internet radio station name', |
||
2981 | 'TRSO' => 'Internet radio station owner', |
||
2982 | 'TSI' => 'Size', |
||
2983 | 'TSIZ' => 'Size', |
||
2984 | 'TSOA' => 'Album sort order', |
||
2985 | 'TSOP' => 'Performer sort order', |
||
2986 | 'TSOT' => 'Title sort order', |
||
2987 | 'TSRC' => 'ISRC (international standard recording code)', |
||
2988 | 'TSS' => 'Software/hardware and settings used for encoding', |
||
2989 | 'TSSE' => 'Software/Hardware and settings used for encoding', |
||
2990 | 'TSST' => 'Set subtitle', |
||
2991 | 'TT1' => 'Content group description', |
||
2992 | 'TT2' => 'Title/Songname/Content description', |
||
2993 | 'TT3' => 'Subtitle/Description refinement', |
||
2994 | 'TXT' => 'Lyricist/text writer', |
||
2995 | 'TXX' => 'User defined text information frame', |
||
2996 | 'TXXX' => 'User defined text information frame', |
||
2997 | 'TYE' => 'Year', |
||
2998 | 'TYER' => 'Year', |
||
2999 | 'UFI' => 'Unique file identifier', |
||
3000 | 'UFID' => 'Unique file identifier', |
||
3001 | 'ULT' => 'Unsychronised lyric/text transcription', |
||
3002 | 'USER' => 'Terms of use', |
||
3003 | 'USLT' => 'Unsynchronised lyric/text transcription', |
||
3004 | 'WAF' => 'Official audio file webpage', |
||
3005 | 'WAR' => 'Official artist/performer webpage', |
||
3006 | 'WAS' => 'Official audio source webpage', |
||
3007 | 'WCM' => 'Commercial information', |
||
3008 | 'WCOM' => 'Commercial information', |
||
3009 | 'WCOP' => 'Copyright/Legal information', |
||
3010 | 'WCP' => 'Copyright/Legal information', |
||
3011 | 'WOAF' => 'Official audio file webpage', |
||
3012 | 'WOAR' => 'Official artist/performer webpage', |
||
3013 | 'WOAS' => 'Official audio source webpage', |
||
3014 | 'WORS' => 'Official Internet radio station homepage', |
||
3015 | 'WPAY' => 'Payment', |
||
3016 | 'WPB' => 'Publishers official webpage', |
||
3017 | 'WPUB' => 'Publishers official webpage', |
||
3018 | 'WXX' => 'User defined URL link frame', |
||
3019 | 'WXXX' => 'User defined URL link frame', |
||
3020 | 'TFEA' => 'Featured Artist', |
||
3021 | 'TSTU' => 'Recording Studio', |
||
3022 | 'rgad' => 'Replay Gain Adjustment' |
||
3023 | ]; |
||
3024 | |||
3025 | return @$lookup[$frame_name]; |
||
3026 | |||
3027 | // Last three: |
||
3028 | // from Helium2 [www.helium2.com] |
||
3029 | // from http://privatewww.essex.ac.uk/~djmrob/replaygain/file_format_id3v2.html |
||
3030 | } |
||
3031 | |||
3032 | public static function FrameNameShortLookup($frame_name) |
||
3116 | } |
||
3117 | |||
3118 | public static function TextEncodingTerminatorLookup($encoding) |
||
3119 | { |
||
3120 | // http://www.id3.org/id3v2.4.0-structure.txt |
||
3121 | // Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings: |
||
3122 | // $00 ISO-8859-1. Terminated with $00. |
||
3123 | // $01 UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00. |
||
3124 | // $02 UTF-16BE encoded Unicode without BOM. Terminated with $00 00. |
||
3125 | // $03 UTF-8 encoded Unicode. Terminated with $00. |
||
3126 | |||
3127 | static $lookup = [ |
||
3128 | 0 => "\x00", |
||
3129 | 1 => "\x00\x00", |
||
3130 | 2 => "\x00\x00", |
||
3131 | 3 => "\x00", |
||
3132 | 255 => "\x00\x00" |
||
3133 | ]; |
||
3134 | |||
3135 | return @$lookup[$encoding]; |
||
3136 | } |
||
3137 | |||
3138 | public static function IsValidID3v2FrameName($frame_name, $id3v2_major_version) |
||
3139 | { |
||
3140 | switch ($id3v2_major_version) { |
||
3141 | case 2: |
||
3142 | return preg_match('/[A-Z][A-Z0-9]{2}/', $frame_name); |
||
3143 | |||
3144 | case 3: |
||
3145 | case 4: |
||
3146 | return preg_match('/[A-Z][A-Z0-9]{3}/', $frame_name); |
||
3147 | } |
||
3148 | return false; |
||
3149 | } |
||
3150 | |||
3151 | public static function IsValidDateStampString($date_stamp) |
||
3173 | } |
||
3174 | |||
3175 | public static function array_merge_noclobber($array1, $array2) |
||
3176 | { |
||
3189 | } |
||
3190 | |||
3191 | } |
||
3192 | |||
3193 | |||
3194 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: