getid3_ac3

The WordPress Core getid3 ac3 class.

Defined (1)

The class is defined in the following location(s).

/wp-includes/ID3/module.audio.ac3.php  
  1. class getid3_ac3 extends getid3_handler 
  2. private $AC3header = array(); 
  3. private $BSIoffset = 0; 
  4.  
  5. const syncword = "\x0B\x77"; 
  6.  
  7. public function Analyze() { 
  8. $info = &$this->getid3->info; 
  9.  
  10. ///AH 
  11. $info['ac3']['raw']['bsi'] = array(); 
  12. $thisfile_ac3 = &$info['ac3']; 
  13. $thisfile_ac3_raw = &$thisfile_ac3['raw']; 
  14. $thisfile_ac3_raw_bsi = &$thisfile_ac3_raw['bsi']; 
  15.  
  16.  
  17. // http://www.atsc.org/standards/a_52a.pdf 
  18.  
  19. $info['fileformat'] = 'ac3'; 
  20.  
  21. // An AC-3 serial coded audio bit stream is made up of a sequence of synchronization frames 
  22. // Each synchronization frame contains 6 coded audio blocks (AB), each of which represent 256 
  23. // new audio samples per channel. A synchronization information (SI) header at the beginning 
  24. // of each frame contains information needed to acquire and maintain synchronization. A 
  25. // bit stream information (BSI) header follows SI, and contains parameters describing the coded 
  26. // audio service. The coded audio blocks may be followed by an auxiliary data (Aux) field. At the 
  27. // end of each frame is an error check field that includes a CRC word for error detection. An 
  28. // additional CRC word is located in the SI header, the use of which, by a decoder, is optional. 
  29. // 
  30. // syncinfo() | bsi() | AB0 | AB1 | AB2 | AB3 | AB4 | AB5 | Aux | CRC 
  31.  
  32. // syncinfo() { 
  33. // syncword 16 
  34. // crc1 16 
  35. // fscod 2 
  36. // frmsizecod 6 
  37. // } /* end of syncinfo */ 
  38.  
  39. $this->fseek($info['avdataoffset']); 
  40. $this->AC3header['syncinfo'] = $this->fread(5); 
  41.  
  42. if (strpos($this->AC3header['syncinfo'], self::syncword) === 0) { 
  43. $thisfile_ac3_raw['synchinfo']['synchword'] = self::syncword; 
  44. $offset = 2; 
  45. } else { 
  46. if (!$this->isDependencyFor('matroska')) { 
  47. unset($info['fileformat'], $info['ac3']); 
  48. return $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::syncword).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($this->AC3header['syncinfo'], 0, 2)).'"'); 
  49. $offset = 0; 
  50. $this->fseek(-2, SEEK_CUR); 
  51.  
  52. $info['audio']['dataformat'] = 'ac3'; 
  53. $info['audio']['bitrate_mode'] = 'cbr'; 
  54. $info['audio']['lossless'] = false; 
  55.  
  56. $thisfile_ac3_raw['synchinfo']['crc1'] = getid3_lib::LittleEndian2Int(substr($this->AC3header['syncinfo'], $offset, 2)); 
  57. $ac3_synchinfo_fscod_frmsizecod = getid3_lib::LittleEndian2Int(substr($this->AC3header['syncinfo'], ($offset + 2), 1)); 
  58. $thisfile_ac3_raw['synchinfo']['fscod'] = ($ac3_synchinfo_fscod_frmsizecod & 0xC0) >> 6; 
  59. $thisfile_ac3_raw['synchinfo']['frmsizecod'] = ($ac3_synchinfo_fscod_frmsizecod & 0x3F); 
  60.  
  61. $thisfile_ac3['sample_rate'] = self::sampleRateCodeLookup($thisfile_ac3_raw['synchinfo']['fscod']); 
  62. if ($thisfile_ac3_raw['synchinfo']['fscod'] <= 3) { 
  63. $info['audio']['sample_rate'] = $thisfile_ac3['sample_rate']; 
  64.  
  65. $thisfile_ac3['frame_length'] = self::frameSizeLookup($thisfile_ac3_raw['synchinfo']['frmsizecod'], $thisfile_ac3_raw['synchinfo']['fscod']); 
  66. $thisfile_ac3['bitrate'] = self::bitrateLookup($thisfile_ac3_raw['synchinfo']['frmsizecod']); 
  67. $info['audio']['bitrate'] = $thisfile_ac3['bitrate']; 
  68.  
  69. $this->AC3header['bsi'] = getid3_lib::BigEndian2Bin($this->fread(15)); 
  70. $ac3_bsi_offset = 0; 
  71.  
  72. $thisfile_ac3_raw_bsi['bsid'] = $this->readHeaderBSI(5); 
  73. if ($thisfile_ac3_raw_bsi['bsid'] > 8) { 
  74. // Decoders which can decode version 8 will thus be able to decode version numbers less than 8. 
  75. // If this standard is extended by the addition of additional elements or features, a value of bsid greater than 8 will be used. 
  76. // Decoders built to this version of the standard will not be able to decode versions with bsid greater than 8. 
  77. $this->error('Bit stream identification is version '.$thisfile_ac3_raw_bsi['bsid'].', but getID3() only understands up to version 8'); 
  78. unset($info['ac3']); 
  79. return false; 
  80.  
  81. $thisfile_ac3_raw_bsi['bsmod'] = $this->readHeaderBSI(3); 
  82. $thisfile_ac3_raw_bsi['acmod'] = $this->readHeaderBSI(3); 
  83.  
  84. $thisfile_ac3['service_type'] = self::serviceTypeLookup($thisfile_ac3_raw_bsi['bsmod'], $thisfile_ac3_raw_bsi['acmod']); 
  85. $ac3_coding_mode = self::audioCodingModeLookup($thisfile_ac3_raw_bsi['acmod']); 
  86. foreach($ac3_coding_mode as $key => $value) { 
  87. $thisfile_ac3[$key] = $value; 
  88. switch ($thisfile_ac3_raw_bsi['acmod']) { 
  89. case 0: 
  90. case 1: 
  91. $info['audio']['channelmode'] = 'mono'; 
  92. break; 
  93. case 3: 
  94. case 4: 
  95. $info['audio']['channelmode'] = 'stereo'; 
  96. break; 
  97. default: 
  98. $info['audio']['channelmode'] = 'surround'; 
  99. break; 
  100. $info['audio']['channels'] = $thisfile_ac3['num_channels']; 
  101.  
  102. if ($thisfile_ac3_raw_bsi['acmod'] & 0x01) { 
  103. // If the lsb of acmod is a 1, center channel is in use and cmixlev follows in the bit stream. 
  104. $thisfile_ac3_raw_bsi['cmixlev'] = $this->readHeaderBSI(2); 
  105. $thisfile_ac3['center_mix_level'] = self::centerMixLevelLookup($thisfile_ac3_raw_bsi['cmixlev']); 
  106.  
  107. if ($thisfile_ac3_raw_bsi['acmod'] & 0x04) { 
  108. // If the msb of acmod is a 1, surround channels are in use and surmixlev follows in the bit stream. 
  109. $thisfile_ac3_raw_bsi['surmixlev'] = $this->readHeaderBSI(2); 
  110. $thisfile_ac3['surround_mix_level'] = self::surroundMixLevelLookup($thisfile_ac3_raw_bsi['surmixlev']); 
  111.  
  112. if ($thisfile_ac3_raw_bsi['acmod'] == 0x02) { 
  113. // When operating in the two channel mode, this 2-bit code indicates whether or not the program has been encoded in Dolby Surround. 
  114. $thisfile_ac3_raw_bsi['dsurmod'] = $this->readHeaderBSI(2); 
  115. $thisfile_ac3['dolby_surround_mode'] = self::dolbySurroundModeLookup($thisfile_ac3_raw_bsi['dsurmod']); 
  116.  
  117. $thisfile_ac3_raw_bsi['lfeon'] = (bool) $this->readHeaderBSI(1); 
  118. $thisfile_ac3['lfe_enabled'] = $thisfile_ac3_raw_bsi['lfeon']; 
  119. if ($thisfile_ac3_raw_bsi['lfeon']) { 
  120. //$info['audio']['channels']++; 
  121. $info['audio']['channels'] .= '.1'; 
  122.  
  123. $thisfile_ac3['channels_enabled'] = self::channelsEnabledLookup($thisfile_ac3_raw_bsi['acmod'], $thisfile_ac3_raw_bsi['lfeon']); 
  124.  
  125. // This indicates how far the average dialogue level is below digital 100 percent. Valid values are 1-31. 
  126. // The value of 0 is reserved. The values of 1 to 31 are interpreted as -1 dB to -31 dB with respect to digital 100 percent. 
  127. $thisfile_ac3_raw_bsi['dialnorm'] = $this->readHeaderBSI(5); 
  128. $thisfile_ac3['dialogue_normalization'] = '-'.$thisfile_ac3_raw_bsi['dialnorm'].'dB'; 
  129.  
  130. $thisfile_ac3_raw_bsi['compre_flag'] = (bool) $this->readHeaderBSI(1); 
  131. if ($thisfile_ac3_raw_bsi['compre_flag']) { 
  132. $thisfile_ac3_raw_bsi['compr'] = $this->readHeaderBSI(8); 
  133. $thisfile_ac3['heavy_compression'] = self::heavyCompression($thisfile_ac3_raw_bsi['compr']); 
  134.  
  135. $thisfile_ac3_raw_bsi['langcode_flag'] = (bool) $this->readHeaderBSI(1); 
  136. if ($thisfile_ac3_raw_bsi['langcode_flag']) { 
  137. $thisfile_ac3_raw_bsi['langcod'] = $this->readHeaderBSI(8); 
  138.  
  139. $thisfile_ac3_raw_bsi['audprodie'] = (bool) $this->readHeaderBSI(1); 
  140. if ($thisfile_ac3_raw_bsi['audprodie']) { 
  141. $thisfile_ac3_raw_bsi['mixlevel'] = $this->readHeaderBSI(5); 
  142. $thisfile_ac3_raw_bsi['roomtyp'] = $this->readHeaderBSI(2); 
  143.  
  144. $thisfile_ac3['mixing_level'] = (80 + $thisfile_ac3_raw_bsi['mixlevel']).'dB'; 
  145. $thisfile_ac3['room_type'] = self::roomTypeLookup($thisfile_ac3_raw_bsi['roomtyp']); 
  146.  
  147. if ($thisfile_ac3_raw_bsi['acmod'] == 0x00) { 
  148. // If acmod is 0, then two completely independent program channels (dual mono) 
  149. // are encoded into the bit stream, and are referenced as Ch1, Ch2. In this case,  
  150. // a number of additional items are present in BSI or audblk to fully describe Ch2. 
  151.  
  152. // This indicates how far the average dialogue level is below digital 100 percent. Valid values are 1-31. 
  153. // The value of 0 is reserved. The values of 1 to 31 are interpreted as -1 dB to -31 dB with respect to digital 100 percent. 
  154. $thisfile_ac3_raw_bsi['dialnorm2'] = $this->readHeaderBSI(5); 
  155. $thisfile_ac3['dialogue_normalization2'] = '-'.$thisfile_ac3_raw_bsi['dialnorm2'].'dB'; 
  156.  
  157. $thisfile_ac3_raw_bsi['compre_flag2'] = (bool) $this->readHeaderBSI(1); 
  158. if ($thisfile_ac3_raw_bsi['compre_flag2']) { 
  159. $thisfile_ac3_raw_bsi['compr2'] = $this->readHeaderBSI(8); 
  160. $thisfile_ac3['heavy_compression2'] = self::heavyCompression($thisfile_ac3_raw_bsi['compr2']); 
  161.  
  162. $thisfile_ac3_raw_bsi['langcode_flag2'] = (bool) $this->readHeaderBSI(1); 
  163. if ($thisfile_ac3_raw_bsi['langcode_flag2']) { 
  164. $thisfile_ac3_raw_bsi['langcod2'] = $this->readHeaderBSI(8); 
  165.  
  166. $thisfile_ac3_raw_bsi['audprodie2'] = (bool) $this->readHeaderBSI(1); 
  167. if ($thisfile_ac3_raw_bsi['audprodie2']) { 
  168. $thisfile_ac3_raw_bsi['mixlevel2'] = $this->readHeaderBSI(5); 
  169. $thisfile_ac3_raw_bsi['roomtyp2'] = $this->readHeaderBSI(2); 
  170.  
  171. $thisfile_ac3['mixing_level2'] = (80 + $thisfile_ac3_raw_bsi['mixlevel2']).'dB'; 
  172. $thisfile_ac3['room_type2'] = self::roomTypeLookup($thisfile_ac3_raw_bsi['roomtyp2']); 
  173.  
  174.  
  175. $thisfile_ac3_raw_bsi['copyright'] = (bool) $this->readHeaderBSI(1); 
  176.  
  177. $thisfile_ac3_raw_bsi['original'] = (bool) $this->readHeaderBSI(1); 
  178.  
  179. $thisfile_ac3_raw_bsi['timecode1_flag'] = (bool) $this->readHeaderBSI(1); 
  180. if ($thisfile_ac3_raw_bsi['timecode1_flag']) { 
  181. $thisfile_ac3_raw_bsi['timecode1'] = $this->readHeaderBSI(14); 
  182.  
  183. $thisfile_ac3_raw_bsi['timecode2_flag'] = (bool) $this->readHeaderBSI(1); 
  184. if ($thisfile_ac3_raw_bsi['timecode2_flag']) { 
  185. $thisfile_ac3_raw_bsi['timecode2'] = $this->readHeaderBSI(14); 
  186.  
  187. $thisfile_ac3_raw_bsi['addbsi_flag'] = (bool) $this->readHeaderBSI(1); 
  188. if ($thisfile_ac3_raw_bsi['addbsi_flag']) { 
  189. $thisfile_ac3_raw_bsi['addbsi_length'] = $this->readHeaderBSI(6); 
  190.  
  191. $this->AC3header['bsi'] .= getid3_lib::BigEndian2Bin($this->fread($thisfile_ac3_raw_bsi['addbsi_length'])); 
  192.  
  193. $thisfile_ac3_raw_bsi['addbsi_data'] = substr($this->AC3header['bsi'], $this->BSIoffset, $thisfile_ac3_raw_bsi['addbsi_length'] * 8); 
  194. $this->BSIoffset += $thisfile_ac3_raw_bsi['addbsi_length'] * 8; 
  195.  
  196. return true; 
  197.  
  198. private function readHeaderBSI($length) { 
  199. $data = substr($this->AC3header['bsi'], $this->BSIoffset, $length); 
  200. $this->BSIoffset += $length; 
  201.  
  202. return bindec($data); 
  203.  
  204. public static function sampleRateCodeLookup($fscod) { 
  205. static $sampleRateCodeLookup = array( 
  206. 0 => 48000,  
  207. 1 => 44100,  
  208. 2 => 32000,  
  209. 3 => 'reserved' // If the reserved code is indicated, the decoder should not attempt to decode audio and should mute. 
  210. ); 
  211. return (isset($sampleRateCodeLookup[$fscod]) ? $sampleRateCodeLookup[$fscod] : false); 
  212.  
  213. public static function serviceTypeLookup($bsmod, $acmod) { 
  214. static $serviceTypeLookup = array(); 
  215. if (empty($serviceTypeLookup)) { 
  216. for ($i = 0; $i <= 7; $i++) { 
  217. $serviceTypeLookup[0][$i] = 'main audio service: complete main (CM)'; 
  218. $serviceTypeLookup[1][$i] = 'main audio service: music and effects (ME)'; 
  219. $serviceTypeLookup[2][$i] = 'associated service: visually impaired (VI)'; 
  220. $serviceTypeLookup[3][$i] = 'associated service: hearing impaired (HI)'; 
  221. $serviceTypeLookup[4][$i] = 'associated service: dialogue (D)'; 
  222. $serviceTypeLookup[5][$i] = 'associated service: commentary (C)'; 
  223. $serviceTypeLookup[6][$i] = 'associated service: emergency (E)'; 
  224.  
  225. $serviceTypeLookup[7][1] = 'associated service: voice over (VO)'; 
  226. for ($i = 2; $i <= 7; $i++) { 
  227. $serviceTypeLookup[7][$i] = 'main audio service: karaoke'; 
  228. return (isset($serviceTypeLookup[$bsmod][$acmod]) ? $serviceTypeLookup[$bsmod][$acmod] : false); 
  229.  
  230. public static function audioCodingModeLookup($acmod) { 
  231. // array(channel configuration, # channels (not incl LFE), channel order) 
  232. static $audioCodingModeLookup = array ( 
  233. 0 => array('channel_config'=>'1+1', 'num_channels'=>2, 'channel_order'=>'Ch1, Ch2'),  
  234. 1 => array('channel_config'=>'1/0', 'num_channels'=>1, 'channel_order'=>'C'),  
  235. 2 => array('channel_config'=>'2/0', 'num_channels'=>2, 'channel_order'=>'L, R'),  
  236. 3 => array('channel_config'=>'3/0', 'num_channels'=>3, 'channel_order'=>'L, C, R'),  
  237. 4 => array('channel_config'=>'2/1', 'num_channels'=>3, 'channel_order'=>'L, R, S'),  
  238. 5 => array('channel_config'=>'3/1', 'num_channels'=>4, 'channel_order'=>'L, C, R, S'),  
  239. 6 => array('channel_config'=>'2/2', 'num_channels'=>4, 'channel_order'=>'L, R, SL, SR'),  
  240. 7 => array('channel_config'=>'3/2', 'num_channels'=>5, 'channel_order'=>'L, C, R, SL, SR'),  
  241. ); 
  242. return (isset($audioCodingModeLookup[$acmod]) ? $audioCodingModeLookup[$acmod] : false); 
  243.  
  244. public static function centerMixLevelLookup($cmixlev) { 
  245. static $centerMixLevelLookup; 
  246. if (empty($centerMixLevelLookup)) { 
  247. $centerMixLevelLookup = array( 
  248. 0 => pow(2, -3.0 / 6), // 0.707 (-3.0 dB) 
  249. 1 => pow(2, -4.5 / 6), // 0.595 (-4.5 dB) 
  250. 2 => pow(2, -6.0 / 6), // 0.500 (-6.0 dB) 
  251. 3 => 'reserved' 
  252. ); 
  253. return (isset($centerMixLevelLookup[$cmixlev]) ? $centerMixLevelLookup[$cmixlev] : false); 
  254.  
  255. public static function surroundMixLevelLookup($surmixlev) { 
  256. static $surroundMixLevelLookup; 
  257. if (empty($surroundMixLevelLookup)) { 
  258. $surroundMixLevelLookup = array( 
  259. 0 => pow(2, -3.0 / 6),  
  260. 1 => pow(2, -6.0 / 6),  
  261. 2 => 0,  
  262. 3 => 'reserved' 
  263. ); 
  264. return (isset($surroundMixLevelLookup[$surmixlev]) ? $surroundMixLevelLookup[$surmixlev] : false); 
  265.  
  266. public static function dolbySurroundModeLookup($dsurmod) { 
  267. static $dolbySurroundModeLookup = array( 
  268. 0 => 'not indicated',  
  269. 1 => 'Not Dolby Surround encoded',  
  270. 2 => 'Dolby Surround encoded',  
  271. 3 => 'reserved' 
  272. ); 
  273. return (isset($dolbySurroundModeLookup[$dsurmod]) ? $dolbySurroundModeLookup[$dsurmod] : false); 
  274.  
  275. public static function channelsEnabledLookup($acmod, $lfeon) { 
  276. $lookup = array( 
  277. 'ch1'=>(bool) ($acmod == 0),  
  278. 'ch2'=>(bool) ($acmod == 0),  
  279. 'left'=>(bool) ($acmod > 1),  
  280. 'right'=>(bool) ($acmod > 1),  
  281. 'center'=>(bool) ($acmod & 0x01),  
  282. 'surround_mono'=>false,  
  283. 'surround_left'=>false,  
  284. 'surround_right'=>false,  
  285. 'lfe'=>$lfeon); 
  286. switch ($acmod) { 
  287. case 4: 
  288. case 5: 
  289. $lookup['surround_mono'] = true; 
  290. break; 
  291. case 6: 
  292. case 7: 
  293. $lookup['surround_left'] = true; 
  294. $lookup['surround_right'] = true; 
  295. break; 
  296. return $lookup; 
  297.  
  298. public static function heavyCompression($compre) { 
  299. // The first four bits indicate gain changes in 6.02dB increments which can be 
  300. // implemented with an arithmetic shift operation. The following four bits 
  301. // indicate linear gain changes, and require a 5-bit multiply. 
  302. // We will represent the two 4-bit fields of compr as follows: 
  303. // X0 X1 X2 X3 . Y4 Y5 Y6 Y7 
  304. // The meaning of the X values is most simply described by considering X to represent a 4-bit 
  305. // signed integer with values from -8 to +7. The gain indicated by X is then (X + 1) * 6.02 dB. The 
  306. // following table shows this in detail. 
  307.  
  308. // Meaning of 4 msb of compr 
  309. // 7 +48.16 dB 
  310. // 6 +42.14 dB 
  311. // 5 +36.12 dB 
  312. // 4 +30.10 dB 
  313. // 3 +24.08 dB 
  314. // 2 +18.06 dB 
  315. // 1 +12.04 dB 
  316. // 0 +6.02 dB 
  317. // -1 0 dB 
  318. // -2 -6.02 dB 
  319. // -3 -12.04 dB 
  320. // -4 -18.06 dB 
  321. // -5 -24.08 dB 
  322. // -6 -30.10 dB 
  323. // -7 -36.12 dB 
  324. // -8 -42.14 dB 
  325.  
  326. $fourbit = str_pad(decbin(($compre & 0xF0) >> 4), 4, '0', STR_PAD_LEFT); 
  327. if ($fourbit{0} == '1') { 
  328. $log_gain = -8 + bindec(substr($fourbit, 1)); 
  329. } else { 
  330. $log_gain = bindec(substr($fourbit, 1)); 
  331. $log_gain = ($log_gain + 1) * getid3_lib::RGADamplitude2dB(2); 
  332.  
  333. // The value of Y is a linear representation of a gain change of up to -6 dB. Y is considered to 
  334. // be an unsigned fractional integer, with a leading value of 1, or: 0.1 Y4 Y5 Y6 Y7 (base 2). Y can 
  335. // represent values between 0.111112 (or 31/32) and 0.100002 (or 1/2). Thus, Y can represent gain 
  336. // changes from -0.28 dB to -6.02 dB. 
  337.  
  338. $lin_gain = (16 + ($compre & 0x0F)) / 32; 
  339.  
  340. // The combination of X and Y values allows compr to indicate gain changes from 
  341. // 48.16 - 0.28 = +47.89 dB, to 
  342. // -42.14 - 6.02 = -48.16 dB. 
  343.  
  344. return $log_gain - $lin_gain; 
  345.  
  346. public static function roomTypeLookup($roomtyp) { 
  347. static $roomTypeLookup = array( 
  348. 0 => 'not indicated',  
  349. 1 => 'large room, X curve monitor',  
  350. 2 => 'small room, flat monitor',  
  351. 3 => 'reserved' 
  352. ); 
  353. return (isset($roomTypeLookup[$roomtyp]) ? $roomTypeLookup[$roomtyp] : false); 
  354.  
  355. public static function frameSizeLookup($frmsizecod, $fscod) { 
  356. $padding = (bool) ($frmsizecod % 2); 
  357. $framesizeid = floor($frmsizecod / 2); 
  358.  
  359. static $frameSizeLookup = array(); 
  360. if (empty($frameSizeLookup)) { 
  361. $frameSizeLookup = array ( 
  362. 0 => array(128, 138, 192),  
  363. 1 => array(40, 160, 174, 240),  
  364. 2 => array(48, 192, 208, 288),  
  365. 3 => array(56, 224, 242, 336),  
  366. 4 => array(64, 256, 278, 384),  
  367. 5 => array(80, 320, 348, 480),  
  368. 6 => array(96, 384, 416, 576),  
  369. 7 => array(112, 448, 486, 672),  
  370. 8 => array(128, 512, 556, 768),  
  371. 9 => array(160, 640, 696, 960),  
  372. 10 => array(192, 768, 834, 1152),  
  373. 11 => array(224, 896, 974, 1344),  
  374. 12 => array(256, 1024, 1114, 1536),  
  375. 13 => array(320, 1280, 1392, 1920),  
  376. 14 => array(384, 1536, 1670, 2304),  
  377. 15 => array(448, 1792, 1950, 2688),  
  378. 16 => array(512, 2048, 2228, 3072),  
  379. 17 => array(576, 2304, 2506, 3456),  
  380. 18 => array(640, 2560, 2786, 3840) 
  381. ); 
  382. if (($fscod == 1) && $padding) { 
  383. // frame lengths are padded by 1 word (16 bits) at 44100 
  384. $frameSizeLookup[$frmsizecod] += 2; 
  385. return (isset($frameSizeLookup[$framesizeid][$fscod]) ? $frameSizeLookup[$framesizeid][$fscod] : false); 
  386.  
  387. public static function bitrateLookup($frmsizecod) { 
  388. $framesizeid = floor($frmsizecod / 2); 
  389.  
  390. static $bitrateLookup = array( 
  391. 0 => 32000,  
  392. 1 => 40000,  
  393. 2 => 48000,  
  394. 3 => 56000,  
  395. 4 => 64000,  
  396. 5 => 80000,  
  397. 6 => 96000,  
  398. 7 => 112000,  
  399. 8 => 128000,  
  400. 9 => 160000,  
  401. 10 => 192000,  
  402. 11 => 224000,  
  403. 12 => 256000,  
  404. 13 => 320000,  
  405. 14 => 384000,  
  406. 15 => 448000,  
  407. 16 => 512000,  
  408. 17 => 576000,  
  409. 18 => 640000 
  410. ); 
  411. return (isset($bitrateLookup[$framesizeid]) ? $bitrateLookup[$framesizeid] : false); 
  412.  
  413.