ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
getid3_lpac Class Reference
+ Inheritance diagram for getid3_lpac:
+ Collaboration diagram for getid3_lpac:

Public Member Functions

 getid3_lpac (&$fd, &$ThisFileInfo)
 
 Analyze ()
 
- 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

Definition at line 18 of file module.audio.lpac.php.

Member Function Documentation

◆ Analyze()

getid3_lpac::Analyze ( )

Reimplemented from getid3_handler.

Definition at line 22 of file module.audio.lpac.php.

22 {
23 $info = &$this->getid3->info;
24
25 $this->fseek($info['avdataoffset']);
26 $LPACheader = $this->fread(14);
27 if (substr($LPACheader, 0, 4) != 'LPAC') {
28 $info['error'][] = 'Expected "LPAC" at offset '.$info['avdataoffset'].', found "'.$StreamMarker.'"';
29 return false;
30 }
31 $info['avdataoffset'] += 14;
32
33 $info['fileformat'] = 'lpac';
34 $info['audio']['dataformat'] = 'lpac';
35 $info['audio']['lossless'] = true;
36 $info['audio']['bitrate_mode'] = 'vbr';
37
38 $info['lpac']['file_version'] = getid3_lib::BigEndian2Int(substr($LPACheader, 4, 1));
39 $flags['audio_type'] = getid3_lib::BigEndian2Int(substr($LPACheader, 5, 1));
40 $info['lpac']['total_samples']= getid3_lib::BigEndian2Int(substr($LPACheader, 6, 4));
41 $flags['parameters'] = getid3_lib::BigEndian2Int(substr($LPACheader, 10, 4));
42
43 $info['lpac']['flags']['is_wave'] = (bool) ($flags['audio_type'] & 0x40);
44 $info['lpac']['flags']['stereo'] = (bool) ($flags['audio_type'] & 0x04);
45 $info['lpac']['flags']['24_bit'] = (bool) ($flags['audio_type'] & 0x02);
46 $info['lpac']['flags']['16_bit'] = (bool) ($flags['audio_type'] & 0x01);
47
48 if ($info['lpac']['flags']['24_bit'] && $info['lpac']['flags']['16_bit']) {
49 $info['warning'][] = '24-bit and 16-bit flags cannot both be set';
50 }
51
52 $info['lpac']['flags']['fast_compress'] = (bool) ($flags['parameters'] & 0x40000000);
53 $info['lpac']['flags']['random_access'] = (bool) ($flags['parameters'] & 0x08000000);
54 $info['lpac']['block_length'] = pow(2, (($flags['parameters'] & 0x07000000) >> 24)) * 256;
55 $info['lpac']['flags']['adaptive_prediction_order'] = (bool) ($flags['parameters'] & 0x00800000);
56 $info['lpac']['flags']['adaptive_quantization'] = (bool) ($flags['parameters'] & 0x00400000);
57 $info['lpac']['flags']['joint_stereo'] = (bool) ($flags['parameters'] & 0x00040000);
58 $info['lpac']['quantization'] = ($flags['parameters'] & 0x00001F00) >> 8;
59 $info['lpac']['max_prediction_order'] = ($flags['parameters'] & 0x0000003F);
60
61 if ($info['lpac']['flags']['fast_compress'] && ($info['lpac']['max_prediction_order'] != 3)) {
62 $info['warning'][] = 'max_prediction_order expected to be "3" if fast_compress is true, actual value is "'.$info['lpac']['max_prediction_order'].'"';
63 }
64 switch ($info['lpac']['file_version']) {
65 case 6:
66 if ($info['lpac']['flags']['adaptive_quantization']) {
67 $info['warning'][] = 'adaptive_quantization expected to be false in LPAC file stucture v6, actually true';
68 }
69 if ($info['lpac']['quantization'] != 20) {
70 $info['warning'][] = 'Quantization expected to be 20 in LPAC file stucture v6, actually '.$info['lpac']['flags']['Q'];
71 }
72 break;
73
74 default:
75 //$info['warning'][] = 'This version of getID3() ['.$this->getid3->version().'] only supports LPAC file format version 6, this file is version '.$info['lpac']['file_version'].' - please report to info@getid3.org';
76 break;
77 }
78
79 $getid3_temp = new getID3();
80 $getid3_temp->openfile($this->getid3->filename);
81 $getid3_temp->info = $info;
82 $getid3_riff = new getid3_riff($getid3_temp);
83 $getid3_riff->Analyze();
84 $info['avdataoffset'] = $getid3_temp->info['avdataoffset'];
85 $info['riff'] = $getid3_temp->info['riff'];
86 $info['error'] = $getid3_temp->info['error'];
87 $info['warning'] = $getid3_temp->info['warning'];
88 $info['lpac']['comments']['comment'] = $getid3_temp->info['comments'];
89 $info['audio']['sample_rate'] = $getid3_temp->info['audio']['sample_rate'];
90 unset($getid3_temp, $getid3_riff);
91
92 $info['audio']['channels'] = ($info['lpac']['flags']['stereo'] ? 2 : 1);
93
94 if ($info['lpac']['flags']['24_bit']) {
95 $info['audio']['bits_per_sample'] = $info['riff']['audio'][0]['bits_per_sample'];
96 } elseif ($info['lpac']['flags']['16_bit']) {
97 $info['audio']['bits_per_sample'] = 16;
98 } else {
99 $info['audio']['bits_per_sample'] = 8;
100 }
101
102 if ($info['lpac']['flags']['fast_compress']) {
103 // fast
104 $info['audio']['encoder_options'] = '-1';
105 } else {
106 switch ($info['lpac']['max_prediction_order']) {
107 case 20: // simple
108 $info['audio']['encoder_options'] = '-2';
109 break;
110 case 30: // medium
111 $info['audio']['encoder_options'] = '-3';
112 break;
113 case 40: // high
114 $info['audio']['encoder_options'] = '-4';
115 break;
116 case 60: // extrahigh
117 $info['audio']['encoder_options'] = '-5';
118 break;
119 }
120 }
121
122 $info['playtime_seconds'] = $info['lpac']['total_samples'] / $info['audio']['sample_rate'];
123 $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
124
125 return true;
126 }
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
fread($bytes)
Definition: getid3.php:1685
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
$info
Definition: example_052.php:80

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

