getid3_mp3::MPEGaudioHeaderValid() –

You appear to be a bot. Output may be restricted

Description

Usage

$bool = getid3_mp3::MPEGaudioHeaderValid( $rawarray, $echoerrors, $allowBitrate15 );

Parameters

$rawarray
( array ) required
$echoerrors
( bool ) optional
$allowBitrate15
( bool ) optional

Returns

bool

Source

File name: wordpress/wp-includes/ID3/module.audio.mp3.php
Lines:

1 to 71 of 71
  public static function MPEGaudioHeaderValid($rawarray, $echoerrors=false, $allowBitrate15=false) {
    if (!isset($rawarray['synch']) || ($rawarray['synch'] & 0x0FFE) != 0x0FFE) {
      return false;
    }

    static $MPEGaudioVersionLookup;
    static $MPEGaudioLayerLookup;
    static $MPEGaudioBitrateLookup;
    static $MPEGaudioFrequencyLookup;
    static $MPEGaudioChannelModeLookup;
    static $MPEGaudioModeExtensionLookup;
    static $MPEGaudioEmphasisLookup;
    if (empty($MPEGaudioVersionLookup)) {
      $MPEGaudioVersionLookup       = self::MPEGaudioVersionArray();
      $MPEGaudioLayerLookup         = self::MPEGaudioLayerArray();
      $MPEGaudioBitrateLookup       = self::MPEGaudioBitrateArray();
      $MPEGaudioFrequencyLookup     = self::MPEGaudioFrequencyArray();
      $MPEGaudioChannelModeLookup   = self::MPEGaudioChannelModeArray();
      $MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray();
      $MPEGaudioEmphasisLookup      = self::MPEGaudioEmphasisArray();
    }

    if (isset($MPEGaudioVersionLookup[$rawarray['version']])) {
      $decodedVersion = $MPEGaudioVersionLookup[$rawarray['version']];
    } else {
      echo ($echoerrors ? "\n".'invalid Version ('.$rawarray['version'].')' : '');
      return false;
    }
    if (isset($MPEGaudioLayerLookup[$rawarray['layer']])) {
      $decodedLayer = $MPEGaudioLayerLookup[$rawarray['layer']];
    } else {
      echo ($echoerrors ? "\n".'invalid Layer ('.$rawarray['layer'].')' : '');
      return false;
    }
    if (!isset($MPEGaudioBitrateLookup[$decodedVersion][$decodedLayer][$rawarray['bitrate']])) {
      echo ($echoerrors ? "\n".'invalid Bitrate ('.$rawarray['bitrate'].')' : '');
      if ($rawarray['bitrate'] == 15) {
        // known issue in LAME 3.90 - 3.93.1 where free-format has bitrate ID of 15 instead of 0
        // let it go through here otherwise file will not be identified
        if (!$allowBitrate15) {
          return false;
        }
      } else {
        return false;
      }
    }
    if (!isset($MPEGaudioFrequencyLookup[$decodedVersion][$rawarray['sample_rate']])) {
      echo ($echoerrors ? "\n".'invalid Frequency ('.$rawarray['sample_rate'].')' : '');
      return false;
    }
    if (!isset($MPEGaudioChannelModeLookup[$rawarray['channelmode']])) {
      echo ($echoerrors ? "\n".'invalid ChannelMode ('.$rawarray['channelmode'].')' : '');
      return false;
    }
    if (!isset($MPEGaudioModeExtensionLookup[$decodedLayer][$rawarray['modeextension']])) {
      echo ($echoerrors ? "\n".'invalid Mode Extension ('.$rawarray['modeextension'].')' : '');
      return false;
    }
    if (!isset($MPEGaudioEmphasisLookup[$rawarray['emphasis']])) {
      echo ($echoerrors ? "\n".'invalid Emphasis ('.$rawarray['emphasis'].')' : '');
      return false;
    }
    // These are just either set or not set, you can't mess that up :)
    // $rawarray['protection'];
    // $rawarray['padding'];
    // $rawarray['private'];
    // $rawarray['copyright'];
    // $rawarray['original'];

    return true;
  }
 

 View on GitHub View on Trac