Пример #1
0
 /**
  * Constructs the class with given parameters and reads object related data
  * from the bitstream.
  *
  * @param Zend_Io_Reader $reader The reader object.
  * @param Array $options Array of options.
  */
 public function __construct($reader, &$options = array())
 {
     parent::__construct($reader, $options);
     $flags = $reader->readUInt32BE();
     if (Zend_Bit_Twiddling::testAnyBits($flags, 0x1)) {
         $this->_frames = $this->_reader->readUInt32BE();
     }
     if (Zend_Bit_Twiddling::testAnyBits($flags, 0x2)) {
         $this->_bytes = $this->_reader->readUInt32BE();
     }
     if (Zend_Bit_Twiddling::testAnyBits($flags, 0x4)) {
         $this->_toc = array_merge(unpack('C*', $this->_reader->read(100)));
     }
     if (Zend_Bit_Twiddling::testAnyBits($flags, 0x8)) {
         $this->_qualityIndicator = $this->_reader->readUInt32BE();
     }
 }
Пример #2
0
 /**
  * Constructs the class with given parameters and reads object related data
  * from the bitstream.
  *
  * @param Zend_Io_Reader $reader The reader object.
  * @param Array $options Array of options.
  */
 public function __construct($reader, &$options = array())
 {
     parent::__construct($reader, $options);
     $offset = $this->_reader->getOffset();
     $this->_version = $this->_reader->readUInt16BE();
     $this->_delay = $this->_reader->readUInt16BE();
     $this->_qualityIndicator = $this->_reader->readUInt16BE();
     $this->_bytes = $this->_reader->readUInt32BE();
     $this->_frames = $this->_reader->readUInt32BE();
     $tocEntries = $this->_reader->readUInt16BE();
     $tocEntryScale = $this->_reader->readUInt16BE();
     $tocEntrySize = $this->_reader->readUInt16BE();
     $this->_tocFramesPerEntry = $this->_reader->readUInt16BE();
     $this->_toc = array_merge(unpack($tocEntrySize == 1 ? 'C*' : $tocEntrySize == 2 ? 'n*' : 'N*', $this->_reader->read($tocCount * $tocEntrySize)));
     foreach ($this->_toc as $key => $value) {
         $this->_toc[$key] = $tocEntryScale * $value;
     }
     $this->_length = $this->_reader->getOffset() - $offset;
 }
Пример #3
0
 /**
  * Constructs the class with given parameters and reads object related data
  * from the frame.
  *
  * @param Zend_Io_Reader $reader The reader object.
  * @param Array          $options Array of options.
  */
 public function __construct($reader, &$options = array())
 {
     parent::__construct($reader, $options);
     $this->_offset = $this->_reader->getOffset();
     $header = $this->_reader->readUInt32BE();
     $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);
     $this->_redundancy = !Zend_Bit_Twiddling::testBit($header, 16);
     $this->_bitrate = isset(self::$bitrates[$this->_frequencyType][$this->_layer][$index = Zend_Bit_Twiddling::getValue($header, 12, 15)]) ? self::$bitrates[$this->_frequencyType][$this->_layer][$index] : false;
     $this->_samplingFrequency = isset(self::$samplingFrequencies[$this->_version][$index = Zend_Bit_Twiddling::getValue($header, 10, 11)]) ? self::$samplingFrequencies[$this->_version][$index] : false;
     $this->_padding = Zend_Bit_Twiddling::testBit($header, 9);
     $this->_mode = Zend_Bit_Twiddling::getValue($header, 6, 7);
     $this->_modeExtension = Zend_Bit_Twiddling::getValue($header, 4, 5);
     $this->_copyright = Zend_Bit_Twiddling::testBit($header, 3);
     $this->_original = Zend_Bit_Twiddling::testBit($header, 2);
     $this->_emphasis = Zend_Bit_Twiddling::getValue($header, 0, 1);
     $this->_length = (int) (self::$coefficients[$this->_frequencyType][$this->_layer] * ($this->_bitrate * 1000) / $this->_samplingFrequency + ($this->_padding ? 1 : 0)) * self::$slotsizes[$this->_layer];
     $this->_samples = self::$samples[$this->_frequencyType][$this->_layer];
     if ($this->getOption('readmode', 'lazy') == 'full') {
         $this->_readCrc();
         $this->_readData();
     }
     $this->_reader->skip($this->_length - 4);
 }
