Mercurial > judyates
view e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.dts.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.dts.php |18 // | Module for analyzing DTS audio files |19 // | dependencies: NONE |20 // +----------------------------------------------------------------------+21 //22 // $Id: module.audio.dts.php,v 1.2 2006/11/16 13:14:26 ah Exp $26 // Specs taken from "DTS Coherent Acoustics;Core and Extensions, ETSI TS 102 114 V1.2.1 (2002-12)"27 // (http://pda.etsi.org/pda/queryform.asp)28 // With thanks to Gambit <macteam@users.sourceforge.net> http://mac.sourceforge.net/atl/30 class getid3_dts extends getid3_handler31 {33 public function Analyze() {35 $getid3 = $this->getid3;37 $getid3->info['dts'] = array ();38 $info_dts = &$getid3->info['dts'];40 $getid3->info['fileformat'] = 'dts';42 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);43 $header = fread($getid3->fp, 16);45 $fhBS = getid3_lib::BigEndian2Bin(substr($header, 4, 12));46 $bs_offset = 0;47 $info_dts['raw']['frame_type'] = bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;48 $info_dts['raw']['deficit_samples'] = bindec(substr($fhBS, $bs_offset, 5)); $bs_offset += 5;49 $info_dts['flags']['crc_present'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;50 $info_dts['raw']['pcm_sample_blocks'] = bindec(substr($fhBS, $bs_offset, 7)); $bs_offset += 7;51 $info_dts['raw']['frame_byte_size'] = bindec(substr($fhBS, $bs_offset, 14)); $bs_offset += 14;52 $info_dts['raw']['channel_arrangement'] = bindec(substr($fhBS, $bs_offset, 6)); $bs_offset += 6;53 $info_dts['raw']['sample_frequency'] = bindec(substr($fhBS, $bs_offset, 4)); $bs_offset += 4;54 $info_dts['raw']['bitrate'] = bindec(substr($fhBS, $bs_offset, 5)); $bs_offset += 5;55 $info_dts['flags']['embedded_downmix'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;56 $info_dts['flags']['dynamicrange'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;57 $info_dts['flags']['timestamp'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;58 $info_dts['flags']['auxdata'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;59 $info_dts['flags']['hdcd'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;60 $info_dts['raw']['extension_audio'] = bindec(substr($fhBS, $bs_offset, 3)); $bs_offset += 3;61 $info_dts['flags']['extended_coding'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;62 $info_dts['flags']['audio_sync_insertion'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;63 $info_dts['raw']['lfe_effects'] = bindec(substr($fhBS, $bs_offset, 2)); $bs_offset += 2;64 $info_dts['flags']['predictor_history'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;65 if ($info_dts['flags']['crc_present']) {66 $info_dts['raw']['crc16'] = bindec(substr($fhBS, $bs_offset, 16)); $bs_offset += 16;67 }68 $info_dts['flags']['mri_perfect_reconst'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;69 $info_dts['raw']['encoder_soft_version'] = bindec(substr($fhBS, $bs_offset, 4)); $bs_offset += 4;70 $info_dts['raw']['copy_history'] = bindec(substr($fhBS, $bs_offset, 2)); $bs_offset += 2;71 $info_dts['raw']['bits_per_sample'] = bindec(substr($fhBS, $bs_offset, 2)); $bs_offset += 2;72 $info_dts['flags']['surround_es'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;73 $info_dts['flags']['front_sum_diff'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;74 $info_dts['flags']['surround_sum_diff'] = (bool) bindec(substr($fhBS, $bs_offset, 1)); $bs_offset += 1;75 $info_dts['raw']['dialog_normalization'] = bindec(substr($fhBS, $bs_offset, 4)); $bs_offset += 4;78 $info_dts['bitrate'] = $this->DTSbitrateLookup($info_dts['raw']['bitrate']);79 $info_dts['bits_per_sample'] = $this->DTSbitPerSampleLookup($info_dts['raw']['bits_per_sample']);80 $info_dts['sample_rate'] = $this->DTSsampleRateLookup($info_dts['raw']['sample_frequency']);81 $info_dts['dialog_normalization'] = $this->DTSdialogNormalization($info_dts['raw']['dialog_normalization'], $info_dts['raw']['encoder_soft_version']);82 $info_dts['flags']['lossless'] = (($info_dts['raw']['bitrate'] == 31) ? true : false);83 $info_dts['bitrate_mode'] = (($info_dts['raw']['bitrate'] == 30) ? 'vbr' : 'cbr');84 $info_dts['channels'] = $this->DTSnumChannelsLookup($info_dts['raw']['channel_arrangement']);85 $info_dts['channel_arrangement'] = $this->DTSchannelArrangementLookup($info_dts['raw']['channel_arrangement']);87 $getid3->info['audio']['dataformat'] = 'dts';88 $getid3->info['audio']['lossless'] = $info_dts['flags']['lossless'];89 $getid3->info['audio']['bitrate_mode'] = $info_dts['bitrate_mode'];90 $getid3->info['audio']['bits_per_sample'] = $info_dts['bits_per_sample'];91 $getid3->info['audio']['sample_rate'] = $info_dts['sample_rate'];92 $getid3->info['audio']['channels'] = $info_dts['channels'];93 $getid3->info['audio']['bitrate'] = $info_dts['bitrate'];94 $getid3->info['playtime_seconds'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) / ($info_dts['bitrate'] / 8);96 return true;97 }100 public static function DTSbitrateLookup($index) {102 static $lookup = array (103 0 => 32000,104 1 => 56000,105 2 => 64000,106 3 => 96000,107 4 => 112000,108 5 => 128000,109 6 => 192000,110 7 => 224000,111 8 => 256000,112 9 => 320000,113 10 => 384000,114 11 => 448000,115 12 => 512000,116 13 => 576000,117 14 => 640000,118 15 => 768000,119 16 => 960000,120 17 => 1024000,121 18 => 1152000,122 19 => 1280000,123 20 => 1344000,124 21 => 1408000,125 22 => 1411200,126 23 => 1472000,127 24 => 1536000,128 25 => 1920000,129 26 => 2048000,130 27 => 3072000,131 28 => 3840000,132 29 => 'open',133 30 => 'variable',134 31 => 'lossless'135 );136 return @$lookup[$index];137 }140 public static function DTSsampleRateLookup($index) {142 static $lookup = array (143 0 => 'invalid',144 1 => 8000,145 2 => 16000,146 3 => 32000,147 4 => 'invalid',148 5 => 'invalid',149 6 => 11025,150 7 => 22050,151 8 => 44100,152 9 => 'invalid',153 10 => 'invalid',154 11 => 12000,155 12 => 24000,156 13 => 48000,157 14 => 'invalid',158 15 => 'invalid'159 );160 return @$lookup[$index];161 }164 public static function DTSbitPerSampleLookup($index) {166 static $lookup = array (167 0 => 16,168 1 => 20,169 2 => 24,170 3 => 24,171 );172 return @$lookup[$index];173 }176 public static function DTSnumChannelsLookup($index) {178 switch ($index) {179 case 0:180 return 1;182 case 1:183 case 2:184 case 3:185 case 4:186 return 2;188 case 5:189 case 6:190 return 3;192 case 7:193 case 8:194 return 4;196 case 9:197 return 5;199 case 10:200 case 11:201 case 12:202 return 6;204 case 13:205 return 7;207 case 14:208 case 15:209 return 8;210 }211 return false;212 }215 public static function DTSchannelArrangementLookup($index) {217 static $lookup = array (218 0 => 'A',219 1 => 'A + B (dual mono)',220 2 => 'L + R (stereo)',221 3 => '(L+R) + (L-R) (sum-difference)',222 4 => 'LT + RT (left and right total)',223 5 => 'C + L + R',224 6 => 'L + R + S',225 7 => 'C + L + R + S',226 8 => 'L + R + SL + SR',227 9 => 'C + L + R + SL + SR',228 10 => 'CL + CR + L + R + SL + SR',229 11 => 'C + L + R+ LR + RR + OV',230 12 => 'CF + CR + LF + RF + LR + RR',231 13 => 'CL + C + CR + L + R + SL + SR',232 14 => 'CL + CR + L + R + SL1 + SL2 + SR1 + SR2',233 15 => 'CL + C+ CR + L + R + SL + S + SR',234 );235 return (@$lookup[$index] ? @$lookup[$index] : 'user-defined');236 }239 public static function DTSdialogNormalization($index, $version) {241 switch ($version) {242 case 7:243 return 0 - $index;245 case 6:246 return 0 - 16 - $index;247 }248 return false;249 }251 }254 ?>