ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GetId3\Module\Audio\Vqf Class Reference

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

+ Inheritance diagram for GetId3\Module\Audio\Vqf:
+ Collaboration diagram for GetId3\Module\Audio\Vqf:

Public Member Functions

 analyze ()
 
 VQFchannelFrequencyLookup ($frequencyid)
 @staticvar array $VQFchannelFrequencyLookup More...
 
 VQFcommentNiceNameLookup ($shortname)
 @staticvar array $VQFcommentNiceNameLookup More...
 
- Public Member Functions inherited from GetId3\Handler\BaseHandler
 __construct (GetId3Core $getid3, $call_module=null)
 
 analyze ()
 Analyze from file pointer. More...
 
 AnalyzeString (&$string)
 Analyze from string instead. More...
 
 saveAttachment (&$ThisFileInfoIndex, $filename, $offset, $length)
 

Additional Inherited Members

- Protected Member Functions inherited from GetId3\Handler\BaseHandler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
- Protected Attributes inherited from GetId3\Handler\BaseHandler
 $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 //.

module for analyzing VQF audio files

Author
James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g http://www.getid3.org

Definition at line 29 of file Vqf.php.

Member Function Documentation

◆ analyze()

GetId3\Module\Audio\Vqf::analyze ( )
Returns
boolean

Reimplemented from GetId3\Handler\BaseHandler.

Definition at line 35 of file Vqf.php.

