Improved code and comments: add ID3v1 write support, add unit tests

git-svn-id: http://php-reader.googlecode.com/svn/trunk@39 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2008-03-26 17:27:22 +00:00
parent 3914cfdacc
commit 1182f0e0ff
107 changed files with 2107 additions and 963 deletions

View File

@@ -2,6 +2,8 @@
/**
* PHP Reader Library
*
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@@ -10,7 +12,7 @@
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the BEHR Software Systems nor the names of its
* - Neither the name of the project workgroup nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
@@ -28,9 +30,10 @@
*
* @package php-reader
* @subpackage ID3
* @copyright Copyright (c) 2008 BEHR Software Systems
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Id$
* @since ID3v2.4.0
*/
/**#@+ @ignore */
@@ -53,10 +56,11 @@ require_once("ID3/Frame.php");
*
* @package php-reader
* @subpackage ID3
* @author Sven Vollbehr <sven.vollbehr@behrss.eu>
* @copyright Copyright (c) 2008 BEHR Software Systems
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
* @since ID3v2.4.0
*/
final class ID3_Frame_RVA2 extends ID3_Frame
{
@@ -98,24 +102,24 @@ final class ID3_Frame_RVA2 extends ID3_Frame
$this->_adjustments[$i] = array
("channelType" => substr($this->_data, $j++, 1),
"volumeAdjustment" =>
Transform::getInt16BE(substr($this->_data, $j++, 2)));
Transform::fromInt16BE(substr($this->_data, $j++, 2)));
$bitsInPeak = ord(substr($this->_data, (++$j)++, 1));
$bytesInPeak = $bitsInPeak > 0 ? ceil($bitsInPeak / 8) : 0;
switch ($bytesInPeak) {
case 32:
case 24:
$this->_adjustments[$i]["peakVolume"] =
Transform::getInt32BE(substr($this->_data, $j, $bytesInPeak));
Transform::fromInt32BE(substr($this->_data, $j, $bytesInPeak));
$j += $bytesInPeak;
break;
case 16:
$this->_adjustments[$i]["peakVolume"] =
Transform::getInt16BE(substr($this->_data, $j, $bytesInPeak));
Transform::fromInt16BE(substr($this->_data, $j, $bytesInPeak));
$j += $bytesInPeak;
break;
case 8:
$this->_adjustments[$i]["peakVolume"] =
Transform::getInt8(substr($this->_data, $j, $bytesInPeak));
Transform::fromInt8(substr($this->_data, $j, $bytesInPeak));
$j += $bytesInPeak;
}
}