type $MPEGaudioVersionLookup type $MPEGaudioLayerLookup type $MPEGaudioBitrateLookup type $MPEGaudioFrequencyLookup type $MPEGaudioChannelModeLookup type $MPEGaudioModeExtensionLookup type $MPEGaudioEmphasisLookup array $MPEGaudioHeaderDecodeCache array $MPEGaudioHeaderValidCache
458 static $MPEGaudioVersionLookup;
459 static $MPEGaudioLayerLookup;
460 static $MPEGaudioBitrateLookup;
461 static $MPEGaudioFrequencyLookup;
462 static $MPEGaudioChannelModeLookup;
463 static $MPEGaudioModeExtensionLookup;
464 static $MPEGaudioEmphasisLookup;
465 if (empty($MPEGaudioVersionLookup)) {
466 $MPEGaudioVersionLookup = self::MPEGaudioVersionArray();
467 $MPEGaudioLayerLookup = self::MPEGaudioLayerArray();
468 $MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray();
469 $MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray();
470 $MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray();
471 $MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray();
472 $MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray();
475 if (
fseek($this->getid3->fp, $offset, SEEK_SET) != 0) {
476 $info[
'error'][] =
'decodeMPEGaudioHeader() failed to seek to next offset at ' . $offset;
481 $headerstring =
fread($this->getid3->fp, 226);
488 $head4 = substr($headerstring, 0, 4);
490 static $MPEGaudioHeaderDecodeCache =
array();
491 if (isset($MPEGaudioHeaderDecodeCache[$head4])) {
492 $MPEGheaderRawArray = $MPEGaudioHeaderDecodeCache[$head4];
494 $MPEGheaderRawArray = self::MPEGaudioHeaderDecode($head4);
495 $MPEGaudioHeaderDecodeCache[$head4] = $MPEGheaderRawArray;
498 static $MPEGaudioHeaderValidCache =
array();
499 if (!isset($MPEGaudioHeaderValidCache[$head4])) {
501 $MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGheaderRawArray,
507 if (!isset(
$info[
'mpeg'][
'audio'])) {
510 $thisfile_mpeg_audio = &
$info[
'mpeg'][
'audio'];
512 if ($MPEGaudioHeaderValidCache[$head4]) {
513 $thisfile_mpeg_audio[
'raw'] = $MPEGheaderRawArray;
520 if (!$FastMPEGheaderScan) {
521 $thisfile_mpeg_audio[
'version'] = $MPEGaudioVersionLookup[$thisfile_mpeg_audio[
'raw'][
'version']];
522 $thisfile_mpeg_audio[
'layer'] = $MPEGaudioLayerLookup[$thisfile_mpeg_audio[
'raw'][
'layer']];
524 $thisfile_mpeg_audio[
'channelmode'] = $MPEGaudioChannelModeLookup[$thisfile_mpeg_audio[
'raw'][
'channelmode']];
525 $thisfile_mpeg_audio[
'channels'] = (($thisfile_mpeg_audio[
'channelmode'] ==
'mono') ? 1 : 2);
526 $thisfile_mpeg_audio[
'sample_rate'] = $MPEGaudioFrequencyLookup[$thisfile_mpeg_audio[
'version']][$thisfile_mpeg_audio[
'raw'][
'sample_rate']];
527 $thisfile_mpeg_audio[
'protection'] = !$thisfile_mpeg_audio[
'raw'][
'protection'];
528 $thisfile_mpeg_audio[
'private'] = (bool) $thisfile_mpeg_audio[
'raw'][
'private'];
529 $thisfile_mpeg_audio[
'modeextension'] = $MPEGaudioModeExtensionLookup[$thisfile_mpeg_audio[
'layer']][$thisfile_mpeg_audio[
'raw'][
'modeextension']];
530 $thisfile_mpeg_audio[
'copyright'] = (bool) $thisfile_mpeg_audio[
'raw'][
'copyright'];
531 $thisfile_mpeg_audio[
'original'] = (bool) $thisfile_mpeg_audio[
'raw'][
'original'];
532 $thisfile_mpeg_audio[
'emphasis'] = $MPEGaudioEmphasisLookup[$thisfile_mpeg_audio[
'raw'][
'emphasis']];
534 $info[
'audio'][
'channels'] = $thisfile_mpeg_audio[
'channels'];
535 $info[
'audio'][
'sample_rate'] = $thisfile_mpeg_audio[
'sample_rate'];
537 if ($thisfile_mpeg_audio[
'protection']) {
544 if ($thisfile_mpeg_audio[
'raw'][
'bitrate'] == 15) {
546 $info[
'warning'][] =
'Invalid bitrate index (15), this is a known bug in free-format MP3s encoded by LAME v3.90 - 3.93.1';
547 $thisfile_mpeg_audio[
'raw'][
'bitrate'] = 0;
549 $thisfile_mpeg_audio[
'padding'] = (bool) $thisfile_mpeg_audio[
'raw'][
'padding'];
550 $thisfile_mpeg_audio[
'bitrate'] = $MPEGaudioBitrateLookup[$thisfile_mpeg_audio[
'version']][$thisfile_mpeg_audio[
'layer']][$thisfile_mpeg_audio[
'raw'][
'bitrate']];
552 if (($thisfile_mpeg_audio[
'bitrate'] ==
'free') && ($offset ==
$info[
'avdataoffset'])) {
555 $recursivesearch =
false;
559 if (!$FastMPEGheaderScan && ($thisfile_mpeg_audio[
'layer'] ==
'2')) {
561 $info[
'audio'][
'dataformat'] =
'mp2';
562 switch ($thisfile_mpeg_audio[
'channelmode']) {
565 if (($thisfile_mpeg_audio[
'bitrate'] ==
'free') || ($thisfile_mpeg_audio[
'bitrate'] <= 192000)) {
568 $info[
'error'][] = $thisfile_mpeg_audio[
'bitrate'] .
'kbps not allowed in Layer 2, ' . $thisfile_mpeg_audio[
'channelmode'] .
'.';
577 if (($thisfile_mpeg_audio[
'bitrate'] ==
'free') || ($thisfile_mpeg_audio[
'bitrate'] == 64000) || ($thisfile_mpeg_audio[
'bitrate'] >= 96000)) {
580 $info[
'error'][] = intval(round($thisfile_mpeg_audio[
'bitrate'] / 1000)) .
'kbps not allowed in Layer 2, ' . $thisfile_mpeg_audio[
'channelmode'] .
'.';
588 if (
$info[
'audio'][
'sample_rate'] > 0) {
589 $thisfile_mpeg_audio[
'framelength'] = self::MPEGaudioFrameLength($thisfile_mpeg_audio[
'bitrate'],
590 $thisfile_mpeg_audio[
'version'],
591 $thisfile_mpeg_audio[
'layer'],
592 (
int) $thisfile_mpeg_audio[
'padding'],
593 $info[
'audio'][
'sample_rate']);
596 $nextframetestoffset = $offset + 1;
597 if ($thisfile_mpeg_audio[
'bitrate'] !=
'free') {
599 $info[
'audio'][
'bitrate'] = $thisfile_mpeg_audio[
'bitrate'];
601 if (isset($thisfile_mpeg_audio[
'framelength'])) {
602 $nextframetestoffset = $offset + $thisfile_mpeg_audio[
'framelength'];
604 $info[
'error'][] =
'Frame at offset(' . $offset .
') is has an invalid frame length.';
610 $ExpectedNumberOfAudioBytes = 0;
615 if (substr($headerstring, 4 + 32, 4) ==
'VBRI') {
619 $thisfile_mpeg_audio[
'bitrate_mode'] =
'vbr';
620 $thisfile_mpeg_audio[
'VBR_method'] =
'Fraunhofer';
621 $info[
'audio'][
'codec'] =
'Fraunhofer';
623 $SideInfoData = substr($headerstring, 4 + 2, 32);
625 $FraunhoferVBROffset = 36;
628 $FraunhoferVBROffset + 4,
631 $FraunhoferVBROffset + 6,
634 $FraunhoferVBROffset + 8,
637 $FraunhoferVBROffset + 10,
640 $FraunhoferVBROffset + 14,
643 $FraunhoferVBROffset + 18,
646 $FraunhoferVBROffset + 20,
649 $FraunhoferVBROffset + 22,
652 $FraunhoferVBROffset + 24,
655 $ExpectedNumberOfAudioBytes = $thisfile_mpeg_audio[
'VBR_bytes'];
657 $previousbyteoffset = $offset;
658 for ($i = 0; $i < $thisfile_mpeg_audio[
'VBR_seek_offsets']; $i++) {
660 $FraunhoferVBROffset,
661 $thisfile_mpeg_audio[
'VBR_entry_bytes']));
662 $FraunhoferVBROffset += $thisfile_mpeg_audio[
'VBR_entry_bytes'];
663 $thisfile_mpeg_audio[
'VBR_offsets_relative'][$i] = ($Fraunhofer_OffsetN * $thisfile_mpeg_audio[
'VBR_seek_scale']);
664 $thisfile_mpeg_audio[
'VBR_offsets_absolute'][$i] = ($Fraunhofer_OffsetN * $thisfile_mpeg_audio[
'VBR_seek_scale']) + $previousbyteoffset;
665 $previousbyteoffset += $Fraunhofer_OffsetN;
672 $VBRidOffset = self::XingVBRidOffset($thisfile_mpeg_audio[
'version'],
673 $thisfile_mpeg_audio[
'channelmode']);
674 $SideInfoData = substr($headerstring, 4 + 2, $VBRidOffset - 4);
676 if ((substr($headerstring, $VBRidOffset, strlen(
'Xing')) ==
'Xing') || (substr($headerstring,
678 strlen(
'Info')) ==
'Info')) {
702 $thisfile_mpeg_audio[
'bitrate_mode'] =
'vbr';
703 $thisfile_mpeg_audio[
'VBR_method'] =
'Xing';
713 $thisfile_mpeg_audio[
'xing_flags'][
'frames'] = (bool) ($thisfile_mpeg_audio[
'xing_flags_raw'] & 0x00000001);
714 $thisfile_mpeg_audio[
'xing_flags'][
'bytes'] = (bool) ($thisfile_mpeg_audio[
'xing_flags_raw'] & 0x00000002);
715 $thisfile_mpeg_audio[
'xing_flags'][
'toc'] = (bool) ($thisfile_mpeg_audio[
'xing_flags_raw'] & 0x00000004);
716 $thisfile_mpeg_audio[
'xing_flags'][
'vbr_scale'] = (bool) ($thisfile_mpeg_audio[
'xing_flags_raw'] & 0x00000008);
718 if ($thisfile_mpeg_audio[
'xing_flags'][
'frames']) {
724 if ($thisfile_mpeg_audio[
'xing_flags'][
'bytes']) {
731 if (!empty($thisfile_mpeg_audio[
'VBR_frames']) && !empty($thisfile_mpeg_audio[
'VBR_bytes'])) {
733 $framelengthfloat = $thisfile_mpeg_audio[
'VBR_bytes'] / $thisfile_mpeg_audio[
'VBR_frames'];
735 if ($thisfile_mpeg_audio[
'layer'] ==
'1') {
738 $info[
'audio'][
'bitrate'] = ($framelengthfloat / 4) * $thisfile_mpeg_audio[
'sample_rate'] * (2 /
$info[
'audio'][
'channels']) / 12;
742 $info[
'audio'][
'bitrate'] = $framelengthfloat * $thisfile_mpeg_audio[
'sample_rate'] * (2 /
$info[
'audio'][
'channels']) / 144;
744 $thisfile_mpeg_audio[
'framelength'] = floor($framelengthfloat);
747 if ($thisfile_mpeg_audio[
'xing_flags'][
'toc']) {
748 $LAMEtocData = substr($headerstring, $VBRidOffset + 16, 100);
749 for ($i = 0; $i < 100; $i++) {
750 $thisfile_mpeg_audio[
'toc'][$i] = ord($LAMEtocData{$i});
753 if ($thisfile_mpeg_audio[
'xing_flags'][
'vbr_scale']) {
761 if (substr($headerstring, $VBRidOffset + 120, 4) ==
'LAME') {
764 $thisfile_mpeg_audio[
'LAME'] =
array();
765 $thisfile_mpeg_audio_lame = &$thisfile_mpeg_audio[
'LAME'];
768 $thisfile_mpeg_audio_lame[
'long_version'] = substr($headerstring,
771 $thisfile_mpeg_audio_lame[
'short_version'] = substr($thisfile_mpeg_audio_lame[
'long_version'],
774 if ($thisfile_mpeg_audio_lame[
'short_version'] >=
'LAME3.90') {
777 unset($thisfile_mpeg_audio_lame[
'long_version']);
784 $LAMEtagOffsetContant = $VBRidOffset - 0x24;
787 $thisfile_mpeg_audio_lame[
'RGAD'] =
array(
'track' =>
array(),
'album' =>
array());
788 $thisfile_mpeg_audio_lame_RGAD = &$thisfile_mpeg_audio_lame[
'RGAD'];
789 $thisfile_mpeg_audio_lame_RGAD_track = &$thisfile_mpeg_audio_lame_RGAD[
'track'];
790 $thisfile_mpeg_audio_lame_RGAD_album = &$thisfile_mpeg_audio_lame_RGAD[
'album'];
791 $thisfile_mpeg_audio_lame[
'raw'] =
array();
792 $thisfile_mpeg_audio_lame_raw = &$thisfile_mpeg_audio_lame[
'raw'];
797 unset($thisfile_mpeg_audio[
'VBR_scale']);
799 $LAMEtagOffsetContant + 0x9B,
803 $thisfile_mpeg_audio_lame[
'short_version'] = substr($headerstring,
804 $LAMEtagOffsetContant + 0x9C,
809 $LAMEtagOffsetContant + 0xA5,
812 $thisfile_mpeg_audio_lame[
'tag_revision'] = ($LAMEtagRevisionVBRmethod & 0xF0) >> 4;
813 $thisfile_mpeg_audio_lame_raw[
'vbr_method'] = $LAMEtagRevisionVBRmethod & 0x0F;
814 $thisfile_mpeg_audio_lame[
'vbr_method'] = self::LAMEvbrMethodLookup($thisfile_mpeg_audio_lame_raw[
'vbr_method']);
815 $thisfile_mpeg_audio[
'bitrate_mode'] = substr($thisfile_mpeg_audio_lame[
'vbr_method'],
819 $LAMEtagOffsetContant + 0xA6,
825 if ($thisfile_mpeg_audio_lame[
'short_version'] >=
'LAME3.94b') {
828 $thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'] = (float) ((
Helper::BigEndian2Int(substr($headerstring,
829 $LAMEtagOffsetContant + 0xA7,
835 $LAMEtagOffsetContant + 0xA7,
838 if ($thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'] == 0) {
839 unset($thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude']);
841 $thisfile_mpeg_audio_lame_RGAD[
'peak_db'] =
Helper::RGADamplitude2dB($thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude']);
845 $LAMEtagOffsetContant + 0xAB,
848 $LAMEtagOffsetContant + 0xAD,
852 if ($thisfile_mpeg_audio_lame_raw[
'RGAD_track'] != 0) {
854 $thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'name'] = ($thisfile_mpeg_audio_lame_raw[
'RGAD_track'] & 0xE000) >> 13;
855 $thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'originator'] = ($thisfile_mpeg_audio_lame_raw[
'RGAD_track'] & 0x1C00) >> 10;
856 $thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'sign_bit'] = ($thisfile_mpeg_audio_lame_raw[
'RGAD_track'] & 0x0200) >> 9;
857 $thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'gain_adjust'] = $thisfile_mpeg_audio_lame_raw[
'RGAD_track'] & 0x01FF;
858 $thisfile_mpeg_audio_lame_RGAD_track[
'name'] =
Helper::RGADnameLookup($thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'name']);
859 $thisfile_mpeg_audio_lame_RGAD_track[
'originator'] =
Helper::RGADoriginatorLookup($thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'originator']);
860 $thisfile_mpeg_audio_lame_RGAD_track[
'gain_db'] =
Helper::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'gain_adjust'],
861 $thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'sign_bit']);
863 if (!empty($thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'])) {
864 $info[
'replay_gain'][
'track'][
'peak'] = $thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'];
866 $info[
'replay_gain'][
'track'][
'originator'] = $thisfile_mpeg_audio_lame_RGAD_track[
'originator'];
867 $info[
'replay_gain'][
'track'][
'adjustment'] = $thisfile_mpeg_audio_lame_RGAD_track[
'gain_db'];
869 unset($thisfile_mpeg_audio_lame_RGAD[
'track']);
871 if ($thisfile_mpeg_audio_lame_raw[
'RGAD_album'] != 0) {
873 $thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'name'] = ($thisfile_mpeg_audio_lame_raw[
'RGAD_album'] & 0xE000) >> 13;
874 $thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'originator'] = ($thisfile_mpeg_audio_lame_raw[
'RGAD_album'] & 0x1C00) >> 10;
875 $thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'sign_bit'] = ($thisfile_mpeg_audio_lame_raw[
'RGAD_album'] & 0x0200) >> 9;
876 $thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'gain_adjust'] = $thisfile_mpeg_audio_lame_raw[
'RGAD_album'] & 0x01FF;
877 $thisfile_mpeg_audio_lame_RGAD_album[
'name'] =
Helper::RGADnameLookup($thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'name']);
878 $thisfile_mpeg_audio_lame_RGAD_album[
'originator'] =
Helper::RGADoriginatorLookup($thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'originator']);
879 $thisfile_mpeg_audio_lame_RGAD_album[
'gain_db'] =
Helper::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'gain_adjust'],
880 $thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'sign_bit']);
882 if (!empty($thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'])) {
883 $info[
'replay_gain'][
'album'][
'peak'] = $thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'];
885 $info[
'replay_gain'][
'album'][
'originator'] = $thisfile_mpeg_audio_lame_RGAD_album[
'originator'];
886 $info[
'replay_gain'][
'album'][
'adjustment'] = $thisfile_mpeg_audio_lame_RGAD_album[
'gain_db'];
888 unset($thisfile_mpeg_audio_lame_RGAD[
'album']);
890 if (empty($thisfile_mpeg_audio_lame_RGAD)) {
891 unset($thisfile_mpeg_audio_lame[
'RGAD']);
897 $LAMEtagOffsetContant + 0xAF,
899 $thisfile_mpeg_audio_lame[
'encoding_flags'][
'nspsytune'] = (bool) ($EncodingFlagsATHtype & 0x10);
900 $thisfile_mpeg_audio_lame[
'encoding_flags'][
'nssafejoint'] = (bool) ($EncodingFlagsATHtype & 0x20);
901 $thisfile_mpeg_audio_lame[
'encoding_flags'][
'nogap_next'] = (bool) ($EncodingFlagsATHtype & 0x40);
902 $thisfile_mpeg_audio_lame[
'encoding_flags'][
'nogap_prev'] = (bool) ($EncodingFlagsATHtype & 0x80);
903 $thisfile_mpeg_audio_lame[
'ath_type'] = $EncodingFlagsATHtype & 0x0F;
906 $thisfile_mpeg_audio_lame[
'raw'][
'abrbitrate_minbitrate'] =
Helper::BigEndian2Int(substr($headerstring,
907 $LAMEtagOffsetContant + 0xB0,
909 if ($thisfile_mpeg_audio_lame_raw[
'vbr_method'] == 2) {
910 $thisfile_mpeg_audio_lame[
'bitrate_abr'] = $thisfile_mpeg_audio_lame[
'raw'][
'abrbitrate_minbitrate'];
911 } elseif ($thisfile_mpeg_audio_lame_raw[
'vbr_method'] == 1) {
913 } elseif ($thisfile_mpeg_audio_lame[
'raw'][
'abrbitrate_minbitrate'] > 0) {
914 $thisfile_mpeg_audio_lame[
'bitrate_min'] = $thisfile_mpeg_audio_lame[
'raw'][
'abrbitrate_minbitrate'];
919 $LAMEtagOffsetContant + 0xB1,
921 $thisfile_mpeg_audio_lame[
'encoder_delay'] = ($EncoderDelays & 0xFFF000) >> 12;
922 $thisfile_mpeg_audio_lame[
'end_padding'] = $EncoderDelays & 0x000FFF;
926 $LAMEtagOffsetContant + 0xB4,
928 $thisfile_mpeg_audio_lame_raw[
'noise_shaping'] = ($MiscByte & 0x03);
929 $thisfile_mpeg_audio_lame_raw[
'stereo_mode'] = ($MiscByte & 0x1C) >> 2;
930 $thisfile_mpeg_audio_lame_raw[
'not_optimal_quality'] = ($MiscByte & 0x20) >> 5;
931 $thisfile_mpeg_audio_lame_raw[
'source_sample_freq'] = ($MiscByte & 0xC0) >> 6;
932 $thisfile_mpeg_audio_lame[
'noise_shaping'] = $thisfile_mpeg_audio_lame_raw[
'noise_shaping'];
933 $thisfile_mpeg_audio_lame[
'stereo_mode'] = self::LAMEmiscStereoModeLookup($thisfile_mpeg_audio_lame_raw[
'stereo_mode']);
934 $thisfile_mpeg_audio_lame[
'not_optimal_quality'] = (bool) $thisfile_mpeg_audio_lame_raw[
'not_optimal_quality'];
935 $thisfile_mpeg_audio_lame[
'source_sample_freq'] = self::LAMEmiscSourceSampleFrequencyLookup($thisfile_mpeg_audio_lame_raw[
'source_sample_freq']);
939 $LAMEtagOffsetContant + 0xB5,
943 $thisfile_mpeg_audio_lame[
'mp3_gain_db'] = (
Helper::RGADamplitude2dB(2) / 4) * $thisfile_mpeg_audio_lame_raw[
'mp3_gain'];
944 $thisfile_mpeg_audio_lame[
'mp3_gain_factor'] = pow(2,
945 ($thisfile_mpeg_audio_lame[
'mp3_gain_db'] / 6));
949 $LAMEtagOffsetContant + 0xB6,
952 $thisfile_mpeg_audio_lame_raw[
'surround_info'] = ($PresetSurroundBytes & 0x3800);
953 $thisfile_mpeg_audio_lame[
'surround_info'] = self::LAMEsurroundInfoLookup($thisfile_mpeg_audio_lame_raw[
'surround_info']);
954 $thisfile_mpeg_audio_lame[
'preset_used_id'] = ($PresetSurroundBytes & 0x07FF);
955 $thisfile_mpeg_audio_lame[
'preset_used'] = self::LAMEpresetUsedLookup($thisfile_mpeg_audio_lame);
956 if (!empty($thisfile_mpeg_audio_lame[
'preset_used_id']) && empty($thisfile_mpeg_audio_lame[
'preset_used'])) {
957 $info[
'warning'][] =
'Unknown LAME preset used (' . $thisfile_mpeg_audio_lame[
'preset_used_id'] .
') - please report to info@getid3.org';
959 if (($thisfile_mpeg_audio_lame[
'short_version'] ==
'LAME3.90.') && !empty($thisfile_mpeg_audio_lame[
'preset_used_id'])) {
961 $thisfile_mpeg_audio_lame[
'short_version'] =
'LAME3.90.3';
966 $LAMEtagOffsetContant + 0xB8,
968 $ExpectedNumberOfAudioBytes = (($thisfile_mpeg_audio_lame[
'audio_bytes'] > 0) ? $thisfile_mpeg_audio_lame[
'audio_bytes'] : $thisfile_mpeg_audio[
'VBR_bytes']);
972 $LAMEtagOffsetContant + 0xBC,
977 $LAMEtagOffsetContant + 0xBE,
982 if ($thisfile_mpeg_audio_lame_raw[
'vbr_method'] == 1) {
984 $thisfile_mpeg_audio[
'bitrate_mode'] =
'cbr';
985 $thisfile_mpeg_audio[
'bitrate'] = self::ClosestStandardMP3Bitrate($thisfile_mpeg_audio[
'bitrate']);
986 $info[
'audio'][
'bitrate'] = $thisfile_mpeg_audio[
'bitrate'];
996 $thisfile_mpeg_audio[
'bitrate_mode'] =
'cbr';
997 if ($recursivesearch) {
998 $thisfile_mpeg_audio[
'bitrate_mode'] =
'vbr';
1000 $nextframetestoffset,
true)) {
1001 $recursivesearch =
false;
1002 $thisfile_mpeg_audio[
'bitrate_mode'] =
'cbr';
1004 if ($thisfile_mpeg_audio[
'bitrate_mode'] ==
'vbr') {
1005 $info[
'warning'][] =
'VBR file with no VBR header. Bitrate values calculated from actual frame bitrates.';
1011 if (($ExpectedNumberOfAudioBytes > 0) && ($ExpectedNumberOfAudioBytes != (
$info[
'avdataend'] -
$info[
'avdataoffset']))) {
1012 if ($ExpectedNumberOfAudioBytes > (
$info[
'avdataend'] -
$info[
'avdataoffset'])) {
1013 if (isset(
$info[
'fileformat']) && (
$info[
'fileformat'] ==
'riff')) {
1015 } elseif (($ExpectedNumberOfAudioBytes - (
$info[
'avdataend'] -
$info[
'avdataoffset'])) == 1) {
1016 $info[
'warning'][] =
'Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)';
1018 $info[
'warning'][] =
'Probable truncated file: expecting ' . $ExpectedNumberOfAudioBytes .
' bytes of audio data, only found ' . (
$info[
'avdataend'] -
$info[
'avdataoffset']) .
' (short by ' . ($ExpectedNumberOfAudioBytes - (
$info[
'avdataend'] -
$info[
'avdataoffset'])) .
' bytes)';
1021 if (((
$info[
'avdataend'] -
$info[
'avdataoffset']) - $ExpectedNumberOfAudioBytes) == 1) {
1027 $info[
'avdataend']--;
1033 $info[
'warning'][] =
'Too much data in file: expecting ' . $ExpectedNumberOfAudioBytes .
' bytes of audio data, found ' . (
$info[
'avdataend'] -
$info[
'avdataoffset']) .
' (' . ((
$info[
'avdataend'] -
$info[
'avdataoffset']) - $ExpectedNumberOfAudioBytes) .
' bytes too many)';
1038 if (($thisfile_mpeg_audio[
'bitrate'] ==
'free') && empty(
$info[
'audio'][
'bitrate'])) {
1039 if (($offset ==
$info[
'avdataoffset']) && empty($thisfile_mpeg_audio[
'VBR_frames'])) {
1041 if ($framebytelength > 0) {
1042 $thisfile_mpeg_audio[
'framelength'] = $framebytelength;
1043 if ($thisfile_mpeg_audio[
'layer'] ==
'1') {
1045 $info[
'audio'][
'bitrate'] = ((($framebytelength / 4) - intval($thisfile_mpeg_audio[
'padding'])) * $thisfile_mpeg_audio[
'sample_rate']) / 12;
1048 $info[
'audio'][
'bitrate'] = (($framebytelength - intval($thisfile_mpeg_audio[
'padding'])) * $thisfile_mpeg_audio[
'sample_rate']) / 144;
1051 $info[
'error'][] =
'Error calculating frame length of free-format MP3 without Xing/LAME header';
1056 if (isset($thisfile_mpeg_audio[
'VBR_frames']) ? $thisfile_mpeg_audio[
'VBR_frames'] :
'') {
1057 switch ($thisfile_mpeg_audio[
'bitrate_mode']) {
1060 $bytes_per_frame = 1152;
1061 if (($thisfile_mpeg_audio[
'version'] ==
'1') && ($thisfile_mpeg_audio[
'layer'] == 1)) {
1062 $bytes_per_frame = 384;
1063 } elseif ((($thisfile_mpeg_audio[
'version'] ==
'2') || ($thisfile_mpeg_audio[
'version'] ==
'2.5')) && ($thisfile_mpeg_audio[
'layer'] == 3)) {
1064 $bytes_per_frame = 576;
1066 $thisfile_mpeg_audio[
'VBR_bitrate'] = (isset($thisfile_mpeg_audio[
'VBR_bytes']) ? (($thisfile_mpeg_audio[
'VBR_bytes'] / $thisfile_mpeg_audio[
'VBR_frames']) * 8) * (
$info[
'audio'][
'sample_rate'] / $bytes_per_frame) : 0);
1067 if ($thisfile_mpeg_audio[
'VBR_bitrate'] > 0) {
1068 $info[
'audio'][
'bitrate'] = $thisfile_mpeg_audio[
'VBR_bitrate'];
1069 $thisfile_mpeg_audio[
'bitrate'] = $thisfile_mpeg_audio[
'VBR_bitrate'];
1078 if ($recursivesearch) {
FreeFormatFrameLength($offset, $deepscan=false)
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
static RGADamplitude2dB($amplitude)
fseek($bytes, $whence=SEEK_SET)
static RGADadjustmentLookup($rawadjustment, $signbit)
static RGADnameLookup($namecode)
array $RGADname
Create styles array
The data for the language used.
static RGADoriginatorLookup($originatorcode)
array $RGADoriginator
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
RecursiveFrameScanning(&$offset, &$nextframetestoffset, $ScanAsCBR)
static LittleEndian2Float($byteword)