39 $info = &$this->getid3->info;
43 $thisfile_bonk = &
$info[
'bonk'];
45 $thisfile_bonk[
'dataoffset'] =
$info[
'avdataoffset'];
46 $thisfile_bonk[
'dataend'] =
$info[
'avdataend'];
50 $info[
'warning'][] =
'Unable to parse BONK file from end (v0.6+ preferred method) because PHP filesystem functions only support up to '.round(PHP_INT_MAX / 1073741824).
'GB';
55 fseek($this->getid3->fp, $thisfile_bonk[
'dataend'] - 8, SEEK_SET);
56 $PossibleBonkTag =
fread($this->getid3->fp, 8);
59 fseek($this->getid3->fp, 0 - $BonkTagSize, SEEK_CUR);
60 $BonkTagOffset =
ftell($this->getid3->fp);
61 $TagHeaderTest =
fread($this->getid3->fp, 5);
62 if (($TagHeaderTest{0} !=
"\x00") || (substr($PossibleBonkTag, 4, 4) != strtolower(substr($PossibleBonkTag, 4, 4)))) {
63 $info[
'error'][] =
'Expecting "'.Helper::PrintHexBytes(
"\x00".strtoupper(substr($PossibleBonkTag, 4, 4))).
'" at offset '.$BonkTagOffset.
', found "'.
Helper::PrintHexBytes($TagHeaderTest).
'"';
67 $BonkTagName = substr($TagHeaderTest, 1, 4);
69 $thisfile_bonk[$BonkTagName][
'size'] = $BonkTagSize;
70 $thisfile_bonk[$BonkTagName][
'offset'] = $BonkTagOffset;
72 $NextTagEndOffset = $BonkTagOffset - 8;
73 if ($NextTagEndOffset < $thisfile_bonk[
'dataoffset']) {
74 if (empty(
$info[
'audio'][
'encoder'])) {
75 $info[
'audio'][
'encoder'] =
'Extended BONK v0.9+';
80 fseek($this->getid3->fp, $NextTagEndOffset, SEEK_SET);
81 $PossibleBonkTag =
fread($this->getid3->fp, 8);
87 if (empty($thisfile_bonk[
'BONK'])) {
88 fseek($this->getid3->fp, $thisfile_bonk[
'dataoffset'], SEEK_SET);
90 $TagHeaderTest =
fread($this->getid3->fp, 5);
91 switch ($TagHeaderTest) {
93 if (empty(
$info[
'audio'][
'encoder'])) {
94 $info[
'audio'][
'encoder'] =
'BONK v0.4';
99 $info[
'audio'][
'encoder'] =
'Extended BONK v0.5';
105 $BonkTagName = substr($TagHeaderTest, 1, 4);
106 $thisfile_bonk[$BonkTagName][
'size'] = $thisfile_bonk[
'dataend'] - $thisfile_bonk[
'dataoffset'];
107 $thisfile_bonk[$BonkTagName][
'offset'] = $thisfile_bonk[
'dataoffset'];
114 if (empty($thisfile_bonk[
'INFO']) && isset($thisfile_bonk[
'META'][
'tags'][
'info'])) {
115 fseek($this->getid3->fp, $thisfile_bonk[
'META'][
'tags'][
'info'], SEEK_SET);
116 $TagHeaderTest =
fread($this->getid3->fp, 5);
117 if ($TagHeaderTest ==
"\x00".
'INFO') {
118 $info[
'audio'][
'encoder'] =
'Extended BONK v0.6 - v0.8';
120 $BonkTagName = substr($TagHeaderTest, 1, 4);
121 $thisfile_bonk[$BonkTagName][
'size'] = $thisfile_bonk[
'dataend'] - $thisfile_bonk[
'dataoffset'];
122 $thisfile_bonk[$BonkTagName][
'offset'] = $thisfile_bonk[
'dataoffset'];
127 if (empty(
$info[
'audio'][
'encoder'])) {
128 $info[
'audio'][
'encoder'] =
'Extended BONK v0.9+';
130 if (empty($thisfile_bonk[
'BONK'])) {
131 unset(
$info[
'bonk']);
144 $info = &$this->getid3->info;
145 switch ($BonkTagName) {
148 $thisfile_bonk_BONK = &
$info[
'bonk'][
'BONK'];
150 $BonkData =
"\x00".
'BONK'.
fread($this->getid3->fp, 17);
162 $info[
'avdataoffset'] = $thisfile_bonk_BONK[
'offset'] + 5 + 17;
163 $info[
'avdataend'] = $thisfile_bonk_BONK[
'offset'] + $thisfile_bonk_BONK[
'size'];
165 $info[
'fileformat'] =
'bonk';
166 $info[
'audio'][
'dataformat'] =
'bonk';
167 $info[
'audio'][
'bitrate_mode'] =
'vbr';
168 $info[
'audio'][
'channels'] = $thisfile_bonk_BONK[
'channels'];
169 $info[
'audio'][
'sample_rate'] = $thisfile_bonk_BONK[
'sample_rate'];
170 $info[
'audio'][
'channelmode'] = ($thisfile_bonk_BONK[
'joint_stereo'] ?
'joint stereo' :
'stereo');
171 $info[
'audio'][
'lossless'] = $thisfile_bonk_BONK[
'lossless'];
172 $info[
'audio'][
'codec'] =
'bonk';
174 $info[
'playtime_seconds'] = $thisfile_bonk_BONK[
'number_samples'] / ($thisfile_bonk_BONK[
'sample_rate'] * $thisfile_bonk_BONK[
'channels']);
175 if (
$info[
'playtime_seconds'] > 0) {
176 $info[
'audio'][
'bitrate'] = ((
$info[
'bonk'][
'dataend'] -
$info[
'bonk'][
'dataoffset']) * 8) /
$info[
'playtime_seconds'];
182 $thisfile_bonk_INFO = &
$info[
'bonk'][
'INFO'];
185 $thisfile_bonk_INFO[
'entries_count'] = 0;
186 $NextInfoDataPair =
fread($this->getid3->fp, 5);
188 while (!
feof($this->getid3->fp)) {
193 $NextInfoDataPair =
fread($this->getid3->fp, 5);
195 fseek($this->getid3->fp, -5, SEEK_CUR);
198 $thisfile_bonk_INFO[
'entries_count']++;
204 $BonkData =
"\x00".
'META'.
fread($this->getid3->fp,
$info[
'bonk'][
'META'][
'size'] - 5);
207 $MetaTagEntries = floor(((strlen($BonkData) - 8) - 6) / 8);
209 for ($i = 0; $i < $MetaTagEntries; $i++) {
210 $MetaEntryTagName = substr($BonkData, $offset, 4);
214 $info[
'bonk'][
'META'][
'tags'][$MetaEntryTagName] = $MetaEntryTagOffset;
219 $info[
'audio'][
'encoder'] =
'Extended BONK v0.9+';
222 if (class_exists(
'GetId3\\Module\\Tag\\Id3v2')) {
224 $getid3_temp->openfile($this->getid3->filename);
225 $getid3_id3v2 =
new Id3v2($getid3_temp);
226 $getid3_id3v2->StartingOffset =
$info[
'bonk'][
' ID3'][
'offset'] + 2;
227 $info[
'bonk'][
' ID3'][
'valid'] = $getid3_id3v2->analyze();
228 if (
$info[
'bonk'][
' ID3'][
'valid']) {
229 $info[
'id3v2'] = $getid3_temp->info[
'id3v2'];
231 unset($getid3_temp, $getid3_id3v2);
236 $info[
'warning'][] =
'Unexpected Bonk tag "'.$BonkTagName.
'" at offset '.
$info[
'bonk'][$BonkTagName][
'offset'];
251 static $BonkIsValidTagName =
array(
'BONK',
'INFO',
' ID3',
'META');
252 foreach ($BonkIsValidTagName as $validtagname) {
253 if ($validtagname == $PossibleBonkTag) {
255 } elseif ($ignorecase && (strtolower($validtagname) == strtolower($PossibleBonkTag))) {
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
HandleBonkTags($BonkTagName)
GetId3() by James Heinrich info@getid3.org //.
GetId3() by James Heinrich info@getid3.org //.
GetId3() by James Heinrich info@getid3.org //.
fseek($bytes, $whence=SEEK_SET)
GetId3() by James Heinrich info@getid3.org //.
Create styles array
The data for the language used.
static BonkIsValidTagName($PossibleBonkTag, $ignorecase=false)
array $BonkIsValidTagName
static LittleEndian2Int($byteword, $signed=false)
static intValueSupported($num)
null $hasINT64