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.
'"';
29 $ThisFileInfo[
'avdataoffset'] += 14;
31 $ThisFileInfo[
'fileformat'] =
'lpac';
32 $ThisFileInfo[
'audio'][
'dataformat'] =
'lpac';
33 $ThisFileInfo[
'audio'][
'lossless'] =
true;
34 $ThisFileInfo[
'audio'][
'bitrate_mode'] =
'vbr';
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);
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';
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);
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'].
'"';
62 switch ($ThisFileInfo[
'lpac'][
'file_version']) {
64 if ($ThisFileInfo[
'lpac'][
'flags'][
'adaptive_quantization']) {
65 $ThisFileInfo[
'warning'][] =
'adaptive_quantization expected to be false in LPAC file stucture v6, actually true';
67 if ($ThisFileInfo[
'lpac'][
'quantization'] != 20) {
68 $ThisFileInfo[
'warning'][] =
'Quantization expected to be 20 in LPAC file stucture v6, actually '.$ThisFileInfo[
'lpac'][
'flags'][
'Q'];
77 $dummy = $ThisFileInfo;
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'];
86 $ThisFileInfo[
'audio'][
'channels'] = ($ThisFileInfo[
'lpac'][
'flags'][
'stereo'] ? 2 : 1);
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;
93 $ThisFileInfo[
'audio'][
'bits_per_sample'] = 8;
96 if ($ThisFileInfo[
'lpac'][
'flags'][
'fast_compress']) {
98 $ThisFileInfo[
'audio'][
'encoder_options'] =
'-1';
100 switch ($ThisFileInfo[
'lpac'][
'max_prediction_order']) {
102 $ThisFileInfo[
'audio'][
'encoder_options'] =
'-2';
105 $ThisFileInfo[
'audio'][
'encoder_options'] =
'-3';
108 $ThisFileInfo[
'audio'][
'encoder_options'] =
'-4';
111 $ThisFileInfo[
'audio'][
'encoder_options'] =
'-5';
116 $ThisFileInfo[
'playtime_seconds'] = $ThisFileInfo[
'lpac'][
'total_samples'] / $ThisFileInfo[
'audio'][
'sample_rate'];
117 $ThisFileInfo[
'audio'][
'bitrate'] = (($ThisFileInfo[
'avdataend'] - $ThisFileInfo[
'avdataoffset']) * 8) / $ThisFileInfo[
'playtime_seconds'];