Mercurial > judyates
view e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.rkau.php @ 16:e902d48caadf judyates
added access.log and error.log
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 22 Jun 2010 13:41:04 -0400 |
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.rkau.php |18 // | Module for analyzing RKAU Audio files |19 // | dependencies: NONE |20 // +----------------------------------------------------------------------+21 //22 // $Id: module.audio.rkau.php,v 1.2 2006/11/02 10:48:01 ah Exp $26 class getid3_rkau extends getid3_handler27 {29 public function Analyze() {31 $getid3 = $this->getid3;33 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);34 $rkau_header = fread($getid3->fp, 20);36 // Magic bytes 'RKA'38 $getid3->info['fileformat'] = 'rkau';39 $getid3->info['audio']['dataformat'] = 'rkau';40 $getid3->info['audio']['bitrate_mode'] = 'vbr';42 // Shortcut43 $getid3->info['rkau'] = array ();44 $info_rkau = &$getid3->info['rkau'];46 $info_rkau['raw']['version'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 3, 1));47 $info_rkau['version'] = '1.'.str_pad($info_rkau['raw']['version'] & 0x0F, 2, '0', STR_PAD_LEFT);48 if (($info_rkau['version'] > 1.07) || ($info_rkau['version'] < 1.06)) {49 throw new getid3_exception('This version of getID3() can only parse RKAU files v1.06 and 1.07 (this file is v'.$info_rkau['version'].')');50 }52 getid3_lib::ReadSequence('LittleEndian2Int', $info_rkau, $rkau_header, 4,53 array (54 'source_bytes' => 4,55 'sample_rate' => 4,56 'channels' => 1,57 'bits_per_sample' => 158 )59 );61 $info_rkau['raw']['quality'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 14, 1));63 $quality = $info_rkau['raw']['quality'] & 0x0F;65 $info_rkau['lossless'] = (($quality == 0) ? true : false);66 $info_rkau['compression_level'] = (($info_rkau['raw']['quality'] & 0xF0) >> 4) + 1;67 if (!$info_rkau['lossless']) {68 $info_rkau['quality_setting'] = $quality;69 }71 $info_rkau['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 15, 1));72 $info_rkau['flags']['joint_stereo'] = (bool)(!($info_rkau['raw']['flags'] & 0x01));73 $info_rkau['flags']['streaming'] = (bool) ($info_rkau['raw']['flags'] & 0x02);74 $info_rkau['flags']['vrq_lossy_mode'] = (bool) ($info_rkau['raw']['flags'] & 0x04);76 if ($info_rkau['flags']['streaming']) {77 $getid3->info['avdataoffset'] += 20;78 $info_rkau['compressed_bytes'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 16, 4));79 }80 else {81 $getid3->info['avdataoffset'] += 16;82 $info_rkau['compressed_bytes'] = $getid3->info['avdataend'] - $getid3->info['avdataoffset'] - 1;83 }84 // Note: compressed_bytes does not always equal what appears to be the actual number of compressed bytes,85 // sometimes it's more, sometimes less. No idea why(?)87 $getid3->info['audio']['lossless'] = $info_rkau['lossless'];88 $getid3->info['audio']['channels'] = $info_rkau['channels'];89 $getid3->info['audio']['bits_per_sample'] = $info_rkau['bits_per_sample'];90 $getid3->info['audio']['sample_rate'] = $info_rkau['sample_rate'];92 $getid3->info['playtime_seconds'] = $info_rkau['source_bytes'] / ($info_rkau['sample_rate'] * $info_rkau['channels'] * ($info_rkau['bits_per_sample'] / 8));93 $getid3->info['audio']['bitrate'] = ($info_rkau['compressed_bytes'] * 8) / $getid3->info['playtime_seconds'];95 return true;97 }99 }101 ?>