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