Sample Size Box contains the sample count and a table giving the * size in bytes of each sample. This allows the media data itself to be * unframed. The total number of samples in the media is always indicated in the * sample count. * * There are two variants of the sample size box. The first variant has a fixed * size 32-bit field for representing the sample sizes; it permits defining a * constant size for all samples in a track. The second variant permits smaller * size fields, to save space when the sizes are varying but small. One of these * boxes must be present; the first version is preferred for maximum * compatibility. * * @package php-reader * @subpackage ISO 14496 * @author Sven Vollbehr * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup * @license http://code.google.com/p/php-reader/wiki/License New BSD License * @version $Rev: 92 $ */ final class ISO14496_Box_STSZ extends ISO14496_Box_Full { /** @var integer */ private $_sampleSize; /** @var Array */ private $_sampleSizeTable = array(); /** * Constructs the class with given parameters and reads box related data from * the ISO Base Media file. * * @param Reader $reader The reader object. */ public function __construct($reader, &$options = array()) { parent::__construct($reader, $options); $this->_sampleSize = $this->_reader->readUInt32BE(); $sampleCount = $this->_reader->readUInt32BE(); if ($this->_sampleSize == 0) { $data = $this->_reader->read ($this->getOffset() + $this->getSize() - $this->_reader->getOffset()); for ($i = 1; $i <= $sampleCount; $i++) $this->_sampleSizeTable[$i] = Transform::fromUInt32BE(substr($data, ($i - 1) * 4, 4)); } } /** * Returns the default sample size. If all the samples are the same size, this * field contains that size value. If this field is set to 0, then the samples * have different sizes, and those sizes are stored in the sample size table. * * @return integer */ public function getSampleSize() { return $this->_sampleSize; } /** * Returns an array of sample sizes specifying the size of a sample, indexed * by its number. * * @return Array */ public function getSampleSizeTable() { return $this->_sampleSizeTable; } }