Пример #4
0
 /**
  * Constructs the class with given parameters and reads object related data
  * from the frame.
  *
  * @param Zend_Io_Reader $reader The reader object.
  * @param Array          $options Array of options.
  */
 public function __construct($reader, &$options = array())
 {
     parent::__construct($reader, $options);
     $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);
     $this->_redundancy = !Zend_Bit_Twiddling::testBit($header, 16);
     $this->_bitrate = isset(self::$bitrates[$this->_frequencyType][$this->_layer][$index = Zend_Bit_Twiddling::getValue($header, 12, 15)]) ? self::$bitrates[$this->_frequencyType][$this->_layer][$index] : false;
     $this->_samplingFrequency = isset(self::$samplingFrequencies[$this->_version][$index = Zend_Bit_Twiddling::getValue($header, 10, 11)]) ? self::$samplingFrequencies[$this->_version][$index] : false;
     $this->_padding = Zend_Bit_Twiddling::testBit($header, 9);
     $this->_mode = Zend_Bit_Twiddling::getValue($header, 6, 7);
     $this->_modeExtension = Zend_Bit_Twiddling::getValue($header, 4, 5);
     $this->_copyright = Zend_Bit_Twiddling::testBit($header, 3);
     $this->_original = Zend_Bit_Twiddling::testBit($header, 2);
     $this->_emphasis = Zend_Bit_Twiddling::getValue($header, 0, 1);
     $this->_length = (int) (self::$coefficients[$this->_frequencyType][$this->_layer] * ($this->_bitrate * 1000) / $this->_samplingFrequency + ($this->_padding ? 1 : 0)) * self::$slotsizes[$this->_layer];
     $this->_samples = self::$samples[$this->_frequencyType][$this->_layer];
     if ($this->getOption('readmode', 'lazy') == 'full') {
         $this->_readCrc();
         $this->_readData();
     }
     $this->_reader->skip($this->_length - 4);
 }
Пример #5
0
 /**
  * Constructs the class with given parameters and reads object related data
  * from the bitstream.
  *
  * @param Zend_Io_Reader $reader The reader object.
  * @param Array          $options Array of options.
  */
 public function __construct($reader, &$options = array())
 {
     parent::__construct($reader, $options);
     $this->_version = $this->_reader->readString8(5);
     $tmp = $this->_reader->readUInt8();
     $this->_revision = Zend_Bit_Twiddling::getValue($tmp, 4, 8);
     $this->_vbrMethod = Zend_Bit_Twiddling::getValue($tmp, 0, 3);
     $this->_lowpass = $this->_reader->readUInt8() * 100;
     $this->_peakSignalAmplitude = $this->_reader->readUInt32BE();
     $tmp = $this->_reader->readUInt16BE();
     $this->_radioReplayGain = array('name' => Zend_Bit_Twiddling::getValue($tmp, 0, 2), 'originator' => Zend_Bit_Twiddling::getValue($tmp, 3, 5), 'absoluteGainAdjustment' => Zend_Bit_Twiddling::getValue($tmp, 7, 15) / 10);
     $tmp = $this->_reader->readUInt16BE();
     $this->_audiophileReplayGain = array('name' => Zend_Bit_Twiddling::getValue($tmp, 0, 2), 'originator' => Zend_Bit_Twiddling::getValue($tmp, 3, 5), 'absoluteGainAdjustment' => Zend_Bit_Twiddling::getValue($tmp, 7, 15) / 10);
     $tmp = $this->_reader->readUInt8();
     $this->_encodingFlags = Zend_Bit_Twiddling::getValue($tmp, 4, 8);
     $this->_athType = Zend_Bit_Twiddling::getValue($tmp, 0, 3);
     $this->_bitrate = $this->_reader->readUInt8();
     $tmp = $this->_reader->readUInt32BE();
     // Encoder delay fields
     $this->_encoderDelaySamples = Zend_Bit_Twiddling::getValue($tmp, 20, 31);
     $this->_paddedSamples = Zend_Bit_Twiddling::getValue($tmp, 8, 19);
     // Misc field
     $this->_sourceSampleFrequency = Zend_Bit_Twiddling::getValue($tmp, 6, 7);
     $this->_unwiseSettingsUsed = Zend_Bit_Twiddling::testBit($tmp, 5);
     $this->_mode = Zend_Bit_Twiddling::getValue($tmp, 2, 4);
     $this->_noiseShaping = Zend_Bit_Twiddling::getValue($tmp, 0, 1);
     $this->_mp3Gain = pow(2, $this->_reader->readInt8() / 4);
     $tmp = $this->_reader->readUInt16BE();
     $this->_surroundInfo = Zend_Bit_Twiddling::getValue($tmp, 11, 14);
     $this->_presetUsed = Zend_Bit_Twiddling::getValue($tmp, 0, 10);
     $this->_musicLength = $this->_reader->readUInt32BE();
     $this->_musicCrc = $this->_reader->readUInt16BE();
     $this->_crc = $this->_reader->readUInt16BE();
 }