Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Mp3Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ private function readMpegFrame($fp) {

switch ($header_bytes[1] >> 3 & 0b11) {
case 0b00: $this->codecVersion = self::MPEG_25; break;
case 0b01: $this->codecVersion = self::CODEC_UNDEFINED; break;
case 0b10: $this->codecVersion = self::MPEG_2; break;
case 0b11: $this->codecVersion = self::MPEG_1; break;
}
Expand All @@ -384,6 +383,9 @@ private function readMpegFrame($fp) {
case 0b11: $this->layerVersion = self::LAYER_1; break;
}

if (!isset($this->codecVersion) || !isset($this->layerVersion) || !isset($header_bytes[2])) {
throw new \Exception('Unrecognized codecVersion or layerVersion headers!');
}
$this->bitRate = self::$_bitRateTable[$this->codecVersion][$this->layerVersion][$header_bytes[2] >> 4];
$this->sampleRate = self::$_sampleRateTable[$this->codecVersion][($header_bytes[2] >> 2) & 0b11];

Expand All @@ -394,6 +396,9 @@ private function readMpegFrame($fp) {
case 0b11: $this->channel = self::MONO; break;
}

if (!isset($this->channel)) {
throw new \Exception('Unrecognized channel header!');
}
$vbr_offset = self::$_vbrOffsets[$this->codecVersion][$this->channel == self::MONO ? 0 : 1];

// check for VBR
Expand Down