3 /////////////////////////////////////////////////////////////////
4 /// getID3() by James Heinrich <info@getid3.org> //
5 // available at https://github.com/JamesHeinrich/getID3 //
6 // or https://www.getid3.org //
7 // or http://getid3.sourceforge.net //
8 // see readme.txt for more details //
9 /////////////////////////////////////////////////////////////////
11 // module.audio.aac.php //
12 // module for analyzing AAC Audio files //
13 // dependencies: NONE //
15 /////////////////////////////////////////////////////////////////
17 if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
21 class getid3_aac
extends getid3_handler
26 public function Analyze() {
27 $info = &$this->getid3
->info
;
28 $this->fseek($info['avdataoffset']);
29 if ($this->fread(4) == 'ADIF') {
30 $this->getAACADIFheaderFilepointer();
32 $this->getAACADTSheaderFilepointer();
40 public function getAACADIFheaderFilepointer() {
41 $info = &$this->getid3
->info
;
42 $info['fileformat'] = 'aac';
43 $info['audio']['dataformat'] = 'aac';
44 $info['audio']['lossless'] = false;
46 $this->fseek($info['avdataoffset']);
47 $AACheader = $this->fread(1024);
50 if (substr($AACheader, 0, 4) == 'ADIF') {
52 // http://faac.sourceforge.net/wiki/index.php?page=ADIF
54 // http://libmpeg.org/mpeg4/doc/w2203tfs.pdf
57 // copyright_id_present 1
58 // if( copyright_id_present )
64 // num_program_config_elements 4
65 // for (i = 0; i < num_program_config_elements + 1; i++ ) {
66 // if( bitstream_type == '0' )
67 // adif_buffer_fullness 20
68 // program_config_element()
72 $AACheaderBitstream = getid3_lib
::BigEndian2Bin($AACheader);
75 $info['aac']['header_type'] = 'ADIF';
77 $info['aac']['header']['mpeg_version'] = 4;
79 $info['aac']['header']['copyright'] = substr($AACheaderBitstream, $bitoffset, 1) == '1';
81 if ($info['aac']['header']['copyright']) {
82 $info['aac']['header']['copyright_id'] = getid3_lib
::Bin2String(substr($AACheaderBitstream, $bitoffset, 72));
85 $info['aac']['header']['original_copy'] = substr($AACheaderBitstream, $bitoffset, 1) == '1';
87 $info['aac']['header']['home'] = substr($AACheaderBitstream, $bitoffset, 1) == '1';
89 $info['aac']['header']['is_vbr'] = substr($AACheaderBitstream, $bitoffset, 1) == '1';
91 if ($info['aac']['header']['is_vbr']) {
92 $info['audio']['bitrate_mode'] = 'vbr';
93 $info['aac']['header']['bitrate_max'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 23));
96 $info['audio']['bitrate_mode'] = 'cbr';
97 $info['aac']['header']['bitrate'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 23));
99 $info['audio']['bitrate'] = $info['aac']['header']['bitrate'];
101 if ($info['audio']['bitrate'] == 0) {
102 $this->error('Corrupt AAC file: bitrate_audio == zero');
105 $info['aac']['header']['num_program_configs'] = 1 + getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
108 for ($i = 0; $i < $info['aac']['header']['num_program_configs']; $i++
) {
109 // http://www.audiocoding.com/wiki/index.php?page=program_config_element
111 // buffer_fullness 20
113 // element_instance_tag 4
115 // sampling_frequency_index 4
116 // num_front_channel_elements 4
117 // num_side_channel_elements 4
118 // num_back_channel_elements 4
119 // num_lfe_channel_elements 2
120 // num_assoc_data_elements 3
121 // num_valid_cc_elements 4
122 // mono_mixdown_present 1
123 // mono_mixdown_element_number 4 if mono_mixdown_present == 1
124 // stereo_mixdown_present 1
125 // stereo_mixdown_element_number 4 if stereo_mixdown_present == 1
126 // matrix_mixdown_idx_present 1
127 // matrix_mixdown_idx 2 if matrix_mixdown_idx_present == 1
128 // pseudo_surround_enable 1 if matrix_mixdown_idx_present == 1
129 // for (i = 0; i < num_front_channel_elements; i++) {
130 // front_element_is_cpe[i] 1
131 // front_element_tag_select[i] 4
133 // for (i = 0; i < num_side_channel_elements; i++) {
134 // side_element_is_cpe[i] 1
135 // side_element_tag_select[i] 4
137 // for (i = 0; i < num_back_channel_elements; i++) {
138 // back_element_is_cpe[i] 1
139 // back_element_tag_select[i] 4
141 // for (i = 0; i < num_lfe_channel_elements; i++) {
142 // lfe_element_tag_select[i] 4
144 // for (i = 0; i < num_assoc_data_elements; i++) {
145 // assoc_data_element_tag_select[i] 4
147 // for (i = 0; i < num_valid_cc_elements; i++) {
148 // cc_element_is_ind_sw[i] 1
149 // valid_cc_element_tag_select[i] 4
151 // byte_alignment() VAR
152 // comment_field_bytes 8
153 // for (i = 0; i < comment_field_bytes; i++) {
154 // comment_field_data[i] 8
157 if (!$info['aac']['header']['is_vbr']) {
158 $info['aac']['program_configs'][$i]['buffer_fullness'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 20));
161 $info['aac']['program_configs'][$i]['element_instance_tag'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
163 $info['aac']['program_configs'][$i]['object_type'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
165 $info['aac']['program_configs'][$i]['sampling_frequency_index'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
167 $info['aac']['program_configs'][$i]['num_front_channel_elements'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
169 $info['aac']['program_configs'][$i]['num_side_channel_elements'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
171 $info['aac']['program_configs'][$i]['num_back_channel_elements'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
173 $info['aac']['program_configs'][$i]['num_lfe_channel_elements'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
175 $info['aac']['program_configs'][$i]['num_assoc_data_elements'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 3));
177 $info['aac']['program_configs'][$i]['num_valid_cc_elements'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
179 $info['aac']['program_configs'][$i]['mono_mixdown_present'] = (bool) getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
181 if ($info['aac']['program_configs'][$i]['mono_mixdown_present']) {
182 $info['aac']['program_configs'][$i]['mono_mixdown_element_number'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
185 $info['aac']['program_configs'][$i]['stereo_mixdown_present'] = (bool) getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
187 if ($info['aac']['program_configs'][$i]['stereo_mixdown_present']) {
188 $info['aac']['program_configs'][$i]['stereo_mixdown_element_number'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
191 $info['aac']['program_configs'][$i]['matrix_mixdown_idx_present'] = (bool) getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
193 if ($info['aac']['program_configs'][$i]['matrix_mixdown_idx_present']) {
194 $info['aac']['program_configs'][$i]['matrix_mixdown_idx'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
196 $info['aac']['program_configs'][$i]['pseudo_surround_enable'] = (bool) getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
199 for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_front_channel_elements']; $j++
) {
200 $info['aac']['program_configs'][$i]['front_element_is_cpe'][$j] = (bool) getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
202 $info['aac']['program_configs'][$i]['front_element_tag_select'][$j] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
205 for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_side_channel_elements']; $j++
) {
206 $info['aac']['program_configs'][$i]['side_element_is_cpe'][$j] = (bool) getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
208 $info['aac']['program_configs'][$i]['side_element_tag_select'][$j] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
211 for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_back_channel_elements']; $j++
) {
212 $info['aac']['program_configs'][$i]['back_element_is_cpe'][$j] = (bool) getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
214 $info['aac']['program_configs'][$i]['back_element_tag_select'][$j] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
217 for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_lfe_channel_elements']; $j++
) {
218 $info['aac']['program_configs'][$i]['lfe_element_tag_select'][$j] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
221 for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_assoc_data_elements']; $j++
) {
222 $info['aac']['program_configs'][$i]['assoc_data_element_tag_select'][$j] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
225 for ($j = 0; $j < $info['aac']['program_configs'][$i]['num_valid_cc_elements']; $j++
) {
226 $info['aac']['program_configs'][$i]['cc_element_is_ind_sw'][$j] = (bool) getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
228 $info['aac']['program_configs'][$i]['valid_cc_element_tag_select'][$j] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
232 $bitoffset = ceil($bitoffset / 8) * 8;
234 $info['aac']['program_configs'][$i]['comment_field_bytes'] = getid3_lib
::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 8));
236 $info['aac']['program_configs'][$i]['comment_field'] = getid3_lib
::Bin2String(substr($AACheaderBitstream, $bitoffset, 8 * $info['aac']['program_configs'][$i]['comment_field_bytes']));
237 $bitoffset +
= 8 * $info['aac']['program_configs'][$i]['comment_field_bytes'];
240 $info['aac']['header']['profile'] = self
::AACprofileLookup($info['aac']['program_configs'][$i]['object_type'], $info['aac']['header']['mpeg_version']);
241 $info['aac']['program_configs'][$i]['sampling_frequency'] = self
::AACsampleRateLookup($info['aac']['program_configs'][$i]['sampling_frequency_index']);
242 $info['audio']['sample_rate'] = $info['aac']['program_configs'][$i]['sampling_frequency'];
243 $info['audio']['channels'] = self
::AACchannelCountCalculate($info['aac']['program_configs'][$i]);
244 if ($info['aac']['program_configs'][$i]['comment_field']) {
245 $info['aac']['comments'][] = $info['aac']['program_configs'][$i]['comment_field'];
248 $info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['audio']['bitrate'];
250 $info['audio']['encoder_options'] = $info['aac']['header_type'].' '.$info['aac']['header']['profile'];
258 unset($info['fileformat']);
260 $this->error('AAC-ADIF synch not found at offset '.$info['avdataoffset'].' (expected "ADIF", found "'.substr($AACheader, 0, 4).'" instead)');
268 * @param int $MaxFramesToScan
269 * @param bool $ReturnExtendedInfo
273 public function getAACADTSheaderFilepointer($MaxFramesToScan=1000000, $ReturnExtendedInfo=false) {
274 $info = &$this->getid3
->info
;
276 // based loosely on code from AACfile by Jurgen Faul <jfaulØgmx.de>
277 // http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
280 // http://faac.sourceforge.net/wiki/index.php?page=ADTS // dead link
281 // http://wiki.multimedia.cx/index.php?title=ADTS
283 // * ADTS Fixed Header: these don't change from frame to frame
284 // syncword 12 always: '111111111111'
285 // ID 1 0: MPEG-4, 1: MPEG-2
286 // MPEG layer 2 If you send AAC in MPEG-TS, set to 0
287 // protection_absent 1 0: CRC present; 1: no CRC
288 // profile 2 0: AAC Main; 1: AAC LC (Low Complexity); 2: AAC SSR (Scalable Sample Rate); 3: AAC LTP (Long Term Prediction)
289 // sampling_frequency_index 4 15 not allowed
290 // private_bit 1 usually 0
291 // channel_configuration 3
292 // original/copy 1 0: original; 1: copy
294 // emphasis 2 only if ID == 0 (ie MPEG-4) // not present in some documentation?
296 // * ADTS Variable Header: these can change from frame to frame
297 // copyright_identification_bit 1
298 // copyright_identification_start 1
299 // aac_frame_length 13 length of the frame including header (in bytes)
300 // adts_buffer_fullness 11 0x7FF indicates VBR
301 // no_raw_data_blocks_in_frame 2
303 // * ADTS Error check
304 // crc_check 16 only if protection_absent == 0
306 $byteoffset = $info['avdataoffset'];
309 // Init bit pattern array
310 static $decbin = array();
313 for ($i = 0; $i < 256; $i++
) {
314 $decbin[chr($i)] = str_pad(decbin($i), 8, '0', STR_PAD_LEFT
);
317 // used to calculate bitrate below
318 $BitrateCache = array();
322 // breaks out when end-of-file encountered, or invalid data found,
323 // or MaxFramesToScan frames have been scanned
325 if (!getid3_lib
::intValueSupported($byteoffset)) {
326 $this->warning('Unable to parse AAC file beyond '.$this->ftell().' (PHP does not support file operations beyond '.round(PHP_INT_MAX
/ 1073741824).'GB)');
329 $this->fseek($byteoffset);
331 // First get substring
332 $substring = $this->fread(9); // header is 7 bytes (or 9 if CRC is present)
333 $substringlength = strlen($substring);
334 if ($substringlength != 9) {
335 $this->error('Failed to read 7 bytes at offset '.($this->ftell() - $substringlength).' (only read '.$substringlength.' bytes)');
338 // this would be easier with 64-bit math, but split it up to allow for 32-bit:
339 $header1 = getid3_lib
::BigEndian2Int(substr($substring, 0, 2));
340 $header2 = getid3_lib
::BigEndian2Int(substr($substring, 2, 4));
341 $header3 = getid3_lib
::BigEndian2Int(substr($substring, 6, 1));
343 $info['aac']['header']['raw']['syncword'] = ($header1 & 0xFFF0) >> 4;
344 if ($info['aac']['header']['raw']['syncword'] != 0x0FFF) {
345 $this->error('Synch pattern (0x0FFF) not found at offset '.($this->ftell() - $substringlength).' (found 0x0'.strtoupper(dechex($info['aac']['header']['raw']['syncword'])).' instead)');
346 //if ($info['fileformat'] == 'aac') {
353 // Gather info for first frame only - this takes time to do 1000 times!
354 if ($framenumber == 0) {
355 $info['aac']['header_type'] = 'ADTS';
356 $info['fileformat'] = 'aac';
357 $info['audio']['dataformat'] = 'aac';
359 $info['aac']['header']['raw']['mpeg_version'] = ($header1 & 0x0008) >> 3;
360 $info['aac']['header']['raw']['mpeg_layer'] = ($header1 & 0x0006) >> 1;
361 $info['aac']['header']['raw']['protection_absent'] = ($header1 & 0x0001) >> 0;
363 $info['aac']['header']['raw']['profile_code'] = ($header2 & 0xC0000000) >> 30;
364 $info['aac']['header']['raw']['sample_rate_code'] = ($header2 & 0x3C000000) >> 26;
365 $info['aac']['header']['raw']['private_stream'] = ($header2 & 0x02000000) >> 25;
366 $info['aac']['header']['raw']['channels_code'] = ($header2 & 0x01C00000) >> 22;
367 $info['aac']['header']['raw']['original'] = ($header2 & 0x00200000) >> 21;
368 $info['aac']['header']['raw']['home'] = ($header2 & 0x00100000) >> 20;
369 $info['aac']['header']['raw']['copyright_stream'] = ($header2 & 0x00080000) >> 19;
370 $info['aac']['header']['raw']['copyright_start'] = ($header2 & 0x00040000) >> 18;
371 $info['aac']['header']['raw']['frame_length'] = ($header2 & 0x0003FFE0) >> 5;
373 $info['aac']['header']['mpeg_version'] = ($info['aac']['header']['raw']['mpeg_version'] ?
2 : 4);
374 $info['aac']['header']['crc_present'] = ($info['aac']['header']['raw']['protection_absent'] ?
false: true);
375 $info['aac']['header']['profile'] = self
::AACprofileLookup($info['aac']['header']['raw']['profile_code'], $info['aac']['header']['mpeg_version']);
376 $info['aac']['header']['sample_frequency'] = self
::AACsampleRateLookup($info['aac']['header']['raw']['sample_rate_code']);
377 $info['aac']['header']['private'] = (bool) $info['aac']['header']['raw']['private_stream'];
378 $info['aac']['header']['original'] = (bool) $info['aac']['header']['raw']['original'];
379 $info['aac']['header']['home'] = (bool) $info['aac']['header']['raw']['home'];
380 $info['aac']['header']['channels'] = (($info['aac']['header']['raw']['channels_code'] == 7) ?
8 : $info['aac']['header']['raw']['channels_code']);
381 if ($ReturnExtendedInfo) {
382 $info['aac'][$framenumber]['copyright_id_bit'] = (bool) $info['aac']['header']['raw']['copyright_stream'];
383 $info['aac'][$framenumber]['copyright_id_start'] = (bool) $info['aac']['header']['raw']['copyright_start'];
386 if ($info['aac']['header']['raw']['mpeg_layer'] != 0) {
387 $this->warning('Layer error - expected "0", found "'.$info['aac']['header']['raw']['mpeg_layer'].'" instead');
389 if ($info['aac']['header']['sample_frequency'] == 0) {
390 $this->error('Corrupt AAC file: sample_frequency == zero');
394 $info['audio']['sample_rate'] = $info['aac']['header']['sample_frequency'];
395 $info['audio']['channels'] = $info['aac']['header']['channels'];
398 $FrameLength = ($header2 & 0x0003FFE0) >> 5;
400 if (!isset($BitrateCache[$FrameLength])) {
401 $BitrateCache[$FrameLength] = ($info['aac']['header']['sample_frequency'] / 1024) * $FrameLength * 8;
403 getid3_lib
::safe_inc($info['aac']['bitrate_distribution'][$BitrateCache[$FrameLength]], 1);
405 $info['aac'][$framenumber]['aac_frame_length'] = $FrameLength;
407 $info['aac'][$framenumber]['adts_buffer_fullness'] = (($header2 & 0x0000001F) << 6) & (($header3 & 0xFC) >> 2);
408 if ($info['aac'][$framenumber]['adts_buffer_fullness'] == 0x07FF) {
409 $info['audio']['bitrate_mode'] = 'vbr';
411 $info['audio']['bitrate_mode'] = 'cbr';
413 $info['aac'][$framenumber]['num_raw_data_blocks'] = (($header3 & 0x03) >> 0);
415 if ($info['aac']['header']['crc_present']) {
416 //$info['aac'][$framenumber]['crc'] = getid3_lib::BigEndian2Int(substr($substring, 7, 2);
419 if (!$ReturnExtendedInfo) {
420 unset($info['aac'][$framenumber]);
424 $rounded_precision = 5000;
425 $info['aac']['bitrate_distribution_rounded'] = array();
426 foreach ($info['aac']['bitrate_distribution'] as $bitrate => $count) {
427 $rounded_bitrate = round($bitrate / $rounded_precision) * $rounded_precision;
428 getid3_lib::safe_inc($info['aac']['bitrate_distribution_rounded'][$rounded_bitrate], $count);
430 ksort($info['aac']['bitrate_distribution_rounded']);
433 $byteoffset +
= $FrameLength;
434 if ((++
$framenumber < $MaxFramesToScan) && (($byteoffset +
10) < $info['avdataend'])) {
440 $info['aac']['frames'] = $framenumber;
441 $info['playtime_seconds'] = ($info['avdataend'] / $byteoffset) * (($framenumber * 1024) / $info['aac']['header']['sample_frequency']); // (1 / % of file scanned) * (samples / (samples/sec)) = seconds
442 if ($info['playtime_seconds'] == 0) {
443 $this->error('Corrupt AAC file: playtime_seconds == zero');
446 $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
447 ksort($info['aac']['bitrate_distribution']);
449 $info['audio']['encoder_options'] = $info['aac']['header_type'].' '.$info['aac']['header']['profile'];
455 // should never get here.
459 * @param int $samplerateid
463 public static function AACsampleRateLookup($samplerateid) {
464 static $AACsampleRateLookup = array();
465 if (empty($AACsampleRateLookup)) {
466 $AACsampleRateLookup[0] = 96000;
467 $AACsampleRateLookup[1] = 88200;
468 $AACsampleRateLookup[2] = 64000;
469 $AACsampleRateLookup[3] = 48000;
470 $AACsampleRateLookup[4] = 44100;
471 $AACsampleRateLookup[5] = 32000;
472 $AACsampleRateLookup[6] = 24000;
473 $AACsampleRateLookup[7] = 22050;
474 $AACsampleRateLookup[8] = 16000;
475 $AACsampleRateLookup[9] = 12000;
476 $AACsampleRateLookup[10] = 11025;
477 $AACsampleRateLookup[11] = 8000;
478 $AACsampleRateLookup[12] = 0;
479 $AACsampleRateLookup[13] = 0;
480 $AACsampleRateLookup[14] = 0;
481 $AACsampleRateLookup[15] = 0;
483 return (isset($AACsampleRateLookup[$samplerateid]) ?
$AACsampleRateLookup[$samplerateid] : 'invalid');
487 * @param int $profileid
488 * @param int $mpegversion
492 public static function AACprofileLookup($profileid, $mpegversion) {
493 static $AACprofileLookup = array();
494 if (empty($AACprofileLookup)) {
495 $AACprofileLookup[2][0] = 'Main profile';
496 $AACprofileLookup[2][1] = 'Low Complexity profile (LC)';
497 $AACprofileLookup[2][2] = 'Scalable Sample Rate profile (SSR)';
498 $AACprofileLookup[2][3] = '(reserved)';
499 $AACprofileLookup[4][0] = 'AAC_MAIN';
500 $AACprofileLookup[4][1] = 'AAC_LC';
501 $AACprofileLookup[4][2] = 'AAC_SSR';
502 $AACprofileLookup[4][3] = 'AAC_LTP';
504 return (isset($AACprofileLookup[$mpegversion][$profileid]) ?
$AACprofileLookup[$mpegversion][$profileid] : 'invalid');
508 * @param array $program_configs
512 public static function AACchannelCountCalculate($program_configs) {
514 for ($i = 0; $i < $program_configs['num_front_channel_elements']; $i++
) {
516 if ($program_configs['front_element_is_cpe'][$i]) {
517 // each front element is channel pair (CPE = Channel Pair Element)
521 for ($i = 0; $i < $program_configs['num_side_channel_elements']; $i++
) {
523 if ($program_configs['side_element_is_cpe'][$i]) {
524 // each side element is channel pair (CPE = Channel Pair Element)
528 for ($i = 0; $i < $program_configs['num_back_channel_elements']; $i++
) {
530 if ($program_configs['back_element_is_cpe'][$i]) {
531 // each back element is channel pair (CPE = Channel Pair Element)
535 for ($i = 0; $i < $program_configs['num_lfe_channel_elements']; $i++
) {