summaryrefslogtreecommitdiffstats
path: root/modules/getid3/module.audio.aac_adif.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/getid3/module.audio.aac_adif.php')
-rw-r--r--modules/getid3/module.audio.aac_adif.php58
1 files changed, 29 insertions, 29 deletions
diff --git a/modules/getid3/module.audio.aac_adif.php b/modules/getid3/module.audio.aac_adif.php
index 8f1a6853..9b2f72b6 100644
--- a/modules/getid3/module.audio.aac_adif.php
+++ b/modules/getid3/module.audio.aac_adif.php
@@ -22,14 +22,14 @@
//
// $Id: module.audio.aac_adif.php,v 1.3 2006/11/02 10:48:00 ah Exp $
-
-
+
+
class getid3_aac_adif extends getid3_handler
{
public function Analyze() {
- $getid3 = $this->getid3;
+ $getid3 = $this->getid3;
// http://faac.sourceforge.net/wiki/index.php?page=ADIF
// http://libmpeg.org/mpeg4/doc/w2203tfs.pdf
@@ -49,19 +49,19 @@ class getid3_aac_adif extends getid3_handler
// program_config_element()
// }
// }
-
+
$getid3->info['fileformat'] = 'aac';
$getid3->info['audio']['dataformat'] = 'aac';
$getid3->info['audio']['lossless'] = false;
-
+
$getid3->info['aac']['header'] = array () ;
$info_aac = &$getid3->info['aac'];
$info_aac_header = & $info_aac['header'];
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$aac_header_bitstream = getid3_lib::BigEndian2Bin(fread($getid3->fp, 1024));
-
+
$info_aac['header_type'] = 'ADIF';
$info_aac_header['mpeg_version'] = 4;
$bit_offset = 32;
@@ -71,7 +71,7 @@ class getid3_aac_adif extends getid3_handler
$info_aac_header['copyright_id'] = getid3_aac_adif::Bin2String(substr($aac_header_bitstream, $bit_offset, 72));
$bit_offset += 72;
}
-
+
$info_aac_header['original_copy'] = $aac_header_bitstream{$bit_offset++} == '1';
$info_aac_header['home'] = $aac_header_bitstream{$bit_offset++} == '1';
$info_aac_header['is_vbr'] = $aac_header_bitstream{$bit_offset++} == '1';
@@ -80,14 +80,14 @@ class getid3_aac_adif extends getid3_handler
$getid3->info['audio']['bitrate_mode'] = 'vbr';
$info_aac_header['bitrate_max'] = bindec(substr($aac_header_bitstream, $bit_offset, 23));
$bit_offset += 23;
- }
+ }
else {
$getid3->info['audio']['bitrate_mode'] = 'cbr';
$info_aac_header['bitrate'] = bindec(substr($aac_header_bitstream, $bit_offset, 23));
$bit_offset += 23;
$getid3->info['audio']['bitrate'] = $info_aac_header['bitrate'];
}
-
+
$info_aac_header['num_program_configs'] = 1 + bindec(substr($aac_header_bitstream, $bit_offset, 4));
$bit_offset += 4;
@@ -140,7 +140,7 @@ class getid3_aac_adif extends getid3_handler
// for (i = 0; i < comment_field_bytes; i++) {
// comment_field_data[i] 8
// }
-
+
$info_aac['program_configs'][$i] = array ();
$info_aac_program_configs_i = &$info_aac['program_configs'][$i];
@@ -148,7 +148,7 @@ class getid3_aac_adif extends getid3_handler
$info_aac_program_configs_i['buffer_fullness'] = bindec(substr($aac_header_bitstream, $bit_offset, 20));
$bit_offset += 20;
}
-
+
$info_aac_program_configs_i['element_instance_tag'] = bindec(substr($aac_header_bitstream, $bit_offset, 4));
$info_aac_program_configs_i['object_type'] = bindec(substr($aac_header_bitstream, $bit_offset + 4, 2));
$info_aac_program_configs_i['sampling_frequency_index'] = bindec(substr($aac_header_bitstream, $bit_offset + 6, 4));
@@ -159,26 +159,26 @@ class getid3_aac_adif extends getid3_handler
$info_aac_program_configs_i['num_assoc_data_elements'] = bindec(substr($aac_header_bitstream, $bit_offset + 24, 3));
$info_aac_program_configs_i['num_valid_cc_elements'] = bindec(substr($aac_header_bitstream, $bit_offset + 27, 4));
$bit_offset += 31;
-
+
$info_aac_program_configs_i['mono_mixdown_present'] = $aac_header_bitstream{$bit_offset++} == 1;
if ($info_aac_program_configs_i['mono_mixdown_present']) {
$info_aac_program_configs_i['mono_mixdown_element_number'] = bindec(substr($aac_header_bitstream, $bit_offset, 4));
$bit_offset += 4;
}
-
+
$info_aac_program_configs_i['stereo_mixdown_present'] = $aac_header_bitstream{$bit_offset++} == 1;
if ($info_aac_program_configs_i['stereo_mixdown_present']) {
$info_aac_program_configs_i['stereo_mixdown_element_number'] = bindec(substr($aac_header_bitstream, $bit_offset, 4));
$bit_offset += 4;
}
-
+
$info_aac_program_configs_i['matrix_mixdown_idx_present'] = $aac_header_bitstream{$bit_offset++} == 1;
if ($info_aac_program_configs_i['matrix_mixdown_idx_present']) {
$info_aac_program_configs_i['matrix_mixdown_idx'] = bindec(substr($aac_header_bitstream, $bit_offset, 2));
$bit_offset += 2;
$info_aac_program_configs_i['pseudo_surround_enable'] = $aac_header_bitstream{$bit_offset++} == 1;
}
-
+
for ($j = 0; $j < $info_aac_program_configs_i['num_front_channel_elements']; $j++) {
$info_aac_program_configs_i['front_element_is_cpe'][$j] = $aac_header_bitstream{$bit_offset++} == 1;
$info_aac_program_configs_i['front_element_tag_select'][$j] = bindec(substr($aac_header_bitstream, $bit_offset, 4));
@@ -212,19 +212,19 @@ class getid3_aac_adif extends getid3_handler
$info_aac_program_configs_i['comment_field_bytes'] = bindec(substr($aac_header_bitstream, $bit_offset, 8));
$bit_offset += 8;
-
+
$info_aac_program_configs_i['comment_field'] = getid3_aac_adif::Bin2String(substr($aac_header_bitstream, $bit_offset, 8 * $info_aac_program_configs_i['comment_field_bytes']));
$bit_offset += 8 * $info_aac_program_configs_i['comment_field_bytes'];
$info_aac_header['profile_text'] = getid3_aac_adif::AACprofileLookup($info_aac_program_configs_i['object_type'], $info_aac_header['mpeg_version']);
$info_aac_program_configs_i['sampling_frequency'] = $getid3->info['audio']['sample_rate'] = getid3_aac_adif::AACsampleRateLookup($info_aac_program_configs_i['sampling_frequency_index']);
$getid3->info['audio']['channels'] = getid3_aac_adif::AACchannelCountCalculate($info_aac_program_configs_i);
-
+
if ($info_aac_program_configs_i['comment_field']) {
$info_aac['comments'][] = $info_aac_program_configs_i['comment_field'];
}
}
-
+
$getid3->info['playtime_seconds'] = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['audio']['bitrate'];
$getid3->info['audio']['encoder_options'] = $info_aac['header_type'].' '.$info_aac_header['profile_text'];
@@ -242,11 +242,11 @@ class getid3_aac_adif extends getid3_handler
}
return $string;
}
-
-
-
+
+
+
public static function AACsampleRateLookup($samplerate_id) {
-
+
static $lookup = array (
0 => 96000,
1 => 88200,
@@ -271,14 +271,14 @@ class getid3_aac_adif extends getid3_handler
public static function AACprofileLookup($profile_id, $mpeg_version) {
-
+
static $lookup = array (
- 2 => array (
+ 2 => array (
0 => 'Main profile',
1 => 'Low Complexity profile (LC)',
2 => 'Scalable Sample Rate profile (SSR)',
3 => '(reserved)'
- ),
+ ),
4 => array (
0 => 'AAC_MAIN',
1 => 'AAC_LC',
@@ -292,17 +292,17 @@ class getid3_aac_adif extends getid3_handler
public static function AACchannelCountCalculate($program_configs) {
-
+
$channels = 0;
-
+
foreach (array ('front', 'side', 'back') as $placement) {
for ($i = 0; $i < $program_configs['num_'.$placement.'_channel_elements']; $i++) {
-
+
// Each element is channel pair (CPE = Channel Pair Element)
$channels += 1 + ($program_configs[$placement.'_element_is_cpe'][$i] ? 1 : 0);
}
}
-
+
return $channels + $program_configs['num_lfe_channel_elements'];
}