ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
getid3_vqf Class Reference

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

+ Collaboration diagram for getid3_vqf:

Public Member Functions

 getid3_vqf (&$fd, &$ThisFileInfo)
 
 VQFchannelFrequencyLookup ($frequencyid)
 
 VQFcommentNiceNameLookup ($shortname)
 

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

◆ getid3_vqf()

getid3_vqf::getid3_vqf ( $fd,
$ThisFileInfo 
)

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

References getid3_lib\BigEndian2Int(), VQFchannelFrequencyLookup(), and VQFcommentNiceNameLookup().

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  }
VQFcommentNiceNameLookup($shortname)
VQFchannelFrequencyLookup($frequencyid)
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:

◆ VQFchannelFrequencyLookup()

getid3_vqf::VQFchannelFrequencyLookup (   $frequencyid)

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

Referenced by getid3_vqf().

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  }
+ Here is the caller graph for this function:

◆ VQFcommentNiceNameLookup()

getid3_vqf::VQFcommentNiceNameLookup (   $shortname)

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

Referenced by getid3_vqf().

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  }
+ Here is the caller graph for this function:

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