34 $info = &$this->getid3->info;
35 $info[
'fileformat'] =
'aac';
36 $info[
'audio'][
'dataformat'] =
'aac';
37 $info[
'audio'][
'lossless'] =
false;
40 $AACheader = $this->
fread(1024);
43 if (substr($AACheader, 0, 4) ==
'ADIF') {
68 $info[
'aac'][
'header_type'] =
'ADIF';
70 $info[
'aac'][
'header'][
'mpeg_version'] = 4;
72 $info[
'aac'][
'header'][
'copyright'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) ==
'1');
74 if (
$info[
'aac'][
'header'][
'copyright']) {
78 $info[
'aac'][
'header'][
'original_copy'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) ==
'1');
80 $info[
'aac'][
'header'][
'home'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) ==
'1');
82 $info[
'aac'][
'header'][
'is_vbr'] = (bool) (substr($AACheaderBitstream, $bitoffset, 1) ==
'1');
84 if (
$info[
'aac'][
'header'][
'is_vbr']) {
85 $info[
'audio'][
'bitrate_mode'] =
'vbr';
89 $info[
'audio'][
'bitrate_mode'] =
'cbr';
92 $info[
'audio'][
'bitrate'] =
$info[
'aac'][
'header'][
'bitrate'];
94 if (
$info[
'audio'][
'bitrate'] == 0) {
95 $this->
error(
'Corrupt AAC file: bitrate_audio == zero');
101 for (
$i = 0;
$i <
$info[
'aac'][
'header'][
'num_program_configs'];
$i++) {
150 if (!$info[
'aac'][
'header'][
'is_vbr']) {
151 $info[
'aac'][
'program_configs'][
$i][
'buffer_fullness'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 20));
154 $info[
'aac'][
'program_configs'][
$i][
'element_instance_tag'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
156 $info[
'aac'][
'program_configs'][
$i][
'object_type'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
158 $info[
'aac'][
'program_configs'][
$i][
'sampling_frequency_index'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
160 $info[
'aac'][
'program_configs'][
$i][
'num_front_channel_elements'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
162 $info[
'aac'][
'program_configs'][
$i][
'num_side_channel_elements'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
164 $info[
'aac'][
'program_configs'][
$i][
'num_back_channel_elements'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
166 $info[
'aac'][
'program_configs'][
$i][
'num_lfe_channel_elements'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
168 $info[
'aac'][
'program_configs'][
$i][
'num_assoc_data_elements'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 3));
170 $info[
'aac'][
'program_configs'][
$i][
'num_valid_cc_elements'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
172 $info[
'aac'][
'program_configs'][
$i][
'mono_mixdown_present'] = (bool)
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
174 if ($info[
'aac'][
'program_configs'][
$i][
'mono_mixdown_present']) {
175 $info[
'aac'][
'program_configs'][
$i][
'mono_mixdown_element_number'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
178 $info[
'aac'][
'program_configs'][
$i][
'stereo_mixdown_present'] = (bool)
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
180 if ($info[
'aac'][
'program_configs'][$i][
'stereo_mixdown_present']) {
181 $info[
'aac'][
'program_configs'][
$i][
'stereo_mixdown_element_number'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
184 $info[
'aac'][
'program_configs'][
$i][
'matrix_mixdown_idx_present'] = (bool)
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
186 if ($info[
'aac'][
'program_configs'][$i][
'matrix_mixdown_idx_present']) {
187 $info[
'aac'][
'program_configs'][
$i][
'matrix_mixdown_idx'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 2));
189 $info[
'aac'][
'program_configs'][
$i][
'pseudo_surround_enable'] = (bool)
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
192 for ($j = 0; $j < $info[
'aac'][
'program_configs'][
$i][
'num_front_channel_elements']; $j++) {
193 $info[
'aac'][
'program_configs'][
$i][
'front_element_is_cpe'][$j] = (bool)
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
195 $info[
'aac'][
'program_configs'][
$i][
'front_element_tag_select'][$j] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
198 for ($j = 0; $j < $info[
'aac'][
'program_configs'][
$i][
'num_side_channel_elements']; $j++) {
199 $info[
'aac'][
'program_configs'][
$i][
'side_element_is_cpe'][$j] = (bool)
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
201 $info[
'aac'][
'program_configs'][
$i][
'side_element_tag_select'][$j] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
204 for ($j = 0; $j < $info[
'aac'][
'program_configs'][
$i][
'num_back_channel_elements']; $j++) {
205 $info[
'aac'][
'program_configs'][
$i][
'back_element_is_cpe'][$j] = (bool)
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
207 $info[
'aac'][
'program_configs'][
$i][
'back_element_tag_select'][$j] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
210 for ($j = 0; $j < $info[
'aac'][
'program_configs'][
$i][
'num_lfe_channel_elements']; $j++) {
211 $info[
'aac'][
'program_configs'][
$i][
'lfe_element_tag_select'][$j] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
214 for ($j = 0; $j < $info[
'aac'][
'program_configs'][
$i][
'num_assoc_data_elements']; $j++) {
215 $info[
'aac'][
'program_configs'][
$i][
'assoc_data_element_tag_select'][$j] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
218 for ($j = 0; $j < $info[
'aac'][
'program_configs'][
$i][
'num_valid_cc_elements']; $j++) {
219 $info[
'aac'][
'program_configs'][
$i][
'cc_element_is_ind_sw'][$j] = (bool)
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 1));
221 $info[
'aac'][
'program_configs'][
$i][
'valid_cc_element_tag_select'][$j] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 4));
225 $bitoffset = ceil($bitoffset / 8) * 8;
227 $info[
'aac'][
'program_configs'][
$i][
'comment_field_bytes'] =
getid3_lib::Bin2Dec(substr($AACheaderBitstream, $bitoffset, 8));
229 $info[
'aac'][
'program_configs'][
$i][
'comment_field'] =
getid3_lib::Bin2String(substr($AACheaderBitstream, $bitoffset, 8 * $info[
'aac'][
'program_configs'][$i][
'comment_field_bytes']));
230 $bitoffset += 8 * $info[
'aac'][
'program_configs'][
$i][
'comment_field_bytes'];
233 $info[
'aac'][
'header'][
'profile'] = self::AACprofileLookup($info[
'aac'][
'program_configs'][$i][
'object_type'], $info[
'aac'][
'header'][
'mpeg_version']);
234 $info[
'aac'][
'program_configs'][
$i][
'sampling_frequency'] = self::AACsampleRateLookup($info[
'aac'][
'program_configs'][$i][
'sampling_frequency_index']);
235 $info[
'audio'][
'sample_rate'] = $info[
'aac'][
'program_configs'][
$i][
'sampling_frequency'];
236 $info[
'audio'][
'channels'] = self::AACchannelCountCalculate($info[
'aac'][
'program_configs'][$i]);
237 if ($info[
'aac'][
'program_configs'][$i][
'comment_field']) {
238 $info[
'aac'][
'comments'][] = $info[
'aac'][
'program_configs'][
$i][
'comment_field'];
241 $info[
'playtime_seconds'] = (($info[
'avdataend'] - $info[
'avdataoffset']) * 8) / $info[
'audio'][
'bitrate'];
243 $info[
'audio'][
'encoder_options'] = $info[
'aac'][
'header_type'].
' '.$info[
'aac'][
'header'][
'profile'];
251 unset($info[
'fileformat']);
253 $this->
error(
'AAC-ADIF synch not found at offset '.$info[
'avdataoffset'].
' (expected "ADIF", found "'.substr($AACheader, 0, 4).
'" instead)');
static Bin2Dec($binstring, $signed=false)
static BigEndian2Bin($byteword)
static Bin2String($binstring)
fseek($bytes, $whence=SEEK_SET)