36 {
37 $info = &$this->getid3->info;
38
39 // based loosely on code from TTwinVQ by Jurgen Faul <jfaulØgmx*de>
40 // http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
41
42 $info['fileformat'] = 'vqf';
43 $info['audio']['dataformat'] = 'vqf';
44 $info['audio']['bitrate_mode'] = 'cbr';
45 $info['audio']['lossless'] = false;
46
47 // shortcut
48 $info['vqf']['raw'] = array();
49 $thisfile_vqf = &$info['vqf'];
50 $thisfile_vqf_raw = &$thisfile_vqf['raw'];
51
52 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
53 $VQFheaderData = fread($this->getid3->fp, 16);
54
55 $offset = 0;
56 $thisfile_vqf_raw['header_tag'] = substr($VQFheaderData, $offset, 4);
57 $magic = 'TWIN';
58 if ($thisfile_vqf_raw['header_tag'] != $magic) {
59 $info['error'][] = 'Expecting "'.Helper::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.Helper::PrintHexBytes($thisfile_vqf_raw['header_tag']).'"';
60 unset($info['vqf']);
61 unset($info['fileformat']);
62
63 return false;
64 }
65 $offset += 4;
66 $thisfile_vqf_raw['version'] = substr($VQFheaderData, $offset, 8);
67 $offset += 8;
68 $thisfile_vqf_raw['size'] = Helper::BigEndian2Int(substr($VQFheaderData, $offset, 4));
69 $offset += 4;
70
71 while (ftell($this->getid3->fp) < $info['avdataend']) {
72
73 $ChunkBaseOffset = ftell($this->getid3->fp);
74 $chunkoffset = 0;
75 $ChunkData = fread($this->getid3->fp, 8);
76 $ChunkName = substr($ChunkData, $chunkoffset, 4);
77 if ($ChunkName == 'DATA') {
78 $info['avdataoffset'] = $ChunkBaseOffset;
79 break;
80 }
81 $chunkoffset += 4;
82 $ChunkSize = Helper::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
83 $chunkoffset += 4;
84 if ($ChunkSize > ($info['avdataend'] - ftell($this->getid3->fp))) {
85 $info['error'][] = 'Invalid chunk size ('.$ChunkSize.') for chunk "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
86 break;
87 }
88 if ($ChunkSize > 0) {
89 $ChunkData .= fread($this->getid3->fp, $ChunkSize);
90 }
91
92 switch ($ChunkName) {
93 case 'COMM':
94 // shortcut
95 $thisfile_vqf['COMM'] = array();
96 $thisfile_vqf_COMM = &$thisfile_vqf['COMM'];
97
98 $thisfile_vqf_COMM['channel_mode'] = Helper::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
99 $chunkoffset += 4;
100 $thisfile_vqf_COMM['bitrate'] = Helper::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
101 $chunkoffset += 4;
102 $thisfile_vqf_COMM['sample_rate'] = Helper::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
103 $chunkoffset += 4;
104 $thisfile_vqf_COMM['security_level'] = Helper::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
105 $chunkoffset += 4;
106
107 $info['audio']['channels'] = $thisfile_vqf_COMM['channel_mode'] + 1;
108 $info['audio']['sample_rate'] = $this->VQFchannelFrequencyLookup($thisfile_vqf_COMM['sample_rate']);
109 $info['audio']['bitrate'] = $thisfile_vqf_COMM['bitrate'] * 1000;
110 $info['audio']['encoder_options'] = 'CBR' . ceil($info['audio']['bitrate']/1000);
111
112 if ($info['audio']['bitrate'] == 0) {
113 $info['error'][] = 'Corrupt VQF file: bitrate_audio == zero';
114
115 return false;
116 }
117 break;
118
119 case 'NAME':
120 case 'AUTH':
121 case '(c) ':
122 case 'FILE':
123 case 'COMT':
124 case 'ALBM':
125 $thisfile_vqf['comments'][$this->VQFcommentNiceNameLookup($ChunkName)][] = trim(substr($ChunkData, 8));
126 break;
127
128 case 'DSIZ':
129 $thisfile_vqf['DSIZ'] = Helper::BigEndian2Int(substr($ChunkData, 8, 4));
130 break;
131
132 default:
133 $info['warning'][] = 'Unhandled chunk type "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
134 break;
135 }
136 }
137
138 $info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['audio']['bitrate'];
139
140 if (isset($thisfile_vqf['DSIZ']) && (($thisfile_vqf['DSIZ'] != ($info['avdataend'] - $info['avdataoffset'] - strlen('DATA'))))) {
141 switch ($thisfile_vqf['DSIZ']) {
142 case 0:
143 case 1:
144 $info['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';
145 $info['audio']['encoder'] = 'Ahead Nero';
146 break;
147
148 default:
149 $info['warning'][] = 'Probable corrupted file - should be '.$thisfile_vqf['DSIZ'].' bytes, actually '.($info['avdataend'] - $info['avdataoffset'] - strlen('DATA'));
150 break;
151 }
152 }
153
154 return true;
155 }
fseek($bytes, $whence=SEEK_SET)
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: Helper.php:374
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Definition: Helper.php:36
VQFchannelFrequencyLookup($frequencyid)
@staticvar array $VQFchannelFrequencyLookup
Definition: Vqf.php:163
VQFcommentNiceNameLookup($shortname)
@staticvar array $VQFcommentNiceNameLookup
Definition: Vqf.php:180
$info
Definition: example_052.php:80

References $info, GetId3\Lib\Helper\BigEndian2Int(), GetId3\Handler\BaseHandler\fread(), GetId3\Handler\BaseHandler\fseek(), GetId3\Handler\BaseHandler\ftell(), GetId3\Lib\Helper\PrintHexBytes(), GetId3\Module\Audio\Vqf\VQFchannelFrequencyLookup(), and GetId3\Module\Audio\Vqf\VQFcommentNiceNameLookup().

+ Here is the call graph for this function:

◆ VQFchannelFrequencyLookup()

GetId3\Module\Audio\Vqf::VQFchannelFrequencyLookup (   $frequencyid)

@staticvar array $VQFchannelFrequencyLookup

Parameters
type$frequencyid
Returns
type

Definition at line 163 of file Vqf.php.

164 {
165 static $VQFchannelFrequencyLookup = array(
166 11 => 11025,
167 22 => 22050,
168 44 => 44100
169 );
170
171 return (isset($VQFchannelFrequencyLookup[$frequencyid]) ? $VQFchannelFrequencyLookup[$frequencyid] : $frequencyid * 1000);
172 }

Referenced by GetId3\Module\Audio\Vqf\analyze().

+ Here is the caller graph for this function:

◆ VQFcommentNiceNameLookup()

GetId3\Module\Audio\Vqf::VQFcommentNiceNameLookup (   $shortname)

@staticvar array $VQFcommentNiceNameLookup

Parameters
type$shortname
Returns
type

Definition at line 180 of file Vqf.php.

181 {
182 static $VQFcommentNiceNameLookup = array(
183 'NAME' => 'title',
184 'AUTH' => 'artist',
185 '(c) ' => 'copyright',
186 'FILE' => 'filename',
187 'COMT' => 'comment',
188 'ALBM' => 'album'
189 );
190
191 return (isset($VQFcommentNiceNameLookup[$shortname]) ? $VQFcommentNiceNameLookup[$shortname] : $shortname);
192 }

Referenced by GetId3\Module\Audio\Vqf\analyze().

+ Here is the caller graph for this function:

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