Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../ID3
File: module.audio.ogg.php
$this->error('Invalid channel count in opus header (must not be zero)');
[500] Fix | Delete
return false;
[501] Fix | Delete
}
[502] Fix | Delete
[503] Fix | Delete
$info['ogg']['pageheader']['opus']['pre_skip'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2));
[504] Fix | Delete
$filedataoffset += 2;
[505] Fix | Delete
[506] Fix | Delete
$info['ogg']['pageheader']['opus']['input_sample_rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
[507] Fix | Delete
$filedataoffset += 4;
[508] Fix | Delete
[509] Fix | Delete
//$info['ogg']['pageheader']['opus']['output_gain'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2));
[510] Fix | Delete
//$filedataoffset += 2;
[511] Fix | Delete
[512] Fix | Delete
//$info['ogg']['pageheader']['opus']['channel_mapping_family'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
[513] Fix | Delete
//$filedataoffset += 1;
[514] Fix | Delete
[515] Fix | Delete
$info['opus']['opus_version'] = $info['ogg']['pageheader']['opus']['version'];
[516] Fix | Delete
$info['opus']['sample_rate_input'] = $info['ogg']['pageheader']['opus']['input_sample_rate'];
[517] Fix | Delete
$info['opus']['out_channel_count'] = $info['ogg']['pageheader']['opus']['out_channel_count'];
[518] Fix | Delete
[519] Fix | Delete
$info['audio']['channels'] = $info['opus']['out_channel_count'];
[520] Fix | Delete
$info['audio']['sample_rate_input'] = $info['opus']['sample_rate_input'];
[521] Fix | Delete
$info['audio']['sample_rate'] = 48000; // "All Opus audio is coded at 48 kHz, and should also be decoded at 48 kHz for playback (unless the target hardware does not support this sampling rate). However, this field may be used to resample the audio back to the original sampling rate, for example, when saving the output to a file." -- https://mf4.xiph.org/jenkins/view/opus/job/opusfile-unix/ws/doc/html/structOpusHead.html
[522] Fix | Delete
return true;
[523] Fix | Delete
}
[524] Fix | Delete
[525] Fix | Delete
/**
[526] Fix | Delete
* @return array|false
[527] Fix | Delete
*/
[528] Fix | Delete
public function ParseOggPageHeader() {
[529] Fix | Delete
// http://xiph.org/ogg/vorbis/doc/framing.html
[530] Fix | Delete
$oggheader = array();
[531] Fix | Delete
$oggheader['page_start_offset'] = $this->ftell(); // where we started from in the file
[532] Fix | Delete
[533] Fix | Delete
$filedata = $this->fread($this->getid3->fread_buffer_size());
[534] Fix | Delete
$filedataoffset = 0;
[535] Fix | Delete
while (substr($filedata, $filedataoffset++, 4) != 'OggS') {
[536] Fix | Delete
if (($this->ftell() - $oggheader['page_start_offset']) >= $this->getid3->fread_buffer_size()) {
[537] Fix | Delete
// should be found before here
[538] Fix | Delete
return false;
[539] Fix | Delete
}
[540] Fix | Delete
if (($filedataoffset + 28) > strlen($filedata)) {
[541] Fix | Delete
if ($this->feof() || (($filedata .= $this->fread($this->getid3->fread_buffer_size())) === '')) {
[542] Fix | Delete
// get some more data, unless eof, in which case fail
[543] Fix | Delete
return false;
[544] Fix | Delete
}
[545] Fix | Delete
}
[546] Fix | Delete
}
[547] Fix | Delete
$filedataoffset += strlen('OggS') - 1; // page, delimited by 'OggS'
[548] Fix | Delete
[549] Fix | Delete
$oggheader['stream_structver'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
[550] Fix | Delete
$filedataoffset += 1;
[551] Fix | Delete
$oggheader['flags_raw'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
[552] Fix | Delete
$filedataoffset += 1;
[553] Fix | Delete
$oggheader['flags']['fresh'] = (bool) ($oggheader['flags_raw'] & 0x01); // fresh packet
[554] Fix | Delete
$oggheader['flags']['bos'] = (bool) ($oggheader['flags_raw'] & 0x02); // first page of logical bitstream (bos)
[555] Fix | Delete
$oggheader['flags']['eos'] = (bool) ($oggheader['flags_raw'] & 0x04); // last page of logical bitstream (eos)
[556] Fix | Delete
[557] Fix | Delete
$oggheader['pcm_abs_position'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
[558] Fix | Delete
$filedataoffset += 8;
[559] Fix | Delete
$oggheader['stream_serialno'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
[560] Fix | Delete
$filedataoffset += 4;
[561] Fix | Delete
$oggheader['page_seqno'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
[562] Fix | Delete
$filedataoffset += 4;
[563] Fix | Delete
$oggheader['page_checksum'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
[564] Fix | Delete
$filedataoffset += 4;
[565] Fix | Delete
$oggheader['page_segments'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
[566] Fix | Delete
$filedataoffset += 1;
[567] Fix | Delete
$oggheader['page_length'] = 0;
[568] Fix | Delete
for ($i = 0; $i < $oggheader['page_segments']; $i++) {
[569] Fix | Delete
$oggheader['segment_table'][$i] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
[570] Fix | Delete
$filedataoffset += 1;
[571] Fix | Delete
$oggheader['page_length'] += $oggheader['segment_table'][$i];
[572] Fix | Delete
}
[573] Fix | Delete
$oggheader['header_end_offset'] = $oggheader['page_start_offset'] + $filedataoffset;
[574] Fix | Delete
$oggheader['page_end_offset'] = $oggheader['header_end_offset'] + $oggheader['page_length'];
[575] Fix | Delete
$this->fseek($oggheader['header_end_offset']);
[576] Fix | Delete
[577] Fix | Delete
return $oggheader;
[578] Fix | Delete
}
[579] Fix | Delete
[580] Fix | Delete
/**
[581] Fix | Delete
* @link http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810005
[582] Fix | Delete
*
[583] Fix | Delete
* @return bool
[584] Fix | Delete
*/
[585] Fix | Delete
public function ParseVorbisComments() {
[586] Fix | Delete
$info = &$this->getid3->info;
[587] Fix | Delete
[588] Fix | Delete
$OriginalOffset = $this->ftell();
[589] Fix | Delete
$commentdata = null;
[590] Fix | Delete
$commentdataoffset = 0;
[591] Fix | Delete
$VorbisCommentPage = 1;
[592] Fix | Delete
$CommentStartOffset = 0;
[593] Fix | Delete
[594] Fix | Delete
switch ($info['audio']['dataformat']) {
[595] Fix | Delete
case 'vorbis':
[596] Fix | Delete
case 'speex':
[597] Fix | Delete
case 'opus':
[598] Fix | Delete
$CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block
[599] Fix | Delete
$this->fseek($CommentStartOffset);
[600] Fix | Delete
$commentdataoffset = 27 + $info['ogg']['pageheader'][$VorbisCommentPage]['page_segments'];
[601] Fix | Delete
$commentdata = $this->fread(self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset);
[602] Fix | Delete
[603] Fix | Delete
if ($info['audio']['dataformat'] == 'vorbis') {
[604] Fix | Delete
$commentdataoffset += (strlen('vorbis') + 1);
[605] Fix | Delete
}
[606] Fix | Delete
else if ($info['audio']['dataformat'] == 'opus') {
[607] Fix | Delete
$commentdataoffset += strlen('OpusTags');
[608] Fix | Delete
}
[609] Fix | Delete
[610] Fix | Delete
break;
[611] Fix | Delete
[612] Fix | Delete
case 'flac':
[613] Fix | Delete
$CommentStartOffset = $info['flac']['VORBIS_COMMENT']['raw']['offset'] + 4;
[614] Fix | Delete
$this->fseek($CommentStartOffset);
[615] Fix | Delete
$commentdata = $this->fread($info['flac']['VORBIS_COMMENT']['raw']['block_length']);
[616] Fix | Delete
break;
[617] Fix | Delete
[618] Fix | Delete
default:
[619] Fix | Delete
return false;
[620] Fix | Delete
}
[621] Fix | Delete
[622] Fix | Delete
$VendorSize = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
[623] Fix | Delete
$commentdataoffset += 4;
[624] Fix | Delete
[625] Fix | Delete
$info['ogg']['vendor'] = substr($commentdata, $commentdataoffset, $VendorSize);
[626] Fix | Delete
$commentdataoffset += $VendorSize;
[627] Fix | Delete
[628] Fix | Delete
$CommentsCount = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
[629] Fix | Delete
$commentdataoffset += 4;
[630] Fix | Delete
$info['avdataoffset'] = $CommentStartOffset + $commentdataoffset;
[631] Fix | Delete
[632] Fix | Delete
$basicfields = array('TITLE', 'ARTIST', 'ALBUM', 'TRACKNUMBER', 'GENRE', 'DATE', 'DESCRIPTION', 'COMMENT');
[633] Fix | Delete
$ThisFileInfo_ogg_comments_raw = &$info['ogg']['comments_raw'];
[634] Fix | Delete
for ($i = 0; $i < $CommentsCount; $i++) {
[635] Fix | Delete
[636] Fix | Delete
if ($i >= 10000) {
[637] Fix | Delete
// https://github.com/owncloud/music/issues/212#issuecomment-43082336
[638] Fix | Delete
$this->warning('Unexpectedly large number ('.$CommentsCount.') of Ogg comments - breaking after reading '.$i.' comments');
[639] Fix | Delete
break;
[640] Fix | Delete
}
[641] Fix | Delete
[642] Fix | Delete
$ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] = $CommentStartOffset + $commentdataoffset;
[643] Fix | Delete
[644] Fix | Delete
if ($this->ftell() < ($ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + 4)) {
[645] Fix | Delete
if ($oggpageinfo = $this->ParseOggPageHeader()) {
[646] Fix | Delete
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
[647] Fix | Delete
[648] Fix | Delete
$VorbisCommentPage++;
[649] Fix | Delete
[650] Fix | Delete
// First, save what we haven't read yet
[651] Fix | Delete
$AsYetUnusedData = substr($commentdata, $commentdataoffset);
[652] Fix | Delete
[653] Fix | Delete
// Then take that data off the end
[654] Fix | Delete
$commentdata = substr($commentdata, 0, $commentdataoffset);
[655] Fix | Delete
[656] Fix | Delete
// Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct
[657] Fix | Delete
$commentdata .= str_repeat("\x00", 27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
[658] Fix | Delete
$commentdataoffset += (27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
[659] Fix | Delete
[660] Fix | Delete
// Finally, stick the unused data back on the end
[661] Fix | Delete
$commentdata .= $AsYetUnusedData;
[662] Fix | Delete
[663] Fix | Delete
//$commentdata .= $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
[664] Fix | Delete
$commentdata .= $this->fread($this->OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1));
[665] Fix | Delete
}
[666] Fix | Delete
[667] Fix | Delete
}
[668] Fix | Delete
$ThisFileInfo_ogg_comments_raw[$i]['size'] = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4));
[669] Fix | Delete
[670] Fix | Delete
// replace avdataoffset with position just after the last vorbiscomment
[671] Fix | Delete
$info['avdataoffset'] = $ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + $ThisFileInfo_ogg_comments_raw[$i]['size'] + 4;
[672] Fix | Delete
[673] Fix | Delete
$commentdataoffset += 4;
[674] Fix | Delete
while ((strlen($commentdata) - $commentdataoffset) < $ThisFileInfo_ogg_comments_raw[$i]['size']) {
[675] Fix | Delete
if (($ThisFileInfo_ogg_comments_raw[$i]['size'] > $info['avdataend']) || ($ThisFileInfo_ogg_comments_raw[$i]['size'] < 0)) {
[676] Fix | Delete
$this->warning('Invalid Ogg comment size (comment #'.$i.', claims to be '.number_format($ThisFileInfo_ogg_comments_raw[$i]['size']).' bytes) - aborting reading comments');
[677] Fix | Delete
break 2;
[678] Fix | Delete
}
[679] Fix | Delete
[680] Fix | Delete
$VorbisCommentPage++;
[681] Fix | Delete
[682] Fix | Delete
if ($oggpageinfo = $this->ParseOggPageHeader()) {
[683] Fix | Delete
$info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo;
[684] Fix | Delete
[685] Fix | Delete
// First, save what we haven't read yet
[686] Fix | Delete
$AsYetUnusedData = substr($commentdata, $commentdataoffset);
[687] Fix | Delete
[688] Fix | Delete
// Then take that data off the end
[689] Fix | Delete
$commentdata = substr($commentdata, 0, $commentdataoffset);
[690] Fix | Delete
[691] Fix | Delete
// Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct
[692] Fix | Delete
$commentdata .= str_repeat("\x00", 27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
[693] Fix | Delete
$commentdataoffset += (27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']);
[694] Fix | Delete
[695] Fix | Delete
// Finally, stick the unused data back on the end
[696] Fix | Delete
$commentdata .= $AsYetUnusedData;
[697] Fix | Delete
[698] Fix | Delete
//$commentdata .= $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
[699] Fix | Delete
if (!isset($info['ogg']['pageheader'][$VorbisCommentPage])) {
[700] Fix | Delete
$this->warning('undefined Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.$this->ftell());
[701] Fix | Delete
break;
[702] Fix | Delete
}
[703] Fix | Delete
$readlength = self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1);
[704] Fix | Delete
if ($readlength <= 0) {
[705] Fix | Delete
$this->warning('invalid length Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.$this->ftell());
[706] Fix | Delete
break;
[707] Fix | Delete
}
[708] Fix | Delete
$commentdata .= $this->fread($readlength);
[709] Fix | Delete
[710] Fix | Delete
//$filebaseoffset += $oggpageinfo['header_end_offset'] - $oggpageinfo['page_start_offset'];
[711] Fix | Delete
} else {
[712] Fix | Delete
$this->warning('failed to ParseOggPageHeader() at offset '.$this->ftell());
[713] Fix | Delete
break;
[714] Fix | Delete
}
[715] Fix | Delete
}
[716] Fix | Delete
$ThisFileInfo_ogg_comments_raw[$i]['offset'] = $commentdataoffset;
[717] Fix | Delete
$commentstring = substr($commentdata, $commentdataoffset, $ThisFileInfo_ogg_comments_raw[$i]['size']);
[718] Fix | Delete
$commentdataoffset += $ThisFileInfo_ogg_comments_raw[$i]['size'];
[719] Fix | Delete
[720] Fix | Delete
if (!$commentstring) {
[721] Fix | Delete
[722] Fix | Delete
// no comment?
[723] Fix | Delete
$this->warning('Blank Ogg comment ['.$i.']');
[724] Fix | Delete
[725] Fix | Delete
} elseif (strstr($commentstring, '=')) {
[726] Fix | Delete
[727] Fix | Delete
$commentexploded = explode('=', $commentstring, 2);
[728] Fix | Delete
$ThisFileInfo_ogg_comments_raw[$i]['key'] = strtoupper($commentexploded[0]);
[729] Fix | Delete
$ThisFileInfo_ogg_comments_raw[$i]['value'] = (isset($commentexploded[1]) ? $commentexploded[1] : '');
[730] Fix | Delete
[731] Fix | Delete
if ($ThisFileInfo_ogg_comments_raw[$i]['key'] == 'METADATA_BLOCK_PICTURE') {
[732] Fix | Delete
[733] Fix | Delete
// http://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
[734] Fix | Delete
// The unencoded format is that of the FLAC picture block. The fields are stored in big endian order as in FLAC, picture data is stored according to the relevant standard.
[735] Fix | Delete
// http://flac.sourceforge.net/format.html#metadata_block_picture
[736] Fix | Delete
$flac = new getid3_flac($this->getid3);
[737] Fix | Delete
$flac->setStringMode(base64_decode($ThisFileInfo_ogg_comments_raw[$i]['value']));
[738] Fix | Delete
$flac->parsePICTURE();
[739] Fix | Delete
$info['ogg']['comments']['picture'][] = $flac->getid3->info['flac']['PICTURE'][0];
[740] Fix | Delete
unset($flac);
[741] Fix | Delete
[742] Fix | Delete
} elseif ($ThisFileInfo_ogg_comments_raw[$i]['key'] == 'COVERART') {
[743] Fix | Delete
[744] Fix | Delete
$data = base64_decode($ThisFileInfo_ogg_comments_raw[$i]['value']);
[745] Fix | Delete
$this->notice('Found deprecated COVERART tag, it should be replaced in honor of METADATA_BLOCK_PICTURE structure');
[746] Fix | Delete
/** @todo use 'coverartmime' where available */
[747] Fix | Delete
$imageinfo = getid3_lib::GetDataImageSize($data);
[748] Fix | Delete
if ($imageinfo === false || !isset($imageinfo['mime'])) {
[749] Fix | Delete
$this->warning('COVERART vorbiscomment tag contains invalid image');
[750] Fix | Delete
continue;
[751] Fix | Delete
}
[752] Fix | Delete
[753] Fix | Delete
$ogg = new self($this->getid3);
[754] Fix | Delete
$ogg->setStringMode($data);
[755] Fix | Delete
$info['ogg']['comments']['picture'][] = array(
[756] Fix | Delete
'image_mime' => $imageinfo['mime'],
[757] Fix | Delete
'datalength' => strlen($data),
[758] Fix | Delete
'picturetype' => 'cover art',
[759] Fix | Delete
'image_height' => $imageinfo['height'],
[760] Fix | Delete
'image_width' => $imageinfo['width'],
[761] Fix | Delete
'data' => $ogg->saveAttachment('coverart', 0, strlen($data), $imageinfo['mime']),
[762] Fix | Delete
);
[763] Fix | Delete
unset($ogg);
[764] Fix | Delete
[765] Fix | Delete
} else {
[766] Fix | Delete
[767] Fix | Delete
$info['ogg']['comments'][strtolower($ThisFileInfo_ogg_comments_raw[$i]['key'])][] = $ThisFileInfo_ogg_comments_raw[$i]['value'];
[768] Fix | Delete
[769] Fix | Delete
}
[770] Fix | Delete
[771] Fix | Delete
} else {
[772] Fix | Delete
[773] Fix | Delete
$this->warning('[known problem with CDex >= v1.40, < v1.50b7] Invalid Ogg comment name/value pair ['.$i.']: '.$commentstring);
[774] Fix | Delete
[775] Fix | Delete
}
[776] Fix | Delete
unset($ThisFileInfo_ogg_comments_raw[$i]);
[777] Fix | Delete
}
[778] Fix | Delete
unset($ThisFileInfo_ogg_comments_raw);
[779] Fix | Delete
[780] Fix | Delete
[781] Fix | Delete
// Replay Gain Adjustment
[782] Fix | Delete
// http://privatewww.essex.ac.uk/~djmrob/replaygain/
[783] Fix | Delete
if (isset($info['ogg']['comments']) && is_array($info['ogg']['comments'])) {
[784] Fix | Delete
foreach ($info['ogg']['comments'] as $index => $commentvalue) {
[785] Fix | Delete
switch ($index) {
[786] Fix | Delete
case 'rg_audiophile':
[787] Fix | Delete
case 'replaygain_album_gain':
[788] Fix | Delete
$info['replay_gain']['album']['adjustment'] = (double) $commentvalue[0];
[789] Fix | Delete
unset($info['ogg']['comments'][$index]);
[790] Fix | Delete
break;
[791] Fix | Delete
[792] Fix | Delete
case 'rg_radio':
[793] Fix | Delete
case 'replaygain_track_gain':
[794] Fix | Delete
$info['replay_gain']['track']['adjustment'] = (double) $commentvalue[0];
[795] Fix | Delete
unset($info['ogg']['comments'][$index]);
[796] Fix | Delete
break;
[797] Fix | Delete
[798] Fix | Delete
case 'replaygain_album_peak':
[799] Fix | Delete
$info['replay_gain']['album']['peak'] = (double) $commentvalue[0];
[800] Fix | Delete
unset($info['ogg']['comments'][$index]);
[801] Fix | Delete
break;
[802] Fix | Delete
[803] Fix | Delete
case 'rg_peak':
[804] Fix | Delete
case 'replaygain_track_peak':
[805] Fix | Delete
$info['replay_gain']['track']['peak'] = (double) $commentvalue[0];
[806] Fix | Delete
unset($info['ogg']['comments'][$index]);
[807] Fix | Delete
break;
[808] Fix | Delete
[809] Fix | Delete
case 'replaygain_reference_loudness':
[810] Fix | Delete
$info['replay_gain']['reference_volume'] = (double) $commentvalue[0];
[811] Fix | Delete
unset($info['ogg']['comments'][$index]);
[812] Fix | Delete
break;
[813] Fix | Delete
[814] Fix | Delete
default:
[815] Fix | Delete
// do nothing
[816] Fix | Delete
break;
[817] Fix | Delete
}
[818] Fix | Delete
}
[819] Fix | Delete
}
[820] Fix | Delete
[821] Fix | Delete
$this->fseek($OriginalOffset);
[822] Fix | Delete
[823] Fix | Delete
return true;
[824] Fix | Delete
}
[825] Fix | Delete
[826] Fix | Delete
/**
[827] Fix | Delete
* @param int $mode
[828] Fix | Delete
*
[829] Fix | Delete
* @return string|null
[830] Fix | Delete
*/
[831] Fix | Delete
public static function SpeexBandModeLookup($mode) {
[832] Fix | Delete
static $SpeexBandModeLookup = array();
[833] Fix | Delete
if (empty($SpeexBandModeLookup)) {
[834] Fix | Delete
$SpeexBandModeLookup[0] = 'narrow';
[835] Fix | Delete
$SpeexBandModeLookup[1] = 'wide';
[836] Fix | Delete
$SpeexBandModeLookup[2] = 'ultra-wide';
[837] Fix | Delete
}
[838] Fix | Delete
return (isset($SpeexBandModeLookup[$mode]) ? $SpeexBandModeLookup[$mode] : null);
[839] Fix | Delete
}
[840] Fix | Delete
[841] Fix | Delete
/**
[842] Fix | Delete
* @param array $OggInfoArray
[843] Fix | Delete
* @param int $SegmentNumber
[844] Fix | Delete
*
[845] Fix | Delete
* @return int
[846] Fix | Delete
*/
[847] Fix | Delete
public static function OggPageSegmentLength($OggInfoArray, $SegmentNumber=1) {
[848] Fix | Delete
$segmentlength = 0;
[849] Fix | Delete
for ($i = 0; $i < $SegmentNumber; $i++) {
[850] Fix | Delete
$segmentlength = 0;
[851] Fix | Delete
foreach ($OggInfoArray['segment_table'] as $key => $value) {
[852] Fix | Delete
$segmentlength += $value;
[853] Fix | Delete
if ($value < 255) {
[854] Fix | Delete
break;
[855] Fix | Delete
}
[856] Fix | Delete
}
[857] Fix | Delete
}
[858] Fix | Delete
return $segmentlength;
[859] Fix | Delete
}
[860] Fix | Delete
[861] Fix | Delete
/**
[862] Fix | Delete
* @param int $nominal_bitrate
[863] Fix | Delete
*
[864] Fix | Delete
* @return float
[865] Fix | Delete
*/
[866] Fix | Delete
public static function get_quality_from_nominal_bitrate($nominal_bitrate) {
[867] Fix | Delete
[868] Fix | Delete
// decrease precision
[869] Fix | Delete
$nominal_bitrate = $nominal_bitrate / 1000;
[870] Fix | Delete
[871] Fix | Delete
if ($nominal_bitrate < 128) {
[872] Fix | Delete
// q-1 to q4
[873] Fix | Delete
$qval = ($nominal_bitrate - 64) / 16;
[874] Fix | Delete
} elseif ($nominal_bitrate < 256) {
[875] Fix | Delete
// q4 to q8
[876] Fix | Delete
$qval = $nominal_bitrate / 32;
[877] Fix | Delete
} elseif ($nominal_bitrate < 320) {
[878] Fix | Delete
// q8 to q9
[879] Fix | Delete
$qval = ($nominal_bitrate + 256) / 64;
[880] Fix | Delete
} else {
[881] Fix | Delete
// q9 to q10
[882] Fix | Delete
$qval = ($nominal_bitrate + 1300) / 180;
[883] Fix | Delete
}
[884] Fix | Delete
//return $qval; // 5.031324
[885] Fix | Delete
//return intval($qval); // 5
[886] Fix | Delete
return round($qval, 1); // 5 or 4.9
[887] Fix | Delete
}
[888] Fix | Delete
[889] Fix | Delete
/**
[890] Fix | Delete
* @param int $colorspace_id
[891] Fix | Delete
*
[892] Fix | Delete
* @return string|null
[893] Fix | Delete
*/
[894] Fix | Delete
public static function TheoraColorSpace($colorspace_id) {
[895] Fix | Delete
// http://www.theora.org/doc/Theora.pdf (table 6.3)
[896] Fix | Delete
static $TheoraColorSpaceLookup = array();
[897] Fix | Delete
if (empty($TheoraColorSpaceLookup)) {
[898] Fix | Delete
$TheoraColorSpaceLookup[0] = 'Undefined';
[899] Fix | Delete
$TheoraColorSpaceLookup[1] = 'Rec. 470M';
[900] Fix | Delete
$TheoraColorSpaceLookup[2] = 'Rec. 470BG';
[901] Fix | Delete
$TheoraColorSpaceLookup[3] = 'Reserved';
[902] Fix | Delete
}
[903] Fix | Delete
return (isset($TheoraColorSpaceLookup[$colorspace_id]) ? $TheoraColorSpaceLookup[$colorspace_id] : null);
[904] Fix | Delete
}
[905] Fix | Delete
[906] Fix | Delete
/**
[907] Fix | Delete
* @param int $pixelformat_id
[908] Fix | Delete
*
[909] Fix | Delete
* @return string|null
[910] Fix | Delete
*/
[911] Fix | Delete
public static function TheoraPixelFormat($pixelformat_id) {
[912] Fix | Delete
// http://www.theora.org/doc/Theora.pdf (table 6.4)
[913] Fix | Delete
static $TheoraPixelFormatLookup = array();
[914] Fix | Delete
if (empty($TheoraPixelFormatLookup)) {
[915] Fix | Delete
$TheoraPixelFormatLookup[0] = '4:2:0';
[916] Fix | Delete
$TheoraPixelFormatLookup[1] = 'Reserved';
[917] Fix | Delete
$TheoraPixelFormatLookup[2] = '4:2:2';
[918] Fix | Delete
$TheoraPixelFormatLookup[3] = '4:4:4';
[919] Fix | Delete
}
[920] Fix | Delete
return (isset($TheoraPixelFormatLookup[$pixelformat_id]) ? $TheoraPixelFormatLookup[$pixelformat_id] : null);
[921] Fix | Delete
}
[922] Fix | Delete
[923] Fix | Delete
}
[924] Fix | Delete
[925] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function