Fix issue 44

git-svn-id: http://php-reader.googlecode.com/svn/trunk@208 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2010-12-28 13:48:09 +00:00
parent 6eb18085f3
commit ae666f57f4
3 changed files with 40 additions and 3 deletions

View File

@@ -139,13 +139,43 @@ final class Zend_Media_Mpeg_Abs extends Zend_Media_Mpeg_Abs_Object
}
$this->_reader->setOffset($offset);
/* Skip ID3v2 tag */
if ($this->_reader->readString8(3) == 'ID3') {
/* Skip ID3v2 tags (some files errorneusly contain multiple tags) */
while ($this->_reader->readString8(3) == 'ID3') {
require_once 'Zend/Media/Id3/Header.php';
$header = new Zend_Media_Id3_Header($this->_reader);
$this->_reader->skip
($header->getSize() +
($header->hasFlag(Zend_Media_Id3_Header::FOOTER) ? 10 : 0));
$offset = $this->_reader->getOffset();
}
$this->_reader->setOffset($offset);
/* Check whether the ABS is contained within a RIFF chunk */
$offset = $this->_reader->getOffset();
if ($this->_reader->readString8(4) == 'RIFF') {
$riffSize = $this->_reader->readUInt32LE();
$riffType = $this->_reader->read(4); // WAVE
while ($this->_reader->getOffset() < $offset + 8 + $riffSize - 1) {
$chunkId = $this->_reader->read(4);
$chunkSize = $this->_reader->readUInt32LE();
if ($chunkId == 'fmt ') {
if ($this->_reader->readInt16LE() != 85) { // 85: MPEG-1 Layer 3 Codec
require_once 'Zend/Media/Mpeg/Exception.php';
throw new Zend_Media_Mpeg_Exception
('File does not contain a valid MPEG Audio Bit Stream (Contains RIFF with no MPEG ABS)');
} else {
$this->_reader->skip($chunkSize - 2);
}
} else if ($chunkId == 'data') {
$offset = $this->_reader->getOffset();
break;
} else {
$this->_reader->skip($chunkSize);
}
}
} else {
$this->_reader->setOffset($offset);
}

View File

@@ -230,6 +230,11 @@ final class Zend_Media_Mpeg_Abs_Frame extends Zend_Media_Mpeg_Abs_Object
$this->_offset = $this->_reader->getOffset();
$header = $this->_reader->readUInt32BE();
if (!Zend_Bit_Twiddling::testAllBits(Zend_Bit_Twiddling::getValue($header, 21, 32), 0xffe)) {
require_once 'Zend/Media/Mpeg/Exception.php';
throw new Zend_Media_Mpeg_Exception
('File does not contain a valid MPEG Audio Bit Stream (Invalid frame sync)');
}
$this->_version = Zend_Bit_Twiddling::getValue($header, 19, 20);
$this->_frequencyType = Zend_Bit_Twiddling::testBit($header, 19);
$this->_layer = Zend_Bit_Twiddling::getValue($header, 17, 18);

View File

@@ -92,7 +92,9 @@ final class Zend_Media_Mpeg_Ps extends Zend_Media_Mpeg_Object
$i1 = $this->_reader->readUInt32BE();
$i2 = $this->_reader->readUInt32BE();
if (!Zend_Bit_Twiddling::testAllBits($i2, 0x2000)) {
throw new RuntimeException('Invalid mark');
require_once 'Zend/Media/Mpeg/Exception.php';
throw new Zend_Media_Mpeg_Exception
('File does not contain a valid MPEG Program Stream (Invalid mark)');
}
$pictureRate = $rates[Zend_Bit_Twiddling::getValue($i1, 4, 8)];
$foundSeqHdr = true;