41 $info = &$this->getid3->info;
43 $info[
'fileformat'] =
'ofr';
44 $info[
'audio'][
'dataformat'] =
'ofr';
45 $info[
'audio'][
'bitrate_mode'] =
'vbr';
46 $info[
'audio'][
'lossless'] =
true;
48 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
49 $OFRheader =
fread($this->getid3->fp, 8);
50 if (substr($OFRheader, 0, 5) ==
'*RIFF') {
53 } elseif (substr($OFRheader, 0, 3) ==
'OFR') {
58 $info[
'error'][] =
'Expecting "*RIFF" or "OFR " at offset '.$info[
'avdataoffset'].
', found "'.
Helper::PrintHexBytes($OFRheader).
'"';
59 unset(
$info[
'fileformat']);
72 $info = &$this->getid3->info;
73 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
74 $OptimFROGheaderData =
fread($this->getid3->fp, 45);
75 $info[
'avdataoffset'] = 45;
78 $OptimFROGencoderVersion_major = floor($OptimFROGencoderVersion_raw / 10);
79 $OptimFROGencoderVersion_minor = $OptimFROGencoderVersion_raw - ($OptimFROGencoderVersion_major * 10);
80 $RIFFdata = substr($OptimFROGheaderData, 1, 44);
84 if ($OrignalRIFFheaderSize > $OrignalRIFFdataSize) {
85 $info[
'avdataend'] -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
86 fseek($this->getid3->fp,
$info[
'avdataend'], SEEK_SET);
87 $RIFFdata .=
fread($this->getid3->fp, $OrignalRIFFheaderSize - $OrignalRIFFdataSize);
93 $RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8);
96 $getid3_temp->openfile($this->getid3->filename);
97 $getid3_temp->info[
'avdataoffset'] =
$info[
'avdataoffset'];
98 $getid3_temp->info[
'avdataend'] =
$info[
'avdataend'];
99 $getid3_riff =
new Riff($getid3_temp);
100 $getid3_riff->ParseRIFFdata($RIFFdata);
101 $info[
'riff'] = $getid3_temp->info[
'riff'];
103 $info[
'audio'][
'encoder'] =
'OptimFROG '.$OptimFROGencoderVersion_major.
'.'.$OptimFROGencoderVersion_minor;
104 $info[
'audio'][
'channels'] =
$info[
'riff'][
'audio'][0][
'channels'];
105 $info[
'audio'][
'sample_rate'] =
$info[
'riff'][
'audio'][0][
'sample_rate'];
106 $info[
'audio'][
'bits_per_sample'] =
$info[
'riff'][
'audio'][0][
'bits_per_sample'];
107 $info[
'playtime_seconds'] = $OrignalRIFFdataSize / (
$info[
'audio'][
'channels'] *
$info[
'audio'][
'sample_rate'] * (
$info[
'audio'][
'bits_per_sample'] / 8));
108 $info[
'audio'][
'bitrate'] = ((
$info[
'avdataend'] -
$info[
'avdataoffset']) * 8) /
$info[
'playtime_seconds'];
110 unset($getid3_riff, $getid3_temp, $RIFFdata);
123 $info = &$this->getid3->info;
125 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
126 while (!
feof($this->getid3->fp) && (
ftell($this->getid3->fp) <
$info[
'avdataend'])) {
127 $BlockOffset =
ftell($this->getid3->fp);
128 $BlockData =
fread($this->getid3->fp, 8);
130 $BlockName = substr($BlockData, 0, 4);
133 if ($BlockName ==
'OFRX') {
136 if (!isset(
$info[
'ofr'][$BlockName])) {
139 $thisfile_ofr_thisblock = &
$info[
'ofr'][$BlockName];
141 switch ($BlockName) {
145 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
146 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
148 $info[
'audio'][
'encoder'] =
'OptimFROG 4.50 alpha';
149 switch ($BlockSize) {
156 $info[
'warning'][] =
'"'.$BlockName.
'" contains more data than expected (expected 12 or 15 bytes, found '.$BlockSize.
' bytes)';
159 $BlockData .=
fread($this->getid3->fp, $BlockSize);
164 $thisfile_ofr_thisblock[
'sample_type'] = $this->
OptimFROGsampleTypeLookup($thisfile_ofr_thisblock[
'raw'][
'sample_type']);
167 $thisfile_ofr_thisblock[
'channels'] = $thisfile_ofr_thisblock[
'channel_config'];
172 if ($BlockSize > 12) {
181 $thisfile_ofr_thisblock[
'speedup'] = $this->
OptimFROGspeedupLookup($thisfile_ofr_thisblock[
'raw'][
'compression']);
184 $info[
'audio'][
'encoder'] =
'OptimFROG '.$thisfile_ofr_thisblock[
'encoder'];
185 $info[
'audio'][
'encoder_options'] =
'--mode '.$thisfile_ofr_thisblock[
'compression'];
187 if ((($thisfile_ofr_thisblock[
'raw'][
'encoder_id'] & 0xF0) >> 4) == 7) {
191 $info[
'audio'][
'dataformat'] =
'ofs';
192 $info[
'audio'][
'lossless'] =
true;
198 $info[
'audio'][
'channels'] = $thisfile_ofr_thisblock[
'channels'];
199 $info[
'audio'][
'sample_rate'] = $thisfile_ofr_thisblock[
'sample_rate'];
207 $COMPdata[
'offset'] = $BlockOffset;
208 $COMPdata[
'size'] = $BlockSize;
210 if (
$info[
'avdataoffset'] == 0) {
211 $info[
'avdataoffset'] = $BlockOffset;
215 $BlockData .=
fread($this->getid3->fp, 14);
216 fseek($this->getid3->fp, $BlockSize - 14, SEEK_CUR);
232 if (
$info[
'ofr'][
'OFR '][
'size'] > 12) {
241 if ($COMPdata[
'crc_32'] == 0x454E4F4E) {
243 $COMPdata[
'crc_32'] =
false;
246 $thisfile_ofr_thisblock[] = $COMPdata;
250 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
251 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
253 $RIFFdata .=
fread($this->getid3->fp, $BlockSize);
257 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
258 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
260 if ($BlockSize > 0) {
261 $RIFFdata .=
fread($this->getid3->fp, $BlockSize);
268 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
269 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
271 fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
278 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
279 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
280 $info[
'warning'][] =
'APEtag processing inside OptimFROG not supported in this version ('.$this->getid3->version().
') of GetId3Core()';
282 fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
289 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
290 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
292 if ($BlockSize == 16) {
294 $thisfile_ofr_thisblock[
'md5_binary'] =
fread($this->getid3->fp, $BlockSize);
295 $thisfile_ofr_thisblock[
'md5_string'] =
Helper::PrintHexBytes($thisfile_ofr_thisblock[
'md5_binary'],
true,
false,
false);
296 $info[
'md5_data_source'] = $thisfile_ofr_thisblock[
'md5_string'];
300 $info[
'warning'][] =
'Expecting block size of 16 in "MD5 " chunk, found '.$BlockSize.
' instead';
301 fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
308 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
309 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
311 $info[
'warning'][] =
'Unhandled OptimFROG block type "'.$BlockName.
'" at offset '.$thisfile_ofr_thisblock[
'offset'];
312 fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
316 if (isset(
$info[
'ofr'][
'TAIL'][
'offset'])) {
317 $info[
'avdataend'] =
$info[
'ofr'][
'TAIL'][
'offset'];
320 $info[
'playtime_seconds'] = (float)
$info[
'ofr'][
'OFR '][
'total_samples'] / (
$info[
'audio'][
'channels'] *
$info[
'audio'][
'sample_rate']);
321 $info[
'audio'][
'bitrate'] = (($info[
'avdataend'] - $info[
'avdataoffset']) * 8) / $info[
'playtime_seconds'];
326 $RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8);
329 $getid3_temp->openfile($this->getid3->filename);
330 $getid3_temp->info[
'avdataoffset'] = $info[
'avdataoffset'];
331 $getid3_temp->info[
'avdataend'] = $info[
'avdataend'];
332 $getid3_riff =
new Riff($getid3_temp);
333 $getid3_riff->ParseRIFFdata($RIFFdata);
334 $info[
'riff'] = $getid3_temp->info[
'riff'];
336 unset($getid3_riff, $getid3_temp, $RIFFdata);
349 static $OptimFROGsampleTypeLookup =
array(
350 0 =>
'unsigned int (8-bit)',
351 1 =>
'signed int (8-bit)',
352 2 =>
'unsigned int (16-bit)',
353 3 =>
'signed int (16-bit)',
354 4 =>
'unsigned int (24-bit)',
355 5 =>
'signed int (24-bit)',
356 6 =>
'unsigned int (32-bit)',
357 7 =>
'signed int (32-bit)',
358 8 =>
'float 0.24 (32-bit)',
359 9 =>
'float 16.8 (32-bit)',
360 10 =>
'float 24.0 (32-bit)' 363 return (isset($OptimFROGsampleTypeLookup[$SampleType]) ? $OptimFROGsampleTypeLookup[$SampleType] :
false);
374 static $OptimFROGbitsPerSampleTypeLookup =
array(
388 return (isset($OptimFROGbitsPerSampleTypeLookup[$SampleType]) ? $OptimFROGbitsPerSampleTypeLookup[$SampleType] :
false);
399 static $OptimFROGchannelConfigurationLookup =
array(
404 return (isset($OptimFROGchannelConfigurationLookup[$ChannelConfiguration]) ? $OptimFROGchannelConfigurationLookup[$ChannelConfiguration] :
false);
415 static $OptimFROGchannelConfigNumChannelsLookup =
array(
420 return (isset($OptimFROGchannelConfigNumChannelsLookup[$ChannelConfiguration]) ? $OptimFROGchannelConfigNumChannelsLookup[$ChannelConfiguration] :
false);
439 $EncoderVersion = number_format(((($EncoderID & 0xF0) >> 4) + 4500) / 1000, 3);
440 $EncoderSystemID = ($EncoderID & 0x0F);
442 static $OptimFROGencoderSystemLookup =
array(
443 0x00 =>
'Windows console',
444 0x01 =>
'Linux console',
448 return $EncoderVersion.
' ('.(isset($OptimFROGencoderSystemLookup[$EncoderSystemID]) ? $OptimFROGencoderSystemLookup[$EncoderSystemID] :
'undefined encoder type (0x'.dechex($EncoderSystemID).
')').
')';
462 $CompressionModeID = ($CompressionID & 0xF8) >> 3;
465 static $OptimFROGencoderModeLookup =
array(
478 return (isset($OptimFROGencoderModeLookup[$CompressionModeID]) ? $OptimFROGencoderModeLookup[$CompressionModeID] :
'undefined mode (0x'.str_pad(dechex($CompressionModeID), 2,
'0', STR_PAD_LEFT).
')');
493 $CompressionSpeedupID = ($CompressionID & 0x07);
495 static $OptimFROGencoderSpeedupLookup =
array(
501 return (isset($OptimFROGencoderSpeedupLookup[$CompressionSpeedupID]) ? $OptimFROGencoderSpeedupLookup[$CompressionSpeedupID] :
'undefined mode (0x'.dechex($CompressionSpeedupID));
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
GetId3() by James Heinrich info@getid3.org //.
static OptimFROGencoderNameLookup($EncoderID)
array $OptimFROGencoderSystemLookup
static OptimFROGbitsPerSampleTypeLookup($SampleType)
array $OptimFROGbitsPerSampleTypeLookup
static fileextension($filename, $numextensions=1)
GetId3() by James Heinrich info@getid3.org //.
fseek($bytes, $whence=SEEK_SET)
GetId3() by James Heinrich info@getid3.org //.
static OptimFROGchannelConfigurationLookup($ChannelConfiguration)
array $OptimFROGchannelConfigurationLookup
Create styles array
The data for the language used.
static OptimFROGspeedupLookup($CompressionID)
array $OptimFROGencoderSpeedupLookup
static OptimFROGchannelConfigNumChannelsLookup($ChannelConfiguration)
array $OptimFROGchannelConfigNumChannelsLookup
static LittleEndian2Int($byteword, $signed=false)
static OptimFROGcompressionLookup($CompressionID)
array $OptimFROGencoderModeLookup
GetId3() by James Heinrich info@getid3.org //.
static OptimFROGsampleTypeLookup($SampleType)
array $OptimFROGsampleTypeLookup