22define(
'GETID3_MP3_VALID_CHECK_FRAMES', 35);
 
   31                $info = &$this->getid3->info;
 
   33                $initialOffset = 
$info[
'avdataoffset'];
 
   36                        if ($this->allow_bruteforce) {
 
   37                                $this->
error(
'Rescanning file in BruteForce mode');
 
   43                if (isset(
$info[
'mpeg'][
'audio'][
'bitrate_mode'])) {
 
   44                        $info[
'audio'][
'bitrate_mode'] = strtolower(
$info[
'mpeg'][
'audio'][
'bitrate_mode']);
 
   47                if (((isset(
$info[
'id3v2'][
'headerlength']) && (
$info[
'avdataoffset'] > 
$info[
'id3v2'][
'headerlength'])) || (!isset(
$info[
'id3v2']) && (
$info[
'avdataoffset'] > 0) && (
$info[
'avdataoffset'] != $initialOffset)))) {
 
   49                        $synchoffsetwarning = 
'Unknown data before synch ';
 
   50                        if (isset(
$info[
'id3v2'][
'headerlength'])) {
 
   51                                $synchoffsetwarning .= 
'(ID3v2 header ends at '.$info[
'id3v2'][
'headerlength'].
', then '.(
$info[
'avdataoffset'] - 
$info[
'id3v2'][
'headerlength']).
' bytes garbage, ';
 
   52                        } elseif ($initialOffset > 0) {
 
   53                                $synchoffsetwarning .= 
'(should be at '.$initialOffset.
', ';
 
   55                                $synchoffsetwarning .= 
'(should be at beginning of file, ';
 
   57                        $synchoffsetwarning .= 
'synch detected at '.$info[
'avdataoffset'].
')';
 
   58                        if (isset(
$info[
'audio'][
'bitrate_mode']) && (
$info[
'audio'][
'bitrate_mode'] == 
'cbr')) {
 
   60                                if (!empty(
$info[
'id3v2'][
'headerlength']) && ((
$info[
'avdataoffset'] - 
$info[
'id3v2'][
'headerlength']) == 
$info[
'mpeg'][
'audio'][
'framelength'])) {
 
   62                                        $synchoffsetwarning .= 
'. This is a known problem with some versions of LAME (3.90-3.92) DLL in CBR mode.';
 
   63                                        $info[
'audio'][
'codec'] = 
'LAME';
 
   64                                        $CurrentDataLAMEversionString = 
'LAME3.';
 
   66                                } elseif (empty(
$info[
'id3v2'][
'headerlength']) && (
$info[
'avdataoffset'] == 
$info[
'mpeg'][
'audio'][
'framelength'])) {
 
   68                                        $synchoffsetwarning .= 
'. This is a known problem with some versions of LAME (3.90 - 3.92) DLL in CBR mode.';
 
   69                                        $info[
'audio'][
'codec'] = 
'LAME';
 
   70                                        $CurrentDataLAMEversionString = 
'LAME3.';
 
   75                        $this->
warning($synchoffsetwarning);
 
   79                if (isset(
$info[
'mpeg'][
'audio'][
'LAME'])) {
 
   80                        $info[
'audio'][
'codec'] = 
'LAME';
 
   81                        if (!empty(
$info[
'mpeg'][
'audio'][
'LAME'][
'long_version'])) {
 
   82                                $info[
'audio'][
'encoder'] = rtrim(
$info[
'mpeg'][
'audio'][
'LAME'][
'long_version'], 
"\x00");
 
   83                        } elseif (!empty(
$info[
'mpeg'][
'audio'][
'LAME'][
'short_version'])) {
 
   84                                $info[
'audio'][
'encoder'] = rtrim(
$info[
'mpeg'][
'audio'][
'LAME'][
'short_version'], 
"\x00");
 
   88                $CurrentDataLAMEversionString = (!empty($CurrentDataLAMEversionString) ? $CurrentDataLAMEversionString : (isset(
$info[
'audio'][
'encoder']) ? 
$info[
'audio'][
'encoder'] : 
''));
 
   89                if (!empty($CurrentDataLAMEversionString) && (substr($CurrentDataLAMEversionString, 0, 6) == 
'LAME3.') && !preg_match(
'[0-9\)]', substr($CurrentDataLAMEversionString, -1))) {
 
   95                        $PossiblyLongerLAMEversion_FrameLength = 1441;
 
   98                        $PossibleLAMEversionStringOffset = 
$info[
'avdataend'] - $PossiblyLongerLAMEversion_FrameLength;
 
   99                        $this->
fseek($PossibleLAMEversionStringOffset);
 
  100                        $PossiblyLongerLAMEversion_Data = $this->
fread($PossiblyLongerLAMEversion_FrameLength);
 
  101                        switch (substr($CurrentDataLAMEversionString, -1)) {
 
  106                                        $CurrentDataLAMEversionString = substr($CurrentDataLAMEversionString, 0, -1);
 
  109                        if (($PossiblyLongerLAMEversion_String = strstr($PossiblyLongerLAMEversion_Data, $CurrentDataLAMEversionString)) !== 
false) {
 
  110                                if (substr($PossiblyLongerLAMEversion_String, 0, strlen($CurrentDataLAMEversionString)) == $CurrentDataLAMEversionString) {
 
  111                                        $PossiblyLongerLAMEversion_NewString = substr($PossiblyLongerLAMEversion_String, 0, strspn($PossiblyLongerLAMEversion_String, 
'LAME0123456789., (abcdefghijklmnopqrstuvwxyzJFSOND)')); 
 
  112                                        if (empty(
$info[
'audio'][
'encoder']) || (strlen($PossiblyLongerLAMEversion_NewString) > strlen(
$info[
'audio'][
'encoder']))) {
 
  113                                                $info[
'audio'][
'encoder'] = $PossiblyLongerLAMEversion_NewString;
 
  118                if (!empty(
$info[
'audio'][
'encoder'])) {
 
  119                        $info[
'audio'][
'encoder'] = rtrim(
$info[
'audio'][
'encoder'], 
"\x00 ");
 
  122                switch (isset(
$info[
'mpeg'][
'audio'][
'layer']) ? 
$info[
'mpeg'][
'audio'][
'layer'] : 
'') {
 
  125                                $info[
'audio'][
'dataformat'] = 
'mp'.$info[
'mpeg'][
'audio'][
'layer'];
 
  128                if (isset(
$info[
'fileformat']) && (
$info[
'fileformat'] == 
'mp3')) {
 
  129                        switch (
$info[
'audio'][
'dataformat']) {
 
  133                                        $info[
'fileformat'] = 
$info[
'audio'][
'dataformat'];
 
  137                                        $this->
warning(
'Expecting [audio][dataformat] to be mp1/mp2/mp3 when fileformat == mp3, [audio][dataformat] actually "'.$info[
'audio'][
'dataformat'].
'"');
 
  142                if (empty(
$info[
'fileformat'])) {
 
  143                        unset(
$info[
'fileformat']);
 
  144                        unset(
$info[
'audio'][
'bitrate_mode']);
 
  145                        unset(
$info[
'avdataoffset']);
 
  146                        unset(
$info[
'avdataend']);
 
  150                $info[
'mime_type']         = 
'audio/mpeg';
 
  151                $info[
'audio'][
'lossless'] = 
false;
 
  154                if (!isset(
$info[
'playtime_seconds']) && isset(
$info[
'audio'][
'bitrate']) && (
$info[
'audio'][
'bitrate'] > 0)) {
 
  155                        $info[
'playtime_seconds'] = (
$info[
'avdataend'] - 
$info[
'avdataoffset']) * 8 / 
$info[
'audio'][
'bitrate'];
 
  166                $info = &$this->getid3->info;
 
  167                if (!empty(
$info[
'mpeg'][
'audio'])) {
 
  168                        $thisfile_mpeg_audio = &
$info[
'mpeg'][
'audio'];
 
  169                        if (!empty($thisfile_mpeg_audio[
'LAME'])) {
 
  170                                $thisfile_mpeg_audio_lame = &$thisfile_mpeg_audio[
'LAME'];
 
  174                $encoder_options = 
'';
 
  175                static $NamedPresetBitrates = array(16, 24, 40, 56, 112, 128, 160, 192, 256);
 
  177                if (isset($thisfile_mpeg_audio[
'VBR_method']) && ($thisfile_mpeg_audio[
'VBR_method'] == 
'Fraunhofer') && !empty($thisfile_mpeg_audio[
'VBR_quality'])) {
 
  179                        $encoder_options = 
'VBR q'.$thisfile_mpeg_audio[
'VBR_quality'];
 
  181                } elseif (!empty($thisfile_mpeg_audio_lame[
'preset_used']) && (!in_array($thisfile_mpeg_audio_lame[
'preset_used_id'], $NamedPresetBitrates))) {
 
  183                        $encoder_options = $thisfile_mpeg_audio_lame[
'preset_used'];
 
  185                } elseif (!empty($thisfile_mpeg_audio_lame[
'vbr_quality'])) {
 
  187                        static $KnownEncoderValues = array();
 
  188                        if (empty($KnownEncoderValues)) {
 
  191                                $KnownEncoderValues[0xFF][58][1][1][3][2][20500] = 
'--alt-preset insane';        
 
  192                                $KnownEncoderValues[0xFF][58][1][1][3][2][20600] = 
'--alt-preset insane';        
 
  193                                $KnownEncoderValues[0xFF][57][1][1][3][4][20500] = 
'--alt-preset insane';        
 
  194                                $KnownEncoderValues[
'**'][78][3][2][3][2][19500] = 
'--alt-preset extreme';       
 
  195                                $KnownEncoderValues[
'**'][78][3][2][3][2][19600] = 
'--alt-preset extreme';       
 
  196                                $KnownEncoderValues[
'**'][78][3][1][3][2][19600] = 
'--alt-preset extreme';       
 
  197                                $KnownEncoderValues[
'**'][78][4][2][3][2][19500] = 
'--alt-preset fast extreme';  
 
  198                                $KnownEncoderValues[
'**'][78][4][2][3][2][19600] = 
'--alt-preset fast extreme';  
 
  199                                $KnownEncoderValues[
'**'][78][3][2][3][4][19000] = 
'--alt-preset standard';      
 
  200                                $KnownEncoderValues[
'**'][78][3][1][3][4][19000] = 
'--alt-preset standard';      
 
  201                                $KnownEncoderValues[
'**'][78][4][2][3][4][19000] = 
'--alt-preset fast standard'; 
 
  202                                $KnownEncoderValues[
'**'][78][4][1][3][4][19000] = 
'--alt-preset fast standard'; 
 
  203                                $KnownEncoderValues[
'**'][88][4][1][3][3][19500] = 
'--r3mix';                    
 
  204                                $KnownEncoderValues[
'**'][88][4][1][3][3][19600] = 
'--r3mix';                    
 
  205                                $KnownEncoderValues[
'**'][67][4][1][3][4][18000] = 
'--r3mix';                    
 
  206                                $KnownEncoderValues[
'**'][68][3][2][3][4][18000] = 
'--alt-preset medium';        
 
  207                                $KnownEncoderValues[
'**'][68][4][2][3][4][18000] = 
'--alt-preset fast medium';   
 
  209                                $KnownEncoderValues[0xFF][99][1][1][1][2][0]     = 
'--preset studio';            
 
  210                                $KnownEncoderValues[0xFF][58][2][1][3][2][20600] = 
'--preset studio';            
 
  211                                $KnownEncoderValues[0xFF][58][2][1][3][2][20500] = 
'--preset studio';            
 
  212                                $KnownEncoderValues[0xFF][57][2][1][3][4][20500] = 
'--preset studio';            
 
  213                                $KnownEncoderValues[0xC0][88][1][1][1][2][0]     = 
'--preset cd';                
 
  214                                $KnownEncoderValues[0xC0][58][2][2][3][2][19600] = 
'--preset cd';                
 
  215                                $KnownEncoderValues[0xC0][58][2][2][3][2][19500] = 
'--preset cd';                
 
  216                                $KnownEncoderValues[0xC0][57][2][1][3][4][19500] = 
'--preset cd';                
 
  217                                $KnownEncoderValues[0xA0][78][1][1][3][2][18000] = 
'--preset hifi';              
 
  218                                $KnownEncoderValues[0xA0][58][2][2][3][2][18000] = 
'--preset hifi';              
 
  219                                $KnownEncoderValues[0xA0][57][2][1][3][4][18000] = 
'--preset hifi';              
 
  220                                $KnownEncoderValues[0x80][67][1][1][3][2][18000] = 
'--preset tape';              
 
  221                                $KnownEncoderValues[0x80][67][1][1][3][2][15000] = 
'--preset radio';             
 
  222                                $KnownEncoderValues[0x70][67][1][1][3][2][15000] = 
'--preset fm';                
 
  223                                $KnownEncoderValues[0x70][58][2][2][3][2][16000] = 
'--preset tape/radio/fm';     
 
  224                                $KnownEncoderValues[0x70][57][2][1][3][4][16000] = 
'--preset tape/radio/fm';     
 
  225                                $KnownEncoderValues[0x38][58][2][2][0][2][10000] = 
'--preset voice';             
 
  226                                $KnownEncoderValues[0x38][57][2][1][0][4][15000] = 
'--preset voice';             
 
  227                                $KnownEncoderValues[0x38][57][2][1][0][4][16000] = 
'--preset voice';             
 
  228                                $KnownEncoderValues[0x28][65][1][1][0][2][7500]  = 
'--preset mw-us';             
 
  229                                $KnownEncoderValues[0x28][65][1][1][0][2][7600]  = 
'--preset mw-us';             
 
  230                                $KnownEncoderValues[0x28][58][2][2][0][2][7000]  = 
'--preset mw-us';             
 
  231                                $KnownEncoderValues[0x28][57][2][1][0][4][10500] = 
'--preset mw-us';             
 
  232                                $KnownEncoderValues[0x28][57][2][1][0][4][11200] = 
'--preset mw-us';             
 
  233                                $KnownEncoderValues[0x28][57][2][1][0][4][8800]  = 
'--preset mw-us';             
 
  234                                $KnownEncoderValues[0x18][58][2][2][0][2][4000]  = 
'--preset phon+/lw/mw-eu/sw'; 
 
  235                                $KnownEncoderValues[0x18][58][2][2][0][2][3900]  = 
'--preset phon+/lw/mw-eu/sw'; 
 
  236                                $KnownEncoderValues[0x18][57][2][1][0][4][5900]  = 
'--preset phon+/lw/mw-eu/sw'; 
 
  237                                $KnownEncoderValues[0x18][57][2][1][0][4][6200]  = 
'--preset phon+/lw/mw-eu/sw'; 
 
  238                                $KnownEncoderValues[0x18][57][2][1][0][4][3200]  = 
'--preset phon+/lw/mw-eu/sw'; 
 
  239                                $KnownEncoderValues[0x10][58][2][2][0][2][3800]  = 
'--preset phone';             
 
  240                                $KnownEncoderValues[0x10][58][2][2][0][2][3700]  = 
'--preset phone';             
 
  241                                $KnownEncoderValues[0x10][57][2][1][0][4][5600]  = 
'--preset phone';             
 
  244                        if (isset($KnownEncoderValues[$thisfile_mpeg_audio_lame[
'raw'][
'abrbitrate_minbitrate']][$thisfile_mpeg_audio_lame[
'vbr_quality']][$thisfile_mpeg_audio_lame[
'raw'][
'vbr_method']][$thisfile_mpeg_audio_lame[
'raw'][
'noise_shaping']][$thisfile_mpeg_audio_lame[
'raw'][
'stereo_mode']][$thisfile_mpeg_audio_lame[
'ath_type']][$thisfile_mpeg_audio_lame[
'lowpass_frequency']])) {
 
  246                                $encoder_options = $KnownEncoderValues[$thisfile_mpeg_audio_lame[
'raw'][
'abrbitrate_minbitrate']][$thisfile_mpeg_audio_lame[
'vbr_quality']][$thisfile_mpeg_audio_lame[
'raw'][
'vbr_method']][$thisfile_mpeg_audio_lame[
'raw'][
'noise_shaping']][$thisfile_mpeg_audio_lame[
'raw'][
'stereo_mode']][$thisfile_mpeg_audio_lame[
'ath_type']][$thisfile_mpeg_audio_lame[
'lowpass_frequency']];
 
  248                        } elseif (isset($KnownEncoderValues[
'**'][$thisfile_mpeg_audio_lame[
'vbr_quality']][$thisfile_mpeg_audio_lame[
'raw'][
'vbr_method']][$thisfile_mpeg_audio_lame[
'raw'][
'noise_shaping']][$thisfile_mpeg_audio_lame[
'raw'][
'stereo_mode']][$thisfile_mpeg_audio_lame[
'ath_type']][$thisfile_mpeg_audio_lame[
'lowpass_frequency']])) {
 
  250                                $encoder_options = $KnownEncoderValues[
'**'][$thisfile_mpeg_audio_lame[
'vbr_quality']][$thisfile_mpeg_audio_lame[
'raw'][
'vbr_method']][$thisfile_mpeg_audio_lame[
'raw'][
'noise_shaping']][$thisfile_mpeg_audio_lame[
'raw'][
'stereo_mode']][$thisfile_mpeg_audio_lame[
'ath_type']][$thisfile_mpeg_audio_lame[
'lowpass_frequency']];
 
  252                        } elseif (
$info[
'audio'][
'bitrate_mode'] == 
'vbr') {
 
  258                                $LAME_V_value = 10 - ceil($thisfile_mpeg_audio_lame[
'vbr_quality'] / 10);
 
  259                                $LAME_q_value = 100 - $thisfile_mpeg_audio_lame[
'vbr_quality'] - ($LAME_V_value * 10);
 
  260                                $encoder_options = 
'-V'.$LAME_V_value.
' -q'.$LAME_q_value;
 
  262                        } elseif (
$info[
'audio'][
'bitrate_mode'] == 
'cbr') {
 
  264                                $encoder_options = strtoupper(
$info[
'audio'][
'bitrate_mode']).ceil(
$info[
'audio'][
'bitrate'] / 1000);
 
  268                                $encoder_options = strtoupper(
$info[
'audio'][
'bitrate_mode']);
 
  272                } elseif (!empty($thisfile_mpeg_audio_lame[
'bitrate_abr'])) {
 
  274                        $encoder_options = 
'ABR'.$thisfile_mpeg_audio_lame[
'bitrate_abr'];
 
  276                } elseif (!empty(
$info[
'audio'][
'bitrate'])) {
 
  278                        if (
$info[
'audio'][
'bitrate_mode'] == 
'cbr') {
 
  279                                $encoder_options = strtoupper(
$info[
'audio'][
'bitrate_mode']).ceil(
$info[
'audio'][
'bitrate'] / 1000);
 
  281                                $encoder_options = strtoupper(
$info[
'audio'][
'bitrate_mode']);
 
  285                if (!empty($thisfile_mpeg_audio_lame[
'bitrate_min'])) {
 
  286                        $encoder_options .= 
' -b'.$thisfile_mpeg_audio_lame[
'bitrate_min'];
 
  289                if (!empty($thisfile_mpeg_audio_lame[
'encoding_flags'][
'nogap_prev']) || !empty($thisfile_mpeg_audio_lame[
'encoding_flags'][
'nogap_next'])) {
 
  290                        $encoder_options .= 
' --nogap';
 
  293                if (!empty($thisfile_mpeg_audio_lame[
'lowpass_frequency'])) {
 
  294                        $ExplodedOptions = explode(
' ', $encoder_options, 4);
 
  295                        if ($ExplodedOptions[0] == 
'--r3mix') {
 
  296                                $ExplodedOptions[1] = 
'r3mix';
 
  298                        switch ($ExplodedOptions[0]) {
 
  302                                        if ($ExplodedOptions[1] == 
'fast') {
 
  303                                                $ExplodedOptions[1] .= 
' '.$ExplodedOptions[2];
 
  305                                        switch ($ExplodedOptions[1]) {
 
  311                                                case 'fast portable':
 
  313                                                case 'fast standard':
 
  317                                                        static $ExpectedLowpass = array(
 
  318                                                                        'insane|20500'        => 20500,
 
  319                                                                        'insane|20600'        => 20600,  
 
  320                                                                        'medium|18000'        => 18000,
 
  321                                                                        'fast medium|18000'   => 18000,
 
  322                                                                        'extreme|19500'       => 19500,  
 
  323                                                                        'extreme|19600'       => 19600,  
 
  324                                                                        'fast extreme|19500'  => 19500,  
 
  325                                                                        'fast extreme|19600'  => 19600,  
 
  326                                                                        'standard|19000'      => 19000,
 
  327                                                                        'fast standard|19000' => 19000,
 
  328                                                                        'r3mix|19500'         => 19500,  
 
  329                                                                        'r3mix|19600'         => 19600,  
 
  330                                                                        'r3mix|18000'         => 18000,  
 
  332                                                        if (!isset($ExpectedLowpass[$ExplodedOptions[1].
'|'.$thisfile_mpeg_audio_lame[
'lowpass_frequency']]) && ($thisfile_mpeg_audio_lame[
'lowpass_frequency'] < 22050) && (round($thisfile_mpeg_audio_lame[
'lowpass_frequency'] / 1000) < round($thisfile_mpeg_audio[
'sample_rate'] / 2000))) {
 
  333                                                                $encoder_options .= 
' --lowpass '.$thisfile_mpeg_audio_lame[
'lowpass_frequency'];
 
  344                if (isset($thisfile_mpeg_audio_lame[
'raw'][
'source_sample_freq'])) {
 
  345                        if (($thisfile_mpeg_audio[
'sample_rate'] == 44100) && ($thisfile_mpeg_audio_lame[
'raw'][
'source_sample_freq'] != 1)) {
 
  346                                $encoder_options .= 
' --resample 44100';
 
  347                        } elseif (($thisfile_mpeg_audio[
'sample_rate'] == 48000) && ($thisfile_mpeg_audio_lame[
'raw'][
'source_sample_freq'] != 2)) {
 
  348                                $encoder_options .= 
' --resample 48000';
 
  349                        } elseif ($thisfile_mpeg_audio[
'sample_rate'] < 44100) {
 
  350                                switch ($thisfile_mpeg_audio_lame[
'raw'][
'source_sample_freq']) {
 
  357                                                $ExplodedOptions = explode(
' ', $encoder_options, 4);
 
  358                                                switch ($ExplodedOptions[0]) {
 
  361                                                                switch ($ExplodedOptions[1]) {
 
  368                                                                                $encoder_options .= 
' --resample '.$thisfile_mpeg_audio[
'sample_rate'];
 
  372                                                                                static $ExpectedResampledRate = array(
 
  373                                                                                                'phon+/lw/mw-eu/sw|16000' => 16000,
 
  374                                                                                                'mw-us|24000'             => 24000, 
 
  375                                                                                                'mw-us|32000'             => 32000, 
 
  376                                                                                                'mw-us|16000'             => 16000, 
 
  377                                                                                                'phone|16000'             => 16000,
 
  378                                                                                                'phone|11025'             => 11025, 
 
  379                                                                                                'radio|32000'             => 32000, 
 
  380                                                                                                'fm/radio|32000'          => 32000, 
 
  382                                                                                                'voice|32000'             => 32000);
 
  383                                                                                if (!isset($ExpectedResampledRate[$ExplodedOptions[1].
'|'.$thisfile_mpeg_audio[
'sample_rate']])) {
 
  384                                                                                        $encoder_options .= 
' --resample '.$thisfile_mpeg_audio[
'sample_rate'];
 
  392                                                                $encoder_options .= 
' --resample '.$thisfile_mpeg_audio[
'sample_rate'];
 
  399                if (empty($encoder_options) && !empty(
$info[
'audio'][
'bitrate']) && !empty(
$info[
'audio'][
'bitrate_mode'])) {
 
  401                        $encoder_options = strtoupper(
$info[
'audio'][
'bitrate_mode']);
 
  404                return $encoder_options;
 
  409                static $MPEGaudioVersionLookup;
 
  410                static $MPEGaudioLayerLookup;
 
  411                static $MPEGaudioBitrateLookup;
 
  412                static $MPEGaudioFrequencyLookup;
 
  413                static $MPEGaudioChannelModeLookup;
 
  414                static $MPEGaudioModeExtensionLookup;
 
  415                static $MPEGaudioEmphasisLookup;
 
  416                if (empty($MPEGaudioVersionLookup)) {
 
  426                if ($this->
fseek($offset) != 0) {
 
  427                        $this->
error(
'decodeMPEGaudioHeader() failed to seek to next offset at '.$offset);
 
  431                $headerstring = $this->
fread(226); 
 
  439                $head4 = substr($headerstring, 0, 4);
 
  440                static $MPEGaudioHeaderDecodeCache = array();
 
  441                if (isset($MPEGaudioHeaderDecodeCache[$head4])) {
 
  442                        $MPEGheaderRawArray = $MPEGaudioHeaderDecodeCache[$head4];
 
  445                        $MPEGaudioHeaderDecodeCache[$head4] = $MPEGheaderRawArray;
 
  448                static $MPEGaudioHeaderValidCache = array();
 
  449                if (!isset($MPEGaudioHeaderValidCache[$head4])) { 
 
  455                if (!isset(
$info[
'mpeg'][
'audio'])) {
 
  456                        $info[
'mpeg'][
'audio'] = array();
 
  458                $thisfile_mpeg_audio = &
$info[
'mpeg'][
'audio'];
 
  461                if ($MPEGaudioHeaderValidCache[$head4]) {
 
  462                        $thisfile_mpeg_audio[
'raw'] = $MPEGheaderRawArray;
 
  468                if (!$FastMPEGheaderScan) {
 
  469                        $thisfile_mpeg_audio[
'version']       = $MPEGaudioVersionLookup[$thisfile_mpeg_audio[
'raw'][
'version']];
 
  470                        $thisfile_mpeg_audio[
'layer']         = $MPEGaudioLayerLookup[$thisfile_mpeg_audio[
'raw'][
'layer']];
 
  472                        $thisfile_mpeg_audio[
'channelmode']   = $MPEGaudioChannelModeLookup[$thisfile_mpeg_audio[
'raw'][
'channelmode']];
 
  473                        $thisfile_mpeg_audio[
'channels']      = (($thisfile_mpeg_audio[
'channelmode'] == 
'mono') ? 1 : 2);
 
  474                        $thisfile_mpeg_audio[
'sample_rate']   = $MPEGaudioFrequencyLookup[$thisfile_mpeg_audio[
'version']][$thisfile_mpeg_audio[
'raw'][
'sample_rate']];
 
  475                        $thisfile_mpeg_audio[
'protection']    = !$thisfile_mpeg_audio[
'raw'][
'protection'];
 
  476                        $thisfile_mpeg_audio[
'private']       = (bool) $thisfile_mpeg_audio[
'raw'][
'private'];
 
  477                        $thisfile_mpeg_audio[
'modeextension'] = $MPEGaudioModeExtensionLookup[$thisfile_mpeg_audio[
'layer']][$thisfile_mpeg_audio[
'raw'][
'modeextension']];
 
  478                        $thisfile_mpeg_audio[
'copyright']     = (bool) $thisfile_mpeg_audio[
'raw'][
'copyright'];
 
  479                        $thisfile_mpeg_audio[
'original']      = (bool) $thisfile_mpeg_audio[
'raw'][
'original'];
 
  480                        $thisfile_mpeg_audio[
'emphasis']      = $MPEGaudioEmphasisLookup[$thisfile_mpeg_audio[
'raw'][
'emphasis']];
 
  482                        $info[
'audio'][
'channels']    = $thisfile_mpeg_audio[
'channels'];
 
  483                        $info[
'audio'][
'sample_rate'] = $thisfile_mpeg_audio[
'sample_rate'];
 
  485                        if ($thisfile_mpeg_audio[
'protection']) {
 
  490                if ($thisfile_mpeg_audio[
'raw'][
'bitrate'] == 15) {
 
  492                        $this->
warning(
'Invalid bitrate index (15), this is a known bug in free-format MP3s encoded by LAME v3.90 - 3.93.1');
 
  493                        $thisfile_mpeg_audio[
'raw'][
'bitrate'] = 0;
 
  495                $thisfile_mpeg_audio[
'padding'] = (bool) $thisfile_mpeg_audio[
'raw'][
'padding'];
 
  496                $thisfile_mpeg_audio[
'bitrate'] = $MPEGaudioBitrateLookup[$thisfile_mpeg_audio[
'version']][$thisfile_mpeg_audio[
'layer']][$thisfile_mpeg_audio[
'raw'][
'bitrate']];
 
  498                if (($thisfile_mpeg_audio[
'bitrate'] == 
'free') && ($offset == 
$info[
'avdataoffset'])) {
 
  501                        $recursivesearch = 
false;
 
  505                if (!$FastMPEGheaderScan && ($thisfile_mpeg_audio[
'layer'] == 
'2')) {
 
  507                        $info[
'audio'][
'dataformat'] = 
'mp2';
 
  508                        switch ($thisfile_mpeg_audio[
'channelmode']) {
 
  511                                        if (($thisfile_mpeg_audio[
'bitrate'] == 
'free') || ($thisfile_mpeg_audio[
'bitrate'] <= 192000)) {
 
  514                                                $this->
error($thisfile_mpeg_audio[
'bitrate'].
'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio[
'channelmode'].
'.');
 
  522                                        if (($thisfile_mpeg_audio[
'bitrate'] == 
'free') || ($thisfile_mpeg_audio[
'bitrate'] == 64000) || ($thisfile_mpeg_audio[
'bitrate'] >= 96000)) {
 
  525                                                $this->
error(intval(round($thisfile_mpeg_audio[
'bitrate'] / 1000)).
'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio[
'channelmode'].
'.');
 
  535                if (
$info[
'audio'][
'sample_rate'] > 0) {
 
  536                        $thisfile_mpeg_audio[
'framelength'] = 
self::MPEGaudioFrameLength($thisfile_mpeg_audio[
'bitrate'], $thisfile_mpeg_audio[
'version'], $thisfile_mpeg_audio[
'layer'], (
int) $thisfile_mpeg_audio[
'padding'], 
$info[
'audio'][
'sample_rate']);
 
  539                $nextframetestoffset = $offset + 1;
 
  540                if ($thisfile_mpeg_audio[
'bitrate'] != 
'free') {
 
  542                        $info[
'audio'][
'bitrate'] = $thisfile_mpeg_audio[
'bitrate'];
 
  544                        if (isset($thisfile_mpeg_audio[
'framelength'])) {
 
  545                                $nextframetestoffset = $offset + $thisfile_mpeg_audio[
'framelength'];
 
  547                                $this->
error(
'Frame at offset('.$offset.
') is has an invalid frame length.');
 
  553                $ExpectedNumberOfAudioBytes = 0;
 
  558                if (substr($headerstring, 4 + 32, 4) == 
'VBRI') {
 
  562                        $thisfile_mpeg_audio[
'bitrate_mode'] = 
'vbr';
 
  563                        $thisfile_mpeg_audio[
'VBR_method']   = 
'Fraunhofer';
 
  564                        $info[
'audio'][
'codec']                = 
'Fraunhofer';
 
  566                        $SideInfoData = substr($headerstring, 4 + 2, 32);
 
  568                        $FraunhoferVBROffset = 36;
 
  570                        $thisfile_mpeg_audio[
'VBR_encoder_version']     = 
getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset +  4, 2)); 
 
  571                        $thisfile_mpeg_audio[
'VBR_encoder_delay']       = 
getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset +  6, 2)); 
 
  575                        $thisfile_mpeg_audio[
'VBR_seek_offsets']        = 
getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 18, 2)); 
 
  577                        $thisfile_mpeg_audio[
'VBR_entry_bytes']         = 
getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 22, 2)); 
 
  578                        $thisfile_mpeg_audio[
'VBR_entry_frames']        = 
getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 24, 2)); 
 
  580                        $ExpectedNumberOfAudioBytes = $thisfile_mpeg_audio[
'VBR_bytes'];
 
  582                        $previousbyteoffset = $offset;
 
  583                        for (
$i = 0; 
$i < $thisfile_mpeg_audio[
'VBR_seek_offsets']; 
$i++) {
 
  584                                $Fraunhofer_OffsetN = 
getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset, $thisfile_mpeg_audio[
'VBR_entry_bytes']));
 
  585                                $FraunhoferVBROffset += $thisfile_mpeg_audio[
'VBR_entry_bytes'];
 
  586                                $thisfile_mpeg_audio[
'VBR_offsets_relative'][
$i] = ($Fraunhofer_OffsetN * $thisfile_mpeg_audio[
'VBR_seek_scale']);
 
  587                                $thisfile_mpeg_audio[
'VBR_offsets_absolute'][
$i] = ($Fraunhofer_OffsetN * $thisfile_mpeg_audio[
'VBR_seek_scale']) + $previousbyteoffset;
 
  588                                $previousbyteoffset += $Fraunhofer_OffsetN;
 
  597                        $VBRidOffset = 
self::XingVBRidOffset($thisfile_mpeg_audio[
'version'], $thisfile_mpeg_audio[
'channelmode']);
 
  598                        $SideInfoData = substr($headerstring, 4 + 2, $VBRidOffset - 4);
 
  600                        if ((substr($headerstring, $VBRidOffset, strlen(
'Xing')) == 
'Xing') || (substr($headerstring, $VBRidOffset, strlen(
'Info')) == 
'Info')) {
 
  627                                        $thisfile_mpeg_audio[
'bitrate_mode'] = 
'vbr';
 
  628                                        $thisfile_mpeg_audio[
'VBR_method']   = 
'Xing';
 
  636                                $thisfile_mpeg_audio[
'xing_flags'][
'frames']    = (bool) ($thisfile_mpeg_audio[
'xing_flags_raw'] & 0x00000001);
 
  637                                $thisfile_mpeg_audio[
'xing_flags'][
'bytes']     = (bool) ($thisfile_mpeg_audio[
'xing_flags_raw'] & 0x00000002);
 
  638                                $thisfile_mpeg_audio[
'xing_flags'][
'toc']       = (bool) ($thisfile_mpeg_audio[
'xing_flags_raw'] & 0x00000004);
 
  639                                $thisfile_mpeg_audio[
'xing_flags'][
'vbr_scale'] = (bool) ($thisfile_mpeg_audio[
'xing_flags_raw'] & 0x00000008);
 
  641                                if ($thisfile_mpeg_audio[
'xing_flags'][
'frames']) {
 
  645                                if ($thisfile_mpeg_audio[
'xing_flags'][
'bytes']) {
 
  651                                if (!empty($thisfile_mpeg_audio[
'VBR_frames'])) {
 
  653                                        if (!empty($thisfile_mpeg_audio[
'VBR_bytes'])) {
 
  654                                                $used_filesize = $thisfile_mpeg_audio[
'VBR_bytes'];
 
  655                                        } elseif (!empty(
$info[
'filesize'])) {
 
  656                                                $used_filesize  = 
$info[
'filesize'];
 
  657                                                $used_filesize -= intval(@
$info[
'id3v2'][
'headerlength']);
 
  658                                                $used_filesize -= (isset(
$info[
'id3v1']) ? 128 : 0);
 
  659                                                $used_filesize -= (isset(
$info[
'tag_offset_end']) ? 
$info[
'tag_offset_end'] - 
$info[
'tag_offset_start'] : 0);
 
  660                                                $this->
warning(
'MP3.Xing header missing VBR_bytes, assuming MPEG audio portion of file is '.number_format($used_filesize).
' bytes');
 
  663                                        $framelengthfloat = $used_filesize / $thisfile_mpeg_audio[
'VBR_frames'];
 
  665                                        if ($thisfile_mpeg_audio[
'layer'] == 
'1') {
 
  668                                                $info[
'audio'][
'bitrate'] = ($framelengthfloat / 4) * $thisfile_mpeg_audio[
'sample_rate'] * (2 / 
$info[
'audio'][
'channels']) / 12;
 
  672                                                $info[
'audio'][
'bitrate'] = $framelengthfloat * $thisfile_mpeg_audio[
'sample_rate'] * (2 / 
$info[
'audio'][
'channels']) / 144;
 
  674                                        $thisfile_mpeg_audio[
'framelength'] = floor($framelengthfloat);
 
  677                                if ($thisfile_mpeg_audio[
'xing_flags'][
'toc']) {
 
  678                                        $LAMEtocData = substr($headerstring, $VBRidOffset + 16, 100);
 
  679                                        for (
$i = 0; 
$i < 100; 
$i++) {
 
  680                                                $thisfile_mpeg_audio[
'toc'][
$i] = ord($LAMEtocData{
$i});
 
  683                                if ($thisfile_mpeg_audio[
'xing_flags'][
'vbr_scale']) {
 
  689                                if (substr($headerstring, $VBRidOffset + 120, 4) == 
'LAME') {
 
  692                                        $thisfile_mpeg_audio[
'LAME'] = array();
 
  693                                        $thisfile_mpeg_audio_lame    = &$thisfile_mpeg_audio[
'LAME'];
 
  696                                        $thisfile_mpeg_audio_lame[
'long_version']  = substr($headerstring, $VBRidOffset + 120, 20);
 
  697                                        $thisfile_mpeg_audio_lame[
'short_version'] = substr($thisfile_mpeg_audio_lame[
'long_version'], 0, 9);
 
  699                                        if ($thisfile_mpeg_audio_lame[
'short_version'] >= 
'LAME3.90') {
 
  702                                                unset($thisfile_mpeg_audio_lame[
'long_version']);
 
  710                                                $LAMEtagOffsetContant = $VBRidOffset - 0x24;
 
  713                                                $thisfile_mpeg_audio_lame[
'RGAD']    = array(
'track'=>array(), 
'album'=>array());
 
  714                                                $thisfile_mpeg_audio_lame_RGAD       = &$thisfile_mpeg_audio_lame[
'RGAD'];
 
  715                                                $thisfile_mpeg_audio_lame_RGAD_track = &$thisfile_mpeg_audio_lame_RGAD[
'track'];
 
  716                                                $thisfile_mpeg_audio_lame_RGAD_album = &$thisfile_mpeg_audio_lame_RGAD[
'album'];
 
  717                                                $thisfile_mpeg_audio_lame[
'raw'] = array();
 
  718                                                $thisfile_mpeg_audio_lame_raw    = &$thisfile_mpeg_audio_lame[
'raw'];
 
  723                                                unset($thisfile_mpeg_audio[
'VBR_scale']);
 
  724                                                $thisfile_mpeg_audio_lame[
'vbr_quality'] = 
getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0x9B, 1));
 
  727                                                $thisfile_mpeg_audio_lame[
'short_version'] = substr($headerstring, $LAMEtagOffsetContant + 0x9C, 9);
 
  732                                                $thisfile_mpeg_audio_lame[
'tag_revision']   = ($LAMEtagRevisionVBRmethod & 0xF0) >> 4;
 
  733                                                $thisfile_mpeg_audio_lame_raw[
'vbr_method'] =  $LAMEtagRevisionVBRmethod & 0x0F;
 
  735                                                $thisfile_mpeg_audio[
'bitrate_mode']        = substr($thisfile_mpeg_audio_lame[
'vbr_method'], 0, 3); 
 
  738                                                $thisfile_mpeg_audio_lame[
'lowpass_frequency'] = 
getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA6, 1)) * 100;
 
  743                                                if ($thisfile_mpeg_audio_lame[
'short_version'] >= 
'LAME3.94b') {
 
  746                                                        $thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'] = (float) ((
getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA7, 4))) / 8388608);
 
  752                                                if ($thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'] == 0) {
 
  753                                                        unset($thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude']);
 
  758                                                $thisfile_mpeg_audio_lame_raw[
'RGAD_track']      =   
getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAB, 2));
 
  759                                                $thisfile_mpeg_audio_lame_raw[
'RGAD_album']      =   
getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAD, 2));
 
  762                                                if ($thisfile_mpeg_audio_lame_raw[
'RGAD_track'] != 0) {
 
  764                                                        $thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'name']        = ($thisfile_mpeg_audio_lame_raw[
'RGAD_track'] & 0xE000) >> 13;
 
  765                                                        $thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'originator']  = ($thisfile_mpeg_audio_lame_raw[
'RGAD_track'] & 0x1C00) >> 10;
 
  766                                                        $thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'sign_bit']    = ($thisfile_mpeg_audio_lame_raw[
'RGAD_track'] & 0x0200) >> 9;
 
  767                                                        $thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'gain_adjust'] =  $thisfile_mpeg_audio_lame_raw[
'RGAD_track'] & 0x01FF;
 
  768                                                        $thisfile_mpeg_audio_lame_RGAD_track[
'name']       = 
getid3_lib::RGADnameLookup($thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'name']);
 
  770                                                        $thisfile_mpeg_audio_lame_RGAD_track[
'gain_db']    = 
getid3_lib::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'gain_adjust'], $thisfile_mpeg_audio_lame_RGAD_track[
'raw'][
'sign_bit']);
 
  772                                                        if (!empty($thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'])) {
 
  773                                                                $info[
'replay_gain'][
'track'][
'peak']   = $thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'];
 
  775                                                        $info[
'replay_gain'][
'track'][
'originator'] = $thisfile_mpeg_audio_lame_RGAD_track[
'originator'];
 
  776                                                        $info[
'replay_gain'][
'track'][
'adjustment'] = $thisfile_mpeg_audio_lame_RGAD_track[
'gain_db'];
 
  778                                                        unset($thisfile_mpeg_audio_lame_RGAD[
'track']);
 
  780                                                if ($thisfile_mpeg_audio_lame_raw[
'RGAD_album'] != 0) {
 
  782                                                        $thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'name']        = ($thisfile_mpeg_audio_lame_raw[
'RGAD_album'] & 0xE000) >> 13;
 
  783                                                        $thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'originator']  = ($thisfile_mpeg_audio_lame_raw[
'RGAD_album'] & 0x1C00) >> 10;
 
  784                                                        $thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'sign_bit']    = ($thisfile_mpeg_audio_lame_raw[
'RGAD_album'] & 0x0200) >> 9;
 
  785                                                        $thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'gain_adjust'] = $thisfile_mpeg_audio_lame_raw[
'RGAD_album'] & 0x01FF;
 
  786                                                        $thisfile_mpeg_audio_lame_RGAD_album[
'name']       = 
getid3_lib::RGADnameLookup($thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'name']);
 
  788                                                        $thisfile_mpeg_audio_lame_RGAD_album[
'gain_db']    = 
getid3_lib::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'gain_adjust'], $thisfile_mpeg_audio_lame_RGAD_album[
'raw'][
'sign_bit']);
 
  790                                                        if (!empty($thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'])) {
 
  791                                                                $info[
'replay_gain'][
'album'][
'peak']   = $thisfile_mpeg_audio_lame_RGAD[
'peak_amplitude'];
 
  793                                                        $info[
'replay_gain'][
'album'][
'originator'] = $thisfile_mpeg_audio_lame_RGAD_album[
'originator'];
 
  794                                                        $info[
'replay_gain'][
'album'][
'adjustment'] = $thisfile_mpeg_audio_lame_RGAD_album[
'gain_db'];
 
  796                                                        unset($thisfile_mpeg_audio_lame_RGAD[
'album']);
 
  798                                                if (empty($thisfile_mpeg_audio_lame_RGAD)) {
 
  799                                                        unset($thisfile_mpeg_audio_lame[
'RGAD']);
 
  805                                                $thisfile_mpeg_audio_lame[
'encoding_flags'][
'nspsytune']   = (bool) ($EncodingFlagsATHtype & 0x10);
 
  806                                                $thisfile_mpeg_audio_lame[
'encoding_flags'][
'nssafejoint'] = (bool) ($EncodingFlagsATHtype & 0x20);
 
  807                                                $thisfile_mpeg_audio_lame[
'encoding_flags'][
'nogap_next']  = (bool) ($EncodingFlagsATHtype & 0x40);
 
  808                                                $thisfile_mpeg_audio_lame[
'encoding_flags'][
'nogap_prev']  = (bool) ($EncodingFlagsATHtype & 0x80);
 
  809                                                $thisfile_mpeg_audio_lame[
'ath_type']                      =         $EncodingFlagsATHtype & 0x0F;
 
  812                                                $thisfile_mpeg_audio_lame[
'raw'][
'abrbitrate_minbitrate'] = 
getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB0, 1));
 
  813                                                if ($thisfile_mpeg_audio_lame_raw[
'vbr_method'] == 2) { 
 
  814                                                        $thisfile_mpeg_audio_lame[
'bitrate_abr'] = $thisfile_mpeg_audio_lame[
'raw'][
'abrbitrate_minbitrate'];
 
  815                                                } elseif ($thisfile_mpeg_audio_lame_raw[
'vbr_method'] == 1) { 
 
  817                                                } elseif ($thisfile_mpeg_audio_lame[
'raw'][
'abrbitrate_minbitrate'] > 0) { 
 
  818                                                        $thisfile_mpeg_audio_lame[
'bitrate_min'] = $thisfile_mpeg_audio_lame[
'raw'][
'abrbitrate_minbitrate'];
 
  823                                                $thisfile_mpeg_audio_lame[
'encoder_delay'] = ($EncoderDelays & 0xFFF000) >> 12;
 
  824                                                $thisfile_mpeg_audio_lame[
'end_padding']   =  $EncoderDelays & 0x000FFF;
 
  828                                                $thisfile_mpeg_audio_lame_raw[
'noise_shaping']       = ($MiscByte & 0x03);
 
  829                                                $thisfile_mpeg_audio_lame_raw[
'stereo_mode']         = ($MiscByte & 0x1C) >> 2;
 
  830                                                $thisfile_mpeg_audio_lame_raw[
'not_optimal_quality'] = ($MiscByte & 0x20) >> 5;
 
  831                                                $thisfile_mpeg_audio_lame_raw[
'source_sample_freq']  = ($MiscByte & 0xC0) >> 6;
 
  832                                                $thisfile_mpeg_audio_lame[
'noise_shaping']       = $thisfile_mpeg_audio_lame_raw[
'noise_shaping'];
 
  834                                                $thisfile_mpeg_audio_lame[
'not_optimal_quality'] = (bool) $thisfile_mpeg_audio_lame_raw[
'not_optimal_quality'];
 
  838                                                $thisfile_mpeg_audio_lame_raw[
'mp3_gain'] = 
getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB5, 1), 
false, 
true);
 
  840                                                $thisfile_mpeg_audio_lame[
'mp3_gain_factor'] = pow(2, ($thisfile_mpeg_audio_lame[
'mp3_gain_db'] / 6));
 
  845                                                $thisfile_mpeg_audio_lame_raw[
'surround_info'] = ($PresetSurroundBytes & 0x3800);
 
  847                                                $thisfile_mpeg_audio_lame[
'preset_used_id']    = ($PresetSurroundBytes & 0x07FF);
 
  849                                                if (!empty($thisfile_mpeg_audio_lame[
'preset_used_id']) && empty($thisfile_mpeg_audio_lame[
'preset_used'])) {
 
  850                                                        $this->
warning(
'Unknown LAME preset used ('.$thisfile_mpeg_audio_lame[
'preset_used_id'].
') - please report to info@getid3.org');
 
  852                                                if (($thisfile_mpeg_audio_lame[
'short_version'] == 
'LAME3.90.') && !empty($thisfile_mpeg_audio_lame[
'preset_used_id'])) {
 
  854                                                        $thisfile_mpeg_audio_lame[
'short_version'] = 
'LAME3.90.3';
 
  858                                                $thisfile_mpeg_audio_lame[
'audio_bytes'] = 
getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB8, 4));
 
  859                                                $ExpectedNumberOfAudioBytes = (($thisfile_mpeg_audio_lame[
'audio_bytes'] > 0) ? $thisfile_mpeg_audio_lame[
'audio_bytes'] : $thisfile_mpeg_audio[
'VBR_bytes']);
 
  862                                                $thisfile_mpeg_audio_lame[
'music_crc']    = 
getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xBC, 2));
 
  865                                                $thisfile_mpeg_audio_lame[
'lame_tag_crc'] = 
getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xBE, 2));
 
  869                                                if ($thisfile_mpeg_audio_lame_raw[
'vbr_method'] == 1) {
 
  871                                                        $thisfile_mpeg_audio[
'bitrate_mode'] = 
'cbr';
 
  873                                                        $info[
'audio'][
'bitrate'] = $thisfile_mpeg_audio[
'bitrate'];
 
  886                                $thisfile_mpeg_audio[
'bitrate_mode'] = 
'cbr';
 
  887                                if ($recursivesearch) {
 
  888                                        $thisfile_mpeg_audio[
'bitrate_mode'] = 
'vbr';
 
  890                                                $recursivesearch = 
false;
 
  891                                                $thisfile_mpeg_audio[
'bitrate_mode'] = 
'cbr';
 
  893                                        if ($thisfile_mpeg_audio[
'bitrate_mode'] == 
'vbr') {
 
  894                                                $this->
warning(
'VBR file with no VBR header. Bitrate values calculated from actual frame bitrates.');
 
  902                if (($ExpectedNumberOfAudioBytes > 0) && ($ExpectedNumberOfAudioBytes != (
$info[
'avdataend'] - 
$info[
'avdataoffset']))) {
 
  903                        if ($ExpectedNumberOfAudioBytes > (
$info[
'avdataend'] - 
$info[
'avdataoffset'])) {
 
  907                                elseif (($ExpectedNumberOfAudioBytes - (
$info[
'avdataend'] - 
$info[
'avdataoffset'])) == 1) {
 
  908                                        $this->
warning(
'Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)');
 
  911                                        $this->
warning(
'Probable truncated file: expecting '.$ExpectedNumberOfAudioBytes.
' bytes of audio data, only found '.(
$info[
'avdataend'] - 
$info[
'avdataoffset']).
' (short by '.($ExpectedNumberOfAudioBytes - (
$info[
'avdataend'] - 
$info[
'avdataoffset'])).
' bytes)');
 
  914                                if (((
$info[
'avdataend'] - 
$info[
'avdataoffset']) - $ExpectedNumberOfAudioBytes) == 1) {
 
  920                                                $info[
'avdataend']--;
 
  926                                        $this->
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)');
 
  931                if (($thisfile_mpeg_audio[
'bitrate'] == 
'free') && empty(
$info[
'audio'][
'bitrate'])) {
 
  932                        if (($offset == 
$info[
'avdataoffset']) && empty($thisfile_mpeg_audio[
'VBR_frames'])) {
 
  934                                if ($framebytelength > 0) {
 
  935                                        $thisfile_mpeg_audio[
'framelength'] = $framebytelength;
 
  936                                        if ($thisfile_mpeg_audio[
'layer'] == 
'1') {
 
  938                                                $info[
'audio'][
'bitrate'] = ((($framebytelength / 4) - intval($thisfile_mpeg_audio[
'padding'])) * $thisfile_mpeg_audio[
'sample_rate']) / 12;
 
  941                                                $info[
'audio'][
'bitrate'] = (($framebytelength - intval($thisfile_mpeg_audio[
'padding'])) * $thisfile_mpeg_audio[
'sample_rate']) / 144;
 
  944                                        $this->
error(
'Error calculating frame length of free-format MP3 without Xing/LAME header');
 
  949                if (isset($thisfile_mpeg_audio[
'VBR_frames']) ? $thisfile_mpeg_audio[
'VBR_frames'] : 
'') {
 
  950                        switch ($thisfile_mpeg_audio[
'bitrate_mode']) {
 
  953                                        $bytes_per_frame = 1152;
 
  954                                        if (($thisfile_mpeg_audio[
'version'] == 
'1') && ($thisfile_mpeg_audio[
'layer'] == 1)) {
 
  955                                                $bytes_per_frame = 384;
 
  956                                        } elseif ((($thisfile_mpeg_audio[
'version'] == 
'2') || ($thisfile_mpeg_audio[
'version'] == 
'2.5')) && ($thisfile_mpeg_audio[
'layer'] == 3)) {
 
  957                                                $bytes_per_frame = 576;
 
  959                                        $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);
 
  960                                        if ($thisfile_mpeg_audio[
'VBR_bitrate'] > 0) {
 
  961                                                $info[
'audio'][
'bitrate']       = $thisfile_mpeg_audio[
'VBR_bitrate'];
 
  962                                                $thisfile_mpeg_audio[
'bitrate'] = $thisfile_mpeg_audio[
'VBR_bitrate']; 
 
  971                if ($recursivesearch) {
 
 1086                $info = &$this->getid3->info;
 
 1087                $firstframetestarray = array(
'error' => array(), 
'warning'=> array(), 
'avdataend' => 
$info[
'avdataend'], 
'avdataoffset' => 
$info[
'avdataoffset']);
 
 1092                        if (($nextframetestoffset + 4) >= 
$info[
'avdataend']) {
 
 1097                        $nextframetestarray = array(
'error' => array(), 
'warning' => array(), 
'avdataend' => 
$info[
'avdataend'], 
'avdataoffset'=>
$info[
'avdataoffset']);
 
 1101                                        if (!isset($nextframetestarray[
'mpeg'][
'audio'][
'bitrate']) || !isset($firstframetestarray[
'mpeg'][
'audio'][
'bitrate']) || ($nextframetestarray[
'mpeg'][
'audio'][
'bitrate'] != $firstframetestarray[
'mpeg'][
'audio'][
'bitrate'])) {
 
 1108                                if (isset($nextframetestarray[
'mpeg'][
'audio'][
'framelength']) && ($nextframetestarray[
'mpeg'][
'audio'][
'framelength'] > 0)) {
 
 1109                                        $nextframetestoffset += $nextframetestarray[
'mpeg'][
'audio'][
'framelength'];
 
 1111                                        $this->
error(
'Frame at offset ('.$offset.
') is has an invalid frame length.');
 
 1115                        } elseif (!empty($firstframetestarray[
'mpeg'][
'audio'][
'framelength']) && (($nextframetestoffset + $firstframetestarray[
'mpeg'][
'audio'][
'framelength']) > 
$info[
'avdataend'])) {
 
 1123                                $this->
warning(
'Frame at offset ('.$offset.
') is valid, but the next one at ('.$nextframetestoffset.
') is not.');
 
 1132                $info = &$this->getid3->info;
 
 1134                $this->
fseek($offset);
 
 1135                $MPEGaudioData = $this->
fread(32768);
 
 1137                $SyncPattern1 = substr($MPEGaudioData, 0, 4);
 
 1139                $SyncPattern2 = $SyncPattern1{0}.$SyncPattern1{1}.chr(ord($SyncPattern1{2}) | 0x02).$SyncPattern1{3};
 
 1140                if ($SyncPattern2 === $SyncPattern1) {
 
 1141                        $SyncPattern2 = $SyncPattern1{0}.$SyncPattern1{1}.chr(ord($SyncPattern1{2}) & 0xFD).$SyncPattern1{3};
 
 1144                $framelength = 
false;
 
 1145                $framelength1 = strpos($MPEGaudioData, $SyncPattern1, 4);
 
 1146                $framelength2 = strpos($MPEGaudioData, $SyncPattern2, 4);
 
 1147                if ($framelength1 > 4) {
 
 1148                        $framelength = $framelength1;
 
 1150                if (($framelength2 > 4) && ($framelength2 < $framelength1)) {
 
 1151                        $framelength = $framelength2;
 
 1153                if (!$framelength) {
 
 1156                        $framelength1 = strpos($MPEGaudioData, substr($SyncPattern1, 0, 3), 4);
 
 1157                        $framelength2 = strpos($MPEGaudioData, substr($SyncPattern2, 0, 3), 4);
 
 1159                        if ($framelength1 > 4) {
 
 1160                                $framelength = $framelength1;
 
 1162                        if (($framelength2 > 4) && ($framelength2 < $framelength1)) {
 
 1163                                $framelength = $framelength2;
 
 1165                        if (!$framelength) {
 
 1169                                $this->
warning(
'ModeExtension varies between first frame and other frames (known free-format issue in LAME 3.88)');
 
 1170                                $info[
'audio'][
'codec']   = 
'LAME';
 
 1171                                $info[
'audio'][
'encoder'] = 
'LAME3.88';
 
 1172                                $SyncPattern1 = substr($SyncPattern1, 0, 3);
 
 1173                                $SyncPattern2 = substr($SyncPattern2, 0, 3);
 
 1179                        $ActualFrameLengthValues = array();
 
 1180                        $nextoffset = $offset + $framelength;
 
 1181                        while ($nextoffset < (
$info[
'avdataend'] - 6)) {
 
 1182                                $this->
fseek($nextoffset - 1);
 
 1183                                $NextSyncPattern = $this->
fread(6);
 
 1184                                if ((substr($NextSyncPattern, 1, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 1, strlen($SyncPattern2)) == $SyncPattern2)) {
 
 1186                                        $ActualFrameLengthValues[] = $framelength;
 
 1187                                } elseif ((substr($NextSyncPattern, 0, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 0, strlen($SyncPattern2)) == $SyncPattern2)) {
 
 1189                                        $ActualFrameLengthValues[] = ($framelength - 1);
 
 1191                                } elseif ((substr($NextSyncPattern, 2, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 2, strlen($SyncPattern2)) == $SyncPattern2)) {
 
 1193                                        $ActualFrameLengthValues[] = ($framelength + 1);
 
 1196                                        $this->
error(
'Did not find expected free-format sync pattern at offset '.$nextoffset);
 
 1199                                $nextoffset += $framelength;
 
 1201                        if (count($ActualFrameLengthValues) > 0) {
 
 1202                                $framelength = intval(round(array_sum($ActualFrameLengthValues) / count($ActualFrameLengthValues)));
 
 1205                return $framelength;
 
 1209                $MPEGaudioHeaderDecodeCache   = array();
 
 1210                $MPEGaudioHeaderValidCache    = array();
 
 1211                $MPEGaudioHeaderLengthCache   = array();
 
 1219                $LongMPEGversionLookup        = array();
 
 1220                $LongMPEGlayerLookup          = array();
 
 1221                $LongMPEGbitrateLookup        = array();
 
 1222                $LongMPEGpaddingLookup        = array();
 
 1223                $LongMPEGfrequencyLookup      = array();
 
 1224                $Distribution[
'bitrate']      = array();
 
 1225                $Distribution[
'frequency']    = array();
 
 1226                $Distribution[
'layer']        = array();
 
 1227                $Distribution[
'version']      = array();
 
 1228                $Distribution[
'padding']      = array();
 
 1230                $info = &$this->getid3->info;
 
 1233                $max_frames_scan = 5000;
 
 1234                $frames_scanned  = 0;
 
 1236                $previousvalidframe = 
$info[
'avdataoffset'];
 
 1237                while ($this->
ftell() < 
$info[
'avdataend']) {
 
 1239                        $head4 = $this->
fread(4);
 
 1240                        if (strlen($head4) < 4) {
 
 1243                        if ($head4{0} != 
"\xFF") {
 
 1244                                for (
$i = 1; 
$i < 4; 
$i++) {
 
 1245                                        if ($head4{
$i} == 
"\xFF") {
 
 1246                                                $this->
fseek(
$i - 4, SEEK_CUR);
 
 1252                        if (!isset($MPEGaudioHeaderDecodeCache[$head4])) {
 
 1255                        if (!isset($MPEGaudioHeaderValidCache[$head4])) {
 
 1258                        if ($MPEGaudioHeaderValidCache[$head4]) {
 
 1260                                if (!isset($MPEGaudioHeaderLengthCache[$head4])) {
 
 1261                                        $LongMPEGversionLookup[$head4]   = $MPEGaudioVersionLookup[$MPEGaudioHeaderDecodeCache[$head4][
'version']];
 
 1262                                        $LongMPEGlayerLookup[$head4]     = $MPEGaudioLayerLookup[$MPEGaudioHeaderDecodeCache[$head4][
'layer']];
 
 1263                                        $LongMPEGbitrateLookup[$head4]   = $MPEGaudioBitrateLookup[$LongMPEGversionLookup[$head4]][$LongMPEGlayerLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4][
'bitrate']];
 
 1264                                        $LongMPEGpaddingLookup[$head4]   = (bool) $MPEGaudioHeaderDecodeCache[$head4][
'padding'];
 
 1265                                        $LongMPEGfrequencyLookup[$head4] = $MPEGaudioFrequencyLookup[$LongMPEGversionLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4][
'sample_rate']];
 
 1267                                                $LongMPEGbitrateLookup[$head4],
 
 1268                                                $LongMPEGversionLookup[$head4],
 
 1269                                                $LongMPEGlayerLookup[$head4],
 
 1270                                                $LongMPEGpaddingLookup[$head4],
 
 1271                                                $LongMPEGfrequencyLookup[$head4]);
 
 1273                                if ($MPEGaudioHeaderLengthCache[$head4] > 4) {
 
 1274                                        $WhereWeWere = $this->
ftell();
 
 1275                                        $this->
fseek($MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR);
 
 1276                                        $next4 = $this->
fread(4);
 
 1277                                        if ($next4{0} == 
"\xFF") {
 
 1278                                                if (!isset($MPEGaudioHeaderDecodeCache[$next4])) {
 
 1281                                                if (!isset($MPEGaudioHeaderValidCache[$next4])) {
 
 1284                                                if ($MPEGaudioHeaderValidCache[$next4]) {
 
 1285                                                        $this->
fseek(-4, SEEK_CUR);
 
 1292                                                        if ($max_frames_scan && (++$frames_scanned >= $max_frames_scan)) {
 
 1293                                                                $pct_data_scanned = ($this->
ftell() - 
$info[
'avdataoffset']) / (
$info[
'avdataend'] - 
$info[
'avdataoffset']);
 
 1294                                                                $this->
warning(
'too many MPEG audio frames to scan, only scanned first '.$max_frames_scan.
' frames ('.number_format($pct_data_scanned * 100, 1).
'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.');
 
 1295                                                                foreach ($Distribution as $key1 => $value1) {
 
 1296                                                                        foreach ($value1 as $key2 => $value2) {
 
 1297                                                                                $Distribution[$key1][$key2] = round($value2 / $pct_data_scanned);
 
 1306                                        $this->
fseek($WhereWeWere - 3);
 
 1311                foreach ($Distribution as 
$key => $value) {
 
 1312                        ksort($Distribution[
$key], SORT_NUMERIC);
 
 1314                ksort($Distribution[
'version'], SORT_STRING);
 
 1315                $info[
'mpeg'][
'audio'][
'bitrate_distribution']   = $Distribution[
'bitrate'];
 
 1316                $info[
'mpeg'][
'audio'][
'frequency_distribution'] = $Distribution[
'frequency'];
 
 1317                $info[
'mpeg'][
'audio'][
'layer_distribution']     = $Distribution[
'layer'];
 
 1318                $info[
'mpeg'][
'audio'][
'version_distribution']   = $Distribution[
'version'];
 
 1319                $info[
'mpeg'][
'audio'][
'padding_distribution']   = $Distribution[
'padding'];
 
 1320                if (count($Distribution[
'version']) > 1) {
 
 1321                        $this->
error(
'Corrupt file - more than one MPEG version detected');
 
 1323                if (count($Distribution[
'layer']) > 1) {
 
 1324                        $this->
error(
'Corrupt file - more than one MPEG layer detected');
 
 1326                if (count($Distribution[
'frequency']) > 1) {
 
 1327                        $this->
error(
'Corrupt file - more than one MPEG sample rate detected');
 
 1332                foreach ($Distribution[
'bitrate'] as $bitratevalue => $bitratecount) {
 
 1333                        if ($bitratevalue != 
'free') {
 
 1334                                $bittotal += ($bitratevalue * $bitratecount);
 
 1337                $info[
'mpeg'][
'audio'][
'frame_count']  = array_sum($Distribution[
'bitrate']);
 
 1338                if (
$info[
'mpeg'][
'audio'][
'frame_count'] == 0) {
 
 1339                        $this->
error(
'no MPEG audio frames found');
 
 1342                $info[
'mpeg'][
'audio'][
'bitrate']      = ($bittotal / 
$info[
'mpeg'][
'audio'][
'frame_count']);
 
 1343                $info[
'mpeg'][
'audio'][
'bitrate_mode'] = ((count($Distribution[
'bitrate']) > 0) ? 
'vbr' : 
'cbr');
 
 1346                $info[
'audio'][
'bitrate']      = 
$info[
'mpeg'][
'audio'][
'bitrate'];
 
 1347                $info[
'audio'][
'bitrate_mode'] = 
$info[
'mpeg'][
'audio'][
'bitrate_mode'];
 
 1348                $info[
'audio'][
'sample_rate']  = 
$info[
'mpeg'][
'audio'][
'sample_rate'];
 
 1349                $info[
'audio'][
'dataformat']   = 
'mp'.getid3_lib::array_max($Distribution[
'layer'], 
true);
 
 1350                $info[
'fileformat']            = 
$info[
'audio'][
'dataformat'];
 
 1359                $info = &$this->getid3->info;
 
 1361                static $MPEGaudioVersionLookup;
 
 1362                static $MPEGaudioLayerLookup;
 
 1363                static $MPEGaudioBitrateLookup;
 
 1364                if (empty($MPEGaudioVersionLookup)) {
 
 1371                $this->
fseek($avdataoffset);
 
 1372                $sync_seek_buffer_size = min(128 * 1024, 
$info[
'avdataend'] - $avdataoffset);
 
 1373                if ($sync_seek_buffer_size <= 0) {
 
 1374                        $this->
error(
'Invalid $sync_seek_buffer_size at offset '.$avdataoffset);
 
 1378                $sync_seek_buffer_size = strlen(
$header);
 
 1379                $SynchSeekOffset = 0;
 
 1380                while ($SynchSeekOffset < $sync_seek_buffer_size) {
 
 1381                        if ((($avdataoffset + $SynchSeekOffset)  < 
$info[
'avdataend']) && !
feof($this->getid3->fp)) {
 
 1383                                if ($SynchSeekOffset > $sync_seek_buffer_size) {
 
 1385                                        $this->
error(
'Could not find valid MPEG audio synch within the first '.round($sync_seek_buffer_size / 1024).
'kB');
 
 1386                                        if (isset(
$info[
'audio'][
'bitrate'])) {
 
 1387                                                unset(
$info[
'audio'][
'bitrate']);
 
 1389                                        if (isset(
$info[
'mpeg'][
'audio'])) {
 
 1390                                                unset(
$info[
'mpeg'][
'audio']);
 
 1392                                        if (empty(
$info[
'mpeg'])) {
 
 1393                                                unset(
$info[
'mpeg']);
 
 1397                                } elseif (
feof($this->getid3->fp)) {
 
 1399                                        $this->
error(
'Could not find valid MPEG audio synch before end of file');
 
 1400                                        if (isset(
$info[
'audio'][
'bitrate'])) {
 
 1401                                                unset(
$info[
'audio'][
'bitrate']);
 
 1403                                        if (isset(
$info[
'mpeg'][
'audio'])) {
 
 1404                                                unset(
$info[
'mpeg'][
'audio']);
 
 1406                                        if (isset(
$info[
'mpeg']) && (!is_array(
$info[
'mpeg']) || (count(
$info[
'mpeg']) == 0))) {
 
 1407                                                unset(
$info[
'mpeg']);
 
 1413                        if (($SynchSeekOffset + 1) >= strlen(
$header)) {
 
 1414                                $this->
error(
'Could not find valid MPEG synch before end of file');
 
 1418                        if ((
$header{$SynchSeekOffset} == 
"\xFF") && (
$header{($SynchSeekOffset + 1)} > 
"\xE0")) { 
 
 1419                                if (!isset($FirstFrameThisfileInfo) && !isset(
$info[
'mpeg'][
'audio'])) {
 
 1420                                        $FirstFrameThisfileInfo = 
$info;
 
 1421                                        $FirstFrameAVDataOffset = $avdataoffset + $SynchSeekOffset;
 
 1425                                                unset($FirstFrameThisfileInfo);
 
 1432                                        $info[
'avdataoffset'] = $avdataoffset + $SynchSeekOffset;
 
 1433                                        switch (isset(
$info[
'fileformat']) ? 
$info[
'fileformat'] : 
'') {
 
 1438                                                        $info[
'fileformat']          = 
'mp3';
 
 1439                                                        $info[
'audio'][
'dataformat'] = 
'mp3';
 
 1442                                        if (isset($FirstFrameThisfileInfo[
'mpeg'][
'audio'][
'bitrate_mode']) && ($FirstFrameThisfileInfo[
'mpeg'][
'audio'][
'bitrate_mode'] == 
'vbr')) {
 
 1443                                                if (!(abs(
$info[
'audio'][
'bitrate'] - $FirstFrameThisfileInfo[
'audio'][
'bitrate']) <= 1)) {
 
 1446                                                        $info = $FirstFrameThisfileInfo;
 
 1447                                                        $info[
'avdataoffset']        = $FirstFrameAVDataOffset;
 
 1448                                                        $info[
'fileformat']          = 
'mp3';
 
 1449                                                        $info[
'audio'][
'dataformat'] = 
'mp3';
 
 1451                                                        unset($dummy[
'mpeg'][
'audio']);
 
 1452                                                        $GarbageOffsetStart = $FirstFrameAVDataOffset + $FirstFrameThisfileInfo[
'mpeg'][
'audio'][
'framelength'];
 
 1453                                                        $GarbageOffsetEnd   = $avdataoffset + $SynchSeekOffset;
 
 1456                                                                $info[
'avdataoffset'] = $GarbageOffsetEnd;
 
 1457                                                                $this->
warning(
'apparently-valid VBR header not used because could not find '.
GETID3_MP3_VALID_CHECK_FRAMES.
' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).
' bytes between '.$GarbageOffsetStart.
' and '.$GarbageOffsetEnd.
'), but did find valid CBR stream starting at '.$GarbageOffsetEnd);
 
 1459                                                                $this->
warning(
'using data from VBR header even though could not find '.
GETID3_MP3_VALID_CHECK_FRAMES.
' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).
' bytes between '.$GarbageOffsetStart.
' and '.$GarbageOffsetEnd.
')');
 
 1463                                        if (isset(
$info[
'mpeg'][
'audio'][
'bitrate_mode']) && (
$info[
'mpeg'][
'audio'][
'bitrate_mode'] == 
'vbr') && !isset(
$info[
'mpeg'][
'audio'][
'VBR_method'])) {
 
 1465                                                $BitrateHistogram = 
true;
 
 1468                                        if ($BitrateHistogram) {
 
 1470                                                $info[
'mpeg'][
'audio'][
'stereo_distribution']  = array(
'stereo'=>0, 
'joint stereo'=>0, 
'dual channel'=>0, 
'mono'=>0);
 
 1471                                                $info[
'mpeg'][
'audio'][
'version_distribution'] = array(
'1'=>0, 
'2'=>0, 
'2.5'=>0);
 
 1473                                                if (
$info[
'mpeg'][
'audio'][
'version'] == 
'1') {
 
 1474                                                        if (
$info[
'mpeg'][
'audio'][
'layer'] == 3) {
 
 1475                                                                $info[
'mpeg'][
'audio'][
'bitrate_distribution'] = array(
'free'=>0, 32000=>0, 40000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 320000=>0);
 
 1476                                                        } elseif (
$info[
'mpeg'][
'audio'][
'layer'] == 2) {
 
 1477                                                                $info[
'mpeg'][
'audio'][
'bitrate_distribution'] = array(
'free'=>0, 32000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 320000=>0, 384000=>0);
 
 1478                                                        } elseif (
$info[
'mpeg'][
'audio'][
'layer'] == 1) {
 
 1479                                                                $info[
'mpeg'][
'audio'][
'bitrate_distribution'] = array(
'free'=>0, 32000=>0, 64000=>0, 96000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 288000=>0, 320000=>0, 352000=>0, 384000=>0, 416000=>0, 448000=>0);
 
 1481                                                } elseif (
$info[
'mpeg'][
'audio'][
'layer'] == 1) {
 
 1482                                                        $info[
'mpeg'][
'audio'][
'bitrate_distribution'] = array(
'free'=>0, 32000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 144000=>0, 160000=>0, 176000=>0, 192000=>0, 224000=>0, 256000=>0);
 
 1484                                                        $info[
'mpeg'][
'audio'][
'bitrate_distribution'] = array(
'free'=>0, 8000=>0, 16000=>0, 24000=>0, 32000=>0, 40000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 144000=>0, 160000=>0);
 
 1487                                                $dummy = array(
'error'=>
$info[
'error'], 
'warning'=>
$info[
'warning'], 
'avdataend'=>
$info[
'avdataend'], 
'avdataoffset'=>
$info[
'avdataoffset']);
 
 1488                                                $synchstartoffset = 
$info[
'avdataoffset'];
 
 1489                                                $this->
fseek($info[
'avdataoffset']);
 
 1492                                                $max_frames_scan  = 50000;
 
 1493                                                $max_scan_segments = 10;
 
 1497                                                $SynchErrorsFound = 0;
 
 1498                                                $frames_scanned   = 0;
 
 1499                                                $this_scan_segment = 0;
 
 1500                                                $frames_scan_per_segment = ceil($max_frames_scan / $max_scan_segments);
 
 1501                                                $pct_data_scanned = 0;
 
 1502                                                for ($current_segment = 0; $current_segment < $max_scan_segments; $current_segment++) {
 
 1503                                                        $frames_scanned_this_segment = 0;
 
 1504                                                        if ($this->
ftell() >= $info[
'avdataend']) {
 
 1507                                                        $scan_start_offset[$current_segment] = max($this->
ftell(), $info[
'avdataoffset'] + round($current_segment * ((
$info[
'avdataend'] - 
$info[
'avdataoffset']) / $max_scan_segments)));
 
 1508                                                        if ($current_segment > 0) {
 
 1509                                                                $this->
fseek($scan_start_offset[$current_segment]);
 
 1510                                                                $buffer_4k = $this->
fread(4096);
 
 1511                                                                for ($j = 0; $j < (strlen($buffer_4k) - 4); $j++) {
 
 1512                                                                        if (($buffer_4k{$j} == 
"\xFF") && ($buffer_4k{($j + 1)} > 
"\xE0")) { 
 
 1513                                                                                if ($this->
decodeMPEGaudioHeader($scan_start_offset[$current_segment] + $j, $dummy, 
false, 
false, $FastMode)) {
 
 1514                                                                                        $calculated_next_offset = $scan_start_offset[$current_segment] + $j + $dummy[
'mpeg'][
'audio'][
'framelength'];
 
 1516                                                                                                $scan_start_offset[$current_segment] += $j;
 
 1523                                                        $synchstartoffset = $scan_start_offset[$current_segment];
 
 1526                                                                $thisframebitrate = $MPEGaudioBitrateLookup[$MPEGaudioVersionLookup[$dummy[
'mpeg'][
'audio'][
'raw'][
'version']]][$MPEGaudioLayerLookup[$dummy[
'mpeg'][
'audio'][
'raw'][
'layer']]][$dummy[
'mpeg'][
'audio'][
'raw'][
'bitrate']];
 
 1528                                                                if (empty($dummy[
'mpeg'][
'audio'][
'framelength'])) {
 
 1529                                                                        $SynchErrorsFound++;
 
 1530                                                                        $synchstartoffset++;
 
 1535                                                                        $synchstartoffset += $dummy[
'mpeg'][
'audio'][
'framelength'];
 
 1538                                                                if ($frames_scan_per_segment && (++$frames_scanned_this_segment >= $frames_scan_per_segment)) {
 
 1539                                                                        $this_pct_scanned = ($this->
ftell() - $scan_start_offset[$current_segment]) / (
$info[
'avdataend'] - 
$info[
'avdataoffset']);
 
 1540                                                                        if (($current_segment == 0) && (($this_pct_scanned * $max_scan_segments) >= 1)) {
 
 1542                                                                                $max_scan_segments = 1;
 
 1543                                                                                $frames_scan_per_segment = $max_frames_scan;
 
 1545                                                                                $pct_data_scanned += $this_pct_scanned;
 
 1551                                                if ($pct_data_scanned > 0) {
 
 1552                                                        $this->
warning(
'too many MPEG audio frames to scan, only scanned '.$frames_scanned.
' frames in '.$max_scan_segments.
' segments ('.number_format($pct_data_scanned * 100, 1).
'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.');
 
 1553                                                        foreach (
$info[
'mpeg'][
'audio'] as $key1 => $value1) {
 
 1554                                                                if (!preg_match(
'#_distribution$#i', $key1)) {
 
 1557                                                                foreach ($value1 as $key2 => $value2) {
 
 1558                                                                        $info[
'mpeg'][
'audio'][$key1][$key2] = round($value2 / $pct_data_scanned);
 
 1563                                                if ($SynchErrorsFound > 0) {
 
 1564                                                        $this->
warning(
'Found '.$SynchErrorsFound.
' synch errors in histogram analysis');
 
 1570                                                foreach (
$info[
'mpeg'][
'audio'][
'bitrate_distribution'] as $bitratevalue => $bitratecount) {
 
 1571                                                        $framecounter += $bitratecount;
 
 1572                                                        if ($bitratevalue != 
'free') {
 
 1573                                                                $bittotal += ($bitratevalue * $bitratecount);
 
 1576                                                if ($framecounter == 0) {
 
 1577                                                        $this->
error(
'Corrupt MP3 file: framecounter == zero');
 
 1581                                                $info[
'mpeg'][
'audio'][
'bitrate']     = ($bittotal / $framecounter);
 
 1583                                                $info[
'audio'][
'bitrate'] = 
$info[
'mpeg'][
'audio'][
'bitrate'];
 
 1587                                                $distinct_bitrates = 0;
 
 1588                                                foreach (
$info[
'mpeg'][
'audio'][
'bitrate_distribution'] as $bitrate_value => $bitrate_count) {
 
 1589                                                        if ($bitrate_count > 0) {
 
 1590                                                                $distinct_bitrates++;
 
 1593                                                if ($distinct_bitrates > 1) {
 
 1594                                                        $info[
'mpeg'][
'audio'][
'bitrate_mode'] = 
'vbr';
 
 1596                                                        $info[
'mpeg'][
'audio'][
'bitrate_mode'] = 
'cbr';
 
 1598                                                $info[
'audio'][
'bitrate_mode'] = 
$info[
'mpeg'][
'audio'][
'bitrate_mode'];
 
 1607                        if (($avdataoffset + $SynchSeekOffset) >= 
$info[
'avdataend']) {
 
 1610                                if (empty(
$info[
'mpeg'][
'audio'])) {
 
 1612                                        $this->
error(
'could not find valid MPEG synch before end of file');
 
 1613                                        if (isset(
$info[
'audio'][
'bitrate'])) {
 
 1614                                                unset(
$info[
'audio'][
'bitrate']);
 
 1616                                        if (isset(
$info[
'mpeg'][
'audio'])) {
 
 1617                                                unset(
$info[
'mpeg'][
'audio']);
 
 1619                                        if (isset(
$info[
'mpeg']) && (!is_array(
$info[
'mpeg']) || empty(
$info[
'mpeg']))) {
 
 1620                                                unset(
$info[
'mpeg']);
 
 1629                $info[
'audio'][
'channels']        = 
$info[
'mpeg'][
'audio'][
'channels'];
 
 1630                $info[
'audio'][
'channelmode']     = 
$info[
'mpeg'][
'audio'][
'channelmode'];
 
 1631                $info[
'audio'][
'sample_rate']     = 
$info[
'mpeg'][
'audio'][
'sample_rate'];
 
 1637                static $MPEGaudioVersion = array(
'2.5', 
false, 
'2', 
'1');
 
 1638                return $MPEGaudioVersion;
 
 1642                static $MPEGaudioLayer = array(
false, 3, 2, 1);
 
 1643                return $MPEGaudioLayer;
 
 1647                static $MPEGaudioBitrate;
 
 1648                if (empty($MPEGaudioBitrate)) {
 
 1649                        $MPEGaudioBitrate = array (
 
 1650                                '1'  =>  array (1 => array(
'free', 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000),
 
 1651                                                                2 => array(
'free', 32000, 48000, 56000,  64000,  80000,  96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000),
 
 1652                                                                3 => array(
'free', 32000, 40000, 48000,  56000,  64000,  80000,  96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000)
 
 1655                                '2'  =>  array (1 => array(
'free', 32000, 48000, 56000,  64000,  80000,  96000, 112000, 128000, 144000, 160000, 176000, 192000, 224000, 256000),
 
 1656                                                                2 => array(
'free',  8000, 16000, 24000,  32000,  40000,  48000,  56000,  64000,  80000,  96000, 112000, 128000, 144000, 160000),
 
 1659                        $MPEGaudioBitrate[
'2'][3] = $MPEGaudioBitrate[
'2'][2];
 
 1660                        $MPEGaudioBitrate[
'2.5']  = $MPEGaudioBitrate[
'2'];
 
 1662                return $MPEGaudioBitrate;
 
 1666                static $MPEGaudioFrequency;
 
 1667                if (empty($MPEGaudioFrequency)) {
 
 1668                        $MPEGaudioFrequency = array (
 
 1669                                '1'   => array(44100, 48000, 32000),
 
 1670                                '2'   => array(22050, 24000, 16000),
 
 1671                                '2.5' => array(11025, 12000,  8000)
 
 1674                return $MPEGaudioFrequency;
 
 1678                static $MPEGaudioChannelMode = array(
'stereo', 
'joint stereo', 
'dual channel', 
'mono');
 
 1679                return $MPEGaudioChannelMode;
 
 1683                static $MPEGaudioModeExtension;
 
 1684                if (empty($MPEGaudioModeExtension)) {
 
 1685                        $MPEGaudioModeExtension = array (
 
 1686                                1 => array(
'4-31', 
'8-31', 
'12-31', 
'16-31'),
 
 1687                                2 => array(
'4-31', 
'8-31', 
'12-31', 
'16-31'),
 
 1688                                3 => array(
'', 
'IS', 
'MS', 
'IS+MS')
 
 1691                return $MPEGaudioModeExtension;
 
 1695                static $MPEGaudioEmphasis = array(
'none', 
'50/15ms', 
false, 
'CCIT J.17');
 
 1696                return $MPEGaudioEmphasis;
 
 1704                if (($rawarray[
'synch'] & 0x0FFE) != 0x0FFE) {
 
 1708                static $MPEGaudioVersionLookup;
 
 1709                static $MPEGaudioLayerLookup;
 
 1710                static $MPEGaudioBitrateLookup;
 
 1711                static $MPEGaudioFrequencyLookup;
 
 1712                static $MPEGaudioChannelModeLookup;
 
 1713                static $MPEGaudioModeExtensionLookup;
 
 1714                static $MPEGaudioEmphasisLookup;
 
 1715                if (empty($MPEGaudioVersionLookup)) {
 
 1725                if (isset($MPEGaudioVersionLookup[$rawarray[
'version']])) {
 
 1726                        $decodedVersion = $MPEGaudioVersionLookup[$rawarray[
'version']];
 
 1728                        echo ($echoerrors ? 
"\n".
'invalid Version ('.$rawarray[
'version'].
')' : 
'');
 
 1731                if (isset($MPEGaudioLayerLookup[$rawarray[
'layer']])) {
 
 1732                        $decodedLayer = $MPEGaudioLayerLookup[$rawarray[
'layer']];
 
 1734                        echo ($echoerrors ? 
"\n".
'invalid Layer ('.$rawarray[
'layer'].
')' : 
'');
 
 1737                if (!isset($MPEGaudioBitrateLookup[$decodedVersion][$decodedLayer][$rawarray[
'bitrate']])) {
 
 1738                        echo ($echoerrors ? 
"\n".
'invalid Bitrate ('.$rawarray[
'bitrate'].
')' : 
'');
 
 1739                        if ($rawarray[
'bitrate'] == 15) {
 
 1742                                if (!$allowBitrate15) {
 
 1749                if (!isset($MPEGaudioFrequencyLookup[$decodedVersion][$rawarray[
'sample_rate']])) {
 
 1750                        echo ($echoerrors ? 
"\n".
'invalid Frequency ('.$rawarray[
'sample_rate'].
')' : 
'');
 
 1753                if (!isset($MPEGaudioChannelModeLookup[$rawarray[
'channelmode']])) {
 
 1754                        echo ($echoerrors ? 
"\n".
'invalid ChannelMode ('.$rawarray[
'channelmode'].
')' : 
'');
 
 1757                if (!isset($MPEGaudioModeExtensionLookup[$decodedLayer][$rawarray[
'modeextension']])) {
 
 1758                        echo ($echoerrors ? 
"\n".
'invalid Mode Extension ('.$rawarray[
'modeextension'].
')' : 
'');
 
 1761                if (!isset($MPEGaudioEmphasisLookup[$rawarray[
'emphasis']])) {
 
 1762                        echo ($echoerrors ? 
"\n".
'invalid Emphasis ('.$rawarray[
'emphasis'].
')' : 
'');
 
 1791                if (strlen($Header4Bytes) != 4) {
 
 1796                $MPEGrawHeader[
'version']       = (ord($Header4Bytes{1}) & 0x18) >> 3; 
 
 1797                $MPEGrawHeader[
'layer']         = (ord($Header4Bytes{1}) & 0x06) >> 1; 
 
 1798                $MPEGrawHeader[
'protection']    = (ord($Header4Bytes{1}) & 0x01);      
 
 1799                $MPEGrawHeader[
'bitrate']       = (ord($Header4Bytes{2}) & 0xF0) >> 4; 
 
 1800                $MPEGrawHeader[
'sample_rate']   = (ord($Header4Bytes{2}) & 0x0C) >> 2; 
 
 1801                $MPEGrawHeader[
'padding']       = (ord($Header4Bytes{2}) & 0x02) >> 1; 
 
 1802                $MPEGrawHeader[
'private']       = (ord($Header4Bytes{2}) & 0x01);      
 
 1803                $MPEGrawHeader[
'channelmode']   = (ord($Header4Bytes{3}) & 0xC0) >> 6; 
 
 1804                $MPEGrawHeader[
'modeextension'] = (ord($Header4Bytes{3}) & 0x30) >> 4; 
 
 1805                $MPEGrawHeader[
'copyright']     = (ord($Header4Bytes{3}) & 0x08) >> 3; 
 
 1806                $MPEGrawHeader[
'original']      = (ord($Header4Bytes{3}) & 0x04) >> 2; 
 
 1807                $MPEGrawHeader[
'emphasis']      = (ord($Header4Bytes{3}) & 0x03);      
 
 1809                return $MPEGrawHeader;
 
 1813                static $AudioFrameLengthCache = array();
 
 1815                if (!isset($AudioFrameLengthCache[$bitrate][
$version][$layer][$padding][$samplerate])) {
 
 1816                        $AudioFrameLengthCache[$bitrate][
$version][$layer][$padding][$samplerate] = 
false;
 
 1817                        if ($bitrate != 
'free') {
 
 1821                                        if ($layer == 
'1') {
 
 1824                                                $FrameLengthCoefficient = 48;
 
 1830                                                $FrameLengthCoefficient = 144;
 
 1837                                        if ($layer == 
'1') {
 
 1840                                                $FrameLengthCoefficient = 24;
 
 1843                                        } elseif ($layer == 
'2') {
 
 1846                                                $FrameLengthCoefficient = 144;
 
 1852                                                $FrameLengthCoefficient = 72;
 
 1860                                if ($samplerate > 0) {
 
 1861                                        $NewFramelength  = ($FrameLengthCoefficient * $bitrate) / $samplerate;
 
 1862                                        $NewFramelength  = floor($NewFramelength / $SlotLength) * $SlotLength; 
 
 1864                                                $NewFramelength += $SlotLength;
 
 1866                                        $AudioFrameLengthCache[$bitrate][
$version][$layer][$padding][$samplerate] = (int) $NewFramelength;
 
 1870                return $AudioFrameLengthCache[$bitrate][
$version][$layer][$padding][$samplerate];
 
 1874                static $standard_bit_rates = array (320000, 256000, 224000, 192000, 160000, 128000, 112000, 96000, 80000, 64000, 56000, 48000, 40000, 32000, 24000, 16000, 8000);
 
 1875                static $bit_rate_table = array (0=>
'-');
 
 1876                $round_bit_rate = intval(round($bit_rate, -3));
 
 1877                if (!isset($bit_rate_table[$round_bit_rate])) {
 
 1878                        if ($round_bit_rate > max($standard_bit_rates)) {
 
 1879                                $bit_rate_table[$round_bit_rate] = round($bit_rate, 2 - strlen($bit_rate));
 
 1881                                $bit_rate_table[$round_bit_rate] = max($standard_bit_rates);
 
 1882                                foreach ($standard_bit_rates as $standard_bit_rate) {
 
 1883                                        if ($round_bit_rate >= $standard_bit_rate + (($bit_rate_table[$round_bit_rate] - $standard_bit_rate) / 2)) {
 
 1886                                        $bit_rate_table[$round_bit_rate] = $standard_bit_rate;
 
 1890                return $bit_rate_table[$round_bit_rate];
 
 1894                static $XingVBRidOffsetCache = array();
 
 1895                if (empty($XingVBRidOffset)) {
 
 1896                        $XingVBRidOffset = array (
 
 1897                                '1'   => array (
'mono'          => 0x15, 
 
 1899                                                                'joint stereo'  => 0x24,
 
 1900                                                                'dual channel'  => 0x24
 
 1903                                '2'   => array (
'mono'          => 0x0D, 
 
 1905                                                                'joint stereo'  => 0x15,
 
 1906                                                                'dual channel'  => 0x15
 
 1909                                '2.5' => array (
'mono'          => 0x15,
 
 1911                                                                'joint stereo'  => 0x15,
 
 1912                                                                'dual channel'  => 0x15
 
 1916                return $XingVBRidOffset[
$version][$channelmode];
 
 1920                static $LAMEvbrMethodLookup = array(
 
 1924                        0x03 => 
'vbr-old / vbr-rh',
 
 1925                        0x04 => 
'vbr-new / vbr-mtrh',
 
 1927                        0x06 => 
'vbr (full vbr method 4)',
 
 1928                        0x08 => 
'cbr (constant bitrate 2 pass)',
 
 1929                        0x09 => 
'abr (2 pass)',
 
 1932                return (isset($LAMEvbrMethodLookup[$VBRmethodID]) ? $LAMEvbrMethodLookup[$VBRmethodID] : 
'');
 
 1936                static $LAMEmiscStereoModeLookup = array(
 
 1940                        3 => 
'joint stereo',
 
 1941                        4 => 
'forced stereo',
 
 1943                        6 => 
'intensity stereo',
 
 1946                return (isset($LAMEmiscStereoModeLookup[$StereoModeID]) ? $LAMEmiscStereoModeLookup[$StereoModeID] : 
'');
 
 1950                static $LAMEmiscSourceSampleFrequencyLookup = array(
 
 1956                return (isset($LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID]) ? $LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID] : 
'');
 
 1960                static $LAMEsurroundInfoLookup = array(
 
 1961                        0 => 
'no surround info',
 
 1962                        1 => 
'DPL encoding',
 
 1963                        2 => 
'DPL2 encoding',
 
 1964                        3 => 
'Ambisonic encoding' 
 1966                return (isset($LAMEsurroundInfoLookup[$SurroundInfoID]) ? $LAMEsurroundInfoLookup[$SurroundInfoID] : 
'reserved');
 
 1971                if ($LAMEtag[
'preset_used_id'] == 0) {
 
 1976                $LAMEpresetUsedLookup = array();
 
 1979                for (
$i = 8; 
$i <= 320; 
$i++) {
 
 1980                        switch ($LAMEtag[
'vbr_method']) {
 
 1982                                        $LAMEpresetUsedLookup[
$i] = 
'--alt-preset '.$LAMEtag[
'vbr_method'].
' '.
$i;
 
 1986                                        $LAMEpresetUsedLookup[
$i] = 
'--alt-preset '.$i;
 
 1994                $LAMEpresetUsedLookup[1000] = 
'--r3mix';
 
 1995                $LAMEpresetUsedLookup[1001] = 
'--alt-preset standard';
 
 1996                $LAMEpresetUsedLookup[1002] = 
'--alt-preset extreme';
 
 1997                $LAMEpresetUsedLookup[1003] = 
'--alt-preset insane';
 
 1998                $LAMEpresetUsedLookup[1004] = 
'--alt-preset fast standard';
 
 1999                $LAMEpresetUsedLookup[1005] = 
'--alt-preset fast extreme';
 
 2000                $LAMEpresetUsedLookup[1006] = 
'--alt-preset medium';
 
 2001                $LAMEpresetUsedLookup[1007] = 
'--alt-preset fast medium';
 
 2004                $LAMEpresetUsedLookup[1010] = 
'--preset portable';                                                           
 
 2005                $LAMEpresetUsedLookup[1015] = 
'--preset radio';                                                              
 
 2007                $LAMEpresetUsedLookup[320]  = 
'--preset insane';                                                             
 
 2008                $LAMEpresetUsedLookup[410]  = 
'-V9';
 
 2009                $LAMEpresetUsedLookup[420]  = 
'-V8';
 
 2010                $LAMEpresetUsedLookup[440]  = 
'-V6';
 
 2011                $LAMEpresetUsedLookup[430]  = 
'--preset radio';                                                              
 
 2012                $LAMEpresetUsedLookup[450]  = 
'--preset '.(($LAMEtag[
'raw'][
'vbr_method'] == 4) ? 
'fast ' : 
'').
'portable';  
 
 2013                $LAMEpresetUsedLookup[460]  = 
'--preset '.(($LAMEtag[
'raw'][
'vbr_method'] == 4) ? 
'fast ' : 
'').
'medium';    
 
 2014                $LAMEpresetUsedLookup[470]  = 
'--r3mix';                                                                     
 
 2015                $LAMEpresetUsedLookup[480]  = 
'--preset '.(($LAMEtag[
'raw'][
'vbr_method'] == 4) ? 
'fast ' : 
'').
'standard';  
 
 2016                $LAMEpresetUsedLookup[490]  = 
'-V1';
 
 2017                $LAMEpresetUsedLookup[500]  = 
'--preset '.(($LAMEtag[
'raw'][
'vbr_method'] == 4) ? 
'fast ' : 
'').
'extreme';   
 
 2019                return (isset($LAMEpresetUsedLookup[$LAMEtag[
'preset_used_id']]) ? $LAMEpresetUsedLookup[$LAMEtag[
'preset_used_id']] : 
'new/unknown preset: '.$LAMEtag[
'preset_used_id'].
' - report to info@getid3.org');
 
An exception for terminatinating execution or to throw for unit testing.
fseek($bytes, $whence=SEEK_SET)
static RGADadjustmentLookup($rawadjustment, $signbit)
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
static RGADamplitude2dB($amplitude)
static safe_inc(&$variable, $increment=1)
static RGADoriginatorLookup($originatorcode)
static array_max($arraydata, $returnkey=false)
static LittleEndian2Float($byteword)
static RGADnameLookup($namecode)
static CastAsInt($floatnum)
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
static MPEGaudioFrameLength(&$bitrate, &$version, &$layer, $padding, &$samplerate)
static MPEGaudioFrequencyArray()
getOnlyMPEGaudioInfo($avdataoffset, $BitrateHistogram=false)
static LAMEpresetUsedLookup($LAMEtag)
static MPEGaudioHeaderValid($rawarray, $echoerrors=false, $allowBitrate15=false)
getOnlyMPEGaudioInfoBruteForce()
static MPEGaudioHeaderBytesValid($head4, $allowBitrate15=false)
static LAMEmiscStereoModeLookup($StereoModeID)
RecursiveFrameScanning(&$offset, &$nextframetestoffset, $ScanAsCBR)
static MPEGaudioHeaderDecode($Header4Bytes)
static MPEGaudioVersionArray()
static MPEGaudioEmphasisArray()
static XingVBRidOffset($version, $channelmode)
static ClosestStandardMP3Bitrate($bit_rate)
static LAMEvbrMethodLookup($VBRmethodID)
static MPEGaudioModeExtensionArray()
static LAMEmiscSourceSampleFrequencyLookup($SourceSampleFrequencyID)
static MPEGaudioChannelModeArray()
static MPEGaudioLayerArray()
static LAMEsurroundInfoLookup($SurroundInfoID)
decodeMPEGaudioHeader($offset, &$info, $recursivesearch=true, $ScanAsCBR=false, $FastMPEGheaderScan=false)
FreeFormatFrameLength($offset, $deepscan=false)
static MPEGaudioBitrateArray()
const GETID3_MP3_VALID_CHECK_FRAMES
getID3() by James Heinrich info@getid3.org //