diff e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.rkau.php @ 3:3f6b44aa6b35 judyates

[svn r4] added ability to buy stuff, from a Prints page, but it doesn't work well with the css, and it also has not been fitted into the perl make system.
author rlm
date Mon, 22 Feb 2010 08:02:39 -0500
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.rkau.php	Mon Feb 22 08:02:39 2010 -0500
     1.3 @@ -0,0 +1,101 @@
     1.4 +<?php
     1.5 +// +----------------------------------------------------------------------+
     1.6 +// | PHP version 5                                                        |
     1.7 +// +----------------------------------------------------------------------+
     1.8 +// | Copyright (c) 2002-2006 James Heinrich, Allan Hansen                 |
     1.9 +// +----------------------------------------------------------------------+
    1.10 +// | This source file is subject to version 2 of the GPL license,         |
    1.11 +// | that is bundled with this package in the file license.txt and is     |
    1.12 +// | available through the world-wide-web at the following url:           |
    1.13 +// | http://www.gnu.org/copyleft/gpl.html                                 |
    1.14 +// +----------------------------------------------------------------------+
    1.15 +// | getID3() - http://getid3.sourceforge.net or http://www.getid3.org    |
    1.16 +// +----------------------------------------------------------------------+
    1.17 +// | Authors: James Heinrich <infoØgetid3*org>                            |
    1.18 +// |          Allan Hansen <ahØartemis*dk>                                |
    1.19 +// +----------------------------------------------------------------------+
    1.20 +// | module.audio.rkau.php                                                |
    1.21 +// | Module for analyzing RKAU Audio files                                |
    1.22 +// | dependencies: NONE                                                   |
    1.23 +// +----------------------------------------------------------------------+
    1.24 +//
    1.25 +// $Id: module.audio.rkau.php,v 1.2 2006/11/02 10:48:01 ah Exp $
    1.26 +
    1.27 +        
    1.28 +        
    1.29 +class getid3_rkau extends getid3_handler
    1.30 +{
    1.31 +
    1.32 +    public function Analyze() {
    1.33 +
    1.34 +        $getid3 = $this->getid3;
    1.35 +        
    1.36 +        fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
    1.37 +        $rkau_header = fread($getid3->fp, 20);
    1.38 +        
    1.39 +        // Magic bytes 'RKA'
    1.40 +            
    1.41 +        $getid3->info['fileformat']            = 'rkau';
    1.42 +        $getid3->info['audio']['dataformat']   = 'rkau';
    1.43 +        $getid3->info['audio']['bitrate_mode'] = 'vbr';
    1.44 +        
    1.45 +        // Shortcut
    1.46 +        $getid3->info['rkau'] = array ();
    1.47 +        $info_rkau            = &$getid3->info['rkau'];
    1.48 +        
    1.49 +        $info_rkau['raw']['version']   = getid3_lib::LittleEndian2Int(substr($rkau_header, 3, 1));
    1.50 +        $info_rkau['version']          = '1.'.str_pad($info_rkau['raw']['version'] & 0x0F, 2, '0', STR_PAD_LEFT);
    1.51 +        if (($info_rkau['version'] > 1.07) || ($info_rkau['version'] < 1.06)) {
    1.52 +            throw new getid3_exception('This version of getID3() can only parse RKAU files v1.06 and 1.07 (this file is v'.$info_rkau['version'].')');
    1.53 +        }
    1.54 +
    1.55 +        getid3_lib::ReadSequence('LittleEndian2Int', $info_rkau, $rkau_header,  4,
    1.56 +            array (
    1.57 +                'source_bytes'     => 4,
    1.58 +                'sample_rate'      => 4,
    1.59 +                'channels'         => 1,
    1.60 +                'bits_per_sample'  => 1
    1.61 +            )
    1.62 +        );
    1.63 +
    1.64 +        $info_rkau['raw']['quality']   = getid3_lib::LittleEndian2Int(substr($rkau_header, 14, 1));
    1.65 +        
    1.66 +        $quality =  $info_rkau['raw']['quality'] & 0x0F;
    1.67 +
    1.68 +        $info_rkau['lossless']          = (($quality == 0) ? true : false);
    1.69 +        $info_rkau['compression_level'] = (($info_rkau['raw']['quality'] & 0xF0) >> 4) + 1;
    1.70 +        if (!$info_rkau['lossless']) {
    1.71 +            $info_rkau['quality_setting'] = $quality;
    1.72 +        }
    1.73 +        
    1.74 +        $info_rkau['raw']['flags']            = getid3_lib::LittleEndian2Int(substr($rkau_header, 15, 1));
    1.75 +        $info_rkau['flags']['joint_stereo']   = (bool)(!($info_rkau['raw']['flags'] & 0x01));
    1.76 +        $info_rkau['flags']['streaming']      =  (bool) ($info_rkau['raw']['flags'] & 0x02);
    1.77 +        $info_rkau['flags']['vrq_lossy_mode'] =  (bool) ($info_rkau['raw']['flags'] & 0x04);
    1.78 +
    1.79 +        if ($info_rkau['flags']['streaming']) {
    1.80 +            $getid3->info['avdataoffset'] += 20;
    1.81 +            $info_rkau['compressed_bytes']  = getid3_lib::LittleEndian2Int(substr($rkau_header, 16, 4));
    1.82 +        } 
    1.83 +        else {
    1.84 +            $getid3->info['avdataoffset'] += 16;
    1.85 +            $info_rkau['compressed_bytes'] = $getid3->info['avdataend'] - $getid3->info['avdataoffset'] - 1;
    1.86 +        }
    1.87 +        // Note: compressed_bytes does not always equal what appears to be the actual number of compressed bytes,
    1.88 +        // sometimes it's more, sometimes less. No idea why(?)
    1.89 +
    1.90 +        $getid3->info['audio']['lossless']        = $info_rkau['lossless'];
    1.91 +        $getid3->info['audio']['channels']        = $info_rkau['channels'];
    1.92 +        $getid3->info['audio']['bits_per_sample'] = $info_rkau['bits_per_sample'];
    1.93 +        $getid3->info['audio']['sample_rate']     = $info_rkau['sample_rate'];
    1.94 +
    1.95 +        $getid3->info['playtime_seconds']         = $info_rkau['source_bytes'] / ($info_rkau['sample_rate'] * $info_rkau['channels'] * ($info_rkau['bits_per_sample'] / 8));
    1.96 +        $getid3->info['audio']['bitrate']         = ($info_rkau['compressed_bytes'] * 8) / $getid3->info['playtime_seconds'];
    1.97 +
    1.98 +        return true;
    1.99 +
   1.100 +    }
   1.101 +
   1.102 +}
   1.103 +
   1.104 +?>
   1.105 \ No newline at end of file