23 $ThisFileInfo[
'fileformat'] =
'vqf';
24 $ThisFileInfo[
'audio'][
'dataformat'] =
'vqf';
25 $ThisFileInfo[
'audio'][
'bitrate_mode'] =
'cbr';
26 $ThisFileInfo[
'audio'][
'lossless'] =
false;
29 $ThisFileInfo[
'vqf'][
'raw'] = array();
30 $thisfile_vqf = &$ThisFileInfo[
'vqf'];
31 $thisfile_vqf_raw = &$thisfile_vqf[
'raw'];
33 fseek($fd, $ThisFileInfo[
'avdataoffset'], SEEK_SET);
34 $VQFheaderData = fread($fd, 16);
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']);
45 $thisfile_vqf_raw[
'version'] = substr($VQFheaderData, $offset, 8);
50 while (ftell($fd) < $ThisFileInfo[
'avdataend']) {
52 $ChunkBaseOffset = ftell($fd);
54 $ChunkData = fread($fd, 8);
55 $ChunkName = substr($ChunkData, $chunkoffset, 4);
56 if ($ChunkName ==
'DATA') {
57 $ThisFileInfo[
'avdataoffset'] = $ChunkBaseOffset;
63 if ($ChunkSize > ($ThisFileInfo[
'avdataend'] - ftell($fd))) {
64 $ThisFileInfo[
'error'][] =
'Invalid chunk size ('.$ChunkSize.
') for chunk "'.$ChunkName.
'" at offset '.$ChunkBaseOffset;
68 $ChunkData .= fread($fd, $ChunkSize);
74 $thisfile_vqf[
'COMM'] = array();
75 $thisfile_vqf_COMM = &$thisfile_vqf[
'COMM'];
86 $ThisFileInfo[
'audio'][
'channels'] = $thisfile_vqf_COMM[
'channel_mode'] + 1;
88 $ThisFileInfo[
'audio'][
'bitrate'] = $thisfile_vqf_COMM[
'bitrate'] * 1000;
89 $ThisFileInfo[
'audio'][
'encoder_options'] =
'CBR' . ceil($ThisFileInfo[
'audio'][
'bitrate']/1000);
91 if ($ThisFileInfo[
'audio'][
'bitrate'] == 0) {
92 $ThisFileInfo[
'error'][] =
'Corrupt VQF file: bitrate_audio == zero';
111 $ThisFileInfo[
'warning'][] =
'Unhandled chunk type "'.$ChunkName.
'" at offset '.$ChunkBaseOffset;
116 $ThisFileInfo[
'playtime_seconds'] = (($ThisFileInfo[
'avdataend'] - $ThisFileInfo[
'avdataoffset']) * 8) / $ThisFileInfo[
'audio'][
'bitrate'];
118 if (isset($thisfile_vqf[
'DSIZ']) && (($thisfile_vqf[
'DSIZ'] != ($ThisFileInfo[
'avdataend'] - $ThisFileInfo[
'avdataoffset'] - strlen(
'DATA'))))) {
119 switch ($thisfile_vqf[
'DSIZ']) {
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';
127 $ThisFileInfo[
'warning'][] =
'Probable corrupted file - should be '.$thisfile_vqf[
'DSIZ'].
' bytes, actually '.($ThisFileInfo[
'avdataend'] - $ThisFileInfo[
'avdataoffset'] - strlen(
'DATA'));
136 static $VQFchannelFrequencyLookup = array(
141 return (isset($VQFchannelFrequencyLookup[$frequencyid]) ? $VQFchannelFrequencyLookup[$frequencyid] : $frequencyid * 1000);
145 static $VQFcommentNiceNameLookup = array(
148 '(c) ' =>
'copyright',
149 'FILE' =>
'filename',
153 return (isset($VQFcommentNiceNameLookup[$shortname]) ? $VQFcommentNiceNameLookup[$shortname] : $shortname);