diff e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.au.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.au.php	Mon Feb 22 08:02:39 2010 -0500
     1.3 @@ -0,0 +1,184 @@
     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.au.php                                                  |
    1.21 +// | module for analyzing AU files                                        |
    1.22 +// | dependencies: NONE                                                   |
    1.23 +// +----------------------------------------------------------------------+
    1.24 +//
    1.25 +// $Id: module.audio.au.php,v 1.2 2006/11/02 10:48:01 ah Exp $
    1.26 +
    1.27 +        
    1.28 +        
    1.29 +class getid3_au 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 +        $au_header  = fread($getid3->fp, 8);
    1.38 +
    1.39 +        // Magic bytes: .snd
    1.40 +
    1.41 +        $getid3->info['au'] = array ();
    1.42 +        $info_au = &$getid3->info['au'];
    1.43 +
    1.44 +        $getid3->info['fileformat']            = 'au';
    1.45 +        $getid3->info['audio']['dataformat']   = 'au';
    1.46 +        $getid3->info['audio']['bitrate_mode'] = 'cbr';
    1.47 +        $info_au['encoding']                   = 'ISO-8859-1';
    1.48 +
    1.49 +        $info_au['header_length']   = getid3_lib::BigEndian2Int(substr($au_header,  4, 4));
    1.50 +        $au_header .= fread($getid3->fp, $info_au['header_length'] - 8);
    1.51 +        $getid3->info['avdataoffset'] += $info_au['header_length'];
    1.52 +
    1.53 +        getid3_lib::ReadSequence('BigEndian2Int', $info_au, $au_header, 8,  
    1.54 +            array (
    1.55 +                'data_size'     => 4,
    1.56 +                'data_format_id'=> 4,
    1.57 +                'sample_rate'   => 4,
    1.58 +                'channels'      => 4
    1.59 +            )
    1.60 +        );
    1.61 +        $info_au['comments']['comment'][] = trim(substr($au_header, 24));
    1.62 +
    1.63 +        $info_au['data_format']          = getid3_au::AUdataFormatNameLookup($info_au['data_format_id']);
    1.64 +        $info_au['used_bits_per_sample'] = getid3_au::AUdataFormatUsedBitsPerSampleLookup($info_au['data_format_id']);
    1.65 +        if ($info_au['bits_per_sample']  = getid3_au::AUdataFormatBitsPerSampleLookup($info_au['data_format_id'])) {
    1.66 +            $getid3->info['audio']['bits_per_sample'] = $info_au['bits_per_sample'];
    1.67 +        } else {
    1.68 +            unset($info_au['bits_per_sample']);
    1.69 +        }
    1.70 +
    1.71 +        $getid3->info['audio']['sample_rate'] = $info_au['sample_rate'];
    1.72 +        $getid3->info['audio']['channels']    = $info_au['channels'];
    1.73 +
    1.74 +        if (($getid3->info['avdataoffset'] + $info_au['data_size']) > $getid3->info['avdataend']) {
    1.75 +            $getid3->warning('Possible truncated file - expecting "'.$info_au['data_size'].'" bytes of audio data, only found '.($getid3->info['avdataend'] - $getid3->info['avdataoffset']).' bytes"');
    1.76 +        }
    1.77 +
    1.78 +        $getid3->info['playtime_seconds'] = $info_au['data_size'] / ($info_au['sample_rate'] * $info_au['channels'] * ($info_au['used_bits_per_sample'] / 8));
    1.79 +        $getid3->info['audio']['bitrate'] = ($info_au['data_size'] * 8) / $getid3->info['playtime_seconds'];
    1.80 +
    1.81 +        return true;
    1.82 +    }
    1.83 +
    1.84 +
    1.85 +
    1.86 +    public static function AUdataFormatNameLookup($id) {
    1.87 +        
    1.88 +        static $lookup = array (
    1.89 +            0  => 'unspecified format',
    1.90 +            1  => '8-bit mu-law',
    1.91 +            2  => '8-bit linear',
    1.92 +            3  => '16-bit linear',
    1.93 +            4  => '24-bit linear',
    1.94 +            5  => '32-bit linear',
    1.95 +            6  => 'floating-point',
    1.96 +            7  => 'double-precision float',
    1.97 +            8  => 'fragmented sampled data',
    1.98 +            9  => 'SUN_FORMAT_NESTED',
    1.99 +            10 => 'DSP program',
   1.100 +            11 => '8-bit fixed-point',
   1.101 +            12 => '16-bit fixed-point',
   1.102 +            13 => '24-bit fixed-point',
   1.103 +            14 => '32-bit fixed-point',
   1.104 +
   1.105 +            16 => 'non-audio display data',
   1.106 +            17 => 'SND_FORMAT_MULAW_SQUELCH',
   1.107 +            18 => '16-bit linear with emphasis',
   1.108 +            19 => '16-bit linear with compression',
   1.109 +            20 => '16-bit linear with emphasis + compression',
   1.110 +            21 => 'Music Kit DSP commands',
   1.111 +            22 => 'SND_FORMAT_DSP_COMMANDS_SAMPLES',
   1.112 +            23 => 'CCITT g.721 4-bit ADPCM',
   1.113 +            24 => 'CCITT g.722 ADPCM',
   1.114 +            25 => 'CCITT g.723 3-bit ADPCM',
   1.115 +            26 => 'CCITT g.723 5-bit ADPCM',
   1.116 +            27 => 'A-Law 8-bit'
   1.117 +        );
   1.118 +        
   1.119 +        return (isset($lookup[$id]) ? $lookup[$id] : false);
   1.120 +    }
   1.121 +
   1.122 +
   1.123 +
   1.124 +    public static function AUdataFormatBitsPerSampleLookup($id) {
   1.125 +        
   1.126 +        static $lookup = array (
   1.127 +            1  => 8,
   1.128 +            2  => 8,
   1.129 +            3  => 16,
   1.130 +            4  => 24,
   1.131 +            5  => 32,
   1.132 +            6  => 32,
   1.133 +            7  => 64,
   1.134 +
   1.135 +            11 => 8,
   1.136 +            12 => 16,
   1.137 +            13 => 24,
   1.138 +            14 => 32,
   1.139 +
   1.140 +            18 => 16,
   1.141 +            19 => 16,
   1.142 +            20 => 16,
   1.143 +
   1.144 +            23 => 16,
   1.145 +
   1.146 +            25 => 16,
   1.147 +            26 => 16,
   1.148 +            27 => 8
   1.149 +        );
   1.150 +        return (isset($lookup[$id]) ? $lookup[$id] : false);
   1.151 +    }
   1.152 +
   1.153 +
   1.154 +
   1.155 +    public static function AUdataFormatUsedBitsPerSampleLookup($id) {
   1.156 +        
   1.157 +        static $lookup = array (
   1.158 +            1  => 8,
   1.159 +            2  => 8,
   1.160 +            3  => 16,
   1.161 +            4  => 24,
   1.162 +            5  => 32,
   1.163 +            6  => 32,
   1.164 +            7  => 64,
   1.165 +
   1.166 +            11 => 8,
   1.167 +            12 => 16,
   1.168 +            13 => 24,
   1.169 +            14 => 32,
   1.170 +
   1.171 +            18 => 16,
   1.172 +            19 => 16,
   1.173 +            20 => 16,
   1.174 +
   1.175 +            23 => 4,
   1.176 +
   1.177 +            25 => 3,
   1.178 +            26 => 5,
   1.179 +            27 => 8,
   1.180 +        );
   1.181 +        return (isset($lookup[$id]) ? $lookup[$id] : false);
   1.182 +    }
   1.183 +
   1.184 +}
   1.185 +
   1.186 +
   1.187 +?>
   1.188 \ No newline at end of file