ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
getid3_tta Class Reference

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g // More...

+ Inheritance diagram for getid3_tta:
+ Collaboration diagram for getid3_tta:

Public Member Functions

 getid3_tta (&$fd, &$ThisFileInfo)
 
 Analyze ()
 
- Public Member Functions inherited from getid3_handler
 __construct (getID3 $getid3, $call_module=null)
 
 Analyze ()
 
 AnalyzeString ($string)
 
 setStringMode ($string)
 
 saveAttachment ($name, $offset, $length, $image_mime=null)
 

Additional Inherited Members

- Protected Member Functions inherited from getid3_handler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
 notice ($text)
 
- Protected Attributes inherited from getid3_handler
 $getid3
 
 $data_string_flag = false
 
 $data_string = ''
 
 $data_string_position = 0
 
 $data_string_length = 0
 

Detailed Description

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //

Definition at line 17 of file module.audio.tta.php.

Member Function Documentation

◆ Analyze()

getid3_tta::Analyze ( )

Definition at line 21 of file module.audio.tta.php.

References $info, getid3_handler\fread(), getid3_handler\fseek(), getid3_lib\LittleEndian2Int(), and getid3_lib\PrintHexBytes().

21  {
22  $info = &$this->getid3->info;
23 
24  $info['fileformat'] = 'tta';
25  $info['audio']['dataformat'] = 'tta';
26  $info['audio']['lossless'] = true;
27  $info['audio']['bitrate_mode'] = 'vbr';
28 
29  $this->fseek($info['avdataoffset']);
30  $ttaheader = $this->fread(26);
31 
32  $info['tta']['magic'] = substr($ttaheader, 0, 3);
33  $magic = 'TTA';
34  if ($info['tta']['magic'] != $magic) {
35  $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['tta']['magic']).'"';
36  unset($info['fileformat']);
37  unset($info['audio']);
38  unset($info['tta']);
39  return false;
40  }
41 
42  switch ($ttaheader{3}) {
43  case "\x01": // TTA v1.x
44  case "\x02": // TTA v1.x
45  case "\x03": // TTA v1.x
46  // "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."
47  $info['tta']['major_version'] = 1;
48  $info['avdataoffset'] += 16;
49 
50  $info['tta']['compression_level'] = ord($ttaheader{3});
51  $info['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2));
52  $info['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
53  $info['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 4));
54  $info['tta']['samples_per_channel'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12, 4));
55 
56  $info['audio']['encoder_options'] = '-e'.$info['tta']['compression_level'];
57  $info['playtime_seconds'] = $info['tta']['samples_per_channel'] / $info['tta']['sample_rate'];
58  break;
59 
60  case '2': // TTA v2.x
61  // "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."
62  $info['tta']['major_version'] = 2;
63  $info['avdataoffset'] += 20;
64 
65  $info['tta']['compression_level'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2));
66  $info['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
67  $info['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 2));
68  $info['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 10, 2));
69  $info['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12, 4));
70  $info['tta']['data_length'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 16, 4));
71 
72  $info['audio']['encoder_options'] = '-e'.$info['tta']['compression_level'];
73  $info['playtime_seconds'] = $info['tta']['data_length'] / $info['tta']['sample_rate'];
74  break;
75 
76  case '1': // TTA v3.x
77  // "This is a first stable release of the TTA format. It will be supported by the encoders v3 or higher."
78  $info['tta']['major_version'] = 3;
79  $info['avdataoffset'] += 26;
80 
81  $info['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2)); // getid3_riff::wFormatTagLookup()
82  $info['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
83  $info['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 2));
84  $info['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 10, 4));
85  $info['tta']['data_length'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 14, 4));
86  $info['tta']['crc32_footer'] = substr($ttaheader, 18, 4);
87  $info['tta']['seek_point'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 22, 4));
88 
89  $info['playtime_seconds'] = $info['tta']['data_length'] / $info['tta']['sample_rate'];
90  break;
91 
92  default:
93  $info['error'][] = 'This version of getID3() ['.$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};
94  return false;
95  break;
96  }
97 
98  $info['audio']['encoder'] = 'TTA v'.$info['tta']['major_version'];
99  $info['audio']['bits_per_sample'] = $info['tta']['bits_per_sample'];
100  $info['audio']['sample_rate'] = $info['tta']['sample_rate'];
101  $info['audio']['channels'] = $info['tta']['channels'];
102  $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
103 
104  return true;
105  }
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266
$info
Definition: example_052.php:80
fread($bytes)
Definition: getid3.php:1685
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
PrintHexBytes($string, $hex=true, $spaces=true, $htmlsafe=true)
Definition: getid3.lib.php:17
+ Here is the call graph for this function:

◆ getid3_tta()

getid3_tta::getid3_tta ( $fd,
$ThisFileInfo 
)

Definition at line 20 of file module.audio.tta.php.

References getid3_handler\fread(), getid3_handler\fseek(), and getid3_lib\LittleEndian2Int().

20  {
21 
22  $ThisFileInfo['fileformat'] = 'tta';
23  $ThisFileInfo['audio']['dataformat'] = 'tta';
24  $ThisFileInfo['audio']['lossless'] = true;
25  $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
26 
27  fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
28  $ttaheader = fread($fd, 26);
29 
30  $ThisFileInfo['tta']['magic'] = substr($ttaheader, 0, 3);
31  if ($ThisFileInfo['tta']['magic'] != 'TTA') {
32  $ThisFileInfo['error'][] = 'Expecting "TTA" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$ThisFileInfo['tta']['magic'].'"';
33  unset($ThisFileInfo['fileformat']);
34  unset($ThisFileInfo['audio']);
35  unset($ThisFileInfo['tta']);
36  return false;
37  }
38 
39  switch ($ttaheader{3}) {
40  case "\x01": // TTA v1.x
41  case "\x02": // TTA v1.x
42  case "\x03": // TTA v1.x
43  // "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."
44  $ThisFileInfo['tta']['major_version'] = 1;
45  $ThisFileInfo['avdataoffset'] += 16;
46 
47  $ThisFileInfo['tta']['compression_level'] = ord($ttaheader{3});
48  $ThisFileInfo['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2));
49  $ThisFileInfo['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
50  $ThisFileInfo['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 4));
51  $ThisFileInfo['tta']['samples_per_channel'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12, 4));
52 
53  $ThisFileInfo['audio']['encoder_options'] = '-e'.$ThisFileInfo['tta']['compression_level'];
54  $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['tta']['samples_per_channel'] / $ThisFileInfo['tta']['sample_rate'];
55  break;
56 
57  case '2': // TTA v2.x
58  // "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."
59  $ThisFileInfo['tta']['major_version'] = 2;
60  $ThisFileInfo['avdataoffset'] += 20;
61 
62  $ThisFileInfo['tta']['compression_level'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2));
63  $ThisFileInfo['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
64  $ThisFileInfo['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 2));
65  $ThisFileInfo['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 10, 2));
66  $ThisFileInfo['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12, 4));
67  $ThisFileInfo['tta']['data_length'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 16, 4));
68 
69  $ThisFileInfo['audio']['encoder_options'] = '-e'.$ThisFileInfo['tta']['compression_level'];
70  $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['tta']['data_length'] / $ThisFileInfo['tta']['sample_rate'];
71  break;
72 
73  case '1': // TTA v3.x
74  // "This is a first stable release of the TTA format. It will be supported by the encoders v3 or higher."
75  $ThisFileInfo['tta']['major_version'] = 3;
76  $ThisFileInfo['avdataoffset'] += 26;
77 
78  $ThisFileInfo['tta']['audio_format'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 4, 2)); // getid3_riff::RIFFwFormatTagLookup()
79  $ThisFileInfo['tta']['channels'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 6, 2));
80  $ThisFileInfo['tta']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 8, 2));
81  $ThisFileInfo['tta']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 10, 4));
82  $ThisFileInfo['tta']['data_length'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 14, 4));
83  $ThisFileInfo['tta']['crc32_footer'] = substr($ttaheader, 18, 4);
84  $ThisFileInfo['tta']['seek_point'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 22, 4));
85 
86  $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['tta']['data_length'] / $ThisFileInfo['tta']['sample_rate'];
87  break;
88 
89  default:
90  $ThisFileInfo['error'][] = 'This version of getID3() 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};
91  return false;
92  break;
93  }
94 
95  $ThisFileInfo['audio']['encoder'] = 'TTA v'.$ThisFileInfo['tta']['major_version'];
96  $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['tta']['bits_per_sample'];
97  $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['tta']['sample_rate'];
98  $ThisFileInfo['audio']['channels'] = $ThisFileInfo['tta']['channels'];
99  $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
100 
101  return true;
102  }
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266
fread($bytes)
Definition: getid3.php:1685
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: