22 {
23 $info = &$this->getid3->info;
24
25 $info[
'fileformat'] =
'dsf';
26 $info[
'audio'][
'dataformat'] =
'dsf';
27 $info[
'audio'][
'lossless'] =
true;
28 $info[
'audio'][
'bitrate_mode'] =
'cbr';
29
31 $dsfheader = $this->
fread(28 + 12);
32
33 $headeroffset = 0;
34 $info[
'dsf'][
'dsd'][
'magic'] = substr($dsfheader, $headeroffset, 4);
35 $headeroffset += 4;
36 $magic = 'DSD ';
37 if (
$info[
'dsf'][
'dsd'][
'magic'] != $magic) {
39 unset(
$info[
'fileformat']);
40 unset(
$info[
'audio']);
42 return false;
43 }
45 $headeroffset += 8;
47 $headeroffset += 8;
49 $headeroffset += 8;
50
51
52 $info[
'dsf'][
'fmt'][
'magic'] = substr($dsfheader, $headeroffset, 4);
53 $headeroffset += 4;
54 $magic = 'fmt ';
55 if (
$info[
'dsf'][
'fmt'][
'magic'] != $magic) {
57 return false;
58 }
60 $headeroffset += 8;
61 $dsfheader .= $this->
fread(
$info[
'dsf'][
'fmt'][
'fmt_chunk_size'] - 12 + 12);
62 if (strlen($dsfheader) != (
$info[
'dsf'][
'dsd'][
'dsd_chunk_size'] +
$info[
'dsf'][
'fmt'][
'fmt_chunk_size'] + 12)) {
63 $this->
error(
'Expecting '.(
$info[
'dsf'][
'dsd'][
'dsd_chunk_size'] +
$info[
'dsf'][
'fmt'][
'fmt_chunk_size']).
' bytes header, found '.strlen($dsfheader).
' bytes');
64 return false;
65 }
67 $headeroffset += 4;
69 $headeroffset += 4;
71 $headeroffset += 4;
73 $headeroffset += 4;
75 $headeroffset += 4;
77 $headeroffset += 4;
79 $headeroffset += 8;
81 $headeroffset += 4;
83 $headeroffset += 4;
84
85
86 $info[
'dsf'][
'data'][
'magic'] = substr($dsfheader, $headeroffset, 4);
87 $headeroffset += 4;
88 $magic = 'data';
89 if (
$info[
'dsf'][
'data'][
'magic'] != $magic) {
91 return false;
92 }
94 $headeroffset += 8;
95 $info[
'avdataoffset'] = $headeroffset;
96 $info[
'avdataend'] =
$info[
'avdataoffset'] +
$info[
'dsf'][
'data'][
'data_chunk_size'];
97
98
99 if (
$info[
'dsf'][
'dsd'][
'meta_chunk_offset'] > 0) {
101 $getid3_id3v2->StartingOffset =
$info[
'dsf'][
'dsd'][
'meta_chunk_offset'];
102 $getid3_id3v2->Analyze();
103 unset($getid3_id3v2);
104 }
105
106
108 $info[
'audio'][
'channelmode'] =
$info[
'dsf'][
'fmt'][
'channel_type'];
109 $info[
'audio'][
'bits_per_sample'] =
$info[
'dsf'][
'fmt'][
'bits_per_sample'];
110 $info[
'audio'][
'sample_rate'] =
$info[
'dsf'][
'fmt'][
'sample_rate'];
111 $info[
'audio'][
'channels'] =
$info[
'dsf'][
'fmt'][
'channels'];
112 $info[
'audio'][
'bitrate'] =
$info[
'audio'][
'bits_per_sample'] *
$info[
'audio'][
'sample_rate'] *
$info[
'audio'][
'channels'];
113 $info[
'playtime_seconds'] = (
$info[
'dsf'][
'data'][
'data_chunk_size'] * 8) /
$info[
'audio'][
'bitrate'];
114
115 return true;
116 }
static DSFchannelTypeLookup($channel_type_id)
fseek($bytes, $whence=SEEK_SET)
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
static LittleEndian2Int($byteword, $signed=false)