23 $info = &$this->getid3->info;
26 $LPACheader = $this->
fread(14);
27 if (substr($LPACheader, 0, 4) !=
'LPAC') {
28 $this->
error(
'Expected "LPAC" at offset '.
$info[
'avdataoffset'].
', found "'.$StreamMarker.
'"');
31 $info[
'avdataoffset'] += 14;
33 $info[
'fileformat'] =
'lpac';
34 $info[
'audio'][
'dataformat'] =
'lpac';
35 $info[
'audio'][
'lossless'] =
true;
36 $info[
'audio'][
'bitrate_mode'] =
'vbr';
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);
48 if (
$info[
'lpac'][
'flags'][
'24_bit'] &&
$info[
'lpac'][
'flags'][
'16_bit']) {
49 $this->
warning(
'24-bit and 16-bit flags cannot both be set');
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);
61 if (
$info[
'lpac'][
'flags'][
'fast_compress'] && (
$info[
'lpac'][
'max_prediction_order'] != 3)) {
62 $this->
warning(
'max_prediction_order expected to be "3" if fast_compress is true, actual value is "'.
$info[
'lpac'][
'max_prediction_order'].
'"');
64 switch (
$info[
'lpac'][
'file_version']) {
66 if (
$info[
'lpac'][
'flags'][
'adaptive_quantization']) {
67 $this->
warning(
'adaptive_quantization expected to be false in LPAC file stucture v6, actually true');
69 if (
$info[
'lpac'][
'quantization'] != 20) {
70 $this->
warning(
'Quantization expected to be 20 in LPAC file stucture v6, actually '.
$info[
'lpac'][
'flags'][
'Q']);
79 $getid3_temp =
new getID3();
80 $getid3_temp->openfile($this->getid3->filename);
81 $getid3_temp->info =
$info;
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);
92 $info[
'audio'][
'channels'] = (
$info[
'lpac'][
'flags'][
'stereo'] ? 2 : 1);
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;
99 $info[
'audio'][
'bits_per_sample'] = 8;
102 if (
$info[
'lpac'][
'flags'][
'fast_compress']) {
104 $info[
'audio'][
'encoder_options'] =
'-1';
106 switch (
$info[
'lpac'][
'max_prediction_order']) {
108 $info[
'audio'][
'encoder_options'] =
'-2';
111 $info[
'audio'][
'encoder_options'] =
'-3';
114 $info[
'audio'][
'encoder_options'] =
'-4';
117 $info[
'audio'][
'encoder_options'] =
'-5';
122 $info[
'playtime_seconds'] =
$info[
'lpac'][
'total_samples'] /
$info[
'audio'][
'sample_rate'];
123 $info[
'audio'][
'bitrate'] = ((
$info[
'avdataend'] -
$info[
'avdataoffset']) * 8) /
$info[
'playtime_seconds'];
static IncludeDependency($filename, $sourcefile, $DieOnFailure=false)
fseek($bytes, $whence=SEEK_SET)
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)