ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
getid3_mpc Class Reference

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

+ Inheritance diagram for getid3_mpc:
+ Collaboration diagram for getid3_mpc:

Public Member Functions

 getid3_mpc (&$fd, &$ThisFileInfo)
 
 MPCprofileNameLookup ($profileid)
 
 MPCfrequencyLookup ($frequencyid)
 
 MPCpeakDBLookup ($intvalue)
 
 MPCencoderVersionLookup ($encoderversion)
 
 Analyze ()
 
 ParseMPCsv8 ()
 
 ParseMPCsv7 ()
 
 ParseMPCsv6 ()
 
 MPCprofileNameLookup ($profileid)
 
 MPCfrequencyLookup ($frequencyid)
 
 MPCpeakDBLookup ($intvalue)
 
 MPCencoderVersionLookup ($encoderversion)
 
 SV8variableLengthInteger ($data, &$packetLength, $maxHandledPacketLength=9)
 
 MPCsv8PacketName ($packetKey)
 
- 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.mpc.php.

Member Function Documentation

◆ Analyze()

getid3_mpc::Analyze ( )

Definition at line 21 of file module.audio.mpc.php.

References $info, getid3_handler\fread(), getid3_handler\fseek(), ParseMPCsv6(), ParseMPCsv7(), ParseMPCsv8(), and getid3_lib\PrintHexBytes().

21  {
22  $info = &$this->getid3->info;
23 
24  $info['mpc']['header'] = array();
25  $thisfile_mpc_header = &$info['mpc']['header'];
26 
27  $info['fileformat'] = 'mpc';
28  $info['audio']['dataformat'] = 'mpc';
29  $info['audio']['bitrate_mode'] = 'vbr';
30  $info['audio']['channels'] = 2; // up to SV7 the format appears to have been hardcoded for stereo only
31  $info['audio']['lossless'] = false;
32 
33  $this->fseek($info['avdataoffset']);
34  $MPCheaderData = $this->fread(4);
35  $info['mpc']['header']['preamble'] = substr($MPCheaderData, 0, 4); // should be 'MPCK' (SV8) or 'MP+' (SV7), otherwise possible stream data (SV4-SV6)
36  if (preg_match('#^MPCK#', $info['mpc']['header']['preamble'])) {
37 
38  // this is SV8
39  return $this->ParseMPCsv8();
40 
41  } elseif (preg_match('#^MP\+#', $info['mpc']['header']['preamble'])) {
42 
43  // this is SV7
44  return $this->ParseMPCsv7();
45 
46  } elseif (preg_match('/^[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0]/s', $MPCheaderData)) {
47 
48  // this is SV4 - SV6, handle seperately
49  return $this->ParseMPCsv6();
50 
51  } else {
52 
53  $info['error'][] = 'Expecting "MP+" or "MPCK" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($MPCheaderData, 0, 4)).'"';
54  unset($info['fileformat']);
55  unset($info['mpc']);
56  return false;
57 
58  }
59  return false;
60  }
$info
Definition: example_052.php:80
fread($bytes)
Definition: getid3.php:1685
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
PrintHexBytes($string, $hex=true, $spaces=true, $htmlsafe=true)
Definition: getid3.lib.php:17
+ Here is the call graph for this function:

◆ getid3_mpc()

getid3_mpc::getid3_mpc ( $fd,
$ThisFileInfo 
)

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

References getid3_lib\CastAsInt(), getid3_handler\fread(), getid3_handler\fseek(), getid3_lib\LittleEndian2Int(), MPCencoderVersionLookup(), MPCfrequencyLookup(), MPCpeakDBLookup(), and MPCprofileNameLookup().

