diff e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.tta.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.tta.php	Mon Feb 22 08:02:39 2010 -0500
     1.3 @@ -0,0 +1,125 @@
     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.tta.php                                                 |
    1.21 +// | Module for analyzing TTA Audio files                                 |
    1.22 +// | dependencies: NONE                                                   |
    1.23 +// +----------------------------------------------------------------------+
    1.24 +//
    1.25 +// $Id: module.audio.tta.php,v 1.2 2006/11/02 10:48:01 ah Exp $
    1.26 +
    1.27 +        
    1.28 +        
    1.29 +class getid3_tta extends getid3_handler
    1.30 +{
    1.31 +
    1.32 +    public function Analyze() {
    1.33 +
    1.34 +        $getid3 = $this->getid3;
    1.35 +        
    1.36 +        $getid3->info['fileformat']            = 'tta';
    1.37 +        $getid3->info['audio']['dataformat']   = 'tta';
    1.38 +        $getid3->info['audio']['lossless']     = true;
    1.39 +        $getid3->info['audio']['bitrate_mode'] = 'vbr';
    1.40 +
    1.41 +        fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
    1.42 +        $tta_header = fread($getid3->fp, 26);
    1.43 +
    1.44 +        $getid3->info['tta']['magic'] = 'TTA';  // Magic bytes
    1.45 +        
    1.46 +        switch ($tta_header{3}) {
    1.47 +        
    1.48 +            case "\x01": // TTA v1.x
    1.49 +            case "\x02": // TTA v1.x
    1.50 +            case "\x03": // TTA v1.x
    1.51 +                
    1.52 +                // "It was the demo-version of the TTA encoder. There is no released format with such header. TTA encoder v1 is not supported about a year."
    1.53 +                $getid3->info['tta']['major_version'] = 1;
    1.54 +                $getid3->info['avdataoffset'] += 16;
    1.55 +                
    1.56 +                getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4, 
    1.57 +                    array (
    1.58 +                        'channels'            => 2,
    1.59 +                        'bits_per_sample'     => 2,
    1.60 +                        'sample_rate'         => 4,
    1.61 +                        'samples_per_channel' => 4
    1.62 +                    )
    1.63 +                );                
    1.64 +                $getid3->info['tta']['compression_level'] = ord($tta_header{3});
    1.65 +                
    1.66 +                $getid3->info['audio']['encoder_options']   = '-e'.$getid3->info['tta']['compression_level'];
    1.67 +                $getid3->info['playtime_seconds']           = $getid3->info['tta']['samples_per_channel'] / $getid3->info['tta']['sample_rate'];
    1.68 +                break;
    1.69 +
    1.70 +            case '2': // TTA v2.x
    1.71 +                // "I have hurried to release the TTA 2.0 encoder. Format documentation is removed from our site. This format still in development. Please wait the TTA2 format, encoder v4."
    1.72 +                $getid3->info['tta']['major_version'] = 2;
    1.73 +                $getid3->info['avdataoffset'] += 20;
    1.74 +
    1.75 +                getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4, 
    1.76 +                    array (
    1.77 +                        'compression_level' => 2,
    1.78 +                        'audio_format'      => 2,
    1.79 +                        'channels'          => 2,
    1.80 +                        'bits_per_sample'   => 2,
    1.81 +                        'sample_rate'       => 4,
    1.82 +                        'data_length'       => 4
    1.83 +                    )
    1.84 +                );                
    1.85 +                
    1.86 +                $getid3->info['audio']['encoder_options']   = '-e'.$getid3->info['tta']['compression_level'];
    1.87 +                $getid3->info['playtime_seconds']           = $getid3->info['tta']['data_length'] / $getid3->info['tta']['sample_rate'];
    1.88 +                break;
    1.89 +
    1.90 +            case '1': // TTA v3.x
    1.91 +                // "This is a first stable release of the TTA format. It will be supported by the encoders v3 or higher."
    1.92 +                $getid3->info['tta']['major_version'] = 3;
    1.93 +                $getid3->info['avdataoffset'] += 26;
    1.94 +
    1.95 +                getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4, 
    1.96 +                    array (
    1.97 +                        'audio_format'   => 2,
    1.98 +                        'channels'       => 2,
    1.99 +                        'bits_per_sample'=> 2,
   1.100 +                        'sample_rate'    => 4,
   1.101 +                        'data_length'    => 4,
   1.102 +                        'crc32_footer'   => -4,     // string
   1.103 +                        'seek_point'     => 4 
   1.104 +                    )
   1.105 +                );                
   1.106 +
   1.107 +                $getid3->info['playtime_seconds']    = $getid3->info['tta']['data_length'] / $getid3->info['tta']['sample_rate'];
   1.108 +                break;
   1.109 +
   1.110 +            default:
   1.111 +                throw new getid3_exception('This version of getID3() only knows how to handle TTA v1, v2 and v3 - it may not work correctly with this file which appears to be TTA v'.$tta_header{3});
   1.112 +                return false;
   1.113 +                break;
   1.114 +        }
   1.115 +
   1.116 +        $getid3->info['audio']['encoder']         = 'TTA v'.$getid3->info['tta']['major_version'];
   1.117 +        $getid3->info['audio']['bits_per_sample'] = $getid3->info['tta']['bits_per_sample'];
   1.118 +        $getid3->info['audio']['sample_rate']     = $getid3->info['tta']['sample_rate'];
   1.119 +        $getid3->info['audio']['channels']        = $getid3->info['tta']['channels'];
   1.120 +        $getid3->info['audio']['bitrate']         = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['playtime_seconds'];
   1.121 +
   1.122 +        return true;
   1.123 +    }
   1.124 +
   1.125 +}
   1.126 +
   1.127 +
   1.128 +?>
   1.129 \ No newline at end of file