Mercurial > judyates
view e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.mpc_old.php @ 28:118cb614cf18 judyates tip
judy bio.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 29 Dec 2015 16:26:18 -0800 |
parents | 3f6b44aa6b35 |
children |
line wrap: on
line source
1 <?php2 // +----------------------------------------------------------------------+3 // | PHP version 5 |4 // +----------------------------------------------------------------------+5 // | Copyright (c) 2002-2006 James Heinrich, Allan Hansen |6 // +----------------------------------------------------------------------+7 // | This source file is subject to version 2 of the GPL license, |8 // | that is bundled with this package in the file license.txt and is |9 // | available through the world-wide-web at the following url: |10 // | http://www.gnu.org/copyleft/gpl.html |11 // +----------------------------------------------------------------------+12 // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org |13 // +----------------------------------------------------------------------+14 // | Authors: James Heinrich <infoØgetid3*org> |15 // | Allan Hansen <ahØartemis*dk> |16 // +----------------------------------------------------------------------+17 // | module.audio.mpc_old.php |18 // | Module for analyzing Musepack/MPEG+ Audio files - SV4-SV6 |19 // | dependencies: NONE |20 // +----------------------------------------------------------------------+21 //22 // $Id: module.audio.mpc_old.php,v 1.2 2006/11/02 10:48:01 ah Exp $26 class getid3_mpc_old extends getid3_handler27 {29 public function Analyze() {31 $getid3 = $this->getid3;33 // http://www.uni-jena.de/~pfk/mpp/sv8/header.html35 $getid3->info['mpc']['header'] = array ();36 $info_mpc_header = &$getid3->info['mpc']['header'];38 $getid3->info['fileformat'] = 'mpc';39 $getid3->info['audio']['dataformat'] = 'mpc';40 $getid3->info['audio']['bitrate_mode'] = 'vbr';41 $getid3->info['audio']['channels'] = 2; // the format appears to be hardcoded for stereo only42 $getid3->info['audio']['lossless'] = false;44 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);46 $info_mpc_header['size'] = 8;47 $getid3->info['avdataoffset'] += $info_mpc_header['size'];49 $mpc_header_data = fread($getid3->fp, $info_mpc_header['size']);52 // Most of this code adapted from Jurgen Faul's MPEGplus source code - thanks Jurgen! :)53 $header_dword[0] = getid3_lib::LittleEndian2Int(substr($mpc_header_data, 0, 4));54 $header_dword[1] = getid3_lib::LittleEndian2Int(substr($mpc_header_data, 4, 4));57 // DDDD DDDD CCCC CCCC BBBB BBBB AAAA AAAA58 // aaaa aaaa abcd dddd dddd deee eeff ffff59 //60 // a = bitrate = anything61 // b = IS = anything62 // c = MS = anything63 // d = streamversion = 0000000004 or 0000000005 or 000000000664 // e = maxband = anything65 // f = blocksize = 000001 for SV5+, anything(?) for SV467 $info_mpc_header['target_bitrate'] = (($header_dword[0] & 0xFF800000) >> 23);68 $info_mpc_header['intensity_stereo'] = (bool)(($header_dword[0] & 0x00400000) >> 22);69 $info_mpc_header['mid-side_stereo'] = (bool)(($header_dword[0] & 0x00200000) >> 21);70 $info_mpc_header['stream_major_version'] = ($header_dword[0] & 0x001FF800) >> 11;71 $info_mpc_header['stream_minor_version'] = 0;72 $info_mpc_header['max_band'] = ($header_dword[0] & 0x000007C0) >> 6; // related to lowpass frequency, not sure how it translates exactly73 $info_mpc_header['block_size'] = ($header_dword[0] & 0x0000003F);75 switch ($info_mpc_header['stream_major_version']) {76 case 4:77 $info_mpc_header['frame_count'] = ($header_dword[1] >> 16);78 break;79 case 5:80 case 6:81 $info_mpc_header['frame_count'] = $header_dword[1];82 break;84 default:85 throw new getid3_exception('Expecting 4, 5 or 6 in version field, found '.$info_mpc_header['stream_major_version'].' instead');86 }88 if (($info_mpc_header['stream_major_version'] > 4) && ($info_mpc_header['block_size'] != 1)) {89 $getid3->warning('Block size expected to be 1, actual value found: '.$info_mpc_header['block_size']);90 }92 $info_mpc_header['sample_rate'] = $getid3->info['audio']['sample_rate'] = 44100; // AB: used by all files up to SV793 $info_mpc_header['samples'] = $info_mpc_header['frame_count'] * 1152 * $getid3->info['audio']['channels'];95 $getid3->info['audio']['bitrate_mode'] = $info_mpc_header['target_bitrate'] == 0 ? 'vbr' : 'cbr';97 $getid3->info['mpc']['bitrate'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8 * 44100 / $info_mpc_header['frame_count'] / 1152;98 $getid3->info['audio']['bitrate'] = $getid3->info['mpc']['bitrate'];99 $getid3->info['audio']['encoder'] = 'SV'.$info_mpc_header['stream_major_version'];101 return true;102 }104 }107 ?>