20  {
21  // http://www.uni-jena.de/~pfk/mpp/sv8/header.html
22 
23  $ThisFileInfo['mpc']['header'] = array();
24  $thisfile_mpc_header = &$ThisFileInfo['mpc']['header'];
25 
26  $ThisFileInfo['fileformat'] = 'mpc';
27  $ThisFileInfo['audio']['dataformat'] = 'mpc';
28  $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
29  $ThisFileInfo['audio']['channels'] = 2; // the format appears to be hardcoded for stereo only
30  $ThisFileInfo['audio']['lossless'] = false;
31 
32  fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
33 
34  $thisfile_mpc_header['size'] = 28;
35  $MPCheaderData = fread($fd, $thisfile_mpc_header['size']);
36  $offset = 0;
37 
38  if (substr($MPCheaderData, $offset, 3) == 'MP+') {
39 
40  // great, this is SV7+
41  $thisfile_mpc_header['raw']['preamble'] = substr($MPCheaderData, $offset, 3); // should be 'MP+'
42  $offset += 3;
43 
44  } elseif (preg_match('/^[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0]/s', substr($MPCheaderData, 0, 4))) {
45 
46  // this is SV4 - SV6, handle seperately
47  $thisfile_mpc_header['size'] = 8;
48 
49  // add size of file header to avdataoffset - calc bitrate correctly + MD5 data
50  $ThisFileInfo['avdataoffset'] += $thisfile_mpc_header['size'];
51 
52  // Most of this code adapted from Jurgen Faul's MPEGplus source code - thanks Jurgen! :)
53  $HeaderDWORD[0] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, 0, 4));
54  $HeaderDWORD[1] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, 4, 4));
55 
56 
57  // DDDD DDDD CCCC CCCC BBBB BBBB AAAA AAAA
58  // aaaa aaaa abcd dddd dddd deee eeff ffff
59  //
60  // a = bitrate = anything
61  // b = IS = anything
62  // c = MS = anything
63  // d = streamversion = 0000000004 or 0000000005 or 0000000006
64  // e = maxband = anything
65  // f = blocksize = 000001 for SV5+, anything(?) for SV4
66 
67  $thisfile_mpc_header['target_bitrate'] = (($HeaderDWORD[0] & 0xFF800000) >> 23);
68  $thisfile_mpc_header['intensity_stereo'] = (bool) (($HeaderDWORD[0] & 0x00400000) >> 22);
69  $thisfile_mpc_header['mid-side_stereo'] = (bool) (($HeaderDWORD[0] & 0x00200000) >> 21);
70  $thisfile_mpc_header['stream_major_version'] = ($HeaderDWORD[0] & 0x001FF800) >> 11;
71  $thisfile_mpc_header['stream_minor_version'] = 0; // no sub-version numbers before SV7
72  $thisfile_mpc_header['max_band'] = ($HeaderDWORD[0] & 0x000007C0) >> 6; // related to lowpass frequency, not sure how it translates exactly
73  $thisfile_mpc_header['block_size'] = ($HeaderDWORD[0] & 0x0000003F);
74 
75  switch ($thisfile_mpc_header['stream_major_version']) {
76  case 4:
77  $thisfile_mpc_header['frame_count'] = ($HeaderDWORD[1] >> 16);
78  break;
79 
80  case 5:
81  case 6:
82  $thisfile_mpc_header['frame_count'] = $HeaderDWORD[1];
83  break;
84 
85  default:
86  $ThisFileInfo['error'] = 'Expecting 4, 5 or 6 in version field, found '.$thisfile_mpc_header['stream_major_version'].' instead';
87  unset($ThisFileInfo['mpc']);
88  return false;
89  break;
90  }
91 
92  if (($thisfile_mpc_header['stream_major_version'] > 4) && ($thisfile_mpc_header['block_size'] != 1)) {
93  $ThisFileInfo['warning'][] = 'Block size expected to be 1, actual value found: '.$thisfile_mpc_header['block_size'];
94  }
95 
96  $thisfile_mpc_header['sample_rate'] = 44100; // AB: used by all files up to SV7
97  $ThisFileInfo['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
98  $thisfile_mpc_header['samples'] = $thisfile_mpc_header['frame_count'] * 1152 * $ThisFileInfo['audio']['channels'];
99 
100  if ($thisfile_mpc_header['target_bitrate'] == 0) {
101  $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
102  } else {
103  $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
104  }
105 
106  $ThisFileInfo['mpc']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 * 44100 / $thisfile_mpc_header['frame_count'] / 1152;
107  $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpc']['bitrate'];
108  $ThisFileInfo['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_major_version'];
109 
110  return true;
111 
112  } else {
113 
114  $ThisFileInfo['error'][] = 'Expecting "MP+" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($MPCheaderData, $offset, 3).'"';
115  unset($ThisFileInfo['fileformat']);
116  unset($ThisFileInfo['mpc']);
117  return false;
118 
119  }
120 
121  // Continue with SV7+ handling
122  $StreamVersionByte = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
123  $offset += 1;
124  $thisfile_mpc_header['stream_major_version'] = ($StreamVersionByte & 0x0F);
125  $thisfile_mpc_header['stream_minor_version'] = ($StreamVersionByte & 0xF0) >> 4;
126  $thisfile_mpc_header['frame_count'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
127  $offset += 4;
128 
129  switch ($thisfile_mpc_header['stream_major_version']) {
130  case 7:
131  //$ThisFileInfo['fileformat'] = 'SV7';
132  break;
133 
134  default:
135  $ThisFileInfo['error'][] = 'Only Musepack SV7 supported';
136  return false;
137  }
138 
139  $FlagsDWORD1 = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
140  $offset += 4;
141  $thisfile_mpc_header['intensity_stereo'] = (bool) (($FlagsDWORD1 & 0x80000000) >> 31);
142  $thisfile_mpc_header['mid_side_stereo'] = (bool) (($FlagsDWORD1 & 0x40000000) >> 30);
143  $thisfile_mpc_header['max_subband'] = ($FlagsDWORD1 & 0x3F000000) >> 24;
144  $thisfile_mpc_header['raw']['profile'] = ($FlagsDWORD1 & 0x00F00000) >> 20;
145  $thisfile_mpc_header['begin_loud'] = (bool) (($FlagsDWORD1 & 0x00080000) >> 19);
146  $thisfile_mpc_header['end_loud'] = (bool) (($FlagsDWORD1 & 0x00040000) >> 18);
147  $thisfile_mpc_header['raw']['sample_rate'] = ($FlagsDWORD1 & 0x00030000) >> 16;
148  $thisfile_mpc_header['max_level'] = ($FlagsDWORD1 & 0x0000FFFF);
149 
150  $thisfile_mpc_header['raw']['title_peak'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2));
151  $offset += 2;
152  $thisfile_mpc_header['raw']['title_gain'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2), true);
153  $offset += 2;
154 
155  $thisfile_mpc_header['raw']['album_peak'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2));
156  $offset += 2;
157  $thisfile_mpc_header['raw']['album_gain'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2), true);
158  $offset += 2;
159 
160  $FlagsDWORD2 = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
161  $offset += 4;
162  $thisfile_mpc_header['true_gapless'] = (bool) (($FlagsDWORD2 & 0x80000000) >> 31);
163  $thisfile_mpc_header['last_frame_length'] = ($FlagsDWORD2 & 0x7FF00000) >> 20;
164 
165 
166  $thisfile_mpc_header['raw']['not_sure_what'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 3));
167  $offset += 3;
168  $thisfile_mpc_header['raw']['encoder_version'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
169  $offset += 1;
170 
171  $thisfile_mpc_header['profile'] = $this->MPCprofileNameLookup($thisfile_mpc_header['raw']['profile']);
172  $thisfile_mpc_header['sample_rate'] = $this->MPCfrequencyLookup($thisfile_mpc_header['raw']['sample_rate']);
173  if ($thisfile_mpc_header['sample_rate'] == 0) {
174  $ThisFileInfo['error'][] = 'Corrupt MPC file: frequency == zero';
175  return false;
176  }
177  $ThisFileInfo['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
178  $thisfile_mpc_header['samples'] = ((($thisfile_mpc_header['frame_count'] - 1) * 1152) + $thisfile_mpc_header['last_frame_length']) * $ThisFileInfo['audio']['channels'];
179 
180  $ThisFileInfo['playtime_seconds'] = ($thisfile_mpc_header['samples'] / $ThisFileInfo['audio']['channels']) / $ThisFileInfo['audio']['sample_rate'];
181  if ($ThisFileInfo['playtime_seconds'] == 0) {
182  $ThisFileInfo['error'][] = 'Corrupt MPC file: playtime_seconds == zero';
183  return false;
184  }
185 
186  // add size of file header to avdataoffset - calc bitrate correctly + MD5 data
187  $ThisFileInfo['avdataoffset'] += $thisfile_mpc_header['size'];
188 
189  $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
190 
191  $thisfile_mpc_header['title_peak'] = $thisfile_mpc_header['raw']['title_peak'];
192  $thisfile_mpc_header['title_peak_db'] = $this->MPCpeakDBLookup($thisfile_mpc_header['title_peak']);
193  if ($thisfile_mpc_header['raw']['title_gain'] < 0) {
194  $thisfile_mpc_header['title_gain_db'] = (float) (32768 + $thisfile_mpc_header['raw']['title_gain']) / -100;
195  } else {
196  $thisfile_mpc_header['title_gain_db'] = (float) $thisfile_mpc_header['raw']['title_gain'] / 100;
197  }
198 
199  $thisfile_mpc_header['album_peak'] = $thisfile_mpc_header['raw']['album_peak'];
200  $thisfile_mpc_header['album_peak_db'] = $this->MPCpeakDBLookup($thisfile_mpc_header['album_peak']);
201  if ($thisfile_mpc_header['raw']['album_gain'] < 0) {
202  $thisfile_mpc_header['album_gain_db'] = (float) (32768 + $thisfile_mpc_header['raw']['album_gain']) / -100;
203  } else {
204  $thisfile_mpc_header['album_gain_db'] = (float) $thisfile_mpc_header['raw']['album_gain'] / 100;;
205  }
206  $thisfile_mpc_header['encoder_version'] = $this->MPCencoderVersionLookup($thisfile_mpc_header['raw']['encoder_version']);
207 
208  $ThisFileInfo['replay_gain']['track']['adjustment'] = $thisfile_mpc_header['title_gain_db'];
209  $ThisFileInfo['replay_gain']['album']['adjustment'] = $thisfile_mpc_header['album_gain_db'];
210 
211  if ($thisfile_mpc_header['title_peak'] > 0) {
212  $ThisFileInfo['replay_gain']['track']['peak'] = $thisfile_mpc_header['title_peak'];
213  } elseif (round($thisfile_mpc_header['max_level'] * 1.18) > 0) {
214  $ThisFileInfo['replay_gain']['track']['peak'] = getid3_lib::CastAsInt(round($thisfile_mpc_header['max_level'] * 1.18)); // why? I don't know - see mppdec.c
215  }
216  if ($thisfile_mpc_header['album_peak'] > 0) {
217  $ThisFileInfo['replay_gain']['album']['peak'] = $thisfile_mpc_header['album_peak'];
218  }
219 
220  //$ThisFileInfo['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_major_version'].'.'.$thisfile_mpc_header['stream_minor_version'].', '.$thisfile_mpc_header['encoder_version'];
221  $ThisFileInfo['audio']['encoder'] = $thisfile_mpc_header['encoder_version'];
222  $ThisFileInfo['audio']['encoder_options'] = $thisfile_mpc_header['profile'];
223 
224  return true;
225  }
MPCencoderVersionLookup($encoderversion)
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266
fread($bytes)
Definition: getid3.php:1685
CastAsInt($floatnum)
Definition: getid3.lib.php:60
MPCpeakDBLookup($intvalue)
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
MPCfrequencyLookup($frequencyid)
MPCprofileNameLookup($profileid)
+ Here is the call graph for this function:

◆ MPCencoderVersionLookup() [1/2]

getid3_mpc::MPCencoderVersionLookup (   $encoderversion)

Definition at line 266 of file module.audio.mpc.php.

Referenced by getid3_mpc(), and ParseMPCsv7().

266  {
267  //Encoder version * 100 (106 = 1.06)
268  //EncoderVersion % 10 == 0 Release (1.0)
269  //EncoderVersion % 2 == 0 Beta (1.06)
270  //EncoderVersion % 2 == 1 Alpha (1.05a...z)
271 
272  if ($encoderversion == 0) {
273  // very old version, not known exactly which
274  return 'Buschmann v1.7.0-v1.7.9 or Klemm v0.90-v1.05';
275  }
276 
277  if (($encoderversion % 10) == 0) {
278 
279  // release version
280  return number_format($encoderversion / 100, 2);
281 
282  } elseif (($encoderversion % 2) == 0) {
283 
284  // beta version
285  return number_format($encoderversion / 100, 2).' beta';
286 
287  }
288 
289  // alpha version
290  return number_format($encoderversion / 100, 2).' alpha';
291  }
+ Here is the caller graph for this function:

◆ MPCencoderVersionLookup() [2/2]

getid3_mpc::MPCencoderVersionLookup (   $encoderversion)

Definition at line 440 of file module.audio.mpc.php.

440  {
441  //Encoder version * 100 (106 = 1.06)
442  //EncoderVersion % 10 == 0 Release (1.0)
443  //EncoderVersion % 2 == 0 Beta (1.06)
444  //EncoderVersion % 2 == 1 Alpha (1.05a...z)
445 
446  if ($encoderversion == 0) {
447  // very old version, not known exactly which
448  return 'Buschmann v1.7.0-v1.7.9 or Klemm v0.90-v1.05';
449  }
450 
451  if (($encoderversion % 10) == 0) {
452 
453  // release version
454  return number_format($encoderversion / 100, 2);
455 
456  } elseif (($encoderversion % 2) == 0) {
457 
458  // beta version
459  return number_format($encoderversion / 100, 2).' beta';
460 
461  }
462 
463  // alpha version
464  return number_format($encoderversion / 100, 2).' alpha';
465  }

◆ MPCfrequencyLookup() [1/2]

getid3_mpc::MPCfrequencyLookup (   $frequencyid)

Definition at line 249 of file module.audio.mpc.php.

Referenced by getid3_mpc(), ParseMPCsv7(), and ParseMPCsv8().

249  {
250  static $MPCfrequencyLookup = array(
251  0 => 44100,
252  1 => 48000,
253  2 => 37800,
254  3 => 32000
255  );
256  return (isset($MPCfrequencyLookup[$frequencyid]) ? $MPCfrequencyLookup[$frequencyid] : 'invalid');
257  }
+ Here is the caller graph for this function:

◆ MPCfrequencyLookup() [2/2]

getid3_mpc::MPCfrequencyLookup (   $frequencyid)

Definition at line 423 of file module.audio.mpc.php.

423  {
424  static $MPCfrequencyLookup = array(
425  0 => 44100,
426  1 => 48000,
427  2 => 37800,
428  3 => 32000
429  );
430  return (isset($MPCfrequencyLookup[$frequencyid]) ? $MPCfrequencyLookup[$frequencyid] : 'invalid');
431  }

◆ MPCpeakDBLookup() [1/2]

getid3_mpc::MPCpeakDBLookup (   $intvalue)

Definition at line 259 of file module.audio.mpc.php.

Referenced by getid3_mpc(), and ParseMPCsv7().

259  {
260  if ($intvalue > 0) {
261  return ((log10($intvalue) / log10(2)) - 15) * 6;
262  }
263  return false;
264  }
+ Here is the caller graph for this function:

◆ MPCpeakDBLookup() [2/2]

getid3_mpc::MPCpeakDBLookup (   $intvalue)

Definition at line 433 of file module.audio.mpc.php.

433  {
434  if ($intvalue > 0) {
435  return ((log10($intvalue) / log10(2)) - 15) * 6;
436  }
437  return false;
438  }

◆ MPCprofileNameLookup() [1/2]

getid3_mpc::MPCprofileNameLookup (   $profileid)

Definition at line 227 of file module.audio.mpc.php.

Referenced by getid3_mpc(), and ParseMPCsv7().

227  {
228  static $MPCprofileNameLookup = array(
229  0 => 'no profile',
230  1 => 'Experimental',
231  2 => 'unused',
232  3 => 'unused',
233  4 => 'unused',
234  5 => 'below Telephone (q = 0.0)',
235  6 => 'below Telephone (q = 1.0)',
236  7 => 'Telephone (q = 2.0)',
237  8 => 'Thumb (q = 3.0)',
238  9 => 'Radio (q = 4.0)',
239  10 => 'Standard (q = 5.0)',
240  11 => 'Extreme (q = 6.0)',
241  12 => 'Insane (q = 7.0)',
242  13 => 'BrainDead (q = 8.0)',
243  14 => 'above BrainDead (q = 9.0)',
244  15 => 'above BrainDead (q = 10.0)'
245  );
246  return (isset($MPCprofileNameLookup[$profileid]) ? $MPCprofileNameLookup[$profileid] : 'invalid');
247  }
+ Here is the caller graph for this function:

◆ MPCprofileNameLookup() [2/2]

getid3_mpc::MPCprofileNameLookup (   $profileid)

Definition at line 401 of file module.audio.mpc.php.

401  {
402  static $MPCprofileNameLookup = array(
403  0 => 'no profile',
404  1 => 'Experimental',
405  2 => 'unused',
406  3 => 'unused',
407  4 => 'unused',
408  5 => 'below Telephone (q = 0.0)',
409  6 => 'below Telephone (q = 1.0)',
410  7 => 'Telephone (q = 2.0)',
411  8 => 'Thumb (q = 3.0)',
412  9 => 'Radio (q = 4.0)',
413  10 => 'Standard (q = 5.0)',
414  11 => 'Extreme (q = 6.0)',
415  12 => 'Insane (q = 7.0)',
416  13 => 'BrainDead (q = 8.0)',
417  14 => 'above BrainDead (q = 9.0)',
418  15 => 'above BrainDead (q = 10.0)'
419  );
420  return (isset($MPCprofileNameLookup[$profileid]) ? $MPCprofileNameLookup[$profileid] : 'invalid');
421  }

◆ MPCsv8PacketName()

getid3_mpc::MPCsv8PacketName (   $packetKey)

Definition at line 491 of file module.audio.mpc.php.

Referenced by ParseMPCsv8().

491  {
492  static $MPCsv8PacketName = array();
493  if (empty($MPCsv8PacketName)) {
494  $MPCsv8PacketName = array(
495  'AP' => 'Audio Packet',
496  'CT' => 'Chapter Tag',
497  'EI' => 'Encoder Info',
498  'RG' => 'Replay Gain',
499  'SE' => 'Stream End',
500  'SH' => 'Stream Header',
501  'SO' => 'Seek Table Offset',
502  'ST' => 'Seek Table',
503  );
504  }
505  return (isset($MPCsv8PacketName[$packetKey]) ? $MPCsv8PacketName[$packetKey] : $packetKey);
506  }
+ Here is the caller graph for this function:

◆ ParseMPCsv6()

getid3_mpc::ParseMPCsv6 ( )

Definition at line 325 of file module.audio.mpc.php.

References $info, getid3_handler\fread(), getid3_handler\fseek(), and getid3_lib\LittleEndian2Int().

Referenced by Analyze().

325  {
326  // this is SV4 - SV6
327 
328  $info = &$this->getid3->info;
329  $thisfile_mpc_header = &$info['mpc']['header'];
330  $offset = 0;
331 
332  $thisfile_mpc_header['size'] = 8;
333  $this->fseek($info['avdataoffset']);
334  $MPCheaderData = $this->fread($thisfile_mpc_header['size']);
335 
336  // add size of file header to avdataoffset - calc bitrate correctly + MD5 data
337  $info['avdataoffset'] += $thisfile_mpc_header['size'];
338 
339  // Most of this code adapted from Jurgen Faul's MPEGplus source code - thanks Jurgen! :)
340  $HeaderDWORD[0] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, 0, 4));
341  $HeaderDWORD[1] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, 4, 4));
342 
343 
344  // DDDD DDDD CCCC CCCC BBBB BBBB AAAA AAAA
345  // aaaa aaaa abcd dddd dddd deee eeff ffff
346  //
347  // a = bitrate = anything
348  // b = IS = anything
349  // c = MS = anything
350  // d = streamversion = 0000000004 or 0000000005 or 0000000006
351  // e = maxband = anything
352  // f = blocksize = 000001 for SV5+, anything(?) for SV4
353 
354  $thisfile_mpc_header['target_bitrate'] = (($HeaderDWORD[0] & 0xFF800000) >> 23);
355  $thisfile_mpc_header['intensity_stereo'] = (bool) (($HeaderDWORD[0] & 0x00400000) >> 22);
356  $thisfile_mpc_header['mid_side_stereo'] = (bool) (($HeaderDWORD[0] & 0x00200000) >> 21);
357  $thisfile_mpc_header['stream_version_major'] = ($HeaderDWORD[0] & 0x001FF800) >> 11;
358  $thisfile_mpc_header['stream_version_minor'] = 0; // no sub-version numbers before SV7
359  $thisfile_mpc_header['max_band'] = ($HeaderDWORD[0] & 0x000007C0) >> 6; // related to lowpass frequency, not sure how it translates exactly
360  $thisfile_mpc_header['block_size'] = ($HeaderDWORD[0] & 0x0000003F);
361 
362  switch ($thisfile_mpc_header['stream_version_major']) {
363  case 4:
364  $thisfile_mpc_header['frame_count'] = ($HeaderDWORD[1] >> 16);
365  break;
366 
367  case 5:
368  case 6:
369  $thisfile_mpc_header['frame_count'] = $HeaderDWORD[1];
370  break;
371 
372  default:
373  $info['error'] = 'Expecting 4, 5 or 6 in version field, found '.$thisfile_mpc_header['stream_version_major'].' instead';
374  unset($info['mpc']);
375  return false;
376  break;
377  }
378 
379  if (($thisfile_mpc_header['stream_version_major'] > 4) && ($thisfile_mpc_header['block_size'] != 1)) {
380  $info['warning'][] = 'Block size expected to be 1, actual value found: '.$thisfile_mpc_header['block_size'];
381  }
382 
383  $thisfile_mpc_header['sample_rate'] = 44100; // AB: used by all files up to SV7
384  $info['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
385  $thisfile_mpc_header['samples'] = $thisfile_mpc_header['frame_count'] * 1152 * $info['audio']['channels'];
386 
387  if ($thisfile_mpc_header['target_bitrate'] == 0) {
388  $info['audio']['bitrate_mode'] = 'vbr';
389  } else {
390  $info['audio']['bitrate_mode'] = 'cbr';
391  }
392 
393  $info['mpc']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 * 44100 / $thisfile_mpc_header['frame_count'] / 1152;
394  $info['audio']['bitrate'] = $info['mpc']['bitrate'];
395  $info['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_version_major'];
396 
397  return true;
398  }
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266
$info
Definition: example_052.php:80
fread($bytes)
Definition: getid3.php:1685
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ParseMPCsv7()

