ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
getid3_vqf Class Reference

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

+ Inheritance diagram for getid3_vqf:
+ Collaboration diagram for getid3_vqf:

Public Member Functions

 Analyze ()
 
 VQFchannelFrequencyLookup ($frequencyid)
 
 VQFcommentNiceNameLookup ($shortname)
 
- 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 18 of file module.audio.vqf.php.

Member Function Documentation

◆ Analyze()

getid3_vqf::Analyze ( )

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

References $info, array, getid3_lib\BigEndian2Int(), getid3_handler\error(), getid3_handler\fread(), getid3_handler\fseek(), getid3_handler\ftell(), getid3_lib\PrintHexBytes(), VQFchannelFrequencyLookup(), VQFcommentNiceNameLookup(), and getid3_handler\warning().

20  {
21  $info = &$this->getid3->info;
22 
23  // based loosely on code from TTwinVQ by Jurgen Faul <jfaulØgmx*de>
24  // http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
25 
26  $info['fileformat'] = 'vqf';
27  $info['audio']['dataformat'] = 'vqf';
28  $info['audio']['bitrate_mode'] = 'cbr';
29  $info['audio']['lossless'] = false;
30 
31  // shortcut
32  $info['vqf']['raw'] = array();
33  $thisfile_vqf = &$info['vqf'];
34  $thisfile_vqf_raw = &$thisfile_vqf['raw'];
35 
36  $this->fseek($info['avdataoffset']);
37  $VQFheaderData = $this->fread(16);
38 
39  $offset = 0;
40  $thisfile_vqf_raw['header_tag'] = substr($VQFheaderData, $offset, 4);
41  $magic = 'TWIN';
42  if ($thisfile_vqf_raw['header_tag'] != $magic) {
43  $this->error('Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($thisfile_vqf_raw['header_tag']).'"');
44  unset($info['vqf']);
45  unset($info['fileformat']);
46  return false;
47  }
48  $offset += 4;
49  $thisfile_vqf_raw['version'] = substr($VQFheaderData, $offset, 8);
50  $offset += 8;
51  $thisfile_vqf_raw['size'] = getid3_lib::BigEndian2Int(substr($VQFheaderData, $offset, 4));
52  $offset += 4;
53 
54  while ($this->ftell() < $info['avdataend']) {
55 
56  $ChunkBaseOffset = $this->ftell();
57  $chunkoffset = 0;
58  $ChunkData = $this->fread(8);
59  $ChunkName = substr($ChunkData, $chunkoffset, 4);
60  if ($ChunkName == 'DATA') {
61  $info['avdataoffset'] = $ChunkBaseOffset;
62  break;
63  }
64  $chunkoffset += 4;
65  $ChunkSize = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
66  $chunkoffset += 4;
67  if ($ChunkSize > ($info['avdataend'] - $this->ftell())) {
68  $this->error('Invalid chunk size ('.$ChunkSize.') for chunk "'.$ChunkName.'" at offset '.$ChunkBaseOffset);
69  break;
70  }
71  if ($ChunkSize > 0) {
72  $ChunkData .= $this->fread($ChunkSize);
73  }
74 
75  switch ($ChunkName) {
76  case 'COMM':
77  // shortcut
78  $thisfile_vqf['COMM'] = array();
79  $thisfile_vqf_COMM = &$thisfile_vqf['COMM'];
80 
81  $thisfile_vqf_COMM['channel_mode'] = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
82  $chunkoffset += 4;
83  $thisfile_vqf_COMM['bitrate'] = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
84  $chunkoffset += 4;
85  $thisfile_vqf_COMM['sample_rate'] = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
86  $chunkoffset += 4;
87  $thisfile_vqf_COMM['security_level'] = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
88  $chunkoffset += 4;
89 
90  $info['audio']['channels'] = $thisfile_vqf_COMM['channel_mode'] + 1;
91  $info['audio']['sample_rate'] = $this->VQFchannelFrequencyLookup($thisfile_vqf_COMM['sample_rate']);
92  $info['audio']['bitrate'] = $thisfile_vqf_COMM['bitrate'] * 1000;
93  $info['audio']['encoder_options'] = 'CBR' . ceil($info['audio']['bitrate']/1000);
94 
95  if ($info['audio']['bitrate'] == 0) {
96  $this->error('Corrupt VQF file: bitrate_audio == zero');
97  return false;
98  }
99  break;
100 
101  case 'NAME':
102  case 'AUTH':
103  case '(c) ':
104  case 'FILE':
105  case 'COMT':
106  case 'ALBM':
107  $thisfile_vqf['comments'][$this->VQFcommentNiceNameLookup($ChunkName)][] = trim(substr($ChunkData, 8));
108  break;
109 
110  case 'DSIZ':
111  $thisfile_vqf['DSIZ'] = getid3_lib::BigEndian2Int(substr($ChunkData, 8, 4));
112  break;
113 
114  default:
115  $this->warning('Unhandled chunk type "'.$ChunkName.'" at offset '.$ChunkBaseOffset);
116  break;
117  }
118  }
119 
120  $info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['audio']['bitrate'];
121 
122  if (isset($thisfile_vqf['DSIZ']) && (($thisfile_vqf['DSIZ'] != ($info['avdataend'] - $info['avdataoffset'] - strlen('DATA'))))) {
123  switch ($thisfile_vqf['DSIZ']) {
124  case 0:
125  case 1:
126  $this->warning('Invalid DSIZ value "'.$thisfile_vqf['DSIZ'].'". This is known to happen with VQF files encoded by Ahead Nero, and seems to be its way of saying this is TwinVQF v'.($thisfile_vqf['DSIZ'] + 1).'.0');
127  $info['audio']['encoder'] = 'Ahead Nero';
128  break;
129 
130  default:
131  $this->warning('Probable corrupted file - should be '.$thisfile_vqf['DSIZ'].' bytes, actually '.($info['avdataend'] - $info['avdataoffset'] - strlen('DATA')));
132  break;
133  }
134  }
135 
136  return true;
137  }
VQFcommentNiceNameLookup($shortname)
error($text)
Definition: getid3.php:1752
warning($text)
Definition: getid3.php:1758
VQFchannelFrequencyLookup($frequencyid)
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Definition: getid3.lib.php:18
fread($bytes)
Definition: getid3.php:1683
Create styles array
The data for the language used.
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1711
$info
Definition: index.php:5
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:263
+ Here is the call graph for this function:

◆ VQFchannelFrequencyLookup()

getid3_vqf::VQFchannelFrequencyLookup (   $frequencyid)

Definition at line 139 of file module.audio.vqf.php.

References array.

Referenced by Analyze().

139  {
140  static $VQFchannelFrequencyLookup = array(
141  11 => 11025,
142  22 => 22050,
143  44 => 44100
144  );
145  return (isset($VQFchannelFrequencyLookup[$frequencyid]) ? $VQFchannelFrequencyLookup[$frequencyid] : $frequencyid * 1000);
146  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ VQFcommentNiceNameLookup()

getid3_vqf::VQFcommentNiceNameLookup (   $shortname)

Definition at line 148 of file module.audio.vqf.php.

References array.

Referenced by Analyze().

148  {
149  static $VQFcommentNiceNameLookup = array(
150  'NAME' => 'title',
151  'AUTH' => 'artist',
152  '(c) ' => 'copyright',
153  'FILE' => 'filename',
154  'COMT' => 'comment',
155  'ALBM' => 'album'
156  );
157  return (isset($VQFcommentNiceNameLookup[$shortname]) ? $VQFcommentNiceNameLookup[$shortname] : $shortname);
158  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

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