annotate e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.wavpack.php @ 8:1b77e8657088 judyates

[svn r9] saving for transference to cd
author rlm
date Fri, 19 Mar 2010 07:17:36 -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.wavpack.php |
rlm@3 18 // | module for analyzing WavPack v4.0+ Audio files |
rlm@3 19 // | dependencies: audio-video.riff |
rlm@3 20 // +----------------------------------------------------------------------+
rlm@3 21 //
rlm@3 22 // $Id: module.audio.wavpack.php,v 1.2 2006/11/02 10:48:02 ah Exp $
rlm@3 23
rlm@3 24
rlm@3 25 class getid3_wavpack extends getid3_handler
rlm@3 26 {
rlm@3 27
rlm@3 28 public function Analyze() {
rlm@3 29
rlm@3 30 $getid3 = $this->getid3;
rlm@3 31
rlm@3 32 $getid3->include_module('audio-video.riff');
rlm@3 33
rlm@3 34 $getid3->info['wavpack'] = array ();
rlm@3 35 $info_wavpack = &$getid3->info['wavpack'];
rlm@3 36
rlm@3 37 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
rlm@3 38
rlm@3 39 while (true) {
rlm@3 40
rlm@3 41 $wavpack_header = fread($getid3->fp, 32);
rlm@3 42
rlm@3 43 if (ftell($getid3->fp) >= $getid3->info['avdataend']) {
rlm@3 44 break;
rlm@3 45 } elseif (feof($getid3->fp)) {
rlm@3 46 break;
rlm@3 47 } elseif (
rlm@3 48 (@$info_wavpack_blockheader['total_samples'] > 0) &&
rlm@3 49 (@$info_wavpack_blockheader['block_samples'] > 0) &&
rlm@3 50 (!isset($info_wavpack['riff_trailer_size']) || ($info_wavpack['riff_trailer_size'] <= 0)) &&
rlm@3 51 ((@$info_wavpack['config_flags']['md5_checksum'] === false) || !empty($getid3->info['md5_data_source']))) {
rlm@3 52 break;
rlm@3 53 }
rlm@3 54
rlm@3 55 $block_header_offset = ftell($getid3->fp) - 32;
rlm@3 56 $block_header_magic = substr($wavpack_header, 0, 4);
rlm@3 57 $block_header_size = getid3_lib::LittleEndian2Int(substr($wavpack_header, 4, 4));
rlm@3 58
rlm@3 59 if ($block_header_magic != 'wvpk') {
rlm@3 60 throw new getid3_exception('Expecting "wvpk" at offset '.$block_header_offset.', found "'.$block_header_magic.'"');
rlm@3 61 }
rlm@3 62
rlm@3 63 if ((@$info_wavpack_blockheader['block_samples'] <= 0) || (@$info_wavpack_blockheader['total_samples'] <= 0)) {
rlm@3 64
rlm@3 65 // Also, it is possible that the first block might not have
rlm@3 66 // any samples (block_samples == 0) and in this case you should skip blocks
rlm@3 67 // until you find one with samples because the other information (like
rlm@3 68 // total_samples) are not guaranteed to be correct until (block_samples > 0)
rlm@3 69
rlm@3 70 // Finally, I have defined a format for files in which the length is not known
rlm@3 71 // (for example when raw files are created using pipes). In these cases
rlm@3 72 // total_samples will be -1 and you must seek to the final block to determine
rlm@3 73 // the total number of samples.
rlm@3 74
rlm@3 75
rlm@3 76 $getid3->info['audio']['dataformat'] = 'wavpack';
rlm@3 77 $getid3->info['fileformat'] = 'wavpack';
rlm@3 78 $getid3->info['audio']['lossless'] = true;
rlm@3 79 $getid3->info['audio']['bitrate_mode'] = 'vbr';
rlm@3 80
rlm@3 81 $info_wavpack['blockheader']['offset'] = $block_header_offset;
rlm@3 82 $info_wavpack['blockheader']['magic'] = $block_header_magic;
rlm@3 83 $info_wavpack['blockheader']['size'] = $block_header_size;
rlm@3 84 $info_wavpack_blockheader = &$info_wavpack['blockheader'];
rlm@3 85
rlm@3 86 if ($info_wavpack_blockheader['size'] >= 0x100000) {
rlm@3 87 throw new getid3_exception('Expecting WavPack block size less than "0x100000", found "'.$info_wavpack_blockheader['size'].'" at offset '.$info_wavpack_blockheader['offset']);
rlm@3 88 }
rlm@3 89
rlm@3 90 $info_wavpack_blockheader['minor_version'] = ord($wavpack_header{8});
rlm@3 91 $info_wavpack_blockheader['major_version'] = ord($wavpack_header{9});
rlm@3 92
rlm@3 93 if (($info_wavpack_blockheader['major_version'] != 4) ||
rlm@3 94 (($info_wavpack_blockheader['minor_version'] < 4) &&
rlm@3 95 ($info_wavpack_blockheader['minor_version'] > 16))) {
rlm@3 96 throw new getid3_exception('Expecting WavPack version between "4.2" and "4.16", found version "'.$info_wavpack_blockheader['major_version'].'.'.$info_wavpack_blockheader['minor_version'].'" at offset '.$info_wavpack_blockheader['offset']);
rlm@3 97 }
rlm@3 98
rlm@3 99 $info_wavpack_blockheader['track_number'] = ord($wavpack_header{10}); // unused
rlm@3 100 $info_wavpack_blockheader['index_number'] = ord($wavpack_header{11}); // unused
rlm@3 101
rlm@3 102 getid3_lib::ReadSequence('LittleEndian2Int', $info_wavpack_blockheader, $wavpack_header, 12,
rlm@3 103 array (
rlm@3 104 'total_samples' => 4,
rlm@3 105 'block_index' => 4,
rlm@3 106 'block_samples' => 4,
rlm@3 107 'flags_raw' => 4,
rlm@3 108 'crc' => 4
rlm@3 109 )
rlm@3 110 );
rlm@3 111
rlm@3 112
rlm@3 113 $info_wavpack_blockheader['flags']['bytes_per_sample'] = 1 + ($info_wavpack_blockheader['flags_raw'] & 0x00000003);
rlm@3 114 $info_wavpack_blockheader['flags']['mono'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000004);
rlm@3 115 $info_wavpack_blockheader['flags']['hybrid'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000008);
rlm@3 116 $info_wavpack_blockheader['flags']['joint_stereo'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000010);
rlm@3 117 $info_wavpack_blockheader['flags']['cross_decorrelation'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000020);
rlm@3 118 $info_wavpack_blockheader['flags']['hybrid_noiseshape'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000040);
rlm@3 119 $info_wavpack_blockheader['flags']['ieee_32bit_float'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000080);
rlm@3 120 $info_wavpack_blockheader['flags']['int_32bit'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000100);
rlm@3 121 $info_wavpack_blockheader['flags']['hybrid_bitrate_noise'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000200);
rlm@3 122 $info_wavpack_blockheader['flags']['hybrid_balance_noise'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000400);
rlm@3 123 $info_wavpack_blockheader['flags']['multichannel_initial'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000800);
rlm@3 124 $info_wavpack_blockheader['flags']['multichannel_final'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00001000);
rlm@3 125
rlm@3 126 $getid3->info['audio']['lossless'] = !$info_wavpack_blockheader['flags']['hybrid'];
rlm@3 127 }
rlm@3 128
rlm@3 129
rlm@3 130 while (!feof($getid3->fp) && (ftell($getid3->fp) < ($block_header_offset + $block_header_size + 8))) {
rlm@3 131
rlm@3 132 $metablock = array('offset'=>ftell($getid3->fp));
rlm@3 133 $metablockheader = fread($getid3->fp, 2);
rlm@3 134 if (feof($getid3->fp)) {
rlm@3 135 break;
rlm@3 136 }
rlm@3 137 $metablock['id'] = ord($metablockheader{0});
rlm@3 138 $metablock['function_id'] = ($metablock['id'] & 0x3F);
rlm@3 139 $metablock['function_name'] = $this->WavPackMetablockNameLookup($metablock['function_id']);
rlm@3 140
rlm@3 141 // The 0x20 bit in the id of the meta subblocks (which is defined as
rlm@3 142 // ID_OPTIONAL_DATA) is a permanent part of the id. The idea is that
rlm@3 143 // if a decoder encounters an id that it does not know about, it uses
rlm@3 144 // that "ID_OPTIONAL_DATA" flag to determine what to do. If it is set
rlm@3 145 // then the decoder simply ignores the metadata, but if it is zero
rlm@3 146 // then the decoder should quit because it means that an understanding
rlm@3 147 // of the metadata is required to correctly decode the audio.
rlm@3 148
rlm@3 149 $metablock['non_decoder'] = (bool) ($metablock['id'] & 0x20);
rlm@3 150 $metablock['padded_data'] = (bool) ($metablock['id'] & 0x40);
rlm@3 151 $metablock['large_block'] = (bool) ($metablock['id'] & 0x80);
rlm@3 152 if ($metablock['large_block']) {
rlm@3 153 $metablockheader .= fread($getid3->fp, 2);
rlm@3 154 }
rlm@3 155 $metablock['size'] = getid3_lib::LittleEndian2Int(substr($metablockheader, 1)) * 2; // size is stored in words
rlm@3 156 $metablock['data'] = null;
rlm@3 157
rlm@3 158 if ($metablock['size'] > 0) {
rlm@3 159
rlm@3 160 switch ($metablock['function_id']) {
rlm@3 161
rlm@3 162 case 0x21: // ID_RIFF_HEADER
rlm@3 163 case 0x22: // ID_RIFF_TRAILER
rlm@3 164 case 0x23: // ID_REPLAY_GAIN
rlm@3 165 case 0x24: // ID_CUESHEET
rlm@3 166 case 0x25: // ID_CONFIG_BLOCK
rlm@3 167 case 0x26: // ID_MD5_CHECKSUM
rlm@3 168 $metablock['data'] = fread($getid3->fp, $metablock['size']);
rlm@3 169
rlm@3 170 if ($metablock['padded_data']) {
rlm@3 171 // padded to the nearest even byte
rlm@3 172 $metablock['size']--;
rlm@3 173 $metablock['data'] = substr($metablock['data'], 0, -1);
rlm@3 174 }
rlm@3 175 break;
rlm@3 176
rlm@3 177
rlm@3 178 case 0x00: // ID_DUMMY
rlm@3 179 case 0x01: // ID_ENCODER_INFO
rlm@3 180 case 0x02: // ID_DECORR_TERMS
rlm@3 181 case 0x03: // ID_DECORR_WEIGHTS
rlm@3 182 case 0x04: // ID_DECORR_SAMPLES
rlm@3 183 case 0x05: // ID_ENTROPY_VARS
rlm@3 184 case 0x06: // ID_HYBRID_PROFILE
rlm@3 185 case 0x07: // ID_SHAPING_WEIGHTS
rlm@3 186 case 0x08: // ID_FLOAT_INFO
rlm@3 187 case 0x09: // ID_INT32_INFO
rlm@3 188 case 0x0A: // ID_WV_BITSTREAM
rlm@3 189 case 0x0B: // ID_WVC_BITSTREAM
rlm@3 190 case 0x0C: // ID_WVX_BITSTREAM
rlm@3 191 case 0x0D: // ID_CHANNEL_INFO
rlm@3 192 fseek($getid3->fp, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
rlm@3 193 break;
rlm@3 194
rlm@3 195
rlm@3 196 default:
rlm@3 197 $getid3->warning('Unexpected metablock type "0x'.str_pad(dechex($metablock['function_id']), 2, '0', STR_PAD_LEFT).'" at offset '.$metablock['offset']);
rlm@3 198 fseek($getid3->fp, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
rlm@3 199 break;
rlm@3 200 }
rlm@3 201
rlm@3 202
rlm@3 203 switch ($metablock['function_id']) {
rlm@3 204
rlm@3 205 case 0x21: // ID_RIFF_HEADER
rlm@3 206
rlm@3 207 $original_wav_filesize = getid3_lib::LittleEndian2Int(substr($metablock['data'], 4, 4));
rlm@3 208
rlm@3 209 // Clone getid3
rlm@3 210 $clone = clone $getid3;
rlm@3 211
rlm@3 212 // Analyze clone by string
rlm@3 213 $riff = new getid3_riff($clone);
rlm@3 214 $riff->AnalyzeString($metablock['data']);
rlm@3 215
rlm@3 216 // Import from clone and destroy
rlm@3 217 $metablock['riff'] = $clone->info['riff'];
rlm@3 218 $getid3->warnings($clone->warnings());
rlm@3 219 unset($clone);
rlm@3 220
rlm@3 221 // Save RIFF header - we may need it later for RIFF footer parsing
rlm@3 222 $this->riff_header = $metablock['data'];
rlm@3 223
rlm@3 224 $metablock['riff']['original_filesize'] = $original_wav_filesize;
rlm@3 225 $info_wavpack['riff_trailer_size'] = $original_wav_filesize - $metablock['riff']['WAVE']['data'][0]['size'] - $metablock['riff']['header_size'];
rlm@3 226
rlm@3 227 $getid3->info['audio']['sample_rate'] = $metablock['riff']['raw']['fmt ']['nSamplesPerSec'];
rlm@3 228 $getid3->info['playtime_seconds'] = $info_wavpack_blockheader['total_samples'] / $getid3->info['audio']['sample_rate'];
rlm@3 229
rlm@3 230 // Safe RIFF header in case there's a RIFF footer later
rlm@3 231 $metablock_riff_header = $metablock['data'];
rlm@3 232 break;
rlm@3 233
rlm@3 234
rlm@3 235 case 0x22: // ID_RIFF_TRAILER
rlm@3 236
rlm@3 237 $metablock_riff_footer = $metablock_riff_header.$metablock['data'];
rlm@3 238
rlm@3 239 $start_offset = $metablock['offset'] + ($metablock['large_block'] ? 4 : 2);
rlm@3 240
rlm@3 241 $ftell_old = ftell($getid3->fp);
rlm@3 242
rlm@3 243 // Clone getid3
rlm@3 244 $clone = clone $getid3;
rlm@3 245
rlm@3 246 // Call public method that really should be private
rlm@3 247 $riff = new getid3_riff($clone);
rlm@3 248 $metablock['riff'] = $riff->ParseRIFF($start_offset, $start_offset + $metablock['size']);
rlm@3 249 unset($clone);
rlm@3 250
rlm@3 251 fseek($getid3->fp, $ftell_old, SEEK_SET);
rlm@3 252
rlm@3 253 if (!empty($metablock['riff']['INFO'])) {
rlm@3 254 getid3_riff::RIFFCommentsParse($metablock['riff']['INFO'], $metablock['comments']);
rlm@3 255 $getid3->info['tags']['riff'] = $metablock['comments'];
rlm@3 256 }
rlm@3 257 break;
rlm@3 258
rlm@3 259
rlm@3 260 case 0x23: // ID_REPLAY_GAIN
rlm@3 261 $getid3->warning('WavPack "Replay Gain" contents not yet handled by getID3() in metablock at offset '.$metablock['offset']);
rlm@3 262 break;
rlm@3 263
rlm@3 264
rlm@3 265 case 0x24: // ID_CUESHEET
rlm@3 266 $getid3->warning('WavPack "Cuesheet" contents not yet handled by getID3() in metablock at offset '.$metablock['offset']);
rlm@3 267 break;
rlm@3 268
rlm@3 269
rlm@3 270 case 0x25: // ID_CONFIG_BLOCK
rlm@3 271 $metablock['flags_raw'] = getid3_lib::LittleEndian2Int(substr($metablock['data'], 0, 3));
rlm@3 272
rlm@3 273 $metablock['flags']['adobe_mode'] = (bool) ($metablock['flags_raw'] & 0x000001); // "adobe" mode for 32-bit floats
rlm@3 274 $metablock['flags']['fast_flag'] = (bool) ($metablock['flags_raw'] & 0x000002); // fast mode
rlm@3 275 $metablock['flags']['very_fast_flag'] = (bool) ($metablock['flags_raw'] & 0x000004); // double fast
rlm@3 276 $metablock['flags']['high_flag'] = (bool) ($metablock['flags_raw'] & 0x000008); // high quality mode
rlm@3 277 $metablock['flags']['very_high_flag'] = (bool) ($metablock['flags_raw'] & 0x000010); // double high (not used yet)
rlm@3 278 $metablock['flags']['bitrate_kbps'] = (bool) ($metablock['flags_raw'] & 0x000020); // bitrate is kbps, not bits / sample
rlm@3 279 $metablock['flags']['auto_shaping'] = (bool) ($metablock['flags_raw'] & 0x000040); // automatic noise shaping
rlm@3 280 $metablock['flags']['shape_override'] = (bool) ($metablock['flags_raw'] & 0x000080); // shaping mode specified
rlm@3 281 $metablock['flags']['joint_override'] = (bool) ($metablock['flags_raw'] & 0x000100); // joint-stereo mode specified
rlm@3 282 $metablock['flags']['copy_time'] = (bool) ($metablock['flags_raw'] & 0x000200); // copy file-time from source
rlm@3 283 $metablock['flags']['create_exe'] = (bool) ($metablock['flags_raw'] & 0x000400); // create executable
rlm@3 284 $metablock['flags']['create_wvc'] = (bool) ($metablock['flags_raw'] & 0x000800); // create correction file
rlm@3 285 $metablock['flags']['optimize_wvc'] = (bool) ($metablock['flags_raw'] & 0x001000); // maximize bybrid compression
rlm@3 286 $metablock['flags']['quality_mode'] = (bool) ($metablock['flags_raw'] & 0x002000); // psychoacoustic quality mode
rlm@3 287 $metablock['flags']['raw_flag'] = (bool) ($metablock['flags_raw'] & 0x004000); // raw mode (not implemented yet)
rlm@3 288 $metablock['flags']['calc_noise'] = (bool) ($metablock['flags_raw'] & 0x008000); // calc noise in hybrid mode
rlm@3 289 $metablock['flags']['lossy_mode'] = (bool) ($metablock['flags_raw'] & 0x010000); // obsolete (for information)
rlm@3 290 $metablock['flags']['extra_mode'] = (bool) ($metablock['flags_raw'] & 0x020000); // extra processing mode
rlm@3 291 $metablock['flags']['skip_wvx'] = (bool) ($metablock['flags_raw'] & 0x040000); // no wvx stream w/ floats & big ints
rlm@3 292 $metablock['flags']['md5_checksum'] = (bool) ($metablock['flags_raw'] & 0x080000); // compute & store MD5 signature
rlm@3 293 $metablock['flags']['quiet_mode'] = (bool) ($metablock['flags_raw'] & 0x100000); // don't report progress %
rlm@3 294
rlm@3 295 $info_wavpack['config_flags'] = $metablock['flags'];
rlm@3 296
rlm@3 297 $getid3->info['audio']['encoder_options'] = trim(
rlm@3 298 ($info_wavpack_blockheader['flags']['hybrid'] ? ' -b???' : '') .
rlm@3 299 ($metablock['flags']['adobe_mode'] ? ' -a' : '') .
rlm@3 300 ($metablock['flags']['optimize_wvc'] ? ' -cc' : '') .
rlm@3 301 ($metablock['flags']['create_exe'] ? ' -e' : '') .
rlm@3 302 ($metablock['flags']['fast_flag'] ? ' -f' : '') .
rlm@3 303 ($metablock['flags']['joint_override'] ? ' -j?' : '') .
rlm@3 304 ($metablock['flags']['high_flag'] ? ' -h' : '') .
rlm@3 305 ($metablock['flags']['md5_checksum'] ? ' -m' : '') .
rlm@3 306 ($metablock['flags']['calc_noise'] ? ' -n' : '') .
rlm@3 307 ($metablock['flags']['shape_override'] ? ' -s?' : '') .
rlm@3 308 ($metablock['flags']['extra_mode'] ? ' -x?' : '')
rlm@3 309 );
rlm@3 310 if (!$getid3->info['audio']['encoder_options']) {
rlm@3 311 unset($getid3->info['audio']['encoder_options']);
rlm@3 312 }
rlm@3 313 break;
rlm@3 314
rlm@3 315
rlm@3 316 case 0x26: // ID_MD5_CHECKSUM
rlm@3 317 if (strlen($metablock['data']) == 16) {
rlm@3 318 $getid3->info['md5_data_source'] = strtolower(getid3_lib::PrintHexBytes($metablock['data'], true, false, false));
rlm@3 319 } else {
rlm@3 320 $getid3->warning('Expecting 16 bytes of WavPack "MD5 Checksum" in metablock at offset '.$metablock['offset'].', but found '.strlen($metablock['data']).' bytes');
rlm@3 321 }
rlm@3 322 break;
rlm@3 323
rlm@3 324
rlm@3 325 case 0x00: // ID_DUMMY
rlm@3 326 case 0x01: // ID_ENCODER_INFO
rlm@3 327 case 0x02: // ID_DECORR_TERMS
rlm@3 328 case 0x03: // ID_DECORR_WEIGHTS
rlm@3 329 case 0x04: // ID_DECORR_SAMPLES
rlm@3 330 case 0x05: // ID_ENTROPY_VARS
rlm@3 331 case 0x06: // ID_HYBRID_PROFILE
rlm@3 332 case 0x07: // ID_SHAPING_WEIGHTS
rlm@3 333 case 0x08: // ID_FLOAT_INFO
rlm@3 334 case 0x09: // ID_INT32_INFO
rlm@3 335 case 0x0A: // ID_WV_BITSTREAM
rlm@3 336 case 0x0B: // ID_WVC_BITSTREAM
rlm@3 337 case 0x0C: // ID_WVX_BITSTREAM
rlm@3 338 case 0x0D: // ID_CHANNEL_INFO
rlm@3 339 unset($metablock);
rlm@3 340 break;
rlm@3 341 }
rlm@3 342
rlm@3 343 }
rlm@3 344
rlm@3 345 if (!empty($metablock)) {
rlm@3 346 $info_wavpack['metablocks'][] = $metablock;
rlm@3 347 }
rlm@3 348
rlm@3 349 }
rlm@3 350
rlm@3 351 }
rlm@3 352
rlm@3 353 $getid3->info['audio']['encoder'] = 'WavPack v'.$info_wavpack_blockheader['major_version'].'.'.str_pad($info_wavpack_blockheader['minor_version'], 2, '0', STR_PAD_LEFT);
rlm@3 354 $getid3->info['audio']['bits_per_sample'] = $info_wavpack_blockheader['flags']['bytes_per_sample'] * 8;
rlm@3 355 $getid3->info['audio']['channels'] = ($info_wavpack_blockheader['flags']['mono'] ? 1 : 2);
rlm@3 356
rlm@3 357 if (@$getid3->info['playtime_seconds']) {
rlm@3 358 $getid3->info['audio']['bitrate'] = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['playtime_seconds'];
rlm@3 359 } else {
rlm@3 360 $getid3->info['audio']['dataformat'] = 'wvc';
rlm@3 361 }
rlm@3 362
rlm@3 363 return true;
rlm@3 364 }
rlm@3 365
rlm@3 366
rlm@3 367
rlm@3 368 public static function WavPackMetablockNameLookup($id) {
rlm@3 369
rlm@3 370 static $lookup = array(
rlm@3 371 0x00 => 'Dummy',
rlm@3 372 0x01 => 'Encoder Info',
rlm@3 373 0x02 => 'Decorrelation Terms',
rlm@3 374 0x03 => 'Decorrelation Weights',
rlm@3 375 0x04 => 'Decorrelation Samples',
rlm@3 376 0x05 => 'Entropy Variables',
rlm@3 377 0x06 => 'Hybrid Profile',
rlm@3 378 0x07 => 'Shaping Weights',
rlm@3 379 0x08 => 'Float Info',
rlm@3 380 0x09 => 'Int32 Info',
rlm@3 381 0x0A => 'WV Bitstream',
rlm@3 382 0x0B => 'WVC Bitstream',
rlm@3 383 0x0C => 'WVX Bitstream',
rlm@3 384 0x0D => 'Channel Info',
rlm@3 385 0x21 => 'RIFF header',
rlm@3 386 0x22 => 'RIFF trailer',
rlm@3 387 0x23 => 'Replay Gain',
rlm@3 388 0x24 => 'Cuesheet',
rlm@3 389 0x25 => 'Config Block',
rlm@3 390 0x26 => 'MD5 Checksum',
rlm@3 391 );
rlm@3 392
rlm@3 393 return (@$lookup[$id]);
rlm@3 394 }
rlm@3 395
rlm@3 396 }
rlm@3 397
rlm@3 398
rlm@3 399 ?>