diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.dts.php	Mon Feb 22 08:02:39 2010 -0500
     1.3 @@ -0,0 +1,254 @@
     1.4 +<?php
     1.5 +// +----------------------------------------------------------------------+
     1.6 +// | PHP version 5                                                        |
     1.7 +// +----------------------------------------------------------------------+
     1.8 +// | Copyright (c) 2002-2006 James Heinrich, Allan Hansen                 |
     1.9 +// +----------------------------------------------------------------------+
    1.10 +// | This source file is subject to version 2 of the GPL license,         |
    1.11 +// | that is bundled with this package in the file license.txt and is     |
    1.12 +// | available through the world-wide-web at the following url:           |
    1.13 +// | http://www.gnu.org/copyleft/gpl.html                                 |
    1.14 +// +----------------------------------------------------------------------+
    1.15 +// | getID3() - http://getid3.sourceforge.net or http://www.getid3.org    |
    1.16 +// +----------------------------------------------------------------------+
    1.17 +// | Authors: James Heinrich <infoØgetid3*org>                            |
    1.18 +// |          Allan Hansen <ahØartemis*dk>                                |
    1.19 +// +----------------------------------------------------------------------+
    1.20 +// | module.audio.dts.php                                                 |
    1.21 +// | Module for analyzing DTS audio files                                 |
    1.22 +// | dependencies: NONE                                                   |
    1.23 +// +----------------------------------------------------------------------+
    1.24 +//
    1.25 +// $Id: module.audio.dts.php,v 1.2 2006/11/16 13:14:26 ah Exp $
    1.26 +
    1.27 +        
    1.28 +        
    1.29 +// Specs taken from "DTS Coherent Acoustics;Core and Extensions,  ETSI TS 102 114 V1.2.1 (2002-12)"
    1.30 +// (http://pda.etsi.org/pda/queryform.asp)
    1.31 +// With thanks to Gambit <macteam@users.sourceforge.net> http://mac.sourceforge.net/atl/
    1.32 +        
    1.33 +class getid3_dts extends getid3_handler
    1.34 +{
    1.35 +
    1.36 +    public function Analyze() {
    1.37 +        
    1.38 +        $getid3 = $this->getid3;
    1.39 +        
    1.40 +        $getid3->info['dts'] = array ();
    1.41 +        $info_dts = &$getid3->info['dts'];
    1.42 +
    1.43 +        $getid3->info['fileformat'] = 'dts';
    1.44 +
    1.45 +        fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
    1.46 +        $header = fread($getid3->fp, 16);
    1.47 +
    1.48 +        $fhBS = getid3_lib::BigEndian2Bin(substr($header, 4, 12));
    1.49 +        $bs_offset = 0;
    1.50 +        $info_dts['raw']['frame_type']             =        bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.51 +        $info_dts['raw']['deficit_samples']        =        bindec(substr($fhBS, $bs_offset,  5)); $bs_offset +=  5;
    1.52 +        $info_dts['flags']['crc_present']          = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.53 +        $info_dts['raw']['pcm_sample_blocks']      =        bindec(substr($fhBS, $bs_offset,  7)); $bs_offset +=  7;
    1.54 +        $info_dts['raw']['frame_byte_size']        =        bindec(substr($fhBS, $bs_offset, 14)); $bs_offset += 14;
    1.55 +        $info_dts['raw']['channel_arrangement']    =        bindec(substr($fhBS, $bs_offset,  6)); $bs_offset +=  6;
    1.56 +        $info_dts['raw']['sample_frequency']       =        bindec(substr($fhBS, $bs_offset,  4)); $bs_offset +=  4;
    1.57 +        $info_dts['raw']['bitrate']                =        bindec(substr($fhBS, $bs_offset,  5)); $bs_offset +=  5;
    1.58 +        $info_dts['flags']['embedded_downmix']     = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.59 +        $info_dts['flags']['dynamicrange']         = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.60 +        $info_dts['flags']['timestamp']            = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.61 +        $info_dts['flags']['auxdata']              = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.62 +        $info_dts['flags']['hdcd']                 = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.63 +        $info_dts['raw']['extension_audio']        =        bindec(substr($fhBS, $bs_offset,  3)); $bs_offset +=  3;
    1.64 +        $info_dts['flags']['extended_coding']      = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.65 +        $info_dts['flags']['audio_sync_insertion'] = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.66 +        $info_dts['raw']['lfe_effects']            =        bindec(substr($fhBS, $bs_offset,  2)); $bs_offset +=  2;
    1.67 +        $info_dts['flags']['predictor_history']    = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.68 +        if ($info_dts['flags']['crc_present']) {
    1.69 +            $info_dts['raw']['crc16']              =        bindec(substr($fhBS, $bs_offset, 16)); $bs_offset += 16;
    1.70 +        }
    1.71 +        $info_dts['flags']['mri_perfect_reconst']  = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.72 +        $info_dts['raw']['encoder_soft_version']   =        bindec(substr($fhBS, $bs_offset,  4)); $bs_offset +=  4;
    1.73 +        $info_dts['raw']['copy_history']           =        bindec(substr($fhBS, $bs_offset,  2)); $bs_offset +=  2;
    1.74 +        $info_dts['raw']['bits_per_sample']        =        bindec(substr($fhBS, $bs_offset,  2)); $bs_offset +=  2;
    1.75 +        $info_dts['flags']['surround_es']          = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.76 +        $info_dts['flags']['front_sum_diff']       = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.77 +        $info_dts['flags']['surround_sum_diff']    = (bool) bindec(substr($fhBS, $bs_offset,  1)); $bs_offset +=  1;
    1.78 +        $info_dts['raw']['dialog_normalization']   =        bindec(substr($fhBS, $bs_offset,  4)); $bs_offset +=  4;
    1.79 +
    1.80 +
    1.81 +        $info_dts['bitrate']              = $this->DTSbitrateLookup($info_dts['raw']['bitrate']);
    1.82 +        $info_dts['bits_per_sample']      = $this->DTSbitPerSampleLookup($info_dts['raw']['bits_per_sample']);
    1.83 +        $info_dts['sample_rate']          = $this->DTSsampleRateLookup($info_dts['raw']['sample_frequency']);
    1.84 +        $info_dts['dialog_normalization'] = $this->DTSdialogNormalization($info_dts['raw']['dialog_normalization'], $info_dts['raw']['encoder_soft_version']);
    1.85 +        $info_dts['flags']['lossless']    = (($info_dts['raw']['bitrate'] == 31) ? true  : false);
    1.86 +        $info_dts['bitrate_mode']         = (($info_dts['raw']['bitrate'] == 30) ? 'vbr' : 'cbr');
    1.87 +        $info_dts['channels']             = $this->DTSnumChannelsLookup($info_dts['raw']['channel_arrangement']);
    1.88 +        $info_dts['channel_arrangement']  = $this->DTSchannelArrangementLookup($info_dts['raw']['channel_arrangement']);
    1.89 +
    1.90 +        $getid3->info['audio']['dataformat']      = 'dts';
    1.91 +        $getid3->info['audio']['lossless']        = $info_dts['flags']['lossless'];
    1.92 +        $getid3->info['audio']['bitrate_mode']    = $info_dts['bitrate_mode'];
    1.93 +        $getid3->info['audio']['bits_per_sample'] = $info_dts['bits_per_sample'];
    1.94 +        $getid3->info['audio']['sample_rate']     = $info_dts['sample_rate'];
    1.95 +        $getid3->info['audio']['channels']        = $info_dts['channels'];
    1.96 +        $getid3->info['audio']['bitrate']         = $info_dts['bitrate'];
    1.97 +        $getid3->info['playtime_seconds']         = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) / ($info_dts['bitrate'] / 8);
    1.98 +
    1.99 +        return true;
   1.100 +    }
   1.101 +
   1.102 +
   1.103 +    public static function DTSbitrateLookup($index) {
   1.104 +        
   1.105 +        static $lookup = array (
   1.106 +            0  => 32000,
   1.107 +            1  => 56000,
   1.108 +            2  => 64000,
   1.109 +            3  => 96000,
   1.110 +            4  => 112000,
   1.111 +            5  => 128000,
   1.112 +            6  => 192000,
   1.113 +            7  => 224000,
   1.114 +            8  => 256000,
   1.115 +            9  => 320000,
   1.116 +            10 => 384000,
   1.117 +            11 => 448000,
   1.118 +            12 => 512000,
   1.119 +            13 => 576000,
   1.120 +            14 => 640000,
   1.121 +            15 => 768000,
   1.122 +            16 => 960000,
   1.123 +            17 => 1024000,
   1.124 +            18 => 1152000,
   1.125 +            19 => 1280000,
   1.126 +            20 => 1344000,
   1.127 +            21 => 1408000,
   1.128 +            22 => 1411200,
   1.129 +            23 => 1472000,
   1.130 +            24 => 1536000,
   1.131 +            25 => 1920000,
   1.132 +            26 => 2048000,
   1.133 +            27 => 3072000,
   1.134 +            28 => 3840000,
   1.135 +            29 => 'open',
   1.136 +            30 => 'variable',
   1.137 +            31 => 'lossless'
   1.138 +        );
   1.139 +        return @$lookup[$index];
   1.140 +    }
   1.141 +
   1.142 +    
   1.143 +    public static function DTSsampleRateLookup($index) {
   1.144 +        
   1.145 +        static $lookup = array (
   1.146 +            0  => 'invalid',
   1.147 +            1  => 8000,
   1.148 +            2  => 16000,
   1.149 +            3  => 32000,
   1.150 +            4  => 'invalid',
   1.151 +            5  => 'invalid',
   1.152 +            6  => 11025,
   1.153 +            7  => 22050,
   1.154 +            8  => 44100,
   1.155 +            9  => 'invalid',
   1.156 +            10 => 'invalid',
   1.157 +            11 => 12000,
   1.158 +            12 => 24000,
   1.159 +            13 => 48000,
   1.160 +            14 => 'invalid',
   1.161 +            15 => 'invalid'
   1.162 +        );
   1.163 +        return @$lookup[$index];
   1.164 +    }
   1.165 +
   1.166 +    
   1.167 +    public static function DTSbitPerSampleLookup($index) {
   1.168 +        
   1.169 +        static $lookup = array (
   1.170 +            0  => 16,
   1.171 +            1  => 20,
   1.172 +            2  => 24,
   1.173 +            3  => 24,
   1.174 +        );
   1.175 +        return @$lookup[$index];
   1.176 +    }
   1.177 +
   1.178 +    
   1.179 +    public static function DTSnumChannelsLookup($index) {
   1.180 +        
   1.181 +        switch ($index) {
   1.182 +            case 0:
   1.183 +                return 1;
   1.184 +                
   1.185 +            case 1:
   1.186 +            case 2:
   1.187 +            case 3:
   1.188 +            case 4:
   1.189 +                return 2;
   1.190 +                
   1.191 +            case 5:
   1.192 +            case 6:
   1.193 +                return 3;
   1.194 +                
   1.195 +            case 7:
   1.196 +            case 8:
   1.197 +                return 4;
   1.198 +                
   1.199 +            case 9:
   1.200 +                return 5;
   1.201 +                
   1.202 +            case 10:
   1.203 +            case 11:
   1.204 +            case 12:
   1.205 +                return 6;
   1.206 +                
   1.207 +            case 13:
   1.208 +                return 7;
   1.209 +                
   1.210 +            case 14:
   1.211 +            case 15:
   1.212 +                return 8;
   1.213 +        }
   1.214 +        return false;
   1.215 +    }
   1.216 +
   1.217 +    
   1.218 +    public static function DTSchannelArrangementLookup($index) {
   1.219 +        
   1.220 +        static $lookup = array (
   1.221 +            0  => 'A',
   1.222 +            1  => 'A + B (dual mono)',
   1.223 +            2  => 'L + R (stereo)',
   1.224 +            3  => '(L+R) + (L-R) (sum-difference)',
   1.225 +            4  => 'LT + RT (left and right total)',
   1.226 +            5  => 'C + L + R',
   1.227 +            6  => 'L + R + S',
   1.228 +            7  => 'C + L + R + S',
   1.229 +            8  => 'L + R + SL + SR',
   1.230 +            9  => 'C + L + R + SL + SR',
   1.231 +            10 => 'CL + CR + L + R + SL + SR',
   1.232 +            11 => 'C + L + R+ LR + RR + OV',
   1.233 +            12 => 'CF + CR + LF + RF + LR + RR',
   1.234 +            13 => 'CL + C + CR + L + R + SL + SR',
   1.235 +            14 => 'CL + CR + L + R + SL1 + SL2 + SR1 + SR2',
   1.236 +            15 => 'CL + C+ CR + L + R + SL + S + SR',
   1.237 +        );
   1.238 +        return (@$lookup[$index] ? @$lookup[$index] : 'user-defined');
   1.239 +    }
   1.240 +
   1.241 +    
   1.242 +    public static function DTSdialogNormalization($index, $version) {
   1.243 +        
   1.244 +        switch ($version) {
   1.245 +            case 7:
   1.246 +                return 0 - $index;
   1.247 +                
   1.248 +            case 6:
   1.249 +                return 0 - 16 - $index;
   1.250 +        }
   1.251 +        return false;
   1.252 +    }
   1.253 +
   1.254 +}
   1.255 +
   1.256 +
   1.257 +?>
   1.258 \ No newline at end of file