37 {
38 $info = &$this->getid3->info;
39
40 $info[
'fileformat'] =
'tta';
41 $info[
'audio'][
'dataformat'] =
'tta';
42 $info[
'audio'][
'lossless'] =
true;
43 $info[
'audio'][
'bitrate_mode'] =
'vbr';
44
45 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
46 $ttaheader =
fread($this->getid3->fp, 26);
47
48 $info[
'tta'][
'magic'] = substr($ttaheader, 0, 3);
49 $magic = 'TTA';
50 if (
$info[
'tta'][
'magic'] != $magic) {
52 unset(
$info[
'fileformat']);
53 unset(
$info[
'audio']);
55
56 return false;
57 }
58
59 switch ($ttaheader{3}) {
60 case "\x01":
61 case "\x02":
62 case "\x03":
63
64 $info[
'tta'][
'major_version'] = 1;
65 $info[
'avdataoffset'] += 16;
66
67 $info[
'tta'][
'compression_level'] = ord($ttaheader{3});
72
73 $info[
'audio'][
'encoder_options'] =
'-e'.$info[
'tta'][
'compression_level'];
74 $info[
'playtime_seconds'] =
$info[
'tta'][
'samples_per_channel'] /
$info[
'tta'][
'sample_rate'];
75 break;
76
77 case '2':
78
79 $info[
'tta'][
'major_version'] = 2;
80 $info[
'avdataoffset'] += 20;
81
88
89 $info[
'audio'][
'encoder_options'] =
'-e'.$info[
'tta'][
'compression_level'];
90 $info[
'playtime_seconds'] =
$info[
'tta'][
'data_length'] /
$info[
'tta'][
'sample_rate'];
91 break;
92
93 case '1':
94
95 $info[
'tta'][
'major_version'] = 3;
96 $info[
'avdataoffset'] += 26;
97
103 $info[
'tta'][
'crc32_footer'] = substr($ttaheader, 18, 4);
105
106 $info[
'playtime_seconds'] =
$info[
'tta'][
'data_length'] /
$info[
'tta'][
'sample_rate'];
107 break;
108
109 default:
110 $info[
'error'][] =
'This version of GetId3Core() ['.$this->getid3->version().
'] only knows how to handle TTA v1 and v2 - it may not work correctly with this file which appears to be TTA v'.$ttaheader{3};
111
112 return false;
113 break;
114 }
115
116 $info[
'audio'][
'encoder'] =
'TTA v'.$info[
'tta'][
'major_version'];
117 $info[
'audio'][
'bits_per_sample'] =
$info[
'tta'][
'bits_per_sample'];
118 $info[
'audio'][
'sample_rate'] =
$info[
'tta'][
'sample_rate'];
119 $info[
'audio'][
'channels'] =
$info[
'tta'][
'channels'];
120 $info[
'audio'][
'bitrate'] = ((
$info[
'avdataend'] -
$info[
'avdataoffset']) * 8) /
$info[
'playtime_seconds'];
121
122 return true;
123 }
fseek($bytes, $whence=SEEK_SET)
static LittleEndian2Int($byteword, $signed=false)
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')