Minor fixes

git-svn-id: http://php-reader.googlecode.com/svn/trunk@126 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2008-12-13 22:21:35 +00:00
parent 2d31422910
commit b4cae3bf42
2 changed files with 9 additions and 7 deletions

View File

@@ -59,6 +59,7 @@ require_once("MPEG/ABS/Frame.php");
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License * @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev: 1 $ * @version $Rev: 1 $
* @todo Implement validation routines
*/ */
final class MPEG_ABS extends MPEG_ABS_Object final class MPEG_ABS extends MPEG_ABS_Object
{ {
@@ -356,8 +357,7 @@ final class MPEG_ABS extends MPEG_ABS_Object
*/ */
public function getFrames() public function getFrames()
{ {
if ($this->getOption("readmode", "lazy") == "lazy" && if ($this->getOption("readmode", "lazy") == "lazy") {
$this->_frames === false) {
$this->_readFrames(); $this->_readFrames();
} }
return $this->_frames; return $this->_frames;
@@ -376,6 +376,7 @@ final class MPEG_ABS extends MPEG_ABS_Object
$this->_reader->setOffset($this->_lastFrameOffset); $this->_reader->setOffset($this->_lastFrameOffset);
for ($i = 0; $this->_reader->getOffset() < $this->_bytes; $i++) { for ($i = 0; $this->_reader->getOffset() < $this->_bytes; $i++) {
$options = $this->getOptions();
$frame = new MPEG_ABS_Frame($this->_reader, $options); $frame = new MPEG_ABS_Frame($this->_reader, $options);
$this->_cumulativePlayDuration += $this->_cumulativePlayDuration +=
@@ -383,6 +384,8 @@ final class MPEG_ABS extends MPEG_ABS_Object
$this->_cumulativeBitrate += $frame->getBitrate(); $this->_cumulativeBitrate += $frame->getBitrate();
$this->_frames[] = $frame; $this->_frames[] = $frame;
if ($limit === false)
$this->_lastFrameOffset = $this->_reader->getOffset();
if ($limit !== false && ($i + 1) == $limit) { if ($limit !== false && ($i + 1) == $limit) {
$this->_lastFrameOffset = $this->_reader->getOffset(); $this->_lastFrameOffset = $this->_reader->getOffset();
break; break;

View File

@@ -266,12 +266,11 @@ class MPEG_ABS_Frame extends MPEG_ABS_Object
($this->_padding ? 1 : 0)) * self::$slotsizes[$this->_layer]; ($this->_padding ? 1 : 0)) * self::$slotsizes[$this->_layer];
$this->_samples = self::$samples[$this->_frequencyType][$this->_layer]; $this->_samples = self::$samples[$this->_frequencyType][$this->_layer];
if ($this->getOption("readmode", "lazy") == "lazy") if ($this->getOption("readmode", "lazy") == "full") {
$this->_reader->skip($this->_length - 4);
else { // full
$this->_readCrc(); $this->_readCrc();
$this->_readData(); $this->_readData();
} }
$this->_reader->skip($this->_length - 4);
} }
/** /**
@@ -473,7 +472,7 @@ class MPEG_ABS_Frame extends MPEG_ABS_Object
if ($this->hasRedundancy()) { if ($this->hasRedundancy()) {
$offset = $this->_reader->getOffset(); $offset = $this->_reader->getOffset();
$this->_reader->setOffset($this->_offset + 4); $this->_reader->setOffset($this->_offset + 4);
$this->_crc = $reader->readUInt16BE(); $this->_crc = $this->_reader->readUInt16BE();
$this->_reader->setOffset($offset); $this->_reader->setOffset($offset);
} }
} }