diff e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.wavpack.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.wavpack.php	Mon Feb 22 08:02:39 2010 -0500
     1.3 @@ -0,0 +1,399 @@
     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.wavpack.php                                             |
    1.21 +// | module for analyzing WavPack v4.0+ Audio files                       |
    1.22 +// | dependencies: audio-video.riff                                       |
    1.23 +// +----------------------------------------------------------------------+
    1.24 +//
    1.25 +// $Id: module.audio.wavpack.php,v 1.2 2006/11/02 10:48:02 ah Exp $
    1.26 +
    1.27 +
    1.28 +class getid3_wavpack extends getid3_handler
    1.29 +{
    1.30 +
    1.31 +    public function Analyze() {
    1.32 +
    1.33 +        $getid3 = $this->getid3;
    1.34 +        
    1.35 +        $getid3->include_module('audio-video.riff');
    1.36 +        
    1.37 +        $getid3->info['wavpack'] = array ();
    1.38 +        $info_wavpack = &$getid3->info['wavpack'];
    1.39 +        
    1.40 +        fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
    1.41 +
    1.42 +        while (true) {
    1.43 +
    1.44 +            $wavpack_header = fread($getid3->fp, 32);
    1.45 +
    1.46 +            if (ftell($getid3->fp) >= $getid3->info['avdataend']) {
    1.47 +                break;
    1.48 +            } elseif (feof($getid3->fp)) {
    1.49 +                break;
    1.50 +            } elseif (
    1.51 +                (@$info_wavpack_blockheader['total_samples'] > 0) &&
    1.52 +                (@$info_wavpack_blockheader['block_samples'] > 0) &&
    1.53 +                (!isset($info_wavpack['riff_trailer_size']) || ($info_wavpack['riff_trailer_size'] <= 0)) &&
    1.54 +                ((@$info_wavpack['config_flags']['md5_checksum'] === false) || !empty($getid3->info['md5_data_source']))) {
    1.55 +                    break;
    1.56 +            }
    1.57 +
    1.58 +            $block_header_offset = ftell($getid3->fp) - 32;
    1.59 +            $block_header_magic  =                              substr($wavpack_header, 0, 4);
    1.60 +            $block_header_size   = getid3_lib::LittleEndian2Int(substr($wavpack_header, 4, 4));
    1.61 +
    1.62 +            if ($block_header_magic != 'wvpk') {
    1.63 +                throw new getid3_exception('Expecting "wvpk" at offset '.$block_header_offset.', found "'.$block_header_magic.'"');
    1.64 +            }
    1.65 +
    1.66 +            if ((@$info_wavpack_blockheader['block_samples'] <= 0)  ||  (@$info_wavpack_blockheader['total_samples'] <= 0)) {
    1.67 +                
    1.68 +                // Also, it is possible that the first block might not have
    1.69 +                // any samples (block_samples == 0) and in this case you should skip blocks
    1.70 +                // until you find one with samples because the other information (like
    1.71 +                // total_samples) are not guaranteed to be correct until (block_samples > 0)
    1.72 +
    1.73 +                // Finally, I have defined a format for files in which the length is not known
    1.74 +                // (for example when raw files are created using pipes). In these cases
    1.75 +                // total_samples will be -1 and you must seek to the final block to determine
    1.76 +                // the total number of samples.
    1.77 +
    1.78 +
    1.79 +                $getid3->info['audio']['dataformat']   = 'wavpack';
    1.80 +                $getid3->info['fileformat']            = 'wavpack';
    1.81 +                $getid3->info['audio']['lossless']     = true;
    1.82 +                $getid3->info['audio']['bitrate_mode'] = 'vbr';
    1.83 +
    1.84 +                $info_wavpack['blockheader']['offset'] = $block_header_offset;
    1.85 +                $info_wavpack['blockheader']['magic']  = $block_header_magic;
    1.86 +                $info_wavpack['blockheader']['size']   = $block_header_size;
    1.87 +                $info_wavpack_blockheader = &$info_wavpack['blockheader'];
    1.88 +
    1.89 +                if ($info_wavpack_blockheader['size'] >= 0x100000) {
    1.90 +                    throw new getid3_exception('Expecting WavPack block size less than "0x100000", found "'.$info_wavpack_blockheader['size'].'" at offset '.$info_wavpack_blockheader['offset']);
    1.91 +                }
    1.92 +
    1.93 +                $info_wavpack_blockheader['minor_version'] = ord($wavpack_header{8});
    1.94 +                $info_wavpack_blockheader['major_version'] = ord($wavpack_header{9});
    1.95 +
    1.96 +                if (($info_wavpack_blockheader['major_version'] != 4) ||
    1.97 +                    (($info_wavpack_blockheader['minor_version'] < 4) &&
    1.98 +                    ($info_wavpack_blockheader['minor_version'] > 16))) {
    1.99 +                    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']);
   1.100 +                }
   1.101 +
   1.102 +                $info_wavpack_blockheader['track_number']  = ord($wavpack_header{10}); // unused
   1.103 +                $info_wavpack_blockheader['index_number']  = ord($wavpack_header{11}); // unused
   1.104 +                
   1.105 +                getid3_lib::ReadSequence('LittleEndian2Int', $info_wavpack_blockheader, $wavpack_header, 12,
   1.106 +                    array (
   1.107 +                        'total_samples' => 4,
   1.108 +                        'block_index'   => 4,
   1.109 +                        'block_samples' => 4,
   1.110 +                        'flags_raw'     => 4,
   1.111 +                        'crc'           => 4
   1.112 +                    )
   1.113 +                );
   1.114 +                
   1.115 +                
   1.116 +                $info_wavpack_blockheader['flags']['bytes_per_sample']     =    1 + ($info_wavpack_blockheader['flags_raw'] & 0x00000003);
   1.117 +                $info_wavpack_blockheader['flags']['mono']                 = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000004);
   1.118 +                $info_wavpack_blockheader['flags']['hybrid']               = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000008);
   1.119 +                $info_wavpack_blockheader['flags']['joint_stereo']         = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000010);
   1.120 +                $info_wavpack_blockheader['flags']['cross_decorrelation']  = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000020);
   1.121 +                $info_wavpack_blockheader['flags']['hybrid_noiseshape']    = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000040);
   1.122 +                $info_wavpack_blockheader['flags']['ieee_32bit_float']     = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000080);
   1.123 +                $info_wavpack_blockheader['flags']['int_32bit']            = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000100);
   1.124 +                $info_wavpack_blockheader['flags']['hybrid_bitrate_noise'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000200);
   1.125 +                $info_wavpack_blockheader['flags']['hybrid_balance_noise'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000400);
   1.126 +                $info_wavpack_blockheader['flags']['multichannel_initial'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000800);
   1.127 +                $info_wavpack_blockheader['flags']['multichannel_final']   = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00001000);
   1.128 +
   1.129 +                $getid3->info['audio']['lossless'] = !$info_wavpack_blockheader['flags']['hybrid'];
   1.130 +            }
   1.131 +
   1.132 +
   1.133 +            while (!feof($getid3->fp) && (ftell($getid3->fp) < ($block_header_offset + $block_header_size + 8))) {
   1.134 +
   1.135 +                $metablock = array('offset'=>ftell($getid3->fp));
   1.136 +                $metablockheader = fread($getid3->fp, 2);
   1.137 +                if (feof($getid3->fp)) {
   1.138 +                    break;
   1.139 +                }
   1.140 +                $metablock['id'] = ord($metablockheader{0});
   1.141 +                $metablock['function_id'] = ($metablock['id'] & 0x3F);
   1.142 +                $metablock['function_name'] = $this->WavPackMetablockNameLookup($metablock['function_id']);
   1.143 +
   1.144 +                // The 0x20 bit in the id of the meta subblocks (which is defined as
   1.145 +                // ID_OPTIONAL_DATA) is a permanent part of the id. The idea is that
   1.146 +                // if a decoder encounters an id that it does not know about, it uses
   1.147 +                // that "ID_OPTIONAL_DATA" flag to determine what to do. If it is set
   1.148 +                // then the decoder simply ignores the metadata, but if it is zero
   1.149 +                // then the decoder should quit because it means that an understanding
   1.150 +                // of the metadata is required to correctly decode the audio.
   1.151 +                
   1.152 +                $metablock['non_decoder'] = (bool) ($metablock['id'] & 0x20);
   1.153 +                $metablock['padded_data'] = (bool) ($metablock['id'] & 0x40);
   1.154 +                $metablock['large_block'] = (bool) ($metablock['id'] & 0x80);
   1.155 +                if ($metablock['large_block']) {
   1.156 +                    $metablockheader .= fread($getid3->fp, 2);
   1.157 +                }
   1.158 +                $metablock['size'] = getid3_lib::LittleEndian2Int(substr($metablockheader, 1)) * 2; // size is stored in words
   1.159 +                $metablock['data'] = null;
   1.160 +
   1.161 +                if ($metablock['size'] > 0) {
   1.162 +
   1.163 +                    switch ($metablock['function_id']) {
   1.164 +
   1.165 +                        case 0x21: // ID_RIFF_HEADER
   1.166 +                        case 0x22: // ID_RIFF_TRAILER
   1.167 +                        case 0x23: // ID_REPLAY_GAIN
   1.168 +                        case 0x24: // ID_CUESHEET
   1.169 +                        case 0x25: // ID_CONFIG_BLOCK
   1.170 +                        case 0x26: // ID_MD5_CHECKSUM
   1.171 +                            $metablock['data'] = fread($getid3->fp, $metablock['size']);
   1.172 +
   1.173 +                            if ($metablock['padded_data']) {
   1.174 +                                // padded to the nearest even byte
   1.175 +                                $metablock['size']--;
   1.176 +                                $metablock['data'] = substr($metablock['data'], 0, -1);
   1.177 +                            }
   1.178 +                            break;
   1.179 +
   1.180 +
   1.181 +                        case 0x00: // ID_DUMMY
   1.182 +                        case 0x01: // ID_ENCODER_INFO
   1.183 +                        case 0x02: // ID_DECORR_TERMS
   1.184 +                        case 0x03: // ID_DECORR_WEIGHTS
   1.185 +                        case 0x04: // ID_DECORR_SAMPLES
   1.186 +                        case 0x05: // ID_ENTROPY_VARS
   1.187 +                        case 0x06: // ID_HYBRID_PROFILE
   1.188 +                        case 0x07: // ID_SHAPING_WEIGHTS
   1.189 +                        case 0x08: // ID_FLOAT_INFO
   1.190 +                        case 0x09: // ID_INT32_INFO
   1.191 +                        case 0x0A: // ID_WV_BITSTREAM
   1.192 +                        case 0x0B: // ID_WVC_BITSTREAM
   1.193 +                        case 0x0C: // ID_WVX_BITSTREAM
   1.194 +                        case 0x0D: // ID_CHANNEL_INFO
   1.195 +                            fseek($getid3->fp, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
   1.196 +                            break;
   1.197 +
   1.198 +
   1.199 +                        default:
   1.200 +                            $getid3->warning('Unexpected metablock type "0x'.str_pad(dechex($metablock['function_id']), 2, '0', STR_PAD_LEFT).'" at offset '.$metablock['offset']);
   1.201 +                            fseek($getid3->fp, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
   1.202 +                            break;
   1.203 +                    }
   1.204 +
   1.205 +
   1.206 +                    switch ($metablock['function_id']) {
   1.207 +
   1.208 +                        case 0x21: // ID_RIFF_HEADER
   1.209 +                            
   1.210 +                            $original_wav_filesize = getid3_lib::LittleEndian2Int(substr($metablock['data'], 4, 4));
   1.211 +                            
   1.212 +                            // Clone getid3 
   1.213 +                            $clone = clone $getid3;
   1.214 +                            
   1.215 +                            // Analyze clone by string
   1.216 +                            $riff = new getid3_riff($clone);
   1.217 +                            $riff->AnalyzeString($metablock['data']);
   1.218 +                            
   1.219 +                            // Import from clone and destroy
   1.220 +                            $metablock['riff'] = $clone->info['riff'];
   1.221 +                            $getid3->warnings($clone->warnings());
   1.222 +                            unset($clone);
   1.223 +                            
   1.224 +                            // Save RIFF header - we may need it later for RIFF footer parsing
   1.225 +                            $this->riff_header = $metablock['data'];
   1.226 +                            
   1.227 +                            $metablock['riff']['original_filesize'] = $original_wav_filesize;
   1.228 +                            $info_wavpack['riff_trailer_size'] = $original_wav_filesize - $metablock['riff']['WAVE']['data'][0]['size'] - $metablock['riff']['header_size'];
   1.229 +
   1.230 +                            $getid3->info['audio']['sample_rate'] = $metablock['riff']['raw']['fmt ']['nSamplesPerSec'];
   1.231 +                            $getid3->info['playtime_seconds']     = $info_wavpack_blockheader['total_samples'] / $getid3->info['audio']['sample_rate'];
   1.232 +
   1.233 +                            // Safe RIFF header in case there's a RIFF footer later
   1.234 +                            $metablock_riff_header = $metablock['data'];
   1.235 +                            break;
   1.236 +
   1.237 +
   1.238 +                        case 0x22: // ID_RIFF_TRAILER
   1.239 +
   1.240 +                            $metablock_riff_footer = $metablock_riff_header.$metablock['data'];
   1.241 +                            
   1.242 +                            $start_offset = $metablock['offset'] + ($metablock['large_block'] ? 4 : 2);
   1.243 +                            
   1.244 +                            $ftell_old = ftell($getid3->fp);
   1.245 +                            
   1.246 +                            // Clone getid3 
   1.247 +                            $clone = clone $getid3;
   1.248 +                            
   1.249 +                            // Call public method that really should be private
   1.250 +                            $riff = new getid3_riff($clone);
   1.251 +                            $metablock['riff'] = $riff->ParseRIFF($start_offset, $start_offset + $metablock['size']);
   1.252 +                            unset($clone);
   1.253 +                            
   1.254 +                            fseek($getid3->fp, $ftell_old, SEEK_SET);
   1.255 +
   1.256 +                            if (!empty($metablock['riff']['INFO'])) {
   1.257 +                                getid3_riff::RIFFCommentsParse($metablock['riff']['INFO'], $metablock['comments']);
   1.258 +                                $getid3->info['tags']['riff'] = $metablock['comments'];
   1.259 +                            }
   1.260 +                            break;
   1.261 +
   1.262 +
   1.263 +                        case 0x23: // ID_REPLAY_GAIN
   1.264 +                            $getid3->warning('WavPack "Replay Gain" contents not yet handled by getID3() in metablock at offset '.$metablock['offset']);
   1.265 +                            break;
   1.266 +
   1.267 +
   1.268 +                        case 0x24: // ID_CUESHEET
   1.269 +                            $getid3->warning('WavPack "Cuesheet" contents not yet handled by getID3() in metablock at offset '.$metablock['offset']);
   1.270 +                            break;
   1.271 +
   1.272 +
   1.273 +                        case 0x25: // ID_CONFIG_BLOCK
   1.274 +                            $metablock['flags_raw'] = getid3_lib::LittleEndian2Int(substr($metablock['data'], 0, 3));
   1.275 +
   1.276 +                            $metablock['flags']['adobe_mode']     = (bool) ($metablock['flags_raw'] & 0x000001); // "adobe" mode for 32-bit floats
   1.277 +                            $metablock['flags']['fast_flag']      = (bool) ($metablock['flags_raw'] & 0x000002); // fast mode
   1.278 +                            $metablock['flags']['very_fast_flag'] = (bool) ($metablock['flags_raw'] & 0x000004); // double fast
   1.279 +                            $metablock['flags']['high_flag']      = (bool) ($metablock['flags_raw'] & 0x000008); // high quality mode
   1.280 +                            $metablock['flags']['very_high_flag'] = (bool) ($metablock['flags_raw'] & 0x000010); // double high (not used yet)
   1.281 +                            $metablock['flags']['bitrate_kbps']   = (bool) ($metablock['flags_raw'] & 0x000020); // bitrate is kbps, not bits / sample
   1.282 +                            $metablock['flags']['auto_shaping']   = (bool) ($metablock['flags_raw'] & 0x000040); // automatic noise shaping
   1.283 +                            $metablock['flags']['shape_override'] = (bool) ($metablock['flags_raw'] & 0x000080); // shaping mode specified
   1.284 +                            $metablock['flags']['joint_override'] = (bool) ($metablock['flags_raw'] & 0x000100); // joint-stereo mode specified
   1.285 +                            $metablock['flags']['copy_time']      = (bool) ($metablock['flags_raw'] & 0x000200); // copy file-time from source
   1.286 +                            $metablock['flags']['create_exe']     = (bool) ($metablock['flags_raw'] & 0x000400); // create executable
   1.287 +                            $metablock['flags']['create_wvc']     = (bool) ($metablock['flags_raw'] & 0x000800); // create correction file
   1.288 +                            $metablock['flags']['optimize_wvc']   = (bool) ($metablock['flags_raw'] & 0x001000); // maximize bybrid compression
   1.289 +                            $metablock['flags']['quality_mode']   = (bool) ($metablock['flags_raw'] & 0x002000); // psychoacoustic quality mode
   1.290 +                            $metablock['flags']['raw_flag']       = (bool) ($metablock['flags_raw'] & 0x004000); // raw mode (not implemented yet)
   1.291 +                            $metablock['flags']['calc_noise']     = (bool) ($metablock['flags_raw'] & 0x008000); // calc noise in hybrid mode
   1.292 +                            $metablock['flags']['lossy_mode']     = (bool) ($metablock['flags_raw'] & 0x010000); // obsolete (for information)
   1.293 +                            $metablock['flags']['extra_mode']     = (bool) ($metablock['flags_raw'] & 0x020000); // extra processing mode
   1.294 +                            $metablock['flags']['skip_wvx']       = (bool) ($metablock['flags_raw'] & 0x040000); // no wvx stream w/ floats & big ints
   1.295 +                            $metablock['flags']['md5_checksum']   = (bool) ($metablock['flags_raw'] & 0x080000); // compute & store MD5 signature
   1.296 +                            $metablock['flags']['quiet_mode']     = (bool) ($metablock['flags_raw'] & 0x100000); // don't report progress %
   1.297 +
   1.298 +                            $info_wavpack['config_flags'] = $metablock['flags'];
   1.299 +
   1.300 +                            $getid3->info['audio']['encoder_options'] = trim(
   1.301 +                                ($info_wavpack_blockheader['flags']['hybrid'] ? ' -b???' : '') .
   1.302 +                                ($metablock['flags']['adobe_mode']            ? ' -a'    : '') .
   1.303 +                                ($metablock['flags']['optimize_wvc']          ? ' -cc'   : '') .
   1.304 +                                ($metablock['flags']['create_exe']            ? ' -e'    : '') .
   1.305 +                                ($metablock['flags']['fast_flag']             ? ' -f'    : '') .
   1.306 +                                ($metablock['flags']['joint_override']        ? ' -j?'   : '') .
   1.307 +                                ($metablock['flags']['high_flag']             ? ' -h'    : '') .
   1.308 +                                ($metablock['flags']['md5_checksum']          ? ' -m'    : '') .
   1.309 +                                ($metablock['flags']['calc_noise']            ? ' -n'    : '') .
   1.310 +                                ($metablock['flags']['shape_override']        ? ' -s?'   : '') .
   1.311 +                                ($metablock['flags']['extra_mode']            ? ' -x?'   : '')
   1.312 +                            );
   1.313 +                            if (!$getid3->info['audio']['encoder_options']) {
   1.314 +                                unset($getid3->info['audio']['encoder_options']);
   1.315 +                            }
   1.316 +                            break;
   1.317 +
   1.318 +
   1.319 +                        case 0x26: // ID_MD5_CHECKSUM
   1.320 +                            if (strlen($metablock['data']) == 16) {
   1.321 +                                $getid3->info['md5_data_source'] = strtolower(getid3_lib::PrintHexBytes($metablock['data'], true, false, false));
   1.322 +                            } else {
   1.323 +                                $getid3->warning('Expecting 16 bytes of WavPack "MD5 Checksum" in metablock at offset '.$metablock['offset'].', but found '.strlen($metablock['data']).' bytes');
   1.324 +                            }
   1.325 +                            break;
   1.326 +
   1.327 +
   1.328 +                        case 0x00: // ID_DUMMY
   1.329 +                        case 0x01: // ID_ENCODER_INFO
   1.330 +                        case 0x02: // ID_DECORR_TERMS
   1.331 +                        case 0x03: // ID_DECORR_WEIGHTS
   1.332 +                        case 0x04: // ID_DECORR_SAMPLES
   1.333 +                        case 0x05: // ID_ENTROPY_VARS
   1.334 +                        case 0x06: // ID_HYBRID_PROFILE
   1.335 +                        case 0x07: // ID_SHAPING_WEIGHTS
   1.336 +                        case 0x08: // ID_FLOAT_INFO
   1.337 +                        case 0x09: // ID_INT32_INFO
   1.338 +                        case 0x0A: // ID_WV_BITSTREAM
   1.339 +                        case 0x0B: // ID_WVC_BITSTREAM
   1.340 +                        case 0x0C: // ID_WVX_BITSTREAM
   1.341 +                        case 0x0D: // ID_CHANNEL_INFO
   1.342 +                            unset($metablock);
   1.343 +                            break;
   1.344 +                    }
   1.345 +
   1.346 +                }
   1.347 +            
   1.348 +                if (!empty($metablock)) {
   1.349 +                    $info_wavpack['metablocks'][] = $metablock;
   1.350 +                }
   1.351 +
   1.352 +            }
   1.353 +
   1.354 +        }
   1.355 +
   1.356 +        $getid3->info['audio']['encoder']         = 'WavPack v'.$info_wavpack_blockheader['major_version'].'.'.str_pad($info_wavpack_blockheader['minor_version'], 2, '0', STR_PAD_LEFT);
   1.357 +        $getid3->info['audio']['bits_per_sample'] = $info_wavpack_blockheader['flags']['bytes_per_sample'] * 8;
   1.358 +        $getid3->info['audio']['channels']        = ($info_wavpack_blockheader['flags']['mono'] ? 1 : 2);
   1.359 +
   1.360 +        if (@$getid3->info['playtime_seconds']) {
   1.361 +            $getid3->info['audio']['bitrate']     = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['playtime_seconds'];
   1.362 +        } else {
   1.363 +            $getid3->info['audio']['dataformat']  = 'wvc';
   1.364 +        }
   1.365 +
   1.366 +        return true;
   1.367 +    }
   1.368 +
   1.369 +
   1.370 +
   1.371 +    public static function WavPackMetablockNameLookup($id) {
   1.372 +
   1.373 +        static $lookup = array(
   1.374 +            0x00 => 'Dummy',
   1.375 +            0x01 => 'Encoder Info',
   1.376 +            0x02 => 'Decorrelation Terms',
   1.377 +            0x03 => 'Decorrelation Weights',
   1.378 +            0x04 => 'Decorrelation Samples',
   1.379 +            0x05 => 'Entropy Variables',
   1.380 +            0x06 => 'Hybrid Profile',
   1.381 +            0x07 => 'Shaping Weights',
   1.382 +            0x08 => 'Float Info',
   1.383 +            0x09 => 'Int32 Info',
   1.384 +            0x0A => 'WV Bitstream',
   1.385 +            0x0B => 'WVC Bitstream',
   1.386 +            0x0C => 'WVX Bitstream',
   1.387 +            0x0D => 'Channel Info',
   1.388 +            0x21 => 'RIFF header',
   1.389 +            0x22 => 'RIFF trailer',
   1.390 +            0x23 => 'Replay Gain',
   1.391 +            0x24 => 'Cuesheet',
   1.392 +            0x25 => 'Config Block',
   1.393 +            0x26 => 'MD5 Checksum',
   1.394 +        );
   1.395 +        
   1.396 +        return (@$lookup[$id]);
   1.397 +    }
   1.398 +
   1.399 +}
   1.400 +
   1.401 +
   1.402 +?>
   1.403 \ No newline at end of file