getid3_mpc::ParseMPCsv7 ( )

Definition at line 211 of file module.audio.mpc.php.

References $info, getid3_lib\CastAsInt(), getid3_handler\fread(), getid3_lib\LittleEndian2Int(), MPCencoderVersionLookup(), MPCfrequencyLookup(), MPCpeakDBLookup(), and MPCprofileNameLookup().

Referenced by Analyze().

211  {
212  // this is SV7
213  // http://www.uni-jena.de/~pfk/mpp/sv8/header.html
214 
215  $info = &$this->getid3->info;
216  $thisfile_mpc_header = &$info['mpc']['header'];
217  $offset = 0;
218 
219  $thisfile_mpc_header['size'] = 28;
220  $MPCheaderData = $info['mpc']['header']['preamble'];
221  $MPCheaderData .= $this->fread($thisfile_mpc_header['size'] - strlen($info['mpc']['header']['preamble']));
222  $offset = strlen('MP+');
223 
224  $StreamVersionByte = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
225  $offset += 1;
226  $thisfile_mpc_header['stream_version_major'] = ($StreamVersionByte & 0x0F) >> 0;
227  $thisfile_mpc_header['stream_version_minor'] = ($StreamVersionByte & 0xF0) >> 4; // should always be 0, subversions no longer exist in SV8
228  $thisfile_mpc_header['frame_count'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
229  $offset += 4;
230 
231  if ($thisfile_mpc_header['stream_version_major'] != 7) {
232  $info['error'][] = 'Only Musepack SV7 supported (this file claims to be v'.$thisfile_mpc_header['stream_version_major'].')';
233  return false;
234  }
235 
236  $FlagsDWORD1 = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
237  $offset += 4;
238  $thisfile_mpc_header['intensity_stereo'] = (bool) (($FlagsDWORD1 & 0x80000000) >> 31);
239  $thisfile_mpc_header['mid_side_stereo'] = (bool) (($FlagsDWORD1 & 0x40000000) >> 30);
240  $thisfile_mpc_header['max_subband'] = ($FlagsDWORD1 & 0x3F000000) >> 24;
241  $thisfile_mpc_header['raw']['profile'] = ($FlagsDWORD1 & 0x00F00000) >> 20;
242  $thisfile_mpc_header['begin_loud'] = (bool) (($FlagsDWORD1 & 0x00080000) >> 19);
243  $thisfile_mpc_header['end_loud'] = (bool) (($FlagsDWORD1 & 0x00040000) >> 18);
244  $thisfile_mpc_header['raw']['sample_rate'] = ($FlagsDWORD1 & 0x00030000) >> 16;
245  $thisfile_mpc_header['max_level'] = ($FlagsDWORD1 & 0x0000FFFF);
246 
247  $thisfile_mpc_header['raw']['title_peak'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2));
248  $offset += 2;
249  $thisfile_mpc_header['raw']['title_gain'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2), true);
250  $offset += 2;
251 
252  $thisfile_mpc_header['raw']['album_peak'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2));
253  $offset += 2;
254  $thisfile_mpc_header['raw']['album_gain'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2), true);
255  $offset += 2;
256 
257  $FlagsDWORD2 = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
258  $offset += 4;
259  $thisfile_mpc_header['true_gapless'] = (bool) (($FlagsDWORD2 & 0x80000000) >> 31);
260  $thisfile_mpc_header['last_frame_length'] = ($FlagsDWORD2 & 0x7FF00000) >> 20;
261 
262 
263  $thisfile_mpc_header['raw']['not_sure_what'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 3));
264  $offset += 3;
265  $thisfile_mpc_header['raw']['encoder_version'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
266  $offset += 1;
267 
268  $thisfile_mpc_header['profile'] = $this->MPCprofileNameLookup($thisfile_mpc_header['raw']['profile']);
269  $thisfile_mpc_header['sample_rate'] = $this->MPCfrequencyLookup($thisfile_mpc_header['raw']['sample_rate']);
270  if ($thisfile_mpc_header['sample_rate'] == 0) {
271  $info['error'][] = 'Corrupt MPC file: frequency == zero';
272  return false;
273  }
274  $info['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
275  $thisfile_mpc_header['samples'] = ((($thisfile_mpc_header['frame_count'] - 1) * 1152) + $thisfile_mpc_header['last_frame_length']) * $info['audio']['channels'];
276 
277  $info['playtime_seconds'] = ($thisfile_mpc_header['samples'] / $info['audio']['channels']) / $info['audio']['sample_rate'];
278  if ($info['playtime_seconds'] == 0) {
279  $info['error'][] = 'Corrupt MPC file: playtime_seconds == zero';
280  return false;
281  }
282 
283  // add size of file header to avdataoffset - calc bitrate correctly + MD5 data
284  $info['avdataoffset'] += $thisfile_mpc_header['size'];
285 
286  $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
287 
288  $thisfile_mpc_header['title_peak'] = $thisfile_mpc_header['raw']['title_peak'];
289  $thisfile_mpc_header['title_peak_db'] = $this->MPCpeakDBLookup($thisfile_mpc_header['title_peak']);
290  if ($thisfile_mpc_header['raw']['title_gain'] < 0) {
291  $thisfile_mpc_header['title_gain_db'] = (float) (32768 + $thisfile_mpc_header['raw']['title_gain']) / -100;
292  } else {
293  $thisfile_mpc_header['title_gain_db'] = (float) $thisfile_mpc_header['raw']['title_gain'] / 100;
294  }
295 
296  $thisfile_mpc_header['album_peak'] = $thisfile_mpc_header['raw']['album_peak'];
297  $thisfile_mpc_header['album_peak_db'] = $this->MPCpeakDBLookup($thisfile_mpc_header['album_peak']);
298  if ($thisfile_mpc_header['raw']['album_gain'] < 0) {
299  $thisfile_mpc_header['album_gain_db'] = (float) (32768 + $thisfile_mpc_header['raw']['album_gain']) / -100;
300  } else {
301  $thisfile_mpc_header['album_gain_db'] = (float) $thisfile_mpc_header['raw']['album_gain'] / 100;;
302  }
303  $thisfile_mpc_header['encoder_version'] = $this->MPCencoderVersionLookup($thisfile_mpc_header['raw']['encoder_version']);
304 
305  $info['replay_gain']['track']['adjustment'] = $thisfile_mpc_header['title_gain_db'];
306  $info['replay_gain']['album']['adjustment'] = $thisfile_mpc_header['album_gain_db'];
307 
308  if ($thisfile_mpc_header['title_peak'] > 0) {
309  $info['replay_gain']['track']['peak'] = $thisfile_mpc_header['title_peak'];
310  } elseif (round($thisfile_mpc_header['max_level'] * 1.18) > 0) {
311  $info['replay_gain']['track']['peak'] = getid3_lib::CastAsInt(round($thisfile_mpc_header['max_level'] * 1.18)); // why? I don't know - see mppdec.c
312  }
313  if ($thisfile_mpc_header['album_peak'] > 0) {
314  $info['replay_gain']['album']['peak'] = $thisfile_mpc_header['album_peak'];
315  }
316 
317  //$info['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_version_major'].'.'.$thisfile_mpc_header['stream_version_minor'].', '.$thisfile_mpc_header['encoder_version'];
318  $info['audio']['encoder'] = $thisfile_mpc_header['encoder_version'];
319  $info['audio']['encoder_options'] = $thisfile_mpc_header['profile'];
320  $thisfile_mpc_header['quality'] = (float) ($thisfile_mpc_header['raw']['profile'] - 5); // values can range from 0 to 15, of which 0..4 are "reserved/experimental", and 5..15 are mapped to qualities of 0.0 to 10.0
321 
322  return true;
323  }
MPCencoderVersionLookup($encoderversion)
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266
$info
Definition: example_052.php:80
fread($bytes)
Definition: getid3.php:1685
CastAsInt($floatnum)
Definition: getid3.lib.php:60
MPCpeakDBLookup($intvalue)
MPCfrequencyLookup($frequencyid)
MPCprofileNameLookup($profileid)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ParseMPCsv8()

getid3_mpc::ParseMPCsv8 ( )

Definition at line 63 of file module.audio.mpc.php.

References $info, getid3_lib\BigEndian2Int(), getid3_handler\fread(), getid3_handler\fseek(), getid3_handler\ftell(), MPCfrequencyLookup(), MPCsv8PacketName(), and SV8variableLengthInteger().

Referenced by Analyze().

63  {
64  // this is SV8
65  // http://trac.musepack.net/trac/wiki/SV8Specification
66 
67  $info = &$this->getid3->info;
68  $thisfile_mpc_header = &$info['mpc']['header'];
69 
70  $keyNameSize = 2;
71  $maxHandledPacketLength = 9; // specs say: "n*8; 0 < n < 10"
72 
73  $offset = $this->ftell();
74  while ($offset < $info['avdataend']) {
75  $thisPacket = array();
76  $thisPacket['offset'] = $offset;
77  $packet_offset = 0;
78 
79  // Size is a variable-size field, could be 1-4 bytes (possibly more?)
80  // read enough data in and figure out the exact size later
81  $MPCheaderData = $this->fread($keyNameSize + $maxHandledPacketLength);
82  $packet_offset += $keyNameSize;
83  $thisPacket['key'] = substr($MPCheaderData, 0, $keyNameSize);
84  $thisPacket['key_name'] = $this->MPCsv8PacketName($thisPacket['key']);
85  if ($thisPacket['key'] == $thisPacket['key_name']) {
86  $info['error'][] = 'Found unexpected key value "'.$thisPacket['key'].'" at offset '.$thisPacket['offset'];
87  return false;
88  }
89  $packetLength = 0;
90  $thisPacket['packet_size'] = $this->SV8variableLengthInteger(substr($MPCheaderData, $keyNameSize), $packetLength); // includes keyname and packet_size field
91  if ($thisPacket['packet_size'] === false) {
92  $info['error'][] = 'Did not find expected packet length within '.$maxHandledPacketLength.' bytes at offset '.($thisPacket['offset'] + $keyNameSize);
93  return false;
94  }
95  $packet_offset += $packetLength;
96  $offset += $thisPacket['packet_size'];
97 
98  switch ($thisPacket['key']) {
99  case 'SH': // Stream Header
100  $moreBytesToRead = $thisPacket['packet_size'] - $keyNameSize - $maxHandledPacketLength;
101  if ($moreBytesToRead > 0) {
102  $MPCheaderData .= $this->fread($moreBytesToRead);
103  }
104  $thisPacket['crc'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 4));
105  $packet_offset += 4;
106  $thisPacket['stream_version'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 1));
107  $packet_offset += 1;
108 
109  $packetLength = 0;
110  $thisPacket['sample_count'] = $this->SV8variableLengthInteger(substr($MPCheaderData, $packet_offset, $maxHandledPacketLength), $packetLength);
111  $packet_offset += $packetLength;
112 
113  $packetLength = 0;
114  $thisPacket['beginning_silence'] = $this->SV8variableLengthInteger(substr($MPCheaderData, $packet_offset, $maxHandledPacketLength), $packetLength);
115  $packet_offset += $packetLength;
116 
117  $otherUsefulData = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 2));
118  $packet_offset += 2;
119  $thisPacket['sample_frequency_raw'] = (($otherUsefulData & 0xE000) >> 13);
120  $thisPacket['max_bands_used'] = (($otherUsefulData & 0x1F00) >> 8);
121  $thisPacket['channels'] = (($otherUsefulData & 0x00F0) >> 4) + 1;
122  $thisPacket['ms_used'] = (bool) (($otherUsefulData & 0x0008) >> 3);
123  $thisPacket['audio_block_frames'] = (($otherUsefulData & 0x0007) >> 0);
124  $thisPacket['sample_frequency'] = $this->MPCfrequencyLookup($thisPacket['sample_frequency_raw']);
125 
126  $thisfile_mpc_header['mid_side_stereo'] = $thisPacket['ms_used'];
127  $thisfile_mpc_header['sample_rate'] = $thisPacket['sample_frequency'];
128  $thisfile_mpc_header['samples'] = $thisPacket['sample_count'];
129  $thisfile_mpc_header['stream_version_major'] = $thisPacket['stream_version'];
130 
131  $info['audio']['channels'] = $thisPacket['channels'];
132  $info['audio']['sample_rate'] = $thisPacket['sample_frequency'];
133  $info['playtime_seconds'] = $thisPacket['sample_count'] / $thisPacket['sample_frequency'];
134  $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
135  break;
136 
137  case 'RG': // Replay Gain
138  $moreBytesToRead = $thisPacket['packet_size'] - $keyNameSize - $maxHandledPacketLength;
139  if ($moreBytesToRead > 0) {
140  $MPCheaderData .= $this->fread($moreBytesToRead);
141  }
142  $thisPacket['replaygain_version'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 1));
143  $packet_offset += 1;
144  $thisPacket['replaygain_title_gain'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 2));
145  $packet_offset += 2;
146  $thisPacket['replaygain_title_peak'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 2));
147  $packet_offset += 2;
148  $thisPacket['replaygain_album_gain'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 2));
149  $packet_offset += 2;
150  $thisPacket['replaygain_album_peak'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 2));
151  $packet_offset += 2;
152 
153  if ($thisPacket['replaygain_title_gain']) { $info['replay_gain']['title']['gain'] = $thisPacket['replaygain_title_gain']; }
154  if ($thisPacket['replaygain_title_peak']) { $info['replay_gain']['title']['peak'] = $thisPacket['replaygain_title_peak']; }
155  if ($thisPacket['replaygain_album_gain']) { $info['replay_gain']['album']['gain'] = $thisPacket['replaygain_album_gain']; }
156  if ($thisPacket['replaygain_album_peak']) { $info['replay_gain']['album']['peak'] = $thisPacket['replaygain_album_peak']; }
157  break;
158 
159  case 'EI': // Encoder Info
160  $moreBytesToRead = $thisPacket['packet_size'] - $keyNameSize - $maxHandledPacketLength;
161  if ($moreBytesToRead > 0) {
162  $MPCheaderData .= $this->fread($moreBytesToRead);
163  }
164  $profile_pns = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 1));
165  $packet_offset += 1;
166  $quality_int = (($profile_pns & 0xF0) >> 4);
167  $quality_dec = (($profile_pns & 0x0E) >> 3);
168  $thisPacket['quality'] = (float) $quality_int + ($quality_dec / 8);
169  $thisPacket['pns_tool'] = (bool) (($profile_pns & 0x01) >> 0);
170  $thisPacket['version_major'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 1));
171  $packet_offset += 1;
172  $thisPacket['version_minor'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 1));
173  $packet_offset += 1;
174  $thisPacket['version_build'] = getid3_lib::BigEndian2Int(substr($MPCheaderData, $packet_offset, 1));
175  $packet_offset += 1;
176  $thisPacket['version'] = $thisPacket['version_major'].'.'.$thisPacket['version_minor'].'.'.$thisPacket['version_build'];
177 
178  $info['audio']['encoder'] = 'MPC v'.$thisPacket['version'].' ('.(($thisPacket['version_minor'] % 2) ? 'unstable' : 'stable').')';
179  $thisfile_mpc_header['encoder_version'] = $info['audio']['encoder'];
180  //$thisfile_mpc_header['quality'] = (float) ($thisPacket['quality'] / 1.5875); // values can range from 0.000 to 15.875, mapped to qualities of 0.0 to 10.0
181  $thisfile_mpc_header['quality'] = (float) ($thisPacket['quality'] - 5); // values can range from 0.000 to 15.875, of which 0..4 are "reserved/experimental", and 5..15 are mapped to qualities of 0.0 to 10.0
182  break;
183 
184  case 'SO': // Seek Table Offset
185  $packetLength = 0;
186  $thisPacket['seek_table_offset'] = $thisPacket['offset'] + $this->SV8variableLengthInteger(substr($MPCheaderData, $packet_offset, $maxHandledPacketLength), $packetLength);
187  $packet_offset += $packetLength;
188  break;
189 
190  case 'ST': // Seek Table
191  case 'SE': // Stream End
192  case 'AP': // Audio Data
193  // nothing useful here, just skip this packet
194  $thisPacket = array();
195  break;
196 
197  default:
198  $info['error'][] = 'Found unhandled key type "'.$thisPacket['key'].'" at offset '.$thisPacket['offset'];
199  return false;
200  break;
201  }
202  if (!empty($thisPacket)) {
203  $info['mpc']['packets'][] = $thisPacket;
204  }
205  $this->fseek($offset);
206  }
207  $thisfile_mpc_header['size'] = $offset;
208  return true;
209  }
SV8variableLengthInteger($data, &$packetLength, $maxHandledPacketLength=9)
MPCsv8PacketName($packetKey)
$info
Definition: example_052.php:80
fread($bytes)
Definition: getid3.php:1685
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
MPCfrequencyLookup($frequencyid)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SV8variableLengthInteger()

