44 $info = &$this->getid3->info;
46 $info[
'fileformat'] =
'ogg';
49 if (isset(
$info[
'id3v2'])) {
50 $info[
'warning'][] =
'Illegal ID3v2 tag present.';
52 if (isset(
$info[
'id3v1'])) {
53 $info[
'warning'][] =
'Illegal ID3v1 tag present.';
55 if (isset(
$info[
'ape'])) {
56 $info[
'warning'][] =
'Illegal APE tag present.';
64 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']] = $oggpageinfo;
66 if ($this->
ftell() >= $this->getid3->fread_buffer_size()) {
67 $info[
'error'][] =
'Could not find start of Ogg page in the first '.$this->getid3->fread_buffer_size().
' bytes (this might not be an Ogg-Vorbis file?)';
68 unset(
$info[
'fileformat']);
74 $filedata = $this->
fread($oggpageinfo[
'page_length']);
77 if (substr($filedata, 0, 4) ==
'fLaC') {
79 $info[
'audio'][
'dataformat'] =
'flac';
80 $info[
'audio'][
'bitrate_mode'] =
'vbr';
81 $info[
'audio'][
'lossless'] =
true;
83 } elseif (substr($filedata, 1, 6) ==
'vorbis') {
87 } elseif (substr($filedata, 0, 8) ==
'Speex ') {
91 $info[
'audio'][
'dataformat'] =
'speex';
92 $info[
'mime_type'] =
'audio/speex';
93 $info[
'audio'][
'bitrate_mode'] =
'abr';
94 $info[
'audio'][
'lossless'] =
false;
96 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'speex_string'] = substr($filedata, $filedataoffset, 8);
98 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'speex_version'] = substr($filedata, $filedataoffset, 20);
99 $filedataoffset += 20;
100 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'speex_version_id'] =
Helper::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
101 $filedataoffset += 4;
103 $filedataoffset += 4;
105 $filedataoffset += 4;
107 $filedataoffset += 4;
108 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'mode_bitstream_version'] =
Helper::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
109 $filedataoffset += 4;
111 $filedataoffset += 4;
113 $filedataoffset += 4;
115 $filedataoffset += 4;
117 $filedataoffset += 4;
118 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'frames_per_packet'] =
Helper::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
119 $filedataoffset += 4;
121 $filedataoffset += 4;
123 $filedataoffset += 4;
125 $filedataoffset += 4;
127 $info[
'speex'][
'speex_version'] = trim(
$info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'speex_version']);
128 $info[
'speex'][
'sample_rate'] =
$info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'rate'];
129 $info[
'speex'][
'channels'] =
$info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'nb_channels'];
130 $info[
'speex'][
'vbr'] = (bool)
$info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'vbr'];
133 $info[
'audio'][
'sample_rate'] =
$info[
'speex'][
'sample_rate'];
134 $info[
'audio'][
'channels'] =
$info[
'speex'][
'channels'];
135 if (
$info[
'speex'][
'vbr']) {
136 $info[
'audio'][
'bitrate_mode'] =
'vbr';
139 } elseif (substr($filedata, 0, 8) ==
"fishead\x00") {
143 $filedataoffset += 8;
145 $filedataoffset += 2;
147 $filedataoffset += 2;
149 $filedataoffset += 8;
150 $info[
'ogg'][
'skeleton'][
'fishead'][
'raw'][
'presentationtime_denominator'] =
Helper::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
151 $filedataoffset += 8;
153 $filedataoffset += 8;
155 $filedataoffset += 8;
157 $filedataoffset += 20;
159 $info[
'ogg'][
'skeleton'][
'fishead'][
'version'] =
$info[
'ogg'][
'skeleton'][
'fishead'][
'raw'][
'version_major'].
'.'.
$info[
'ogg'][
'skeleton'][
'fishead'][
'raw'][
'version_minor'];
160 $info[
'ogg'][
'skeleton'][
'fishead'][
'presentationtime'] =
$info[
'ogg'][
'skeleton'][
'fishead'][
'raw'][
'presentationtime_numerator'] /
$info[
'ogg'][
'skeleton'][
'fishead'][
'raw'][
'presentationtime_denominator'];
161 $info[
'ogg'][
'skeleton'][
'fishead'][
'basetime'] =
$info[
'ogg'][
'skeleton'][
'fishead'][
'raw'][
'basetime_numerator'] /
$info[
'ogg'][
'skeleton'][
'fishead'][
'raw'][
'basetime_denominator'];
162 $info[
'ogg'][
'skeleton'][
'fishead'][
'utc'] =
$info[
'ogg'][
'skeleton'][
'fishead'][
'raw'][
'utc'];
167 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno'].
'.'.
$counter++] = $oggpageinfo;
168 $filedata = $this->
fread($oggpageinfo[
'page_length']);
169 $this->
fseek($oggpageinfo[
'page_end_offset']);
171 if (substr($filedata, 0, 8) ==
"fisbone\x00") {
175 $filedataoffset += 4;
177 $filedataoffset += 4;
179 $filedataoffset += 4;
181 $filedataoffset += 8;
183 $filedataoffset += 8;
185 $filedataoffset += 8;
187 $filedataoffset += 4;
189 $filedataoffset += 1;
190 $info[
'ogg'][
'skeleton'][
'fisbone'][
'raw'][
'padding'] = substr($filedata, $filedataoffset, 3);
191 $filedataoffset += 3;
193 } elseif (substr($filedata, 1, 6) ==
'theora') {
195 $info[
'video'][
'dataformat'] =
'theora';
196 $info[
'error'][] =
'Ogg Theora not correctly handled in this version of GetId3 ['.$this->getid3->version().
']';
199 } elseif (substr($filedata, 1, 6) ==
'vorbis') {
204 $info[
'error'][] =
'unexpected';
208 }
while (($oggpageinfo[
'page_seqno'] == 0) && (substr($filedata, 0, 8) !=
"fisbone\x00"));
210 $this->
fseek($oggpageinfo[
'page_start_offset']);
212 $info[
'error'][] =
'Ogg Skeleton not correctly handled in this version of GetId3 ['.$this->getid3->version().
']';
217 $info[
'error'][] =
'Expecting either "Speex " or "vorbis" identifier strings, found "'.substr($filedata, 0, 8).
'"';
219 unset(
$info[
'mime_type']);
227 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']] = $oggpageinfo;
229 switch (
$info[
'audio'][
'dataformat']) {
231 $filedata = $this->
fread(
$info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'page_length']);
233 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'stream_type'] = substr($filedata, 1, 6);
239 $getid3_flac =
new Flac($this->getid3);
240 if (!$getid3_flac->parseMETAdata()) {
241 $info[
'error'][] =
'Failed to parse FLAC headers';
249 $this->
fseek(
$info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'page_length'], SEEK_CUR);
259 $info[
'warning'][] =
'Unable to parse Ogg end chunk file (PHP does not support file operations beyond '.round(PHP_INT_MAX / 1073741824).
'GB)';
263 $this->
fseek(max(
$info[
'avdataend'] - $this->getid3->fread_buffer_size(), 0));
264 $LastChunkOfOgg = strrev($this->
fread($this->getid3->fread_buffer_size()));
265 if ($LastOggSpostion = strpos($LastChunkOfOgg,
'SggO')) {
266 $this->
fseek(
$info[
'avdataend'] - ($LastOggSpostion + strlen(
'SggO')));
269 $info[
'ogg'][
'samples'] =
$info[
'ogg'][
'pageheader'][
'eos'][
'pcm_abs_position'];
270 if (
$info[
'ogg'][
'samples'] == 0) {
271 $info[
'error'][] =
'Corrupt Ogg file: eos.number of samples == zero';
275 if (!empty(
$info[
'audio'][
'sample_rate'])) {
276 $info[
'ogg'][
'bitrate_average'] = ((
$info[
'avdataend'] -
$info[
'avdataoffset']) * 8) / (
$info[
'ogg'][
'samples'] /
$info[
'audio'][
'sample_rate']);
282 if (!empty(
$info[
'ogg'][
'bitrate_average'])) {
283 $info[
'audio'][
'bitrate'] =
$info[
'ogg'][
'bitrate_average'];
284 } elseif (!empty(
$info[
'ogg'][
'bitrate_nominal'])) {
285 $info[
'audio'][
'bitrate'] =
$info[
'ogg'][
'bitrate_nominal'];
286 } elseif (!empty(
$info[
'ogg'][
'bitrate_min']) && !empty(
$info[
'ogg'][
'bitrate_max'])) {
287 $info[
'audio'][
'bitrate'] = (
$info[
'ogg'][
'bitrate_min'] +
$info[
'ogg'][
'bitrate_max']) / 2;
289 if (isset(
$info[
'audio'][
'bitrate']) && !isset(
$info[
'playtime_seconds'])) {
290 if (
$info[
'audio'][
'bitrate'] == 0) {
291 $info[
'error'][] =
'Corrupt Ogg file: bitrate_audio == zero';
295 $info[
'playtime_seconds'] = (float) (((
$info[
'avdataend'] -
$info[
'avdataoffset']) * 8) /
$info[
'audio'][
'bitrate']);
298 if (isset(
$info[
'ogg'][
'vendor'])) {
299 $info[
'audio'][
'encoder'] = preg_replace(
'/^Encoded with /',
'',
$info[
'ogg'][
'vendor']);
302 if (
$info[
'audio'][
'dataformat'] ==
'vorbis') {
305 if (preg_match(
'/^Xiph.Org/',
$info[
'audio'][
'encoder'])) {
307 if (
$info[
'audio'][
'bitrate_mode'] ==
'abr') {
310 $info[
'audio'][
'encoder_options'] =
'-b '.round(
$info[
'ogg'][
'bitrate_nominal'] / 1000);
312 } elseif ((
$info[
'audio'][
'bitrate_mode'] ==
'vbr') && (
$info[
'audio'][
'channels'] == 2) && (
$info[
'audio'][
'sample_rate'] >= 44100) && (
$info[
'audio'][
'sample_rate'] <= 48000)) {
314 $info[
'audio'][
'encoder_options'] =
'-q '.$this->get_quality_from_nominal_bitrate(
$info[
'ogg'][
'bitrate_nominal']);
319 if (empty(
$info[
'audio'][
'encoder_options']) && !empty(
$info[
'ogg'][
'bitrate_nominal'])) {
320 $info[
'audio'][
'encoder_options'] =
'Nominal bitrate: '.intval(round(
$info[
'ogg'][
'bitrate_nominal'] / 1000)).
'kbps';
330 $info = &$this->getid3->info;
331 $info[
'audio'][
'dataformat'] =
'vorbis';
332 $info[
'audio'][
'lossless'] =
false;
335 $filedataoffset += 1;
336 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'stream_type'] = substr($filedata, $filedataoffset, 6);
337 $filedataoffset += 6;
339 $filedataoffset += 4;
341 $filedataoffset += 1;
342 $info[
'audio'][
'channels'] =
$info[
'ogg'][
'numberofchannels'];
344 $filedataoffset += 4;
345 if (
$info[
'ogg'][
'samplerate'] == 0) {
346 $info[
'error'][] =
'Corrupt Ogg file: sample rate == zero';
350 $info[
'audio'][
'sample_rate'] =
$info[
'ogg'][
'samplerate'];
351 $info[
'ogg'][
'samples'] = 0;
352 $info[
'ogg'][
'bitrate_average'] = 0;
354 $filedataoffset += 4;
356 $filedataoffset += 4;
358 $filedataoffset += 4;
363 $info[
'audio'][
'bitrate_mode'] =
'vbr';
364 if (
$info[
'ogg'][
'bitrate_max'] == 0xFFFFFFFF) {
365 unset(
$info[
'ogg'][
'bitrate_max']);
366 $info[
'audio'][
'bitrate_mode'] =
'abr';
368 if (
$info[
'ogg'][
'bitrate_nominal'] == 0xFFFFFFFF) {
369 unset(
$info[
'ogg'][
'bitrate_nominal']);
371 if (
$info[
'ogg'][
'bitrate_min'] == 0xFFFFFFFF) {
372 unset(
$info[
'ogg'][
'bitrate_min']);
373 $info[
'audio'][
'bitrate_mode'] =
'abr';
386 $oggheader[
'page_start_offset'] = $this->
ftell();
388 $filedata = $this->
fread($this->getid3->fread_buffer_size());
390 while ((substr($filedata, $filedataoffset++, 4) !=
'OggS')) {
391 if (($this->
ftell() - $oggheader[
'page_start_offset']) >= $this->getid3->fread_buffer_size()) {
395 if ((($filedataoffset + 28) > strlen($filedata)) || (strlen($filedata) < 28)) {
396 if ($this->
feof() || (($filedata .= $this->
fread($this->getid3->fread_buffer_size())) ===
false)) {
402 $filedataoffset += strlen(
'OggS') - 1;
405 $filedataoffset += 1;
407 $filedataoffset += 1;
408 $oggheader[
'flags'][
'fresh'] = (bool) ($oggheader[
'flags_raw'] & 0x01);
409 $oggheader[
'flags'][
'bos'] = (bool) ($oggheader[
'flags_raw'] & 0x02);
410 $oggheader[
'flags'][
'eos'] = (bool) ($oggheader[
'flags_raw'] & 0x04);
413 $filedataoffset += 8;
415 $filedataoffset += 4;
417 $filedataoffset += 4;
419 $filedataoffset += 4;
421 $filedataoffset += 1;
422 $oggheader[
'page_length'] = 0;
423 for ($i = 0; $i < $oggheader[
'page_segments']; $i++) {
425 $filedataoffset += 1;
426 $oggheader[
'page_length'] += $oggheader[
'segment_table'][$i];
428 $oggheader[
'header_end_offset'] = $oggheader[
'page_start_offset'] + $filedataoffset;
429 $oggheader[
'page_end_offset'] = $oggheader[
'header_end_offset'] + $oggheader[
'page_length'];
430 $this->
fseek($oggheader[
'header_end_offset']);
441 $info = &$this->getid3->info;
443 $OriginalOffset = $this->
ftell();
444 $commentdataoffset = 0;
445 $VorbisCommentPage = 1;
447 switch (
$info[
'audio'][
'dataformat']) {
450 $CommentStartOffset =
$info[
'ogg'][
'pageheader'][$VorbisCommentPage][
'page_start_offset'];
451 $this->
fseek($CommentStartOffset);
452 $commentdataoffset = 27 +
$info[
'ogg'][
'pageheader'][$VorbisCommentPage][
'page_segments'];
453 $commentdata = $this->
fread(self::OggPageSegmentLength(
$info[
'ogg'][
'pageheader'][$VorbisCommentPage], 1) + $commentdataoffset);
455 if (
$info[
'audio'][
'dataformat'] ==
'vorbis') {
456 $commentdataoffset += (strlen(
'vorbis') + 1);
461 $CommentStartOffset =
$info[
'flac'][
'VORBIS_COMMENT'][
'raw'][
'offset'] + 4;
462 $this->
fseek($CommentStartOffset);
463 $commentdata = $this->
fread(
$info[
'flac'][
'VORBIS_COMMENT'][
'raw'][
'block_length']);
471 $commentdataoffset += 4;
473 $info[
'ogg'][
'vendor'] = substr($commentdata, $commentdataoffset, $VendorSize);
474 $commentdataoffset += $VendorSize;
477 $commentdataoffset += 4;
478 $info[
'avdataoffset'] = $CommentStartOffset + $commentdataoffset;
480 $basicfields =
array(
'TITLE',
'ARTIST',
'ALBUM',
'TRACKNUMBER',
'GENRE',
'DATE',
'DESCRIPTION',
'COMMENT');
481 $ThisFileInfo_ogg_comments_raw = &
$info[
'ogg'][
'comments_raw'];
482 for ($i = 0; $i < $CommentsCount; $i++) {
484 $ThisFileInfo_ogg_comments_raw[$i][
'dataoffset'] = $CommentStartOffset + $commentdataoffset;
486 if ($this->
ftell() < ($ThisFileInfo_ogg_comments_raw[$i][
'dataoffset'] + 4)) {
488 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']] = $oggpageinfo;
490 $VorbisCommentPage++;
493 $AsYetUnusedData = substr($commentdata, $commentdataoffset);
496 $commentdata = substr($commentdata, 0, $commentdataoffset);
499 $commentdata .= str_repeat(
"\x00", 27 +
$info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'page_segments']);
500 $commentdataoffset += (27 +
$info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'page_segments']);
503 $commentdata .= $AsYetUnusedData;
513 $info[
'avdataoffset'] = $ThisFileInfo_ogg_comments_raw[$i][
'dataoffset'] + $ThisFileInfo_ogg_comments_raw[$i][
'size'] + 4;
515 $commentdataoffset += 4;
516 while ((strlen($commentdata) - $commentdataoffset) < $ThisFileInfo_ogg_comments_raw[$i][
'size']) {
517 if (($ThisFileInfo_ogg_comments_raw[$i][
'size'] >
$info[
'avdataend']) || ($ThisFileInfo_ogg_comments_raw[$i][
'size'] < 0)) {
518 $info[
'warning'][] =
'Invalid Ogg comment size (comment #'.$i.
', claims to be '.number_format($ThisFileInfo_ogg_comments_raw[$i][
'size']).
' bytes) - aborting reading comments';
522 $VorbisCommentPage++;
525 $info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']] = $oggpageinfo;
528 $AsYetUnusedData = substr($commentdata, $commentdataoffset);
531 $commentdata = substr($commentdata, 0, $commentdataoffset);
534 $commentdata .= str_repeat(
"\x00", 27 +
$info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'page_segments']);
535 $commentdataoffset += (27 +
$info[
'ogg'][
'pageheader'][$oggpageinfo[
'page_seqno']][
'page_segments']);
538 $commentdata .= $AsYetUnusedData;
541 if (!isset(
$info[
'ogg'][
'pageheader'][$VorbisCommentPage])) {
542 $info[
'warning'][] =
'undefined Vorbis Comment page "'.$VorbisCommentPage.
'" at offset '.$this->
ftell();
545 $readlength = self::OggPageSegmentLength(
$info[
'ogg'][
'pageheader'][$VorbisCommentPage], 1);
546 if ($readlength <= 0) {
547 $info[
'warning'][] =
'invalid length Vorbis Comment page "'.$VorbisCommentPage.
'" at offset '.$this->
ftell();
550 $commentdata .= $this->
fread($readlength);
554 $ThisFileInfo_ogg_comments_raw[$i][
'offset'] = $commentdataoffset;
555 $commentstring = substr($commentdata, $commentdataoffset, $ThisFileInfo_ogg_comments_raw[$i][
'size']);
556 $commentdataoffset += $ThisFileInfo_ogg_comments_raw[$i][
'size'];
558 if (!$commentstring) {
561 $info[
'warning'][] =
'Blank Ogg comment ['.$i.
']';
563 } elseif (strstr($commentstring,
'=')) {
565 $commentexploded = explode(
'=', $commentstring, 2);
566 $ThisFileInfo_ogg_comments_raw[$i][
'key'] = strtoupper($commentexploded[0]);
567 $ThisFileInfo_ogg_comments_raw[$i][
'value'] = (isset($commentexploded[1]) ? $commentexploded[1] :
'');
568 $ThisFileInfo_ogg_comments_raw[$i][
'data'] = base64_decode($ThisFileInfo_ogg_comments_raw[$i][
'value']);
569 $ThisFileInfo_ogg_comments_raw[$i][
'data_length'] = strlen($ThisFileInfo_ogg_comments_raw[$i][
'data']);
571 if ($ThisFileInfo_ogg_comments_raw[$i][
'key'] ==
'METADATA_BLOCK_PICTURE') {
576 $getid3_flac =
new Flac($getid3_temp);
577 $getid3_flac->data_string = $ThisFileInfo_ogg_comments_raw[$i][
'data'];
578 $getid3_flac->data_string_flag =
true;
579 if ($getid3_flac->parsePICTURE()) {
580 if (!empty($getid3_temp->info[
'flac'][
'PICTURE'])) {
581 foreach ($getid3_temp->info[
'flac'][
'PICTURE'] as $key => $value) {
582 $ThisFileInfo_ogg_comments_raw[$i][
'data'] = $value[
'data'];
583 $ThisFileInfo_ogg_comments_raw[$i][
'data_length'] = strlen($value[
'data']);
584 $ThisFileInfo_ogg_comments_raw[$i][
'image_mime'] = $value[
'image_mime'];
585 $ThisFileInfo_ogg_comments_raw[$i][
'width'] = $value[
'width'];
586 $ThisFileInfo_ogg_comments_raw[$i][
'height'] = $value[
'height'];
587 $ThisFileInfo_ogg_comments_raw[$i][
'type'] = $value[
'type'];
588 $ThisFileInfo_ogg_comments_raw[$i][
'typeid'] = $value[
'typeid'];
589 $ThisFileInfo_ogg_comments_raw[$i][
'color_depth'] = $value[
'color_depth'];
590 $ThisFileInfo_ogg_comments_raw[$i][
'colors_indexed'] = $value[
'colors_indexed'];
594 $info[
'warning'][] =
'Failed to GetId3_flac.parsePICTURE()';
596 unset($getid3_flac, $getid3_temp);
599 if (preg_match(
'#^(BM|GIF|\xFF\xD8\xFF|\x89\x50\x4E\x47\x0D\x0A\x1A\x0A|II\x2A\x00|MM\x00\x2A)#s', $ThisFileInfo_ogg_comments_raw[$i][
'data'])) {
600 $imageinfo =
array();
603 if (!empty($imagechunkcheck)) {
604 $ThisFileInfo_ogg_comments_raw[$i][
'image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
605 if ($ThisFileInfo_ogg_comments_raw[$i][
'image_mime'] && ($ThisFileInfo_ogg_comments_raw[$i][
'image_mime'] !=
'application/octet-stream')) {
606 unset($ThisFileInfo_ogg_comments_raw[$i][
'value']);
611 if (isset($ThisFileInfo_ogg_comments_raw[$i][
'value'])) {
612 unset($ThisFileInfo_ogg_comments_raw[$i][
'data']);
613 $info[
'ogg'][
'comments'][strtolower($ThisFileInfo_ogg_comments_raw[$i][
'key'])][] = $ThisFileInfo_ogg_comments_raw[$i][
'value'];
616 if ($this->inline_attachments ===
false) {
618 unset($ThisFileInfo_ogg_comments_raw[$i][
'data']);
621 if ($this->inline_attachments ===
true) {
623 } elseif (is_int($this->inline_attachments)) {
624 if ($this->inline_attachments < $ThisFileInfo_ogg_comments_raw[$i][
'data_length']) {
626 $info[
'warning'][] =
'attachment at '.$ThisFileInfo_ogg_comments_raw[$i][
'offset'].
' is too large to process inline ('.number_format($ThisFileInfo_ogg_comments_raw[$i][
'data_length']).
' bytes)';
627 unset($ThisFileInfo_ogg_comments_raw[$i][
'data']);
630 } elseif (is_string($this->inline_attachments)) {
631 $this->inline_attachments = rtrim(str_replace(
array(
'/',
'\\'), DIRECTORY_SEPARATOR, $this->inline_attachments), DIRECTORY_SEPARATOR);
632 if (!is_dir($this->inline_attachments) || !is_writable($this->inline_attachments)) {
634 $info[
'warning'][] =
'attachment at '.$ThisFileInfo_ogg_comments_raw[$i][
'offset'].
' cannot be saved to "'.$this->inline_attachments.
'" (not writable)';
635 unset($ThisFileInfo_ogg_comments_raw[$i][
'data']);
640 if (is_string($this->inline_attachments)) {
641 $destination_filename = $this->inline_attachments.DIRECTORY_SEPARATOR.md5(
$info[
'filenamepath']).
'_'.$ThisFileInfo_ogg_comments_raw[$i][
'offset'];
642 if (!file_exists($destination_filename) || is_writable($destination_filename)) {
643 file_put_contents($destination_filename, $ThisFileInfo_ogg_comments_raw[$i][
'data']);
645 $info[
'warning'][] =
'attachment at '.$ThisFileInfo_ogg_comments_raw[$i][
'offset'].
' cannot be saved to "'.$destination_filename.
'" (not writable)';
647 $ThisFileInfo_ogg_comments_raw[$i][
'data_filename'] = $destination_filename;
648 unset($ThisFileInfo_ogg_comments_raw[$i][
'data']);
650 $info[
'ogg'][
'comments'][
'picture'][] =
array(
'data'=>$ThisFileInfo_ogg_comments_raw[$i][
'data'],
'image_mime'=>$ThisFileInfo_ogg_comments_raw[$i][
'image_mime']);
658 $info[
'warning'][] =
'[known problem with CDex >= v1.40, < v1.50b7] Invalid Ogg comment name/value pair ['.$i.
']: '.$commentstring;
665 if (isset(
$info[
'ogg'][
'comments']) && is_array(
$info[
'ogg'][
'comments'])) {
666 foreach (
$info[
'ogg'][
'comments'] as $index => $commentvalue) {
668 case 'rg_audiophile':
669 case 'replaygain_album_gain':
670 $info[
'replay_gain'][
'album'][
'adjustment'] = (double) $commentvalue[0];
671 unset(
$info[
'ogg'][
'comments'][$index]);
675 case 'replaygain_track_gain':
676 $info[
'replay_gain'][
'track'][
'adjustment'] = (double) $commentvalue[0];
677 unset(
$info[
'ogg'][
'comments'][$index]);
680 case 'replaygain_album_peak':
681 $info[
'replay_gain'][
'album'][
'peak'] = (double) $commentvalue[0];
682 unset(
$info[
'ogg'][
'comments'][$index]);
686 case 'replaygain_track_peak':
687 $info[
'replay_gain'][
'track'][
'peak'] = (double) $commentvalue[0];
688 unset(
$info[
'ogg'][
'comments'][$index]);
691 case 'replaygain_reference_loudness':
692 $info[
'replay_gain'][
'reference_volume'] = (double) $commentvalue[0];
693 unset(
$info[
'ogg'][
'comments'][$index]);
703 $this->
fseek($OriginalOffset);
716 static $SpeexBandModeLookup =
array();
717 if (empty($SpeexBandModeLookup)) {
718 $SpeexBandModeLookup[0] =
'narrow';
719 $SpeexBandModeLookup[1] =
'wide';
720 $SpeexBandModeLookup[2] =
'ultra-wide';
723 return (isset($SpeexBandModeLookup[$mode]) ? $SpeexBandModeLookup[$mode] : null);
734 for ($i = 0; $i < $SegmentNumber; $i++) {
736 foreach ($OggInfoArray[
'segment_table'] as $key => $value) {
737 $segmentlength += $value;
744 return $segmentlength;
755 $nominal_bitrate = $nominal_bitrate / 1000;
757 if ($nominal_bitrate < 128) {
759 $qval = ($nominal_bitrate - 64) / 16;
760 } elseif ($nominal_bitrate < 256) {
762 $qval = $nominal_bitrate / 32;
763 } elseif ($nominal_bitrate < 320) {
765 $qval = ($nominal_bitrate + 256) / 64;
768 $qval = ($nominal_bitrate + 1300) / 180;
772 return round($qval, 1);
static SpeexBandModeLookup($mode)
array $SpeexBandModeLookup
ParseVorbisPageHeader(&$filedata, &$filedataoffset, &$oggpageinfo)
static get_quality_from_nominal_bitrate($nominal_bitrate)
static GetDataImageSize($imgData, &$imageinfo)
string $tempdir
GetId3() by James Heinrich info@getid3.org //.
fseek($bytes, $whence=SEEK_SET)
GetId3() by James Heinrich info@getid3.org //.
GetId3() by James Heinrich info@getid3.org //.
GetId3() by James Heinrich info@getid3.org //.
static OggPageSegmentLength($OggInfoArray, $SegmentNumber=1)
Create styles array
The data for the language used.
static LittleEndian2Int($byteword, $signed=false)
static intValueSupported($num)
null $hasINT64