ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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

 getid3_vqf (&$fd, &$ThisFileInfo)
 
 VQFchannelFrequencyLookup ($frequencyid)
 
 VQFcommentNiceNameLookup ($shortname)
 
 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 17 of file module.audio.vqf.php.

Member Function Documentation

◆ Analyze()

getid3_vqf::Analyze ( )

Reimplemented from getid3_handler.

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

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 $info['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 $info['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 $info['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 $info['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 $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';
127 $info['audio']['encoder'] = 'Ahead Nero';
128 break;
129
130 default:
131 $info['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 }
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
fread($bytes)
Definition: getid3.php:1685
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
PrintHexBytes($string, $hex=true, $spaces=true, $htmlsafe=true)
Definition: getid3.lib.php:17
VQFcommentNiceNameLookup($shortname)
VQFchannelFrequencyLookup($frequencyid)
$info
Definition: example_052.php:80

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

+ Here is the call graph for this function:

◆ getid3_vqf()

getid3_vqf::getid3_vqf ( $fd,
$ThisFileInfo 
)

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

19 {
20 // based loosely on code from TTwinVQ by Jurgen Faul <jfaulØgmx*de>
21 // http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
22
23 $ThisFileInfo['fileformat'] = 'vqf';
24 $ThisFileInfo['audio']['dataformat'] = 'vqf';
25 $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
26 $ThisFileInfo['audio']['lossless'] = false;
27
28 // shortcut
29 $ThisFileInfo['vqf']['raw'] = array();
30 $thisfile_vqf = &$ThisFileInfo['vqf'];
31 $thisfile_vqf_raw = &$thisfile_vqf['raw'];
32
33 fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
34 $VQFheaderData = fread($fd, 16);
35
36 $offset = 0;
37 $thisfile_vqf_raw['header_tag'] = substr($VQFheaderData, $offset, 4);
38 if ($thisfile_vqf_raw['header_tag'] != 'TWIN') {
39 $ThisFileInfo['error'][] = 'Expecting "TWIN" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$thisfile_vqf_raw['header_tag'].'"';
40 unset($ThisFileInfo['vqf']);
41 unset($ThisFileInfo['fileformat']);
42 return false;
43 }
44 $offset += 4;
45 $thisfile_vqf_raw['version'] = substr($VQFheaderData, $offset, 8);
46 $offset += 8;
47 $thisfile_vqf_raw['size'] = getid3_lib::BigEndian2Int(substr($VQFheaderData, $offset, 4));
48 $offset += 4;
49
50 while (ftell($fd) < $ThisFileInfo['avdataend']) {
51
52 $ChunkBaseOffset = ftell($fd);
53 $chunkoffset = 0;
54 $ChunkData = fread($fd, 8);
55 $ChunkName = substr($ChunkData, $chunkoffset, 4);
56 if ($ChunkName == 'DATA') {
57 $ThisFileInfo['avdataoffset'] = $ChunkBaseOffset;
58 break;
59 }
60 $chunkoffset += 4;
61 $ChunkSize = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
62 $chunkoffset += 4;
63 if ($ChunkSize > ($ThisFileInfo['avdataend'] - ftell($fd))) {
64 $ThisFileInfo['error'][] = 'Invalid chunk size ('.$ChunkSize.') for chunk "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
65 break;
66 }
67 if ($ChunkSize > 0) {
68 $ChunkData .= fread($fd, $ChunkSize);
69 }
70
71 switch ($ChunkName) {
72 case 'COMM':
73 // shortcut
74 $thisfile_vqf['COMM'] = array();
75 $thisfile_vqf_COMM = &$thisfile_vqf['COMM'];
76
77 $thisfile_vqf_COMM['channel_mode'] = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
78 $chunkoffset += 4;
79 $thisfile_vqf_COMM['bitrate'] = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
80 $chunkoffset += 4;
81 $thisfile_vqf_COMM['sample_rate'] = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
82 $chunkoffset += 4;
83 $thisfile_vqf_COMM['security_level'] = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
84 $chunkoffset += 4;
85
86 $ThisFileInfo['audio']['channels'] = $thisfile_vqf_COMM['channel_mode'] + 1;
87 $ThisFileInfo['audio']['sample_rate'] = $this->VQFchannelFrequencyLookup($thisfile_vqf_COMM['sample_rate']);
88 $ThisFileInfo['audio']['bitrate'] = $thisfile_vqf_COMM['bitrate'] * 1000;
89 $ThisFileInfo['audio']['encoder_options'] = 'CBR' . ceil($ThisFileInfo['audio']['bitrate']/1000);
90
91 if ($ThisFileInfo['audio']['bitrate'] == 0) {
92 $ThisFileInfo['error'][] = 'Corrupt VQF file: bitrate_audio == zero';
93 return false;
94 }
95 break;
96
97 case 'NAME':
98 case 'AUTH':
99 case '(c) ':
100 case 'FILE':
101 case 'COMT':
102 case 'ALBM':
103 $thisfile_vqf['comments'][$this->VQFcommentNiceNameLookup($ChunkName)][] = trim(substr($ChunkData, 8));
104 break;
105
106 case 'DSIZ':
107 $thisfile_vqf['DSIZ'] = getid3_lib::BigEndian2Int(substr($ChunkData, 8, 4));
108 break;
109
110 default:
111 $ThisFileInfo['warning'][] = 'Unhandled chunk type "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
112 break;
113 }
114 }
115
116 $ThisFileInfo['playtime_seconds'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['audio']['bitrate'];
117
118 if (isset($thisfile_vqf['DSIZ']) && (($thisfile_vqf['DSIZ'] != ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'] - strlen('DATA'))))) {
119 switch ($thisfile_vqf['DSIZ']) {
120 case 0:
121 case 1:
122 $ThisFileInfo['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';
123 $ThisFileInfo['audio']['encoder'] = 'Ahead Nero';
124 break;
125
126 default:
127 $ThisFileInfo['warning'][] = 'Probable corrupted file - should be '.$thisfile_vqf['DSIZ'].' bytes, actually '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'] - strlen('DATA'));
128 break;
129 }
130 }
131
132 return true;
133 }

References getid3_lib\BigEndian2Int(), getid3_handler\fread(), getid3_handler\fseek(), getid3_handler\ftell(), VQFchannelFrequencyLookup(), and VQFcommentNiceNameLookup().

+ Here is the call graph for this function:

◆ VQFchannelFrequencyLookup() [1/2]

getid3_vqf::VQFchannelFrequencyLookup (   $frequencyid)

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

135 {
136 static $VQFchannelFrequencyLookup = array(
137 11 => 11025,
138 22 => 22050,
139 44 => 44100
140 );
141 return (isset($VQFchannelFrequencyLookup[$frequencyid]) ? $VQFchannelFrequencyLookup[$frequencyid] : $frequencyid * 1000);
142 }

Referenced by Analyze(), and getid3_vqf().

+ Here is the caller graph for this function:

◆ VQFchannelFrequencyLookup() [2/2]

getid3_vqf::VQFchannelFrequencyLookup (   $frequencyid)

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

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 }

◆ VQFcommentNiceNameLookup() [1/2]

getid3_vqf::VQFcommentNiceNameLookup (   $shortname)

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

144 {
145 static $VQFcommentNiceNameLookup = array(
146 'NAME' => 'title',
147 'AUTH' => 'artist',
148 '(c) ' => 'copyright',
149 'FILE' => 'filename',
150 'COMT' => 'comment',
151 'ALBM' => 'album'
152 );
153 return (isset($VQFcommentNiceNameLookup[$shortname]) ? $VQFcommentNiceNameLookup[$shortname] : $shortname);
154 }

Referenced by Analyze(), and getid3_vqf().

+ Here is the caller graph for this function:

◆ VQFcommentNiceNameLookup() [2/2]

getid3_vqf::VQFcommentNiceNameLookup (   $shortname)

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

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 }

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