annotate e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.rkau.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
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.rkau.php |
rlm@3 18 // | Module for analyzing RKAU Audio files |
rlm@3 19 // | dependencies: NONE |
rlm@3 20 // +----------------------------------------------------------------------+
rlm@3 21 //
rlm@3 22 // $Id: module.audio.rkau.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_rkau 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 $rkau_header = fread($getid3->fp, 20);
rlm@3 35
rlm@3 36 // Magic bytes 'RKA'
rlm@3 37
rlm@3 38 $getid3->info['fileformat'] = 'rkau';
rlm@3 39 $getid3->info['audio']['dataformat'] = 'rkau';
rlm@3 40 $getid3->info['audio']['bitrate_mode'] = 'vbr';
rlm@3 41
rlm@3 42 // Shortcut
rlm@3 43 $getid3->info['rkau'] = array ();
rlm@3 44 $info_rkau = &$getid3->info['rkau'];
rlm@3 45
rlm@3 46 $info_rkau['raw']['version'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 3, 1));
rlm@3 47 $info_rkau['version'] = '1.'.str_pad($info_rkau['raw']['version'] & 0x0F, 2, '0', STR_PAD_LEFT);
rlm@3 48 if (($info_rkau['version'] > 1.07) || ($info_rkau['version'] < 1.06)) {
rlm@3 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'].')');
rlm@3 50 }
rlm@3 51
rlm@3 52 getid3_lib::ReadSequence('LittleEndian2Int', $info_rkau, $rkau_header, 4,
rlm@3 53 array (
rlm@3 54 'source_bytes' => 4,
rlm@3 55 'sample_rate' => 4,
rlm@3 56 'channels' => 1,
rlm@3 57 'bits_per_sample' => 1
rlm@3 58 )
rlm@3 59 );
rlm@3 60
rlm@3 61 $info_rkau['raw']['quality'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 14, 1));
rlm@3 62
rlm@3 63 $quality = $info_rkau['raw']['quality'] & 0x0F;
rlm@3 64
rlm@3 65 $info_rkau['lossless'] = (($quality == 0) ? true : false);
rlm@3 66 $info_rkau['compression_level'] = (($info_rkau['raw']['quality'] & 0xF0) >> 4) + 1;
rlm@3 67 if (!$info_rkau['lossless']) {
rlm@3 68 $info_rkau['quality_setting'] = $quality;
rlm@3 69 }
rlm@3 70
rlm@3 71 $info_rkau['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 15, 1));
rlm@3 72 $info_rkau['flags']['joint_stereo'] = (bool)(!($info_rkau['raw']['flags'] & 0x01));
rlm@3 73 $info_rkau['flags']['streaming'] = (bool) ($info_rkau['raw']['flags'] & 0x02);
rlm@3 74 $info_rkau['flags']['vrq_lossy_mode'] = (bool) ($info_rkau['raw']['flags'] & 0x04);
rlm@3 75
rlm@3 76 if ($info_rkau['flags']['streaming']) {
rlm@3 77 $getid3->info['avdataoffset'] += 20;
rlm@3 78 $info_rkau['compressed_bytes'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 16, 4));
rlm@3 79 }
rlm@3 80 else {
rlm@3 81 $getid3->info['avdataoffset'] += 16;
rlm@3 82 $info_rkau['compressed_bytes'] = $getid3->info['avdataend'] - $getid3->info['avdataoffset'] - 1;
rlm@3 83 }
rlm@3 84 // Note: compressed_bytes does not always equal what appears to be the actual number of compressed bytes,
rlm@3 85 // sometimes it's more, sometimes less. No idea why(?)
rlm@3 86
rlm@3 87 $getid3->info['audio']['lossless'] = $info_rkau['lossless'];
rlm@3 88 $getid3->info['audio']['channels'] = $info_rkau['channels'];
rlm@3 89 $getid3->info['audio']['bits_per_sample'] = $info_rkau['bits_per_sample'];
rlm@3 90 $getid3->info['audio']['sample_rate'] = $info_rkau['sample_rate'];
rlm@3 91
rlm@3 92 $getid3->info['playtime_seconds'] = $info_rkau['source_bytes'] / ($info_rkau['sample_rate'] * $info_rkau['channels'] * ($info_rkau['bits_per_sample'] / 8));
rlm@3 93 $getid3->info['audio']['bitrate'] = ($info_rkau['compressed_bytes'] * 8) / $getid3->info['playtime_seconds'];
rlm@3 94
rlm@3 95 return true;
rlm@3 96
rlm@3 97 }
rlm@3 98
rlm@3 99 }
rlm@3 100
rlm@3 101 ?>