getid3_mpc::SV8variableLengthInteger (   $data,
$packetLength,
  $maxHandledPacketLength = 9 
)

Definition at line 467 of file module.audio.mpc.php.

References $data.

Referenced by ParseMPCsv8().

467  {
468  $packet_size = 0;
469  for ($packetLength = 1; $packetLength <= $maxHandledPacketLength; $packetLength++) {
470  // variable-length size field:
471  // bits, big-endian
472  // 0xxx xxxx - value 0 to 2^7-1
473  // 1xxx xxxx 0xxx xxxx - value 0 to 2^14-1
474  // 1xxx xxxx 1xxx xxxx 0xxx xxxx - value 0 to 2^21-1
475  // 1xxx xxxx 1xxx xxxx 1xxx xxxx 0xxx xxxx - value 0 to 2^28-1
476  // ...
477  $thisbyte = ord(substr($data, ($packetLength - 1), 1));
478  // look through bytes until find a byte with MSB==0
479  $packet_size = ($packet_size << 7);
480  $packet_size = ($packet_size | ($thisbyte & 0x7F));
481  if (($thisbyte & 0x80) === 0) {
482  break;
483  }
484  if ($packetLength >= $maxHandledPacketLength) {
485  return false;
486  }
487  }
488  return $packet_size;
489  }
$data
+ Here is the caller graph for this function:

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