annotate e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.au.php @ 18:903b91a97990 judyates

updated site to use google analytics
author Robert McIntyre <rlm@mit.edu>
date Mon, 11 Jul 2011 03:06:13 -0400
parents 3f6b44aa6b35
children
rev   line source
rlm@3 1 <?php
rlm@3 2 // +----------------------------------------------------------------------+
rlm@3 3 // | PHP version 5 |
rlm@3 4 // +----------------------------------------------------------------------+
rlm@3 5 // | Copyright (c) 2002-2006 James Heinrich, Allan Hansen |
rlm@3 6 // +----------------------------------------------------------------------+
rlm@3 7 // | This source file is subject to version 2 of the GPL license, |
rlm@3 8 // | that is bundled with this package in the file license.txt and is |
rlm@3 9 // | available through the world-wide-web at the following url: |
rlm@3 10 // | http://www.gnu.org/copyleft/gpl.html |
rlm@3 11 // +----------------------------------------------------------------------+
rlm@3 12 // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org |
rlm@3 13 // +----------------------------------------------------------------------+
rlm@3 14 // | Authors: James Heinrich <infoØgetid3*org> |
rlm@3 15 // | Allan Hansen <ahØartemis*dk> |
rlm@3 16 // +----------------------------------------------------------------------+
rlm@3 17 // | module.audio.au.php |
rlm@3 18 // | module for analyzing AU files |
rlm@3 19 // | dependencies: NONE |
rlm@3 20 // +----------------------------------------------------------------------+
rlm@3 21 //
rlm@3 22 // $Id: module.audio.au.php,v 1.2 2006/11/02 10:48:01 ah Exp $
rlm@3 23
rlm@3 24
rlm@3 25
rlm@3 26 class getid3_au extends getid3_handler
rlm@3 27 {
rlm@3 28
rlm@3 29 public function Analyze() {
rlm@3 30
rlm@3 31 $getid3 = $this->getid3;
rlm@3 32
rlm@3 33 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
rlm@3 34 $au_header = fread($getid3->fp, 8);
rlm@3 35
rlm@3 36 // Magic bytes: .snd
rlm@3 37
rlm@3 38 $getid3->info['au'] = array ();
rlm@3 39 $info_au = &$getid3->info['au'];
rlm@3 40
rlm@3 41 $getid3->info['fileformat'] = 'au';
rlm@3 42 $getid3->info['audio']['dataformat'] = 'au';
rlm@3 43 $getid3->info['audio']['bitrate_mode'] = 'cbr';
rlm@3 44 $info_au['encoding'] = 'ISO-8859-1';
rlm@3 45
rlm@3 46 $info_au['header_length'] = getid3_lib::BigEndian2Int(substr($au_header, 4, 4));
rlm@3 47 $au_header .= fread($getid3->fp, $info_au['header_length'] - 8);
rlm@3 48 $getid3->info['avdataoffset'] += $info_au['header_length'];
rlm@3 49
rlm@3 50 getid3_lib::ReadSequence('BigEndian2Int', $info_au, $au_header, 8,
rlm@3 51 array (
rlm@3 52 'data_size' => 4,
rlm@3 53 'data_format_id'=> 4,
rlm@3 54 'sample_rate' => 4,
rlm@3 55 'channels' => 4
rlm@3 56 )
rlm@3 57 );
rlm@3 58 $info_au['comments']['comment'][] = trim(substr($au_header, 24));
rlm@3 59
rlm@3 60 $info_au['data_format'] = getid3_au::AUdataFormatNameLookup($info_au['data_format_id']);
rlm@3 61 $info_au['used_bits_per_sample'] = getid3_au::AUdataFormatUsedBitsPerSampleLookup($info_au['data_format_id']);
rlm@3 62 if ($info_au['bits_per_sample'] = getid3_au::AUdataFormatBitsPerSampleLookup($info_au['data_format_id'])) {
rlm@3 63 $getid3->info['audio']['bits_per_sample'] = $info_au['bits_per_sample'];
rlm@3 64 } else {
rlm@3 65 unset($info_au['bits_per_sample']);
rlm@3 66 }
rlm@3 67
rlm@3 68 $getid3->info['audio']['sample_rate'] = $info_au['sample_rate'];
rlm@3 69 $getid3->info['audio']['channels'] = $info_au['channels'];
rlm@3 70
rlm@3 71 if (($getid3->info['avdataoffset'] + $info_au['data_size']) > $getid3->info['avdataend']) {
rlm@3 72 $getid3->warning('Possible truncated file - expecting "'.$info_au['data_size'].'" bytes of audio data, only found '.($getid3->info['avdataend'] - $getid3->info['avdataoffset']).' bytes"');
rlm@3 73 }
rlm@3 74
rlm@3 75 $getid3->info['playtime_seconds'] = $info_au['data_size'] / ($info_au['sample_rate'] * $info_au['channels'] * ($info_au['used_bits_per_sample'] / 8));
rlm@3 76 $getid3->info['audio']['bitrate'] = ($info_au['data_size'] * 8) / $getid3->info['playtime_seconds'];
rlm@3 77
rlm@3 78 return true;
rlm@3 79 }
rlm@3 80
rlm@3 81
rlm@3 82
rlm@3 83 public static function AUdataFormatNameLookup($id) {
rlm@3 84
rlm@3 85 static $lookup = array (
rlm@3 86 0 => 'unspecified format',
rlm@3 87 1 => '8-bit mu-law',
rlm@3 88 2 => '8-bit linear',
rlm@3 89 3 => '16-bit linear',
rlm@3 90 4 => '24-bit linear',
rlm@3 91 5 => '32-bit linear',
rlm@3 92 6 => 'floating-point',
rlm@3 93 7 => 'double-precision float',
rlm@3 94 8 => 'fragmented sampled data',
rlm@3 95 9 => 'SUN_FORMAT_NESTED',
rlm@3 96 10 => 'DSP program',
rlm@3 97 11 => '8-bit fixed-point',
rlm@3 98 12 => '16-bit fixed-point',
rlm@3 99 13 => '24-bit fixed-point',
rlm@3 100 14 => '32-bit fixed-point',
rlm@3 101
rlm@3 102 16 => 'non-audio display data',
rlm@3 103 17 => 'SND_FORMAT_MULAW_SQUELCH',
rlm@3 104 18 => '16-bit linear with emphasis',
rlm@3 105 19 => '16-bit linear with compression',
rlm@3 106 20 => '16-bit linear with emphasis + compression',
rlm@3 107 21 => 'Music Kit DSP commands',
rlm@3 108 22 => 'SND_FORMAT_DSP_COMMANDS_SAMPLES',
rlm@3 109 23 => 'CCITT g.721 4-bit ADPCM',
rlm@3 110 24 => 'CCITT g.722 ADPCM',
rlm@3 111 25 => 'CCITT g.723 3-bit ADPCM',
rlm@3 112 26 => 'CCITT g.723 5-bit ADPCM',
rlm@3 113 27 => 'A-Law 8-bit'
rlm@3 114 );
rlm@3 115
rlm@3 116 return (isset($lookup[$id]) ? $lookup[$id] : false);
rlm@3 117 }
rlm@3 118
rlm@3 119
rlm@3 120
rlm@3 121 public static function AUdataFormatBitsPerSampleLookup($id) {
rlm@3 122
rlm@3 123 static $lookup = array (
rlm@3 124 1 => 8,
rlm@3 125 2 => 8,
rlm@3 126 3 => 16,
rlm@3 127 4 => 24,
rlm@3 128 5 => 32,
rlm@3 129 6 => 32,
rlm@3 130 7 => 64,
rlm@3 131
rlm@3 132 11 => 8,
rlm@3 133 12 => 16,
rlm@3 134 13 => 24,
rlm@3 135 14 => 32,
rlm@3 136
rlm@3 137 18 => 16,
rlm@3 138 19 => 16,
rlm@3 139 20 => 16,
rlm@3 140
rlm@3 141 23 => 16,
rlm@3 142
rlm@3 143 25 => 16,
rlm@3 144 26 => 16,
rlm@3 145 27 => 8
rlm@3 146 );
rlm@3 147 return (isset($lookup[$id]) ? $lookup[$id] : false);
rlm@3 148 }
rlm@3 149
rlm@3 150
rlm@3 151
rlm@3 152 public static function AUdataFormatUsedBitsPerSampleLookup($id) {
rlm@3 153
rlm@3 154 static $lookup = array (
rlm@3 155 1 => 8,
rlm@3 156 2 => 8,
rlm@3 157 3 => 16,
rlm@3 158 4 => 24,
rlm@3 159 5 => 32,
rlm@3 160 6 => 32,
rlm@3 161 7 => 64,
rlm@3 162
rlm@3 163 11 => 8,
rlm@3 164 12 => 16,
rlm@3 165 13 => 24,
rlm@3 166 14 => 32,
rlm@3 167
rlm@3 168 18 => 16,
rlm@3 169 19 => 16,
rlm@3 170 20 => 16,
rlm@3 171
rlm@3 172 23 => 4,
rlm@3 173
rlm@3 174 25 => 3,
rlm@3 175 26 => 5,
rlm@3 176 27 => 8,
rlm@3 177 );
rlm@3 178 return (isset($lookup[$id]) ? $lookup[$id] : false);
rlm@3 179 }
rlm@3 180
rlm@3 181 }
rlm@3 182
rlm@3 183
rlm@3 184 ?>