+ Here is the call graph for this function:

◆ getid3_lpac()

getid3_lpac::getid3_lpac ( $fd,
$ThisFileInfo 
)

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

21 {
22
23 fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
24 $LPACheader = fread($fd, 14);
25 if (substr($LPACheader, 0, 4) != 'LPAC') {
26 $ThisFileInfo['error'][] = 'Expected "LPAC" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$StreamMarker.'"';
27 return false;
28 }
29 $ThisFileInfo['avdataoffset'] += 14;
30
31 $ThisFileInfo['fileformat'] = 'lpac';
32 $ThisFileInfo['audio']['dataformat'] = 'lpac';
33 $ThisFileInfo['audio']['lossless'] = true;
34 $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
35
36 $ThisFileInfo['lpac']['file_version'] = getid3_lib::BigEndian2Int(substr($LPACheader, 4, 1));
37 $flags['audio_type'] = getid3_lib::BigEndian2Int(substr($LPACheader, 5, 1));
38 $ThisFileInfo['lpac']['total_samples']= getid3_lib::BigEndian2Int(substr($LPACheader, 6, 4));
39 $flags['parameters'] = getid3_lib::BigEndian2Int(substr($LPACheader, 10, 4));
40
41 $ThisFileInfo['lpac']['flags']['is_wave'] = (bool) ($flags['audio_type'] & 0x40);
42 $ThisFileInfo['lpac']['flags']['stereo'] = (bool) ($flags['audio_type'] & 0x04);
43 $ThisFileInfo['lpac']['flags']['24_bit'] = (bool) ($flags['audio_type'] & 0x02);
44 $ThisFileInfo['lpac']['flags']['16_bit'] = (bool) ($flags['audio_type'] & 0x01);
45
46 if ($ThisFileInfo['lpac']['flags']['24_bit'] && $ThisFileInfo['lpac']['flags']['16_bit']) {
47 $ThisFileInfo['warning'][] = '24-bit and 16-bit flags cannot both be set';
48 }
49
50 $ThisFileInfo['lpac']['flags']['fast_compress'] = (bool) ($flags['parameters'] & 0x40000000);
51 $ThisFileInfo['lpac']['flags']['random_access'] = (bool) ($flags['parameters'] & 0x08000000);
52 $ThisFileInfo['lpac']['block_length'] = pow(2, (($flags['parameters'] & 0x07000000) >> 24)) * 256;
53 $ThisFileInfo['lpac']['flags']['adaptive_prediction_order'] = (bool) ($flags['parameters'] & 0x00800000);
54 $ThisFileInfo['lpac']['flags']['adaptive_quantization'] = (bool) ($flags['parameters'] & 0x00400000);
55 $ThisFileInfo['lpac']['flags']['joint_stereo'] = (bool) ($flags['parameters'] & 0x00040000);
56 $ThisFileInfo['lpac']['quantization'] = ($flags['parameters'] & 0x00001F00) >> 8;
57 $ThisFileInfo['lpac']['max_prediction_order'] = ($flags['parameters'] & 0x0000003F);
58
59 if ($ThisFileInfo['lpac']['flags']['fast_compress'] && ($ThisFileInfo['lpac']['max_prediction_order'] != 3)) {
60 $ThisFileInfo['warning'][] = 'max_prediction_order expected to be "3" if fast_compress is true, actual value is "'.$ThisFileInfo['lpac']['max_prediction_order'].'"';
61 }
62 switch ($ThisFileInfo['lpac']['file_version']) {
63 case 6:
64 if ($ThisFileInfo['lpac']['flags']['adaptive_quantization']) {
65 $ThisFileInfo['warning'][] = 'adaptive_quantization expected to be false in LPAC file stucture v6, actually true';
66 }
67 if ($ThisFileInfo['lpac']['quantization'] != 20) {
68 $ThisFileInfo['warning'][] = 'Quantization expected to be 20 in LPAC file stucture v6, actually '.$ThisFileInfo['lpac']['flags']['Q'];
69 }
70 break;
71
72 default:
73 //$ThisFileInfo['warning'][] = 'This version of getID3() only supports LPAC file format version 6, this file is version '.$ThisFileInfo['lpac']['file_version'].' - please report to info@getid3.org';
74 break;
75 }
76
77 $dummy = $ThisFileInfo;
78 $riff = new getid3_riff($fd, $dummy);
79 $ThisFileInfo['avdataoffset'] = $dummy['avdataoffset'];
80 $ThisFileInfo['riff'] = $dummy['riff'];
81 $ThisFileInfo['error'] = $dummy['error'];
82 $ThisFileInfo['warning'] = $dummy['warning'];
83 $ThisFileInfo['lpac']['comments']['comment'] = $dummy['comments'];
84 $ThisFileInfo['audio']['sample_rate'] = $dummy['audio']['sample_rate'];
85
86 $ThisFileInfo['audio']['channels'] = ($ThisFileInfo['lpac']['flags']['stereo'] ? 2 : 1);
87
88 if ($ThisFileInfo['lpac']['flags']['24_bit']) {
89 $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['riff']['audio'][0]['bits_per_sample'];
90 } elseif ($ThisFileInfo['lpac']['flags']['16_bit']) {
91 $ThisFileInfo['audio']['bits_per_sample'] = 16;
92 } else {
93 $ThisFileInfo['audio']['bits_per_sample'] = 8;
94 }
95
96 if ($ThisFileInfo['lpac']['flags']['fast_compress']) {
97 // fast
98 $ThisFileInfo['audio']['encoder_options'] = '-1';
99 } else {
100 switch ($ThisFileInfo['lpac']['max_prediction_order']) {
101 case 20: // simple
102 $ThisFileInfo['audio']['encoder_options'] = '-2';
103 break;
104 case 30: // medium
105 $ThisFileInfo['audio']['encoder_options'] = '-3';
106 break;
107 case 40: // high
108 $ThisFileInfo['audio']['encoder_options'] = '-4';
109 break;
110 case 60: // extrahigh
111 $ThisFileInfo['audio']['encoder_options'] = '-5';
112 break;
113 }
114 }
115
116 $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['lpac']['total_samples'] / $ThisFileInfo['audio']['sample_rate'];
117 $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
118
119 return true;
120 }

References getid3_lib\BigEndian2Int(), getid3_handler\fread(), and getid3_handler\fseek().

+ Here is the call graph for this function:

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